Changeset 3848 for trunk/tools/database/StateUpd.cpp
- Timestamp:
- Jul 18, 2000, 7:56:51 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/database/StateUpd.cpp
r3840 r3848 1 /* $Id: StateUpd.cpp,v 1.2 4 2000-07-18 07:33:13bird Exp $1 /* $Id: StateUpd.cpp,v 1.25 2000-07-18 17:56:50 bird Exp $ 2 2 * 3 3 * StateUpd - Scans source files for API functions and imports data on them. … … 68 68 static void copy(char *psz, char *pszFrom, int iFrom, char *pszTo, int iTo, char **papszLines); 69 69 static void copy(char *psz, int jFrom, int iFrom, int jTo, int iTo, char **papszLines); 70 static void copyComment(char *psz, char *pszFrom, int iFrom, char **papszLines, BOOL fStrip );71 static void copyComment(char *psz, int jFrom, int iFrom, char **papszLines, BOOL fStrip );70 static void copyComment(char *psz, char *pszFrom, int iFrom, char **papszLines, BOOL fStrip, BOOL fHTML); 71 static void copyComment(char *psz, int jFrom, int iFrom, char **papszLines, BOOL fStrip, BOOL fHTML); 72 72 static char *stristr(const char *pszStr, const char *pszSubStr); 73 73 static char *skipBackwards(const char *pszStopAt, const char *pszFrom, int &iLine, char **papszLines); … … 94 94 char *pszUser = "root"; 95 95 char *pszPasswd = ""; 96 ULONG ul0, ul1, ul2; 96 ULONG ul1, ul2; 97 ULONG cUpdated, cAll, cNotAliased; 97 98 98 99 DosError(0x3); … … 317 318 if (!options.fIntegrityOnly) 318 319 { 319 ul2 = dbGetNumberOfUpdatedFunction(options.lDllRefcode); 320 ul1 = dbCountFunctionInDll(options.lDllRefcode, FALSE); 321 ul0 = dbCountFunctionInDll(options.lDllRefcode, TRUE); 322 if (ul0 > ul2) 323 { 324 fprintf(phSignal, "%d functions where not found (found=%d, total=%d).\n", ul0 - ul2, ul2, ul0); 320 cUpdated = dbGetNumberOfUpdatedFunction(options.lDllRefcode); 321 cAll = dbCountFunctionInDll(options.lDllRefcode, FALSE); 322 cNotAliased = dbCountFunctionInDll(options.lDllRefcode, TRUE); 323 if (cNotAliased > cUpdated) 324 { 325 fprintf(phSignal, "%d functions where not found (found=%d, total=%d).\n", 326 cNotAliased- cUpdated, cUpdated, cNotAliased); 325 327 ulRc += 0x00010000; 326 328 } … … 330 332 fprintf(phLog, "-------------------------------------------------\n"); 331 333 fprintf(phLog, "-------------------------------------------------\n\n"); 332 fprintf(phLog,"Number of function in this DLL: %4ld (%ld)\n", ul1, ul0);333 fprintf(phLog,"Number of successfully processed APIs: %4ld (%ld)\n", (long)(0x0000FFFF & ulRc), ul2);334 fprintf(phLog,"Number of function in this DLL: %4ld (%ld)\n", cAll, cNotAliased); 335 fprintf(phLog,"Number of successfully processed APIs: %4ld (%ld)\n", (long)(0x0000FFFF & ulRc), cUpdated); 334 336 } 335 337 fprintf(phLog,"Number of signals: %4ld\n", (long)(ulRc >> 16)); … … 344 346 if (!options.fIntegrityOnly) 345 347 { 346 fprintf(stdout,"Number of function in this DLL: %4ld (%ld)\n", ul1, ul0);347 fprintf(stdout,"Number of successfully processed APIs: %4ld (%ld)\n", (long)(0x0000FFFF & ulRc), ul2);348 fprintf(stdout,"Number of function in this DLL: %4ld (%ld)\n", cAll, cNotAliased); 349 fprintf(stdout,"Number of successfully processed APIs: %4ld (%ld)\n", (long)(0x0000FFFF & ulRc), cUpdated); 348 350 } 349 351 fprintf(stdout,"Number of signals: %4ld\n", (long)(ulRc >> 16)); … … 657 659 char * psz, *psz2; 658 660 const char * pszDBFilename; 659 char * pszLastDateTime; 660 char * pszRevision; 661 char * pszAuthor; 662 signed long lLastAuthor; 661 char * pszLastDateTime = NULL; 662 char * pszRevision = NULL; 663 char * pszAuthor = NULL; 664 signed long lLastAuthor = 0; 665 unsigned long ulRc = 0; 663 666 664 667 /* … … 689 692 { /* found $Id: */ 690 693 psz2 = strchr(psz+3, '$'); 691 strncpy(&szId[0], psz, psz2 - psz); 692 szId[psz2 - psz] = '\0'; 693 iRet = i; 694 695 /* parse it! */ 696 psz = strstr(szId+4, ",v "); 697 if (psz == NULL) 698 { 699 fprintf(phSignal, "%s, module header: $Id keyword is incorrect (or the parsing code is broken).\n", pszFilename); 700 return 0x00010000; 701 } 702 pszRevision = trim(psz + 3); 703 psz = strchr(pszRevision, ' '); 704 *psz++ = '\0'; 705 trimR(pszRevision); 706 707 pszLastDateTime = trim(psz); 708 psz = strchr(strchr(pszLastDateTime, ' ') + 1, ' '); 709 *psz++ = '\0'; 710 pszLastDateTime[4] = pszLastDateTime[7] = '-'; 711 trimR(pszLastDateTime); 712 713 pszAuthor = trim(psz); 714 psz = strchr(pszAuthor, ' '); 715 *psz = '\0'; 716 lLastAuthor = dbFindAuthor(pszAuthor, NULL); 717 718 /* 719 * Is there more stuff here, in this comment? 720 * Skip to end of the current comment and copy the contents to szDescription. 721 * if szDescription suddenly contains nothing. 722 */ 723 psz = &szDescription[0]; 724 copyComment(psz, psz2+1, i, papszLines, TRUE); 725 while (*psz == '\n' && *psz == ' ') 726 psz++; 727 if (*psz == '\0') 728 { /* 729 * No description in the first comment. (The one with $Id.) 730 * Is there a comment following the first one? 694 if (psz2 != NULL && psz2 - psz > 39 && psz2 - psz < 256) 695 { 696 strncpy(&szId[0], psz, psz2 - psz); 697 szId[psz2 - psz] = '\0'; 698 iRet = i; 699 700 /* parse it! */ 701 psz = strstr(szId+4, ",v "); 702 if (psz != NULL) 703 { 704 pszRevision = trim(psz + 3); 705 psz = strchr(pszRevision, ' '); 706 *psz++ = '\0'; 707 trimR(pszRevision); 708 709 pszLastDateTime = trim(psz); 710 psz = strchr(strchr(pszLastDateTime, ' ') + 1, ' '); 711 *psz++ = '\0'; 712 pszLastDateTime[4] = pszLastDateTime[7] = '-'; 713 trimR(pszLastDateTime); 714 715 pszAuthor = trim(psz); 716 psz = strchr(pszAuthor, ' '); 717 *psz = '\0'; 718 lLastAuthor = dbFindAuthor(pszAuthor, NULL); 719 } 720 else 721 { 722 fprintf(phSignal, "%s, module header: $Id keyword is incorrect (2).\n", pszFilename); 723 ulRc += 0x00010000; 724 } 725 726 727 /* 728 * Is there more stuff here, in this comment? 729 * Skip to end of the current comment and copy the contents to szDescription. 730 * if szDescription suddenly contains nothing. 731 731 */ 732 while (papszLines[i] != NULL && strstr(papszLines[i++], "*/") == NULL) 733 i = i; 734 while (papszLines[i] != NULL) 735 { 736 psz2 = papszLines[i]; 737 while (*psz2 == ' ') 738 psz2++; 739 if (*psz2 != '\0') 740 break; 741 i++; 742 } 743 if (psz2 != NULL && strncmp(psz2, "/*", 2) == 0) 744 { 745 psz = &szDescription[0]; 746 copyComment(psz, psz2+1, i, papszLines, TRUE); 747 while (*psz == '\n' && *psz == ' ') 748 psz++; 749 if (psz == '\0') 750 szDescription[0] = '\0'; 751 732 psz = &szDescription[0]; 733 copyComment(psz, psz2+1, i, papszLines, TRUE, TRUE); 734 if (*psz == '\0') 735 { /* 736 * No description in the first comment. (The one with $Id.) 737 * Is there a comment following the first one? 738 */ 739 while (papszLines[i] != NULL && strstr(papszLines[i++], "*/") == NULL) 740 i = i; 741 while (papszLines[i] != NULL) 742 { 743 psz2 = papszLines[i]; 744 while (*psz2 == ' ') 745 psz2++; 746 if (*psz2 != '\0') 747 break; 748 i++; 749 } 750 if (psz2 != NULL && strncmp(psz2, "/*", 2) == 0) 751 { 752 psz = &szDescription[0]; 753 copyComment(psz, psz2+1, i, papszLines, TRUE, TRUE); 754 while (*psz == '\n' && *psz == ' ') 755 psz++; 756 if (psz == '\0') 757 szDescription[0] = '\0'; 758 759 /* Skip to line after comment end. */ 760 while (papszLines[i] != NULL && strstr(papszLines[i++], "*/") == NULL) 761 i = i; 762 } 763 } 764 else 765 { 752 766 /* Skip to line after comment end. */ 753 767 while (papszLines[i] != NULL && strstr(papszLines[i++], "*/") == NULL) … … 757 771 else 758 772 { 759 /* Skip to line after comment end. */ 760 while (papszLines[i] != NULL && strstr(papszLines[i++], "*/") == NULL) 761 i = i; 773 fprintf(phSignal, "%s, module header: $Id keyword is incorrect (1).\n", pszFilename); 774 ulRc += 0x00010000; 762 775 } 763 776 iRet = i; 777 764 778 765 779 /* … … 774 788 */ 775 789 pOptions->lFileRefcode = dbFindFile(pOptions->lDllRefcode, pszDBFilename); 776 if (pOptions->lFileRefcode < =0)790 if (pOptions->lFileRefcode < 0) 777 791 { 778 792 fprintf(phSignal, "%s, module header: failed to find file in DB. %s\n", … … 836 850 } 837 851 else 838 copyComment(&szBuffer[0], 0, i+1, papszLines, TRUE );852 copyComment(&szBuffer[0], 0, i+1, papszLines, TRUE, TRUE); 839 853 840 854 /* Update database */ … … 1564 1578 /* find parameter */ 1565 1579 for (j = 0; j < pFnDesc->cParams; j++) 1566 if (strcmp(pFnDesc->apszParamName[j], pszParam) != 0)1580 if (strcmp(pFnDesc->apszParamName[j], pszParam) == 0) 1567 1581 break; 1568 1582 if (j < pFnDesc->cParams) … … 2532 2546 * 2533 2547 */ 2534 static void copyComment(char *psz, char *pszFrom, int iFrom, char **papszLines, BOOL fStrip )2535 { 2536 copyComment(psz, pszFrom - papszLines[iFrom], iFrom, papszLines, fStrip );2548 static void copyComment(char *psz, char *pszFrom, int iFrom, char **papszLines, BOOL fStrip, BOOL fHTML) 2549 { 2550 copyComment(psz, pszFrom - papszLines[iFrom], iFrom, papszLines, fStrip, fHTML); 2537 2551 } 2538 2552 … … 2549 2563 * @param papszLines Array of lines. 2550 2564 * @param fStrip Strip blank lines at start and end + LICENCE notice (at end). 2565 * @param fHTML Convert to HTML while copying. 2551 2566 * @status completely implemented. 2552 2567 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no) 2553 2568 */ 2554 static void copyComment(char *psz, int jFrom, int iFrom, char **papszLines, BOOL fStrip )2569 static void copyComment(char *psz, int jFrom, int iFrom, char **papszLines, BOOL fStrip, BOOL fHTML) 2555 2570 { 2556 2571 char * pszStartBuffer = psz; /* Start of the target buffer. */ … … 2587 2602 psz = pszStart; 2588 2603 if (psz > pszStartBuffer || !fStrip) 2604 { 2605 if (fHTML) 2606 { 2607 *psz++ = '<'; 2608 *psz++ = 'B'; 2609 *psz++ = 'R'; 2610 *psz++ = '>'; 2611 } 2589 2612 *psz++ = '\n'; 2613 } 2590 2614 2591 2615 /* next */ … … 2603 2627 if (fStrip) 2604 2628 { 2629 if (fHTML) 2630 { 2631 while (psz >= pszStartBuffer) 2632 { 2633 if (*psz == ' ' || *psz == '\n' || *psz == '\0') 2634 *psz-- = '\0'; 2635 else if (psz - 4 >= pszStartBuffer && strncmp(psz - 4, "<BR>", 4) == 0) 2636 *(psz -= 4) = '\0'; 2637 else 2638 break; 2639 } 2640 } 2605 2641 while (psz >= pszStartBuffer && (*psz == ' ' || *psz == '\n' || *psz == '\0')) 2606 2642 *psz-- = '\0'; 2607 2643 2644 2608 2645 if (psz - 20 > pszStartBuffer && strstr(psz - 20, "LICENSE.TXT") != NULL) 2609 2646 { … … 2612 2649 } 2613 2650 2651 if (fHTML) 2652 { 2653 while (psz >= pszStartBuffer) 2654 { 2655 if (*psz == ' ' || *psz == '\n' || *psz == '\0') 2656 *psz-- = '\0'; 2657 else if (psz - 4 >= pszStartBuffer && strncmp(psz - 4, "<BR>", 4) == 0) 2658 *(psz -= 4) = '\0'; 2659 else 2660 break; 2661 } 2662 } 2614 2663 while (psz >= pszStartBuffer && (*psz == ' ' || *psz == '\n' || *psz == '\0')) 2615 2664 *psz-- = '\0';
Note:
See TracChangeset
for help on using the changeset viewer.