Changeset 16414 for trunk/psModules/src/config/pmConfig.c
- Timestamp:
- Feb 12, 2008, 3:42:23 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/config/pmConfig.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/config/pmConfig.c
r16341 r16414 1227 1227 PS_ASSERT_PTR_NON_NULL(argv, NULL); 1228 1228 1229 int Narg; 1229 int Narg; // Argument number 1230 1230 1231 1231 // we load all input files onto a psArray, to be parsed later … … 1264 1264 1265 1265 // load the list from the supplied text file 1266 if (list && strlen(list) > 0 && (Narg = psArgumentGet (*argc, argv, list))) { 1267 int nItems; 1268 char line[1024]; // XXX limits the list lines to 1024 chars 1269 char word[1024]; 1270 char *filename; 1271 1266 if (list && strlen(list) > 0 && (Narg = psArgumentGet(*argc, argv, list))) { 1272 1267 psArgumentRemove (Narg, argc, argv); 1273 1268 FILE *f = fopen (argv[Narg], "r"); 1274 if (f == NULL) { 1275 psAbort("unable to open specified list file"); 1276 } 1277 while (fgets (line, 1024, f) != NULL) { 1278 nItems = sscanf (line, "%s", word); 1269 if (!f) { 1270 psError(PS_ERR_IO, true, "Unable to open specified list file"); 1271 psFree(input); 1272 return NULL; 1273 } 1274 1275 // XXX Reading the list should be reimplemented using psSlurp 1276 1277 char line[1024]; // XXX limits the list lines to 1024 chars 1278 while (fgets(line, 1024, f) != NULL) { 1279 char word[1024]; 1280 int nItems = sscanf(line, "%s", word); 1279 1281 switch (nItems) { 1280 case 0:1282 case 0: 1281 1283 break; 1282 case 1: 1283 filename = psStringCopy (word); 1284 psArrayAdd (input, 16, filename); 1285 psFree (filename); 1286 break; 1287 default: 1284 case 1: { 1285 psString filename = psStringCopy(word); 1286 psArrayAdd(input, 16, filename); 1287 psFree(filename); 1288 fclose(f); 1289 break; 1290 } 1291 default: 1288 1292 // rigid format, no comments allowed? 1289 psAbort("error parsing input list file"); 1290 break; 1291 } 1292 } 1293 psArgumentRemove (Narg, argc, argv); 1293 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to parse file list: spaces detected."); 1294 psFree(input); 1295 fclose(f); 1296 return NULL; 1297 } 1298 } 1299 psArgumentRemove(Narg, argc, argv); 1300 fclose(f); 1294 1301 } 1295 1302
Note:
See TracChangeset
for help on using the changeset viewer.
