Ignore:
Timestamp:
Sep 7, 2001, 12:33:10 PM (24 years ago)
Author:
bird
Message:

reverse prev rev.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/database/db.cpp

    r6677 r6678  
    1 /* $Id: db.cpp,v 1.26 2001-09-07 10:24:07 bird Exp $ *
     1/* $Id: db.cpp,v 1.27 2001-09-07 10:31:44 bird Exp $ *
    22 *
    33 * DB - contains all database routines.
     
    154154
    155155/**
    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)
     156 * Gets the refid for the give dll name.
     157 * @returns   Dll refid. -1 on error.
     158 * @param     pszDllName  Dll name.
     159 */
     160signed long _System dbGetDll(const char *pszDllName)
    161161{
    162162    int         rc;
     
    164164    MYSQL_RES * pres;
    165165
    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);
    167167    rc   = mysql_query(pmysql, &szQuery[0]);
    168168    pres = mysql_store_result(pmysql);
     
    178178
    179179/**
    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)
     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 */
     185signed long     _System dbCountFunctionInDll(signed long lDll, BOOL fNotAliases)
    186186{
    187187    signed long rc;
     
    189189    MYSQL_RES * pres;
    190190
    191     if (lModule >= 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);
    194194        if (fNotAliases)
    195195            strcat(&szQuery[0], " AND aliasfn < 0");
     
    211211
    212212/**
    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 */
     219signed long _System dbCheckInsertDll(const char *pszDll, char fchType)
    221220{
    222221    int         rc;
     
    225224
    226225    /* 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);
    228227    rc   = mysql_query(pmysql, &szQuery[0]);
    229228    pres = mysql_store_result(pmysql);
    230229
    231     /* not found? - insert module */
     230    /* not found? - insert dll */
    232231    if (rc < 0 || pres == NULL || mysql_num_rows(pres) == 0)
    233232    {
    234233        mysql_free_result(pres);
    235234
    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);
    237236        rc = mysql_query(pmysql, &szQuery[0]);
    238237        if (rc < 0)
     
    240239
    241240        /* 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);
    243242        rc   = mysql_query(pmysql, &szQuery[0]);
    244243        pres = mysql_store_result(pmysql);
     
    291290 * The update flags is always updated.
    292291 * @returns     Success indicator. TRUE / FALSE.
    293  * @param       lModule             Module refcode.
     292 * @param       lDll                Dll refcode.
    294293 * @param       pszFunction         Function name.
    295294 * @param       pszIntFunction      Internal function name. (required!)
     
    298297 * @param       fchType             Function type flag. One of the FUNCTION_* defines.
    299298 */
    300 BOOL _System dbInsertUpdateFunction(signed long lModule,
     299BOOL _System dbInsertUpdateFunction(signed long lDll,
    301300                                    const char *pszFunction, const char *pszIntFunction,
    302301                                    unsigned long ulOrdinal, BOOL fIgnoreOrdinal, char fchType)
     
    313312
    314313    /* 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);
    316315    rc = mysql_query(pmysql, pszQuery);
    317316    pres = mysql_store_result(pmysql);
     
    323322        if (mysql_num_rows(pres) > 1)
    324323        {
    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);
     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);
    327326            return FALSE;
    328327        }
     
    348347         * Insert it.
    349348         */
    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);
     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);
    352351        rc = mysql_query(pmysql, &szQuery[0]);
    353352    }
     
    361360 * Inserts or updates (existing) file information.
    362361 * @returns     Success indicator (TRUE / FALSE).
    363  * @param       lModule         Module reference code.
     362 * @param       lDll           Dll reference code.
    364363 * @param       pszFilename     Filename.
    365364 * @param       pszDescription  Pointer to file description.
     
    370369 * @remark
    371370 */
    372 BOOL            _System dbInsertUpdateFile(signed long lModule,
     371BOOL            _System dbInsertUpdateFile(signed long lDll,
    373372                                           const char *pszFilename,
    374373                                           const char *pszDescription,
     
    383382
    384383    /* parameter assertions */
    385     assert(lModule != 0);
     384    assert(lDll != 0);
    386385    assert(pszFilename != NULL);
    387386    assert(*pszFilename != '\0');
    388387
    389388    /* 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);
    391390    rc = mysql_query(pmysql, &szQuery[0]);
    392391    pres = mysql_store_result(pmysql);
     
    396395        if (mysql_num_rows(pres) > 1)
    397396        {
    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);
     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);
    400399            return FALSE;
    401400        }
     
    451450    else
    452451    {   /* insert */
    453         sprintf(&szQuery[0], "INSERT INTO file(module, name, lastauthor, description, lastdatetime, revision) VALUES(%d, '%s', %ld, ",
    454                 lModule, pszFilename, lLastAuthor);
     452        sprintf(&szQuery[0], "INSERT INTO file(dll, name, lastauthor, description, lastdatetime, revision) VALUES(%d, '%s', %ld, ",
     453                lDll, pszFilename, lLastAuthor);
    455454        if (pszDescription != NULL && *pszDescription != '\0')
    456455            sqlstrcat(&szQuery[0], NULL, pszDescription);
     
    525524 * @param     pszFunctionName   Pointer to a function name string. (input)
    526525 * @param     pFnFindBuf        Pointer to a find buffer. (output)
    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).
     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).
    530529 *            2) Get functions which aliases the functions found in (1).
    531530 *            3) Get new aliases by intname
     
    534533 *            6) Update all functions from (3) and (4) to alias the first function from 1.
    535534 */
    536 BOOL _System dbFindFunction(const char *pszFunctionName, PFNFINDBUF pFnFindBuf, signed long lModule)
     535BOOL _System dbFindFunction(const char *pszFunctionName, PFNFINDBUF pFnFindBuf, signed long lDll)
    537536{
    538537    MYSQL_RES   *pres;
     
    542541
    543542    /*
    544      * 1) Get functions for this module(if given).
     543     * 1) Get functions for this dll(if given).
    545544     */
    546     if (lModule < 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'",
    548547                pszFunctionName);
    549548    else
    550         sprintf(&szQuery[0], "SELECT refcode, module, aliasfn, file, name, type FROM function "
    551                 "WHERE intname = '%s' AND module = %ld",
    552                 pszFunctionName, lModule);
     549        sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn, file, name FROM function "
     550                "WHERE intname = '%s' AND dll = %ld",
     551                pszFunctionName, lDll);
    553552
    554553    rc = mysql_query1(pmysql, &szQuery[0]);
     
    559558        {
    560559            char szFnName[NBR_FUNCTIONS][80];
    561             BOOL fAPI = FALSE;
    562560
    563561            pFnFindBuf->cFns = 0;
     
    565563            {
    566564                pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]);
    567                 pFnFindBuf->alModRefCode[pFnFindBuf->cFns] = atol(row[1]);
     565                pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]);
    568566                pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);
    569567                pFnFindBuf->alFileRefCode[pFnFindBuf->cFns] = atol(row[3]);
    570568                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;
    575569
    576570                /* next */
     
    579573            mysql_free_result(pres);
    580574
    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)
    583577            {
    584                 int cFnsThisModule, cFnsAliasesAndThisModule, i, f;
     578                int cFnsThisDll, cFnsAliasesAndThisDll, i, f;
    585579
    586580                /*
    587581                 * 2) Get functions which aliases the functions found in (1).
    588582                 */
    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++)
     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++)
    592586                {
    593587                    if (i > 0)  strcat(&szQuery[0], " OR ");
     
    605599                        {
    606600                            pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]);
    607                             pFnFindBuf->alModRefCode[pFnFindBuf->cFns] = atol(row[1]);
     601                            pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]);
    608602                            pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);
    609603                            pFnFindBuf->alFileRefCode[pFnFindBuf->cFns] = atol(row[3]);
     
    618612                         * 3) Get new aliases by intname
    619613                         */
    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++)
     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++)
    625619                            sprintf(&szQuery[strlen(&szQuery[0])], " OR intname = '%s'", szFnName[i]);
    626620                        strcat(&szQuery[0], ")");
     
    635629                                {
    636630                                    pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]);
    637                                     pFnFindBuf->alModRefCode[pFnFindBuf->cFns] = atol(row[1]);
     631                                    pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]);
    638632                                    if (row[2] != NULL)
    639633                                        pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);
     
    651645                                 * 4) Get new aliases by name
    652646                                 */
    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++)
     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++)
    657651                                    sprintf(&szQuery[strlen(&szQuery[0])], " OR name = '%s'", szFnName[i]);
    658652                                strcat(&szQuery[0], ")");
     
    667661                                        {
    668662                                            pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]);
    669                                             pFnFindBuf->alModRefCode[pFnFindBuf->cFns] = atol(row[1]);
     663                                            pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]);
    670664                                            if (row[2] != NULL)
    671665                                                pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);
     
    684678                                        sprintf(&szQuery[0], "UPDATE function SET aliasfn = (-2) "
    685679                                                             "WHERE refcode IN (",
    686                                                 lModule, pszFunctionName);
    687                                         for (f = 0, i = 0; i < cFnsThisModule; i++)
     680                                                lDll, pszFunctionName);
     681                                        for (f = 0, i = 0; i < cFnsThisDll; i++)
    688682                                            if (pFnFindBuf->alAliasFn[i] != ALIAS_DONTMIND)
    689683                                                sprintf(&szQuery[strlen(&szQuery[0])],
     
    694688                                        else
    695689                                            rc = 0;
    696                                         if (rc >= 0 && cFnsAliasesAndThisModule < pFnFindBuf->cFns)
     690                                        if (rc >= 0 && cFnsAliasesAndThisDll < pFnFindBuf->cFns)
    697691                                        {
    698692                                            /*
     
    702696                                                                 "WHERE aliasfn = (-1) AND refcode IN (",
    703697                                                    pFnFindBuf->alRefCode[0], pFnFindBuf->alFileRefCode[0]);
    704                                             for (i = cFnsAliasesAndThisModule; i < pFnFindBuf->cFns; i++)
     698                                            for (i = cFnsAliasesAndThisDll; i < pFnFindBuf->cFns; i++)
    705699                                            {
    706700                                                sprintf(&szQuery[strlen(&szQuery[0])],
    707                                                         i > cFnsAliasesAndThisModule ? ", %ld" : "%ld", pFnFindBuf->alRefCode[i]);
     701                                                        i > cFnsAliasesAndThisDll ? ", %ld" : "%ld", pFnFindBuf->alRefCode[i]);
    708702                                            }
    709703                                            strcat(&szQuery[0], ")");
     
    728722/**
    729723 * 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 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)
     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 */
     729signed long     _System dbFindFile(signed long lDll, const char *pszFilename)
    736730{
    737731    char        szQuery[256];
     
    739733    signed long lRefCode = -1;
    740734
    741     assert(lModule >= 0);
     735    assert(lDll >= 0);
    742736    assert(pszFilename != NULL);
    743737    assert(*pszFilename != '\0');
    744738
    745     sprintf(&szQuery[0], "SELECT refcode FROM file WHERE module = %ld AND name = '%s'",
    746             lModule, pszFilename);
     739    sprintf(&szQuery[0], "SELECT refcode FROM file WHERE dll = %ld AND name = '%s'",
     740            lDll, pszFilename);
    747741    if (mysql_query(pmysql, &szQuery[0]) >= 0)
    748742    {
     
    884878 * @returns   number of errors.
    885879 * @param     pFnDesc   Function description struct.
    886  * @param     lModule   Module which we are working at.
     880 * @param     lDll      Dll which we are working at.
    887881 * @param     pszError  Buffer for error messages
    888882 * @result    on error(s) pszError will hold information about the error(s).
    889883 */
    890 unsigned long _System dbUpdateFunction(PFNDESC pFnDesc, signed long lModule, char *pszError)
     884unsigned long _System dbUpdateFunction(PFNDESC pFnDesc, signed long lDll, char *pszError)
    891885{
    892886    MYSQL_RES *     pres;
     
    11461140    } /* for */
    11471141
    1148     lModule = lModule;
     1142    lDll = lDll;
    11491143    free(pszQuery2);
    11501144    return ulRc;
     
    11541148/**
    11551149 * 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
    11591156 */
    11601157BOOL            _System dbRemoveDesignNotes(signed long lFile)
     
    11711168 * Adds a design note.
    11721169 * @returns     Success indicator.
    1173  * @param       lModule         Module refcode.
     1170 * @param       lDll            Dll refcode.
    11741171 * @param       lFile           File refcode.
    11751172 * @param       pszTitle        Design note title.
    11761173 * @param       pszText         Design note text.
    11771174 * @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.
    11791176 * @param       lSeqNbrNote     Sequence number in note.
    11801177 * @param       lLine           Line number (1 - based!).
     
    11841181 * @param       plRefCode       Pointer to reference id of the design note. see fSubSection for more info.
    11851182 */
    1186 BOOL            _System dbAddDesignNote(signed long lModule,
     1183BOOL            _System dbAddDesignNote(signed long lDll,
    11871184                                        signed long lFile,
    11881185                                        const char *pszTitle,
     
    12001197
    12011198
    1202     assert(lModule >= 0 && lFile >= 0);
     1199    assert(lDll >= 0 && lFile >= 0);
    12031200    assert(lSeqNbrNote >= 0);
    12041201
     
    12081205    if (lSeqNbr == 0 && !fSubSection)
    12091206    {
    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);
    12111208        if (mysql_query(pmysql, &szQuery[0]) >= 0)
    12121209        {
     
    12321229     */
    12331230    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) "
    12351232                             "VALUES (%ld, %ld, %ld, %ld, %ld, %ld, ",
    1236                 lModule, lFile, lLevel, lSeqNbrNote, lSeqNbr, lLine);
     1233                lDll, lFile, lLevel, lSeqNbrNote, lSeqNbr, lLine);
    12371234    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) "
    12391236                             "VALUES (%ld, %ld, %ld, %ld, %ld, %ld, %ld, ",
    1240                 *plRefCode, lModule, lFile, lLevel, lSeqNbrNote, lSeqNbr, lLine);
     1237                *plRefCode, lDll, lFile, lLevel, lSeqNbrNote, lSeqNbr, lLine);
    12411238
    12421239    if (pszTitle != NULL && *pszTitle != '\0')
     
    12891286
    12901287            /* delete - all rows on this date in the history tables */
    1291             sprintf(pszQuery, "DELETE FROM historymodule WHERE date = '%s'", &szCurDt[0]);
     1288            sprintf(pszQuery, "DELETE FROM historydll WHERE date = '%s'", &szCurDt[0]);
    12921289            rc = mysql_query(pmysql, pszQuery);
    12931290            CheckLogContinue((pszError, "error removing old history rows: %s - (sql=%s) ", dbGetLastErrorDesc(), pszQuery));
     
    12971294            CheckLogContinue((pszError, "error removing old history rows: %s - (sql=%s) ", dbGetLastErrorDesc(), pszQuery));
    12981295
    1299             sprintf(pszQuery, "DELETE FROM historymoduletotal WHERE date = '%s'", &szCurDt[0]);
     1296            sprintf(pszQuery, "DELETE FROM historydlltotal WHERE date = '%s'", &szCurDt[0]);
    13001297            rc = mysql_query(pmysql, pszQuery);
    13011298            CheckLogContinue((pszError, "error removing old history rows: %s - (sql=%s) ", dbGetLastErrorDesc(), pszQuery));
     
    13051302
    13061303            /* insert new stats */
    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",
     1304            sprintf(pszQuery, "INSERT INTO historydll(dll, state, date, count) "
     1305                    "SELECT dll, state, '%s', count(*) FROM function GROUP BY dll, state",
    13091306                    &szCurDt[0]);
    13101307            rc = mysql_query(pmysql, pszQuery);
     
    13191316
    13201317            /* inserting new totals */
    1321             sprintf(pszQuery, "INSERT INTO historymoduletotal(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",
    13231320                    &szCurDt[0]);
    13241321            rc = mysql_query(pmysql, pszQuery);
     
    13261323
    13271324            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 "
    13291326                    "GROUP BY apigroup",
    13301327                    &szCurDt[0]);
     
    13721369
    13731370    /* 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");
    13751372    rc = mysql_query(pmysql, pszQuery);
    13761373    if (rc >= 0)
     
    13811378            while ((row1 = mysql_fetch_row(pres1)) != NULL)
    13821379            {
    1383                 /* check module */
    1384                 sprintf(pszQuery, "SELECT refcode FROM module WHERE refcode = %s", row1[1]);
     1380                /* check dll */
     1381                sprintf(pszQuery, "SELECT refcode FROM dll WHERE refcode = %s", row1[1]);
    13851382                rc = mysql_query(pmysql, pszQuery);
    1386                 CheckFKError("function/module", "Foreign key 'module' not found in the module table");
     1383                CheckFKError("function/dll", "Foreign key 'dll' not found in the dll table");
    13871384
    13881385                /* check state */
     
    14141411
    14151412    /* foreign keys in file */
    1416     strcpy(pszQuery, "SELECT refcode, module FROM file");
     1413    strcpy(pszQuery, "SELECT refcode, dll FROM file");
    14171414    rc = mysql_query(pmysql, pszQuery);
    14181415    if (rc >= 0)
     
    14231420            while ((row1 = mysql_fetch_row(pres1)) != NULL)
    14241421            {
    1425                 /* check module */
    1426                 sprintf(pszQuery, "SELECT refcode FROM module WHERE refcode = %s", row1[1]);
     1422                /* check dll */
     1423                sprintf(pszQuery, "SELECT refcode FROM dll WHERE refcode = %s", row1[1]);
    14271424                rc = mysql_query(pmysql, pszQuery);
    1428                 CheckFKError("apigroup/module", "Foreign key 'module' not found in the module table");
     1425                CheckFKError("apigroup/dll", "Foreign key 'dll' not found in the dll table");
    14291426            }
    14301427            mysql_free_result(pres1);
     
    14351432
    14361433    /* foreign keys in apigroup */
    1437     strcpy(pszQuery, "SELECT refcode, module FROM apigroup");
     1434    strcpy(pszQuery, "SELECT refcode, dll FROM apigroup");
    14381435    rc = mysql_query(pmysql, pszQuery);
    14391436    if (rc >= 0)
     
    14441441            while ((row1 = mysql_fetch_row(pres1)) != NULL)
    14451442            {
    1446                 /* check module */
    1447                 sprintf(pszQuery, "SELECT refcode FROM module WHERE refcode = %s", row1[1]);
     1443                /* check dll */
     1444                sprintf(pszQuery, "SELECT refcode FROM dll WHERE refcode = %s", row1[1]);
    14481445                rc = mysql_query(pmysql, pszQuery);
    1449                 CheckFKError("file/module", "Foreign key 'module' not found in the module table");
     1446                CheckFKError("file/dll", "Foreign key 'dll' not found in the dll table");
    14501447            }
    14511448            mysql_free_result(pres1);
     
    14811478        ulRc += logDbError(pszError, pszQuery);
    14821479
    1483     /* foreign keys in historymodule table */
    1484     strcpy(pszQuery, "SELECT date, module, state FROM historymodule");
     1480    /* foreign keys in historydll table */
     1481    strcpy(pszQuery, "SELECT date, dll, state FROM historydll");
    14851482    rc = mysql_query(pmysql, pszQuery);
    14861483    if (rc >= 0)
     
    14911488            while ((row1 = mysql_fetch_row(pres1)) != NULL)
    14921489            {
    1493                 /* check module */
    1494                 sprintf(pszQuery, "SELECT refcode FROM module WHERE refcode = %s", row1[1]);
     1490                /* check dll */
     1491                sprintf(pszQuery, "SELECT refcode FROM dll WHERE refcode = %s", row1[1]);
    14951492                rc = mysql_query(pmysql, pszQuery);
    1496                 CheckFKError("historymodule/module", "Foreign key 'module' not found in the module table");
     1493                CheckFKError("historydll/dll", "Foreign key 'dll' not found in the dll table");
    14971494
    14981495                /* check state */
    14991496                sprintf(pszQuery, "SELECT refcode FROM state WHERE refcode = %s", row1[2]);
    15001497                rc = mysql_query(pmysql, pszQuery);
    1501                 CheckFKError("historymodule/state", "Foreign key 'state' not found in the state table");
     1498                CheckFKError("historydll/state", "Foreign key 'state' not found in the state table");
    15021499            }
    15031500            mysql_free_result(pres1);
     
    15171514            while ((row1 = mysql_fetch_row(pres1)) != NULL)
    15181515            {
    1519                 /* check module */
     1516                /* check dll */
    15201517                sprintf(pszQuery, "SELECT refcode FROM apigroup WHERE refcode = %s", row1[1]);
    15211518                rc = mysql_query(pmysql, pszQuery);
     
    15331530        ulRc += logDbError(pszError, pszQuery);
    15341531
    1535     /* foreign keys in historymoduletotal table */
    1536     strcpy(pszQuery, "SELECT date, module FROM historymoduletotal");
     1532    /* foreign keys in historydlltotal table */
     1533    strcpy(pszQuery, "SELECT date, dll FROM historydlltotal");
    15371534    rc = mysql_query(pmysql, pszQuery);
    15381535    if (rc >= 0)
     
    15431540            while ((row1 = mysql_fetch_row(pres1)) != NULL)
    15441541            {
    1545                 /* check module */
    1546                 sprintf(pszQuery, "SELECT refcode FROM module WHERE refcode = %s", row1[1]);
     1542                /* check dll */
     1543                sprintf(pszQuery, "SELECT refcode FROM dll WHERE refcode = %s", row1[1]);
    15471544                rc = mysql_query(pmysql, pszQuery);
    1548                 CheckFKError("historymoduletotal/module", "Foreign key 'module' not found in the module table");
     1545                CheckFKError("historydlltotal/dll", "Foreign key 'dll' not found in the dll table");
    15491546            }
    15501547            mysql_free_result(pres1);
     
    15641561            while ((row1 = mysql_fetch_row(pres1)) != NULL)
    15651562            {
    1566                 /* check module */
     1563                /* check dll */
    15671564                sprintf(pszQuery, "SELECT refcode FROM apigroup WHERE refcode = %s", row1[1]);
    15681565                rc = mysql_query(pmysql, pszQuery);
     
    18581855
    18591856/**
    1860  * Display all functions for, the given module, that is not updated.
     1857 * Display all functions for, the given dll, that is not updated.
    18611858 * @returns   TRUE / FALSE.
    1862  * @param     lModule      Module reference number.
     1859 * @param     lDll         Dll reference number.
    18631860 * @param     dbFetchCall  Callback function which will be called once for each
    18641861 *                         field for all the functions not updated.
    18651862 *                         pvUser is NULL, pszValue field value, pszFieldName the field name.
    18661863 */
    1867 BOOL _System dbGetNotUpdatedFunction(signed long lModule, DBCALLBACKFETCH dbFetchCallBack)
     1864BOOL _System dbGetNotUpdatedFunction(signed long lDll, DBCALLBACKFETCH dbFetchCallBack)
    18681865{
    18691866    BOOL        fRet = FALSE;
     
    18741871    sprintf(&szQuery[0], "SELECT f1.name, f1.intname, f1.updated, f1.aliasfn, d.name, f2.name, f2.intname AS last "
    18751872                         "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             lModule);
     1873                         "     LEFT JOIN dll d ON f2.dll = d.refcode "
     1874                         "WHERE f1.dll = %ld AND f1.updated = 0",
     1875            lDll);
    18791876    pres = dbExecuteQuery(szQuery);
    18801877    if (pres != NULL)
     
    18921889    sprintf(&szQuery[0], "SELECT f1.name, f1.intname, f1.updated, f1.aliasfn, d.name, f2.name, f2.intname AS last "
    18931890                         "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             lModule);
     1891                         "     LEFT JOIN dll d ON f2.dll = d.refcode "
     1892                         "WHERE f1.dll = %ld AND f1.updated > 1",
     1893            lDll);
    18971894    pres = dbExecuteQuery(szQuery);
    18981895    if (pres != NULL)
     
    19151912
    19161913/**
    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)
     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 */
     1918signed long _System dbGetNumberOfUpdatedFunction(signed long lDll)
    19221919{
    19231920    int         rc;
     
    19251922    MYSQL_RES * pres;
    19261923
    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);
    19281925    rc   = mysql_query(pmysql, &szQuery[0]);
    19291926    pres = mysql_store_result(pmysql);
     
    19391936
    19401937/**
    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)
     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 */
     1944BOOL             _System dbClearUpdateFlagFile(signed long lDll)
    19481945{
    19491946    int         rc;
     
    19511948
    19521949    sprintf(&szQuery[0],
    1953             "UPDATE file SET updated = 0 WHERE module = (%ld)",
    1954             lModule);
     1950            "UPDATE file SET updated = 0 WHERE dll = (%ld)",
     1951            lDll);
    19551952    rc = mysql_query(pmysql, &szQuery[0]);
    19561953    return rc == 0;
     
    19601957/**
    19611958 * Clear update flag
    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)
     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 */
     1965BOOL             _System dbClearUpdateFlagFunction(signed long lDll, BOOL fAll)
    19691966{
    19701967    int         rc;
     
    19721969
    19731970    sprintf(&szQuery[0],
    1974             "UPDATE function SET updated = 0 WHERE module = (%ld)",
    1975             lModule);
     1971            "UPDATE function SET updated = 0 WHERE dll = (%ld)",
     1972            lDll);
    19761973    if (!fAll)
    19771974        strcat(&szQuery[0], " AND type IN ('A', 'I')");
     
    19831980
    19841981/**
    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.
    19861983 * @returns     Success indicator.
    1987  * @param       lModule    Module refcode.
     1984 * @param       lDll    Dll refcode.
    19881985 * @sketch      Select all files which is to be deleted.
    19891986 *                  Set all references to each file in function to -1.
     
    19921989 * @remark      Use with GRATE CARE!
    19931990 */
    1994 BOOL             _System dbDeleteNotUpdatedFiles(signed long lModule)
     1991BOOL             _System dbDeleteNotUpdatedFiles(signed long lDll)
    19951992{
    19961993    MYSQL_RES * pres;
     
    20001997
    20011998    sprintf(&szQuery[0],
    2002             "SELECT refcode FROM file WHERE module = (%ld) AND updated = 0",
    2003             lModule);
     1999            "SELECT refcode FROM file WHERE dll = (%ld) AND updated = 0",
     2000            lDll);
    20042001    rc = mysql_query(pmysql, &szQuery[0]);
    20052002    pres = mysql_store_result(pmysql);
     
    20182015
    20192016    sprintf(&szQuery[0],
    2020             "DELETE FROM file WHERE module = %ld AND updated = 0",
    2021             lModule);
     2017            "DELETE FROM file WHERE dll = %ld AND updated = 0",
     2018            lDll);
    20222019    rc = mysql_query(pmysql, &szQuery[0]);
    20232020    if (rc) fRc = FALSE;
     
    20332030 *
    20342031 * @returns     Success indicator. (TRUE / FALSE)
    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).
     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).
    20382035 *              If anyone Then
    20392036 *                  Delete the referenced to the functions in:
     
    20442041 * @remark      Use with GREATE CARE!
    20452042 */
    2046 BOOL             _System dbDeleteNotUpdatedFunctions(signed long lModule, BOOL fAll)
     2043BOOL             _System dbDeleteNotUpdatedFunctions(signed long lDll, BOOL fAll)
    20472044{
    20482045    MYSQL_RES * pres;
     
    20522049
    20532050    sprintf(&szQuery[0],
    2054             "SELECT refcode FROM function WHERE module = %ld AND updated = 0",
    2055             lModule);
     2051            "SELECT refcode FROM function WHERE dll = %ld AND updated = 0",
     2052            lDll);
    20562053    if (!fAll)
    20572054        strcat(&szQuery[0], " AND type IN ('A', 'I')");
     
    20842081        {
    20852082            sprintf(&szQuery[0],
    2086                     "DELETE FROM function WHERE module = %ld AND updated = 0",
    2087                     lModule);
     2083                    "DELETE FROM function WHERE dll = %ld AND updated = 0",
     2084                    lDll);
    20882085            if (!fAll)
    20892086                strcat(&szQuery[0], " AND type IN ('A', 'I')");
Note: See TracChangeset for help on using the changeset viewer.