comparison cfgparser.c @ 1075:a981413af7cd

: No such... fix
author szabii
date Sat, 09 Jun 2001 17:30:40 +0000
parents 936b28a365e6
children c433e62cb3de
comparison
equal deleted inserted replaced
1074:e196f109ff8a 1075:a981413af7cd
251 printf("too deep 'include'. check your configfiles\n"); 251 printf("too deep 'include'. check your configfiles\n");
252 --recursion_depth; 252 --recursion_depth;
253 return -1; 253 return -1;
254 } 254 }
255 255
256 if (verbose) printf("Reading config file: %s", conffile); 256 // printf("Reading config file: %s", conffile);
257 257
258 if (init_conf(conf, CONFIG_FILE) == -1) { 258 if (init_conf(conf, CONFIG_FILE) == -1) {
259 ret = -1; 259 ret = -1;
260 goto out; 260 goto out;
261 } 261 }
265 ret = -1; 265 ret = -1;
266 goto out; 266 goto out;
267 } 267 }
268 268
269 if ((fp = fopen(conffile, "r")) == NULL) { 269 if ((fp = fopen(conffile, "r")) == NULL) {
270 if (!verbose) printf("Reading config file: %s", conffile); 270 // printf(": %s\n", strerror(errno));
271 printf(": %s\n", strerror(errno));
272 free(line); 271 free(line);
273 ret = 0; 272 ret = 0;
274 goto out; 273 goto out;
275 } 274 }
276 if (verbose) printf("\n"); 275 // printf("\n");
277 276
278 while (fgets(line, MAX_LINE_LEN, fp)) { 277 while (fgets(line, MAX_LINE_LEN, fp)) {
279 line_num++; 278 line_num++;
280 line_pos = 0; 279 line_pos = 0;
281 280
416 if (init_conf(conf, COMMAND_LINE) == -1) 415 if (init_conf(conf, COMMAND_LINE) == -1)
417 return -1; 416 return -1;
418 417
419 for (i = 1; i < argc; i++) { 418 for (i = 1; i < argc; i++) {
420 opt = argv[i]; 419 opt = argv[i];
421 if (*opt != '-') 420 if (*opt != '-') {
422 goto not_an_option; 421 if (found_filename) {
422 printf("invalid option:\n");
423 goto err_out;
424 }
425 goto filename;
426 }
423 427
424 /* remove trailing '-' */ 428 /* remove trailing '-' */
425 opt++; 429 opt++;
426 430
427 tmp = read_option(opt, argv[i + 1]); 431 tmp = read_option(opt, argv[i + 1]);
428 432
429 switch (tmp) { 433 switch (tmp) {
430 case ERR_NOT_AN_OPTION: 434 case ERR_NOT_AN_OPTION:
431 not_an_option:
432 /* opt is not an option -> treat it as a filename */ 435 /* opt is not an option -> treat it as a filename */
433 if (found_filename) { 436 if (found_filename) {
434 /* we already have a filename */ 437 /* we already have a filename */
435 goto err_out; 438 goto err_out;
436 } else { 439 }
437 found_filename = 1; 440 filename:
438 *filename = argv[i]; 441 found_filename = 1;
439 continue; /* next option */ 442 *filename = argv[i];
440 }
441 break; 443 break;
442 case ERR_MISSING_PARAM: 444 case ERR_MISSING_PARAM:
443 case ERR_OUT_OF_RANGE: 445 case ERR_OUT_OF_RANGE:
444 case ERR_FUNC_ERR: 446 case ERR_FUNC_ERR:
445 goto err_out; 447 goto err_out;
446 /* break; */ 448 /* break; */
447 } 449 default:
448 450 i += tmp;
449 i += tmp; /* we already processed the params (if there was any) */ 451 }
450 } 452 }
451 return found_filename; 453 return found_filename;
452 err_out: 454 err_out:
453 printf("parse_command_line: %s\n", argv[i]); 455 printf("command line: %s\n", argv[i]);
454 return -1; 456 return -1;
455 } 457 }