|
34 | 34 | // |
35 | 35 |
|
36 | 36 | static int compare_overrides(ippopt_override_t *a, ippopt_override_t *b); |
37 | | -static ippopt_insert_sheet_t *copy_insert_sheet(ippopt_insert_sheet_t *is); |
38 | 37 | static ippopt_override_t *copy_override(ippopt_override_t *is); |
39 | 38 | static const char *get_option(const char *name, size_t num_options, cups_option_t *options); |
40 | 39 | static bool parse_media(const char *value, cups_media_t *media); |
@@ -76,7 +75,6 @@ ippOptionsDelete(ipp_options_t *ippo) // I - IPP options |
76 | 75 | return; |
77 | 76 |
|
78 | 77 | // Free memory |
79 | | - cupsArrayDelete(ippo->insert_sheet); |
80 | 78 | cupsArrayDelete(ippo->overrides); |
81 | 79 | free(ippo); |
82 | 80 | } |
@@ -184,6 +182,7 @@ ippOptionsNew(size_t num_options,// I - Number of command-line options |
184 | 182 | size_t i; // Looping var |
185 | 183 | size_t num_col; // Number of collection values |
186 | 184 | cups_option_t *col; // Collection values |
| 185 | + const char *nextcol; // Next collection value |
187 | 186 |
|
188 | 187 |
|
189 | 188 | // Allocate memory and set defaults... |
@@ -243,13 +242,6 @@ ippOptionsNew(size_t num_options,// I - Number of command-line options |
243 | 242 | if ((value = get_option("imposition-template", num_options, options)) != NULL) |
244 | 243 | cupsCopyString(ippo->imposition_template, value, sizeof(ippo->imposition_template)); |
245 | 244 |
|
246 | | - if ((value = get_option("insert-sheets", num_options, options)) != NULL && *value == '{') |
247 | | - { |
248 | | - // Parse "insert-sheets" collection value(s)... |
249 | | - // TODO: Implement me |
250 | | - ippo->insert_sheet = cupsArrayNew(NULL, NULL, NULL, 0, (cups_acopy_cb_t)copy_insert_sheet, (cups_afree_cb_t)free); |
251 | | - } |
252 | | - |
253 | 245 | if ((value = get_option("job-error-sheet", num_options, options)) != NULL) |
254 | 246 | { |
255 | 247 | // Parse job-error-sheet collection value... |
@@ -528,8 +520,66 @@ ippOptionsNew(size_t num_options,// I - Number of command-line options |
528 | 520 | if ((value = get_option("overrides", num_options, options)) != NULL && *value == '{') |
529 | 521 | { |
530 | 522 | // Parse "overrides" collection value(s)... |
531 | | - // TODO: Implement me |
| 523 | + ippopt_override_t override; // overrides value |
| 524 | + |
532 | 525 | ippo->overrides = cupsArrayNew((cups_array_cb_t)compare_overrides, NULL, NULL, 0, (cups_acopy_cb_t)copy_override, (cups_afree_cb_t)free); |
| 526 | + |
| 527 | + for (nextcol = value; nextcol && *nextcol;) |
| 528 | + { |
| 529 | + // Get the next collection value |
| 530 | + if (*nextcol == ',') |
| 531 | + nextcol ++; |
| 532 | + |
| 533 | + num_col = cupsParseOptions(nextcol, &nextcol, 0, &col); |
| 534 | + |
| 535 | + memset(&override, 0, sizeof(override)); |
| 536 | + |
| 537 | + if ((value = cupsGetOption("document-numbers", num_col, col)) != NULL) |
| 538 | + { |
| 539 | + switch (sscanf(value, "%d-%d", &override.first_document, &override.last_document)) |
| 540 | + { |
| 541 | + case 1 : |
| 542 | + override.last_document = override.first_document; |
| 543 | + break; |
| 544 | + |
| 545 | + case 2 : |
| 546 | + break; |
| 547 | + |
| 548 | + default : |
| 549 | + override.first_document = 0; |
| 550 | + override.last_document = 0; |
| 551 | + break; |
| 552 | + } |
| 553 | + } |
| 554 | + |
| 555 | + if ((value = cupsGetOption("page-numbers", num_col, col)) != NULL) |
| 556 | + { |
| 557 | + switch (sscanf(value, "%d-%d", &override.first_page, &override.last_page)) |
| 558 | + { |
| 559 | + case 1 : |
| 560 | + override.last_page = override.first_page; |
| 561 | + break; |
| 562 | + |
| 563 | + case 2 : |
| 564 | + break; |
| 565 | + |
| 566 | + default : |
| 567 | + override.first_page = 0; |
| 568 | + override.last_page = 0; |
| 569 | + break; |
| 570 | + } |
| 571 | + } |
| 572 | + |
| 573 | + if ((value = cupsGetOption("media", num_col, col)) == NULL) |
| 574 | + value = cupsGetOption("media-col", num_col, col); |
| 575 | + if (value) |
| 576 | + parse_media(value, &override.media); |
| 577 | + |
| 578 | + if ((value = cupsGetOption("orientation-requests", num_col, col)) != NULL && (intvalue = atoi(value)) >= IPP_ORIENT_PORTRAIT && intvalue <= IPP_ORIENT_NONE) |
| 579 | + override.orientation_requested = (ipp_orient_t)intvalue; |
| 580 | + |
| 581 | + cupsArrayAdd(ippo->overrides, &override); |
| 582 | + } |
533 | 583 | } |
534 | 584 |
|
535 | 585 | // Return the final IPP options... |
@@ -566,24 +616,6 @@ compare_overrides(ippopt_override_t *a, // I - First override |
566 | 616 | } |
567 | 617 |
|
568 | 618 |
|
569 | | -// |
570 | | -// 'copy_insert_sheet()' - Copy an "insert-sheet" value. |
571 | | -// |
572 | | - |
573 | | -static ippopt_insert_sheet_t * // O - New "insert-sheet" value |
574 | | -copy_insert_sheet( |
575 | | - ippopt_insert_sheet_t *is) // I - "insert-sheet" value |
576 | | -{ |
577 | | - ippopt_insert_sheet_t *nis; // New "insert-sheet" value |
578 | | - |
579 | | - |
580 | | - if ((nis = (ippopt_insert_sheet_t *)malloc(sizeof(ippopt_insert_sheet_t))) != NULL) |
581 | | - memcpy(nis, is, sizeof(ippopt_insert_sheet_t)); |
582 | | - |
583 | | - return (nis); |
584 | | -} |
585 | | - |
586 | | - |
587 | 619 | // |
588 | 620 | // 'copy_override()' - Copy an "overrides" value. |
589 | 621 | // |
|
0 commit comments