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