@@ -3395,16 +3395,14 @@ add_printer_defaults(cupsd_printer_t *p)/* I - Printer */
33953395 */
33963396
33973397static void
3398- add_ppd_defaults_to_ipp (cupsd_printer_t * p , /* I - Printer */
3399- ppd_file_t * ppd ) /* I - PPD file */
3398+ add_ppd_defaults_to_ipp (
3399+ cupsd_printer_t * p , /* I - Printer */
3400+ ppd_file_t * ppd ) /* I - PPD file */
34003401{
34013402 ppd_option_t * option ; /* Current PPD option */
3402- ppd_group_t * group ; /* Current PPD group */
3403- const char * ipp_name ; /* IPP attribute name */
34043403 const char * ipp_value ; /* IPP attribute value */
3405- const char * mapped_value ; /* Mapped IPP attribute value */
3406- char attr_name [256 ]; /* Attribute name buffer */
3407- int i ; /* Looping var */
3404+ char ipp_name [256 ], /* Mapped attribute name buffer */
3405+ * ipp_ptr ; /* Pointer into buffer */
34083406
34093407
34103408 /*
@@ -3418,117 +3416,100 @@ add_ppd_defaults_to_ipp(cupsd_printer_t *p, /* I - Printer */
34183416 * Loop through all PPD options and map their defaults to IPP attributes...
34193417 */
34203418
3421- for (group = ppd -> groups ; group ; group = group -> next )
3419+ for (option = ( ppd_option_t * ) cupsArrayFirst ( ppd -> options ); option ; option = ( ppd_option_t * ) cupsArrayNext ( ppd -> options ) )
34223420 {
3423- for (option = (ppd_option_t * )cupsArrayFirst (group -> options );
3424- option ;
3425- option = (ppd_option_t * )cupsArrayNext (group -> options ))
3421+ /*
3422+ * Skip if no default choice...
3423+ */
3424+
3425+ if (!option -> defchoice [0 ])
3426+ continue ;
3427+
3428+ /*
3429+ * Skip options that are already explicitly handled...
3430+ */
3431+
3432+ if (!strcmp (option -> keyword , "PageSize" ) ||
3433+ !strcmp (option -> keyword , "PageRegion" ) ||
3434+ !strcmp (option -> keyword , "ColorModel" ) ||
3435+ !strcmp (option -> keyword , "HPColorMode" ) ||
3436+ !strcmp (option -> keyword , "BRMonoColor" ) ||
3437+ !strcmp (option -> keyword , "CNIJSGrayScale" ) ||
3438+ !strcmp (option -> keyword , "HPColorAsGray" ) ||
3439+ !strcmp (option -> keyword , "Resolution" ) ||
3440+ !strcmp (option -> keyword , "JCLResolution" ) ||
3441+ !strcmp (option -> keyword , "SetResolution" ) ||
3442+ !strcmp (option -> keyword , "CNRes_PGP" ) ||
3443+ !strcmp (option -> keyword , "Duplex" ) ||
3444+ !strcmp (option -> keyword , "EFDuplex" ) ||
3445+ !strcmp (option -> keyword , "EFDuplexing" ) ||
3446+ !strcmp (option -> keyword , "KD03Duplex" ) ||
3447+ !strcmp (option -> keyword , "JCLDuplex" ) ||
3448+ !strcmp (option -> keyword , "OutputBin" ) ||
3449+ !strcmp (option -> keyword , "InputSlot" ) ||
3450+ !strcmp (option -> keyword , "HPPaperSource" ) ||
3451+ !strcmp (option -> keyword , "MediaType" ) ||
3452+ !strcmp (option -> keyword , "DefaultMediaType" ) ||
3453+ !strcmp (option -> keyword , "DefaultInputSlot" ))
3454+ continue ;
3455+
3456+ /*
3457+ * Map PPD option names to IPP attribute names...
3458+ */
3459+
3460+ if (!strcmp (option -> keyword , "OutputOrder" ))
34263461 {
34273462 /*
3428- * Skip if no default choice ...
3463+ * Map OutputOrder to page-delivery ...
34293464 */
34303465
3431- if (!option -> defchoice || !option -> defchoice [0 ])
3432- continue ;
3466+ if (!_cups_strcasecmp (option -> defchoice , "Normal" ))
3467+ ipp_value = "same-order-face-down" ;
3468+ else
3469+ ipp_value = "reverse-order-face-down" ;
34333470
3471+ ippAddString (p -> attrs , IPP_TAG_PRINTER , IPP_TAG_KEYWORD , "page-delivery-default" , NULL , ipp_value );
3472+ }
3473+ else if (!strcmp (option -> keyword , "Collate" ))
3474+ {
34343475 /*
3435- * Skip options that are already explicitly handled ...
3476+ * Map Collate values to IPP multiple-document-handling values ...
34363477 */
34373478
3438- if (!strcmp (option -> keyword , "PageSize" ) ||
3439- !strcmp (option -> keyword , "PageRegion" ) ||
3440- !strcmp (option -> keyword , "ColorModel" ) ||
3441- !strcmp (option -> keyword , "HPColorMode" ) ||
3442- !strcmp (option -> keyword , "BRMonoColor" ) ||
3443- !strcmp (option -> keyword , "CNIJSGrayScale" ) ||
3444- !strcmp (option -> keyword , "HPColorAsGray" ) ||
3445- !strcmp (option -> keyword , "Resolution" ) ||
3446- !strcmp (option -> keyword , "JCLResolution" ) ||
3447- !strcmp (option -> keyword , "SetResolution" ) ||
3448- !strcmp (option -> keyword , "CNRes_PGP" ) ||
3449- !strcmp (option -> keyword , "Duplex" ) ||
3450- !strcmp (option -> keyword , "EFDuplex" ) ||
3451- !strcmp (option -> keyword , "EFDuplexing" ) ||
3452- !strcmp (option -> keyword , "KD03Duplex" ) ||
3453- !strcmp (option -> keyword , "JCLDuplex" ) ||
3454- !strcmp (option -> keyword , "OutputBin" ) ||
3455- !strcmp (option -> keyword , "InputSlot" ) ||
3456- !strcmp (option -> keyword , "HPPaperSource" ) ||
3457- !strcmp (option -> keyword , "MediaType" ) ||
3458- !strcmp (option -> keyword , "DefaultMediaType" ) ||
3459- !strcmp (option -> keyword , "DefaultInputSlot" ))
3460- continue ;
3479+ if (!_cups_strcasecmp (option -> defchoice , "True" ) || !_cups_strcasecmp (option -> defchoice , "On" ) || !_cups_strcasecmp (option -> defchoice , "Yes" ))
3480+ ipp_value = "separate-documents-collated-copies" ;
3481+ else
3482+ ipp_value = "separate-documents-uncollated-copies" ;
34613483
3484+ ippAddString (p -> attrs , IPP_TAG_PRINTER , IPP_TAG_KEYWORD , "multiple-document-handling-default" , NULL , ipp_value );
3485+ }
3486+ else if (!strcmp (option -> keyword , "cupsPrintQuality" ) && !ippFindAttribute (p -> attrs , "print-quality-default" , IPP_TAG_ZERO ))
3487+ {
34623488 /*
3463- * Map PPD option names to IPP attribute names ...
3489+ * Map quality names to IPP enum values ...
34643490 */
34653491
3466- ipp_name = NULL ;
3467- ipp_value = option -> defchoice ;
3468- mapped_value = ipp_value ;
3469-
3470- if (!strcmp (option -> keyword , "OutputOrder" ))
3471- ipp_name = "output-order" ;
3472- else if (!strcmp (option -> keyword , "Collate" ))
3473- {
3474- ipp_name = "multiple-document-handling" ;
3475- /*
3476- * Map Collate values to IPP multiple-document-handling values...
3477- */
3478- if (!_cups_strcasecmp (ipp_value , "True" ) ||
3479- !_cups_strcasecmp (ipp_value , "On" ) ||
3480- !_cups_strcasecmp (ipp_value , "Yes" ))
3481- {
3482- mapped_value = "separate-documents-collated-copies" ;
3483- }
3484- else
3485- {
3486- mapped_value = "separate-documents-uncollated-copies" ;
3487- }
3488- }
3489- else if (!strcmp (option -> keyword , "cupsPrintQuality" ) ||
3490- !strcmp (option -> keyword , "OutputMode" ))
3491- {
3492- ipp_name = "print-quality" ;
3493- /*
3494- * Map quality names to IPP enum values...
3495- */
3496- if (!_cups_strcasecmp (ipp_value , "draft" ) ||
3497- !_cups_strcasecmp (ipp_value , "fast" ))
3498- {
3499- if (!ippFindAttribute (p -> attrs , "print-quality-default" , IPP_TAG_ZERO ))
3500- ippAddInteger (p -> attrs , IPP_TAG_PRINTER , IPP_TAG_ENUM , "print-quality-default" , IPP_QUALITY_DRAFT );
3501- }
3502- else if (!_cups_strcasecmp (ipp_value , "best" ) ||
3503- !_cups_strcasecmp (ipp_value , "high" ))
3504- {
3505- if (!ippFindAttribute (p -> attrs , "print-quality-default" , IPP_TAG_ZERO ))
3506- ippAddInteger (p -> attrs , IPP_TAG_PRINTER , IPP_TAG_ENUM , "print-quality-default" , IPP_QUALITY_HIGH );
3507- }
3508- else
3509- {
3510- if (!ippFindAttribute (p -> attrs , "print-quality-default" , IPP_TAG_ZERO ))
3511- ippAddInteger (p -> attrs , IPP_TAG_PRINTER , IPP_TAG_ENUM , "print-quality-default" , IPP_QUALITY_NORMAL );
3512- }
3513- continue ;
3514- }
3492+ if (!_cups_strcasecmp (option -> defchoice , "draft" ) || !_cups_strcasecmp (option -> defchoice , "fast" ))
3493+ ippAddInteger (p -> attrs , IPP_TAG_PRINTER , IPP_TAG_ENUM , "print-quality-default" , IPP_QUALITY_DRAFT );
3494+ else if (!_cups_strcasecmp (option -> defchoice , "best" ) || !_cups_strcasecmp (option -> defchoice , "high" ))
3495+ ippAddInteger (p -> attrs , IPP_TAG_PRINTER , IPP_TAG_ENUM , "print-quality-default" , IPP_QUALITY_HIGH );
35153496 else
3516- {
3517- /*
3518- * For other options, convert the option name to lowercase with dashes
3519- * and append "-default"...
3520- */
3521-
3522- snprintf (attr_name , sizeof (attr_name ), "%s-default" , option -> keyword );
3523- for (i = 0 ; attr_name [i ]; i ++ )
3524- {
3525- if (attr_name [i ] >= 'A' && attr_name [i ] <= 'Z' )
3526- attr_name [i ] = (char )(attr_name [i ] | 32 ); /* tolower */
3527- else if (attr_name [i ] == '_' )
3528- attr_name [i ] = '-' ;
3529- }
3497+ ippAddInteger (p -> attrs , IPP_TAG_PRINTER , IPP_TAG_ENUM , "print-quality-default" , IPP_QUALITY_NORMAL );
3498+ }
3499+ else
3500+ {
3501+ /*
3502+ * For other options, convert the option name to lowercase with dashes
3503+ * and append "-default"...
3504+ */
35303505
3531- ipp_name = attr_name ;
3506+ snprintf (ipp_name , sizeof (ipp_name ), "%s-default" , option -> keyword );
3507+ for (ipp_ptr = ipp_name ; * ipp_ptr ; ipp_ptr ++ )
3508+ {
3509+ if (isupper (* ipp_ptr & 255 ))
3510+ * ipp_ptr = tolower (* ipp_ptr & 255 );
3511+ else if (* ipp_ptr == '_' )
3512+ * ipp_ptr = '-' ;
35323513 }
35333514
35343515 /*
@@ -3539,31 +3520,13 @@ add_ppd_defaults_to_ipp(cupsd_printer_t *p, /* I - Printer */
35393520 continue ;
35403521
35413522 /*
3542- * Add the IPP "-default" attribute ...
3523+ * Add the appropriate value ...
35433524 */
35443525
3545- if (ipp_name && mapped_value )
3546- {
3547- /*
3548- * For boolean options, convert to boolean...
3549- */
3550-
3551- if (option -> ui == PPD_UI_BOOLEAN )
3552- {
3553- ippAddBoolean (p -> attrs , IPP_TAG_PRINTER , ipp_name ,
3554- !_cups_strcasecmp (mapped_value , "True" ) ||
3555- !_cups_strcasecmp (mapped_value , "On" ) ||
3556- !_cups_strcasecmp (mapped_value , "Yes" ));
3557- }
3558- else
3559- {
3560- /*
3561- * For other options, add as string/keyword...
3562- */
3563-
3564- ippAddString (p -> attrs , IPP_TAG_PRINTER , IPP_TAG_KEYWORD , ipp_name , NULL , mapped_value );
3565- }
3566- }
3526+ if (option -> ui == PPD_UI_BOOLEAN )
3527+ ippAddBoolean (p -> attrs , IPP_TAG_PRINTER , ipp_name , !_cups_strcasecmp (option -> defchoice , "True" ) || !_cups_strcasecmp (option -> defchoice , "On" ) || !_cups_strcasecmp (option -> defchoice , "Yes" ));
3528+ else
3529+ ippAddString (p -> attrs , IPP_TAG_PRINTER , IPP_TAG_NAME , ipp_name , NULL , option -> defchoice );
35673530 }
35683531 }
35693532}
0 commit comments