]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/encode.c
Update ipp documentation to reflect the behavior of configuring WiFi on IPP USB printers.
[thirdparty/cups.git] / cups / encode.c
index 62dd8d7b3f27c3e1374b95d45829ee24b669b416..5bcbf6fe5a749011f759a4b05de18011571fd891 100644 (file)
@@ -1,18 +1,11 @@
 /*
- * "$Id$"
- *
  * Option encoding routines for CUPS.
  *
- * Copyright 2007-2015 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
- *
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file.  If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * Copyright © 2007-2019 by Apple Inc.
+ * Copyright © 1997-2007 by Easy Software Products.
  *
- * This file is subject to the Apple OS-Developed Software exception.
+ * Licensed under Apache License v2.0.  See the file "LICENSE" for more
+ * information.
  */
 
 /*
@@ -20,6 +13,7 @@
  */
 
 #include "cups-private.h"
+#include "debug-internal.h"
 
 
 /*
@@ -117,6 +111,9 @@ static const _ipp_option_t ipp_options[] =
   { 0, "copies",               IPP_TAG_INTEGER,        IPP_TAG_JOB,
                                                        IPP_TAG_DOCUMENT },
   { 0, "copies-default",       IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
+  { 0, "date-time-at-completed",IPP_TAG_DATE,          IPP_TAG_ZERO }, /* never send as option */
+  { 0, "date-time-at-creation",        IPP_TAG_DATE,           IPP_TAG_ZERO }, /* never send as option */
+  { 0, "date-time-at-processing",IPP_TAG_DATE,         IPP_TAG_ZERO }, /* never send as option */
   { 0, "device-uri",           IPP_TAG_URI,            IPP_TAG_PRINTER },
   { 1, "document-copies",      IPP_TAG_RANGE,          IPP_TAG_JOB,
                                                        IPP_TAG_DOCUMENT,
@@ -133,6 +130,9 @@ static const _ipp_option_t ipp_options[] =
                                                        cups_schemes },
   { 1, "finishings",           IPP_TAG_ENUM,           IPP_TAG_JOB,
                                                        IPP_TAG_DOCUMENT },
+  { 1, "finishings-col",       IPP_TAG_BEGIN_COLLECTION, IPP_TAG_JOB,
+                                                       IPP_TAG_DOCUMENT },
+  { 1, "finishings-col-default", IPP_TAG_BEGIN_COLLECTION, IPP_TAG_PRINTER },
   { 1, "finishings-default",   IPP_TAG_ENUM,           IPP_TAG_PRINTER },
   { 0, "fit-to-page",          IPP_TAG_BOOLEAN,        IPP_TAG_JOB,
                                                        IPP_TAG_DOCUMENT },
@@ -146,6 +146,7 @@ static const _ipp_option_t ipp_options[] =
   { 1, "include-schemes",      IPP_TAG_NAME,           IPP_TAG_OPERATION,
                                                        IPP_TAG_ZERO,
                                                        cups_schemes },
+  { 0, "ipp-attribute-fidelity", IPP_TAG_BOOLEAN,      IPP_TAG_OPERATION },
   { 0, "job-account-id",        IPP_TAG_NAME,           IPP_TAG_JOB },
   { 0, "job-account-id-default",IPP_TAG_NAME,           IPP_TAG_PRINTER },
   { 0, "job-accounting-user-id", IPP_TAG_NAME,          IPP_TAG_JOB },
@@ -154,15 +155,20 @@ static const _ipp_option_t ipp_options[] =
   { 0, "job-cancel-after",     IPP_TAG_INTEGER,        IPP_TAG_JOB },
   { 0, "job-cancel-after-default", IPP_TAG_INTEGER,    IPP_TAG_PRINTER },
   { 0, "job-hold-until",       IPP_TAG_KEYWORD,        IPP_TAG_JOB },
+  { 0, "job-hold-until-default", IPP_TAG_KEYWORD,      IPP_TAG_PRINTER },
   { 0, "job-id",               IPP_TAG_INTEGER,        IPP_TAG_ZERO }, /* never send as option */
-  { 0, "job-impressions",      IPP_TAG_INTEGER,        IPP_TAG_ZERO }, /* never send as option */
+  { 0, "job-impressions",      IPP_TAG_INTEGER,        IPP_TAG_OPERATION },
   { 0, "job-impressions-completed", IPP_TAG_INTEGER,   IPP_TAG_ZERO }, /* never send as option */
   { 0, "job-k-limit",          IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
-  { 0, "job-k-octets",         IPP_TAG_INTEGER,        IPP_TAG_ZERO }, /* never send as option */
+  { 0, "job-k-octets",         IPP_TAG_INTEGER,        IPP_TAG_OPERATION },
   { 0, "job-k-octets-completed",IPP_TAG_INTEGER,       IPP_TAG_ZERO }, /* never send as option */
-  { 0, "job-media-sheets",     IPP_TAG_INTEGER,        IPP_TAG_ZERO }, /* never send as option */
+  { 0, "job-media-sheets",     IPP_TAG_INTEGER,        IPP_TAG_OPERATION },
   { 0, "job-media-sheets-completed", IPP_TAG_INTEGER,  IPP_TAG_ZERO }, /* never send as option */
+  { 0, "job-name",             IPP_TAG_NAME,           IPP_TAG_OPERATION,
+                                                       IPP_TAG_JOB },
   { 0, "job-page-limit",       IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
+  { 0, "job-pages",            IPP_TAG_INTEGER,        IPP_TAG_OPERATION },
+  { 0, "job-pages-completed",  IPP_TAG_INTEGER,        IPP_TAG_ZERO }, /* never send as option */
   { 0, "job-password",          IPP_TAG_STRING,         IPP_TAG_OPERATION,
                                                        IPP_TAG_ZERO,
                                                        ipp_job_creation },
@@ -170,6 +176,7 @@ static const _ipp_option_t ipp_options[] =
                                                        IPP_TAG_ZERO,
                                                        ipp_job_creation },
   { 0, "job-priority",         IPP_TAG_INTEGER,        IPP_TAG_JOB },
+  { 0, "job-priority-default", IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
   { 0, "job-quota-period",     IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
   { 1, "job-sheets",           IPP_TAG_NAME,           IPP_TAG_JOB },
   { 1, "job-sheets-default",   IPP_TAG_NAME,           IPP_TAG_PRINTER },
@@ -188,6 +195,8 @@ static const _ipp_option_t ipp_options[] =
   { 1, "marker-types",         IPP_TAG_KEYWORD,        IPP_TAG_PRINTER },
   { 1, "media",                        IPP_TAG_KEYWORD,        IPP_TAG_JOB,
                                                        IPP_TAG_DOCUMENT },
+  { 0, "media-bottom-margin",  IPP_TAG_INTEGER,        IPP_TAG_JOB,
+                                                       IPP_TAG_DOCUMENT },
   { 0, "media-col",            IPP_TAG_BEGIN_COLLECTION, IPP_TAG_JOB,
                                                        IPP_TAG_DOCUMENT },
   { 0, "media-col-default",    IPP_TAG_BEGIN_COLLECTION, IPP_TAG_PRINTER },
@@ -196,12 +205,25 @@ static const _ipp_option_t ipp_options[] =
   { 1, "media-default",                IPP_TAG_KEYWORD,        IPP_TAG_PRINTER },
   { 0, "media-key",            IPP_TAG_KEYWORD,        IPP_TAG_JOB,
                                                        IPP_TAG_DOCUMENT },
+  { 0, "media-left-margin",    IPP_TAG_INTEGER,        IPP_TAG_JOB,
+                                                       IPP_TAG_DOCUMENT },
+  { 0, "media-right-margin",   IPP_TAG_INTEGER,        IPP_TAG_JOB,
+                                                       IPP_TAG_DOCUMENT },
   { 0, "media-size",           IPP_TAG_BEGIN_COLLECTION, IPP_TAG_JOB,
                                                        IPP_TAG_DOCUMENT },
+  { 0, "media-size-name",      IPP_TAG_KEYWORD,        IPP_TAG_JOB,
+                                                       IPP_TAG_DOCUMENT },
+  { 0, "media-source",         IPP_TAG_KEYWORD,        IPP_TAG_JOB,
+                                                       IPP_TAG_DOCUMENT },
+  { 0, "media-top-margin",     IPP_TAG_INTEGER,        IPP_TAG_JOB,
+                                                       IPP_TAG_DOCUMENT },
   { 0, "media-type",           IPP_TAG_KEYWORD,        IPP_TAG_JOB,
                                                        IPP_TAG_DOCUMENT },
   { 0, "mirror",               IPP_TAG_BOOLEAN,        IPP_TAG_JOB },
   { 0, "mirror-default",       IPP_TAG_BOOLEAN,        IPP_TAG_PRINTER },
+  { 0, "multiple-document-handling", IPP_TAG_KEYWORD,  IPP_TAG_JOB,
+                                                       IPP_TAG_DOCUMENT },
+  { 0, "multiple-document-handling-default", IPP_TAG_KEYWORD, IPP_TAG_PRINTER },
   { 0, "natural-scaling",      IPP_TAG_INTEGER,        IPP_TAG_JOB },
   { 0, "natural-scaling-default", IPP_TAG_INTEGER,     IPP_TAG_PRINTER },
   { 0, "notify-charset",       IPP_TAG_CHARSET,        IPP_TAG_SUBSCRIPTION },
@@ -217,18 +239,26 @@ static const _ipp_option_t ipp_options[] =
   { 0, "number-up",            IPP_TAG_INTEGER,        IPP_TAG_JOB,
                                                        IPP_TAG_DOCUMENT },
   { 0, "number-up-default",    IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
+  { 0, "number-up-layout",     IPP_TAG_KEYWORD,        IPP_TAG_JOB,
+                                                       IPP_TAG_DOCUMENT },
+  { 0, "number-up-layout-default", IPP_TAG_KEYWORD,    IPP_TAG_PRINTER },
   { 0, "orientation-requested",        IPP_TAG_ENUM,           IPP_TAG_JOB,
                                                        IPP_TAG_DOCUMENT },
   { 0, "orientation-requested-default", IPP_TAG_ENUM,  IPP_TAG_PRINTER },
+  { 0, "output-bin",           IPP_TAG_KEYWORD,        IPP_TAG_JOB,
+                                                       IPP_TAG_DOCUMENT },
+  { 0, "output-bin-default",   IPP_TAG_KEYWORD,        IPP_TAG_PRINTER },
   { 1, "overrides",            IPP_TAG_BEGIN_COLLECTION, IPP_TAG_JOB,
                                                        IPP_TAG_DOCUMENT },
   { 0, "page-bottom",          IPP_TAG_INTEGER,        IPP_TAG_JOB },
   { 0, "page-bottom-default",  IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
+  { 0, "page-delivery",                IPP_TAG_KEYWORD,        IPP_TAG_JOB,
+                                                       IPP_TAG_DOCUMENT },
+  { 0, "page-delivery-default",        IPP_TAG_KEYWORD,        IPP_TAG_PRINTER },
   { 0, "page-left",            IPP_TAG_INTEGER,        IPP_TAG_JOB },
   { 0, "page-left-default",    IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
   { 1, "page-ranges",          IPP_TAG_RANGE,          IPP_TAG_JOB,
                                                        IPP_TAG_DOCUMENT },
-  { 1, "page-ranges-default",  IPP_TAG_RANGE,          IPP_TAG_PRINTER },
   { 0, "page-right",           IPP_TAG_INTEGER,        IPP_TAG_JOB },
   { 0, "page-right-default",   IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
   { 0, "page-top",             IPP_TAG_INTEGER,        IPP_TAG_JOB },
@@ -269,23 +299,48 @@ static const _ipp_option_t ipp_options[] =
   { 0, "ppi-default",          IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
   { 0, "prettyprint",          IPP_TAG_BOOLEAN,        IPP_TAG_JOB },
   { 0, "prettyprint-default",  IPP_TAG_BOOLEAN,        IPP_TAG_PRINTER },
+  { 0, "print-color-mode",     IPP_TAG_KEYWORD,        IPP_TAG_JOB,
+                                                       IPP_TAG_DOCUMENT },
+  { 0, "print-color-mode-default", IPP_TAG_KEYWORD,    IPP_TAG_PRINTER },
+  { 0, "print-content-optimize", IPP_TAG_KEYWORD,      IPP_TAG_JOB,
+                                                       IPP_TAG_DOCUMENT },
+  { 0, "print-content-optimize-default", IPP_TAG_KEYWORD, IPP_TAG_PRINTER },
   { 0, "print-quality",                IPP_TAG_ENUM,           IPP_TAG_JOB,
                                                        IPP_TAG_DOCUMENT },
   { 0, "print-quality-default",        IPP_TAG_ENUM,           IPP_TAG_PRINTER },
+  { 0, "print-rendering-intent", IPP_TAG_KEYWORD,      IPP_TAG_JOB,
+                                                       IPP_TAG_DOCUMENT },
+  { 0, "print-rendering-intent-default", IPP_TAG_KEYWORD, IPP_TAG_PRINTER },
+  { 0, "print-scaling",                IPP_TAG_KEYWORD,        IPP_TAG_JOB,
+                                                       IPP_TAG_DOCUMENT },
+  { 0, "print-scaling-default",        IPP_TAG_KEYWORD,        IPP_TAG_PRINTER },
+  { 1, "printer-alert",                IPP_TAG_STRING,         IPP_TAG_PRINTER },
+  { 1, "printer-alert-description", IPP_TAG_TEXT,      IPP_TAG_PRINTER },
   { 1, "printer-commands",     IPP_TAG_KEYWORD,        IPP_TAG_PRINTER },
   { 0, "printer-error-policy", IPP_TAG_NAME,           IPP_TAG_PRINTER },
+  { 1, "printer-finisher",     IPP_TAG_STRING,         IPP_TAG_PRINTER },
+  { 1, "printer-finisher-description", IPP_TAG_TEXT,   IPP_TAG_PRINTER },
+  { 1, "printer-finisher-supplies", IPP_TAG_STRING,    IPP_TAG_PRINTER },
+  { 1, "printer-finisher-supplies-description", IPP_TAG_TEXT, IPP_TAG_PRINTER },
+  { 0, "printer-geo-location", IPP_TAG_URI,            IPP_TAG_PRINTER },
   { 0, "printer-info",         IPP_TAG_TEXT,           IPP_TAG_PRINTER },
+  { 1, "printer-input-tray",   IPP_TAG_STRING,         IPP_TAG_PRINTER },
   { 0, "printer-is-accepting-jobs", IPP_TAG_BOOLEAN,   IPP_TAG_PRINTER },
   { 0, "printer-is-shared",    IPP_TAG_BOOLEAN,        IPP_TAG_PRINTER },
+  { 0, "printer-is-temporary", IPP_TAG_BOOLEAN,        IPP_TAG_PRINTER },
   { 0, "printer-location",     IPP_TAG_TEXT,           IPP_TAG_PRINTER },
   { 0, "printer-make-and-model", IPP_TAG_TEXT,         IPP_TAG_PRINTER },
   { 0, "printer-more-info",    IPP_TAG_URI,            IPP_TAG_PRINTER },
   { 0, "printer-op-policy",    IPP_TAG_NAME,           IPP_TAG_PRINTER },
+  { 1, "printer-output-tray",  IPP_TAG_STRING,         IPP_TAG_PRINTER },
   { 0, "printer-resolution",   IPP_TAG_RESOLUTION,     IPP_TAG_JOB,
                                                        IPP_TAG_DOCUMENT },
+  { 0, "printer-resolution-default", IPP_TAG_RESOLUTION, IPP_TAG_PRINTER },
   { 0, "printer-state",                IPP_TAG_ENUM,           IPP_TAG_PRINTER },
   { 0, "printer-state-change-time", IPP_TAG_INTEGER,   IPP_TAG_PRINTER },
   { 1, "printer-state-reasons",        IPP_TAG_KEYWORD,        IPP_TAG_PRINTER },
+  { 1, "printer-supply",       IPP_TAG_STRING,         IPP_TAG_PRINTER },
+  { 1, "printer-supply-description", IPP_TAG_TEXT,     IPP_TAG_PRINTER },
   { 0, "printer-type",         IPP_TAG_ENUM,           IPP_TAG_PRINTER },
   { 0, "printer-uri",          IPP_TAG_URI,            IPP_TAG_OPERATION },
   { 1, "printer-uri-supported",        IPP_TAG_URI,            IPP_TAG_PRINTER },
@@ -323,317 +378,311 @@ static int      compare_ipp_options(_ipp_option_t *a, _ipp_option_t *b);
 
 
 /*
- * '_cupsConvertOptions()' - Convert printer options to standard IPP attributes.
- *
- * This functions converts PPD and CUPS-specific options to their standard IPP
- * attributes and values and adds them to the specified IPP request.
+ * '_cupsEncodeOption()' - Encode a single option as an IPP attribute.
  */
 
-int                                            /* O - New number of copies */
-_cupsConvertOptions(ipp_t           *request,  /* I - IPP request */
-                    ppd_file_t      *ppd,      /* I - PPD file */
-                   _ppd_cache_t    *pc,        /* I - PPD cache info */
-                   ipp_attribute_t *media_col_sup,
-                                               /* I - media-col-supported values */
-                   ipp_attribute_t *doc_handling_sup,
-                                               /* I - multiple-document-handling-supported values */
-                   ipp_attribute_t *print_color_mode_sup,
-                                               /* I - Printer supports print-color-mode */
-                   const char    *user,        /* I - User info */
-                   const char    *format,      /* I - document-format value */
-                   int           copies,       /* I - Number of copies */
-                   int           num_options,  /* I - Number of options */
-                   cups_option_t *options)     /* I - Options */
+ipp_attribute_t *                      /* O - New attribute or @code NULL@ on error */
+_cupsEncodeOption(
+    ipp_t         *ipp,                        /* I - IPP request/response/collection */
+    ipp_tag_t     group_tag,           /* I - Group tag */
+    _ipp_option_t *map,                        /* I - Option mapping, if any */
+    const char    *name,               /* I - Attribute name */
+    const char    *value)              /* I - Value */
 {
-  int          i;                      /* Looping var */
-  const char   *keyword;               /* PWG keyword */
-  pwg_size_t   *size;                  /* PWG media size */
-  ipp_t                *media_col,             /* media-col value */
-               *media_size;            /* media-size value */
-  const char   *media_source,          /* media-source value */
-               *media_type,            /* media-type value */
-               *collate_str,           /* multiple-document-handling value */
-               *color_attr_name,       /* Supported color attribute */
-               *mandatory;             /* Mandatory attributes */
-  int          num_finishings = 0,     /* Number of finishing values */
-               finishings[10];         /* Finishing enum values */
-  ppd_choice_t *choice;                /* Marked choice */
+  int                  i,              /* Looping var */
+                       count;          /* Number of values */
+  char                 *s,             /* Pointer into option value */
+                       *val,           /* Pointer to option value */
+                       *copy,          /* Copy of option value */
+                       *sep,           /* Option separator */
+                       quote;          /* Quote character */
+  ipp_attribute_t      *attr;          /* IPP attribute */
+  ipp_tag_t            value_tag;      /* IPP value tag */
+  ipp_t                        *collection;    /* Collection value */
+  int                  num_cols;       /* Number of collection values */
+  cups_option_t                *cols;          /* Collection values */
 
 
+  DEBUG_printf(("_cupsEncodeOption(ipp=%p(%s), group=%s, map=%p, name=\"%s\", value=\"%s\")", (void *)ipp, ipp ? ippOpString(ippGetOperation(ipp)) : "", ippTagString(group_tag), (void *)map, name, value));
+
  /*
-  * Send standard IPP attributes...
+  * Figure out the attribute syntax for encoding...
   */
 
-  if (pc->password && (keyword = cupsGetOption("job-password", num_options, options)) != NULL)
-  {
-    ippAddOctetString(request, IPP_TAG_OPERATION, "job-password", keyword, (int)strlen(keyword));
+  if (!map)
+    map = _ippFindOption(name);
 
-    if ((keyword = cupsGetOption("job-password-encryption", num_options, options)) == NULL)
-      keyword = "none";
+  if (map)
+    value_tag = map->value_tag;
+  else if (!_cups_strcasecmp(value, "true") || !_cups_strcasecmp(value, "false"))
+    value_tag = IPP_TAG_BOOLEAN;
+  else if (value[0] == '{')
+    value_tag = IPP_TAG_BEGIN_COLLECTION;
+  else
+    value_tag = IPP_TAG_NAME;
 
-    ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "job-password-encryption", NULL, keyword);
-  }
+ /*
+  * Count the number of values...
+  */
 
-  if (pc->account_id)
+  if (map && map->multivalue)
   {
-    if ((keyword = cupsGetOption("job-account-id", num_options, options)) == NULL)
-      keyword = cupsGetOption("job-billing", num_options, options);
+    for (count = 1, sep = (char *)value, quote = 0; *sep; sep ++)
+    {
+      if (*sep == quote)
+       quote = 0;
+      else if (!quote && (*sep == '\'' || *sep == '\"'))
+      {
+       /*
+       * Skip quoted option value...
+       */
 
-    if (keyword)
-      ippAddString(request, IPP_TAG_JOB, IPP_TAG_NAME, "job-account-id", NULL, keyword);
+       quote = *sep;
+      }
+      else if (*sep == ',' && !quote)
+       count ++;
+      else if (*sep == '\\' && sep[1])
+       sep ++;
+    }
   }
+  else
+    count = 1;
+
+  DEBUG_printf(("2_cupsEncodeOption: value_tag=%s, count=%d", ippTagString(value_tag), count));
+
+ /*
+  * Allocate memory for the attribute values...
+  */
 
-  if (pc->accounting_user_id)
+  if ((attr = ippAddStrings(ipp, group_tag, value_tag, name, count, NULL, NULL)) == NULL)
   {
-    if ((keyword = cupsGetOption("job-accounting-user-id", num_options, options)) == NULL)
-      keyword = user;
+   /*
+    * Ran out of memory!
+    */
 
-    if (keyword)
-      ippAddString(request, IPP_TAG_JOB, IPP_TAG_NAME, "job-accounting-user-id", NULL, keyword);
+    DEBUG_puts("1_cupsEncodeOption: Ran out of memory for attributes.");
+    return (NULL);
   }
 
-  for (mandatory = (const char *)cupsArrayFirst(pc->mandatory); mandatory; mandatory = (const char *)cupsArrayNext(pc->mandatory))
+  if (count > 1)
   {
-    if (strcmp(mandatory, "copies") &&
-       strcmp(mandatory, "destination-uris") &&
-       strcmp(mandatory, "finishings") &&
-       strcmp(mandatory, "job-account-id") &&
-       strcmp(mandatory, "job-accounting-user-id") &&
-       strcmp(mandatory, "job-password") &&
-       strcmp(mandatory, "job-password-encryption") &&
-       strcmp(mandatory, "media") &&
-       strncmp(mandatory, "media-col", 9) &&
-       strcmp(mandatory, "multiple-document-handling") &&
-       strcmp(mandatory, "output-bin") &&
-       strcmp(mandatory, "print-color-mode") &&
-       strcmp(mandatory, "print-quality") &&
-       strcmp(mandatory, "sides") &&
-       (keyword = cupsGetOption(mandatory, num_options, options)) != NULL)
-    {
-      _ipp_option_t *opt = _ippFindOption(mandatory);
-                                   /* Option type */
-      ipp_tag_t        value_tag = opt ? opt->value_tag : IPP_TAG_NAME;
-                                   /* Value type */
+   /*
+    * Make a copy of the value we can fiddle with...
+    */
 
-      switch (value_tag)
-      {
-       case IPP_TAG_INTEGER :
-       case IPP_TAG_ENUM :
-           ippAddInteger(request, IPP_TAG_JOB, value_tag, mandatory, atoi(keyword));
-           break;
-       case IPP_TAG_BOOLEAN :
-           ippAddBoolean(request, IPP_TAG_JOB, mandatory, !_cups_strcasecmp(keyword, "true"));
-           break;
-       case IPP_TAG_RANGE :
-           {
-             int lower, upper; /* Range */
+    if ((copy = strdup(value)) == NULL)
+    {
+     /*
+      * Ran out of memory!
+      */
 
-             if (sscanf(keyword, "%d-%d", &lower, &upper) != 2)
-               lower = upper = atoi(keyword);
+      DEBUG_puts("1_cupsEncodeOption: Ran out of memory for value copy.");
+      ippDeleteAttribute(ipp, attr);
+      return (NULL);
+    }
 
-             ippAddRange(request, IPP_TAG_JOB, mandatory, lower, upper);
-           }
-           break;
-       case IPP_TAG_STRING :
-           ippAddOctetString(request, IPP_TAG_JOB, mandatory, keyword, (int)strlen(keyword));
-           break;
-       default :
-           if (!strcmp(mandatory, "print-color-mode") && !strcmp(keyword, "monochrome"))
-           {
-             if (ippContainsString(print_color_mode_sup, "auto-monochrome"))
-               keyword = "auto-monochrome";
-             else if (ippContainsString(print_color_mode_sup, "process-monochrome") && !ippContainsString(print_color_mode_sup, "monochrome"))
-               keyword = "process-monochrome";
-           }
+    val = copy;
+  }
+  else
+  {
+   /*
+    * Since we have a single value, use the value directly...
+    */
 
-           ippAddString(request, IPP_TAG_JOB, value_tag, mandatory, NULL, keyword);
-           break;
-      }
-    }
+    val  = (char *)value;
+    copy = NULL;
   }
 
-  if ((keyword = cupsGetOption("PageSize", num_options, options)) == NULL)
-    keyword = cupsGetOption("media", num_options, options);
+ /*
+  * Scan the value string for values...
+  */
 
-  if ((size = _ppdCacheGetSize(pc, keyword)) != NULL)
+  for (i = 0, sep = val; i < count; val = sep, i ++)
   {
    /*
-    * Add a media-col value...
+    * Find the end of this value and mark it if needed...
     */
 
-    media_size = ippNew();
-    ippAddInteger(media_size, IPP_TAG_ZERO, IPP_TAG_INTEGER,
-                 "x-dimension", size->width);
-    ippAddInteger(media_size, IPP_TAG_ZERO, IPP_TAG_INTEGER,
-                 "y-dimension", size->length);
+    if (count > 1)
+    {
+      for (quote = 0; *sep; sep ++)
+      {
+       if (*sep == quote)
+       {
+        /*
+         * Finish quoted value...
+         */
 
-    media_col = ippNew();
-    ippAddCollection(media_col, IPP_TAG_ZERO, "media-size", media_size);
+         quote = 0;
+       }
+       else if (!quote && (*sep == '\'' || *sep == '\"'))
+       {
+        /*
+         * Handle quoted option value...
+         */
 
-    media_source = _ppdCacheGetSource(pc, cupsGetOption("InputSlot",
-                                                       num_options,
-                                                       options));
-    media_type   = _ppdCacheGetType(pc, cupsGetOption("MediaType",
-                                                     num_options,
-                                                     options));
+         quote = *sep;
+       }
+       else if (*sep == ',')
+         break;
+       else if (*sep == '\\' && sep[1])
+       {
+        /*
+         * Skip quoted character...
+         */
 
-    for (i = 0; i < media_col_sup->num_values; i ++)
-    {
-      if (!strcmp(media_col_sup->values[i].string.text, "media-left-margin"))
-       ippAddInteger(media_col, IPP_TAG_ZERO, IPP_TAG_INTEGER, "media-left-margin", size->left);
-      else if (!strcmp(media_col_sup->values[i].string.text, "media-bottom-margin"))
-       ippAddInteger(media_col, IPP_TAG_ZERO, IPP_TAG_INTEGER, "media-bottom-margin", size->bottom);
-      else if (!strcmp(media_col_sup->values[i].string.text, "media-right-margin"))
-       ippAddInteger(media_col, IPP_TAG_ZERO, IPP_TAG_INTEGER, "media-right-margin", size->right);
-      else if (!strcmp(media_col_sup->values[i].string.text, "media-top-margin"))
-       ippAddInteger(media_col, IPP_TAG_ZERO, IPP_TAG_INTEGER, "media-top-margin", size->top);
-      else if (!strcmp(media_col_sup->values[i].string.text, "media-source") && media_source)
-       ippAddString(media_col, IPP_TAG_ZERO, IPP_TAG_KEYWORD, "media-source", NULL, media_source);
-      else if (!strcmp(media_col_sup->values[i].string.text, "media-type") && media_type)
-       ippAddString(media_col, IPP_TAG_ZERO, IPP_TAG_KEYWORD, "media-type", NULL, media_type);
+         memmove(sep, sep + 1, strlen(sep));
+       }
+      }
+
+      if (*sep == ',')
+       *sep++ = '\0';
     }
 
-    ippAddCollection(request, IPP_TAG_JOB, "media-col", media_col);
-  }
+   /*
+    * Copy the option value(s) over as needed by the type...
+    */
 
-  if ((keyword = cupsGetOption("output-bin", num_options, options)) == NULL)
-  {
-    if ((choice = ppdFindMarkedChoice(ppd, "OutputBin")) != NULL)
-      keyword = _ppdCacheGetBin(pc, choice->choice);
-  }
+    switch (attr->value_tag)
+    {
+      case IPP_TAG_INTEGER :
+      case IPP_TAG_ENUM :
+        /*
+         * Integer/enumeration value...
+         */
 
-  if (keyword)
-    ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "output-bin", NULL, keyword);
+         ippSetInteger(ipp, &attr, i, (int)strtol(val, &s, 10));
+         break;
 
-  color_attr_name = print_color_mode_sup ? "print-color-mode" : "output-mode";
+      case IPP_TAG_BOOLEAN :
+         if (!_cups_strcasecmp(val, "true") || !_cups_strcasecmp(val, "on") || !_cups_strcasecmp(val, "yes"))
+         {
+          /*
+           * Boolean value - true...
+           */
 
-  if ((keyword = cupsGetOption("print-color-mode", num_options, options)) == NULL)
-  {
-    if ((choice = ppdFindMarkedChoice(ppd, "ColorModel")) != NULL)
-    {
-      if (!_cups_strcasecmp(choice->choice, "Gray"))
-       keyword = "monochrome";
-      else
-       keyword = "color";
-    }
-  }
+            ippSetBoolean(ipp, &attr, i, 1);
+         }
+         else
+         {
+          /*
+           * Boolean value - false...
+           */
 
-  if (keyword && !strcmp(keyword, "monochrome"))
-  {
-    if (ippContainsString(print_color_mode_sup, "auto-monochrome"))
-      keyword = "auto-monochrome";
-    else if (ippContainsString(print_color_mode_sup, "process-monochrome") && !ippContainsString(print_color_mode_sup, "monochrome"))
-      keyword = "process-monochrome";
-  }
+            ippSetBoolean(ipp, &attr, i, 0);
+         }
+         break;
 
-  if (keyword)
-    ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, color_attr_name, NULL, keyword);
+      case IPP_TAG_RANGE :
+          {
+          /*
+           * Range...
+           */
 
-  if ((keyword = cupsGetOption("print-quality", num_options, options)) != NULL)
-    ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_ENUM, "print-quality", atoi(keyword));
-  else if ((choice = ppdFindMarkedChoice(ppd, "cupsPrintQuality")) != NULL)
-  {
-    if (!_cups_strcasecmp(choice->choice, "draft"))
-      ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_ENUM, "print-quality", IPP_QUALITY_DRAFT);
-    else if (!_cups_strcasecmp(choice->choice, "normal"))
-      ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_ENUM, "print-quality", IPP_QUALITY_NORMAL);
-    else if (!_cups_strcasecmp(choice->choice, "high"))
-      ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_ENUM, "print-quality", IPP_QUALITY_HIGH);
-  }
+           int lower, upper;           /* Lower and upper ranges... */
 
-  if ((keyword = cupsGetOption("sides", num_options, options)) != NULL)
-    ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "sides", NULL, keyword);
-  else if (pc->sides_option && (choice = ppdFindMarkedChoice(ppd, pc->sides_option)) != NULL)
-  {
-    if (!_cups_strcasecmp(choice->choice, pc->sides_1sided))
-      ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "sides", NULL, "one-sided");
-    else if (!_cups_strcasecmp(choice->choice, pc->sides_2sided_long))
-      ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "sides", NULL, "two-sided-long-edge");
-    if (!_cups_strcasecmp(choice->choice, pc->sides_2sided_short))
-      ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "sides", NULL, "two-sided-short-edge");
-  }
+           if (*val == '-')
+           {
+             lower = 1;
+             s     = val;
+           }
+           else
+             lower = (int)strtol(val, &s, 10);
 
- /*
-  * Copies...
-  */
+           if (*s == '-')
+           {
+             if (s[1])
+               upper = (int)strtol(s + 1, NULL, 10);
+             else
+               upper = 2147483647;
+           }
+           else
+             upper = lower;
 
-  if ((keyword = cupsGetOption("multiple-document-handling", num_options, options)) != NULL)
-  {
-    if (strstr(keyword, "uncollated"))
-      keyword = "false";
-    else
-      keyword = "true";
-  }
-  else if ((keyword = cupsGetOption("collate", num_options, options)) == NULL)
-    keyword = "true";
+            ippSetRange(ipp, &attr, i, lower, upper);
+         }
+         break;
 
-  if (format)
-  {
-    if (!_cups_strcasecmp(format, "image/gif") ||
-       !_cups_strcasecmp(format, "image/jp2") ||
-       !_cups_strcasecmp(format, "image/jpeg") ||
-       !_cups_strcasecmp(format, "image/png") ||
-       !_cups_strcasecmp(format, "image/tiff") ||
-       !_cups_strncasecmp(format, "image/x-", 8))
-    {
-     /*
-      * Collation makes no sense for single page image formats...
-      */
+      case IPP_TAG_RESOLUTION :
+          {
+          /*
+           * Resolution...
+           */
+           int         xres, yres;     /* Resolution values */
+           ipp_res_t   units;          /* Resolution units */
 
-      keyword = "false";
-    }
-    else if (!_cups_strncasecmp(format, "image/", 6) ||
-            !_cups_strcasecmp(format, "application/vnd.cups-raster"))
-    {
-     /*
-      * Multi-page image formats will have copies applied by the upstream
-      * filters...
-      */
+           xres = (int)strtol(val, &s, 10);
 
-      copies = 1;
-    }
-  }
+           if (*s == 'x')
+             yres = (int)strtol(s + 1, &s, 10);
+           else
+             yres = xres;
 
-  if (doc_handling_sup)
-  {
-    if (!_cups_strcasecmp(keyword, "true"))
-      collate_str = "separate-documents-collated-copies";
-    else
-      collate_str = "separate-documents-uncollated-copies";
+           if (!_cups_strcasecmp(s, "dpc") || !_cups_strcasecmp(s, "dpcm"))
+             units = IPP_RES_PER_CM;
+           else
+             units = IPP_RES_PER_INCH;
 
-    for (i = 0; i < doc_handling_sup->num_values; i ++)
-    {
-      if (!strcmp(doc_handling_sup->values[i].string.text, collate_str))
-      {
-       ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "multiple-document-handling", NULL, collate_str);
-       break;
-      }
-    }
+           ippSetResolution(ipp, &attr, i, units, xres, yres);
+          }
+         break;
 
-    if (i >= doc_handling_sup->num_values)
-      copies = 1;
-  }
+      case IPP_TAG_STRING :
+        /*
+         * octetString
+         */
 
- /*
-  * Map finishing options...
-  */
+          ippSetOctetString(ipp, &attr, i, val, (int)strlen(val));
+         break;
 
-  num_finishings = _ppdCacheGetFinishingValues(pc, num_options, options, (int)(sizeof(finishings) / sizeof(finishings[0])), finishings);
-  if (num_finishings > 0)
-  {
-    ippAddIntegers(request, IPP_TAG_JOB, IPP_TAG_ENUM, "finishings", num_finishings, finishings);
+      case IPP_TAG_BEGIN_COLLECTION :
+        /*
+         * Collection value
+         */
 
-    if (copies > 1 && (keyword = cupsGetOption("job-impressions", num_options, options)) != NULL)
-    {
-     /*
-      * Send job-pages-per-set attribute to apply finishings correctly...
-      */
+         num_cols = cupsParseOptions(val, 0, &cols);
+         if ((collection = ippNew()) == NULL)
+         {
+           cupsFreeOptions(num_cols, cols);
+
+           if (copy)
+             free(copy);
+
+           ippDeleteAttribute(ipp, attr);
+           return (NULL);
+         }
 
-      ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-pages-per-set", atoi(keyword) / copies);
+         ippSetCollection(ipp, &attr, i, collection);
+         cupsEncodeOptions2(collection, num_cols, cols, IPP_TAG_JOB);
+         cupsFreeOptions(num_cols, cols);
+         break;
+
+      default :
+         ippSetString(ipp, &attr, i, val);
+         break;
     }
   }
 
-  return (copies);
+  if (copy)
+    free(copy);
+
+  return (attr);
+}
+
+
+/*
+ * 'cupsEncodeOption()' - Encode a single option into an IPP attribute.
+ *
+ * @since CUPS 2.3/macOS 10.14@
+ */
+
+ipp_attribute_t        *                       /* O - New attribute or @code NULL@ on error */
+cupsEncodeOption(ipp_t      *ipp,      /* I - IPP request/response */
+                 ipp_tag_t  group_tag, /* I - Attribute group */
+                 const char *name,     /* I - Option name */
+                 const char *value)    /* I - Option string value */
+{
+  return (_cupsEncodeOption(ipp, group_tag, _ippFindOption(name), name, value));
 }
 
 
@@ -641,16 +690,16 @@ _cupsConvertOptions(ipp_t           *request,     /* I - IPP request */
  * 'cupsEncodeOptions()' - Encode printer options into IPP attributes.
  *
  * This function adds operation, job, and then subscription attributes,
- * in that order. Use the cupsEncodeOptions2() function to add attributes
+ * in that order. Use the @link cupsEncodeOptions2@ function to add attributes
  * for a single group.
  */
 
 void
-cupsEncodeOptions(ipp_t         *ipp,          /* I - Request to add to */
+cupsEncodeOptions(ipp_t         *ipp,          /* I - IPP request/response */
                  int           num_options,    /* I - Number of options */
                  cups_option_t *options)       /* I - Options */
 {
-  DEBUG_printf(("cupsEncodeOptions(%p, %d, %p)", ipp, num_options, options));
+  DEBUG_printf(("cupsEncodeOptions(%p, %d, %p)", (void *)ipp, num_options, (void *)options));
 
  /*
   * Add the options in the proper groups & order...
@@ -666,40 +715,27 @@ cupsEncodeOptions(ipp_t         *ipp,             /* I - Request to add to */
  * 'cupsEncodeOptions2()' - Encode printer options into IPP attributes for a group.
  *
  * This function only adds attributes for a single group. Call this
- * function multiple times for each group, or use cupsEncodeOptions()
+ * function multiple times for each group, or use @link cupsEncodeOptions@
  * to add the standard groups.
  *
- * @since CUPS 1.2/OS X 10.5@
+ * @since CUPS 1.2/macOS 10.5@
  */
 
 void
 cupsEncodeOptions2(
-    ipp_t         *ipp,                        /* I - Request to add to */
+    ipp_t         *ipp,                        /* I - IPP request/response */
     int           num_options,         /* I - Number of options */
     cups_option_t *options,            /* I - Options */
     ipp_tag_t     group_tag)           /* I - Group to encode */
 {
-  int                  i, j;           /* Looping vars */
-  int                  count;          /* Number of values */
-  char                 *s,             /* Pointer into option value */
-                       *val,           /* Pointer to option value */
-                       *copy,          /* Copy of option value */
-                       *sep,           /* Option separator */
-                       quote;          /* Quote character */
-  ipp_attribute_t      *attr;          /* IPP attribute */
-  ipp_tag_t            value_tag;      /* IPP value tag */
+  int                  i;              /* Looping var */
+  char                 *val;           /* Pointer to option value */
   cups_option_t                *option;        /* Current option */
-  ipp_t                        *collection;    /* Collection value */
-  int                  num_cols;       /* Number of collection values */
-  cups_option_t                *cols;          /* Collection values */
   ipp_op_t             op;             /* Operation for this request */
   const ipp_op_t       *ops;           /* List of allowed operations */
 
 
-  DEBUG_printf(("cupsEncodeOptions2(ipp=%p(%s), num_options=%d, options=%p, "
-                "group_tag=%x)", ipp,
-                ipp ? ippOpString(ippGetOperation(ipp)) : "", num_options,
-                options, group_tag));
+  DEBUG_printf(("cupsEncodeOptions2(ipp=%p(%s), num_options=%d, options=%p, group_tag=%x)", (void *)ipp, ipp ? ippOpString(ippGetOperation(ipp)) : "", num_options, (void *)options, group_tag));
 
  /*
   * Range check input...
@@ -714,24 +750,18 @@ cupsEncodeOptions2(
 
   op = ippGetOperation(ipp);
 
-  if (group_tag == IPP_TAG_OPERATION &&
-      (op == IPP_OP_PRINT_JOB || op == IPP_OP_PRINT_URI ||
-       op == IPP_OP_SEND_DOCUMENT || op == IPP_OP_SEND_URI))
+  if (group_tag == IPP_TAG_OPERATION && (op == IPP_OP_PRINT_JOB || op == IPP_OP_PRINT_URI || op == IPP_OP_SEND_DOCUMENT || op == IPP_OP_SEND_URI))
   {
    /*
     * Handle the document format stuff first...
     */
 
-    if ((val = (char *)cupsGetOption("document-format", num_options,
-                                     options)) != NULL)
-      ippAddString(ipp, IPP_TAG_OPERATION, IPP_TAG_MIMETYPE, "document-format",
-                  NULL, val);
+    if ((val = (char *)cupsGetOption("document-format", num_options, options)) != NULL)
+      ippAddString(ipp, IPP_TAG_OPERATION, IPP_TAG_MIMETYPE, "document-format", NULL, val);
     else if (cupsGetOption("raw", num_options, options))
-      ippAddString(ipp, IPP_TAG_OPERATION, IPP_TAG_MIMETYPE, "document-format",
-                  NULL, "application/vnd.cups-raw");
+      ippAddString(ipp, IPP_TAG_OPERATION, IPP_TAG_MIMETYPE, "document-format", NULL, "application/vnd.cups-raw");
     else
-      ippAddString(ipp, IPP_TAG_OPERATION, IPP_TAG_MIMETYPE, "document-format",
-                  NULL, "application/octet-stream");
+      ippAddString(ipp, IPP_TAG_OPERATION, IPP_TAG_MIMETYPE, "document-format", NULL, "application/octet-stream");
   }
 
  /*
@@ -742,14 +772,11 @@ cupsEncodeOptions2(
   {
     _ipp_option_t      *match;         /* Matching attribute */
 
-
    /*
     * Skip document format options that are handled above...
     */
 
-    if (!_cups_strcasecmp(option->name, "raw") ||
-        !_cups_strcasecmp(option->name, "document-format") ||
-       !option->name[0])
+    if (!_cups_strcasecmp(option->name, "raw") || !_cups_strcasecmp(option->name, "document-format") || !option->name[0])
       continue;
 
    /*
@@ -761,8 +788,6 @@ cupsEncodeOptions2(
       if (match->group_tag != group_tag && match->alt_group_tag != group_tag)
         continue;
 
-      value_tag = match->value_tag;
-
       if (match->operations)
         ops = match->operations;
       else if (group_tag == IPP_TAG_JOB)
@@ -783,12 +808,9 @@ cupsEncodeOptions2(
     {
       int      namelen;                /* Length of name */
 
-
       namelen = (int)strlen(option->name);
 
-      if (namelen < 10 ||
-          (strcmp(option->name + namelen - 8, "-default") &&
-           strcmp(option->name + namelen - 10, "-supported")))
+      if (namelen < 10 || (strcmp(option->name + namelen - 8, "-default") && strcmp(option->name + namelen - 10, "-supported")))
       {
        if (group_tag != IPP_TAG_JOB && group_tag != IPP_TAG_DOCUMENT)
        {
@@ -808,12 +830,6 @@ cupsEncodeOptions2(
         ops = ipp_doc_creation;
       else
         ops = ipp_set_printer;
-
-      if (!_cups_strcasecmp(option->value, "true") ||
-          !_cups_strcasecmp(option->value, "false"))
-       value_tag = IPP_TAG_BOOLEAN;
-      else
-       value_tag = IPP_TAG_NAME;
     }
 
    /*
@@ -832,277 +848,7 @@ cupsEncodeOptions2(
       continue;
     }
 
-   /*
-    * Count the number of values...
-    */
-
-    if (match && match->multivalue)
-    {
-      for (count = 1, sep = option->value, quote = 0; *sep; sep ++)
-      {
-       if (*sep == quote)
-         quote = 0;
-       else if (!quote && (*sep == '\'' || *sep == '\"'))
-       {
-        /*
-         * Skip quoted option value...
-         */
-
-         quote = *sep++;
-       }
-       else if (*sep == ',' && !quote)
-         count ++;
-       else if (*sep == '\\' && sep[1])
-         sep ++;
-      }
-    }
-    else
-      count = 1;
-
-    DEBUG_printf(("2cupsEncodeOptions2: option=\"%s\", count=%d",
-                  option->name, count));
-
-   /*
-    * Allocate memory for the attribute values...
-    */
-
-    if ((attr = ippAddStrings(ipp, group_tag, value_tag, option->name, count,
-                              NULL, NULL)) == NULL)
-    {
-     /*
-      * Ran out of memory!
-      */
-
-      DEBUG_puts("1cupsEncodeOptions2: Ran out of memory for attributes!");
-      return;
-    }
-
-    if (count > 1)
-    {
-     /*
-      * Make a copy of the value we can fiddle with...
-      */
-
-      if ((copy = strdup(option->value)) == NULL)
-      {
-       /*
-       * Ran out of memory!
-       */
-
-       DEBUG_puts("1cupsEncodeOptions2: Ran out of memory for value copy!");
-       ippDeleteAttribute(ipp, attr);
-       return;
-      }
-
-      val = copy;
-    }
-    else
-    {
-     /*
-      * Since we have a single value, use the value directly...
-      */
-
-      val  = option->value;
-      copy = NULL;
-    }
-
-   /*
-    * Scan the value string for values...
-    */
-
-    for (j = 0, sep = val; j < count; val = sep, j ++)
-    {
-     /*
-      * Find the end of this value and mark it if needed...
-      */
-
-      if (count > 1)
-      {
-       for (quote = 0; *sep; sep ++)
-       {
-         if (*sep == quote)
-         {
-          /*
-           * Finish quoted value...
-           */
-
-           quote = 0;
-         }
-         else if (!quote && (*sep == '\'' || *sep == '\"'))
-         {
-          /*
-           * Handle quoted option value...
-           */
-
-           quote = *sep;
-         }
-         else if (*sep == ',' && count > 1)
-           break;
-         else if (*sep == '\\' && sep[1])
-         {
-          /*
-           * Skip quoted character...
-           */
-
-           sep ++;
-         }
-       }
-
-       if (*sep == ',')
-         *sep++ = '\0';
-      }
-
-     /*
-      * Copy the option value(s) over as needed by the type...
-      */
-
-      switch (attr->value_tag)
-      {
-       case IPP_TAG_INTEGER :
-       case IPP_TAG_ENUM :
-          /*
-           * Integer/enumeration value...
-           */
-
-            attr->values[j].integer = (int)strtol(val, &s, 10);
-
-            DEBUG_printf(("2cupsEncodeOptions2: Added integer option value "
-                         "%d...", attr->values[j].integer));
-            break;
-
-       case IPP_TAG_BOOLEAN :
-           if (!_cups_strcasecmp(val, "true") ||
-               !_cups_strcasecmp(val, "on") ||
-               !_cups_strcasecmp(val, "yes"))
-           {
-            /*
-             * Boolean value - true...
-             */
-
-             attr->values[j].boolean = 1;
-
-              DEBUG_puts("2cupsEncodeOptions2: Added boolean true value...");
-           }
-           else
-           {
-            /*
-             * Boolean value - false...
-             */
-
-             attr->values[j].boolean = 0;
-
-              DEBUG_puts("2cupsEncodeOptions2: Added boolean false value...");
-           }
-            break;
-
-       case IPP_TAG_RANGE :
-          /*
-           * Range...
-           */
-
-            if (*val == '-')
-           {
-             attr->values[j].range.lower = 1;
-             s = val;
-           }
-           else
-             attr->values[j].range.lower = (int)strtol(val, &s, 10);
-
-           if (*s == '-')
-           {
-             if (s[1])
-               attr->values[j].range.upper = (int)strtol(s + 1, NULL, 10);
-             else
-               attr->values[j].range.upper = 2147483647;
-            }
-           else
-             attr->values[j].range.upper = attr->values[j].range.lower;
-
-           DEBUG_printf(("2cupsEncodeOptions2: Added range option value "
-                         "%d-%d...", attr->values[j].range.lower,
-                         attr->values[j].range.upper));
-            break;
-
-       case IPP_TAG_RESOLUTION :
-          /*
-           * Resolution...
-           */
-
-           attr->values[j].resolution.xres = (int)strtol(val, &s, 10);
-
-           if (*s == 'x')
-             attr->values[j].resolution.yres = (int)strtol(s + 1, &s, 10);
-           else
-             attr->values[j].resolution.yres = attr->values[j].resolution.xres;
-
-           if (!_cups_strcasecmp(s, "dpc") ||
-               !_cups_strcasecmp(s, "dpcm"))
-              attr->values[j].resolution.units = IPP_RES_PER_CM;
-            else
-              attr->values[j].resolution.units = IPP_RES_PER_INCH;
-
-           DEBUG_printf(("2cupsEncodeOptions2: Added resolution option value "
-                         "%s...", val));
-            break;
-
-       case IPP_TAG_STRING :
-           /*
-           * octet-string
-           */
-
-            attr->values[j].unknown.length = (int)strlen(val);
-           attr->values[j].unknown.data   = strdup(val);
-
-            DEBUG_printf(("2cupsEncodeOptions2: Added octet-string value "
-                         "\"%s\"...", (char *)attr->values[j].unknown.data));
-            break;
-
-        case IPP_TAG_BEGIN_COLLECTION :
-          /*
-           * Collection value
-           */
-
-           num_cols   = cupsParseOptions(val, 0, &cols);
-           if ((collection = ippNew()) == NULL)
-           {
-             cupsFreeOptions(num_cols, cols);
-
-             if (copy)
-               free(copy);
-
-             ippDeleteAttribute(ipp, attr);
-             return;
-            }
-
-           attr->values[j].collection = collection;
-           cupsEncodeOptions2(collection, num_cols, cols, IPP_TAG_JOB);
-            cupsFreeOptions(num_cols, cols);
-           break;
-
-       default :
-           if ((attr->values[j].string.text = _cupsStrAlloc(val)) == NULL)
-           {
-            /*
-             * Ran out of memory!
-             */
-
-             DEBUG_puts("1cupsEncodeOptions2: Ran out of memory for string!");
-
-             if (copy)
-               free(copy);
-
-             ippDeleteAttribute(ipp, attr);
-             return;
-           }
-
-           DEBUG_printf(("2cupsEncodeOptions2: Added string value \"%s\"...",
-                         val));
-            break;
-      }
-    }
-
-    if (copy)
-      free(copy);
+    _cupsEncodeOption(ipp, group_tag, match, option->name, option->value);
   }
 }
 
@@ -1161,8 +907,3 @@ compare_ipp_options(_ipp_option_t *a,      /* I - First option */
 {
   return (strcmp(a->name, b->name));
 }
-
-
-/*
- * End of "$Id$".
- */