Changeset 2770 for trunk/tools/database


Ignore:
Timestamp:
Feb 13, 2000, 12:54:30 AM (26 years ago)
Author:
bird
Message:

Corrections, DB optimizations, and some new features in StateUpd.

Location:
trunk/tools/database
Files:
7 edited

Legend:

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

    r2759 r2770  
    1 /* $Id: APIImport.cpp,v 1.2 2000-02-11 18:35:53 bird Exp $ */
     1/* $Id: APIImport.cpp,v 1.3 2000-02-12 23:54:28 bird Exp $ */
    22/*
    33 *
     
    3535static void closeLog(void);
    3636static long processFile(const char *pszFilename, const POPTIONS pOptions, long &cFunctions);
    37 static void demangle(const char *pszMangledName, char *pszDemangled);
     37static void demangle(char *pszDemangled, const char *pszMangledName);
    3838
    3939
     
    286286                            char szName[64];
    287287
    288                             demangle(export.achIntName, &szIntName[0]);
     288                            /* exported name */
    289289                            if (export.achName == '\0')
    290290                                sprintf(&szName[0], "Ordinal%04ld", export.ulOrdinal);
    291291                            else
    292292                                strcpy(&szName[0], &export.achName[0]);
     293
     294                            /* internal name */
     295                            if (export.achIntName[0] == '\0')
     296                                demangle(&szIntName[0], &szName[0]);
     297                            else
     298                                demangle(&szIntName[0], export.achIntName);
    293299
    294300                            fprintf(phLog, "%s: %08ld %-30s %s\n",
     
    342348/**
    343349 * Demangles stdcall functions.
     350 * @param       pszDemangled    Pointer to buffer which will hold the demangled name upon return.
    344351 * @param       pszMangledName  Mangled name
    345  * @param       pszDemangled    Pointer to buffer which will hold the demangled name upon return.
    346  */
    347 static void demangle(const char *pszMangledName, char *pszDemangled)
     352 */
     353static void demangle(char *pszDemangled, const char *pszMangledName)
    348354{
    349355    int iEnd;
  • trunk/tools/database/CreateTables.sql

    r2761 r2770  
    1 -- $Id: CreateTables.sql,v 1.3 2000-02-11 23:54:24 bird Exp $
     1-- $Id: CreateTables.sql,v 1.4 2000-02-12 23:54:29 bird Exp $
    22--
    33-- Create all tables.
     
    3838    updated  TINYINT  NOT NULL DEFAULT 0,
    3939    UNIQUE i1(refcode, aliasfn),
    40     UNIQUE i1a(aliasfn, name, dll),
    41     UNIQUE i1b(aliasfn, dll, refcode),
     40    UNIQUE i1a(dll, aliasfn, refcode),
     41    UNIQUE i1b(aliasfn, name, dll),
    4242    UNIQUE i1c(aliasfn, intname, dll, refcode),
    4343    UNIQUE i2(name, dll, refcode),
  • trunk/tools/database/Makefile

    r2761 r2770  
    1 # $Id: Makefile,v 1.7 2000-02-11 23:54:25 bird Exp $
     1# $Id: Makefile,v 1.8 2000-02-12 23:54:29 bird Exp $
    22
    33#
     
    126126#
    127127clean:
    128    -@$(RM) *.obj
    129    -@$(RM) *.lib
    130    -@$(RM) *.o
    131    -@$(RM) *.a
    132    -@$(RM) *.dll
    133    -@$(RM) *.exe
    134    -@$(RM) *.pch
    135    -@$(RM) *.log
    136    -@$(RM) *.map
    137    @cd gd
    138    @nmake /nologo clean
     128   $(RM) *.obj *.lib *.o *.a *.dll *.exe *.pch *.log *.map *.html
     129   cd gd
     130   $(MAKE) /nologo clean
     131   cd ..
    139132
    140133force:
  • trunk/tools/database/StateUpd.cpp

    r2765 r2770  
    1 /* $Id: StateUpd.cpp,v 1.10 2000-02-12 17:55:02 bird Exp $
     1/* $Id: StateUpd.cpp,v 1.11 2000-02-12 23:54:29 bird Exp $
    22 *
    33 * StateUpd - Scans source files for API functions and imports data on them.
     
    1313#define INCL_DOSERRORS
    1414#define INCL_DOSMISC
     15#define INCL_DOSPROCESS
    1516#include <os2.h>
    1617#include <stdio.h>
     
    5455static void copy(char *psz, char *pszFrom, int iFrom, char *pszTo, int iTo, char **papszLines);
    5556static char *stristr(const char *pszStr, const char *pszSubStr);
     57static char *skipBackwards(const char *pszStopAt, const char *pszFrom, int &iLine, char **papszLines);
    5658
    5759
     
    7577    char          *pszUser     = "root";
    7678    char          *pszPasswd   = "";
    77     ULONG          ul1, ul2;
     79    ULONG          ul0, ul1, ul2;
     80
    7881    DosError(0x3);
     82    DosSetPriority(PRTYS_PROCESSTREE, PRTYC_REGULAR, 1, 0);
    7983
    8084    /* get dll name from directory */
     
    286290        /* write status to log */
    287291        ul2 = dbGetNumberOfUpdatedFunction(options.lDllRefcode);
    288         ul1 = dbCountFunctionInDll(options.lDllRefcode);
     292        ul1 = dbCountFunctionInDll(options.lDllRefcode, FALSE);
     293        ul0 = dbCountFunctionInDll(options.lDllRefcode, TRUE);
    289294        fprintf(phLog, "-------------------------------------------------\n");
    290295        fprintf(phLog, "-------- Functions which was not updated --------\n");
     
    292297        fprintf(phLog, "-------------------------------------------------\n");
    293298        fprintf(phLog, "-------------------------------------------------\n\n");
    294         fprintf(phLog,"Number of function in this DLL:        %4ld\n", ul1);
     299        fprintf(phLog,"Number of function in this DLL:        %4ld (%ld)\n", ul1, ul0);
    295300        fprintf(phLog,"Number of successfully processed APIs: %4ld (%ld)\n", (long)(0x0000FFFF & ulRc), ul2);
    296301        fprintf(phLog,"Number of signals:                     %4ld\n", (long)(ulRc >> 16));
     
    303308
    304309        /* warn if error during processing. */
    305         fprintf(stdout,"Number of function in this DLL:        %4ld\n", ul1);
     310        fprintf(stdout,"Number of function in this DLL:        %4ld (%ld)\n", ul1, ul0);
    306311        fprintf(stdout,"Number of successfully processed APIs: %4ld (%ld)\n", (long)(0x0000FFFF & ulRc), ul2);
    307312        fprintf(stdout,"Number of signals:                     %4ld\n", (long)(ulRc >> 16));
     
    744749    int     cArgs;
    745750    char *  apszArgs[30];
     751    int     iClass;
     752    char *  pszClass, *pszClassEnd;
    746753
    747754    /* 1.*/
     
    753760    {
    754761        fprintf(phSignal, "%d: oops! didn't find end of function!, %d\n", pszFilename, __LINE__);
    755         iRet = iP1;
     762        iRet = iP1+1;
    756763        return 0x00010000;
    757764    }
     
    764771    {
    765772        pszFn = papszLines[--iFn];
    766         pszFn += strlen(pszFn);
    767     }
    768     while (iFn >= i && *pszFn == ' ')
     773        pszFn += strlen(pszFn) - (*pszFn != '\0');
     774    }
     775    while (iFn >= 0 && *pszFn == ' ')
    769776    {
    770777        if (pszFn != papszLines[iFn])
     
    773780        {
    774781            pszFn = papszLines[--iFn];
    775             pszFn += strlen(pszFn);
    776         }
    777     }
    778     if (*pszFn == ' ' || *pszFn == '\0')
     782            pszFn += strlen(pszFn) - (*pszFn != '\0');
     783        }
     784    }
     785    if (iFn < 0 || *pszFn == ' ' || *pszFn == '\0')
    779786    {
    780787        fprintf(phSignal, "%s: internal error!, %d\n", pszFilename, __LINE__);
    781         iRet = iP1;
     788        iRet = iP1+1;
    782789        return 0x00010000;
    783790    }
    784791    pszFnEnd = pszFn;
    785     pszFn = findStartOfWord(pszFn, papszLines[i]);
     792    pszFn = findStartOfWord(pszFn, papszLines[iFn]);
    786793
    787794    /* 2a. */
    788     psz = pszFn;
    789     while (psz >= papszLines[i] && *psz == ' ')
    790         psz--;
    791     if (psz > papszLines[i] && *psz == ':')
    792     {
    793         while (psz >= papszLines[i] && *psz == ' ')
    794             psz--;
    795         if (psz > papszLines[i] && *psz == ':')
    796         {
    797             while (psz >= papszLines[i] && *psz == ' ')
    798                 psz--;
    799             if (psz > papszLines[i])
    800                 pszFn = findStartOfWord(psz, papszLines[i]);
    801             else
    802                 fprintf(phLog, "%.*s: class name is not at same line as the ::\n", pszFnEnd - psz-1, psz+1);
    803         }
    804         else
    805         {
    806             fprintf(phLog, "%.*s: invalid class '::'\n", pszFnEnd - psz, psz);
    807             return 0;
    808         }
    809     }
     795    /* operators are not supported (BOOL kTime::operator > (const kTime &time) const) */
     796    if (pszFn > papszLines[iFn])
     797    {
     798        pszClassEnd = pszFn - 1;
     799        iClass = iFn;
     800    }
     801    else
     802    {
     803        pszClassEnd = pszFn - 1;
     804        iClass = iFn - 1;
     805    }
     806    c = 2;
     807    while (iClass >= 0 && c >= 0)
     808    {
     809        if (*pszClassEnd == ':')
     810            c--;
     811        else if (*pszClassEnd != ' ')
     812            break;
     813        pszClassEnd--;
     814    }
     815    if (*pszClassEnd != ' ' && c == 0)
     816        pszClass = findStartOfWord(pszClassEnd, papszLines[iClass]);
     817    else
     818        pszClass = pszClassEnd = NULL;
    810819
    811820    /* 3. */
     
    860869
    861870    /* 6. */
    862     if (strnicmp(pszFn, "ODINFUNCTION", 12) == 0)
    863     {
    864         if (cArgs < 2)
     871    if (strnicmp(pszFn, "ODINFUNCTION", 12) == 0 || strnicmp(pszFn, "ODINPROCEDURE", 13) == 0)
     872    {
     873        BOOL fProc = strnicmp(pszFn, "ODINPROCEDURE", 13) == 0;
     874        j = 0;
     875        if (cArgs < (fProc ? 1 : 2))
    865876        {
    866877            fprintf(phSignal, "%s: Invalid ODINFUNCTION function too few parameters!\n", pszFilename);
    867878            return 0x00010000;
    868879        }
     880
    869881        /* return type */
    870         pFnDesc->pszReturnType = apszArgs[0];
     882        if (fProc)
     883            pFnDesc->pszReturnType = "void";
     884        else
     885            pFnDesc->pszReturnType = apszArgs[j++];
    871886
    872887        /* function name */
    873         pFnDesc->pszName = apszArgs[1];
     888        pFnDesc->pszName = apszArgs[j++];
    874889
    875890        /* arguments */
    876         j = 2;
    877891        pFnDesc->cParams = 0;
    878892        while (j+1 < cArgs)
     
    886900    else
    887901    {
    888         /* return type - not implemented TODO/FIXME! */
     902        /* return type */
     903        int     iReturn = pszClass != NULL ? iClass : iFn;
     904        char *  pszReturn = pszClass != NULL ? pszClass : pszFn;
     905
     906        if (pszReturn != papszLines[iReturn])
     907            pszReturn--;
     908        else
     909        {
     910            pszReturn = papszLines[--iReturn];
     911            pszReturn += strlen(pszReturn) - (*pszReturn != '\0');
     912        }
     913        pszReturn = skipBackwards("{};-+#:\"\'", pszReturn, iReturn, papszLines);
    889914        *pszEnd = '\0';
    890         copy(pszEnd, papszLines[i], i, pszFn-1, iFn, papszLines);
     915        copy(pszEnd, pszReturn, iReturn, pszFn-1, iFn, papszLines);
     916        if (strlen(pszEnd) > 1024)
     917        {
     918            fprintf(phSignal,"Fatal error! return statement is too larget. len=%d", strlen(pszEnd));
     919            fprintf(phLog,   "Fatal error! return statement is too larget. len=%d", strlen(pszEnd));
     920            fprintf(stderr,  "Fatal error! return statement is too larget. len=%d", strlen(pszEnd));
     921            fflush(phLog);
     922            fflush(phSignal);
     923            fflush(stderr);
     924        }
     925        pszEnd = trim(pszEnd);
    891926        pFnDesc->pszReturnType = *pszEnd == '\0' ? NULL : pszEnd;
    892927        pszEnd = strlen(pszEnd) + pszEnd + 1;
     
    898933        {   /* cdecl function is prefixed with an '_' */
    899934            strcpy(pszEnd, "_");
    900             strncat(pszEnd + 1, pszFn, pszFnEnd - pszFn+1);
    901         }
    902         else
    903             strncat(pszEnd, pszFn, pszFnEnd - pszFn+1);
     935        }
     936        if (pszClass != NULL)
     937        {
     938            strncat(pszEnd,pszClass, pszClassEnd - pszClass + 1);
     939            strcat(pszEnd, "::");
     940        }
     941        strncat(pszEnd, pszFn, pszFnEnd - pszFn + 1);
    904942        pFnDesc->pszName = pszEnd;
    905943        pszEnd = strlen(pszEnd) + pszEnd + 1;
     
    12441282        {
    12451283            pszP1 = strchr(papszLines[i], '(');
    1246             if (pszP1 != NULL && pszP1 > papszLines[i])
     1284            if (pszP1 != NULL && pszP1 >= papszLines[i])
    12471285            {
    12481286                int  cchFnName  = 0;
    12491287                char *pszFnName = pszP1 - 1;
    12501288
    1251                 while (pszFnName - cchFnName > papszLines[i] && pszFnName[cchFnName] == ' ')
     1289                while (pszFnName - cchFnName > papszLines[0] && pszFnName[cchFnName] == ' ')
    12521290                    cchFnName--, pszFnName--;
    12531291
    1254                 pszFnName = findStartOfWord(pszFnName, papszLines[i]);
     1292                pszFnName = findStartOfWord(pszFnName, papszLines[0]);
    12551293                cchFnName += pszP1 - pszFnName;
    12561294                if (cchFnName >= 0)
     
    12941332                                    return TRUE;
    12951333                                }
     1334                                /* FIXME: constructors with ':' afterwards are not supported !TODO! */
    12961335                            }
    12971336                        }
     
    15261565    char *psz = pszFile;
    15271566    char **papszLines = NULL;
    1528     int  cLines = 0;
     1567    int  cLines = 1;
    15291568
    15301569    while (*psz != '\0')
     
    15441583    if (papszLines != NULL)
    15451584    {
    1546         cLines = 0;
    1547         psz = pszFile;
     1585        cLines = 1;
     1586        papszLines[0] = psz = pszFile;
    15481587        while (*psz != '\0')
    15491588        {
     
    16281667}
    16291668
    1630 
     1669#if 0
    16311670static void copy(char *psz, int jFrom, int iFrom, int jTo, int iTo, char **papszLines)
    16321671{
     
    16391678    while (i < iTo || (i == iTo && j <= jTo))
    16401679    {
    1641         if (papszLines[i][j] != '\0' &&
    1642             !(papszLines[i][j] == '/' && papszLines[i][j+1] == '/')  /* '//' coments */
     1680        if (papszLines[i][j] != '\0'
     1681            && !(papszLines[i][j] == '/' && papszLines[i][j+1] == '/')  /* '//' coments */
    16431682            )
    16441683        {
     
    16781717}
    16791718
     1719#else
     1720static void copy(char *psz, int jFrom, int iFrom, int jTo, int iTo, char **papszLines)
     1721{
     1722    char chPrev = '\n';
     1723    int i, j;
     1724    int fComment = FALSE;
     1725    int fFirst = TRUE;
     1726
     1727    i = iFrom;
     1728    j = jFrom;
     1729    while (i < iTo || (i == iTo && j <= jTo))
     1730    {
     1731        if (papszLines[i][j] != '\0'
     1732            && !(papszLines[i][j] == '/' && papszLines[i][j+1] == '/')  /* '//' coments */
     1733            && !(!fComment && fFirst && papszLines[i][j] == '#')
     1734            )
     1735        {
     1736            fFirst = papszLines[i][j] == ' ';
     1737
     1738            /* copy char ? */
     1739            if (!fComment)
     1740            {
     1741                fComment = papszLines[i][j] == '/' && papszLines[i][j+1] == '*';
     1742
     1743                if (!fComment && !(chPrev == ' ' && papszLines[i][j] == ' ') /* only one space char */
     1744                    && !(chPrev == '(' && papszLines[i][j] == ' ') /* no space after '(' */
     1745                    )
     1746                {
     1747                    if (chPrev == ' ' && (papszLines[i][j] == ',' || papszLines[i][j] == ')'))
     1748                        psz[-1] = papszLines[i][j]; /* no space before ',' and ')' */
     1749                    else
     1750                    {
     1751                        chPrev = *psz++ = papszLines[i][j];
     1752                        if (chPrev == '*')                  /* ensure ' ' after '*' */
     1753                            chPrev = *psz++ = ' ';
     1754                    }
     1755                }
     1756
     1757            }
     1758            else
     1759                if ((fComment = papszLines[i][j] != '*' || papszLines[i][j+1] != '/') == FALSE)
     1760                    j++;
     1761            j++;
     1762        }
     1763        else
     1764        {
     1765            /* next */
     1766            j = 0;
     1767            fFirst = TRUE;
     1768            i++;
     1769            if (chPrev != ' ' && chPrev != '(')
     1770                chPrev = *psz++ = ' ';
     1771        }
     1772    }
     1773    *psz = '\0';
     1774}
     1775#endif
     1776
    16801777
    16811778/**
     
    17141811}
    17151812
     1813
     1814
     1815/**
     1816 * Skips backwards until one of the chars in pszStopAt or star of file is reached.
     1817 * @returns   Pointer to end.
     1818 * @param     pszStopAt   Array of chars which we should stop at.
     1819 * @param     pszFrom     Start pointer.
     1820 * @param     iLine       Reference to index to array of lines. input: start line, output: result line.
     1821 * @param     papszLines  Array lines.
     1822 * @sketch
     1823 * @author    knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
     1824 * @remark    Comments are skipped.
     1825 *            No tests for strings ("...asdf").
     1826 */
     1827static char *skipBackwards(const char *pszStopAt, const char *pszFrom, int &iLine, char **papszLines)
     1828{
     1829    BOOL        fComment = FALSE;
     1830    int         i = iLine;
     1831    const char *psz = pszFrom;
     1832
     1833    while (i >= 0)
     1834    {
     1835        /* check for stop char */
     1836        const char *psz1 = pszStopAt;
     1837        while (*psz1 != '\0')
     1838            if (*psz1++ == *psz)
     1839                break;
     1840        if (*psz1 != '\0')
     1841            break;
     1842
     1843        /* comment check */
     1844        if (!fComment && psz > papszLines[i] && *psz == '/' && psz[-1] == '*')
     1845            fComment = TRUE;
     1846        else if (fComment && *psz == '/' && psz[1] == '*')
     1847            fComment = FALSE;
     1848
     1849        /* ok position to return? */
     1850        if (!fComment)
     1851        {
     1852            iLine = i;
     1853            pszFrom = psz;
     1854        }
     1855
     1856        /* prev */
     1857        if (psz > papszLines[i])
     1858            psz--;
     1859        else
     1860        {   /* try find line comment */
     1861            do
     1862            {
     1863                char *pszStart = papszLines[--i];
     1864                while (*pszStart == ' ')
     1865                    pszStart++;
     1866                if (*pszStart != '\0' && *pszStart != '#'
     1867                    && !(*pszStart == '/' && pszStart[1] == '/'))
     1868                {   /* find '//' */
     1869                    pszStart = strstr(pszStart, "//");
     1870                    if (pszStart != NULL)
     1871                        psz = pszStart-1;
     1872                    else
     1873                        psz = papszLines[i] + strlen(papszLines[i]) - 1;
     1874                    break;
     1875                }
     1876            } while (i > 0);
     1877        }
     1878    }
     1879
     1880    return (char*)pszFrom;
     1881}
     1882
  • trunk/tools/database/db.cpp

    r2765 r2770  
    1 /* $Id: db.cpp,v 1.7 2000-02-12 17:55:03 bird Exp $ *
     1/* $Id: db.cpp,v 1.8 2000-02-12 23:54:29 bird Exp $ *
    22 *
    33 * DB - contains all database routines.
     
    178178 * Count the function in a given dll.
    179179 * @returns  Number of functions. -1 on error.
    180  * @param    usDll  Dll refcode.
    181  */
    182 signed long     _System dbCountFunctionInDll(signed long ulDll)
     180 * @param    usDll        Dll refcode.
     181 * @param    fNotAliases  TRUE: don't count aliased functions.
     182 */
     183signed long     _System dbCountFunctionInDll(signed long ulDll, BOOL fNotAliases)
    183184{
    184185    signed long rc;
     
    189190    {
    190191        sprintf(&szQuery[0], "SELECT count(refcode) FROM function WHERE dll = %ld\n", ulDll);
     192        if (fNotAliases)
     193            strcat(&szQuery[0], " AND aliasfn < 0");
    191194        rc   = mysql_query(pmysql, &szQuery[0]);
    192195        pres = mysql_store_result(pmysql);
     
    284287 * @param     usDll           Dll refcode.
    285288 * @param     pszFunction     Function name.
    286  * @param     pszIntFunction  Internal function name.
     289 * @param     pszIntFunction  Internal function name. (required!)
    287290 * @param     ulOrdinal       Ordinal value.
    288291 * @param     fIgnoreOrdinal  Do not update ordinal value.
     
    297300    MYSQL_RES *pres;
    298301
    299     /* when no internal name, the exported name is the internal name too! */
     302    /* when no internal name fail! */
    300303    if (pszIntFunction == NULL || *pszIntFunction == '\0')
    301         pszIntFunction = pszFunction;
     304        return FALSE;
    302305
    303306    /* try find function */
     
    360363}
    361364
     365
    362366#if 1
     367/*
     368 * Stubs used while optimizing sqls.
     369 */
     370int     mysql_query1(MYSQL *mysql, const char *q)
     371{   return mysql_query(mysql, q); }
     372int     mysql_query2(MYSQL *mysql, const char *q)
     373{   return mysql_query(mysql, q); }
     374int     mysql_query3(MYSQL *mysql, const char *q)
     375{   return mysql_query(mysql, q); }
     376int     mysql_query4(MYSQL *mysql, const char *q)
     377{   return mysql_query(mysql, q); }
     378int     mysql_query5(MYSQL *mysql, const char *q)
     379{   return mysql_query(mysql, q); }
     380MYSQL_RES *  mysql_store_result1(MYSQL *mysql)
     381{   return mysql_store_result(mysql); }
     382MYSQL_RES *  mysql_store_result5(MYSQL *mysql)
     383{   return mysql_store_result(mysql); }
     384
     385#else
     386
     387#define mysql_query1            mysql_query
     388#define mysql_query2            mysql_query
     389#define mysql_query3            mysql_query
     390#define mysql_query4            mysql_query
     391#define mysql_query5            mysql_query
     392#define mysql_store_result1     mysql_store_result
     393#define mysql_store_result5     mysql_store_result
     394
     395#endif
     396
     397
     398
    363399/**
    364400 * Find occurences of a function, given by internal name.
     
    383419                pszFunctionName, lDll);
    384420
    385     rc = mysql_query(pmysql, &szQuery[0]);
     421    rc = mysql_query1(pmysql, &szQuery[0]);
    386422    if (rc >= 0)
    387423    {
    388         pres = mysql_store_result(pmysql);
     424        pres = mysql_store_result1(pmysql);
    389425        if (pres != NULL)
    390426        {
     
    404440            if (lDll >= 0 && pFnFindBuf->cFns != 0)
    405441            {
     442                #if 0
    406443                int i;
    407 
    408                 /* Make the selected function to DONT TOUCH */
    409                 sprintf(&szQuery[0], "UPDATE function SET aliasfn = (-2) "
    410                                      "WHERE (",
    411                         lDll, pszFunctionName);
    412                 for (i = 0; i < pFnFindBuf->cFns; i++)
    413                 {
    414                     if (i != 0) strcat(&szQuery[0], " OR");
    415                     sprintf(&szQuery[strlen(szQuery)], " refcode = %ld", pFnFindBuf->alRefCode[i]);
    416                 }
    417                 strcat(&szQuery[0], ") AND aliasfn <> (-2)");
    418 
    419                 rc = mysql_query(pmysql, &szQuery[0]);
    420                 if (rc >= 0)
    421                 {
    422                     /* Update all with equal internal... which is not in this Dll */
    423                     sprintf(&szQuery[0], "UPDATE function SET aliasfn = (%ld) "
    424                                          "WHERE aliasfn = (-1) AND dll <> %ld AND intname = '%s'",
    425                             pFnFindBuf->alRefCode[0], lDll, pszFunctionName, pszFunctionName);
    426                     rc = mysql_query(pmysql, &szQuery[0]);
    427                     if (rc >= 0)
    428                     {
    429                         /* Update all with equal external name... which is not in this Dll */
    430                         sprintf(&szQuery[0], "UPDATE function SET aliasfn = (%ld) "
    431                                              "WHERE aliasfn = (-1) AND dll <> %ld AND name = '%s'",
    432                                 pFnFindBuf->alRefCode[0], lDll, pszFunctionName, pszFunctionName);
    433 
    434                         rc = mysql_query(pmysql, &szQuery[0]);
    435                         if (rc >= 0)
    436                         {
    437                             /* get the functions aliases to the functions we have allready found. */
    438                             strcpy(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function WHERE aliasfn IN (");
    439                             for (i = 0; i < pFnFindBuf->cFns; i++)
    440                             {
    441                                 if (i != 0) strcat(&szQuery[0], ", ");
    442                                 sprintf(&szQuery[strlen(szQuery)], "%ld", pFnFindBuf->alRefCode[i]);
    443                             }
    444                             sprintf(&szQuery[strlen(szQuery)], ") AND dll <> %ld", lDll);
    445 
    446                             rc = mysql_query(pmysql, &szQuery[0]);
    447                             if (rc >= 0)
    448                             {
    449                                 pres = mysql_store_result(pmysql);
    450                                 if (pres != NULL)
    451                                 {
    452                                     while ((row = mysql_fetch_row(pres)) != NULL)
    453                                     {
    454                                         pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]);
    455                                         pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]);
    456                                         if (row[2] != NULL)
    457                                             pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);
    458                                         else
    459                                             pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = ALIAS_NULL;
    460 
    461                                         /* next */
    462                                         pFnFindBuf->cFns++;
    463                                     }
    464                                     mysql_free_result(pres);
    465                                 }
    466                             }
    467                         }
    468                     }
    469                 }
    470             }
    471         }
    472         else
    473             rc = -1;
    474     }
    475 
    476     return rc >= 0;
    477 }
    478 #else
    479 int     mysql_query1(MYSQL *mysql, const char *q)
    480 {
    481     return mysql_query(mysql, q);
    482 }
    483 
    484 int     mysql_query2(MYSQL *mysql, const char *q)
    485 {
    486     return mysql_query(mysql, q);
    487 }
    488 
    489 int     mysql_query3(MYSQL *mysql, const char *q)
    490 {
    491     return mysql_query(mysql, q);
    492 }
    493 
    494 int     mysql_query4(MYSQL *mysql, const char *q)
    495 {
    496     return mysql_query(mysql, q);
    497 }
    498 
    499 int     mysql_query5(MYSQL *mysql, const char *q)
    500 {
    501     return mysql_query(mysql, q);
    502 }
    503 
    504 MYSQL_RES *  mysql_store_result1(MYSQL *mysql)
    505 {
    506     return mysql_store_result(mysql);
    507 }
    508 
    509 MYSQL_RES *  mysql_store_result2(MYSQL *mysql)
    510 {
    511     return mysql_store_result(mysql);
    512 }
    513 
    514 
    515 /**
    516  * Find occurences of a function, given by internal name.
    517  * @returns   success indicator, TRUE / FALSE.
    518  * @param     pszFunctionName
    519  * @param     pFnFindBuf
    520  * @param     lDll
    521  */
    522 BOOL _System dbFindFunction(const char *pszFunctionName, PFNFINDBUF pFnFindBuf, signed long lDll)
    523 {
    524     MYSQL_RES   *pres;
    525     MYSQL_ROW    row;
    526     int          rc;
    527     char         szQuery[256];
    528 
    529     if (lDll < 0)
    530         sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function WHERE intname = '%s'",
    531                 pszFunctionName);
    532     else
    533         sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function "
    534                 "WHERE intname = '%s' AND dll = %ld",
    535                 pszFunctionName, lDll);
    536 
    537     rc = mysql_query1(pmysql, &szQuery[0]);
    538     if (rc >= 0)
    539     {
    540         pres = mysql_store_result1(pmysql);
    541         if (pres != NULL)
    542         {
    543             pFnFindBuf->cFns = 0;
    544             while ((row = mysql_fetch_row(pres)) != NULL)
    545             {
    546                 pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]);
    547                 pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]);
    548                 pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);
    549 
    550                 /* next */
    551                 pFnFindBuf->cFns++;
    552             }
    553             mysql_free_result(pres);
    554 
    555             /* alias check and fix */
    556             if (lDll >= 0 && pFnFindBuf->cFns != 0)
    557             {
    558                 int i;
    559 
    560444                /* Make the selected function to DONT TOUCH */
    561445                sprintf(&szQuery[0], "UPDATE function SET aliasfn = (-2) "
     
    587471                        if (rc >= 0)
    588472                        {
    589                             int cFns = pFnFindBuf->cFns;
    590                             for (i = 0; i < cFns; i++)
     473                            /* get the functions aliases to the functions we have allready found. */
     474                            sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function WHERE dll = %ld AND aliasfn IN (", lDll);
     475                            for (i = 0; i < pFnFindBuf->cFns; i++)
    591476                            {
    592                                 /* get the functions aliases to the functions we have allready found. */
    593                                 sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function WHERE aliasfn = %ld AND dll <> %ld",
    594                                         pFnFindBuf->alRefCode[i], lDll);
    595                                 rc = mysql_query5(pmysql, &szQuery[0]);
     477                                if (i != 0) strcat(&szQuery[0], ", ");
     478                                sprintf(&szQuery[strlen(szQuery)], "%ld", pFnFindBuf->alRefCode[i]);
     479                            }
     480                            strcat(&szQuery[strlen(szQuery)], ")");
     481
     482                            DosSleep(0);
     483                            rc = mysql_query5(pmysql, &szQuery[0]);
     484                            if (rc >= 0)
     485                            {
     486                                pres = mysql_store_result5(pmysql);
     487                                if (pres != NULL)
     488                                {
     489                                    while ((row = mysql_fetch_row(pres)) != NULL)
     490                                    {
     491                                        pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]);
     492                                        pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]);
     493                                        if (row[2] != NULL)
     494                                            pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);
     495                                        else
     496                                            pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = ALIAS_NULL;
     497
     498                                        /* next */
     499                                        pFnFindBuf->cFns++;
     500                                    }
     501                                    mysql_free_result(pres);
     502                                }
     503                            }
     504                        }
     505                    }
     506                }
     507                #else
     508                int i;
     509                int cFnsThisDll = (int)pFnFindBuf->cFns;
     510
     511                /* get the functions aliases to the functions we have allready found. */
     512                sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function "
     513                                     "WHERE aliasfn = (-1) AND dll <> %ld AND intname = '%s'",
     514                        lDll, pszFunctionName);
     515                rc = mysql_query2(pmysql, &szQuery[0]);
     516                if (rc >= 0)
     517                {
     518                    pres = mysql_store_result(pmysql);
     519                    if (pres != NULL)
     520                    {
     521                        while ((row = mysql_fetch_row(pres)) != NULL)
     522                        {
     523                            pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]);
     524                            pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]);
     525                            if (row[2] != NULL)
     526                                pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);
     527                            else
     528                                pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = ALIAS_NULL;
     529
     530                            /* next */
     531                            pFnFindBuf->cFns++;
     532                        }
     533                        mysql_free_result(pres);
     534
     535
     536                        /* get the functions aliases to the functions we have allready found. */
     537                        sprintf(&szQuery[0], "SELECT refcode, dll, aliasfn FROM function "
     538                                             "WHERE aliasfn = (-1) AND dll <> %ld AND name = '%s'",
     539                                lDll, pszFunctionName);
     540                        rc = mysql_query3(pmysql, &szQuery[0]);
     541                        if (rc >= 0)
     542                        {
     543                            pres = mysql_store_result(pmysql);
     544                            if (pres != NULL)
     545                            {
     546                                while ((row = mysql_fetch_row(pres)) != NULL)
     547                                {
     548                                    pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]);
     549                                    pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]);
     550                                    if (row[2] != NULL)
     551                                        pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);
     552                                    else
     553                                        pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = ALIAS_NULL;
     554
     555                                    /* next */
     556                                    pFnFindBuf->cFns++;
     557                                }
     558                                mysql_free_result(pres);
     559
     560                                /* do updates! */
     561                                /* Make the selected function to DONT TOUCH */
     562                                sprintf(&szQuery[0], "UPDATE function SET aliasfn = (-2) "
     563                                                     "WHERE (",
     564                                        lDll, pszFunctionName);
     565                                for (i = 0; i < cFnsThisDll; i++)
     566                                {
     567                                    if (i != 0) strcat(&szQuery[0], " OR");
     568                                    sprintf(&szQuery[strlen(szQuery)], " refcode = %ld", pFnFindBuf->alRefCode[i]);
     569                                }
     570                                strcat(&szQuery[0], ") AND aliasfn <> (-2)");
     571
     572                                rc = mysql_query4(pmysql, &szQuery[0]);
    596573                                if (rc >= 0)
    597574                                {
    598                                     pres = mysql_store_result2(pmysql);
    599                                     if (pres != NULL)
     575                                    /* Update all with equal internal... which is not in this Dll */
     576                                    sprintf(&szQuery[0], "UPDATE function SET aliasfn = (%ld) "
     577                                                         "WHERE aliasfn = (-1) AND dll <> %ld AND intname = '%s'",
     578                                            pFnFindBuf->alRefCode[0], lDll, pszFunctionName, pszFunctionName);
     579                                    rc = mysql_query5(pmysql, &szQuery[0]);
     580                                    if (rc >= 0)
    600581                                    {
    601                                         while ((row = mysql_fetch_row(pres)) != NULL)
    602                                         {
    603                                             pFnFindBuf->alRefCode[pFnFindBuf->cFns] = atol(row[0]);
    604                                             pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] = atol(row[1]);
    605                                             if (row[2] != NULL)
    606                                                 pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = atol(row[2]);
    607                                             else
    608                                                 pFnFindBuf->alAliasFn[pFnFindBuf->cFns] = ALIAS_NULL;
    609 
    610                                             /* next */
    611                                             if (pFnFindBuf->alDllRefCode[pFnFindBuf->cFns] != lDll)
    612                                                 pFnFindBuf->cFns++;
    613                                         }
    614                                         mysql_free_result(pres);
     582                                        /* Update all with equal external name... which is not in this Dll */
     583                                        sprintf(&szQuery[0], "UPDATE function SET aliasfn = (%ld) "
     584                                                             "WHERE aliasfn = (-1) AND dll <> %ld AND name = '%s'",
     585                                                pFnFindBuf->alRefCode[0], lDll, pszFunctionName, pszFunctionName);
     586
     587                                        rc = mysql_query4(pmysql, &szQuery[0]);
    615588                                    }
    616589                                }
     
    619592                    }
    620593                }
     594                #endif
    621595            }
    622596        }
     
    627601    return rc >= 0;
    628602}
    629 
    630 #endif
    631603
    632604
  • trunk/tools/database/db.h

    r2765 r2770  
    1 /* $Id: db.h,v 1.5 2000-02-12 17:55:03 bird Exp $ */
     1/* $Id: db.h,v 1.6 2000-02-12 23:54:29 bird Exp $ */
    22/*
    33 * DB - contains all database routines
     
    3131    {
    3232        /* buffers */
    33         char  szFnDclBuffer[512];
    34         char  szFnHdrBuffer[1024];
     33        char  szFnDclBuffer[2048];
     34        char  szFnHdrBuffer[2048];
    3535
    3636        /* function name and type */
     
    7878    BOOL            _System dbDisconnect();
    7979    signed short    _System dbGetDll(const char *pszDllName);
    80     signed long     _System dbCountFunctionInDll(signed long ulDll);
    81 
     80    signed long     _System dbCountFunctionInDll(signed long ulDll,
     81                                                 BOOL fNotAliases);
    8282    signed short    _System dbCheckInsertDll(const char *pszDll);
    8383    unsigned short  _System dbGet(const char *pszTable,
  • trunk/tools/database/makefile.gcc

    r2745 r2770  
    1 # $Id: makefile.gcc,v 1.1 2000-02-10 22:43:19 bird Exp $
     1# $Id: makefile.gcc,v 1.2 2000-02-12 23:54:30 bird Exp $
    22
    33#
     
    170170
    171171
    172 
    173172#
    174173# clean
    175174#
    176175clean:
    177    @$(RM) *.obj *.lib *.o *.a *.dll *.exe *.pch *.log *.map
    178    @cd gd
    179    @nmake /nologo clean
    180    @cd ..
     176   $(RM) *.obj *.lib *.o *.a *.dll *.exe *.pch *.log *.map *.html
     177   cd gd
     178   $(MAKE) /nologo clean
     179   cd ..
    181180
    182181force:
Note: See TracChangeset for help on using the changeset viewer.