********************************** * * parseoptions * ********************************** */
| 486 | ********************************** |
| 487 | */ |
| 488 | boolean |
| 489 | parseoptions( |
| 490 | char *opts, |
| 491 | boolean tinitial, |
| 492 | boolean tfrom_file) |
| 493 | { |
| 494 | char *op; |
| 495 | boolean negated, got_match = FALSE, pfx_match = FALSE; |
| 496 | #if 0 |
| 497 | boolean has_val = FALSE; |
| 498 | #endif |
| 499 | int i, matchidx = -1, optresult = optn_err, optlen, optlen_wo_val; |
| 500 | boolean retval = TRUE; |
| 501 | |
| 502 | duplicate = FALSE; |
| 503 | using_alias = FALSE; |
| 504 | go.opt_initial = tinitial; |
| 505 | go.opt_from_file = tfrom_file; |
| 506 | /* |
| 507 | * Process elements of comma-separated list in right to left order. |
| 508 | * When some options are set interactively--notably various compound |
| 509 | * options that issue a prompt for a value--they use parseoptions() |
| 510 | * to handle setting the new value. For those, 'tinitial' is False |
| 511 | * and if user tries to supply a comma-separated list, it will be |
| 512 | * treated as part of the current option, probably failing to parse. |
| 513 | */ |
| 514 | if (tinitial && (op = strchr(opts, ',')) != 0) { |
| 515 | *op++ = 0; |
| 516 | /* current element remains pending while the rest of the line gets |
| 517 | handled recursively; if the rest of line contains any commas, |
| 518 | then the process will recurse deeper as it is processed */ |
| 519 | if (!parseoptions(op, go.opt_initial, go.opt_from_file)) |
| 520 | retval = FALSE; |
| 521 | } |
| 522 | if (strlen(opts) > BUFSZ / 2) { |
| 523 | config_error_add("Option too long, max length is %i characters", |
| 524 | (BUFSZ / 2)); |
| 525 | return FALSE; |
| 526 | } |
| 527 | |
| 528 | /* strip leading and trailing white space */ |
| 529 | while (isspace((uchar) *opts)) |
| 530 | opts++; |
| 531 | op = eos(opts); |
| 532 | while (--op >= opts && isspace((uchar) *op)) |
| 533 | *op = '\0'; |
| 534 | |
| 535 | if (!*opts) { |
| 536 | config_error_add("Empty statement"); |
| 537 | return FALSE; |
| 538 | } |
| 539 | negated = FALSE; |
| 540 | while ((*opts == '!') || !strncmpi(opts, "no", 2)) { |
| 541 | opts += (*opts == '!') ? 1 : (opts[2] != '-') ? 2 : 3; |
| 542 | negated = !negated; |
| 543 | } |
| 544 | optlen = (int) strlen(opts); |
| 545 | optlen_wo_val = length_without_val(opts, optlen); |
no test coverage detected