| 1 |  | 
|---|
| 2 | /* | 
|---|
| 3 | *@@sourcefile mapfile.h: | 
|---|
| 4 | *      header file for map_vac.c. | 
|---|
| 5 | * | 
|---|
| 6 | *      Note: Version numbering in this file relates to XWorkplace version | 
|---|
| 7 | *            numbering. | 
|---|
| 8 | * | 
|---|
| 9 | *@@include #include <os2.h> | 
|---|
| 10 | *@@include #include "helpers\linklist.h" | 
|---|
| 11 | *@@include #include "helpers\mapfile.h" | 
|---|
| 12 | */ | 
|---|
| 13 |  | 
|---|
| 14 | /*      Copyright (C) 2002 Ulrich Mller. | 
|---|
| 15 | *      This file is part of the "XWorkplace helpers" source package. | 
|---|
| 16 | *      This is free software; you can redistribute it and/or modify | 
|---|
| 17 | *      it under the terms of the GNU General Public License as published | 
|---|
| 18 | *      by the Free Software Foundation, in version 2 as it comes in the | 
|---|
| 19 | *      "COPYING" file of the XWorkplace main distribution. | 
|---|
| 20 | *      This program is distributed in the hope that it will be useful, | 
|---|
| 21 | *      but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 22 | *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 23 | *      GNU General Public License for more details. | 
|---|
| 24 | */ | 
|---|
| 25 |  | 
|---|
| 26 | #if __cplusplus | 
|---|
| 27 | extern "C" { | 
|---|
| 28 | #endif | 
|---|
| 29 |  | 
|---|
| 30 | #ifndef MAPFILE_HEADER_INCLUDED | 
|---|
| 31 | #define MAPFILE_HEADER_INCLUDED | 
|---|
| 32 |  | 
|---|
| 33 | /* ****************************************************************** | 
|---|
| 34 | * | 
|---|
| 35 | *   Errors | 
|---|
| 36 | * | 
|---|
| 37 | ********************************************************************/ | 
|---|
| 38 |  | 
|---|
| 39 | #define MAPERROR_FIRST                      10000 | 
|---|
| 40 | #define MAPERROR_NO_MODULE_NAME             (MAPERROR_FIRST) | 
|---|
| 41 | #define MAPERROR_SYNTAX_SEGMENTS_START      (MAPERROR_FIRST + 1) | 
|---|
| 42 | // cannot handle initial line in segments block; | 
|---|
| 43 | // line must have format | 
|---|
| 44 | // " 0001:00000000 000001630H FREQ_CODE1             CODE 32-bit" | 
|---|
| 45 | #define MAPERROR_SYNTAX_SEGMENTS_NOSEGNAME  (MAPERROR_FIRST + 2) | 
|---|
| 46 | // cannot find segment name | 
|---|
| 47 | #define MAPERROR_SYNTAX_SEGMENTS_SEGTYPE    (MAPERROR_FIRST + 3) | 
|---|
| 48 | // unknown segment type | 
|---|
| 49 | #define MAPERROR_SYNTAX_SEGMENTS_OTHER      (MAPERROR_FIRST + 4) | 
|---|
| 50 |  | 
|---|
| 51 | #define MAPERROR_SYNTAX_EXPORTS_OBJOFS      (MAPERROR_FIRST + 5) | 
|---|
| 52 | #define MAPERROR_SYNTAX_EXPORTS_NAME1       (MAPERROR_FIRST + 6) | 
|---|
| 53 | #define MAPERROR_SYNTAX_EXPORTS_OTHER       (MAPERROR_FIRST + 7) | 
|---|
| 54 |  | 
|---|
| 55 | #define MAPERROR_SYNTAX_PUBLICS_OBJOFS      (MAPERROR_FIRST + 8) | 
|---|
| 56 | #define MAPERROR_SYNTAX_PUBLICS_OTHER       (MAPERROR_FIRST + 9) | 
|---|
| 57 |  | 
|---|
| 58 | /* ****************************************************************** | 
|---|
| 59 | * | 
|---|
| 60 | *   Map definitions | 
|---|
| 61 | * | 
|---|
| 62 | ********************************************************************/ | 
|---|
| 63 |  | 
|---|
| 64 | /* | 
|---|
| 65 | *@@ SEGMENT: | 
|---|
| 66 | * | 
|---|
| 67 | */ | 
|---|
| 68 |  | 
|---|
| 69 | typedef struct _SEGMENT | 
|---|
| 70 | { | 
|---|
| 71 | ULONG   ulObjNo; | 
|---|
| 72 | ULONG   ulObjOfs; | 
|---|
| 73 | ULONG   cbSeg; | 
|---|
| 74 | CHAR    szSegName[30]; | 
|---|
| 75 | ULONG   ulType; | 
|---|
| 76 | #define SEGTYPE_CODE32      1   // CODE 32-bit | 
|---|
| 77 | #define SEGTYPE_CODE16      2   // CODE 16-bit | 
|---|
| 78 | #define SEGTYPE_CONST32     3   // CONST 32-bit | 
|---|
| 79 | #define SEGTYPE_DATA16      4   // DATA16 16-bit | 
|---|
| 80 | #define SEGTYPE_DATA32      5   // DATA 32-bit | 
|---|
| 81 | #define SEGTYPE_EDC_CLASS32 6   // EDC_CLASS 32-bit | 
|---|
| 82 | #define SEGTYPE_BSS32       7   // BSS 32-bit | 
|---|
| 83 | #define SEGTYPE_STACK32     8   // STACK 32-bit | 
|---|
| 84 |  | 
|---|
| 85 | } SEGMENT, *PSEGMENT; | 
|---|
| 86 |  | 
|---|
| 87 | /* | 
|---|
| 88 | *@@ EXPORT: | 
|---|
| 89 | * | 
|---|
| 90 | */ | 
|---|
| 91 |  | 
|---|
| 92 | typedef struct _EXPORT | 
|---|
| 93 | { | 
|---|
| 94 | ULONG   ulObjNo; | 
|---|
| 95 | ULONG   ulObjOfs; | 
|---|
| 96 |  | 
|---|
| 97 | ULONG   ulName1Len, | 
|---|
| 98 | ulName2Len; | 
|---|
| 99 | CHAR    szNames[1];         // ulName1Len chars, followed by \0, | 
|---|
| 100 | // followed by ulName2Len chars, followed by \0 | 
|---|
| 101 | } EXPORT, *PEXPORT; | 
|---|
| 102 |  | 
|---|
| 103 | /* | 
|---|
| 104 | *@@ PUBLIC: | 
|---|
| 105 | * | 
|---|
| 106 | */ | 
|---|
| 107 |  | 
|---|
| 108 | typedef struct _PUBLIC | 
|---|
| 109 | { | 
|---|
| 110 | ULONG   ulObjNo; | 
|---|
| 111 | ULONG   ulObjOfs; | 
|---|
| 112 |  | 
|---|
| 113 | ULONG   ulNameLen, | 
|---|
| 114 | ulImportLen; | 
|---|
| 115 |  | 
|---|
| 116 | ULONG   ulImportIndex;      // if ulImportLen != 0, the index from where | 
|---|
| 117 | // the thing was imported | 
|---|
| 118 |  | 
|---|
| 119 | CHAR    szName[1];          // ulNameLen chars, followed by \0, | 
|---|
| 120 | // and if ulImportLen != 0, followed | 
|---|
| 121 | // by ulImportLen chars, followed by \0 | 
|---|
| 122 |  | 
|---|
| 123 | } PUBLIC, *PPUBLIC; | 
|---|
| 124 |  | 
|---|
| 125 | /* | 
|---|
| 126 | *@@ MAPFILE: | 
|---|
| 127 | * | 
|---|
| 128 | */ | 
|---|
| 129 |  | 
|---|
| 130 | typedef struct _MAPFILE | 
|---|
| 131 | { | 
|---|
| 132 | CHAR        szModule[CCHMAXPATH]; | 
|---|
| 133 |  | 
|---|
| 134 | LINKLIST    llSegments; | 
|---|
| 135 | LINKLIST    llExports; | 
|---|
| 136 | LINKLIST    llPublics; | 
|---|
| 137 |  | 
|---|
| 138 | } MAPFILE, *PMAPFILE; | 
|---|
| 139 |  | 
|---|
| 140 | /* ****************************************************************** | 
|---|
| 141 | * | 
|---|
| 142 | *   Prototypes | 
|---|
| 143 | * | 
|---|
| 144 | ********************************************************************/ | 
|---|
| 145 |  | 
|---|
| 146 | APIRET mapvRead(PCSZ pcszMapFilename, | 
|---|
| 147 | PMAPFILE *ppMapFile, | 
|---|
| 148 | PSZ pszLineBuf, | 
|---|
| 149 | ULONG cbLineBuf, | 
|---|
| 150 | PULONG pulLineError); | 
|---|
| 151 |  | 
|---|
| 152 | APIRET mapvClose(PMAPFILE *ppMapFile); | 
|---|
| 153 |  | 
|---|
| 154 | #endif | 
|---|
| 155 |  | 
|---|
| 156 | #if __cplusplus | 
|---|
| 157 | } | 
|---|
| 158 | #endif | 
|---|
| 159 |  | 
|---|