Changeset 2759 for trunk/tools/database/APIImport.cpp
- Timestamp:
- Feb 11, 2000, 7:35:55 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/database/APIImport.cpp
r830 r2759 1 /* $Id: APIImport.cpp,v 1. 1 1999-09-05 02:53:04bird Exp $ */1 /* $Id: APIImport.cpp,v 1.2 2000-02-11 18:35:53 bird Exp $ */ 2 2 /* 3 3 * 4 4 * APIImport - imports a DLL or Dll-.def with functions into the Odin32 database. 5 5 * 6 * Copyright (c) 1999 knut st. osmundsen6 * Copyright (c) 1999-2000 knut st. osmundsen 7 7 * 8 8 */ … … 34 34 static void openLog(void); 35 35 static void closeLog(void); 36 static long processFile(const char *pszFilename, const POPTIONS pOptions); 36 static long processFile(const char *pszFilename, const POPTIONS pOptions, long &cFunctions); 37 static void demangle(const char *pszMangledName, char *pszDemangled); 37 38 38 39 … … 54 55 char *pszUser = "root"; 55 56 char *pszPasswd = ""; 57 long cFunctions = 0; 58 56 59 57 60 /************************************************************************** … … 127 130 if (dbConnect(pszHost, pszUser, pszPasswd, pszDatabase)) 128 131 { 129 l = processFile(argv[argi], &options );132 l = processFile(argv[argi], &options, cFunctions); 130 133 lRc = ((lRc & 0xffff0000UL) | (l & 0xffff0000UL)) | ((lRc & 0x0000ffffUL) + l & 0x0000ffffUL); 131 134 dbDisconnect(); … … 141 144 argi++; 142 145 } 146 147 /* write function count */ 148 if (phLog != NULL) 149 fprintf(phLog, "\n %d functions were imported!\n\n", cFunctions); 143 150 144 151 /* close the log */ … … 225 232 * @param pszFilename Pointer to the filename of the file which is to be processed. 226 233 * @param pOptions Pointer to the options-struct. 227 */ 228 static long processFile(const char *pszFilename, const POPTIONS pOptions) 234 * @param cFunctions Function count which is to be updated when functions are imported. 235 */ 236 static long processFile(const char *pszFilename, const POPTIONS pOptions, long &cFunctions) 229 237 { 230 238 kFileFormatBase *pFile; … … 275 283 if (!pFile->isDef() || export.ulOrdinal < ORD_START_INTERNAL_FUNCTIONS) 276 284 { 277 if (export.achName[0] != '\0') 278 { /* name */ 279 int iName = strncmp(&export.achName[0], "_OS2", 4) != 0 ? 0 : 4; 280 fprintf(phLog, "%s: %08ld %s\n", pszFilename, export.ulOrdinal, &export.achName[iName]); 281 fOk = dbInsertUpdateFunction(sDll, &export.achName[iName], export.ulOrdinal, 282 pOptions->fIgnoreOrdinals && export.ulOrdinal != 0xffffffffUL); 283 } 285 char szIntName[64]; 286 char szName[64]; 287 288 demangle(export.achIntName, &szIntName[0]); 289 if (export.achName == '\0') 290 sprintf(&szName[0], "Ordinal%04ld", export.ulOrdinal); 284 291 else 285 { /* ordinal only */ 286 char szFn[50]; 287 288 sprintf(&szFn[0], "Ordinal%04ld", export.ulOrdinal); 289 fprintf(phLog, "%s: %08ld %s\n", pszFilename, export.ulOrdinal, &szFn[0]); 290 if (export.ulOrdinal != 0xffffffffUL) 291 fOk = dbInsertUpdateFunction(sDll, &szFn[0], export.ulOrdinal, pOptions->fIgnoreOrdinals); 292 else 293 fprintf(phLog, "%s: error - invalid ordinal value!\n", pszFilename); 294 } 292 strcpy(&szName[0], &export.achName[0]); 293 294 fprintf(phLog, "%s: %08ld %-30s %s\n", 295 pszFilename, export.ulOrdinal, &szName[0], &szIntName[0]); 296 297 fOk = dbInsertUpdateFunction(sDll, 298 &szName[0], 299 &szIntName[0], 300 export.ulOrdinal, 301 pOptions->fIgnoreOrdinals && export.ulOrdinal != 0xffffffffUL); 302 if (fOk) 303 cFunctions++; 295 304 } 296 305 … … 330 339 } 331 340 341 342 /** 343 * Demangles stdcall functions. 344 * @param pszMangledName Mangled name 345 * @param pszDemangled Pointer to buffer which will hold the demangled name upon return. 346 */ 347 static void demangle(const char *pszMangledName, char *pszDemangled) 348 { 349 int iEnd; 350 /* check for @ */ 351 iEnd = strlen(pszMangledName); 352 if (iEnd-- > 3 && *pszMangledName == '_') 353 { 354 while ((pszMangledName[iEnd] >= '0' && pszMangledName[iEnd] <= '9') && iEnd > 0) 355 iEnd--; 356 if (pszMangledName[iEnd] == '@') 357 { 358 *pszDemangled = '\0'; 359 strncat(pszDemangled, pszMangledName+1, iEnd - 1); 360 return; 361 } 362 } 363 364 /* not stdcall */ 365 strcpy(pszDemangled, pszMangledName); 366 } 367
Note:
See TracChangeset
for help on using the changeset viewer.