Changeset 2770 for trunk/tools/database
- Timestamp:
- Feb 13, 2000, 12:54:30 AM (26 years ago)
- Location:
- trunk/tools/database
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/database/APIImport.cpp
r2759 r2770 1 /* $Id: APIImport.cpp,v 1. 2 2000-02-11 18:35:53bird Exp $ */1 /* $Id: APIImport.cpp,v 1.3 2000-02-12 23:54:28 bird Exp $ */ 2 2 /* 3 3 * … … 35 35 static void closeLog(void); 36 36 static long processFile(const char *pszFilename, const POPTIONS pOptions, long &cFunctions); 37 static void demangle(c onst char *pszMangledName, char *pszDemangled);37 static void demangle(char *pszDemangled, const char *pszMangledName); 38 38 39 39 … … 286 286 char szName[64]; 287 287 288 demangle(export.achIntName, &szIntName[0]);288 /* exported name */ 289 289 if (export.achName == '\0') 290 290 sprintf(&szName[0], "Ordinal%04ld", export.ulOrdinal); 291 291 else 292 292 strcpy(&szName[0], &export.achName[0]); 293 294 /* internal name */ 295 if (export.achIntName[0] == '\0') 296 demangle(&szIntName[0], &szName[0]); 297 else 298 demangle(&szIntName[0], export.achIntName); 293 299 294 300 fprintf(phLog, "%s: %08ld %-30s %s\n", … … 342 348 /** 343 349 * Demangles stdcall functions. 350 * @param pszDemangled Pointer to buffer which will hold the demangled name upon return. 344 351 * @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) 352 */ 353 static void demangle(char *pszDemangled, const char *pszMangledName) 348 354 { 349 355 int iEnd; -
trunk/tools/database/CreateTables.sql
r2761 r2770 1 -- $Id: CreateTables.sql,v 1. 3 2000-02-11 23:54:24bird Exp $1 -- $Id: CreateTables.sql,v 1.4 2000-02-12 23:54:29 bird Exp $ 2 2 -- 3 3 -- Create all tables. … … 38 38 updated TINYINT NOT NULL DEFAULT 0, 39 39 UNIQUE i1(refcode, aliasfn), 40 UNIQUE i1a( aliasfn, name, dll),41 UNIQUE i1b(aliasfn, dll, refcode),40 UNIQUE i1a(dll, aliasfn, refcode), 41 UNIQUE i1b(aliasfn, name, dll), 42 42 UNIQUE i1c(aliasfn, intname, dll, refcode), 43 43 UNIQUE i2(name, dll, refcode), -
trunk/tools/database/Makefile
r2761 r2770 1 # $Id: Makefile,v 1. 7 2000-02-11 23:54:25bird Exp $1 # $Id: Makefile,v 1.8 2000-02-12 23:54:29 bird Exp $ 2 2 3 3 # … … 126 126 # 127 127 clean: 128 -@$(RM) *.obj 129 -@$(RM) *.lib 130 -@$(RM) *.o 131 -@$(RM) *.a 132 -@$(RM) *.dll 133 -@$(RM) *.exe 134 -@$(RM) *.pch 135 -@$(RM) *.log 136 -@$(RM) *.map 137 @cd gd 138 @nmake /nologo clean 128 $(RM) *.obj *.lib *.o *.a *.dll *.exe *.pch *.log *.map *.html 129 cd gd 130 $(MAKE) /nologo clean 131 cd .. 139 132 140 133 force: -
trunk/tools/database/StateUpd.cpp
r2765 r2770 1 /* $Id: StateUpd.cpp,v 1.1 0 2000-02-12 17:55:02bird Exp $1 /* $Id: StateUpd.cpp,v 1.11 2000-02-12 23:54:29 bird Exp $ 2 2 * 3 3 * StateUpd - Scans source files for API functions and imports data on them. … … 13 13 #define INCL_DOSERRORS 14 14 #define INCL_DOSMISC 15 #define INCL_DOSPROCESS 15 16 #include <os2.h> 16 17 #include <stdio.h> … … 54 55 static void copy(char *psz, char *pszFrom, int iFrom, char *pszTo, int iTo, char **papszLines); 55 56 static char *stristr(const char *pszStr, const char *pszSubStr); 57 static char *skipBackwards(const char *pszStopAt, const char *pszFrom, int &iLine, char **papszLines); 56 58 57 59 … … 75 77 char *pszUser = "root"; 76 78 char *pszPasswd = ""; 77 ULONG ul1, ul2; 79 ULONG ul0, ul1, ul2; 80 78 81 DosError(0x3); 82 DosSetPriority(PRTYS_PROCESSTREE, PRTYC_REGULAR, 1, 0); 79 83 80 84 /* get dll name from directory */ … … 286 290 /* write status to log */ 287 291 ul2 = dbGetNumberOfUpdatedFunction(options.lDllRefcode); 288 ul1 = dbCountFunctionInDll(options.lDllRefcode); 292 ul1 = dbCountFunctionInDll(options.lDllRefcode, FALSE); 293 ul0 = dbCountFunctionInDll(options.lDllRefcode, TRUE); 289 294 fprintf(phLog, "-------------------------------------------------\n"); 290 295 fprintf(phLog, "-------- Functions which was not updated --------\n"); … … 292 297 fprintf(phLog, "-------------------------------------------------\n"); 293 298 fprintf(phLog, "-------------------------------------------------\n\n"); 294 fprintf(phLog,"Number of function in this DLL: %4ld \n", ul1);299 fprintf(phLog,"Number of function in this DLL: %4ld (%ld)\n", ul1, ul0); 295 300 fprintf(phLog,"Number of successfully processed APIs: %4ld (%ld)\n", (long)(0x0000FFFF & ulRc), ul2); 296 301 fprintf(phLog,"Number of signals: %4ld\n", (long)(ulRc >> 16)); … … 303 308 304 309 /* warn if error during processing. */ 305 fprintf(stdout,"Number of function in this DLL: %4ld \n", ul1);310 fprintf(stdout,"Number of function in this DLL: %4ld (%ld)\n", ul1, ul0); 306 311 fprintf(stdout,"Number of successfully processed APIs: %4ld (%ld)\n", (long)(0x0000FFFF & ulRc), ul2); 307 312 fprintf(stdout,"Number of signals: %4ld\n", (long)(ulRc >> 16)); … … 744 749 int cArgs; 745 750 char * apszArgs[30]; 751 int iClass; 752 char * pszClass, *pszClassEnd; 746 753 747 754 /* 1.*/ … … 753 760 { 754 761 fprintf(phSignal, "%d: oops! didn't find end of function!, %d\n", pszFilename, __LINE__); 755 iRet = iP1 ;762 iRet = iP1+1; 756 763 return 0x00010000; 757 764 } … … 764 771 { 765 772 pszFn = papszLines[--iFn]; 766 pszFn += strlen(pszFn) ;767 } 768 while (iFn >= i&& *pszFn == ' ')773 pszFn += strlen(pszFn) - (*pszFn != '\0'); 774 } 775 while (iFn >= 0 && *pszFn == ' ') 769 776 { 770 777 if (pszFn != papszLines[iFn]) … … 773 780 { 774 781 pszFn = papszLines[--iFn]; 775 pszFn += strlen(pszFn) ;776 } 777 } 778 if ( *pszFn == ' ' || *pszFn == '\0')782 pszFn += strlen(pszFn) - (*pszFn != '\0'); 783 } 784 } 785 if (iFn < 0 || *pszFn == ' ' || *pszFn == '\0') 779 786 { 780 787 fprintf(phSignal, "%s: internal error!, %d\n", pszFilename, __LINE__); 781 iRet = iP1 ;788 iRet = iP1+1; 782 789 return 0x00010000; 783 790 } 784 791 pszFnEnd = pszFn; 785 pszFn = findStartOfWord(pszFn, papszLines[i ]);792 pszFn = findStartOfWord(pszFn, papszLines[iFn]); 786 793 787 794 /* 2a. */ 788 psz = pszFn; 789 while (psz >= papszLines[i] && *psz == ' ') 790 psz--; 791 if (psz > papszLines[i] && *psz == ':') 792 { 793 while (psz >= papszLines[i] && *psz == ' ') 794 psz--; 795 if (psz > papszLines[i] && *psz == ':') 796 { 797 while (psz >= papszLines[i] && *psz == ' ') 798 psz--; 799 if (psz > papszLines[i]) 800 pszFn = findStartOfWord(psz, papszLines[i]); 801 else 802 fprintf(phLog, "%.*s: class name is not at same line as the ::\n", pszFnEnd - psz-1, psz+1); 803 } 804 else 805 { 806 fprintf(phLog, "%.*s: invalid class '::'\n", pszFnEnd - psz, psz); 807 return 0; 808 } 809 } 795 /* operators are not supported (BOOL kTime::operator > (const kTime &time) const) */ 796 if (pszFn > papszLines[iFn]) 797 { 798 pszClassEnd = pszFn - 1; 799 iClass = iFn; 800 } 801 else 802 { 803 pszClassEnd = pszFn - 1; 804 iClass = iFn - 1; 805 } 806 c = 2; 807 while (iClass >= 0 && c >= 0) 808 { 809 if (*pszClassEnd == ':') 810 c--; 811 else if (*pszClassEnd != ' ') 812 break; 813 pszClassEnd--; 814 } 815 if (*pszClassEnd != ' ' && c == 0) 816 pszClass = findStartOfWord(pszClassEnd, papszLines[iClass]); 817 else 818 pszClass = pszClassEnd = NULL; 810 819 811 820 /* 3. */ … … 860 869 861 870 /* 6. */ 862 if (strnicmp(pszFn, "ODINFUNCTION", 12) == 0) 863 { 864 if (cArgs < 2) 871 if (strnicmp(pszFn, "ODINFUNCTION", 12) == 0 || strnicmp(pszFn, "ODINPROCEDURE", 13) == 0) 872 { 873 BOOL fProc = strnicmp(pszFn, "ODINPROCEDURE", 13) == 0; 874 j = 0; 875 if (cArgs < (fProc ? 1 : 2)) 865 876 { 866 877 fprintf(phSignal, "%s: Invalid ODINFUNCTION function too few parameters!\n", pszFilename); 867 878 return 0x00010000; 868 879 } 880 869 881 /* return type */ 870 pFnDesc->pszReturnType = apszArgs[0]; 882 if (fProc) 883 pFnDesc->pszReturnType = "void"; 884 else 885 pFnDesc->pszReturnType = apszArgs[j++]; 871 886 872 887 /* function name */ 873 pFnDesc->pszName = apszArgs[ 1];888 pFnDesc->pszName = apszArgs[j++]; 874 889 875 890 /* arguments */ 876 j = 2;877 891 pFnDesc->cParams = 0; 878 892 while (j+1 < cArgs) … … 886 900 else 887 901 { 888 /* return type - not implemented TODO/FIXME! */ 902 /* return type */ 903 int iReturn = pszClass != NULL ? iClass : iFn; 904 char * pszReturn = pszClass != NULL ? pszClass : pszFn; 905 906 if (pszReturn != papszLines[iReturn]) 907 pszReturn--; 908 else 909 { 910 pszReturn = papszLines[--iReturn]; 911 pszReturn += strlen(pszReturn) - (*pszReturn != '\0'); 912 } 913 pszReturn = skipBackwards("{};-+#:\"\'", pszReturn, iReturn, papszLines); 889 914 *pszEnd = '\0'; 890 copy(pszEnd, papszLines[i], i, pszFn-1, iFn, papszLines); 915 copy(pszEnd, pszReturn, iReturn, pszFn-1, iFn, papszLines); 916 if (strlen(pszEnd) > 1024) 917 { 918 fprintf(phSignal,"Fatal error! return statement is too larget. len=%d", strlen(pszEnd)); 919 fprintf(phLog, "Fatal error! return statement is too larget. len=%d", strlen(pszEnd)); 920 fprintf(stderr, "Fatal error! return statement is too larget. len=%d", strlen(pszEnd)); 921 fflush(phLog); 922 fflush(phSignal); 923 fflush(stderr); 924 } 925 pszEnd = trim(pszEnd); 891 926 pFnDesc->pszReturnType = *pszEnd == '\0' ? NULL : pszEnd; 892 927 pszEnd = strlen(pszEnd) + pszEnd + 1; … … 898 933 { /* cdecl function is prefixed with an '_' */ 899 934 strcpy(pszEnd, "_"); 900 strncat(pszEnd + 1, pszFn, pszFnEnd - pszFn+1); 901 } 902 else 903 strncat(pszEnd, pszFn, pszFnEnd - pszFn+1); 935 } 936 if (pszClass != NULL) 937 { 938 strncat(pszEnd,pszClass, pszClassEnd - pszClass + 1); 939 strcat(pszEnd, "::"); 940 } 941 strncat(pszEnd, pszFn, pszFnEnd - pszFn + 1); 904 942 pFnDesc->pszName = pszEnd; 905 943 pszEnd = strlen(pszEnd) + pszEnd + 1; … … 1244 1282 { 1245 1283 pszP1 = strchr(papszLines[i], '('); 1246 if (pszP1 != NULL && pszP1 > papszLines[i])1284 if (pszP1 != NULL && pszP1 >= papszLines[i]) 1247 1285 { 1248 1286 int cchFnName = 0; 1249 1287 char *pszFnName = pszP1 - 1; 1250 1288 1251 while (pszFnName - cchFnName > papszLines[ i] && pszFnName[cchFnName] == ' ')1289 while (pszFnName - cchFnName > papszLines[0] && pszFnName[cchFnName] == ' ') 1252 1290 cchFnName--, pszFnName--; 1253 1291 1254 pszFnName = findStartOfWord(pszFnName, papszLines[ i]);1292 pszFnName = findStartOfWord(pszFnName, papszLines[0]); 1255 1293 cchFnName += pszP1 - pszFnName; 1256 1294 if (cchFnName >= 0) … … 1294 1332 return TRUE; 1295 1333 } 1334 /* FIXME: constructors with ':' afterwards are not supported !TODO! */ 1296 1335 } 1297 1336 } … … 1526 1565 char *psz = pszFile; 1527 1566 char **papszLines = NULL; 1528 int cLines = 0;1567 int cLines = 1; 1529 1568 1530 1569 while (*psz != '\0') … … 1544 1583 if (papszLines != NULL) 1545 1584 { 1546 cLines = 0;1547 p sz = pszFile;1585 cLines = 1; 1586 papszLines[0] = psz = pszFile; 1548 1587 while (*psz != '\0') 1549 1588 { … … 1628 1667 } 1629 1668 1630 1669 #if 0 1631 1670 static void copy(char *psz, int jFrom, int iFrom, int jTo, int iTo, char **papszLines) 1632 1671 { … … 1639 1678 while (i < iTo || (i == iTo && j <= jTo)) 1640 1679 { 1641 if (papszLines[i][j] != '\0' &&1642 !(papszLines[i][j] == '/' && papszLines[i][j+1] == '/') /* '//' coments */1680 if (papszLines[i][j] != '\0' 1681 && !(papszLines[i][j] == '/' && papszLines[i][j+1] == '/') /* '//' coments */ 1643 1682 ) 1644 1683 { … … 1678 1717 } 1679 1718 1719 #else 1720 static void copy(char *psz, int jFrom, int iFrom, int jTo, int iTo, char **papszLines) 1721 { 1722 char chPrev = '\n'; 1723 int i, j; 1724 int fComment = FALSE; 1725 int fFirst = TRUE; 1726 1727 i = iFrom; 1728 j = jFrom; 1729 while (i < iTo || (i == iTo && j <= jTo)) 1730 { 1731 if (papszLines[i][j] != '\0' 1732 && !(papszLines[i][j] == '/' && papszLines[i][j+1] == '/') /* '//' coments */ 1733 && !(!fComment && fFirst && papszLines[i][j] == '#') 1734 ) 1735 { 1736 fFirst = papszLines[i][j] == ' '; 1737 1738 /* copy char ? */ 1739 if (!fComment) 1740 { 1741 fComment = papszLines[i][j] == '/' && papszLines[i][j+1] == '*'; 1742 1743 if (!fComment && !(chPrev == ' ' && papszLines[i][j] == ' ') /* only one space char */ 1744 && !(chPrev == '(' && papszLines[i][j] == ' ') /* no space after '(' */ 1745 ) 1746 { 1747 if (chPrev == ' ' && (papszLines[i][j] == ',' || papszLines[i][j] == ')')) 1748 psz[-1] = papszLines[i][j]; /* no space before ',' and ')' */ 1749 else 1750 { 1751 chPrev = *psz++ = papszLines[i][j]; 1752 if (chPrev == '*') /* ensure ' ' after '*' */ 1753 chPrev = *psz++ = ' '; 1754 } 1755 } 1756 1757 } 1758 else 1759 if ((fComment = papszLines[i][j] != '*' || papszLines[i][j+1] != '/') == FALSE) 1760 j++; 1761 j++; 1762 } 1763 else 1764 { 1765 /* next */ 1766 j = 0; 1767 fFirst = TRUE; 1768 i++; 1769 if (chPrev != ' ' && chPrev != '(') 1770 chPrev = *psz++ = ' '; 1771 } 1772 } 1773 *psz = '\0'; 1774 } 1775 #endif 1776 1680 1777 1681 1778 /** … … 1714 1811 } 1715 1812 1813 1814 1815 /** 1816 * Skips backwards until one of the chars in pszStopAt or star of file is reached. 1817 * @returns Pointer to end. 1818 * @param pszStopAt Array of chars which we should stop at. 1819 * @param pszFrom Start pointer. 1820 * @param iLine Reference to index to array of lines. input: start line, output: result line. 1821 * @param papszLines Array lines. 1822 * @sketch 1823 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 1824 * @remark Comments are skipped. 1825 * No tests for strings ("...asdf"). 1826 */ 1827 static char *skipBackwards(const char *pszStopAt, const char *pszFrom, int &iLine, char **papszLines) 1828 { 1829 BOOL fComment = FALSE; 1830 int i = iLine; 1831 const char *psz = pszFrom; 1832 1833 while (i >= 0) 1834 { 1835 /* check for stop char */ 1836 const char *psz1 = pszStopAt; 1837 while (*psz1 != '\0') 1838 if (*psz1++ == *psz) 1839 break; 1840 if (*psz1 != '\0') 1841 break; 1842 1843 /* comment check */ 1844 if (!fComment && psz > papszLines[i] && *psz == '/' && psz[-1] == '*') 1845 fComment = TRUE; 1846 else if (fComment && *psz == '/' && psz[1] == '*') 1847 fComment = FALSE; 1848 1849 /* ok position to return? */ 1850 if (!fComment) 1851 { 1852 iLine = i; 1853 pszFrom = psz; 1854 } 1855 1856 /* prev */ 1857 if (psz > papszLines[i]) 1858 psz--; 1859 else 1860 { /* try find line comment */ 1861 do 1862 { 1863 char *pszStart = papszLines[--i]; 1864 while (*pszStart == ' ') 1865 pszStart++; 1866 if (*pszStart != '\0' && *pszStart != '#' 1867 && !(*pszStart == '/' && pszStart[1] == '/')) 1868 { /* find '//' */ 1869 pszStart = strstr(pszStart, "//"); 1870 if (pszStart != NULL) 1871 psz = pszStart-1; 1872 else 1873 psz = papszLines[i] + strlen(papszLines[i]) - 1; 1874 break; 1875 } 1876 } while (i > 0); 1877 } 1878 } 1879 1880 return (char*)pszFrom; 1881 } 1882 -
trunk/tools/database/db.cpp
r2765 r2770 1 /* $Id: db.cpp,v 1. 7 2000-02-12 17:55:03bird Exp $ *1 /* $Id: db.cpp,v 1.8 2000-02-12 23:54:29 bird Exp $ * 2 2 * 3 3 * DB - contains all database routines. … … 178 178 * Count the function in a given dll. 179 179 * @returns Number of functions. -1 on error. 180 * @param usDll Dll refcode. 181 */ 182 signed long _System dbCountFunctionInDll(signed long ulDll) 180 * @param usDll Dll refcode. 181 * @param fNotAliases TRUE: don't count aliased functions. 182 */ 183 signed long _System dbCountFunctionInDll(signed long ulDll, BOOL fNotAliases) 183 184 { 184 185 signed long rc; … … 189 190 { 190 191 sprintf(&szQuery[0], "SELECT count(refcode) FROM function WHERE dll = %ld\n", ulDll); 192 if (fNotAliases) 193 strcat(&szQuery[0], " AND aliasfn < 0"); 191 194 rc = mysql_query(pmysql, &szQuery[0]); 192 195 pres = mysql_store_result(pmysql); … … 284 287 * @param usDll Dll refcode. 285 288 * @param pszFunction Function name. 286 * @param pszIntFunction Internal function name. 289 * @param pszIntFunction Internal function name. (required!) 287 290 * @param ulOrdinal Ordinal value. 288 291 * @param fIgnoreOrdinal Do not update ordinal value. … … 297 300 MYSQL_RES *pres; 298 301 299 /* when no internal name , the exported name is the internal name too! */302 /* when no internal name fail! */ 300 303 if (pszIntFunction == NULL || *pszIntFunction == '\0') 301 pszIntFunction = pszFunction;304 return FALSE; 302 305 303 306 /* try find function */ … … 360 363 } 361 364 365 362 366 #if 1 367 /* 368 * Stubs used while optimizing sqls. 369 */ 370 int mysql_query1(MYSQL *mysql, const char *q) 371 { return mysql_query(mysql, q); } 372 int mysql_query2(MYSQL *mysql, const char *q) 373 { return mysql_query(mysql, q); } 374 int mysql_query3(MYSQL *mysql, const char *q) 375 { return mysql_query(mysql, q); } 376 int mysql_query4(MYSQL *mysql, const char *q) 377 { return mysql_query(mysql, q); } 378 int mysql_query5(MYSQL *mysql, const char *q) 379 { return mysql_query(mysql, q); } 380 MYSQL_RES * mysql_store_result1(MYSQL *mysql) 381 { return mysql_store_result(mysql); } 382 MYSQL_RES * mysql_store_result5(MYSQL *mysql) 383 { return mysql_store_result(mysql); } 384 385 #else 386 387 #define mysql_query1 mysql_query 388 #define mysql_query2 mysql_query 389 #define mysql_query3 mysql_query 390 #define mysql_query4 mysql_query 391 #define mysql_query5 mysql_query 392 #define mysql_store_result1 mysql_store_result 393 #define mysql_store_result5 mysql_store_result 394 395 #endif 396 397 398 363 399 /** 364 400 * Find occurences of a function, given by internal name. … … 383 419 pszFunctionName, lDll); 384 420 385 rc = mysql_query (pmysql, &szQuery[0]);421 rc = mysql_query1(pmysql, &szQuery[0]); 386 422 if (rc >= 0) 387 423 { 388 pres = mysql_store_result (pmysql);424 pres = mysql_store_result1(pmysql); 389 425 if (pres != NULL) 390 426 { … … 404 440 if (lDll >= 0 && pFnFindBuf->cFns != 0) 405 441 { 442 #if 0 406 443 int i; 407 408 /* Make the selected function to DONT TOUCH */409 sprintf(&szQuery[0], "UPDATE function SET aliasfn = (-2) "410 "WHERE (",411 lDll, pszFunctionName);412 for (i = 0; i < pFnFindBuf->cFns; i++)413 {414 if (i != 0) strcat(&szQuery[0], " OR");415 sprintf(&szQuery[strlen(szQuery)], " refcode = %ld", pFnFindBuf->alRefCode[i]);416 }417 strcat(&szQuery[0], ") AND aliasfn <> (-2)");418 419 rc = mysql_query(pmysql, &szQuery[0]);420 if (rc >= 0)421 {422 /* Update all with equal internal... which is not in this Dll */423 sprintf(&szQuery[0], "UPDATE function SET aliasfn = (%ld) "424 "WHERE aliasfn = (-1) AND dll <> %ld AND intname = '%s'",425 pFnFindBuf->alRefCode[0], lDll, pszFunctionName, pszFunctionName);426 rc = mysql_query(pmysql, &szQuery[0]);427 if (rc >= 0)428 {429 /* Update all with equal external name... which is not in this Dll */430 sprintf(&szQuery[0], "UPDATE function SET aliasfn = (%ld) "431 "WHERE aliasfn = (-1) AND dll <> %ld AND name = '%s'",432 pFnFindBuf->alRefCode[0], lDll, pszFunctionName, pszFunctionName);433 434 rc = mysql_query(pmysql, &szQuery[0]);435 if (rc >= 0)436 {437 /* get the functions aliases to the functions we have allready found. */438 strcpy(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function WHERE aliasfn IN (");439 for (i = 0; i < pFnFindBuf->cFns; i++)440 {441 if (i != 0) strcat(&szQuery[0], ", ");442 sprintf(&szQuery[strlen(szQuery)], "%ld", pFnFindBuf->alRefCode[i]);443 }444 sprintf(&szQuery[strlen(szQuery)], ") AND dll <> %ld", lDll);445 446 rc = mysql_query(pmysql, &szQuery[0]);447 if (rc >= 0)448 {449 pres = mysql_store_result(pmysql);450 if (pres != NULL)451 {452 while ((row = mysql_fetch_row(pres)) != NULL)453 {454 pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]);455 pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]);456 if (row[2] != NULL)457 pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);458 else459 pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = ALIAS_NULL;460 461 /* next */462 pFnFindBuf->cFns++;463 }464 mysql_free_result(pres);465 }466 }467 }468 }469 }470 }471 }472 else473 rc = -1;474 }475 476 return rc >= 0;477 }478 #else479 int mysql_query1(MYSQL *mysql, const char *q)480 {481 return mysql_query(mysql, q);482 }483 484 int mysql_query2(MYSQL *mysql, const char *q)485 {486 return mysql_query(mysql, q);487 }488 489 int mysql_query3(MYSQL *mysql, const char *q)490 {491 return mysql_query(mysql, q);492 }493 494 int mysql_query4(MYSQL *mysql, const char *q)495 {496 return mysql_query(mysql, q);497 }498 499 int mysql_query5(MYSQL *mysql, const char *q)500 {501 return mysql_query(mysql, q);502 }503 504 MYSQL_RES * mysql_store_result1(MYSQL *mysql)505 {506 return mysql_store_result(mysql);507 }508 509 MYSQL_RES * mysql_store_result2(MYSQL *mysql)510 {511 return mysql_store_result(mysql);512 }513 514 515 /**516 * Find occurences of a function, given by internal name.517 * @returns success indicator, TRUE / FALSE.518 * @param pszFunctionName519 * @param pFnFindBuf520 * @param lDll521 */522 BOOL _System dbFindFunction(const char *pszFunctionName, PFNFINDBUF pFnFindBuf, signed long lDll)523 {524 MYSQL_RES *pres;525 MYSQL_ROW row;526 int rc;527 char szQuery[256];528 529 if (lDll < 0)530 sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function WHERE intname = '%s'",531 pszFunctionName);532 else533 sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function "534 "WHERE intname = '%s' AND dll = %ld",535 pszFunctionName, lDll);536 537 rc = mysql_query1(pmysql, &szQuery[0]);538 if (rc >= 0)539 {540 pres = mysql_store_result1(pmysql);541 if (pres != NULL)542 {543 pFnFindBuf->cFns = 0;544 while ((row = mysql_fetch_row(pres)) != NULL)545 {546 pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]);547 pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]);548 pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);549 550 /* next */551 pFnFindBuf->cFns++;552 }553 mysql_free_result(pres);554 555 /* alias check and fix */556 if (lDll >= 0 && pFnFindBuf->cFns != 0)557 {558 int i;559 560 444 /* Make the selected function to DONT TOUCH */ 561 445 sprintf(&szQuery[0], "UPDATE function SET aliasfn = (-2) " … … 587 471 if (rc >= 0) 588 472 { 589 int cFns = pFnFindBuf->cFns; 590 for (i = 0; i < cFns; i++) 473 /* get the functions aliases to the functions we have allready found. */ 474 sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function WHERE dll = %ld AND aliasfn IN (", lDll); 475 for (i = 0; i < pFnFindBuf->cFns; i++) 591 476 { 592 /* get the functions aliases to the functions we have allready found. */ 593 sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function WHERE aliasfn = %ld AND dll <> %ld", 594 pFnFindBuf->alRefCode[i], lDll); 595 rc = mysql_query5(pmysql, &szQuery[0]); 477 if (i != 0) strcat(&szQuery[0], ", "); 478 sprintf(&szQuery[strlen(szQuery)], "%ld", pFnFindBuf->alRefCode[i]); 479 } 480 strcat(&szQuery[strlen(szQuery)], ")"); 481 482 DosSleep(0); 483 rc = mysql_query5(pmysql, &szQuery[0]); 484 if (rc >= 0) 485 { 486 pres = mysql_store_result5(pmysql); 487 if (pres != NULL) 488 { 489 while ((row = mysql_fetch_row(pres)) != NULL) 490 { 491 pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]); 492 pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]); 493 if (row[2] != NULL) 494 pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]); 495 else 496 pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = ALIAS_NULL; 497 498 /* next */ 499 pFnFindBuf->cFns++; 500 } 501 mysql_free_result(pres); 502 } 503 } 504 } 505 } 506 } 507 #else 508 int i; 509 int cFnsThisDll = (int)pFnFindBuf->cFns; 510 511 /* get the functions aliases to the functions we have allready found. */ 512 sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function " 513 "WHERE aliasfn = (-1) AND dll <> %ld AND intname = '%s'", 514 lDll, pszFunctionName); 515 rc = mysql_query2(pmysql, &szQuery[0]); 516 if (rc >= 0) 517 { 518 pres = mysql_store_result(pmysql); 519 if (pres != NULL) 520 { 521 while ((row = mysql_fetch_row(pres)) != NULL) 522 { 523 pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]); 524 pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]); 525 if (row[2] != NULL) 526 pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]); 527 else 528 pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = ALIAS_NULL; 529 530 /* next */ 531 pFnFindBuf->cFns++; 532 } 533 mysql_free_result(pres); 534 535 536 /* get the functions aliases to the functions we have allready found. */ 537 sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function " 538 "WHERE aliasfn = (-1) AND dll <> %ld AND name = '%s'", 539 lDll, pszFunctionName); 540 rc = mysql_query3(pmysql, &szQuery[0]); 541 if (rc >= 0) 542 { 543 pres = mysql_store_result(pmysql); 544 if (pres != NULL) 545 { 546 while ((row = mysql_fetch_row(pres)) != NULL) 547 { 548 pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]); 549 pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]); 550 if (row[2] != NULL) 551 pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]); 552 else 553 pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = ALIAS_NULL; 554 555 /* next */ 556 pFnFindBuf->cFns++; 557 } 558 mysql_free_result(pres); 559 560 /* do updates! */ 561 /* Make the selected function to DONT TOUCH */ 562 sprintf(&szQuery[0], "UPDATE function SET aliasfn = (-2) " 563 "WHERE (", 564 lDll, pszFunctionName); 565 for (i = 0; i < cFnsThisDll; i++) 566 { 567 if (i != 0) strcat(&szQuery[0], " OR"); 568 sprintf(&szQuery[strlen(szQuery)], " refcode = %ld", pFnFindBuf->alRefCode[i]); 569 } 570 strcat(&szQuery[0], ") AND aliasfn <> (-2)"); 571 572 rc = mysql_query4(pmysql, &szQuery[0]); 596 573 if (rc >= 0) 597 574 { 598 pres = mysql_store_result2(pmysql); 599 if (pres != NULL) 575 /* Update all with equal internal... which is not in this Dll */ 576 sprintf(&szQuery[0], "UPDATE function SET aliasfn = (%ld) " 577 "WHERE aliasfn = (-1) AND dll <> %ld AND intname = '%s'", 578 pFnFindBuf->alRefCode[0], lDll, pszFunctionName, pszFunctionName); 579 rc = mysql_query5(pmysql, &szQuery[0]); 580 if (rc >= 0) 600 581 { 601 while ((row = mysql_fetch_row(pres)) != NULL) 602 { 603 pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]); 604 pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]); 605 if (row[2] != NULL) 606 pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]); 607 else 608 pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = ALIAS_NULL; 609 610 /* next */ 611 if (pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] != lDll) 612 pFnFindBuf->cFns++; 613 } 614 mysql_free_result(pres); 582 /* Update all with equal external name... which is not in this Dll */ 583 sprintf(&szQuery[0], "UPDATE function SET aliasfn = (%ld) " 584 "WHERE aliasfn = (-1) AND dll <> %ld AND name = '%s'", 585 pFnFindBuf->alRefCode[0], lDll, pszFunctionName, pszFunctionName); 586 587 rc = mysql_query4(pmysql, &szQuery[0]); 615 588 } 616 589 } … … 619 592 } 620 593 } 594 #endif 621 595 } 622 596 } … … 627 601 return rc >= 0; 628 602 } 629 630 #endif631 603 632 604 -
trunk/tools/database/db.h
r2765 r2770 1 /* $Id: db.h,v 1. 5 2000-02-12 17:55:03bird Exp $ */1 /* $Id: db.h,v 1.6 2000-02-12 23:54:29 bird Exp $ */ 2 2 /* 3 3 * DB - contains all database routines … … 31 31 { 32 32 /* buffers */ 33 char szFnDclBuffer[ 512];34 char szFnHdrBuffer[ 1024];33 char szFnDclBuffer[2048]; 34 char szFnHdrBuffer[2048]; 35 35 36 36 /* function name and type */ … … 78 78 BOOL _System dbDisconnect(); 79 79 signed short _System dbGetDll(const char *pszDllName); 80 signed long _System dbCountFunctionInDll(signed long ulDll );81 80 signed long _System dbCountFunctionInDll(signed long ulDll, 81 BOOL fNotAliases); 82 82 signed short _System dbCheckInsertDll(const char *pszDll); 83 83 unsigned short _System dbGet(const char *pszTable, -
trunk/tools/database/makefile.gcc
r2745 r2770 1 # $Id: makefile.gcc,v 1. 1 2000-02-10 22:43:19bird Exp $1 # $Id: makefile.gcc,v 1.2 2000-02-12 23:54:30 bird Exp $ 2 2 3 3 # … … 170 170 171 171 172 173 172 # 174 173 # clean 175 174 # 176 175 clean: 177 @$(RM) *.obj *.lib *.o *.a *.dll *.exe *.pch *.log *.map178 @cd gd179 @nmake/nologo clean180 @cd ..176 $(RM) *.obj *.lib *.o *.a *.dll *.exe *.pch *.log *.map *.html 177 cd gd 178 $(MAKE) /nologo clean 179 cd .. 181 180 182 181 force:
Note:
See TracChangeset
for help on using the changeset viewer.