1 |
|
---|
2 | #define OS2EMX_PLAIN_CHAR
|
---|
3 | // this is needed for "os2emx.h"; if this is defined,
|
---|
4 | // emx will define PSZ as _signed_ char, otherwise
|
---|
5 | // as unsigned char
|
---|
6 |
|
---|
7 | #define INCL_DOS
|
---|
8 | #define INCL_DOSERRORS
|
---|
9 | #include <os2.h>
|
---|
10 |
|
---|
11 | #include <stdlib.h>
|
---|
12 | #include <string.h>
|
---|
13 | #include <stdio.h>
|
---|
14 |
|
---|
15 | #include "setup.h" // code generation and debugging options
|
---|
16 |
|
---|
17 | #include "helpers\linklist.h"
|
---|
18 | #include "helpers\mapfile.h"
|
---|
19 | #include "helpers\stringh.h"
|
---|
20 | #include "helpers\standards.h"
|
---|
21 |
|
---|
22 | #pragma hdrstop
|
---|
23 |
|
---|
24 | /*
|
---|
25 | *@@ main:
|
---|
26 | *
|
---|
27 | */
|
---|
28 |
|
---|
29 | int main (int argc, char *argv[])
|
---|
30 | {
|
---|
31 | int rc;
|
---|
32 | PMAPFILE pMapFile;
|
---|
33 | ULONG ulLineError = 0;
|
---|
34 |
|
---|
35 | CHAR szLineBuf[2000] = "";
|
---|
36 |
|
---|
37 | if (argc < 2)
|
---|
38 | {
|
---|
39 | printf("Usage: map <mapfile>\n");
|
---|
40 | exit(1);
|
---|
41 | }
|
---|
42 |
|
---|
43 | if (!(rc = mapvRead(argv[1],
|
---|
44 | &pMapFile,
|
---|
45 | szLineBuf,
|
---|
46 | sizeof(szLineBuf),
|
---|
47 | &ulLineError)))
|
---|
48 | {
|
---|
49 | PLISTNODE pNode;
|
---|
50 |
|
---|
51 | printf("Map file for module \"%s\" successfully read\n",
|
---|
52 | pMapFile->szModule);
|
---|
53 |
|
---|
54 | printf("Found %d segments\n", lstCountItems(&pMapFile->llSegments));
|
---|
55 | FOR_ALL_NODES(&pMapFile->llSegments, pNode)
|
---|
56 | {
|
---|
57 | PSEGMENT pSeg = (PSEGMENT)pNode->pItemData;
|
---|
58 | printf(" \"%20s\" %04lX:%08lX (0x%lX bytes)\n",
|
---|
59 | pSeg->szSegName,
|
---|
60 | pSeg->ulObjNo,
|
---|
61 | pSeg->ulObjOfs,
|
---|
62 | pSeg->cbSeg);
|
---|
63 | }
|
---|
64 |
|
---|
65 | printf("Found %d exports\n", lstCountItems(&pMapFile->llExports));
|
---|
66 | FOR_ALL_NODES(&pMapFile->llExports, pNode)
|
---|
67 | {
|
---|
68 | PEXPORT pExp = (PEXPORT)pNode->pItemData;
|
---|
69 | printf(" %04lX:%08lX \"%s\" \"%s\"\n",
|
---|
70 | pExp->ulObjNo,
|
---|
71 | pExp->ulObjOfs,
|
---|
72 | pExp->szNames,
|
---|
73 | pExp->szNames + pExp->ulName1Len + 1);
|
---|
74 | }
|
---|
75 |
|
---|
76 | printf("Found %d public symbols\n", lstCountItems(&pMapFile->llPublics));
|
---|
77 | FOR_ALL_NODES(&pMapFile->llPublics, pNode)
|
---|
78 | {
|
---|
79 | PPUBLIC pPub = (PPUBLIC)pNode->pItemData;
|
---|
80 | if (pPub->ulImportLen)
|
---|
81 | printf(" %04lX:%08lX \"%s\" (%s.%d)\n",
|
---|
82 | pPub->ulObjNo,
|
---|
83 | pPub->ulObjOfs,
|
---|
84 | pPub->szName,
|
---|
85 | pPub->szName + pPub->ulNameLen + 1,
|
---|
86 | pPub->ulImportIndex);
|
---|
87 | else
|
---|
88 | printf(" %04lX:%08lX \"%s\"\n",
|
---|
89 | pPub->ulObjNo,
|
---|
90 | pPub->ulObjOfs,
|
---|
91 | pPub->szName);
|
---|
92 | }
|
---|
93 |
|
---|
94 | mapvClose(&pMapFile);
|
---|
95 | }
|
---|
96 | else
|
---|
97 | {
|
---|
98 | printf("Error %d occurred at line %d\n", rc, ulLineError);
|
---|
99 | printf("Line buf: \"%s\"", szLineBuf);
|
---|
100 | }
|
---|
101 |
|
---|
102 | return rc;
|
---|
103 | }
|
---|
104 |
|
---|
105 |
|
---|
106 |
|
---|