| 602 | */ |
| 603 | |
| 604 | char * /* O - String containing option code or @code NULL@ if there is no option code */ |
| 605 | ppdEmitString(ppd_file_t *ppd, /* I - PPD file record */ |
| 606 | ppd_section_t section, /* I - Section to write */ |
| 607 | float min_order) /* I - Lowest OrderDependency */ |
| 608 | { |
| 609 | int i, j, /* Looping vars */ |
| 610 | count; /* Number of choices */ |
| 611 | ppd_choice_t **choices; /* Choices */ |
| 612 | ppd_size_t *size; /* Custom page size */ |
| 613 | ppd_coption_t *coption; /* Custom option */ |
| 614 | ppd_cparam_t *cparam; /* Custom parameter */ |
| 615 | size_t bufsize; /* Size of string buffer needed */ |
| 616 | char *buffer, /* String buffer */ |
| 617 | *bufptr, /* Pointer into buffer */ |
| 618 | *bufend; /* End of buffer */ |
| 619 | struct lconv *loc; /* Locale data */ |
| 620 | |
| 621 | |
| 622 | DEBUG_printf(("ppdEmitString(ppd=%p, section=%d, min_order=%f)", |
| 623 | ppd, section, min_order)); |
| 624 | |
| 625 | /* |
| 626 | * Range check input... |
| 627 | */ |
| 628 | |
| 629 | if (!ppd) |
| 630 | return (NULL); |
| 631 | |
| 632 | /* |
| 633 | * Use PageSize or PageRegion as required... |
| 634 | */ |
| 635 | |
| 636 | ppd_handle_media(ppd); |
| 637 | |
| 638 | /* |
| 639 | * Collect the options we need to emit... |
| 640 | */ |
| 641 | |
| 642 | if ((count = ppdCollect2(ppd, section, min_order, &choices)) == 0) |
| 643 | return (NULL); |
| 644 | |
| 645 | /* |
| 646 | * Count the number of bytes that are required to hold all of the |
| 647 | * option code... |
| 648 | */ |
| 649 | |
| 650 | for (i = 0, bufsize = 1; i < count; i ++) |
| 651 | { |
| 652 | if (section == PPD_ORDER_JCL) |
| 653 | { |
| 654 | if (!_cups_strcasecmp(choices[i]->choice, "Custom") && |
| 655 | (coption = ppdFindCustomOption(ppd, choices[i]->option->keyword)) |
| 656 | != NULL) |
| 657 | { |
| 658 | /* |
| 659 | * Add space to account for custom parameter substitution... |
| 660 | */ |
| 661 | |