Changeset 2759 for trunk/tools/database/StateUpd.cpp
- Timestamp:
- Feb 11, 2000, 7:35:55 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/database/StateUpd.cpp
r2748 r2759 1 /* $Id: StateUpd.cpp,v 1. 7 2000-02-10 23:37:52bird Exp $1 /* $Id: StateUpd.cpp,v 1.8 2000-02-11 18:35:54 bird Exp $ 2 2 * 3 3 * StateUpd - Scans source files for API functions and imports data on them. … … 44 44 static unsigned long analyseFnDcl2(PFNDESC pFnDesc, char **papszLines, int i, int &iRet, const char *pszFilename, POPTIONS pOptions); 45 45 static BOOL isFunction(char **papszLines, int i, POPTIONS pOptions); 46 static long _System dbNotUpdatedCallBack(const char *pszValue, const char *pszFieldName, void *pvUser); 46 47 static char *skipInsignificantChars(char **papszLines, int &i, char *psz); 47 48 static char *readFileIntoMemory(const char *pszFilename); … … 66 67 BOOL fFatal = FALSE; 67 68 unsigned long ulRc = 0; 68 OPTIONS options = {TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE}; 69 char szDLLName[64]; 70 OPTIONS options = {TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, &szDLLName[0], -1}; 69 71 unsigned long ulRc2; 70 72 char *pszErrorDesc = NULL; … … 73 75 char *pszUser = "root"; 74 76 char *pszPasswd = ""; 75 77 ULONG ul1, ul2; 76 78 DosError(0x3); 79 80 /* get dll name from directory */ 81 ul1 = ul2 = 0; 82 DosQueryCurrentDisk(&ul1, &ul2); 83 ul2 = sizeof(szDLLName); 84 DosQueryCurrentDir(ul1, &szDLLName[0], &ul2); 85 if (ul2 != 0) 86 { 87 if (szDLLName[ul2-1] == '\\' || szDLLName[ul2-1] == '/') 88 szDLLName[--ul2] = '\0'; 89 ul1 = ul2; 90 while (ul1 != 0 && szDLLName[ul1-1] != '\\' && szDLLName[ul1-1] != '/') 91 ul1--; 92 if (ul1 != 0) 93 options.pszDLLName = &szDLLName[ul1]; 94 } 95 else 96 szDLLName[0] = '\0'; 97 77 98 78 99 /************************************************************************** … … 87 108 * -COMCTL32<[+]|-> Removes 'COMCTL32'-prefix from function name. 88 109 * -VERSION<[+]|-> Removes 'VERSION'-prefix from function name. 110 * -Dll:<dllname> Name of the dll being processed. 89 111 * -d:<dbname> Database name 90 112 * -p:<passwd> Password … … 101 123 case 'd': 102 124 case 'D': 103 if ( argv[argi][2] == ':')104 pszDatabase = &argv[argi][3];125 if (strnicmp(argv[argi], "dll:", 4) == 0 ) 126 options.pszDLLName = &argv[argi][5]; 105 127 else 106 fprintf(stderr, "warning: option '-d:' requires database name.\n"); 128 { 129 if (argv[argi][2] == ':') 130 pszDatabase = &argv[argi][3]; 131 else 132 fprintf(stderr, "warning: option '-d:' requires database name.\n"); 133 } 107 134 break; 108 135 … … 217 244 if (!options.fIntegrityOnly) 218 245 { 246 /* find dll */ 247 options.lDllRefcode = dbGetDll(options.pszDLLName); 248 fprintf(phLog, "DLL: refcode=%d, name=%s\n", options.lDllRefcode, options.pszDLLName); 249 219 250 /* processing */ 220 251 if (argv[argi] == NULL || *argv[argi] == '\0') … … 253 284 } 254 285 286 /* write status to log */ 287 fprintf(phLog, "-------------------------------------------------\n"); 288 fprintf(phLog, "-------- Functions which was not updated --------\n"); 289 dbGetNotUpdatedFunction(options.lDllRefcode, dbNotUpdatedCallBack); 290 fprintf(phLog, "-------------------------------------------------\n"); 291 fprintf(phLog, "-------------------------------------------------\n\n"); 292 ul1 = dbCountFunctionInDll(options.lDllRefcode); 293 fprintf(phLog,"Number of function in this DLL: %4ld\n", ul1); 294 fprintf(phLog,"Number of successfully processed APIs: %4ld\n", (long)(0x0000FFFF & ulRc)); 295 fprintf(phLog,"Number of signals: %4ld\n", (long)(ulRc >> 16)); 296 255 297 /* close the logs */ 256 298 closeLogs(); … … 260 302 261 303 /* warn if error during processing. */ 304 fprintf(stdout,"Number of function in this DLL: %4ld\n", ul1); 262 305 fprintf(stdout,"Number of successfully processed APIs: %4ld\n", (long)(0x0000FFFF & ulRc)); 263 306 fprintf(stdout,"Number of signals: %4ld\n", (long)(ulRc >> 16)); … … 568 611 569 612 /* 3.*/ 570 fprintf(phLog, "Name: '%s' (refcode=%ld)\n", FnDesc.pszName, FnDesc.lRefCode); 613 fprintf(phLog, "Name: '%s' (refcodes=", FnDesc.pszName); 614 for (j = 0; j < FnDesc.cRefCodes; j++) 615 fprintf(phLog, j > 0 ? ", %ld" : "%ld", FnDesc.alRefCode[j]); 616 fprintf(phLog, ")\n"); 571 617 fprintf(phLog, " Returns: '%s'\n", FnDesc.pszReturnType != NULL ? FnDesc.pszReturnType : "<missing>"); 572 618 fprintf(phLog, " cParams: %2d\n", FnDesc.cParams); … … 640 686 } 641 687 642 if (FnFindBuf.cFns == 0) 643 { 688 pFnDesc->cRefCodes = 0; 689 if (FnFindBuf.cFns != 0) 690 { 691 if (pOptions->lDllRefcode < 0) 692 { 693 if (FnFindBuf.cFns > 1) 694 { 695 fprintf(phSignal, "%s: unknown dll and more than two occurences of this function!\n", pszFilename); 696 return 0x00010000; 697 } 698 pOptions->lDllRefcode = FnFindBuf.alDllRefCode[0]; 699 fprintf(phLog, "DllRef = %d\n", pOptions->lDllRefcode); 700 } 701 702 for (lFn = 0; lFn < FnFindBuf.cFns; lFn++) 703 { 704 if (FnFindBuf.alDllRefCode[lFn] == pOptions->lDllRefcode) 705 pFnDesc->alRefCode[pFnDesc->cRefCodes++] = FnFindBuf.alRefCode[lFn]; 706 } 707 708 if (pFnDesc->cRefCodes == 0) 709 fprintf(phLog, "%s was not an API in this dll(%d)!\n", pFnDesc->pszName, pOptions->lDllRefcode); 710 } 711 else 644 712 fprintf(phLog, "%s was not an API\n", pFnDesc->pszName); 645 return 0; 646 } 647 else if (FnFindBuf.cFns > 1) 648 { /* 3b.*/ 649 while (lFn < (int)FnFindBuf.cFns && FnFindBuf.alDllRefCode[lFn] != lPrevFnDll) 650 lFn++; 651 if (lPrevFnDll == -1L && lFn >= (int)FnFindBuf.cFns) 652 { 653 fprintf(phSignal, "%s, %s: error - more than one function by the name '%s'\n", 654 pszFilename, pFnDesc->pszName, pFnDesc->pszName); 655 return 0x00010000; 656 } 657 } 658 pFnDesc->lRefCode = FnFindBuf.alRefCode[lFn]; 659 lPrevFnDll = FnFindBuf.alDllRefCode[lFn]; 660 713 714 ulRc = pFnDesc->cRefCodes; 661 715 return ulRc; 662 716 } … … 681 735 * 1. find the '(' 682 736 * 2. find the word ahead of the '(', this is the function name. 737 * 2a. class test. 683 738 * 3. find the closing ')' 684 739 * 4. copy the parameters, which is between the two '()' … … 687 742 688 743 int iFn, iP1, iP2, j; 689 char * pszFn, *psz P1, *pszP2;744 char * pszFn, *pszFnEnd, *pszP1, *pszP2; 690 745 char * psz, *pszEnd; 691 746 int cArgs; … … 729 784 return 0x00010000; 730 785 } 786 pszFnEnd = pszFn; 731 787 pszFn = findStartOfWord(pszFn, papszLines[i]); 788 789 /* 2a. */ 790 psz = pszFn; 791 while (psz >= papszLines[i] && *psz == ' ') 792 psz--; 793 if (psz > papszLines[i] && *psz == ':') 794 { 795 while (psz >= papszLines[i] && *psz == ' ') 796 psz--; 797 if (psz > papszLines[i] && *psz == ':') 798 { 799 while (psz >= papszLines[i] && *psz == ' ') 800 psz--; 801 if (psz > papszLines[i]) 802 pszFn = findStartOfWord(psz, papszLines[i]); 803 else 804 fprintf(phLog, "%.*s: class name is not at same line as the ::\n", pszFnEnd - psz-1, psz+1); 805 } 806 else 807 { 808 fprintf(phLog, "%.*s: invalid class '::'\n", pszFnEnd - psz, psz); 809 return 0; 810 } 811 } 732 812 733 813 /* 3. */ … … 792 872 else 793 873 { 874 /* return type - not implemented TODO/FIXME! */ 875 *pszEnd = '\0'; 876 copy(pszEnd, papszLines[i], i, pszFn-1, iFn, papszLines); 877 pFnDesc->pszReturnType = *pszEnd == '\0' ? NULL : pszEnd; 878 pszEnd = strlen(pszEnd) + pszEnd + 1; 879 794 880 /* function name */ 795 881 *pszEnd = '\0'; 796 strncat(pszEnd, pszFn, findEndOfWord(pszFn) - pszFn); 882 if (pFnDesc->pszReturnType != NULL 883 && stristr(pFnDesc->pszReturnType, "cdecl") != NULL) 884 { /* cdecl function is prefixed with an '_' */ 885 strcpy(pszEnd, "_"); 886 strncat(pszEnd+1, pszFn, pszFnEnd - pszFn+1); 887 } 888 else 889 strncat(pszEnd, pszFn, pszFnEnd - pszFn+1); 890 797 891 pFnDesc->pszName = pszEnd; 798 799 /* return type - not implemented TODO/FIXME! */800 pFnDesc->pszReturnType = NULL;801 892 802 893 /* arguments */ … … 1227 1318 1228 1319 1320 1321 /** 1322 * Callback function for the dbGetNotUpdatedFunction routine. 1323 * 1324 */ 1325 static long _System dbNotUpdatedCallBack(const char *pszValue, const char *pszFieldName, void *pvUser) 1326 { 1327 if (stricmp(pszFieldName, "name") == 0) 1328 fprintf(phLog, "%s ", pszValue); 1329 else if (stricmp(pszFieldName, "updated") == 0) 1330 fprintf(phLog, "update=%s ", pszValue); 1331 else if (stricmp(pszFieldName, "intname") == 0) 1332 fprintf(phLog, "(%s)\n", pszValue); 1333 1334 pvUser = pvUser; 1335 return 0; 1336 } 1337 1338 1229 1339 /** 1230 1340 * Skips insignificant chars (spaces, new-lines and comments)
Note:
See TracChangeset
for help on using the changeset viewer.