Changeset 6663 for trunk/tools/database
- Timestamp:
- Sep 6, 2001, 5:07:32 AM (24 years ago)
- Location:
- trunk/tools/database
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/database/CreateTables.sql
r3916 r6663 1 -- $Id: CreateTables.sql,v 1.1 7 2000-08-02 01:22:34bird Exp $1 -- $Id: CreateTables.sql,v 1.18 2001-09-06 03:07:31 bird Exp $ 2 2 -- 3 3 -- Create all tables. … … 103 103 104 104 -- 105 -- This table holds design notes (per dll). 105 -- This table holds design notes (per module). 106 -- 107 -- seqnbrnote is a unique number used to order the 108 -- sections within a design note. 109 -- level is the nesting level of the section. 110 -- 0 is the top section in the note. 106 111 -- 107 112 CREATE TABLE designnote ( 108 refcode INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,113 refcode INTEGER NOT NULL AUTO_INCREMENT, 109 114 dll TINYINT NOT NULL, 110 115 file INTEGER NOT NULL, 111 seqnbrfile SMALLINT NOT NULL, 116 line INTEGER NOT NULL DEFAULT -1, 117 seqnbrnote SMALLINT NOT NULL, 118 level TINYINT NOT NULL, 112 119 seqnbr INTEGER NOT NULL, 113 line INTEGER NOT NULL DEFAULT -1, 114 title TEXT, 120 name TEXT, 115 121 note TEXT NOT NULL, 116 UNIQUE u1(refcode), 117 INDEX u2(file, seqnbrfile, seqnbr, dll) 122 PRIMARY KEY(refcode, seqnbrnote), 123 UNIQUE u1(refcode, seqnbrnote), 124 UNIQUE u2(refcode, seqnbrnote, level), 125 UNIQUE u3(dll, seqnbr, level, seqnbrnote, refcode), 126 INDEX i1(file, refcode) 118 127 ); 119 128 -
trunk/tools/database/StateUpd.cpp
r6660 r6663 1 /* $Id: StateUpd.cpp,v 1.3 5 2001-09-05 23:14:12bird Exp $1 /* $Id: StateUpd.cpp,v 1.36 2001-09-06 03:07:31 bird Exp $ 2 2 * 3 3 * StateUpd - Scans source files for API functions and imports data on them. … … 65 65 inline char *trim(char *psz); 66 66 inline char *trimR(char *psz); 67 static char *trimHtml(char *psz); 67 68 inline char *skip(const char *psz); 68 69 static void copy(char *psz, char *pszFrom, int iFrom, char *pszTo, int iTo, char **papszLines); … … 827 828 unsigned long ulRc = 0; 828 829 char szBuffer[0x10000]; 829 char * psz ;830 char * pszTitle; 830 831 831 832 /* … … 835 836 * 836 837 */ 837 psz = stristr(papszLines[i], "@design"); 838 if (psz != NULL && (psz[7] == '\0' || psz[7] == ' ')) 839 { 838 pszTitle = stristr(papszLines[i], "@design"); 839 if (pszTitle != NULL && (pszTitle[7] == '\0' || pszTitle[7] == ' ')) 840 { 841 char * psz; 840 842 signed long lSeqNbr; 841 842 psz = findEndOfWord(psz+1)+1; 843 lSeqNbr = atol(psz); 843 signed long lSeqNbrNote; 844 signed long lRefCode; 845 long alSeqNbrs[1024]; 846 long lLevel; 847 848 memset(alSeqNbrs, 0, sizeof(alSeqNbrs)); 849 850 /* 851 * Get title and seqnbr. Then copy the entire stuff to the buffer. 852 */ 853 pszTitle = findEndOfWord(pszTitle+1)+1; 854 lSeqNbr = atol(pszTitle); 844 855 if (lSeqNbr != 0) 845 psz = findEndOfWord(psz);846 psz = trim(psz);847 if (psz != NULL && strstr(psz, "*/") != NULL)856 pszTitle = findEndOfWord(pszTitle); 857 pszTitle = trim(pszTitle); 858 if (pszTitle != NULL && strstr(pszTitle, "*/") != NULL) 848 859 { 849 860 szBuffer[0] = '\0'; 850 *strstr(psz , "*/") = '\0';861 *strstr(pszTitle, "*/") = '\0'; 851 862 } 852 863 else 853 864 copyComment(&szBuffer[0], 0, i+1, papszLines, TRUE, TRUE); 854 855 /* Update database */ 856 if (!dbAddDesignNote(pOptions->lDllRefcode, pOptions->lFileRefcode, psz, &szBuffer[0], lSeqNbr, pOptions->lSeqFile++, i + 1)) 857 { 858 ulRc = 0x00010000; 859 fprintf(phSignal, "%s(%d): Failed to add designnote. %s\n", dbGetLastErrorDesc()); 860 } 865 pszTitle = trim(pszTitle); 866 867 /* 868 * Add design note section by section. 869 */ 870 psz = &szBuffer[0]; 871 lLevel = 0; 872 lSeqNbrNote = 0; 873 do 874 { 875 char * pszEnd; 876 long lNextLevel = -1; 877 878 /* 879 * Parse out title and section/squence number if not lLevel 0. 880 * (psz = "@sub...") 881 */ 882 if (lLevel > 0) 883 { 884 pszTitle = findEndOfWord(psz+1); 885 lSeqNbr = atol(pszTitle); 886 if (lSeqNbr != 0) 887 { 888 pszTitle = findEndOfWord(pszTitle); 889 alSeqNbrs[lLevel] = lSeqNbr; 890 } 891 else 892 lSeqNbr = ++alSeqNbrs[lLevel]; 893 894 pszTitle = trim(pszTitle); 895 if (pszTitle != NULL && (psz = strstr(pszTitle, "\n")) != NULL) 896 *psz++ = '\0'; 897 else 898 psz = ""; 899 } 900 901 902 /* 903 * Find end of this section. 904 * (pszEnd will point at @sub or '\0'.) 905 */ 906 pszEnd = psz; 907 do 908 { 909 while (*pszEnd == '\n' || *pszEnd == ' ' || *pszEnd == '\t' || *pszEnd == '\r') 910 ++pszEnd; 911 if (!strnicmp(pszEnd, "@sub", 4) && !strnicmp(findEndOfWord(pszEnd + 1) - 7, "section", 7)) 912 { 913 lNextLevel = 1; 914 while (!strnicmp(pszEnd + 1 + lNextLevel * 3, "sub", 3)) 915 lNextLevel++; 916 break; 917 } 918 } while ((pszEnd = strchr(pszEnd, '\n')) != NULL); 919 if (!pszEnd) 920 pszEnd = psz + strlen(psz); 921 else 922 pszEnd[-1] = '\0'; 923 924 /* 925 * Strip end and start of section. 926 */ 927 psz = trimHtml(psz); 928 pszTitle = trimHtml(pszTitle); 929 930 /* 931 * Add the note. 932 */ 933 if (!dbAddDesignNote(pOptions->lDllRefcode, pOptions->lFileRefcode, 934 pszTitle, psz, 935 lLevel, lSeqNbr, lSeqNbrNote++, i + 1, lLevel > 0, &lRefCode)) 936 { 937 ulRc += 0x00010000; 938 fprintf(phSignal, "%s(%d): Failed to add designnote. %s\n", pszFilename, i, dbGetLastErrorDesc()); 939 } 940 941 /* 942 * Next. 943 */ 944 psz = pszEnd; 945 if (lLevel < lNextLevel) 946 memset(&alSeqNbrs[lLevel+1], 0, (lNextLevel - lLevel) * sizeof(alSeqNbrs[0])); 947 lLevel = lNextLevel; 948 949 } while (*psz); 950 861 951 862 952 /* Skip to line after comment end. */ … … 2457 2547 } 2458 2548 2549 /** 2550 * Trims string. <BR>, <P>, '@', '\t', '\n' and '\t' is trimmed from both ends of the string. 2551 * @returns Pointer to string. 2552 * @param psz String to trim. 2553 */ 2554 char *trimHtml(char *psz) 2555 { 2556 if (!psz) 2557 return NULL; 2558 2559 char *pszEnd = psz + strlen(psz) - 1; 2560 2561 while (pszEnd > psz) 2562 { 2563 if (*pszEnd == '@' || *pszEnd == ' ' || *pszEnd == '\t' || *pszEnd == '\n' || *pszEnd == '\r') 2564 pszEnd--; 2565 else if (!strnicmp(pszEnd - 3, "<BR>", 4)) 2566 pszEnd -= 4; 2567 else if (!strnicmp(pszEnd - 2, "<P>", 3)) 2568 pszEnd -= 3; 2569 else 2570 break; 2571 } 2572 *++pszEnd = '\0'; 2573 2574 while (psz < pszEnd) 2575 { 2576 if (*psz == '@' || *psz == ' ' || *psz == '\t' || *psz == '\n' || *psz == '\r') 2577 psz++; 2578 else if (!strnicmp(psz, "<BR>", 4)) 2579 psz += 4; 2580 else if (!strnicmp(psz, "<P>", 3)) 2581 psz += 3; 2582 else 2583 break; 2584 } 2585 2586 return psz; 2587 } 2588 2459 2589 2460 2590 /** -
trunk/tools/database/db.cpp
r6651 r6663 1 /* $Id: db.cpp,v 1.2 4 2001-09-05 13:59:03bird Exp $ *1 /* $Id: db.cpp,v 1.25 2001-09-06 03:07:32 bird Exp $ * 2 2 * 3 3 * DB - contains all database routines. … … 1172 1172 * @param pszTitle Design note title. 1173 1173 * @param pszText Design note text. 1174 * @param lLevel Level of the note section. 0 is the design note it self. 1174 1175 * @param lSeqNbr Sequence number (in dll). If 0 the use next available number. 1175 * @param lSeqNbr File Sequence number in file.1176 * @param lSeqNbrNote Sequence number in note. 1176 1177 * @param lLine Line number (1 - based!). 1178 * @param fSubSection TRUE if subsection FALSE if design note. 1179 * if TRUE *plRefCode will hold the reference id of the note. 1180 * if FALSE *plRefCode will receive the reference id of the note being created. 1181 * @param plRefCode Pointer to reference id of the design note. see fSubSection for more info. 1177 1182 */ 1178 1183 BOOL _System dbAddDesignNote(signed long lDll, … … 1180 1185 const char *pszTitle, 1181 1186 const char *pszText, 1187 signed long lLevel, 1182 1188 signed long lSeqNbr, 1183 signed long lSeqNbrFile, 1184 signed long lLine) 1185 { 1189 signed long lSeqNbrNote, 1190 signed long lLine, 1191 BOOL fSubSection, 1192 signed long *plRefCode) 1193 { 1194 int rc; 1186 1195 char szQuery[0x10200]; 1187 1196 MYSQL_RES * pres; … … 1189 1198 1190 1199 assert(lDll >= 0 && lFile >= 0); 1191 assert(lSeqNbr File >= 0);1200 assert(lSeqNbrNote >= 0); 1192 1201 1193 1202 /* 1194 1203 * If no lSqlNbr the make one. 1195 1204 */ 1196 if (lSeqNbr == 0 )1197 { 1198 sprintf(&szQuery[0], "SELECT MAX(seqnbr) + 1 FROM designnote WHERE dll = %ld ", lDll);1205 if (lSeqNbr == 0 && !fSubSection) 1206 { 1207 sprintf(&szQuery[0], "SELECT MAX(seqnbr) + 1 FROM designnote WHERE dll = %ld AND level = 0", lDll); 1199 1208 if (mysql_query(pmysql, &szQuery[0]) >= 0) 1200 1209 { … … 1203 1212 { 1204 1213 MYSQL_ROW parow = mysql_fetch_row(pres); 1205 if (parow != NULL )1214 if (parow != NULL && parow[0]) 1206 1215 lSeqNbr = getvalue(0, parow); 1207 1216 else … … 1217 1226 1218 1227 /* 1219 * Create updatequery.1228 * Create insert query. 1220 1229 */ 1221 sprintf(&szQuery[0], "INSERT INTO designnote(dll, file, seqnbrfile, seqnbr, line, title, note) " 1222 "VALUES (%ld, %ld, %ld, %ld, %ld, ", 1223 lDll, lFile, lSeqNbrFile, lSeqNbr, lLine); 1230 if (!fSubSection) 1231 sprintf(&szQuery[0], "INSERT INTO designnote(dll, file, level, seqnbrnote, seqnbr, line, name, note) " 1232 "VALUES (%ld, %ld, %ld, %ld, %ld, %ld, ", 1233 lDll, lFile, lLevel, lSeqNbrNote, lSeqNbr, lLine); 1234 else 1235 sprintf(&szQuery[0], "INSERT INTO designnote(refcode, dll, file, level, seqnbrnote, seqnbr, line, name, note) " 1236 "VALUES (%ld, %ld, %ld, %ld, %ld, %ld, %ld, ", 1237 *plRefCode, lDll, lFile, lLevel, lSeqNbrNote, lSeqNbr, lLine); 1238 1224 1239 if (pszTitle != NULL && *pszTitle != '\0') 1225 1240 sqlstrcat(&szQuery[0], NULL, pszTitle); … … 1228 1243 sqlstrcat(&szQuery[0], ", ", pszText == NULL ? "" : pszText, ")"); 1229 1244 1230 return mysql_query(pmysql, &szQuery[0]) >= 0; 1245 if (mysql_query(pmysql, &szQuery[0]) >= 0) 1246 { 1247 if (!fSubSection) 1248 *plRefCode = mysql_insert_id(pmysql); 1249 return TRUE; 1250 } 1251 return FALSE; 1231 1252 } 1232 1253 -
trunk/tools/database/db.h
r3917 r6663 1 /* $Id: db.h,v 1.1 3 2000-08-02 02:18:05bird Exp $ */1 /* $Id: db.h,v 1.14 2001-09-06 03:07:32 bird Exp $ */ 2 2 /* 3 3 * DB - contains all database routines … … 140 140 const char *pszTitle, 141 141 const char *pszText, 142 signed long lLevel, 142 143 signed long lSeqNbr, 143 signed long lSeqNbrFile, 144 signed long lLine); 144 signed long lSeqNbrNote, 145 signed long lLine, 146 BOOL fSubSection, 147 signed long *plRefCode); 145 148 unsigned long _System dbCreateHistory(char *pszError); 146 149 unsigned long _System dbCheckIntegrity(char *pszError);
Note:
See TracChangeset
for help on using the changeset viewer.