Changeset 3899 for trunk/tools/database


Ignore:
Timestamp:
Jul 29, 2000, 4:12:47 PM (25 years ago)
Author:
bird
Message:

Updates the file column in the function table.

Location:
trunk/tools/database
Files:
3 edited

Legend:

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

    r3882 r3899  
    1 /* $Id: StateUpd.cpp,v 1.26 2000-07-21 21:09:43 bird Exp $
     1/* $Id: StateUpd.cpp,v 1.27 2000-07-29 14:12:46 bird Exp $
    22 *
    33 * StateUpd - Scans source files for API functions and imports data on them.
     
    894894    memset(&FnDesc, 0, sizeof(FnDesc));
    895895
    896     /* default value */
     896    /* default value and file number. */
    897897    FnDesc.lStatus = 99;
     898    FnDesc.lFile = pOptions->lFileRefcode;
    898899
    899900    /* precondition: isFunction is true.
  • trunk/tools/database/db.cpp

    r3882 r3899  
    1 /* $Id: db.cpp,v 1.16 2000-07-21 21:09:44 bird Exp $ *
     1/* $Id: db.cpp,v 1.17 2000-07-29 14:12:47 bird Exp $ *
    22 *
    33 * DB - contains all database routines.
     
    905905    for (k = 0; k < pFnDesc->cRefCodes; k++)
    906906    {
    907         BOOL    f = FALSE;
    908 
    909         /*
    910          * Set updated flag
    911          */
    912         sprintf(pszQuery, "UPDATE function SET updated = updated + 1 WHERE refcode = %ld",
    913                 pFnDesc->alRefCode[k]);
    914         rc = mysql_queryu1(pmysql, pszQuery2);
    915 
    916 
    917907        /*
    918908         * Get current status
     
    922912        {
    923913            strcpy(pszError, dbGetLastErrorDesc());
     914            /*
     915             * Set updated flag
     916             */
     917            sprintf(pszQuery, "UPDATE function SET updated = updated + 1 WHERE refcode = %ld",
     918                    pFnDesc->alRefCode[k]);
     919            rc = mysql_queryu1(pmysql, pszQuery2);
    924920            free(pszQuery2);
    925921            return 1;
     
    930926         * Update function table first
    931927         */
    932         strcpy(pszQuery, "UPDATE function SET ");
     928        strcpy(pszQuery, "UPDATE function SET updated = updated + 1");
    933929        pszQuery += strlen(pszQuery);
    934930
     
    936932        if (lCurrentState != pFnDesc->lStatus
    937933            && pFnDesc->lStatus != 0
    938             && (lCurrentState == 0 || pFnDesc->lStatus != 99))
    939         {
    940             sprintf(pszQuery, "state = %ld", pFnDesc->lStatus);
    941             f = TRUE;
    942         }
    943         pszQuery += strlen(pszQuery);
     934            && (lCurrentState == 0 || pFnDesc->lStatus != 99)
     935            )
     936            pszQuery += sprintf(pszQuery, ", state = %ld", pFnDesc->lStatus);
     937
     938        /* File */
     939        if (pFnDesc->lFile >= 0)
     940            pszQuery += sprintf(pszQuery, ", file = %ld", pFnDesc->lFile);
     941        else
     942            pszQuery += sprintf(pszQuery, ", file = -1");
    944943
    945944        /* return type */
    946945        if (pFnDesc->pszReturnType != NULL)
    947         {
    948             if (f)  strcat(pszQuery, ", ");
    949             pszQuery = sqlstrcat(pszQuery, "return = ",  pFnDesc->pszReturnType);
    950             f = TRUE;
    951         }
     946            pszQuery = sqlstrcat(pszQuery, ", return = ",  pFnDesc->pszReturnType);
     947        else
     948            pszQuery += sprintf(pszQuery, ", return = NULL");
    952949
    953950        /* Description */
    954951        if (pFnDesc->pszDescription != NULL)
    955         {
    956             if (f)  strcat(pszQuery, ", ");
    957             pszQuery = sqlstrcat(pszQuery, "description  = ", pFnDesc->pszDescription);
    958             f = TRUE;
    959         }
     952            pszQuery = sqlstrcat(pszQuery, ", description  = ", pFnDesc->pszDescription);
     953        else
     954            pszQuery += sprintf(pszQuery, ", description = NULL");
    960955
    961956        /* Remark */
    962957        if (pFnDesc->pszRemark != NULL)
    963         {
    964             if (f)  strcat(pszQuery, ", ");
    965             pszQuery = sqlstrcat(pszQuery,  "remark = ", pFnDesc->pszRemark);
    966             f = TRUE;
    967         }
     958            pszQuery = sqlstrcat(pszQuery, ", remark = ", pFnDesc->pszRemark);
     959        else
     960            pszQuery += sprintf(pszQuery, ", remark = NULL");
    968961
    969962        /* Description */
    970963        if (pFnDesc->pszReturnDesc != NULL)
    971         {
    972             if (f)  strcat(pszQuery, ", ");
    973             pszQuery = sqlstrcat(pszQuery,  "returndesc = ", pFnDesc->pszReturnDesc);
    974             f = TRUE;
    975         }
     964            pszQuery = sqlstrcat(pszQuery,  ", returndesc = ", pFnDesc->pszReturnDesc);
     965        else
     966            pszQuery += sprintf(pszQuery, ", returndesc = NULL");
    976967
    977968        /* Sketch */
    978969        if (pFnDesc->pszSketch != NULL)
    979         {
    980             if (f)  strcat(pszQuery, ", ");
    981             pszQuery = sqlstrcat(pszQuery,  "sketch = ", pFnDesc->pszSketch);
    982             f = TRUE;
    983         }
     970            pszQuery = sqlstrcat(pszQuery,  ", sketch = ", pFnDesc->pszSketch);
     971        else
     972            pszQuery += sprintf(pszQuery, ", sketch = NULL");
    984973
    985974        /* Equiv */
    986975        if (pFnDesc->pszEquiv != NULL)
    987         {
    988             if (f)  strcat(pszQuery, ", ");
    989             pszQuery = sqlstrcat(pszQuery,  "equiv = ", pFnDesc->pszEquiv);
    990             f = TRUE;
    991         }
     976            pszQuery = sqlstrcat(pszQuery,  ", equiv = ", pFnDesc->pszEquiv);
     977        else
     978            pszQuery += sprintf(pszQuery, ", equiv = NULL");
    992979
    993980        /* Time */
    994981        if (pFnDesc->pszTime != NULL)
    995         {
    996             if (f)  strcat(pszQuery, ", ");
    997             pszQuery = sqlstrcat(pszQuery,  "time = ", pFnDesc->pszTime);
    998             f = TRUE;
    999         }
     982            pszQuery = sqlstrcat(pszQuery,  ", time = ", pFnDesc->pszTime);
     983        else
     984            pszQuery += sprintf(pszQuery, ", time = NULL");
    1000985
    1001986        /* Execute update query? */
    1002         if (f)
    1003         {
    1004             sprintf(pszQuery + strlen(pszQuery), " WHERE refcode = %ld", pFnDesc->alRefCode[k]);
    1005             rc = mysql_queryu2(pmysql, pszQuery2);
    1006             if (rc < 0)
    1007             {
    1008                 sprintf(pszError, "Updating functiontable failed with error: %s - (sql=%s) ",
    1009                         dbGetLastErrorDesc(), pszQuery2);
    1010                 pszError += strlen(pszError) - 1;
    1011                 ulRc++;
    1012             }
    1013         }
    1014 
     987        sprintf(pszQuery + strlen(pszQuery), " WHERE refcode = %ld", pFnDesc->alRefCode[k]);
     988        rc = mysql_queryu2(pmysql, pszQuery2);
     989        if (rc < 0)
     990        {
     991            sprintf(pszError, "Updating functiontable failed with error: %s - (sql=%s) ",
     992                    dbGetLastErrorDesc(), pszQuery2);
     993            pszError += strlen(pszError) - 1;
     994            ulRc++;
     995        }
    1015996
    1016997
     
    10441025                            if (*pszError == ' ')
    10451026                                strcpy(pszError++, "\n\t");
    1046                             sprintf(pszError, "Updateing parameter %i failed with error: %s - (sql=%s) ",
     1027                            sprintf(pszError, "Updating parameter %i failed with error: %s - (sql=%s) ",
    10471028                                    i, dbGetLastErrorDesc(), pszQuery);
    10481029                            pszError += strlen(pszError) - 1;
     
    20202001 * @param       lDll    The refcode of the dll owning the functions.
    20212002 * @param       fAll    All function. If FALSE then only APIs and Internal APIs.
    2022  * @sketch      Select all functions which has updated = 0 and dll = lDll.
     2003 * @sketch      Select all functions which wan't updated (ie. updated = 0 and dll = lDll).
     2004 *              If anyone Then
    20232005 *                  Delete the referenced to the functions in:
    20242006 *                      parameters
    20252007 *                      fnauthor
    2026  *              Delete all function which has updated = 0 and dll = lDll
    2027  *
     2008 *                  Delete all function which wasn't updated.
     2009 *              EndIf
    20282010 * @remark      Use with GREATE CARE!
    20292011 */
     
    20422024    rc = mysql_query(pmysql, &szQuery[0]);
    20432025    pres = mysql_store_result(pmysql);
     2026
    20442027    if (pres != NULL && mysql_num_rows(pres))
    20452028    {
     
    20572040            if (rc) fRc = FALSE;
    20582041        }
    2059     }
    2060 
    2061     sprintf(&szQuery[0],
    2062             "DELETE FROM function WHERE dll = %ld AND updated = 0",
    2063             lDll);
    2064     if (!fAll)
    2065         strcat(&szQuery[0], " AND type IN ('A', 'I')");
    2066     rc = mysql_query(pmysql, &szQuery[0]);
    2067     if (rc) fRc = FALSE;
     2042
     2043        /*
     2044         * Delete the functions only if above completed without errors.
     2045         *
     2046         * Deleting the functions before all the references has successfully be
     2047         * deleted causes database corruption!
     2048         */
     2049        if (fRc)
     2050        {
     2051            sprintf(&szQuery[0],
     2052                    "DELETE FROM function WHERE dll = %ld AND updated = 0",
     2053                    lDll);
     2054            if (!fAll)
     2055                strcat(&szQuery[0], " AND type IN ('A', 'I')");
     2056            rc = mysql_query(pmysql, &szQuery[0]);
     2057            if (rc) fRc = FALSE;
     2058        }
     2059    }
    20682060
    20692061    return fRc;
  • trunk/tools/database/db.h

    r3882 r3899  
    1 /* $Id: db.h,v 1.11 2000-07-21 21:09:45 bird Exp $ */
     1/* $Id: db.h,v 1.12 2000-07-29 14:12:47 bird Exp $ */
    22/*
    33 * DB - contains all database routines
     
    4444    {
    4545        /* buffers */
    46         char  szFnDclBuffer[2048];
    47         char  szFnHdrBuffer[10240];
     46        char        szFnDclBuffer[2048];
     47        char        szFnHdrBuffer[10240];
    4848
    4949        /* function name and type */
    50         char *pszName;
    51         char *pszReturnType;
    52         long  cRefCodes;
    53         long  alRefCode[NBR_FUNCTIONS];
    54         signed long  lImpDll; /* -1 is SQL-NULL, -2 is do not mind, >= 0 ref to dll. */
     50        char *      pszName;
     51        char *      pszReturnType;
     52        long        cRefCodes;
     53        long        alRefCode[NBR_FUNCTIONS];
     54        signed long lImpDll; /* -1 is SQL-NULL, -2 is do not mind, >= 0 ref to dll. */
    5555
    5656        /* parameters */
    57         int   cParams;
    58         char *apszParamType[NBR_PARAMETERS];
    59         char *apszParamName[NBR_PARAMETERS];
    60         char *apszParamDesc[NBR_PARAMETERS];
     57        int         cParams;
     58        char *      apszParamType[NBR_PARAMETERS];
     59        char *      apszParamName[NBR_PARAMETERS];
     60        char *      apszParamDesc[NBR_PARAMETERS];
    6161
    6262        /* authors */
    63         int   cAuthors;
    64         char *apszAuthor[NBR_AUTHORS];
    65         long  alAuthorRefCode[NBR_AUTHORS];
     63        int         cAuthors;
     64        char *      apszAuthor[NBR_AUTHORS];
     65        long        alAuthorRefCode[NBR_AUTHORS];
    6666
    6767        /* other description fields */
    68         char *pszDescription;
    69         char *pszRemark;
    70         char *pszReturnDesc;
    71         char *pszSketch;
    72         char *pszEquiv;
    73         char *pszTime;
     68        char *      pszDescription;
     69        char *      pszRemark;
     70        char *      pszReturnDesc;
     71        char *      pszSketch;
     72        char *      pszEquiv;
     73        char *      pszTime;
    7474
    7575        /* status */
    76         char *pszStatus;
    77         long  lStatus;
     76        char *      pszStatus;
     77        long        lStatus;
     78
     79        /* file */
     80        long        lFile;              /* File refcode which this function is implemented in. */
     81                                        /* -1 if not valid. */
    7882    } FNDESC, *PFNDESC;
    7983
     
    8185    typedef struct _FunctionFindBuffer
    8286    {
    83         unsigned long cFns;
    84         signed long   alRefCode[NBR_FUNCTIONS];
    85         signed long   alDllRefCode[NBR_FUNCTIONS];
    86         signed long   alAliasFn[NBR_FUNCTIONS];     /* -1 is SQL-NULL, -2 is "do not mind", >= 0 ref to function. */
    87         signed long   alFileRefCode[NBR_FUNCTIONS]; /* -1 is SQL-NULL, -2 is "do not mind", >= 0 ref to file. */
     87        unsigned long   cFns;
     88        signed long     alRefCode[NBR_FUNCTIONS];
     89        signed long     alDllRefCode[NBR_FUNCTIONS];
     90        signed long     alAliasFn[NBR_FUNCTIONS];     /* -1 is SQL-NULL, -2 is "do not mind", >= 0 ref to function. */
     91        signed long     alFileRefCode[NBR_FUNCTIONS]; /* -1 is SQL-NULL, -2 is "do not mind", >= 0 ref to file. */
    8892    } FNFINDBUF, *PFNFINDBUF;
    8993
Note: See TracChangeset for help on using the changeset viewer.