Skip to content

Commit 9914441

Browse files
committed
Implement overrides, drop (deprecated) insert-sheet option.
1 parent f4e878e commit 9914441

2 files changed

Lines changed: 60 additions & 36 deletions

File tree

tools/ipp-options.c

Lines changed: 60 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
//
3535

3636
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);
3837
static ippopt_override_t *copy_override(ippopt_override_t *is);
3938
static const char *get_option(const char *name, size_t num_options, cups_option_t *options);
4039
static bool parse_media(const char *value, cups_media_t *media);
@@ -76,7 +75,6 @@ ippOptionsDelete(ipp_options_t *ippo) // I - IPP options
7675
return;
7776

7877
// Free memory
79-
cupsArrayDelete(ippo->insert_sheet);
8078
cupsArrayDelete(ippo->overrides);
8179
free(ippo);
8280
}
@@ -184,6 +182,7 @@ ippOptionsNew(size_t num_options,// I - Number of command-line options
184182
size_t i; // Looping var
185183
size_t num_col; // Number of collection values
186184
cups_option_t *col; // Collection values
185+
const char *nextcol; // Next collection value
187186

188187

189188
// Allocate memory and set defaults...
@@ -243,13 +242,6 @@ ippOptionsNew(size_t num_options,// I - Number of command-line options
243242
if ((value = get_option("imposition-template", num_options, options)) != NULL)
244243
cupsCopyString(ippo->imposition_template, value, sizeof(ippo->imposition_template));
245244

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-
253245
if ((value = get_option("job-error-sheet", num_options, options)) != NULL)
254246
{
255247
// Parse job-error-sheet collection value...
@@ -528,8 +520,66 @@ ippOptionsNew(size_t num_options,// I - Number of command-line options
528520
if ((value = get_option("overrides", num_options, options)) != NULL && *value == '{')
529521
{
530522
// Parse "overrides" collection value(s)...
531-
// TODO: Implement me
523+
ippopt_override_t override; // overrides value
524+
532525
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+
}
533583
}
534584

535585
// Return the final IPP options...
@@ -566,24 +616,6 @@ compare_overrides(ippopt_override_t *a, // I - First override
566616
}
567617

568618

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-
587619
//
588620
// 'copy_override()' - Copy an "overrides" value.
589621
//

tools/ipp-options.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,6 @@ typedef struct ippopt_error_sheet_s // "job-error-sheet" value
3939
cups_media_t media; // "media" or "media-col" value, if any
4040
} ippopt_error_sheet_t;
4141

42-
typedef struct ippopt_insert_sheet_s // "insert-sheet" value
43-
{
44-
int after_page, // Where to insert the sheet (0 for before page 1)
45-
count; // Number of sheets to insert
46-
cups_media_t media; // "media" or "media-col" value, if any
47-
} ippopt_insert_sheet_t;
48-
4942
typedef enum ippopt_handling_e // "multiple-document-handling" values
5043
{
5144
IPPOPT_HANDLING_COLLATED_COPIES, // 'separate-documents-collated-copies'
@@ -104,7 +97,6 @@ typedef struct ipp_options_s // All IPP options in one structure
10497
ipp_orient_t image_orientation; // "image-orientation" value
10598
char imposition_template[128];
10699
// "imposition-template" value, if any
107-
cups_array_t *insert_sheet; // "insert-sheet" value(s)
108100
ippopt_error_sheet_t job_error_sheet; // "job-error-sheet" value
109101
char job_name[256]; // "job-name" value
110102
char job_originating_user_name[256];

0 commit comments

Comments
 (0)