Changeset 2761 for trunk/tools/database
- Timestamp:
- Feb 12, 2000, 12:54:25 AM (26 years ago)
- Location:
- trunk/tools/database
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/database/CreateTables.sql
r2759 r2761 1 -- $Id: CreateTables.sql,v 1. 2 2000-02-11 18:35:54 bird Exp $1 -- $Id: CreateTables.sql,v 1.3 2000-02-11 23:54:24 bird Exp $ 2 2 -- 3 3 -- Create all tables. … … 12 12 name VARCHAR(32) NOT NULL, 13 13 description VARCHAR(255), 14 UNIQUE i1(refcode),15 UNIQUE i2(name)14 UNIQUE u1(refcode), 15 UNIQUE u2(name) 16 16 ); 17 17 … … 21 21 name VARCHAR(32) NOT NULL, 22 22 description VARCHAR(128), 23 UNIQUE i1(refcode),24 UNIQUE i2(name),25 UNIQUE i3(color)23 UNIQUE u1(refcode), 24 UNIQUE u2(name), 25 UNIQUE u3(color) 26 26 ); 27 27 28 28 CREATE TABLE function ( 29 refcode INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, 30 dll TINYINT NOT NULL, 31 name VARCHAR(64) NOT NULL, 32 intname VARCHAR(64) NOT NULL, 33 state TINYINT NOT NULL DEFAULT 0, 34 ordinal INTEGER NOT NULL, 29 refcode INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, 30 dll TINYINT NOT NULL, 31 aliasfn INTEGER NOT NULL DEFAULT -1, 32 name VARCHAR(64) NOT NULL, 33 intname VARCHAR(64) NOT NULL, 34 state TINYINT NOT NULL DEFAULT 0, 35 ordinal INTEGER NOT NULL, 35 36 apigroup SMALLINT, 36 return VARCHAR(64), 37 updated TINYINT NOT NULL DEFAULT 0, 38 UNIQUE i1(refcode), 39 UNIQUE i2(name,dll), 40 UNIQUE i3(intname, refcode) 37 return VARCHAR(64), 38 updated TINYINT NOT NULL DEFAULT 0, 39 UNIQUE i1(refcode, aliasfn), 40 UNIQUE i1a(aliasfn, name, dll), 41 UNIQUE i1b(aliasfn, dll, refcode), 42 UNIQUE i1c(aliasfn, intname, dll, refcode), 43 UNIQUE i2(name, dll, refcode), 44 UNIQUE i3(intname, dll, refcode), 45 UNIQUE u1(refcode), 46 UNIQUE u2(name, dll) 41 47 ); 42 48 … … 46 52 name VARCHAR(64) NOT NULL, 47 53 description VARCHAR(128), 48 UNIQUE i1(refcode),49 UNIQUE i2(name)54 UNIQUE u1(refcode), 55 UNIQUE u2(name) 50 56 ); 51 57 … … 58 64 country VARCHAR(64), 59 65 location VARCHAR(64), 60 UNIQUE i1(refcode),61 UNIQUE i2(name),62 UNIQUE i3(initials)66 UNIQUE u1(refcode), 67 UNIQUE u2(name), 68 UNIQUE u3(initials) 63 69 -- ,UNIQUE i4(alias), UNIQUE columns have to be defined NOT NULL in mySql. 64 70 -- UNIQUE i5(email) UNIQUE columns have to be defined NOT NULL in mySql. … … 68 74 author SMALLINT NOT NULL, 69 75 function INTEGER NOT NULL, 70 UNIQUE i1(function, author)76 UNIQUE u1(function, author) 71 77 ); 72 78 … … 76 82 date DATE NOT NULL, 77 83 count SMALLINT NOT NULL, 78 UNIQUE i1(dll, state, date)84 UNIQUE u1(dll, state, date) 79 85 ); 80 86 … … 84 90 date DATE NOT NULL, 85 91 count SMALLINT NOT NULL, 86 UNIQUE i1(apigroup, state, date)92 UNIQUE u1(apigroup, state, date) 87 93 ); 88 94 … … 91 97 date DATE NOT NULL, 92 98 totalcount SMALLINT NOT NULL, 93 UNIQUE i1(dll, DATE)99 UNIQUE u1(dll, DATE) 94 100 ); 95 101 … … 98 104 date DATE NOT NULL, 99 105 totalcount SMALLINT NOT NULL, 100 UNIQUE i1(apigroup, date)106 UNIQUE u1(apigroup, date) 101 107 ); 102 108 103 109 CREATE TABLE parameter ( 104 function SMALLINTNOT NULL,110 function INTEGER NOT NULL, 105 111 sequencenbr TINYINT NOT NULL, 112 name VARCHAR(64) NOT NULL, 106 113 type VARCHAR(64) NOT NULL, 107 name VARCHAR(64) NOT NULL,108 114 description VARCHAR(128), 109 UNIQUE i1(function, name) 115 INDEX i1(function, name(10)), 116 UNIQUE u1(function, name) 110 117 ); 111 118 -
trunk/tools/database/Makefile
r2759 r2761 1 # $Id: Makefile,v 1. 6 2000-02-11 18:35:55 bird Exp $1 # $Id: Makefile,v 1.7 2000-02-11 23:54:25 bird Exp $ 2 2 3 3 # … … 13 13 CINCLUDES= -I$(PDWIN32_INCLUDE) -I$(PDWIN32_INCLUDE)\win -Igd -Imysql -I..\common 14 14 !ifdef DEBUG 15 CFLAGS = $(CFLAGS) -Ge+ -Tx+ -Tm- $(CINCLUDES) -DNO_CLIENT_LONG_LONG -Wall+ppt-ppc-inl-cnv-gnr-vft- 16 CXXFLAGS = $(CXXFLAGS) -Ge+ -Gx- -Tx+ -Tm- $(CINCLUDES) -DNO_CLIENT_LONG_LONG -Wall+ppt-ppc-inl-cnv-gnr-vft- 17 LDFLAGS = $(LDFLAGS) -Ge+ -Fe$@ /B"/MAP:full" $(RTLLIB) os2386.lib 15 CFLAGS = $(CFLAGS) -Ge+ -Tx+ -Tm- $(CINCLUDES) -DNO_CLIENT_LONG_LONG -Wall+ppt-ppc-inl-cnv-gnr-vft- -Gh+ 16 CXXFLAGS = $(CXXFLAGS) -Ge+ -Gx- -Tx+ -Tm- $(CINCLUDES) -DNO_CLIENT_LONG_LONG -Wall+ppt-ppc-inl-cnv-gnr-vft- -Gh+ 17 LDFLAGS = $(LDFLAGS) -Ge+ -Fe$@ /B"/MAP:full" $(RTLLIB) os2386.lib cppopa3.obj 18 18 !else 19 19 CFLAGS = $(CFLAGS) -Ge+ -Tx+ $(CINCLUDES) -DNO_CLIENT_LONG_LONG -Wall+ppt-ppc-inl-cnv-gnr-vft- -
trunk/tools/database/StateUpd.cpp
r2759 r2761 1 /* $Id: StateUpd.cpp,v 1. 8 2000-02-11 18:35:54 bird Exp $1 /* $Id: StateUpd.cpp,v 1.9 2000-02-11 23:54:24 bird Exp $ 2 2 * 3 3 * StateUpd - Scans source files for API functions and imports data on them. … … 626 626 627 627 /* 4.*/ 628 ulRcTmp = dbUpdateFunction(&FnDesc, &szErrorDesc[0]);628 ulRcTmp = dbUpdateFunction(&FnDesc, pOptions->lDllRefcode, &szErrorDesc[0]); 629 629 if (ulRcTmp != 0) 630 630 { … … 679 679 680 680 /* 3. */ 681 if (!dbFindFunction(pFnDesc->pszName, &FnFindBuf ))681 if (!dbFindFunction(pFnDesc->pszName, &FnFindBuf, pOptions->lDllRefcode)) 682 682 { 683 683 fprintf(phSignal, "%s, %s: error occured while reading from database, %s\n", … … 701 701 702 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 } 703 pFnDesc->alRefCode[pFnDesc->cRefCodes++] = FnFindBuf.alRefCode[lFn]; 707 704 708 705 if (pFnDesc->cRefCodes == 0) … … 741 738 */ 742 739 743 int iFn, iP1, iP2, j ;740 int iFn, iP1, iP2, j, c; 744 741 char * pszFn, *pszFnEnd, *pszP1, *pszP2; 745 742 char * psz, *pszEnd; … … 812 809 813 810 /* 3. */ 811 c = 1; 814 812 iP2 = iP1; 815 813 pszP2 = pszP1 + 1; 816 while (*pszP2 != ')') 814 while (c > 0) 815 { 816 if (*pszP2 == '(') 817 c++; 818 else if (*pszP2 == ')') 819 if (--c == 0) 820 break; 817 821 if (*pszP2++ == '\0') 818 822 if ((pszP2 = papszLines[++iP2]) == NULL) 819 823 break; 824 } 820 825 821 826 iRet = iP2 + 1; //assumes: only one function on a single line! … … 832 837 char *pszC; 833 838 pszC = trim(psz+1); 839 c = 1; 834 840 while (*pszC != '\0') 835 841 { 836 842 apszArgs[cArgs] = pszC; 837 while (*pszC != ',' && *pszC != ')' && *pszC != '\0') 843 while (*pszC != ',' && c > 0 && *pszC != '\0') 844 { 845 if (*pszC == '(') 846 c++; 847 else if (*pszC == ')') 848 if (--c == 0) 849 break; 838 850 pszC++; 851 } 839 852 *pszC = '\0'; 840 853 trim(apszArgs[cArgs++]); … … 877 890 pFnDesc->pszReturnType = *pszEnd == '\0' ? NULL : pszEnd; 878 891 pszEnd = strlen(pszEnd) + pszEnd + 1; 892 *pszEnd = '\0'; 879 893 880 894 /* function name */ 881 *pszEnd = '\0';882 895 if (pFnDesc->pszReturnType != NULL 883 896 && stristr(pFnDesc->pszReturnType, "cdecl") != NULL) 884 897 { /* cdecl function is prefixed with an '_' */ 885 898 strcpy(pszEnd, "_"); 886 strncat(pszEnd +1, pszFn, pszFnEnd - pszFn+1);899 strncat(pszEnd + 1, pszFn, pszFnEnd - pszFn+1); 887 900 } 888 901 else 889 902 strncat(pszEnd, pszFn, pszFnEnd - pszFn+1); 890 891 903 pFnDesc->pszName = pszEnd; 904 pszEnd = strlen(pszEnd) + pszEnd + 1; 905 *pszEnd = '\0'; 906 892 907 893 908 /* arguments */ … … 895 910 for (j = 0; j < cArgs; j++) 896 911 { 897 pFnDesc->apszParamName[j] = findStartOfWord(apszArgs[j] + strlen(apszArgs[j]) - 1, 898 apszArgs[j]); 899 pFnDesc->apszParamName[j][-1] = '\0'; 900 pFnDesc->apszParamType[j] = trim(apszArgs[j]); 912 if ((psz = strchr(apszArgs[j], ')')) == NULL) 913 { 914 pFnDesc->apszParamName[j] = findStartOfWord(apszArgs[j] + strlen(apszArgs[j]) - 1, 915 apszArgs[j]); 916 pFnDesc->apszParamName[j][-1] = '\0'; 917 pFnDesc->apszParamType[j] = trim(apszArgs[j]); 918 } 919 else 920 { 921 char *pszP2 = psz; 922 psz = findStartOfWord(psz-1, apszArgs[j]); 923 strncat(pszEnd, psz, pszP2 - psz); 924 925 pFnDesc->apszParamName[j] = pszEnd; 926 memset(psz, ' ', pszP2 - psz); 927 pFnDesc->apszParamType[j] = trim(apszArgs[j]); 928 929 pszEnd = strlen(pszEnd) + pszEnd + 1; 930 *pszEnd = '\0'; 931 } 901 932 } 902 933 } … … 1218 1249 1219 1250 while (pszFnName - cchFnName > papszLines[i] && pszFnName[cchFnName] == ' ') 1220 cchFnName-- ;1251 cchFnName--, pszFnName--; 1221 1252 1222 1253 pszFnName = findStartOfWord(pszFnName, papszLines[i]); … … 1239 1270 if (psz != NULL && *psz != '*') 1240 1271 { 1241 char *pszB = pszP1; /*'{'*/ 1272 char *pszB = pszP1 + 1; /*'{'*/ 1273 int c = 1; 1242 1274 1243 1275 /* 3. */ 1244 while (*pszB != ')') 1276 while (c > 0) 1277 { 1278 if (*pszB == '(') 1279 c++; 1280 else if (*pszB == ')') 1281 if (--c == 0) 1282 break; 1245 1283 if (*pszB++ == '\0') 1246 1284 if ((pszB = papszLines[++i]) == NULL) 1247 1285 break; 1286 } 1248 1287 if (pszB != NULL) 1249 1288 { … … 1293 1332 if (pszP1 != NULL && *pszP1 == '(') 1294 1333 { 1295 char *pszB = pszP1; /*'{'*/ 1334 char *pszB = pszP1 + 1; /*'{'*/ 1335 int c = 1; 1296 1336 1297 1337 /* 3. */ 1298 while (*pszB != ')') 1338 while (c > 0) 1339 { 1340 if (*pszB == '(') 1341 c++; 1342 else if (*pszB == ')') 1343 if (--c == 0) 1344 break; 1299 1345 if (*pszB++ == '\0') 1300 1346 if ((pszB = papszLines[++i]) == NULL) 1301 1347 break; 1348 } 1302 1349 if (pszB != NULL) 1303 1350 { -
trunk/tools/database/db.cpp
r2759 r2761 1 /* $Id: db.cpp,v 1. 5 2000-02-11 18:35:54 bird Exp $ */2 /*1 /* $Id: db.cpp,v 1.6 2000-02-11 23:54:25 bird Exp $ * 2 * 3 3 * DB - contains all database routines. 4 4 * … … 80 80 static unsigned long CheckAuthorError(char * &pszError, const char *pszFieldName, const char *pszFieldValue, const char *pszQuery); 81 81 static unsigned long logDbError(char * &pszError, const char *pszQuery); 82 #if def NOTDLL82 #ifndef DLL 83 83 extern "C" void dbHandler(int sig); 84 84 #endif … … 103 103 { 104 104 BOOL fRet = FALSE; 105 #if def NOTDLL105 #ifndef DLL 106 106 static fHandler = FALSE; 107 107 /* signal handler */ … … 188 188 if (ulDll >= 0) 189 189 { 190 sprintf(&szQuery[0], "SELECT count(refcode) FROM function WHERE dll = % d\n", ulDll);190 sprintf(&szQuery[0], "SELECT count(refcode) FROM function WHERE dll = %ld\n", ulDll); 191 191 rc = mysql_query(pmysql, &szQuery[0]); 192 192 pres = mysql_store_result(pmysql); … … 360 360 } 361 361 362 362 #if 0 363 363 /** 364 364 * Find occurences of a function, given by internal name. … … 366 366 * @param pszFunctionName 367 367 * @param pFnFindBuf 368 */ 369 BOOL _System dbFindFunction(const char *pszFunctionName, PFNFINDBUF pFnFindBuf) 368 * @param lDll 369 */ 370 BOOL _System dbFindFunction(const char *pszFunctionName, PFNFINDBUF pFnFindBuf, signed long lDll) 370 371 { 371 372 MYSQL_RES *pres; … … 374 375 char szQuery[256]; 375 376 376 sprintf(&szQuery[0], "SELECT refcode, dll FROM function WHERE intname = '%s'", 377 pszFunctionName, pszFunctionName); 377 if (lDll < 0) 378 sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function WHERE intname = '%s'", 379 pszFunctionName); 380 else 381 sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function " 382 "WHERE intname = '%s' AND dll = %ld", 383 pszFunctionName, lDll); 378 384 379 385 rc = mysql_query(pmysql, &szQuery[0]); … … 388 394 pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]); 389 395 pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]); 396 pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]); 390 397 391 398 /* next */ … … 393 400 } 394 401 mysql_free_result(pres); 402 403 /* alias check and fix */ 404 if (lDll >= 0 && pFnFindBuf->cFns != 0) 405 { 406 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 ("); 439 for (i = 0; i < pFnFindBuf->cFns; i++) 440 { 441 if (i != 0) strcat(&szQuery[0], "OR "); 442 sprintf(&szQuery[strlen(szQuery)], "aliasfn = %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 else 459 pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = ALIAS_NULL; 460 461 /* next */ 462 pFnFindBuf->cFns++; 463 } 464 mysql_free_result(pres); 465 } 466 } 467 } 468 } 469 } 470 } 395 471 } 396 472 else … … 400 476 return rc >= 0; 401 477 } 478 #else 479 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 pszFunctionName 519 * @param pFnFindBuf 520 * @param lDll 521 */ 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 else 533 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 /* Make the selected function to DONT TOUCH */ 561 sprintf(&szQuery[0], "UPDATE function SET aliasfn = (-2) " 562 "WHERE (", 563 lDll, pszFunctionName); 564 for (i = 0; i < pFnFindBuf->cFns; i++) 565 { 566 if (i != 0) strcat(&szQuery[0], " OR"); 567 sprintf(&szQuery[strlen(szQuery)], " refcode = %ld", pFnFindBuf->alRefCode[i]); 568 } 569 strcat(&szQuery[0], ") AND aliasfn <> (-2)"); 570 571 rc = mysql_query2(pmysql, &szQuery[0]); 572 if (rc >= 0) 573 { 574 /* Update all with equal internal... which is not in this Dll */ 575 sprintf(&szQuery[0], "UPDATE function SET aliasfn = (%ld) " 576 "WHERE aliasfn = (-1) AND dll <> %ld AND intname = '%s'", 577 pFnFindBuf->alRefCode[0], lDll, pszFunctionName, pszFunctionName); 578 rc = mysql_query3(pmysql, &szQuery[0]); 579 if (rc >= 0) 580 { 581 /* Update all with equal external name... which is not in this Dll */ 582 sprintf(&szQuery[0], "UPDATE function SET aliasfn = (%ld) " 583 "WHERE aliasfn = (-1) AND dll <> %ld AND name = '%s'", 584 pFnFindBuf->alRefCode[0], lDll, pszFunctionName, pszFunctionName); 585 586 rc = mysql_query4(pmysql, &szQuery[0]); 587 if (rc >= 0) 588 { 589 int cFns = pFnFindBuf->cFns; 590 for (i = 0; i < cFns; i++) 591 { 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]); 596 if (rc >= 0) 597 { 598 pres = mysql_store_result2(pmysql); 599 if (pres != NULL) 600 { 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); 615 } 616 } 617 } 618 } 619 } 620 } 621 } 622 } 623 else 624 rc = -1; 625 } 626 627 return rc >= 0; 628 } 629 630 #endif 402 631 403 632 … … 475 704 * Updates function information. 476 705 * @returns number of errors. 477 * @param pFnDesc 478 * @param pszError 706 * @param pFnDesc Function description struct. 707 * @param lDll Dll which we are working at. 708 * @param pszError Buffer for error messages 479 709 * @result on error(s) pszError will hold information about the error(s). 480 710 */ 481 unsigned long _System dbUpdateFunction(PFNDESC pFnDesc, char *pszError)711 unsigned long _System dbUpdateFunction(PFNDESC pFnDesc, signed long lDll, char *pszError) 482 712 { 483 713 char szQuery[256]; … … 491 721 { 492 722 /* set updated flag */ 493 sprintf(pszQuery, "UPDATE function SET updated = updated + 1 WHERE refcode = % d",723 sprintf(pszQuery, "UPDATE function SET updated = updated + 1 WHERE refcode = %ld", 494 724 pFnDesc->alRefCode[k]); 495 725 rc = mysql_query(pmysql, &szQuery[0]); … … 515 745 if (pFnDesc->pszReturnType != NULL) 516 746 { 517 if (f) 518 { 519 strcat(pszQuery, ", "); 520 pszQuery += strlen(pszQuery); 521 } 522 sprintf(pszQuery, "return = '%s' ", pFnDesc->pszReturnType); 747 if (f) strcat(pszQuery, ", "); 748 sprintf(pszQuery + strlen(pszQuery), "return = '%s' ", pFnDesc->pszReturnType); 523 749 pszQuery += strlen(pszQuery); 524 750 f = TRUE; … … 527 753 if (f) 528 754 { 529 sprintf(pszQuery , "WHERE refcode = %ld", pFnDesc->alRefCode[k]);755 sprintf(pszQuery + strlen(pszQuery), "WHERE refcode = %ld", pFnDesc->alRefCode[k]); 530 756 rc = mysql_query(pmysql, &szQuery[0]); 531 757 if (rc < 0) … … 605 831 } 606 832 } /* for */ 833 834 lDll = lDll; 607 835 return ulRc; 608 836 } … … 1195 1423 1196 1424 /* not updated names */ 1197 sprintf(&szQuery[0], "SELECT name, intname FROM function WHERE dll = % d AND updated = 0",1425 sprintf(&szQuery[0], "SELECT name, intname FROM function WHERE dll = %ld AND updated = 0", 1198 1426 lDll); 1199 1427 pres = dbExecuteQuery(szQuery); … … 1210 1438 1211 1439 /* warn about updated > 1 too */ 1212 sprintf(&szQuery[0], "SELECT updated, name, intname FROM function WHERE dll = % d AND updated > 1",1440 sprintf(&szQuery[0], "SELECT updated, name, intname FROM function WHERE dll = %ld AND updated > 1", 1213 1441 lDll); 1214 1442 pres = dbExecuteQuery(szQuery); … … 1224 1452 } 1225 1453 1226 sprintf(&szQuery[0], "UPDATE function SET updated = 0", 1227 lDll); 1454 strcpy(&szQuery[0], "UPDATE function SET updated = 0"); 1228 1455 mysql_query(pmysql, &szQuery[0]); 1229 1456 … … 1232 1459 1233 1460 1234 #if def NOTDLL1461 #ifndef DLL 1235 1462 /** 1236 1463 * Signal handler. -
trunk/tools/database/db.h
r2759 r2761 1 /* $Id: db.h,v 1. 3 2000-02-11 18:35:54bird Exp $ */1 /* $Id: db.h,v 1.4 2000-02-11 23:54:25 bird Exp $ */ 2 2 /* 3 3 * DB - contains all database routines … … 19 19 * Defined Constants * 20 20 *******************************************************************************/ 21 #define NBR_FUNCTIONS 20 22 #define NBR_AUTHORS 20 21 #define NBR_FUNCTIONS 20 22 #define NBR_AUTHORS 20 23 #define ALIAS_NULL -1 24 #define ALIAS_DONTMIND -2 25 23 26 24 27 /******************************************************************************* … … 36 39 long cRefCodes; 37 40 long alRefCode[NBR_FUNCTIONS]; 41 signed long lImpDll; /* -1 is SQL-NULL, -2 is do not mind, >= 0 ref to dll. */ 38 42 39 43 /* parameters */ … … 58 62 signed long alRefCode[NBR_FUNCTIONS]; 59 63 signed long alDllRefCode[NBR_FUNCTIONS]; 64 signed long alAliasFn[NBR_FUNCTIONS]; /* -1 is SQL-NULL, -2 is do not mind, >= 0 ref to function. */ 60 65 } FNFINDBUF, *PFNFINDBUF; 61 66 … … 86 91 BOOL fIgnoreOrdinal); 87 92 BOOL _System dbFindFunction(const char *pszFunctionName, 88 PFNFINDBUF pFnFindBuf); 93 PFNFINDBUF pFnFindBuf, 94 signed long lDll); 89 95 signed long _System dbFindAuthor(const char *pszAuthor); 90 96 signed long _System dbGetFunctionState(signed long lRefCode); 91 97 unsigned long _System dbUpdateFunction(PFNDESC pFnDesc, 98 signed long lDll, 92 99 char *pszError); 93 100 unsigned long _System dbCreateHistory(char *pszError);
Note:
See TracChangeset
for help on using the changeset viewer.