Changeset 867 for trunk/tools/impdef/ImpDef.cpp
- Timestamp:
- Sep 8, 1999, 9:30:10 AM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/impdef/ImpDef.cpp
r842 r867 1 /* $Id: ImpDef.cpp,v 1. 2 1999-09-05 22:10:26bird Exp $ */1 /* $Id: ImpDef.cpp,v 1.3 1999-09-08 07:30:09 bird Exp $ */ 2 2 /* 3 3 * ImpDef - Create export file which use internal names and ordinals. … … 13 13 #include <stdio.h> 14 14 #include <string.h> 15 #include <stdlib.h> 15 16 #include "ImpDef.h" 16 17 #include "kFileFormatBase.h" … … 39 40 char *pszInput = NULL; 40 41 char *pszOutput = NULL; 41 OPTIONS options = {TRUE, FALSE};42 OPTIONS options = {TRUE, ORD_START_INTERNAL_FUNCTIONS, FALSE, TRUE}; 42 43 43 44 /************************************************************************** … … 46 47 * -S<[+]|-> Similar to exported. (stdcall) 47 48 * -O<[+]|-> Remove OS2 prefix on APIs. 49 * -I:<num> Start ordinal number of internal functions. 50 * -F<[+]|-> Export intname for internal stdcall functions. 48 51 **************************************************************************/ 49 52 if (argc == 1) … … 64 67 case 'O': 65 68 options.fRemoveOS2APIPrefix = argv[argi][2] != '-'; 69 break; 70 71 case 'i': 72 case 'I': 73 if (strlen(argv[argi]) >= 3) 74 { 75 options.ulOrdStartInternalFunctions = atol(&argv[argi][3]); 76 if (options.ulOrdStartInternalFunctions == 0) 77 fprintf(stderr, "warning: internal functions starts at ordinal 0!\n"); 78 } 79 else 80 { 81 fprintf(stderr, "incorrect parameter -I:<ord>. (argi=%d, argv[argi]=%s)\n", argi, argv[argi]); 82 fFatal = TRUE; 83 } 84 break; 85 86 case 'f': 87 case 'F': 88 options.fInternalFnExportStdCallsIntName = argv[argi][2] != '-'; 66 89 break; 67 90 … … 123 146 "syntax: ImpDef.exe [-h|-?] [-S] <infile> <outfile>\n" 124 147 " -h or -? Syntax help. (this)\n" 125 " -O<[+]|-> Remove OS2 prefix on APIs. default: O-\n" 126 " -S<[+]|-> Similar to exported name. default: S+\n" 148 " -F<[+]|-> Fix! Export int.name for int.functions. default: F+\n" 149 " -I:<ord> Start of internal function. default: I:%d\n" 150 " -O<[+]|-> Remove OS2 prefix on APIs. default: O-\n" 151 " -S<[+]|-> Similar to exported name. default: S+\n" 127 152 " infile Name of input file\n" 128 153 " outfile Name of output file\n" … … 134 159 " -O+ has no effect on stdcall functions when -S+ is set. -S+ has higher\n" 135 160 " precedence than -O+.\n" 136 " -O+ only removes the OS2 prefix from internal names.\n" 161 " -O+ only removes the OS2 prefix from internal names.\n", 162 ORD_START_INTERNAL_FUNCTIONS 137 163 ); 138 164 } … … 201 227 202 228 /* real work */ 203 if (pOptions->fSimilarToExported || pOptions->fRemoveOS2APIPrefix) 204 pszName = generateExportName(&export, &szName[0], pOptions); 205 else if (export.achIntName[0] != '\0') 206 pszName = &export.achIntName[0]; 207 else if (export.achName[0] != '\0') 208 pszName = &export.achName[0]; 229 pszName = generateExportName(&export, &szName[0], pOptions); 209 230 210 231 fprintf(phOutput, " %-*s @%ld\n", 40, pszName, export.ulOrdinal); … … 238 259 /** 239 260 * Generate export names according to options defines. 240 * fSimilarToExported only applies to stdcall functions.261 * fSimilarToExported only applies to stdcall API functions. 241 262 * fRemoveOS2APIPrefix only applies to APIs. 242 263 * fRemoveOS2APIPrefix have no effect on stdcall functions when fSimilarToExported is set. … … 252 273 static char *generateExportName(const PEXPORTENTRY pExport, char *pszBuffer, const POPTIONS pOptions) 253 274 { 254 if (pOptions->fSimilarToExported) 255 { 256 if (pExport->achIntName[0] != '\0') 257 { 258 char *pszAt = strchr(&pExport->achIntName[0], '@'); 259 if (pszAt != NULL && pExport->achIntName[0] == '_' && pExport->achName[0] != '"') 260 { /* stdcall - merge */ 261 strcpy(pszBuffer, "_"); 262 /* test for "reserved" definition file names (like HeapSize) in original def-file. */ 263 if (pExport->achName[0] != '"') 264 strcat(pszBuffer, &pExport->achName[0]); 265 else 266 { 267 strcat(pszBuffer, &pExport->achName[1]); 268 pszBuffer[strlen(pszBuffer)-1] = '\0'; //remove tail '"' 269 } 270 271 strcat(pszBuffer, pszAt); 272 } 273 else 274 { /* not a stdcall - no merge but check for OS2prefix */ 275 if (pOptions->fRemoveOS2APIPrefix && pExport->ulOrdinal < ORD_START_INTERNAL_FUNCTIONS) 276 { 277 int i = 0; 278 char *psz = pszBuffer; 279 if (pExport->achIntName[i] == '_') 280 *psz++ = pExport->achIntName[i++]; 281 if (strncmp(&pExport->achIntName[i], "OS2", 3) == 0) 282 i += 3; 283 strcpy(psz, &pExport->achIntName[i]); 275 if (pExport->ulOrdinal < pOptions->ulOrdStartInternalFunctions) 276 { 277 /* API */ 278 if (pOptions->fSimilarToExported) 279 { 280 if (pExport->achIntName[0] != '\0') 281 { 282 char *pszAt = strchr(&pExport->achIntName[0], '@'); 283 if (pszAt != NULL && pExport->achIntName[0] == '_' && pExport->achName[0] != '"') 284 { /* stdcall - merge */ 285 strcpy(pszBuffer, "_"); 286 /* test for "reserved" definition file names (like HeapSize) in original def-file. */ 287 if (pExport->achName[0] != '"') 288 strcat(pszBuffer, &pExport->achName[0]); 289 else 290 { 291 strcat(pszBuffer, &pExport->achName[1]); 292 pszBuffer[strlen(pszBuffer)-1] = '\0'; //remove tail '"' 293 } 294 295 strcat(pszBuffer, pszAt); 284 296 } 285 297 else 286 strcpy(pszBuffer, &pExport->achIntName[0]); 287 } 298 { /* not a stdcall - no merge but check for OS2prefix */ 299 if (pOptions->fRemoveOS2APIPrefix) 300 { 301 int i = 0; 302 char *psz = pszBuffer; 303 if (pExport->achIntName[i] == '_') 304 *psz++ = pExport->achIntName[i++]; 305 if (strncmp(&pExport->achIntName[i], "OS2", 3) == 0) 306 i += 3; 307 strcpy(psz, &pExport->achIntName[i]); 308 } 309 else 310 strcpy(pszBuffer, &pExport->achIntName[0]); 311 } 312 } 313 else 314 strcpy(pszBuffer, &pExport->achName[0]); 315 } 316 else if (pOptions->fRemoveOS2APIPrefix) 317 { /* removes OS2 prefix */ 318 if (pExport->achIntName[0] != '\0') 319 { 320 int i = 0; 321 char *psz = pszBuffer; 322 if (pExport->achIntName[i] == '_') 323 *psz++ = pExport->achIntName[i++]; 324 if (strncmp(&pExport->achIntName[i], "OS2", 3) == 0) 325 i += 3; 326 strcpy(psz, &pExport->achIntName[i]); 327 } 328 else 329 strcpy(pszBuffer, &pExport->achName[0]); 288 330 } 289 331 else 290 strcpy(pszBuffer, &pExport->achName[0]); 291 } 292 else if (pOptions->fRemoveOS2APIPrefix && pExport->ulOrdinal < ORD_START_INTERNAL_FUNCTIONS) 293 { /* removes OS2 prefix */ 294 if (pExport->achIntName[0] != '\0') 295 { 296 int i = 0; 297 char *psz = pszBuffer; 298 if (pExport->achIntName[i] == '_') 299 *psz++ = pExport->achIntName[i++]; 300 if (strncmp(&pExport->achIntName[i], "OS2", 3) == 0) 301 i += 3; 302 strcpy(psz, &pExport->achIntName[i]); 303 } 304 else 305 strcpy(pszBuffer, &pExport->achName[0]); 332 if (pExport->achIntName[0] != '\0') 333 strcpy(pszBuffer, &pExport->achIntName[0]); 334 else 335 strcpy(pszBuffer, &pExport->achName[0]); 306 336 } 307 337 else 308 if (pExport->achIntName[0] != '\0') 338 { /* non-API functions */ 339 if ((pExport->achName[0] == '\0' || (pOptions->fInternalFnExportStdCallsIntName && strchr(&pExport->achIntName[0], '@'))) 340 && pExport->achIntName[0] != '\0' 341 ) 309 342 strcpy(pszBuffer, &pExport->achIntName[0]); 310 343 else 311 344 strcpy(pszBuffer, &pExport->achName[0]); 345 } 312 346 313 347 return pszBuffer;
Note:
See TracChangeset
for help on using the changeset viewer.