Changeset 3899 for trunk/tools/database
- Timestamp:
- Jul 29, 2000, 4:12:47 PM (25 years ago)
- Location:
- trunk/tools/database
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/database/StateUpd.cpp
r3882 r3899 1 /* $Id: StateUpd.cpp,v 1.2 6 2000-07-21 21:09:43bird Exp $1 /* $Id: StateUpd.cpp,v 1.27 2000-07-29 14:12:46 bird Exp $ 2 2 * 3 3 * StateUpd - Scans source files for API functions and imports data on them. … … 894 894 memset(&FnDesc, 0, sizeof(FnDesc)); 895 895 896 /* default value */896 /* default value and file number. */ 897 897 FnDesc.lStatus = 99; 898 FnDesc.lFile = pOptions->lFileRefcode; 898 899 899 900 /* precondition: isFunction is true. -
trunk/tools/database/db.cpp
r3882 r3899 1 /* $Id: db.cpp,v 1.1 6 2000-07-21 21:09:44bird Exp $ *1 /* $Id: db.cpp,v 1.17 2000-07-29 14:12:47 bird Exp $ * 2 2 * 3 3 * DB - contains all database routines. … … 905 905 for (k = 0; k < pFnDesc->cRefCodes; k++) 906 906 { 907 BOOL f = FALSE;908 909 /*910 * Set updated flag911 */912 sprintf(pszQuery, "UPDATE function SET updated = updated + 1 WHERE refcode = %ld",913 pFnDesc->alRefCode[k]);914 rc = mysql_queryu1(pmysql, pszQuery2);915 916 917 907 /* 918 908 * Get current status … … 922 912 { 923 913 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); 924 920 free(pszQuery2); 925 921 return 1; … … 930 926 * Update function table first 931 927 */ 932 strcpy(pszQuery, "UPDATE function SET ");928 strcpy(pszQuery, "UPDATE function SET updated = updated + 1"); 933 929 pszQuery += strlen(pszQuery); 934 930 … … 936 932 if (lCurrentState != pFnDesc->lStatus 937 933 && 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"); 944 943 945 944 /* return type */ 946 945 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"); 952 949 953 950 /* Description */ 954 951 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"); 960 955 961 956 /* Remark */ 962 957 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"); 968 961 969 962 /* Description */ 970 963 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"); 976 967 977 968 /* Sketch */ 978 969 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"); 984 973 985 974 /* Equiv */ 986 975 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"); 992 979 993 980 /* Time */ 994 981 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"); 1000 985 1001 986 /* 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 } 1015 996 1016 997 … … 1044 1025 if (*pszError == ' ') 1045 1026 strcpy(pszError++, "\n\t"); 1046 sprintf(pszError, "Updat eing parameter %i failed with error: %s - (sql=%s) ",1027 sprintf(pszError, "Updating parameter %i failed with error: %s - (sql=%s) ", 1047 1028 i, dbGetLastErrorDesc(), pszQuery); 1048 1029 pszError += strlen(pszError) - 1; … … 2020 2001 * @param lDll The refcode of the dll owning the functions. 2021 2002 * @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 2023 2005 * Delete the referenced to the functions in: 2024 2006 * parameters 2025 2007 * fnauthor 2026 * Delete all function which has updated = 0 and dll = lDll2027 * 2008 * Delete all function which wasn't updated. 2009 * EndIf 2028 2010 * @remark Use with GREATE CARE! 2029 2011 */ … … 2042 2024 rc = mysql_query(pmysql, &szQuery[0]); 2043 2025 pres = mysql_store_result(pmysql); 2026 2044 2027 if (pres != NULL && mysql_num_rows(pres)) 2045 2028 { … … 2057 2040 if (rc) fRc = FALSE; 2058 2041 } 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 } 2068 2060 2069 2061 return fRc; -
trunk/tools/database/db.h
r3882 r3899 1 /* $Id: db.h,v 1.1 1 2000-07-21 21:09:45bird Exp $ */1 /* $Id: db.h,v 1.12 2000-07-29 14:12:47 bird Exp $ */ 2 2 /* 3 3 * DB - contains all database routines … … 44 44 { 45 45 /* buffers */ 46 char szFnDclBuffer[2048];47 char szFnHdrBuffer[10240];46 char szFnDclBuffer[2048]; 47 char szFnHdrBuffer[10240]; 48 48 49 49 /* function name and type */ 50 char * pszName;51 char * pszReturnType;52 long cRefCodes;53 long alRefCode[NBR_FUNCTIONS];54 signed long 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. */ 55 55 56 56 /* 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]; 61 61 62 62 /* 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]; 66 66 67 67 /* 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; 74 74 75 75 /* 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. */ 78 82 } FNDESC, *PFNDESC; 79 83 … … 81 85 typedef struct _FunctionFindBuffer 82 86 { 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. */ 88 92 } FNFINDBUF, *PFNFINDBUF; 89 93
Note:
See TracChangeset
for help on using the changeset viewer.