Changeset 6677 for trunk/tools/database/db.cpp
- Timestamp:
- Sep 7, 2001, 12:26:42 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/database/db.cpp
r6663 r6677 1 /* $Id: db.cpp,v 1.2 5 2001-09-06 03:07:32bird Exp $ *1 /* $Id: db.cpp,v 1.26 2001-09-07 10:24:07 bird Exp $ * 2 2 * 3 3 * DB - contains all database routines. … … 154 154 155 155 /** 156 * Gets the refid for the give dllname.157 * @returns Dllrefid. -1 on error.158 * @param pszDllName Dllname.159 */ 160 signed long _System dbGet Dll(const char *pszDllName)156 * Gets the refid for the give mod name. 157 * @returns Module refid. -1 on error. 158 * @param pszModName Module name. 159 */ 160 signed long _System dbGetModule(const char *pszModName) 161 161 { 162 162 int rc; … … 164 164 MYSQL_RES * pres; 165 165 166 sprintf(&szQuery[0], "SELECT refcode FROM dll WHERE name = '%s'\n", pszDllName);166 sprintf(&szQuery[0], "SELECT refcode FROM module WHERE name = '%s'\n", pszModName); 167 167 rc = mysql_query(pmysql, &szQuery[0]); 168 168 pres = mysql_store_result(pmysql); … … 178 178 179 179 /** 180 * Count the function in a given dll.181 * @returns 182 * @param lDll Dllrefcode.183 * @param fNotAliasesTRUE: don't count aliased functions.184 */ 185 signed long _System dbCountFunctionIn Dll(signed long lDll, BOOL fNotAliases)180 * Count the function in a given module. 181 * @returns Number of functions. -1 on error. 182 * @param lModule Module refcode. 183 * @param fNotAliases TRUE: don't count aliased functions. 184 */ 185 signed long _System dbCountFunctionInModule(signed long lModule, BOOL fNotAliases) 186 186 { 187 187 signed long rc; … … 189 189 MYSQL_RES * pres; 190 190 191 if (l Dll>= 0)192 { 193 sprintf(&szQuery[0], "SELECT count(refcode) FROM function WHERE dll = %ld\n", lDll);191 if (lModule >= 0) 192 { 193 sprintf(&szQuery[0], "SELECT count(refcode) FROM function WHERE module = %ld\n", lModule); 194 194 if (fNotAliases) 195 195 strcat(&szQuery[0], " AND aliasfn < 0"); … … 211 211 212 212 /** 213 * Checks if dll exists. If not exists the dll is inserted. 214 * @returns Dll refcode. -1 on errors. 215 * @param pszDll Dll name. 216 * @remark This search must be case insensitive. 217 * (In the mysql-world everything is case insensitive!) 218 */ 219 signed long _System dbCheckInsertDll(const char *pszDll, char fchType) 213 * Checks if module exists. If not exists the module is inserted. 214 * @returns Module refcode. -1 on errors. 215 * @param pszModule Module name. 216 * @param fchType Module type. 217 * @remark This search must be case insensitive. 218 * (In the mysql-world everything is case insensitive!) 219 */ 220 signed long _System dbCheckInsertModule(const char *pszModule, char fchType) 220 221 { 221 222 int rc; … … 224 225 225 226 /* try find match */ 226 sprintf(&szQuery[0], "SELECT refcode, name FROM dll WHERE name = '%s'\n", pszDll);227 sprintf(&szQuery[0], "SELECT refcode, name FROM module WHERE name = '%s'\n", pszModule); 227 228 rc = mysql_query(pmysql, &szQuery[0]); 228 229 pres = mysql_store_result(pmysql); 229 230 230 /* not found? - insert dll*/231 /* not found? - insert module */ 231 232 if (rc < 0 || pres == NULL || mysql_num_rows(pres) == 0) 232 233 { 233 234 mysql_free_result(pres); 234 235 235 sprintf(&szQuery[0], "INSERT INTO dll(name, type) VALUES('%s', '%c')\n", pszDll, fchType);236 sprintf(&szQuery[0], "INSERT INTO module(name, type) VALUES('%s', '%c')\n", pszModule, fchType); 236 237 rc = mysql_query(pmysql, &szQuery[0]); 237 238 if (rc < 0) … … 239 240 240 241 /* select row to get refcode */ 241 sprintf(&szQuery[0], "SELECT refcode, name FROM dll WHERE name = '%s'\n", pszDll);242 sprintf(&szQuery[0], "SELECT refcode, name FROM module WHERE name = '%s'\n", pszModule); 242 243 rc = mysql_query(pmysql, &szQuery[0]); 243 244 pres = mysql_store_result(pmysql); … … 290 291 * The update flags is always updated. 291 292 * @returns Success indicator. TRUE / FALSE. 292 * @param l Dll Dllrefcode.293 * @param lModule Module refcode. 293 294 * @param pszFunction Function name. 294 295 * @param pszIntFunction Internal function name. (required!) … … 297 298 * @param fchType Function type flag. One of the FUNCTION_* defines. 298 299 */ 299 BOOL _System dbInsertUpdateFunction(signed long l Dll,300 BOOL _System dbInsertUpdateFunction(signed long lModule, 300 301 const char *pszFunction, const char *pszIntFunction, 301 302 unsigned long ulOrdinal, BOOL fIgnoreOrdinal, char fchType) … … 312 313 313 314 /* try find function */ 314 sprintf(pszQuery, "SELECT refcode, intname FROM function WHERE dll = %d AND name = '%s'", lDll, pszFunction);315 sprintf(pszQuery, "SELECT refcode, intname FROM function WHERE module = %d AND name = '%s'", lModule, pszFunction); 315 316 rc = mysql_query(pmysql, pszQuery); 316 317 pres = mysql_store_result(pmysql); … … 322 323 if (mysql_num_rows(pres) > 1) 323 324 { 324 fprintf(stderr, "internal database integrity error(%s): More function by the same name for the same dll. "325 "l Dll = %d, pszFunction = %s\n", __FUNCTION__, lDll, pszFunction);325 fprintf(stderr, "internal database integrity error(%s): More function by the same name for the same module. " 326 "lModule = %d, pszFunction = %s\n", __FUNCTION__, lModule, pszFunction); 326 327 return FALSE; 327 328 } … … 347 348 * Insert it. 348 349 */ 349 sprintf(&szQuery[0], "INSERT INTO function( dll, name, intname, ordinal, updated, type) VALUES(%d, '%s', '%s', %ld, 1, '%c')",350 l Dll, pszFunction, pszIntFunction, ulOrdinal, fchType);350 sprintf(&szQuery[0], "INSERT INTO function(module, name, intname, ordinal, updated, type) VALUES(%d, '%s', '%s', %ld, 1, '%c')", 351 lModule, pszFunction, pszIntFunction, ulOrdinal, fchType); 351 352 rc = mysql_query(pmysql, &szQuery[0]); 352 353 } … … 360 361 * Inserts or updates (existing) file information. 361 362 * @returns Success indicator (TRUE / FALSE). 362 * @param l Dll Dllreference code.363 * @param lModule Module reference code. 363 364 * @param pszFilename Filename. 364 365 * @param pszDescription Pointer to file description. … … 369 370 * @remark 370 371 */ 371 BOOL _System dbInsertUpdateFile(signed long l Dll,372 BOOL _System dbInsertUpdateFile(signed long lModule, 372 373 const char *pszFilename, 373 374 const char *pszDescription, … … 382 383 383 384 /* parameter assertions */ 384 assert(l Dll!= 0);385 assert(lModule != 0); 385 386 assert(pszFilename != NULL); 386 387 assert(*pszFilename != '\0'); 387 388 388 389 /* try find file */ 389 sprintf(&szQuery[0], "SELECT refcode, name FROM file WHERE dll = %d AND name = '%s'", lDll, pszFilename);390 sprintf(&szQuery[0], "SELECT refcode, name FROM file WHERE module = %d AND name = '%s'", lModule, pszFilename); 390 391 rc = mysql_query(pmysql, &szQuery[0]); 391 392 pres = mysql_store_result(pmysql); … … 395 396 if (mysql_num_rows(pres) > 1) 396 397 { 397 fprintf(stderr, "internal database integrity error(%s): More files by the same name in the same dll. "398 "l Dll = %d, pszFilename = %s\n", __FUNCTION__, lDll, pszFilename);398 fprintf(stderr, "internal database integrity error(%s): More files by the same name in the same module. " 399 "lModule = %d, pszFilename = %s\n", __FUNCTION__, lModule, pszFilename); 399 400 return FALSE; 400 401 } … … 450 451 else 451 452 { /* insert */ 452 sprintf(&szQuery[0], "INSERT INTO file( dll, name, lastauthor, description, lastdatetime, revision) VALUES(%d, '%s', %ld, ",453 l Dll, pszFilename, lLastAuthor);453 sprintf(&szQuery[0], "INSERT INTO file(module, name, lastauthor, description, lastdatetime, revision) VALUES(%d, '%s', %ld, ", 454 lModule, pszFilename, lLastAuthor); 454 455 if (pszDescription != NULL && *pszDescription != '\0') 455 456 sqlstrcat(&szQuery[0], NULL, pszDescription); … … 524 525 * @param pszFunctionName Pointer to a function name string. (input) 525 526 * @param pFnFindBuf Pointer to a find buffer. (output) 526 * @param l Dll Dllrefcode (optional). If given the search is limited to527 * the given dlland aliasing functions is updated (slow!).528 * @sketch 1) Get functions for this dll(if given).527 * @param lModule Module refcode (optional). If given the search is limited to 528 * the given module and aliasing functions is updated (slow!). 529 * @sketch 1) Get functions for this module(if given). 529 530 * 2) Get functions which aliases the functions found in (1). 530 531 * 3) Get new aliases by intname … … 533 534 * 6) Update all functions from (3) and (4) to alias the first function from 1. 534 535 */ 535 BOOL _System dbFindFunction(const char *pszFunctionName, PFNFINDBUF pFnFindBuf, signed long l Dll)536 BOOL _System dbFindFunction(const char *pszFunctionName, PFNFINDBUF pFnFindBuf, signed long lModule) 536 537 { 537 538 MYSQL_RES *pres; … … 541 542 542 543 /* 543 * 1) Get functions for this dll(if given).544 * 1) Get functions for this module(if given). 544 545 */ 545 if (l Dll< 0)546 sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn, file, name FROM function WHERE intname = '%s'",546 if (lModule < 0) 547 sprintf(&szQuery[0], "SELECT refcode, module, aliasfn, file, name, type FROM function WHERE intname = '%s'", 547 548 pszFunctionName); 548 549 else 549 sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn, file, name FROM function "550 "WHERE intname = '%s' AND dll= %ld",551 pszFunctionName, l Dll);550 sprintf(&szQuery[0], "SELECT refcode, module, aliasfn, file, name, type FROM function " 551 "WHERE intname = '%s' AND module = %ld", 552 pszFunctionName, lModule); 552 553 553 554 rc = mysql_query1(pmysql, &szQuery[0]); … … 558 559 { 559 560 char szFnName[NBR_FUNCTIONS][80]; 561 BOOL fAPI = FALSE; 560 562 561 563 pFnFindBuf->cFns = 0; … … 563 565 { 564 566 pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]); 565 pFnFindBuf->al DllRefCode[pFnFindBuf->cFns] = atol(row[1]);567 pFnFindBuf->alModRefCode[pFnFindBuf->cFns] = atol(row[1]); 566 568 pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]); 567 569 pFnFindBuf->alFileRefCode[pFnFindBuf->cFns] = atol(row[3]); 568 570 strcpy(szFnName[pFnFindBuf->cFns], row[4]); 571 pFnFindBuf->achType[pFnFindBuf->cFns] = *row[5]; 572 if (pFnFindBuf->achType[pFnFindBuf->cFns] == FUNCTION_ODIN32_API || 573 pFnFindBuf->achType[pFnFindBuf->cFns] == FUNCTION_INTERNAL_ODIN32_API) 574 fAPI = TRUE; 569 575 570 576 /* next */ … … 573 579 mysql_free_result(pres); 574 580 575 /* alias check and fix */576 if ( lDll>= 0 && pFnFindBuf->cFns != 0)581 /* alias check and fix for apis. */ 582 if (fAPI && lModule >= 0 && pFnFindBuf->cFns != 0) 577 583 { 578 int cFnsThis Dll, cFnsAliasesAndThisDll, i, f;584 int cFnsThisModule, cFnsAliasesAndThisModule, i, f; 579 585 580 586 /* 581 587 * 2) Get functions which aliases the functions found in (1). 582 588 */ 583 cFnsThis Dll= (int)pFnFindBuf->cFns;584 strcpy(&szQuery[0], "SELECT refcode, dll, aliasfn, file, name FROM function WHERE aliasfn IN (");585 for (i = 0; i < cFnsThis Dll; i++)589 cFnsThisModule = (int)pFnFindBuf->cFns; 590 strcpy(&szQuery[0], "SELECT refcode, module, aliasfn, file, name FROM function WHERE aliasfn IN ("); 591 for (i = 0; i < cFnsThisModule; i++) 586 592 { 587 593 if (i > 0) strcat(&szQuery[0], " OR "); … … 599 605 { 600 606 pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]); 601 pFnFindBuf->al DllRefCode[pFnFindBuf->cFns] = atol(row[1]);607 pFnFindBuf->alModRefCode[pFnFindBuf->cFns] = atol(row[1]); 602 608 pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]); 603 609 pFnFindBuf->alFileRefCode[pFnFindBuf->cFns] = atol(row[3]); … … 612 618 * 3) Get new aliases by intname 613 619 */ 614 cFnsAliasesAndThis Dll= (int)pFnFindBuf->cFns;615 sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn, file FROM function "616 "WHERE aliasfn = (-1) AND dll<> %ld AND (intname = '%s'",617 l Dll, pszFunctionName);618 for (i = 0; i < cFnsAliasesAndThis Dll; i++)620 cFnsAliasesAndThisModule = (int)pFnFindBuf->cFns; 621 sprintf(&szQuery[0], "SELECT refcode, module, aliasfn, file FROM function " 622 "WHERE aliasfn = (-1) AND module <> %ld AND (intname = '%s'", 623 lModule, pszFunctionName); 624 for (i = 0; i < cFnsAliasesAndThisModule; i++) 619 625 sprintf(&szQuery[strlen(&szQuery[0])], " OR intname = '%s'", szFnName[i]); 620 626 strcat(&szQuery[0], ")"); … … 629 635 { 630 636 pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]); 631 pFnFindBuf->al DllRefCode[pFnFindBuf->cFns] = atol(row[1]);637 pFnFindBuf->alModRefCode[pFnFindBuf->cFns] = atol(row[1]); 632 638 if (row[2] != NULL) 633 639 pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]); … … 645 651 * 4) Get new aliases by name 646 652 */ 647 sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn, file FROM function "648 "WHERE aliasfn = (-1) AND dll<> %ld AND (name = '%s'",649 l Dll, pszFunctionName);650 for (i = 0; i < cFnsAliasesAndThis Dll; i++)653 sprintf(&szQuery[0], "SELECT refcode, module, aliasfn, file FROM function " 654 "WHERE aliasfn = (-1) AND module <> %ld AND (name = '%s'", 655 lModule, pszFunctionName); 656 for (i = 0; i < cFnsAliasesAndThisModule; i++) 651 657 sprintf(&szQuery[strlen(&szQuery[0])], " OR name = '%s'", szFnName[i]); 652 658 strcat(&szQuery[0], ")"); … … 661 667 { 662 668 pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]); 663 pFnFindBuf->al DllRefCode[pFnFindBuf->cFns] = atol(row[1]);669 pFnFindBuf->alModRefCode[pFnFindBuf->cFns] = atol(row[1]); 664 670 if (row[2] != NULL) 665 671 pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]); … … 678 684 sprintf(&szQuery[0], "UPDATE function SET aliasfn = (-2) " 679 685 "WHERE refcode IN (", 680 l Dll, pszFunctionName);681 for (f = 0, i = 0; i < cFnsThis Dll; i++)686 lModule, pszFunctionName); 687 for (f = 0, i = 0; i < cFnsThisModule; i++) 682 688 if (pFnFindBuf->alAliasFn[i] != ALIAS_DONTMIND) 683 689 sprintf(&szQuery[strlen(&szQuery[0])], … … 688 694 else 689 695 rc = 0; 690 if (rc >= 0 && cFnsAliasesAndThis Dll< pFnFindBuf->cFns)696 if (rc >= 0 && cFnsAliasesAndThisModule < pFnFindBuf->cFns) 691 697 { 692 698 /* … … 696 702 "WHERE aliasfn = (-1) AND refcode IN (", 697 703 pFnFindBuf->alRefCode[0], pFnFindBuf->alFileRefCode[0]); 698 for (i = cFnsAliasesAndThis Dll; i < pFnFindBuf->cFns; i++)704 for (i = cFnsAliasesAndThisModule; i < pFnFindBuf->cFns; i++) 699 705 { 700 706 sprintf(&szQuery[strlen(&szQuery[0])], 701 i > cFnsAliasesAndThis Dll? ", %ld" : "%ld", pFnFindBuf->alRefCode[i]);707 i > cFnsAliasesAndThisModule ? ", %ld" : "%ld", pFnFindBuf->alRefCode[i]); 702 708 } 703 709 strcat(&szQuery[0], ")"); … … 722 728 /** 723 729 * Finds the refcode for a file (if it exists). 724 * @returns 725 * 726 * @param lDll Refcode of the dllwhich this file belongs to.727 * @param 728 */ 729 signed long _System dbFindFile(signed long l Dll, const char *pszFilename)730 * @returns File 'refcode'. 731 * -1 on error or not found. 732 * @param lModule Refcode of the module which this file belongs to. 733 * @param pszFilename The filename to search for. 734 */ 735 signed long _System dbFindFile(signed long lModule, const char *pszFilename) 730 736 { 731 737 char szQuery[256]; … … 733 739 signed long lRefCode = -1; 734 740 735 assert(l Dll>= 0);741 assert(lModule >= 0); 736 742 assert(pszFilename != NULL); 737 743 assert(*pszFilename != '\0'); 738 744 739 sprintf(&szQuery[0], "SELECT refcode FROM file WHERE dll= %ld AND name = '%s'",740 l Dll, pszFilename);745 sprintf(&szQuery[0], "SELECT refcode FROM file WHERE module = %ld AND name = '%s'", 746 lModule, pszFilename); 741 747 if (mysql_query(pmysql, &szQuery[0]) >= 0) 742 748 { … … 878 884 * @returns number of errors. 879 885 * @param pFnDesc Function description struct. 880 * @param l Dll Dllwhich we are working at.886 * @param lModule Module which we are working at. 881 887 * @param pszError Buffer for error messages 882 888 * @result on error(s) pszError will hold information about the error(s). 883 889 */ 884 unsigned long _System dbUpdateFunction(PFNDESC pFnDesc, signed long l Dll, char *pszError)890 unsigned long _System dbUpdateFunction(PFNDESC pFnDesc, signed long lModule, char *pszError) 885 891 { 886 892 MYSQL_RES * pres; … … 1140 1146 } /* for */ 1141 1147 1142 l Dll = lDll;1148 lModule = lModule; 1143 1149 free(pszQuery2); 1144 1150 return ulRc; … … 1148 1154 /** 1149 1155 * Removes all the existing design notes in the specified file. 1150 * @returns Success indicator. 1151 * @param lFile File refcode of the file to remove all design notes for. 1152 * @sketch 1153 * @status 1154 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 1155 * @remark 1156 * @returns Success indicator. 1157 * @param lFile File refcode of the file to remove all design notes for. 1158 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 1156 1159 */ 1157 1160 BOOL _System dbRemoveDesignNotes(signed long lFile) … … 1168 1171 * Adds a design note. 1169 1172 * @returns Success indicator. 1170 * @param l Dll Dllrefcode.1173 * @param lModule Module refcode. 1171 1174 * @param lFile File refcode. 1172 1175 * @param pszTitle Design note title. 1173 1176 * @param pszText Design note text. 1174 1177 * @param lLevel Level of the note section. 0 is the design note it self. 1175 * @param lSeqNbr Sequence number (in dll). If 0 the use next available number.1178 * @param lSeqNbr Sequence number (in module). If 0 the use next available number. 1176 1179 * @param lSeqNbrNote Sequence number in note. 1177 1180 * @param lLine Line number (1 - based!). … … 1181 1184 * @param plRefCode Pointer to reference id of the design note. see fSubSection for more info. 1182 1185 */ 1183 BOOL _System dbAddDesignNote(signed long l Dll,1186 BOOL _System dbAddDesignNote(signed long lModule, 1184 1187 signed long lFile, 1185 1188 const char *pszTitle, … … 1197 1200 1198 1201 1199 assert(l Dll>= 0 && lFile >= 0);1202 assert(lModule >= 0 && lFile >= 0); 1200 1203 assert(lSeqNbrNote >= 0); 1201 1204 … … 1205 1208 if (lSeqNbr == 0 && !fSubSection) 1206 1209 { 1207 sprintf(&szQuery[0], "SELECT MAX(seqnbr) + 1 FROM designnote WHERE dll = %ld AND level = 0", lDll);1210 sprintf(&szQuery[0], "SELECT MAX(seqnbr) + 1 FROM designnote WHERE module = %ld AND level = 0", lModule); 1208 1211 if (mysql_query(pmysql, &szQuery[0]) >= 0) 1209 1212 { … … 1229 1232 */ 1230 1233 if (!fSubSection) 1231 sprintf(&szQuery[0], "INSERT INTO designnote( dll, file, level, seqnbrnote, seqnbr, line, name, note) "1234 sprintf(&szQuery[0], "INSERT INTO designnote(module, file, level, seqnbrnote, seqnbr, line, name, note) " 1232 1235 "VALUES (%ld, %ld, %ld, %ld, %ld, %ld, ", 1233 l Dll, lFile, lLevel, lSeqNbrNote, lSeqNbr, lLine);1236 lModule, lFile, lLevel, lSeqNbrNote, lSeqNbr, lLine); 1234 1237 else 1235 sprintf(&szQuery[0], "INSERT INTO designnote(refcode, dll, file, level, seqnbrnote, seqnbr, line, name, note) "1238 sprintf(&szQuery[0], "INSERT INTO designnote(refcode, module, file, level, seqnbrnote, seqnbr, line, name, note) " 1236 1239 "VALUES (%ld, %ld, %ld, %ld, %ld, %ld, %ld, ", 1237 *plRefCode, l Dll, lFile, lLevel, lSeqNbrNote, lSeqNbr, lLine);1240 *plRefCode, lModule, lFile, lLevel, lSeqNbrNote, lSeqNbr, lLine); 1238 1241 1239 1242 if (pszTitle != NULL && *pszTitle != '\0') … … 1286 1289 1287 1290 /* delete - all rows on this date in the history tables */ 1288 sprintf(pszQuery, "DELETE FROM history dllWHERE date = '%s'", &szCurDt[0]);1291 sprintf(pszQuery, "DELETE FROM historymodule WHERE date = '%s'", &szCurDt[0]); 1289 1292 rc = mysql_query(pmysql, pszQuery); 1290 1293 CheckLogContinue((pszError, "error removing old history rows: %s - (sql=%s) ", dbGetLastErrorDesc(), pszQuery)); … … 1294 1297 CheckLogContinue((pszError, "error removing old history rows: %s - (sql=%s) ", dbGetLastErrorDesc(), pszQuery)); 1295 1298 1296 sprintf(pszQuery, "DELETE FROM history dlltotal WHERE date = '%s'", &szCurDt[0]);1299 sprintf(pszQuery, "DELETE FROM historymoduletotal WHERE date = '%s'", &szCurDt[0]); 1297 1300 rc = mysql_query(pmysql, pszQuery); 1298 1301 CheckLogContinue((pszError, "error removing old history rows: %s - (sql=%s) ", dbGetLastErrorDesc(), pszQuery)); … … 1302 1305 1303 1306 /* insert new stats */ 1304 sprintf(pszQuery, "INSERT INTO history dll(dll, state, date, count) "1305 "SELECT dll, state, '%s', count(*) FROM function GROUP BY dll, state",1307 sprintf(pszQuery, "INSERT INTO historymodule(module, state, date, count, type) " 1308 "SELECT module, state, '%s', count(*), type FROM function GROUP BY module, state, type", 1306 1309 &szCurDt[0]); 1307 1310 rc = mysql_query(pmysql, pszQuery); … … 1316 1319 1317 1320 /* inserting new totals */ 1318 sprintf(pszQuery, "INSERT INTO history dlltotal(dll, date, totalcount) "1319 "SELECT dll, '%s', count(*) FROM function GROUP BY dll",1321 sprintf(pszQuery, "INSERT INTO historymoduletotal(module, date, totalcount, type) " 1322 "SELECT module, '%s', count(*), type FROM function GROUP BY module, type", 1320 1323 &szCurDt[0]); 1321 1324 rc = mysql_query(pmysql, pszQuery); … … 1323 1326 1324 1327 sprintf(pszQuery, "INSERT INTO historyapigrouptotal(apigroup, date, totalcount) " 1325 "SELECT apigroup, '%s', count(*) FROM function WHERE apigroup IS NOT NULL "1328 "SELECT apigroup, '%s', count(*) FROM function WHERE apigroup IS NOT NULL AND type = 'A' " 1326 1329 "GROUP BY apigroup", 1327 1330 &szCurDt[0]); … … 1369 1372 1370 1373 /* foreign keys in function table */ 1371 strcpy(pszQuery, "SELECT refcode, dll, state, apigroup, file FROM function");1374 strcpy(pszQuery, "SELECT refcode, module, state, apigroup, file FROM function"); 1372 1375 rc = mysql_query(pmysql, pszQuery); 1373 1376 if (rc >= 0) … … 1378 1381 while ((row1 = mysql_fetch_row(pres1)) != NULL) 1379 1382 { 1380 /* check dll*/1381 sprintf(pszQuery, "SELECT refcode FROM dllWHERE refcode = %s", row1[1]);1383 /* check module */ 1384 sprintf(pszQuery, "SELECT refcode FROM module WHERE refcode = %s", row1[1]); 1382 1385 rc = mysql_query(pmysql, pszQuery); 1383 CheckFKError("function/ dll", "Foreign key 'dll' not found in the dlltable");1386 CheckFKError("function/module", "Foreign key 'module' not found in the module table"); 1384 1387 1385 1388 /* check state */ … … 1411 1414 1412 1415 /* foreign keys in file */ 1413 strcpy(pszQuery, "SELECT refcode, dllFROM file");1416 strcpy(pszQuery, "SELECT refcode, module FROM file"); 1414 1417 rc = mysql_query(pmysql, pszQuery); 1415 1418 if (rc >= 0) … … 1420 1423 while ((row1 = mysql_fetch_row(pres1)) != NULL) 1421 1424 { 1422 /* check dll*/1423 sprintf(pszQuery, "SELECT refcode FROM dllWHERE refcode = %s", row1[1]);1425 /* check module */ 1426 sprintf(pszQuery, "SELECT refcode FROM module WHERE refcode = %s", row1[1]); 1424 1427 rc = mysql_query(pmysql, pszQuery); 1425 CheckFKError("apigroup/ dll", "Foreign key 'dll' not found in the dlltable");1428 CheckFKError("apigroup/module", "Foreign key 'module' not found in the module table"); 1426 1429 } 1427 1430 mysql_free_result(pres1); … … 1432 1435 1433 1436 /* foreign keys in apigroup */ 1434 strcpy(pszQuery, "SELECT refcode, dllFROM apigroup");1437 strcpy(pszQuery, "SELECT refcode, module FROM apigroup"); 1435 1438 rc = mysql_query(pmysql, pszQuery); 1436 1439 if (rc >= 0) … … 1441 1444 while ((row1 = mysql_fetch_row(pres1)) != NULL) 1442 1445 { 1443 /* check dll*/1444 sprintf(pszQuery, "SELECT refcode FROM dllWHERE refcode = %s", row1[1]);1446 /* check module */ 1447 sprintf(pszQuery, "SELECT refcode FROM module WHERE refcode = %s", row1[1]); 1445 1448 rc = mysql_query(pmysql, pszQuery); 1446 CheckFKError("file/ dll", "Foreign key 'dll' not found in the dlltable");1449 CheckFKError("file/module", "Foreign key 'module' not found in the module table"); 1447 1450 } 1448 1451 mysql_free_result(pres1); … … 1478 1481 ulRc += logDbError(pszError, pszQuery); 1479 1482 1480 /* foreign keys in history dlltable */1481 strcpy(pszQuery, "SELECT date, dll, state FROM historydll");1483 /* foreign keys in historymodule table */ 1484 strcpy(pszQuery, "SELECT date, module, state FROM historymodule"); 1482 1485 rc = mysql_query(pmysql, pszQuery); 1483 1486 if (rc >= 0) … … 1488 1491 while ((row1 = mysql_fetch_row(pres1)) != NULL) 1489 1492 { 1490 /* check dll*/1491 sprintf(pszQuery, "SELECT refcode FROM dllWHERE refcode = %s", row1[1]);1493 /* check module */ 1494 sprintf(pszQuery, "SELECT refcode FROM module WHERE refcode = %s", row1[1]); 1492 1495 rc = mysql_query(pmysql, pszQuery); 1493 CheckFKError("history dll/dll", "Foreign key 'dll' not found in the dlltable");1496 CheckFKError("historymodule/module", "Foreign key 'module' not found in the module table"); 1494 1497 1495 1498 /* check state */ 1496 1499 sprintf(pszQuery, "SELECT refcode FROM state WHERE refcode = %s", row1[2]); 1497 1500 rc = mysql_query(pmysql, pszQuery); 1498 CheckFKError("history dll/state", "Foreign key 'state' not found in the state table");1501 CheckFKError("historymodule/state", "Foreign key 'state' not found in the state table"); 1499 1502 } 1500 1503 mysql_free_result(pres1); … … 1514 1517 while ((row1 = mysql_fetch_row(pres1)) != NULL) 1515 1518 { 1516 /* check dll*/1519 /* check module */ 1517 1520 sprintf(pszQuery, "SELECT refcode FROM apigroup WHERE refcode = %s", row1[1]); 1518 1521 rc = mysql_query(pmysql, pszQuery); … … 1530 1533 ulRc += logDbError(pszError, pszQuery); 1531 1534 1532 /* foreign keys in history dlltotal table */1533 strcpy(pszQuery, "SELECT date, dll FROM historydlltotal");1535 /* foreign keys in historymoduletotal table */ 1536 strcpy(pszQuery, "SELECT date, module FROM historymoduletotal"); 1534 1537 rc = mysql_query(pmysql, pszQuery); 1535 1538 if (rc >= 0) … … 1540 1543 while ((row1 = mysql_fetch_row(pres1)) != NULL) 1541 1544 { 1542 /* check dll*/1543 sprintf(pszQuery, "SELECT refcode FROM dllWHERE refcode = %s", row1[1]);1545 /* check module */ 1546 sprintf(pszQuery, "SELECT refcode FROM module WHERE refcode = %s", row1[1]); 1544 1547 rc = mysql_query(pmysql, pszQuery); 1545 CheckFKError("history dlltotal/dll", "Foreign key 'dll' not found in the dlltable");1548 CheckFKError("historymoduletotal/module", "Foreign key 'module' not found in the module table"); 1546 1549 } 1547 1550 mysql_free_result(pres1); … … 1561 1564 while ((row1 = mysql_fetch_row(pres1)) != NULL) 1562 1565 { 1563 /* check dll*/1566 /* check module */ 1564 1567 sprintf(pszQuery, "SELECT refcode FROM apigroup WHERE refcode = %s", row1[1]); 1565 1568 rc = mysql_query(pmysql, pszQuery); … … 1855 1858 1856 1859 /** 1857 * Display all functions for, the given dll, that is not updated.1860 * Display all functions for, the given module, that is not updated. 1858 1861 * @returns TRUE / FALSE. 1859 * @param l Dll Dllreference number.1862 * @param lModule Module reference number. 1860 1863 * @param dbFetchCall Callback function which will be called once for each 1861 1864 * field for all the functions not updated. 1862 1865 * pvUser is NULL, pszValue field value, pszFieldName the field name. 1863 1866 */ 1864 BOOL _System dbGetNotUpdatedFunction(signed long l Dll, DBCALLBACKFETCH dbFetchCallBack)1867 BOOL _System dbGetNotUpdatedFunction(signed long lModule, DBCALLBACKFETCH dbFetchCallBack) 1865 1868 { 1866 1869 BOOL fRet = FALSE; … … 1871 1874 sprintf(&szQuery[0], "SELECT f1.name, f1.intname, f1.updated, f1.aliasfn, d.name, f2.name, f2.intname AS last " 1872 1875 "FROM function f1 LEFT OUTER JOIN function f2 ON f1.aliasfn = f2.refcode " 1873 " LEFT JOIN dll d ON f2.dll= d.refcode "1874 "WHERE f1. dll= %ld AND f1.updated = 0",1875 l Dll);1876 " LEFT JOIN module d ON f2.module = d.refcode " 1877 "WHERE f1.module = %ld AND f1.updated = 0", 1878 lModule); 1876 1879 pres = dbExecuteQuery(szQuery); 1877 1880 if (pres != NULL) … … 1889 1892 sprintf(&szQuery[0], "SELECT f1.name, f1.intname, f1.updated, f1.aliasfn, d.name, f2.name, f2.intname AS last " 1890 1893 "FROM function f1 LEFT OUTER JOIN function f2 ON f1.aliasfn = f2.refcode " 1891 " LEFT JOIN dll d ON f2.dll= d.refcode "1892 "WHERE f1. dll= %ld AND f1.updated > 1",1893 l Dll);1894 " LEFT JOIN module d ON f2.module = d.refcode " 1895 "WHERE f1.module = %ld AND f1.updated > 1", 1896 lModule); 1894 1897 pres = dbExecuteQuery(szQuery); 1895 1898 if (pres != NULL) … … 1912 1915 1913 1916 /** 1914 * Counts the function for the given DLLwhich has been updated.1915 * @returns 1916 * @param lDll Dllreference number.1917 */ 1918 signed long _System dbGetNumberOfUpdatedFunction(signed long l Dll)1917 * Counts the function for the given MODULE which has been updated. 1918 * @returns -1 on error, number of updated function on success. 1919 * @param lModule Module reference number. 1920 */ 1921 signed long _System dbGetNumberOfUpdatedFunction(signed long lModule) 1919 1922 { 1920 1923 int rc; … … 1922 1925 MYSQL_RES * pres; 1923 1926 1924 sprintf(&szQuery[0], "SELECT count(*) FROM function WHERE dll = (%ld) AND updated > 0\n", lDll);1927 sprintf(&szQuery[0], "SELECT count(*) FROM function WHERE module = (%ld) AND updated > 0\n", lModule); 1925 1928 rc = mysql_query(pmysql, &szQuery[0]); 1926 1929 pres = mysql_store_result(pmysql); … … 1936 1939 1937 1940 /** 1938 * Clear the update flags for all file in a dll/module.1939 * @returns 1940 * @param lDll Dllrefcode.1941 * @author 1942 * @remark 1943 */ 1944 BOOL _System dbClearUpdateFlagFile(signed long l Dll)1941 * Clear the update flags for all file in a module/module. 1942 * @returns Success indicator. (TRUE / FALSE) 1943 * @param lModule Module refcode. 1944 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no) 1945 * @remark Intended for use by APIImport. 1946 */ 1947 BOOL _System dbClearUpdateFlagFile(signed long lModule) 1945 1948 { 1946 1949 int rc; … … 1948 1951 1949 1952 sprintf(&szQuery[0], 1950 "UPDATE file SET updated = 0 WHERE dll= (%ld)",1951 l Dll);1953 "UPDATE file SET updated = 0 WHERE module = (%ld)", 1954 lModule); 1952 1955 rc = mysql_query(pmysql, &szQuery[0]); 1953 1956 return rc == 0; … … 1957 1960 /** 1958 1961 * Clear update flag 1959 * @returns 1960 * @param lDll Dllrefcode.1961 * @param fAll All dll. If false only APIs and Internal APIs are cleared1962 * @author 1963 * @remark 1964 */ 1965 BOOL _System dbClearUpdateFlagFunction(signed long l Dll, BOOL fAll)1962 * @returns Success indicator. 1963 * @param lModule Module refcode. 1964 * @param fAll All module. If false only APIs and Internal APIs are cleared 1965 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no) 1966 * @remark Intended for use by APIImport. 1967 */ 1968 BOOL _System dbClearUpdateFlagFunction(signed long lModule, BOOL fAll) 1966 1969 { 1967 1970 int rc; … … 1969 1972 1970 1973 sprintf(&szQuery[0], 1971 "UPDATE function SET updated = 0 WHERE dll= (%ld)",1972 l Dll);1974 "UPDATE function SET updated = 0 WHERE module = (%ld)", 1975 lModule); 1973 1976 if (!fAll) 1974 1977 strcat(&szQuery[0], " AND type IN ('A', 'I')"); … … 1980 1983 1981 1984 /** 1982 * Deletes all the files in a dll/module which was not found/updated.1985 * Deletes all the files in a module/module which was not found/updated. 1983 1986 * @returns Success indicator. 1984 * @param l Dll Dllrefcode.1987 * @param lModule Module refcode. 1985 1988 * @sketch Select all files which is to be deleted. 1986 1989 * Set all references to each file in function to -1. … … 1989 1992 * @remark Use with GRATE CARE! 1990 1993 */ 1991 BOOL _System dbDeleteNotUpdatedFiles(signed long l Dll)1994 BOOL _System dbDeleteNotUpdatedFiles(signed long lModule) 1992 1995 { 1993 1996 MYSQL_RES * pres; … … 1997 2000 1998 2001 sprintf(&szQuery[0], 1999 "SELECT refcode FROM file WHERE dll= (%ld) AND updated = 0",2000 l Dll);2002 "SELECT refcode FROM file WHERE module = (%ld) AND updated = 0", 2003 lModule); 2001 2004 rc = mysql_query(pmysql, &szQuery[0]); 2002 2005 pres = mysql_store_result(pmysql); … … 2015 2018 2016 2019 sprintf(&szQuery[0], 2017 "DELETE FROM file WHERE dll= %ld AND updated = 0",2018 l Dll);2020 "DELETE FROM file WHERE module = %ld AND updated = 0", 2021 lModule); 2019 2022 rc = mysql_query(pmysql, &szQuery[0]); 2020 2023 if (rc) fRc = FALSE; … … 2030 2033 * 2031 2034 * @returns Success indicator. (TRUE / FALSE) 2032 * @param l Dll The refcode of the dllowning the functions.2033 * @param fAll All function. If FALSE then only APIs and Internal APIs.2034 * @sketch Select all functions which wan't updated (ie. updated = 0 and dll = lDll).2035 * @param lModule The refcode of the module owning the functions. 2036 * @param fAll All function. If FALSE then only APIs and Internal APIs. 2037 * @sketch Select all functions which wan't updated (ie. updated = 0 and module = lModule). 2035 2038 * If anyone Then 2036 2039 * Delete the referenced to the functions in: … … 2041 2044 * @remark Use with GREATE CARE! 2042 2045 */ 2043 BOOL _System dbDeleteNotUpdatedFunctions(signed long l Dll, BOOL fAll)2046 BOOL _System dbDeleteNotUpdatedFunctions(signed long lModule, BOOL fAll) 2044 2047 { 2045 2048 MYSQL_RES * pres; … … 2049 2052 2050 2053 sprintf(&szQuery[0], 2051 "SELECT refcode FROM function WHERE dll= %ld AND updated = 0",2052 l Dll);2054 "SELECT refcode FROM function WHERE module = %ld AND updated = 0", 2055 lModule); 2053 2056 if (!fAll) 2054 2057 strcat(&szQuery[0], " AND type IN ('A', 'I')"); … … 2081 2084 { 2082 2085 sprintf(&szQuery[0], 2083 "DELETE FROM function WHERE dll= %ld AND updated = 0",2084 l Dll);2086 "DELETE FROM function WHERE module = %ld AND updated = 0", 2087 lModule); 2085 2088 if (!fAll) 2086 2089 strcat(&szQuery[0], " AND type IN ('A', 'I')");
Note:
See TracChangeset
for help on using the changeset viewer.