| 607 | */ |
| 608 | |
| 609 | int /* O - Number of options */ |
| 610 | _ppdParseOptions( |
| 611 | const char *s, /* I - String to parse */ |
| 612 | int num_options, /* I - Number of options */ |
| 613 | cups_option_t **options, /* IO - Options */ |
| 614 | _ppd_parse_t which) /* I - What to parse */ |
| 615 | { |
| 616 | char option[PPD_MAX_NAME * 2 + 1], /* Current option/property */ |
| 617 | choice[PPD_MAX_NAME], /* Current choice/value */ |
| 618 | *ptr; /* Pointer into option or choice */ |
| 619 | |
| 620 | |
| 621 | if (!s) |
| 622 | return (num_options); |
| 623 | |
| 624 | /* |
| 625 | * Read all of the "*Option Choice" and "property value" pairs from the |
| 626 | * string, add them to an options array as we go... |
| 627 | */ |
| 628 | |
| 629 | while (*s) |
| 630 | { |
| 631 | /* |
| 632 | * Skip leading whitespace... |
| 633 | */ |
| 634 | |
| 635 | while (_cups_isspace(*s)) |
| 636 | s ++; |
| 637 | |
| 638 | /* |
| 639 | * Get the option/property name... |
| 640 | */ |
| 641 | |
| 642 | ptr = option; |
| 643 | while (*s && !_cups_isspace(*s) && ptr < (option + sizeof(option) - 1)) |
| 644 | *ptr++ = *s++; |
| 645 | |
| 646 | if (ptr == s || !_cups_isspace(*s)) |
| 647 | break; |
| 648 | |
| 649 | *ptr = '\0'; |
| 650 | |
| 651 | /* |
| 652 | * Get the choice... |
| 653 | */ |
| 654 | |
| 655 | while (_cups_isspace(*s)) |
| 656 | s ++; |
| 657 | |
| 658 | if (!*s) |
| 659 | break; |
| 660 | |
| 661 | ptr = choice; |
| 662 | while (*s && !_cups_isspace(*s) && ptr < (choice + sizeof(choice) - 1)) |
| 663 | *ptr++ = *s++; |
| 664 | |
| 665 | if (*s && !_cups_isspace(*s)) |
| 666 | break; |
no test coverage detected