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

dll to module conversion.

File:
1 edited

Legend:

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

    r6663 r6677  
    1 /* $Id: db.cpp,v 1.25 2001-09-06 03:07:32 bird Exp $ *
     1/* $Id: db.cpp,v 1.26 2001-09-07 10:24:07 bird Exp $ *
    22 *
    33 * DB - contains all database routines.
     
    154154
    155155/**
    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)
     156 * Gets the refid for the give mod name.
     157 * @returns Module refid. -1 on error.
     158 * @param   pszModName      Module name.
     159 */
     160signed long _System dbGetModule(const char *pszModName)
    161161{
    162162    int         rc;
     
    164164    MYSQL_RES * pres;
    165165
    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);
    167167    rc   = mysql_query(pmysql, &szQuery[0]);
    168168    pres = mysql_store_result(pmysql);
     
    178178
    179179/**
    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)
     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 */
     185signed long     _System dbCountFunctionInModule(signed long lModule, BOOL fNotAliases)
    186186{
    187187    signed long rc;
     
    189189    MYSQL_RES * pres;
    190190
    191     if (lDll >= 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);
    194194        if (fNotAliases)
    195195            strcat(&szQuery[0], " AND aliasfn < 0");
     
    211211
    212212/**
    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 */
     220signed long _System dbCheckInsertModule(const char *pszModule, char fchType)
    220221{
    221222    int         rc;
     
    224225
    225226    /* 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);
    227228    rc   = mysql_query(pmysql, &szQuery[0]);
    228229    pres = mysql_store_result(pmysql);
    229230
    230     /* not found? - insert dll */
     231    /* not found? - insert module */
    231232    if (rc < 0 || pres == NULL || mysql_num_rows(pres) == 0)
    232233    {
    233234        mysql_free_result(pres);
    234235
    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);
    236237        rc = mysql_query(pmysql, &szQuery[0]);
    237238        if (rc < 0)
     
    239240
    240241        /* 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);
    242243        rc   = mysql_query(pmysql, &szQuery[0]);
    243244        pres = mysql_store_result(pmysql);
     
    290291 * The update flags is always updated.
    291292 * @returns     Success indicator. TRUE / FALSE.
    292  * @param       lDll                Dll refcode.
     293 * @param       lModule             Module refcode.
    293294 * @param       pszFunction         Function name.
    294295 * @param       pszIntFunction      Internal function name. (required!)
     
    297298 * @param       fchType             Function type flag. One of the FUNCTION_* defines.
    298299 */
    299 BOOL _System dbInsertUpdateFunction(signed long lDll,
     300BOOL _System dbInsertUpdateFunction(signed long lModule,
    300301                                    const char *pszFunction, const char *pszIntFunction,
    301302                                    unsigned long ulOrdinal, BOOL fIgnoreOrdinal, char fchType)
     
    312313
    313314    /* 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);
    315316    rc = mysql_query(pmysql, pszQuery);
    316317    pres = mysql_store_result(pmysql);
     
    322323        if (mysql_num_rows(pres) > 1)
    323324        {
    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);
     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);
    326327            return FALSE;
    327328        }
     
    347348         * Insert it.
    348349         */
    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);
     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);
    351352        rc = mysql_query(pmysql, &szQuery[0]);
    352353    }
     
    360361 * Inserts or updates (existing) file information.
    361362 * @returns     Success indicator (TRUE / FALSE).
    362  * @param       lDll           Dll reference code.
     363 * @param       lModule         Module reference code.
    363364 * @param       pszFilename     Filename.
    364365 * @param       pszDescription  Pointer to file description.
     
    369370 * @remark
    370371 */
    371 BOOL            _System dbInsertUpdateFile(signed long lDll,
     372BOOL            _System dbInsertUpdateFile(signed long lModule,
    372373                                           const char *pszFilename,
    373374                                           const char *pszDescription,
     
    382383
    383384    /* parameter assertions */
    384     assert(lDll != 0);
     385    assert(lModule != 0);
    385386    assert(pszFilename != NULL);
    386387    assert(*pszFilename != '\0');
    387388
    388389    /* 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);
    390391    rc = mysql_query(pmysql, &szQuery[0]);
    391392    pres = mysql_store_result(pmysql);
     
    395396        if (mysql_num_rows(pres) > 1)
    396397        {
    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);
     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);
    399400            return FALSE;
    400401        }
     
    450451    else
    451452    {   /* insert */
    452         sprintf(&szQuery[0], "INSERT INTO file(dll, name, lastauthor, description, lastdatetime, revision) VALUES(%d, '%s', %ld, ",
    453                 lDll, pszFilename, lLastAuthor);
     453        sprintf(&szQuery[0], "INSERT INTO file(module, name, lastauthor, description, lastdatetime, revision) VALUES(%d, '%s', %ld, ",
     454                lModule, pszFilename, lLastAuthor);
    454455        if (pszDescription != NULL && *pszDescription != '\0')
    455456            sqlstrcat(&szQuery[0], NULL, pszDescription);
     
    524525 * @param     pszFunctionName   Pointer to a function name string. (input)
    525526 * @param     pFnFindBuf        Pointer to a find buffer. (output)
    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).
     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).
    529530 *            2) Get functions which aliases the functions found in (1).
    530531 *            3) Get new aliases by intname
     
    533534 *            6) Update all functions from (3) and (4) to alias the first function from 1.
    534535 */
    535 BOOL _System dbFindFunction(const char *pszFunctionName, PFNFINDBUF pFnFindBuf, signed long lDll)
     536BOOL _System dbFindFunction(const char *pszFunctionName, PFNFINDBUF pFnFindBuf, signed long lModule)
    536537{
    537538    MYSQL_RES   *pres;
     
    541542
    542543    /*
    543      * 1) Get functions for this dll(if given).
     544     * 1) Get functions for this module(if given).
    544545     */
    545     if (lDll < 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'",
    547548                pszFunctionName);
    548549    else
    549         sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn, file, name FROM function "
    550                 "WHERE intname = '%s' AND dll = %ld",
    551                 pszFunctionName, lDll);
     550        sprintf(&szQuery[0], "SELECT refcode, module, aliasfn, file, name, type FROM function "
     551                "WHERE intname = '%s' AND module = %ld",
     552                pszFunctionName, lModule);
    552553
    553554    rc = mysql_query1(pmysql, &szQuery[0]);
     
    558559        {
    559560            char szFnName[NBR_FUNCTIONS][80];
     561            BOOL fAPI = FALSE;
    560562
    561563            pFnFindBuf->cFns = 0;
     
    563565            {
    564566                pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]);
    565                 pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]);
     567                pFnFindBuf->alModRefCode[pFnFindBuf->cFns] = atol(row[1]);
    566568                pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);
    567569                pFnFindBuf->alFileRefCode[pFnFindBuf->cFns] = atol(row[3]);
    568570                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;
    569575
    570576                /* next */
     
    573579            mysql_free_result(pres);
    574580
    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)
    577583            {
    578                 int cFnsThisDll, cFnsAliasesAndThisDll, i, f;
     584                int cFnsThisModule, cFnsAliasesAndThisModule, i, f;
    579585
    580586                /*
    581587                 * 2) Get functions which aliases the functions found in (1).
    582588                 */
    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++)
     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++)
    586592                {
    587593                    if (i > 0)  strcat(&szQuery[0], " OR ");
     
    599605                        {
    600606                            pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]);
    601                             pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]);
     607                            pFnFindBuf->alModRefCode[pFnFindBuf->cFns] = atol(row[1]);
    602608                            pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);
    603609                            pFnFindBuf->alFileRefCode[pFnFindBuf->cFns] = atol(row[3]);
     
    612618                         * 3) Get new aliases by intname
    613619                         */
    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++)
     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++)
    619625                            sprintf(&szQuery[strlen(&szQuery[0])], " OR intname = '%s'", szFnName[i]);
    620626                        strcat(&szQuery[0], ")");
     
    629635                                {
    630636                                    pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]);
    631                                     pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]);
     637                                    pFnFindBuf->alModRefCode[pFnFindBuf->cFns] = atol(row[1]);
    632638                                    if (row[2] != NULL)
    633639                                        pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);
     
    645651                                 * 4) Get new aliases by name
    646652                                 */
    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++)
     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++)
    651657                                    sprintf(&szQuery[strlen(&szQuery[0])], " OR name = '%s'", szFnName[i]);
    652658                                strcat(&szQuery[0], ")");
     
    661667                                        {
    662668                                            pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]);
    663                                             pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]);
     669                                            pFnFindBuf->alModRefCode[pFnFindBuf->cFns] = atol(row[1]);
    664670                                            if (row[2] != NULL)
    665671                                                pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);
     
    678684                                        sprintf(&szQuery[0], "UPDATE function SET aliasfn = (-2) "
    679685                                                             "WHERE refcode IN (",
    680                                                 lDll, pszFunctionName);
    681                                         for (f = 0, i = 0; i < cFnsThisDll; i++)
     686                                                lModule, pszFunctionName);
     687                                        for (f = 0, i = 0; i < cFnsThisModule; i++)
    682688                                            if (pFnFindBuf->alAliasFn[i] != ALIAS_DONTMIND)
    683689                                                sprintf(&szQuery[strlen(&szQuery[0])],
     
    688694                                        else
    689695                                            rc = 0;
    690                                         if (rc >= 0 && cFnsAliasesAndThisDll < pFnFindBuf->cFns)
     696                                        if (rc >= 0 && cFnsAliasesAndThisModule < pFnFindBuf->cFns)
    691697                                        {
    692698                                            /*
     
    696702                                                                 "WHERE aliasfn = (-1) AND refcode IN (",
    697703                                                    pFnFindBuf->alRefCode[0], pFnFindBuf->alFileRefCode[0]);
    698                                             for (i = cFnsAliasesAndThisDll; i < pFnFindBuf->cFns; i++)
     704                                            for (i = cFnsAliasesAndThisModule; i < pFnFindBuf->cFns; i++)
    699705                                            {
    700706                                                sprintf(&szQuery[strlen(&szQuery[0])],
    701                                                         i > cFnsAliasesAndThisDll ? ", %ld" : "%ld", pFnFindBuf->alRefCode[i]);
     707                                                        i > cFnsAliasesAndThisModule ? ", %ld" : "%ld", pFnFindBuf->alRefCode[i]);
    702708                                            }
    703709                                            strcat(&szQuery[0], ")");
     
    722728/**
    723729 * Finds the refcode for a file (if it exists).
    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)
     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 */
     735signed long     _System dbFindFile(signed long lModule, const char *pszFilename)
    730736{
    731737    char        szQuery[256];
     
    733739    signed long lRefCode = -1;
    734740
    735     assert(lDll >= 0);
     741    assert(lModule >= 0);
    736742    assert(pszFilename != NULL);
    737743    assert(*pszFilename != '\0');
    738744
    739     sprintf(&szQuery[0], "SELECT refcode FROM file WHERE dll = %ld AND name = '%s'",
    740             lDll, pszFilename);
     745    sprintf(&szQuery[0], "SELECT refcode FROM file WHERE module = %ld AND name = '%s'",
     746            lModule, pszFilename);
    741747    if (mysql_query(pmysql, &szQuery[0]) >= 0)
    742748    {
     
    878884 * @returns   number of errors.
    879885 * @param     pFnDesc   Function description struct.
    880  * @param     lDll      Dll which we are working at.
     886 * @param     lModule   Module which we are working at.
    881887 * @param     pszError  Buffer for error messages
    882888 * @result    on error(s) pszError will hold information about the error(s).
    883889 */
    884 unsigned long _System dbUpdateFunction(PFNDESC pFnDesc, signed long lDll, char *pszError)
     890unsigned long _System dbUpdateFunction(PFNDESC pFnDesc, signed long lModule, char *pszError)
    885891{
    886892    MYSQL_RES *     pres;
     
    11401146    } /* for */
    11411147
    1142     lDll = lDll;
     1148    lModule = lModule;
    11431149    free(pszQuery2);
    11441150    return ulRc;
     
    11481154/**
    11491155 * 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)
    11561159 */
    11571160BOOL            _System dbRemoveDesignNotes(signed long lFile)
     
    11681171 * Adds a design note.
    11691172 * @returns     Success indicator.
    1170  * @param       lDll            Dll refcode.
     1173 * @param       lModule         Module refcode.
    11711174 * @param       lFile           File refcode.
    11721175 * @param       pszTitle        Design note title.
    11731176 * @param       pszText         Design note text.
    11741177 * @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.
    11761179 * @param       lSeqNbrNote     Sequence number in note.
    11771180 * @param       lLine           Line number (1 - based!).
     
    11811184 * @param       plRefCode       Pointer to reference id of the design note. see fSubSection for more info.
    11821185 */
    1183 BOOL            _System dbAddDesignNote(signed long lDll,
     1186BOOL            _System dbAddDesignNote(signed long lModule,
    11841187                                        signed long lFile,
    11851188                                        const char *pszTitle,
     
    11971200
    11981201
    1199     assert(lDll >= 0 && lFile >= 0);
     1202    assert(lModule >= 0 && lFile >= 0);
    12001203    assert(lSeqNbrNote >= 0);
    12011204
     
    12051208    if (lSeqNbr == 0 && !fSubSection)
    12061209    {
    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);
    12081211        if (mysql_query(pmysql, &szQuery[0]) >= 0)
    12091212        {
     
    12291232     */
    12301233    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) "
    12321235                             "VALUES (%ld, %ld, %ld, %ld, %ld, %ld, ",
    1233                 lDll, lFile, lLevel, lSeqNbrNote, lSeqNbr, lLine);
     1236                lModule, lFile, lLevel, lSeqNbrNote, lSeqNbr, lLine);
    12341237    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) "
    12361239                             "VALUES (%ld, %ld, %ld, %ld, %ld, %ld, %ld, ",
    1237                 *plRefCode, lDll, lFile, lLevel, lSeqNbrNote, lSeqNbr, lLine);
     1240                *plRefCode, lModule, lFile, lLevel, lSeqNbrNote, lSeqNbr, lLine);
    12381241
    12391242    if (pszTitle != NULL && *pszTitle != '\0')
     
    12861289
    12871290            /* delete - all rows on this date in the history tables */
    1288             sprintf(pszQuery, "DELETE FROM historydll WHERE date = '%s'", &szCurDt[0]);
     1291            sprintf(pszQuery, "DELETE FROM historymodule WHERE date = '%s'", &szCurDt[0]);
    12891292            rc = mysql_query(pmysql, pszQuery);
    12901293            CheckLogContinue((pszError, "error removing old history rows: %s - (sql=%s) ", dbGetLastErrorDesc(), pszQuery));
     
    12941297            CheckLogContinue((pszError, "error removing old history rows: %s - (sql=%s) ", dbGetLastErrorDesc(), pszQuery));
    12951298
    1296             sprintf(pszQuery, "DELETE FROM historydlltotal WHERE date = '%s'", &szCurDt[0]);
     1299            sprintf(pszQuery, "DELETE FROM historymoduletotal WHERE date = '%s'", &szCurDt[0]);
    12971300            rc = mysql_query(pmysql, pszQuery);
    12981301            CheckLogContinue((pszError, "error removing old history rows: %s - (sql=%s) ", dbGetLastErrorDesc(), pszQuery));
     
    13021305
    13031306            /* insert new stats */
    1304             sprintf(pszQuery, "INSERT INTO historydll(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",
    13061309                    &szCurDt[0]);
    13071310            rc = mysql_query(pmysql, pszQuery);
     
    13161319
    13171320            /* inserting new totals */
    1318             sprintf(pszQuery, "INSERT INTO historydlltotal(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",
    13201323                    &szCurDt[0]);
    13211324            rc = mysql_query(pmysql, pszQuery);
     
    13231326
    13241327            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' "
    13261329                    "GROUP BY apigroup",
    13271330                    &szCurDt[0]);
     
    13691372
    13701373    /* 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");
    13721375    rc = mysql_query(pmysql, pszQuery);
    13731376    if (rc >= 0)
     
    13781381            while ((row1 = mysql_fetch_row(pres1)) != NULL)
    13791382            {
    1380                 /* check dll */
    1381                 sprintf(pszQuery, "SELECT refcode FROM dll WHERE refcode = %s", row1[1]);
     1383                /* check module */
     1384                sprintf(pszQuery, "SELECT refcode FROM module WHERE refcode = %s", row1[1]);
    13821385                rc = mysql_query(pmysql, pszQuery);
    1383                 CheckFKError("function/dll", "Foreign key 'dll' not found in the dll table");
     1386                CheckFKError("function/module", "Foreign key 'module' not found in the module table");
    13841387
    13851388                /* check state */
     
    14111414
    14121415    /* foreign keys in file */
    1413     strcpy(pszQuery, "SELECT refcode, dll FROM file");
     1416    strcpy(pszQuery, "SELECT refcode, module FROM file");
    14141417    rc = mysql_query(pmysql, pszQuery);
    14151418    if (rc >= 0)
     
    14201423            while ((row1 = mysql_fetch_row(pres1)) != NULL)
    14211424            {
    1422                 /* check dll */
    1423                 sprintf(pszQuery, "SELECT refcode FROM dll WHERE refcode = %s", row1[1]);
     1425                /* check module */
     1426                sprintf(pszQuery, "SELECT refcode FROM module WHERE refcode = %s", row1[1]);
    14241427                rc = mysql_query(pmysql, pszQuery);
    1425                 CheckFKError("apigroup/dll", "Foreign key 'dll' not found in the dll table");
     1428                CheckFKError("apigroup/module", "Foreign key 'module' not found in the module table");
    14261429            }
    14271430            mysql_free_result(pres1);
     
    14321435
    14331436    /* foreign keys in apigroup */
    1434     strcpy(pszQuery, "SELECT refcode, dll FROM apigroup");
     1437    strcpy(pszQuery, "SELECT refcode, module FROM apigroup");
    14351438    rc = mysql_query(pmysql, pszQuery);
    14361439    if (rc >= 0)
     
    14411444            while ((row1 = mysql_fetch_row(pres1)) != NULL)
    14421445            {
    1443                 /* check dll */
    1444                 sprintf(pszQuery, "SELECT refcode FROM dll WHERE refcode = %s", row1[1]);
     1446                /* check module */
     1447                sprintf(pszQuery, "SELECT refcode FROM module WHERE refcode = %s", row1[1]);
    14451448                rc = mysql_query(pmysql, pszQuery);
    1446                 CheckFKError("file/dll", "Foreign key 'dll' not found in the dll table");
     1449                CheckFKError("file/module", "Foreign key 'module' not found in the module table");
    14471450            }
    14481451            mysql_free_result(pres1);
     
    14781481        ulRc += logDbError(pszError, pszQuery);
    14791482
    1480     /* foreign keys in historydll table */
    1481     strcpy(pszQuery, "SELECT date, dll, state FROM historydll");
     1483    /* foreign keys in historymodule table */
     1484    strcpy(pszQuery, "SELECT date, module, state FROM historymodule");
    14821485    rc = mysql_query(pmysql, pszQuery);
    14831486    if (rc >= 0)
     
    14881491            while ((row1 = mysql_fetch_row(pres1)) != NULL)
    14891492            {
    1490                 /* check dll */
    1491                 sprintf(pszQuery, "SELECT refcode FROM dll WHERE refcode = %s", row1[1]);
     1493                /* check module */
     1494                sprintf(pszQuery, "SELECT refcode FROM module WHERE refcode = %s", row1[1]);
    14921495                rc = mysql_query(pmysql, pszQuery);
    1493                 CheckFKError("historydll/dll", "Foreign key 'dll' not found in the dll table");
     1496                CheckFKError("historymodule/module", "Foreign key 'module' not found in the module table");
    14941497
    14951498                /* check state */
    14961499                sprintf(pszQuery, "SELECT refcode FROM state WHERE refcode = %s", row1[2]);
    14971500                rc = mysql_query(pmysql, pszQuery);
    1498                 CheckFKError("historydll/state", "Foreign key 'state' not found in the state table");
     1501                CheckFKError("historymodule/state", "Foreign key 'state' not found in the state table");
    14991502            }
    15001503            mysql_free_result(pres1);
     
    15141517            while ((row1 = mysql_fetch_row(pres1)) != NULL)
    15151518            {
    1516                 /* check dll */
     1519                /* check module */
    15171520                sprintf(pszQuery, "SELECT refcode FROM apigroup WHERE refcode = %s", row1[1]);
    15181521                rc = mysql_query(pmysql, pszQuery);
     
    15301533        ulRc += logDbError(pszError, pszQuery);
    15311534
    1532     /* foreign keys in historydlltotal table */
    1533     strcpy(pszQuery, "SELECT date, dll FROM historydlltotal");
     1535    /* foreign keys in historymoduletotal table */
     1536    strcpy(pszQuery, "SELECT date, module FROM historymoduletotal");
    15341537    rc = mysql_query(pmysql, pszQuery);
    15351538    if (rc >= 0)
     
    15401543            while ((row1 = mysql_fetch_row(pres1)) != NULL)
    15411544            {
    1542                 /* check dll */
    1543                 sprintf(pszQuery, "SELECT refcode FROM dll WHERE refcode = %s", row1[1]);
     1545                /* check module */
     1546                sprintf(pszQuery, "SELECT refcode FROM module WHERE refcode = %s", row1[1]);
    15441547                rc = mysql_query(pmysql, pszQuery);
    1545                 CheckFKError("historydlltotal/dll", "Foreign key 'dll' not found in the dll table");
     1548                CheckFKError("historymoduletotal/module", "Foreign key 'module' not found in the module table");
    15461549            }
    15471550            mysql_free_result(pres1);
     
    15611564            while ((row1 = mysql_fetch_row(pres1)) != NULL)
    15621565            {
    1563                 /* check dll */
     1566                /* check module */
    15641567                sprintf(pszQuery, "SELECT refcode FROM apigroup WHERE refcode = %s", row1[1]);
    15651568                rc = mysql_query(pmysql, pszQuery);
     
    18551858
    18561859/**
    1857  * Display all functions for, the given dll, that is not updated.
     1860 * Display all functions for, the given module, that is not updated.
    18581861 * @returns   TRUE / FALSE.
    1859  * @param     lDll         Dll reference number.
     1862 * @param     lModule      Module reference number.
    18601863 * @param     dbFetchCall  Callback function which will be called once for each
    18611864 *                         field for all the functions not updated.
    18621865 *                         pvUser is NULL, pszValue field value, pszFieldName the field name.
    18631866 */
    1864 BOOL _System dbGetNotUpdatedFunction(signed long lDll, DBCALLBACKFETCH dbFetchCallBack)
     1867BOOL _System dbGetNotUpdatedFunction(signed long lModule, DBCALLBACKFETCH dbFetchCallBack)
    18651868{
    18661869    BOOL        fRet = FALSE;
     
    18711874    sprintf(&szQuery[0], "SELECT f1.name, f1.intname, f1.updated, f1.aliasfn, d.name, f2.name, f2.intname AS last "
    18721875                         "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             lDll);
     1876                         "     LEFT JOIN module d ON f2.module = d.refcode "
     1877                         "WHERE f1.module = %ld AND f1.updated = 0",
     1878            lModule);
    18761879    pres = dbExecuteQuery(szQuery);
    18771880    if (pres != NULL)
     
    18891892    sprintf(&szQuery[0], "SELECT f1.name, f1.intname, f1.updated, f1.aliasfn, d.name, f2.name, f2.intname AS last "
    18901893                         "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             lDll);
     1894                         "     LEFT JOIN module d ON f2.module = d.refcode "
     1895                         "WHERE f1.module = %ld AND f1.updated > 1",
     1896            lModule);
    18941897    pres = dbExecuteQuery(szQuery);
    18951898    if (pres != NULL)
     
    19121915
    19131916/**
    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)
     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 */
     1921signed long _System dbGetNumberOfUpdatedFunction(signed long lModule)
    19191922{
    19201923    int         rc;
     
    19221925    MYSQL_RES * pres;
    19231926
    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);
    19251928    rc   = mysql_query(pmysql, &szQuery[0]);
    19261929    pres = mysql_store_result(pmysql);
     
    19361939
    19371940/**
    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)
     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 */
     1947BOOL             _System dbClearUpdateFlagFile(signed long lModule)
    19451948{
    19461949    int         rc;
     
    19481951
    19491952    sprintf(&szQuery[0],
    1950             "UPDATE file SET updated = 0 WHERE dll = (%ld)",
    1951             lDll);
     1953            "UPDATE file SET updated = 0 WHERE module = (%ld)",
     1954            lModule);
    19521955    rc = mysql_query(pmysql, &szQuery[0]);
    19531956    return rc == 0;
     
    19571960/**
    19581961 * Clear update flag
    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)
     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 */
     1968BOOL             _System dbClearUpdateFlagFunction(signed long lModule, BOOL fAll)
    19661969{
    19671970    int         rc;
     
    19691972
    19701973    sprintf(&szQuery[0],
    1971             "UPDATE function SET updated = 0 WHERE dll = (%ld)",
    1972             lDll);
     1974            "UPDATE function SET updated = 0 WHERE module = (%ld)",
     1975            lModule);
    19731976    if (!fAll)
    19741977        strcat(&szQuery[0], " AND type IN ('A', 'I')");
     
    19801983
    19811984/**
    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.
    19831986 * @returns     Success indicator.
    1984  * @param       lDll    Dll refcode.
     1987 * @param       lModule    Module refcode.
    19851988 * @sketch      Select all files which is to be deleted.
    19861989 *                  Set all references to each file in function to -1.
     
    19891992 * @remark      Use with GRATE CARE!
    19901993 */
    1991 BOOL             _System dbDeleteNotUpdatedFiles(signed long lDll)
     1994BOOL             _System dbDeleteNotUpdatedFiles(signed long lModule)
    19921995{
    19931996    MYSQL_RES * pres;
     
    19972000
    19982001    sprintf(&szQuery[0],
    1999             "SELECT refcode FROM file WHERE dll = (%ld) AND updated = 0",
    2000             lDll);
     2002            "SELECT refcode FROM file WHERE module = (%ld) AND updated = 0",
     2003            lModule);
    20012004    rc = mysql_query(pmysql, &szQuery[0]);
    20022005    pres = mysql_store_result(pmysql);
     
    20152018
    20162019    sprintf(&szQuery[0],
    2017             "DELETE FROM file WHERE dll = %ld AND updated = 0",
    2018             lDll);
     2020            "DELETE FROM file WHERE module = %ld AND updated = 0",
     2021            lModule);
    20192022    rc = mysql_query(pmysql, &szQuery[0]);
    20202023    if (rc) fRc = FALSE;
     
    20302033 *
    20312034 * @returns     Success indicator. (TRUE / FALSE)
    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).
     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).
    20352038 *              If anyone Then
    20362039 *                  Delete the referenced to the functions in:
     
    20412044 * @remark      Use with GREATE CARE!
    20422045 */
    2043 BOOL             _System dbDeleteNotUpdatedFunctions(signed long lDll, BOOL fAll)
     2046BOOL             _System dbDeleteNotUpdatedFunctions(signed long lModule, BOOL fAll)
    20442047{
    20452048    MYSQL_RES * pres;
     
    20492052
    20502053    sprintf(&szQuery[0],
    2051             "SELECT refcode FROM function WHERE dll = %ld AND updated = 0",
    2052             lDll);
     2054            "SELECT refcode FROM function WHERE module = %ld AND updated = 0",
     2055            lModule);
    20532056    if (!fAll)
    20542057        strcat(&szQuery[0], " AND type IN ('A', 'I')");
     
    20812084        {
    20822085            sprintf(&szQuery[0],
    2083                     "DELETE FROM function WHERE dll = %ld AND updated = 0",
    2084                     lDll);
     2086                    "DELETE FROM function WHERE module = %ld AND updated = 0",
     2087                    lModule);
    20852088            if (!fAll)
    20862089                strcat(&szQuery[0], " AND type IN ('A', 'I')");
Note: See TracChangeset for help on using the changeset viewer.