Changeset 2818 for trunk/tools/database
- Timestamp:
- Feb 18, 2000, 1:42:08 PM (26 years ago)
- Location:
- trunk/tools/database
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/database/CreateTables.sql
r2789 r2818 1 -- $Id: CreateTables.sql,v 1. 6 2000-02-15 13:31:06bird Exp $1 -- $Id: CreateTables.sql,v 1.7 2000-02-18 12:42:05 bird Exp $ 2 2 -- 3 3 -- Create all tables. … … 37 37 return VARCHAR(64), 38 38 updated TINYINT NOT NULL DEFAULT 0, 39 description TEXT, 40 remark TEXT, 41 returndesc TEXT, 42 sketch TEXT, 43 equiv TEXT, 44 time TEXT, 39 45 UNIQUE i1(refcode, aliasfn), 40 46 UNIQUE i1a(dll, aliasfn, refcode), … … 112 118 name VARCHAR(64) NOT NULL, 113 119 type VARCHAR(64) NOT NULL, 114 description VARCHAR(128),115 INDEX i1(function, name (10)),120 description TEXT, 121 INDEX i1(function, name), 116 122 UNIQUE u1(function, name) 117 123 ); -
trunk/tools/database/StateUpd.cpp
r2791 r2818 1 /* $Id: StateUpd.cpp,v 1.1 8 2000-02-15 13:37:52bird Exp $1 /* $Id: StateUpd.cpp,v 1.19 2000-02-18 12:42:06 bird Exp $ 2 2 * 3 3 * StateUpd - Scans source files for API functions and imports data on them. … … 15 15 #define INCL_DOSPROCESS 16 16 #include <os2.h> 17 #include <malloc.h> 17 18 #include <stdio.h> 18 19 #include <string.h> 19 #include < malloc.h>20 #include <stdlib.h> 20 21 #include <assert.h> 21 22 … … 30 31 static FILE *phLog = NULL; 31 32 static FILE *phSignal = NULL; 33 34 static const char *pszCommonKeywords[] = 35 { 36 "* Author", "* Status", "* Remark", "* Result", 37 "* Variable", "* Parameters", "* Purpose", NULL 38 }; 32 39 33 40 … … 44 51 static unsigned long analyseFnDcl(PFNDESC pFnDesc, char **papszLines, int i, int &iRet, const char *pszFilename, POPTIONS pOptions); 45 52 static unsigned long analyseFnDcl2(PFNDESC pFnDesc, char **papszLines, int i, int &iRet, const char *pszFilename, POPTIONS pOptions); 53 static char *SDSCopyTextUntilNextTag(char *pszTarget, BOOL fHTML, int iStart, int iEnd, char **papszLines, const char *pszStart = NULL); 54 static char *CommonCopyTextUntilNextTag(char *pszTarget, BOOL fHTML, int iStart, int iEnd, char **papszLines, const char *pszStart = NULL); 46 55 static BOOL isFunction(char **papszLines, int i, POPTIONS pOptions); 47 56 static long _System dbNotUpdatedCallBack(const char *pszValue, const char *pszFieldName, void *pvUser); … … 49 58 static char *readFileIntoMemory(const char *pszFilename); 50 59 static char **createLineArray(char *pszFile); 51 static char *findEndOfWord(char *psz); 52 static char *findStartOfWord(char *psz, const char *pszStart); 53 static char *trim(char *psz); 54 static void copy(char *psz, int jFrom, int iFrom, int jTo, int iTo, char **papszLines); 55 static void copy(char *psz, char *pszFrom, int iFrom, char *pszTo, int iTo, char **papszLines); 60 static char *findEndOfWord(const char *psz); 61 static char *findStartOfWord(const char *psz, const char *pszStart); 62 inline char *trim(char *psz); 63 inline char *trimR(char *psz); 64 inline char *skip(const char *psz); 65 static void copy(char *psz, int jFrom, int iFrom, int jTo, int iTo, char **papszLines); 66 static void copy(char *psz, char *pszFrom, int iFrom, char *pszTo, int iTo, char **papszLines); 56 67 static char *stristr(const char *pszStr, const char *pszSubStr); 57 68 static char *skipBackwards(const char *pszStopAt, const char *pszFrom, int &iLine, char **papszLines); 69 static int findStrLine(const char *psz, int iStart, int iEnd, char **papszLines); 58 70 59 71 … … 637 649 fprintf(phLog, " cParams: %2d\n", FnDesc.cParams); 638 650 for (j = 0; j < FnDesc.cParams; j++) 639 fprintf(phLog, " Param %2d: type '%s' %*s name '%s'\n", j, FnDesc.apszParamType[j], 640 (int)(15 - strlen(FnDesc.apszParamType[j])), "", FnDesc.apszParamName[j]); 651 fprintf(phLog, " Param %2d: type '%s' %*s name '%s' description: %s\n", j, FnDesc.apszParamType[j], 652 max((int)(15 - strlen(FnDesc.apszParamType[j])), 0), "", FnDesc.apszParamName[j], 653 FnDesc.apszParamDesc[j] != NULL ? FnDesc.apszParamDesc[j] : "(null)"); 641 654 fprintf(phLog, " Status: %ld - '%s'\n", FnDesc.lStatus, FnDesc.pszStatus != NULL ? FnDesc.pszStatus : "<missing>"); 642 655 fprintf(phLog, " cAuthors: %2d\n", FnDesc.cAuthors); 643 656 for (j = 0; j < FnDesc.cAuthors; j++) 644 657 fprintf(phLog, " Author %d: '%s' (refcode=%ld)\n", j, FnDesc.apszAuthor[j], FnDesc.alAuthorRefCode[j]); 658 659 fprintf(phLog, " Description: %s\n", FnDesc.pszDescription != NULL ? FnDesc.pszDescription : "(null)"); 660 fprintf(phLog, " Remark: %s\n", FnDesc.pszRemark != NULL ? FnDesc.pszRemark : "(null)"); 661 fprintf(phLog, " Return Desc: %s\n", FnDesc.pszReturnDesc != NULL ? FnDesc.pszReturnDesc : "(null)"); 662 fprintf(phLog, " Sketch: %s\n", FnDesc.pszSketch != NULL ? FnDesc.pszSketch : "(null)"); 663 fprintf(phLog, " Equiv: %s\n", FnDesc.pszEquiv != NULL ? FnDesc.pszEquiv : "(null)"); 664 fprintf(phLog, " Time: %s\n", FnDesc.pszTime != NULL ? FnDesc.pszTime : "(null)"); 665 fprintf(phLog, "------------\n"); 645 666 646 667 /* 4.*/ … … 1068 1089 * @param pszFilename Filename used in the signal log. 1069 1090 * @param pOptions Pointer to options. 1070 * @sketch 1. Search backwards (start at i-1) for a comment or code. 1091 * @sketch 0. initiate pFnDesc struct 1092 * 1. Search backwards (start at i-1) for a comment or code. 1071 1093 * 2. If comment: (else fail) 1072 1094 * 2a. find start and end of comment. … … 1088 1110 int fSDS = 0; 1089 1111 char *psz, *pszB; 1090 char *pszAuthor = NULL;1112 char *pszAuthors = NULL; 1091 1113 unsigned long ulRc = 0x00000001; 1092 1114 … … 1096 1118 return 0; 1097 1119 1098 /* 1. + 2a.*/ 1120 /* 1121 * 0. initiate pFnDesc struct 1122 */ 1123 for (j = 0; j < pFnDesc->cParams; j++) 1124 pFnDesc->apszParamDesc[j] = NULL; 1125 pFnDesc->cAuthors = 0; 1126 pFnDesc->pszDescription = pFnDesc->pszRemark = pFnDesc->pszReturnDesc = NULL; 1127 pFnDesc->pszSketch = pFnDesc->pszEquiv = pFnDesc->pszTime = pFnDesc->pszStatus = NULL; 1128 pFnDesc->lStatus = 99; /* unknown */ 1129 1130 /* 1131 * 1. + 2a. 1132 */ 1099 1133 iEnd = i-1; /* find end */ 1100 1134 j = strlen(papszLines[iEnd]); … … 1134 1168 jStart = j; 1135 1169 1136 /* 2b.*/ 1170 /* 1171 * 2b. 1172 */ 1137 1173 if (strncmp(&papszLines[iStart][jStart], "/**", 3) != 0) /* checks that there are more than one star at start of comment */ 1138 1174 return 0; 1139 1175 1140 iName = iStart; /* Odin32 common */ 1141 while (iName <= iEnd && 1142 stristr(papszLines[iName], "* Name") == NULL) 1143 iName++; 1144 iStatus = iStart; 1145 while (iStatus <= iEnd && 1146 stristr(papszLines[iStatus], "* Status") == NULL) 1147 iStatus++; 1148 iAuthor = iStart; 1149 while (iAuthor <= iEnd && 1150 stristr(papszLines[iAuthor], "* Author") == NULL) 1151 iAuthor++; 1152 1153 if (!(iName <= iEnd || iStatus <= iEnd || iAuthor <= iEnd)) /* if not found try SDS */ 1154 { 1155 iStatus = iStart; 1156 while (iStatus <= iEnd && 1157 stristr(papszLines[iStatus], "@status") == NULL) 1158 iStatus++; 1159 iAuthor = iStart; 1160 while (iAuthor <= iEnd && 1161 stristr(papszLines[iAuthor], "@author") == NULL) 1162 iAuthor++; 1176 /* Odin32 common? */ 1177 iName = findStrLine("* Name", iStart, iEnd, papszLines); 1178 iStatus = findStrLine("* Status", iStart, iEnd, papszLines); 1179 iAuthor = findStrLine("* Author", iStart, iEnd, papszLines); 1180 1181 if (!(iName <= iEnd || iStatus <= iEnd || iAuthor <= iEnd)) 1182 { 1183 /* SDS ? */ 1184 iStatus = findStrLine("@status", iStart, iEnd, papszLines); 1185 iAuthor = findStrLine("@author", iStart, iEnd, papszLines); 1186 iName = iEnd + 1; 1187 1163 1188 if (!(iStatus <= iEnd || iAuthor <= iEnd)) 1164 1189 return 0; 1165 fSDS = 1; 1166 } 1167 1168 /* 2c.*/ 1169 if (iName <= iEnd && strstr(papszLines[iName], pFnDesc->pszName) == NULL) 1170 fprintf(phLog, "Warning: a matching function name is not found in the name Field\n"); 1190 fSDS = TRUE; 1191 } 1192 else 1193 { 1194 /* 2c.*/ 1195 if (iName <= iEnd && strstr(papszLines[iName], pFnDesc->pszName) == NULL) 1196 fprintf(phLog, "Warning: a matching function name is not found in the name Field\n"); 1197 } 1171 1198 1172 1199 /* 2d.*/ 1173 1200 pszB = &pFnDesc->szFnHdrBuffer[0]; 1174 1201 if (!fSDS) 1175 { /* Odin32 common */ 1176 if (iStatus <= iEnd) /* Status */ 1177 { 1178 psz = stristr(papszLines[iStatus], "* Status") + sizeof("* Status") - 1; 1179 while (*psz != '\0' && (*psz == ' ' || *psz == ':')) 1180 psz++; 1181 strcpy(pszB, psz); 1182 trim(pszB); 1183 if (*pszB != '\0' && pszB[strlen(pszB)-1] == '*') /* just in case some have an right hand '*' column */ 1184 { 1185 pszB[strlen(pszB)-1] = '\0'; 1186 trim(pszB); 1187 } 1188 pFnDesc->pszStatus = pszB; 1189 pszB += strlen(pszB) + 1; 1190 } 1191 1192 if (iAuthor <= iEnd) /* Author(s) */ 1193 { 1194 pszAuthor = pszB; 1195 psz = stristr(papszLines[iAuthor], "* Author") + sizeof("* Author") - 1; 1196 do 1197 { 1198 while (*psz != '\0' && (*psz == ' ' || *psz == ':')) 1199 psz++; 1200 strcpy(pszB, psz); 1201 trim(pszB); 1202 if (*pszB != '\0' && pszB[strlen(pszB)-1] == '*') /* just in case some have an right hand '*' column */ 1202 { 1203 /* 1204 * Odin32 common styled header 1205 */ 1206 1207 /* Author(s) */ 1208 pszAuthors = CommonCopyTextUntilNextTag(pszB, FALSE, iAuthor, iEnd, papszLines); 1209 pszB += strlen(pszB) + 1; 1210 1211 /* Status */ 1212 pFnDesc->pszStatus = CommonCopyTextUntilNextTag(pszB, FALSE, iStatus, iEnd, papszLines); 1213 pszB += strlen(pszB) + 1; 1214 1215 /* Remark */ 1216 i = findStrLine("* Remark", iStart, iEnd, papszLines); 1217 pFnDesc->pszRemark = CommonCopyTextUntilNextTag(pszB, TRUE, i, iEnd, papszLines); 1218 pszB += strlen(pszB) + 1; 1219 1220 /* Description */ 1221 i = findStrLine("* Purpose", iStart, iEnd, papszLines); 1222 pFnDesc->pszDescription = CommonCopyTextUntilNextTag(pszB, TRUE, i, iEnd, papszLines); 1223 pszB += strlen(pszB) + 1; 1224 1225 /* Return(result) description */ 1226 i = findStrLine("* Result", iStart, iEnd, papszLines); 1227 pFnDesc->pszReturnDesc = CommonCopyTextUntilNextTag(pszB, TRUE, i, iEnd, papszLines); 1228 pszB += strlen(pszB) + 1; 1229 1230 /* FIXME parameters */ 1231 1232 } 1233 else 1234 { 1235 /* 1236 * SDS styled header 1237 */ 1238 1239 /* author */ 1240 pszAuthors = SDSCopyTextUntilNextTag(pszB, FALSE, iAuthor, iEnd, papszLines); 1241 pszB += strlen(pszB) + 1; 1242 1243 /* status */ 1244 pFnDesc->pszReturnDesc = SDSCopyTextUntilNextTag(pszB, FALSE, iStatus, iEnd, papszLines); 1245 pszB += strlen(pszB) + 1; 1246 1247 /* remark */ 1248 i = findStrLine("@remark", iStart, iEnd, papszLines); 1249 pFnDesc->pszRemark = SDSCopyTextUntilNextTag(pszB, TRUE, i, iEnd, papszLines); 1250 pszB += strlen(pszB) + 1; 1251 1252 /* description */ 1253 i = findStrLine("@desc", iStart, iEnd, papszLines); 1254 pFnDesc->pszDescription = SDSCopyTextUntilNextTag(pszB, TRUE, i > iEnd ? iStart : i, iEnd, papszLines); 1255 pszB += strlen(pszB) + 1; 1256 1257 /* sketch */ 1258 i = findStrLine("@sketch", iStart, iEnd, papszLines); 1259 pFnDesc->pszSketch = SDSCopyTextUntilNextTag(pszB, TRUE, i, iEnd, papszLines); 1260 pszB += strlen(pszB) + 1; 1261 1262 /* return description */ 1263 i = findStrLine("@return", iStart, iEnd, papszLines); 1264 pFnDesc->pszReturnDesc = SDSCopyTextUntilNextTag(pszB, TRUE, i, iEnd, papszLines); 1265 pszB += strlen(pszB) + 1; 1266 1267 /* time */ 1268 i = findStrLine("@time", iStart, iEnd, papszLines); 1269 pFnDesc->pszReturnDesc = SDSCopyTextUntilNextTag(pszB, TRUE, i, iEnd, papszLines); 1270 pszB += strlen(pszB) + 1; 1271 1272 /* equiv */ 1273 i = findStrLine("@equiv", iStart, iEnd, papszLines); 1274 pFnDesc->pszReturnDesc = SDSCopyTextUntilNextTag(pszB, TRUE, i, iEnd, papszLines); 1275 pszB += strlen(pszB) + 1; 1276 1277 /* Set parameter descriptions to NULL */ 1278 for (i = 0; i < pFnDesc->cParams; i++) 1279 pFnDesc->apszParamDesc[i] = NULL; 1280 1281 /* 1282 * parameters, new @param for each parameter! 1283 */ 1284 do 1285 { 1286 char *pszParam; 1287 1288 /* find first */ 1289 i = findStrLine("@param", iStart, iEnd, papszLines); 1290 if (i >= iEnd) 1291 break; 1292 1293 /* Get parameter name - first word */ 1294 pszParam = SDSCopyTextUntilNextTag(pszB, TRUE, i, iEnd, papszLines); 1295 if (pszParam != NULL) 1296 { 1297 /* first word in psz is the parameter name! */ 1298 psz = findEndOfWord(pszParam); 1299 *psz++ = '\0'; 1300 1301 /* find parameter */ 1302 for (j = 0; j < pFnDesc->cParams; j++) 1303 if (strcmp(pFnDesc->apszParamName[j], pszParam) != 0) 1304 break; 1305 if (j < pFnDesc->cParams) 1203 1306 { 1204 pszB[strlen(pszB)-1] = '\0'; 1205 trim(pszB); 1307 /* find end of parameter name */ 1308 psz = findEndOfWord(strstr(papszLines[i], pszParam)); 1309 /* copy from end of parameter name */ 1310 pFnDesc->apszParamDesc[j] = SDSCopyTextUntilNextTag(pszB, TRUE, i, iEnd, papszLines, psz); 1311 pszB += strlen(pszB) + 1; 1206 1312 } 1207 if (*pszB != '\0' && pszB[strlen(pszB)-1] != ',') 1208 strcat(pszB, ","); 1209 pszB += strlen(pszB); 1210 1211 /* next */ 1212 psz = papszLines[++iAuthor] + 1; 1213 j = 0; 1214 while (*psz == ' ' && j++ < 5) psz++; 1215 if (*psz == '*') 1216 psz++; 1217 } while (iAuthor < iEnd && *psz == ' '); 1218 pszB++; 1219 } 1220 } 1221 else 1222 { /* SDS */ 1223 if (iStatus <= iEnd) 1224 { 1225 psz = stristr(papszLines[iStatus], "@status") + sizeof("@status"); 1226 while (*psz == ' ') 1227 psz++; 1228 strcpy(pszB, psz); 1229 trim(pszB); 1230 pszB += strlen(pszB) + 1; 1231 } 1232 1233 if (iAuthor <= iEnd) 1234 { 1235 pszAuthor = pszB; 1236 psz = stristr(papszLines[iAuthor], "@author") + sizeof("@author"); 1237 do 1238 { 1239 while (*psz == ' ') 1240 psz++; 1241 strcpy(pszB, psz); 1242 trim(pszB); 1243 if (*pszB != '\0' && pszB[strlen(pszB)-1] != ',') 1244 strcat(pszB, ","); 1245 pszB += strlen(pszB) + 1; 1246 1247 /* next */ 1248 psz = papszLines[++iAuthor] + 1; 1249 j = 0; 1250 while (*psz == ' ' && j++ < 5) psz++; 1251 if (*psz == '*') 1252 psz++; 1253 } while (iAuthor <= iEnd && (*psz == ' ' || *psz == '@')); 1254 pszB++; 1255 } 1256 } 1257 1258 /* Status - refcodes are hardcoded here! */ 1313 else 1314 { /* signal that parameter name wasn't found! */ 1315 fprintf(phSignal, "%s, %s: '%s' is not a valid parameter.\n", 1316 pszFilename, pFnDesc->pszName, pszParam); 1317 ulRc += 0x00010000; 1318 } 1319 } 1320 } while (i > iEnd); 1321 } 1322 1323 /* 1324 * Status - refcodes are hardcoded here! 1325 */ 1259 1326 if (pFnDesc->pszStatus != NULL && *pFnDesc->pszStatus != '\0') 1260 1327 { … … 1289 1356 } 1290 1357 1291 /* Author */ 1292 if (pszAuthor) 1358 /* 1359 * Author 1360 */ 1361 if (pszAuthors != NULL) 1293 1362 { /* author1, author2, author3 */ 1294 1363 j = 0; 1295 psz = trim(pszAuthor );1364 psz = trim(pszAuthors); 1296 1365 pFnDesc->cAuthors = 0; 1297 1366 while (*psz != '\0' && pFnDesc->cAuthors < (int)(sizeof(pFnDesc->apszAuthor) / sizeof(pFnDesc->apszAuthor[0]))) … … 1299 1368 char *pszBr1 = strchr(psz, '['); 1300 1369 char *pszBr2 = strchr(psz, ']'); 1301 char *pszComma; 1370 char *pszEmail = NULL; 1371 char *pszNext; 1302 1372 1303 1373 /* remove '[text]' text - this is usualy used for time/date */ … … 1307 1377 1308 1378 /* terminate string */ 1309 pszComma = strchr(psz, ','); 1310 if (pszComma != NULL) 1311 { 1312 pszAuthor = pszComma + 1; 1313 *pszComma = '\0'; 1379 pszNext = strchr(psz, ','); 1380 if (pszNext == NULL) 1381 pszNext = strchr(psz, '\n'); 1382 if (pszNext != NULL) 1383 *pszNext = '\0'; 1384 1385 /* check for (email) test */ 1386 pszBr1 = strchr(psz, '('); 1387 pszBr2 = strchr(psz, ')'); 1388 if (pszBr1 != NULL || pszBr2 != NULL) 1389 { 1390 if (pszBr1 != NULL) 1391 *pszBr1++ = '\0'; 1392 if (pszBr2 != NULL) 1393 *pszBr2++ = '\0'; 1394 1395 if (pszBr1 != NULL && pszBr1 < pszBr2) 1396 pszEmail = trim(pszBr1 + 1); 1314 1397 } 1315 1398 1316 1399 pFnDesc->apszAuthor[pFnDesc->cAuthors] = trim(psz); 1317 1400 pFnDesc->alAuthorRefCode[pFnDesc->cAuthors] = 1318 dbFindAuthor(pFnDesc->apszAuthor[pFnDesc->cAuthors] );1401 dbFindAuthor(pFnDesc->apszAuthor[pFnDesc->cAuthors], pszEmail); 1319 1402 1320 1403 if (pFnDesc->alAuthorRefCode[pFnDesc->cAuthors] == -1) … … 1327 1410 /* next */ 1328 1411 pFnDesc->cAuthors++; 1329 psz = trim(pszAuthor);1412 psz = pszNext ? skip(pszNext + 1) : ""; 1330 1413 } 1331 1414 } … … 1333 1416 return ulRc; 1334 1417 } 1418 1419 1420 1421 /** 1422 * Copies a piece of tag/keyword text into an buffer. SDS. 1423 * @returns Pointer to buffer. If iStart > iEnd NULL is returned. 1424 * @param pszTarget Pointer to buffer. 1425 * @param fHTML Add HTML tags like <br> or not 1426 * @param iStart Index of start line. 1427 * @param iEnd Index of last line. 1428 * @param apszLines Array lines. 1429 * @param pszStart Pointer to char to start at (into papszLines[iStart] of course!) 1430 * @status completely impelmented. 1431 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 1432 * @remark Addes some HTML tags. 1433 */ 1434 static char *SDSCopyTextUntilNextTag(char *pszTarget, BOOL fHTML, int iStart, int iEnd, char **papszLines, const char *pszStart) 1435 { 1436 char *pszRet = pszTarget; 1437 1438 if (iStart <= iEnd) 1439 { 1440 int iStartColumn; 1441 const char *psz = pszStart != NULL ? pszStart : papszLines[iStart]; 1442 1443 /* 1444 * skip dummy chars. 1445 */ 1446 while (iStart <= iEnd && (*psz == ' ' || *psz == '/' || *psz == '*' || *psz == '\0' )) 1447 { 1448 if (*psz == '\0') 1449 psz = papszLines[++iStart]; 1450 else 1451 psz++; 1452 } 1453 1454 /* Anything left of the area to copy? */ 1455 if (iStart <= iEnd) 1456 { 1457 /* 1458 * if we stand at a tag, skip over the tag 1459 */ 1460 if (*psz == '@') 1461 psz = skip(findEndOfWord(psz+1)); 1462 1463 /* 1464 * save start columen 1465 */ 1466 iStartColumn = psz - papszLines[iStart]; 1467 1468 /* 1469 * Copy loop. 1470 */ 1471 do 1472 { 1473 int i; 1474 for (i = psz - papszLines[iStart]; i < iStartColumn; i++) 1475 *pszTarget++ = ' '; /* FIXME HTML and indenting... */ 1476 1477 strcpy(pszTarget, psz); 1478 trimR(pszTarget); 1479 pszTarget += strlen(pszTarget); 1480 if (fHTML) 1481 strcpy(pszTarget, "<BR>\n"); 1482 else 1483 strcpy(pszTarget, "\n"); 1484 pszTarget += strlen(pszTarget); 1485 1486 /* Next */ 1487 psz = skip(papszLines[++iStart]); 1488 if (iStart <= iEnd) 1489 { 1490 while (psz != NULL && *psz == '*') 1491 ++psz; 1492 psz = skip(psz); 1493 /* end test comment */ 1494 if (psz > papszLines[iStart] && psz[-1] == '*' && *psz == '/') 1495 break; 1496 } 1497 } while (iStart <= iEnd && *psz != '@'); 1498 1499 /* 1500 * remove empty lines at end. 1501 */ 1502 if (fHTML) 1503 { 1504 pszTarget--; 1505 while (pszTarget >= pszRet && (*pszTarget == '\n' || *pszTarget == ' ')) 1506 { 1507 if (*pszTarget == '\n') 1508 pszTarget -= 4; 1509 *pszTarget-- = '\0'; 1510 } 1511 } 1512 else 1513 { 1514 pszTarget--; 1515 while (pszTarget >= pszRet && (*pszTarget == '\n' || *pszTarget == ' ')) 1516 *pszTarget-- = '\0'; 1517 } 1518 } 1519 else 1520 pszTarget = '\0'; 1521 } 1522 else 1523 pszRet = NULL; 1524 1525 return pszRet != NULL && *pszRet == '\0' ? NULL : pszRet; 1526 } 1527 1528 1529 1530 /** 1531 * Copies a piece of tag/keyword text into an buffer. SDS. 1532 * @returns Pointer to buffer. If iStart > iEnd NULL is returned. 1533 * @param pszTarget Pointer to buffer. 1534 * @param fHTML Add HTML tags like <br> or not 1535 * @param iStart Index of start line. 1536 * @param iEnd Index of last line. 1537 * @param apszLines Array lines. 1538 * @param pszStart Pointer to char to start at (into papszLines[iStart] of course!) 1539 * @status completely impelmented. 1540 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 1541 * @remark Addes some HTML tags. 1542 */ 1543 static char *CommonCopyTextUntilNextTag(char *pszTarget, BOOL fHTML, int iStart, int iEnd, char **papszLines, const char *pszStart) 1544 { 1545 char *pszRet = pszTarget; 1546 1547 if (iStart <= iEnd) 1548 { 1549 /* known keywords */ 1550 int iStartColumn; 1551 int i; 1552 const char *psz = pszStart != NULL ? pszStart : papszLines[iStart]; 1553 1554 /* 1555 * Skip evt. keyword 1556 */ 1557 psz = skip(psz); 1558 for (i = 0; pszCommonKeywords[i] != NULL; i++) 1559 if (strnicmp(pszCommonKeywords[i], psz, strlen(pszCommonKeywords[i])) == 0) 1560 { 1561 psz = skip(psz + strlen(pszCommonKeywords[i])); 1562 psz = skip(*psz == ':' ? psz + 1 : psz); 1563 break; 1564 } 1565 1566 /* 1567 * save start columen 1568 */ 1569 iStartColumn = psz - papszLines[iStart]; 1570 1571 /* 1572 * copy loop 1573 */ 1574 do 1575 { 1576 /* 1577 * Skip '*'s at start of the line. 1578 */ 1579 while (*psz == '*') 1580 psz++; 1581 1582 /* end comment check */ 1583 if (psz > papszLines[iStart] && psz[-1] == '*' && *psz == '/') 1584 break; 1585 psz = skip(psz); 1586 1587 /* 1588 * Indent up to iStartColumn 1589 */ 1590 for (i = psz - papszLines[iStart]; i < iStartColumn; i++) 1591 *pszTarget++ = ' '; /* FIXME HTML and indenting... */ 1592 1593 /* 1594 * Copy the rest of the line and add HTML break. 1595 */ 1596 strcpy(pszTarget, psz); 1597 trimR(pszTarget); 1598 pszTarget += strlen(pszTarget); 1599 if (fHTML) 1600 strcpy(pszTarget, "<BR>\n"); 1601 else 1602 strcpy(pszTarget, "\n"); 1603 pszTarget += strlen(pszTarget); 1604 1605 /* 1606 * Next 1607 */ 1608 psz = skip(papszLines[++iStart]); 1609 1610 /* 1611 * Check for keyword 1612 */ 1613 if (iStart <= iEnd) 1614 { 1615 psz = skip(psz); 1616 for (i = 0; pszCommonKeywords[i] != NULL; i++) 1617 if (strnicmp(pszCommonKeywords[i], psz, strlen(pszCommonKeywords[i])) == 0) 1618 break; 1619 if (pszCommonKeywords[i] != NULL) 1620 break; 1621 } 1622 } while (iStart < iEnd); 1623 1624 /* 1625 * remove empty lines at end. 1626 */ 1627 if (fHTML) 1628 { 1629 pszTarget--; 1630 while (pszTarget >= pszRet && (*pszTarget == '\n' || *pszTarget == ' ')) 1631 { 1632 if (*pszTarget == '\n') 1633 pszTarget -= 4; 1634 *pszTarget-- = '\0'; 1635 } 1636 } 1637 else 1638 { 1639 pszTarget--; 1640 while (pszTarget >= pszRet && (*pszTarget == '\n' || *pszTarget == ' ')) 1641 *pszTarget-- = '\0'; 1642 } 1643 } 1644 else 1645 pszRet = NULL; 1646 1647 return pszRet != NULL && *pszRet == '\0' ? NULL : pszRet; 1648 } 1649 1335 1650 1336 1651 … … 1699 2014 1700 2015 /** first char after word */ 1701 static char *findEndOfWord(c har *psz)2016 static char *findEndOfWord(const char *psz) 1702 2017 { 1703 2018 … … 1712 2027 ) 1713 2028 ++psz; 1714 return psz;2029 return (char *)psz; 1715 2030 } 1716 2031 1717 2032 1718 2033 /** starting char of word */ 1719 static char *findStartOfWord(c har *psz, const char *pszStart)1720 { 1721 c har *pszR = psz;2034 static char *findStartOfWord(const char *psz, const char *pszStart) 2035 { 2036 const char *pszR = psz; 1722 2037 while (psz >= pszStart && 1723 2038 ( … … 1729 2044 ) 1730 2045 pszR = psz--; 1731 return pszR;2046 return (char*)pszR; 1732 2047 } 1733 2048 … … 1740 2055 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 1741 2056 */ 1742 staticchar *trim(char *psz)2057 inline char *trim(char *psz) 1743 2058 { 1744 2059 int i; … … 1752 2067 psz[i+1] = '\0'; 1753 2068 return psz; 2069 } 2070 2071 2072 /** 2073 * Right trims a string, ie. removing spaces (and tabs) from the end of the string. 2074 * @returns Pointer to the string passed in. 2075 * @param psz Pointer to the string which is to be right trimmed. 2076 * @status completely implmented. 2077 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 2078 */ 2079 inline char *trimR(char *psz) 2080 { 2081 int i; 2082 if (psz == NULL) 2083 return NULL; 2084 i = strlen(psz) - 1; 2085 while (i >= 0 && (psz[i] == ' ' || *psz == '\t')) 2086 i--; 2087 psz[i+1] = '\0'; 2088 return psz; 2089 } 2090 2091 2092 /** 2093 * skips blanks until first non-blank. 2094 * @returns Pointer to first not space or tab char in the string. 2095 * @param psz Pointer to the string. 2096 * @status completely implmented. 2097 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 2098 */ 2099 inline char *skip(const char *psz) 2100 { 2101 if (psz == NULL) 2102 return NULL; 2103 2104 while (*psz == ' ' || *psz == '\t') 2105 psz++; 2106 return (char*)psz; 1754 2107 } 1755 2108 … … 1992 2345 } 1993 2346 2347 2348 /** 2349 * Finds a string in a range of pages. 2350 * @returns Index of the line (into ppaszLines). 2351 * @param psz String to search for. 2352 * @param iStart Start line. 2353 * @param iEnd Line to stop at 2354 * @param papszLines Array of lines to search within. 2355 * @status completely implemented. 2356 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 2357 */ 2358 static int findStrLine(const char *psz, int iStart, int iEnd, char **papszLines) 2359 { 2360 while (iStart <= iEnd && 2361 stristr(papszLines[iStart], psz) == NULL) 2362 iStart++; 2363 return iStart; 2364 } 2365 2366 2367 2368 -
trunk/tools/database/db.cpp
r2776 r2818 1 /* $Id: db.cpp,v 1.1 0 2000-02-14 17:18:31bird Exp $ *1 /* $Id: db.cpp,v 1.11 2000-02-18 12:42:06 bird Exp $ * 2 2 * 3 3 * DB - contains all database routines. … … 80 80 static unsigned long CheckAuthorError(char * &pszError, const char *pszFieldName, const char *pszFieldValue, const char *pszQuery); 81 81 static unsigned long logDbError(char * &pszError, const char *pszQuery); 82 static char *sqlstrcat(char *pszQuery, const char *pszBefore, const char *pszStr, const char *pszAfter = NULL); 83 82 84 #ifndef DLL 83 85 extern "C" void dbHandler(int sig); … … 297 299 int rc; 298 300 long lFunction = -1; 299 char szQuery[ 256];301 char szQuery[512]; 300 302 MYSQL_RES *pres; 301 303 … … 596 598 * This doesn't have to be the name. Initials, alias and email 597 599 * is also searched. 598 */ 599 signed long _System dbFindAuthor(const char *pszAuthor) 600 * @param pszEmail Email address. Might be NULL! 601 */ 602 signed long _System dbFindAuthor(const char *pszAuthor, const char *pszEmail) 600 603 { 601 604 signed long refcode = -1; 602 605 MYSQL_RES *pres; 603 char szQuery[256]; 604 606 char szQuery[512]; 607 608 /* 609 * parameter validations 610 */ 611 if (pszAuthor == NULL || strlen(pszAuthor) > 64) 612 return -1; 613 if (pszEmail != NULL && strlen(pszEmail) > 64) 614 { 615 fprintf(stderr, "email too long!"); 616 return -1; 617 } 618 619 /* 620 * Query 621 */ 605 622 sprintf(&szQuery[0], 606 623 "SELECT refcode FROM author " … … 610 627 " email = '%s'", 611 628 pszAuthor, pszAuthor, pszAuthor, pszAuthor); 629 630 if (pszEmail != NULL) 631 sprintf(&szQuery[strlen(&szQuery[0])], " OR email = '%s'", pszEmail); 632 612 633 if (mysql_query(pmysql, &szQuery[0]) >= 0) 613 634 { … … 702 723 MYSQL_RES * pres; 703 724 MYSQL_ROW row; 704 char szQuery[512];705 char * pszQuery = &szQuery[0];725 char * pszQuery2 = (char*)malloc(65500); 726 char * pszQuery = pszQuery2; 706 727 long lCurrentState; 707 728 int i,k,rc; 708 729 unsigned long ulRc = 0; 709 730 731 /* check if malloc have failed allocating memory for us. */ 732 if (pszQuery2 == NULL) 733 { 734 strcpy(pszError, "internal dbUpdateFunction error - malloc failed!\n"); 735 return 1; 736 } 737 738 739 /* 740 * Loop thru all functions in the array of refocodes. 741 */ 710 742 for (k = 0; k < pFnDesc->cRefCodes; k++) 711 743 { … … 717 749 sprintf(pszQuery, "UPDATE function SET updated = updated + 1 WHERE refcode = %ld", 718 750 pFnDesc->alRefCode[k]); 719 rc = mysql_queryu1(pmysql, &szQuery[0]);751 rc = mysql_queryu1(pmysql, pszQuery2); 720 752 721 753 … … 724 756 */ 725 757 lCurrentState = dbGetFunctionState(pFnDesc->alRefCode[k]); 726 if (lCurrentState == -1 )758 if (lCurrentState == -1 && dbGetLastErrorDesc() != NULL && strlen(dbGetLastErrorDesc()) != 0) 727 759 { 728 760 strcpy(pszError, dbGetLastErrorDesc()); 761 free(pszQuery2); 729 762 return 1; 730 763 } … … 736 769 strcpy(pszQuery, "UPDATE function SET "); 737 770 pszQuery += strlen(pszQuery); 738 if (pFnDesc->lStatus != 99 || lCurrentState == 0) 739 { 740 sprintf(pszQuery, "state = %ld ", pFnDesc->lStatus); 771 772 /* Status */ 773 if (lCurrentState != pFnDesc->lStatus 774 && pFnDesc->lStatus != 0 775 && (lCurrentState == 0 || pFnDesc->lStatus != 99)) 776 { 777 sprintf(pszQuery, "state = %ld", pFnDesc->lStatus); 741 778 f = TRUE; 742 779 } 743 780 pszQuery += strlen(pszQuery); 744 781 782 /* return type */ 745 783 if (pFnDesc->pszReturnType != NULL) 746 784 { 747 785 if (f) strcat(pszQuery, ", "); 748 sprintf(pszQuery + strlen(pszQuery), "return = '%s' ", pFnDesc->pszReturnType); 749 pszQuery += strlen(pszQuery); 786 pszQuery = sqlstrcat(pszQuery, "return = ", pFnDesc->pszReturnType); 750 787 f = TRUE; 751 788 } 752 789 790 /* Description */ 791 if (pFnDesc->pszDescription != NULL) 792 { 793 if (f) strcat(pszQuery, ", "); 794 pszQuery = sqlstrcat(pszQuery, "description = ", pFnDesc->pszDescription); 795 f = TRUE; 796 } 797 798 /* Remark */ 799 if (pFnDesc->pszRemark != NULL) 800 { 801 if (f) strcat(pszQuery, ", "); 802 pszQuery = sqlstrcat(pszQuery, "remark = ", pFnDesc->pszRemark); 803 f = TRUE; 804 } 805 806 /* Description */ 807 if (pFnDesc->pszReturnDesc != NULL) 808 { 809 if (f) strcat(pszQuery, ", "); 810 pszQuery = sqlstrcat(pszQuery, "returndesc = ", pFnDesc->pszReturnDesc); 811 f = TRUE; 812 } 813 814 /* Sketch */ 815 if (pFnDesc->pszSketch != NULL) 816 { 817 if (f) strcat(pszQuery, ", "); 818 pszQuery = sqlstrcat(pszQuery, "sketch = ", pFnDesc->pszSketch); 819 f = TRUE; 820 } 821 822 /* Equiv */ 823 if (pFnDesc->pszEquiv != NULL) 824 { 825 if (f) strcat(pszQuery, ", "); 826 pszQuery = sqlstrcat(pszQuery, "equiv = ", pFnDesc->pszEquiv); 827 f = TRUE; 828 } 829 830 /* Equiv */ 831 if (pFnDesc->pszTime != NULL) 832 { 833 if (f) strcat(pszQuery, ", "); 834 pszQuery = sqlstrcat(pszQuery, "time = ", pFnDesc->pszTime); 835 f = TRUE; 836 } 837 838 /* Execute update query? */ 753 839 if (f) 754 840 { 755 sprintf(pszQuery + strlen(pszQuery), " WHERE refcode = %ld", pFnDesc->alRefCode[k]);756 rc = mysql_queryu2(pmysql, &szQuery[0]);841 sprintf(pszQuery + strlen(pszQuery), " WHERE refcode = %ld", pFnDesc->alRefCode[k]); 842 rc = mysql_queryu2(pmysql, pszQuery2); 757 843 if (rc < 0) 758 844 { 759 845 sprintf(pszError, "Updating functiontable failed with error: %s - (sql=%s) ", 760 dbGetLastErrorDesc(), &szQuery[0]);846 dbGetLastErrorDesc(), pszQuery2); 761 847 pszError += strlen(pszError) - 1; 762 848 ulRc++; … … 765 851 766 852 853 767 854 /* 768 855 * Parameters 769 856 */ 770 pszQuery = &szQuery[0];857 pszQuery = pszQuery2; 771 858 sprintf(pszQuery, "SELECT count(*) FROM parameter WHERE function = %ld", pFnDesc->alRefCode[k]); 772 859 rc = mysql_queryu3(pmysql, pszQuery); … … 782 869 for (i = 0; i < pFnDesc->cParams; i++) 783 870 { 784 sprintf(pszQuery, "UPDATE parameter SET type = '%s', name = '%s' " 785 "WHERE function = (%ld) AND sequencenbr = (%ld)", 871 sprintf(pszQuery, "UPDATE parameter SET type = '%s', name = '%s'", 786 872 pFnDesc->apszParamType[i] != NULL ? pFnDesc->apszParamType[i] : "", 787 pFnDesc->apszParamName[i] != NULL ? pFnDesc->apszParamName[i] : "", 788 pFnDesc->alRefCode[k], i 789 ); 873 pFnDesc->apszParamName[i] != NULL ? pFnDesc->apszParamName[i] : ""); 874 if (pFnDesc->apszParamDesc[i] != NULL) 875 sqlstrcat(pszQuery, ", description = ", pFnDesc->apszParamDesc[i]); 876 sprintf(pszQuery + strlen(pszQuery), " WHERE function = (%ld) AND sequencenbr = (%ld)", 877 pFnDesc->alRefCode[k], i); 790 878 rc = mysql_queryu4(pmysql, pszQuery); 791 879 if (rc < 0) … … 820 908 for (i = 0; i < pFnDesc->cParams; i++) 821 909 { 822 sprintf(pszQuery, "INSERT INTO parameter(function, sequencenbr, type, name ) "823 "VALUES (%ld, %d, '%s', '%s' )",910 sprintf(pszQuery, "INSERT INTO parameter(function, sequencenbr, type, name, description) " 911 "VALUES (%ld, %d, '%s', '%s'", 824 912 pFnDesc->alRefCode[k], i, 825 913 pFnDesc->apszParamType[i] != NULL ? pFnDesc->apszParamType[i] : "", 826 914 pFnDesc->apszParamName[i] != NULL ? pFnDesc->apszParamName[i] : "" 827 915 ); 828 rc = mysql_queryu6(pmysql, pszQuery); 916 if (pFnDesc->apszParamDesc[i] != NULL) 917 sqlstrcat(pszQuery, ", ", pFnDesc->apszParamDesc[i]); 918 else 919 strcat(pszQuery, ", NULL)"); 920 921 rc = mysql_queryu6(pmysql, pszQuery2); 829 922 if (rc < 0) 830 923 { … … 896 989 897 990 lDll = lDll; 991 free(pszQuery2); 898 992 return ulRc; 899 993 } … … 1548 1642 mysql_free_result(pres); 1549 1643 return (signed long)rc; 1644 } 1645 1646 1647 /** 1648 * 1649 * @returns Pointer to end of the string. 1650 * @param pszQuery Outputbuffer 1651 * @param pszBefore Text before string, might be NULL. 1652 * @param pszStr String (NOT NULL) 1653 * @param pszAfter Text after, might be NULL. 1654 * @status completely implemented 1655 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 1656 */ 1657 static char *sqlstrcat(char *pszQuery, const char *pszBefore, const char *pszStr, const char *pszAfter) 1658 { 1659 register char ch; 1660 1661 pszQuery += strlen(pszQuery); 1662 1663 /* 1664 * String before 1665 */ 1666 if (pszBefore != NULL) 1667 { 1668 strcpy(pszQuery, pszBefore); 1669 pszQuery += strlen(pszQuery); 1670 } 1671 1672 /* 1673 * THE String 1674 */ 1675 *pszQuery++ = '\''; 1676 while ((ch = *pszStr++) != '\0') 1677 { 1678 if (ch == '\'') 1679 *pszQuery++ = '\\'; 1680 *pszQuery++ = ch; 1681 } 1682 *pszQuery++ = '\''; 1683 1684 /* 1685 * String after 1686 */ 1687 if (pszAfter != NULL) 1688 { 1689 strcpy(pszQuery, pszAfter); 1690 pszQuery += strlen(pszQuery); 1691 } 1692 else 1693 *pszQuery = '\0'; 1694 1695 1696 return pszQuery; 1550 1697 } 1551 1698 -
trunk/tools/database/db.h
r2770 r2818 1 /* $Id: db.h,v 1. 6 2000-02-12 23:54:29bird Exp $ */1 /* $Id: db.h,v 1.7 2000-02-18 12:42:07 bird Exp $ */ 2 2 /* 3 3 * DB - contains all database routines … … 32 32 /* buffers */ 33 33 char szFnDclBuffer[2048]; 34 char szFnHdrBuffer[ 2048];34 char szFnHdrBuffer[10240]; 35 35 36 36 /* function name and type */ … … 45 45 char *apszParamType[30]; 46 46 char *apszParamName[30]; 47 char *apszParamDesc[30]; 47 48 48 49 /* authors */ … … 50 51 char *apszAuthor[NBR_AUTHORS]; 51 52 long alAuthorRefCode[NBR_AUTHORS]; 53 54 /* other description fields */ 55 char *pszDescription; 56 char *pszRemark; 57 char *pszReturnDesc; 58 char *pszSketch; 59 char *pszEquiv; 60 char *pszTime; 52 61 53 62 /* status */ … … 93 102 PFNFINDBUF pFnFindBuf, 94 103 signed long lDll); 95 signed long _System dbFindAuthor(const char *pszAuthor );104 signed long _System dbFindAuthor(const char *pszAuthor, const char *pszEmail); 96 105 signed long _System dbGetFunctionState(signed long lRefCode); 97 106 unsigned long _System dbUpdateFunction(PFNDESC pFnDesc, -
trunk/tools/database/kHtmlPC.cpp
r2765 r2818 1 /* $Id: kHtmlPC.cpp,v 1. 2 2000-02-12 17:55:03bird Exp $ */1 /* $Id: kHtmlPC.cpp,v 1.3 2000-02-18 12:42:07 bird Exp $ */ 2 2 /* 3 3 * kHtmlPC - Special-purpose HTML/SQL preprocessor. … … 112 112 static void openLog(void); 113 113 static void closeLog(void); 114 static unsigned long processFile(const char *pszFilename /*, const POPTIONS pOptions*/);114 static unsigned long processFile(const char *pszFilenamem, const POPTIONS pOptions); 115 115 static unsigned long tagEndkSql(TAG_PARAMETER_LIST); 116 116 static unsigned long tagkSql(TAG_PARAMETER_LIST); 117 static unsigned long tagkTemplate(TAG_PARAMETER_LIST, FILE * &phFile );117 static unsigned long tagkTemplate(TAG_PARAMETER_LIST, FILE * &phFile, const POPTIONS pOptions); 118 118 static unsigned long tagkInclude(TAG_PARAMETER_LIST); 119 static unsigned long tagkGraph(TAG_PARAMETER_LIST );119 static unsigned long tagkGraph(TAG_PARAMETER_LIST, const POPTIONS pOptions); 120 120 static unsigned long tagkDefine(TAG_PARAMETER_LIST); 121 121 static unsigned long tagkUndef(TAG_PARAMETER_LIST); … … 155 155 char *pszUser = "root"; 156 156 char *pszPasswd = ""; 157 char szPathName[CCHMAXPATH]; 158 OPTIONS options = {"."}; 159 157 160 158 161 /* signal handler */ … … 167 170 * parse arguments. 168 171 * options: -h or -? help 172 * -b:<basepath> Basepath for output files. 169 173 * -d:<dbname> Database name 170 174 * -p:<passwd> Password … … 181 185 switch (argv[argi][1]) 182 186 { 187 case 'b': 188 case 'B': 189 printf("%s\n", argv[argi]); 190 if (argv[argi][2] == ':') 191 { 192 if (_fullpath(&szPathName[0], &argv[argi][3], sizeof(szPathName)) != NULL) 193 options.pszBaseDir = &szPathName[0]; 194 else 195 { 196 fprintf(stderr, "error: basepath '%s' don't exists\n", &argv[argi][3]); 197 fFatal = TRUE; 198 } 199 } 200 else 201 { 202 fprintf(stderr, "error: option '-b:' requires a directory name.\n"); 203 fFatal = TRUE; 204 } 205 break; 206 183 207 case 'd': 184 208 case 'D': … … 186 210 pszDatabase = &argv[argi][3]; 187 211 else 188 fprintf(stderr, "warning: option '-d:' requires database name.\n"); 212 { 213 fprintf(stderr, "error: option '-d:' requires database name.\n"); 214 fFatal = TRUE; 215 } 189 216 break; 190 217 … … 205 232 pszPasswd = &argv[argi][3]; 206 233 else 207 fprintf(stderr, "warning: option '-p:' requires password.\n"); 234 { 235 fprintf(stderr, "error: option '-p:' requires password.\n"); 236 fFatal = TRUE; 237 } 208 238 break; 209 239 … … 213 243 pszUser = &argv[argi][3]; 214 244 else 245 { 215 246 fprintf(stderr, "error: option '-u:' requires userid.\n"); 247 fFatal = TRUE; 248 } 216 249 break; 217 250 … … 233 266 if (dbConnect(pszHost, pszUser, pszPasswd, pszDatabase)) 234 267 { 235 ulRc += processFile(argv[argi] /*, &options*/);268 ulRc += processFile(argv[argi], &options); 236 269 dbDisconnect(); 237 270 } … … 330 363 * @remark Big function! 331 364 */ 332 static unsigned long processFile(const char *pszFilename /*, const POPTIONS pOptions*/)365 static unsigned long processFile(const char *pszFilename, const POPTIONS pOptions) 333 366 { 334 367 unsigned long ulRc = 0; … … 454 487 ulRc2 = tagEndkSql(TAG_PARAMETERS); 455 488 else if (tag.isTag("!kTemplate")) /* !kTemplate */ 456 ulRc2 = tagkTemplate(TAG_PARAMETERS, phFile );489 ulRc2 = tagkTemplate(TAG_PARAMETERS, phFile, pOptions); 457 490 else if (tag.isTag("!kInclude")) /* !kInclude */ 458 491 ulRc2 = tagkInclude(TAG_PARAMETERS); 459 492 else if (tag.isTag("!kGraph")) /* !kGraph */ 460 ulRc2 = tagkGraph(TAG_PARAMETERS );493 ulRc2 = tagkGraph(TAG_PARAMETERS, pOptions); 461 494 else if (tag.isTag("!kDefine")) /* !kDefine */ 462 495 ulRc2 = tagkDefine(TAG_PARAMETERS); … … 714 747 * @returns low word: number of errors 715 748 * high word: number of warnings 716 * @param phFile Reference to current output file. 749 * @param phFile Reference to current output file. 750 * @param pOptions Pointer to the options struct. 717 751 * @remark See TAG_PARAMETER_LIST for parameters. 718 752 * Use TAG_PARAMETERS when calling this function. 719 753 */ 720 static unsigned long tagkTemplate(TAG_PARAMETER_LIST, FILE * &phFile )754 static unsigned long tagkTemplate(TAG_PARAMETER_LIST, FILE * &phFile, const POPTIONS pOptions) 721 755 { 722 756 unsigned long ulRc = 0; … … 734 768 if (pszFilename != NULL) 735 769 { 770 char szFullFileName[CCHMAXPATH]; 736 771 if (phFile != NULL) 737 772 fclose(phFile); 738 739 phFile = fopen(pszFilename, "wb"); 740 if (phFile != NULL) 741 fprintf(phLog, "%s(%ld) : info: new output file, '%s'.\n", 742 pCurFile->getFilename(), pCurFile->getLineNumber()+1, pszFilename); 773 if (strlen(pszFilename) + strlen(pOptions->pszBaseDir) + 1 + 1 < sizeof(szFullFileName)) 774 { 775 sprintf(&szFullFileName[0], "%s\\%s", pOptions->pszBaseDir, pszFilename); 776 phFile = fopen(&szFullFileName[0], "wb"); 777 if (phFile != NULL) 778 fprintf(phLog, "%s(%ld) : info: new output file, '%s'.\n", 779 pCurFile->getFilename(), pCurFile->getLineNumber()+1, &szFullFileName[0]); 780 else 781 { 782 fprintf(phLog, "%s(%ld) : error: kTemplate - error opening output file '%s'.\n", 783 pCurFile->getFilename(), pCurFile->getLineNumber()+1, &szFullFileName[0]); 784 ulRc += 0x00000001; 785 } 786 } 743 787 else 744 788 { 745 fprintf(phLog, "%s(%ld) : error: kTemplate - error opening output file '%s'.\n",746 pCurFile->getFilename(), pCurFile->getLineNumber()+1, p szFilename);789 fprintf(phLog, "%s(%ld) : error: kTemplate - filename and base dir is too long! '%s\\%s'.\n", 790 pCurFile->getFilename(), pCurFile->getLineNumber()+1, pOptions->pszBaseDir, pszFilename); 747 791 ulRc += 0x00000001; 748 792 } … … 799 843 * Use TAG_PARAMETERS when calling this function. 800 844 */ 801 static unsigned long tagkGraph(TAG_PARAMETER_LIST )845 static unsigned long tagkGraph(TAG_PARAMETER_LIST, const POPTIONS pOptions) 802 846 { 803 847 unsigned long ulRc = 0; … … 814 858 try 815 859 { 816 kGraph graph(tag );860 kGraph graph(tag, pOptions->pszBaseDir); 817 861 graph.showWarnings(phLog, pCurFile); 818 862 graph.save(); … … 2242 2286 /** 2243 2287 * Analyses the tag and executes SQL statements. 2244 * @param tag Tag. 2288 * @param tag Tag. 2289 * @param pszBaseDir Base output directory. 2245 2290 * @remark Throws kError::enmErrors 2246 2291 */ 2247 void kGraph::analyseTag(const kTag &tag ) throw(kError::enmErrors)2292 void kGraph::analyseTag(const kTag &tag, const char *pszBaseDir) throw(kError::enmErrors) 2248 2293 { 2249 2294 int cArgs, i; … … 2297 2342 { 2298 2343 if (pszValue == NULL || strlen(pszValue) == 0) throw(kError::error_filename_param_is_missing_value); 2299 pszFilename = dupeString(pszValue); 2344 pszFilename = new char[strlen(pszValue) + 2 + strlen(pszBaseDir)]; 2345 if (pszFilename == NULL) throw(kError::error_filename_param_is_missing_value); 2346 sprintf(pszFilename, "%s\\%s", pszBaseDir, pszValue); 2300 2347 } 2301 2348 else if (stricmp(pszName, "title") == 0) … … 3125 3172 * @remark Throws kError::enmError on error. 3126 3173 */ 3127 kGraph::kGraph(const kTag &tag ) throw(kError::enmErrors)3174 kGraph::kGraph(const kTag &tag, const char *pszBaseDir) throw(kError::enmErrors) 3128 3175 : pGraph(NULL), enmTypeCd(unknown), enmSubTypeCd(normal), 3129 3176 pszFilename(NULL), pszTitle(NULL), pszTitleX(NULL), … … 3137 3184 try 3138 3185 { 3139 analyseTag(tag );3186 analyseTag(tag, pszBaseDir); 3140 3187 createBaseGraph(); 3141 3188 if (fLegend) … … 3163 3210 /** 3164 3211 * Saves the graph to the filename specified in the tag. 3212 * 2 3165 3213 * @returns Errorcode. 3166 3214 */ -
trunk/tools/database/kHtmlPC.h
r830 r2818 1 /* $Id: kHtmlPC.h,v 1. 1 1999-09-05 02:53:06bird Exp $ */1 /* $Id: kHtmlPC.h,v 1.2 2000-02-18 12:42:08 bird Exp $ */ 2 2 /* 3 3 * kHtmlPC - Special-purpose HTML/SQL preprocessor. … … 17 17 typedef struct _options 18 18 { 19 BOOL fDummy;19 char *pszBaseDir; 20 20 } OPTIONS, *POPTIONS; 21 21 … … 428 428 429 429 /**@cat internal function */ 430 void analyseTag(const kTag &tag ) throw(kError::enmErrors);430 void analyseTag(const kTag &tag, const char *pszBaseDir) throw(kError::enmErrors); 431 431 void fetchData(const char *pszSql) throw(kError::enmErrors); 432 432 kGraphDataSet *findOrCreateDataSet(const char *pszLegend) throw(kError::enmErrors); … … 450 450 451 451 public: 452 kGraph(const kTag &tag ) throw(kError::enmErrors);452 kGraph(const kTag &tag, const char *pszBaseDir) throw(kError::enmErrors); 453 453 ~kGraph(void); 454 454 -
trunk/tools/database/sample.kSqlHtml
r2765 r2818 1 <!-- $Id: sample.kSqlHtml,v 1. 2 2000-02-12 17:55:04bird Exp $1 <!-- $Id: sample.kSqlHtml,v 1.3 2000-02-18 12:42:08 bird Exp $ 2 2 -- 3 3 -- kSqlHTML Template Sample. … … 186 186 <BODY> 187 187 <H1>Details on APIs in $(dllname)</H1> 188 <P> 189 <IMAGE SRC="odin32Dll$(dllname).gif"> 190 </P> 188 191 <TABLE BORDER=1 BORDERCOLOR="#000000" CELLPADDING=4 CELLSPACING=0> 189 192 <THEAD> 190 <TR VALIGN=TOP> <TH>Ordinal</TH> <TH>API name</TH> <TH> State</TH> </TR>193 <TR VALIGN=TOP> <TH>Ordinal</TH> <TH>API name</TH> <TH>Author(s)</TH> <TH>State</TH> </TR> 191 194 </THEAD> 192 195 <TBODY> 193 196 <!kSql sql="SELECT ordinal, 194 197 function.name AS functionname, 195 state.name AS statename 198 state.name AS statename, 199 function.refcode AS fnrefcode 196 200 FROM function, state 197 201 WHERE state.refcode = state 198 AND dll = $(dllrefcode)" 202 AND dll = $(dllrefcode) 203 ORDER BY function.name" 199 204 ><TR> 200 205 <TD><P ALIGN=RIGHT>$(ordinal)<P></TD> 201 206 <TD><P ALIGN=LEFT>$(functionname)<P></TD> 207 <TD><!kSql sql="SELECT name AS authorname 208 FROM fnauthor fna, author a 209 WHERE function = $(fnrefcode) AND fna.author = a.refcode" 210 ><P ALIGN=RIGHT>$(authorname)<P><!/kSql> 211 </TD> 202 212 <TD><P ALIGN=LEFT>$(statename)<P></TD> 203 213 </TR><!/kSql>
Note:
See TracChangeset
for help on using the changeset viewer.