]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/encode.c
Merge changes from CUPS 1.4svn-r8628.
[thirdparty/cups.git] / cups / encode.c
index 686fb648a4863c10ce092ec05533983394cf1944..3bdcbba052b4dff7b46b56d7d3b75fec51d08ff7 100644 (file)
@@ -1,25 +1,16 @@
 /*
- * "$Id: encode.c 6386 2007-03-23 19:03:01Z mike $"
+ * "$Id: encode.c 7696 2008-06-26 00:54:42Z mike $"
  *
  *   Option encoding routines for the Common UNIX Printing System (CUPS).
  *
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
- *   property of Easy Software Products 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 missing or damaged please contact Easy Software Products
- *   at:
- *
- *       Attn: CUPS Licensing Information
- *       Easy Software Products
- *       44141 Airport View Drive, Suite 204
- *       Hollywood, Maryland 20636 USA
- *
- *       Voice: (301) 373-9600
- *       EMail: cups-info@cups.org
- *         WWW: http://www.cups.org
+ *   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/".
  *
  *   This file is subject to the Apple OS-Developed Software exception.
  *
 
 static const _ipp_option_t ipp_options[] =
 {
-  { "auth-info",               IPP_TAG_TEXT,           IPP_TAG_JOB },
-  { "auth-info-required",      IPP_TAG_KEYWORD,        IPP_TAG_PRINTER },
-  { "blackplot",               IPP_TAG_BOOLEAN,        IPP_TAG_JOB },
-  { "blackplot-default",       IPP_TAG_BOOLEAN,        IPP_TAG_PRINTER },
-  { "brightness",              IPP_TAG_INTEGER,        IPP_TAG_JOB },
-  { "brightness-default",      IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
-  { "columns",                 IPP_TAG_INTEGER,        IPP_TAG_JOB },
-  { "columns-default",         IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
-  { "copies",                  IPP_TAG_INTEGER,        IPP_TAG_JOB },
-  { "copies-default",          IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
-  { "document-format",         IPP_TAG_MIMETYPE,       IPP_TAG_OPERATION },
-  { "document-format-default", IPP_TAG_MIMETYPE,       IPP_TAG_PRINTER },
-  { "finishings",              IPP_TAG_ENUM,           IPP_TAG_JOB },
-  { "finishings-default",      IPP_TAG_ENUM,           IPP_TAG_PRINTER },
-  { "fitplot",                 IPP_TAG_BOOLEAN,        IPP_TAG_JOB },
-  { "fitplot-default",         IPP_TAG_BOOLEAN,        IPP_TAG_PRINTER },
-  { "gamma",                   IPP_TAG_INTEGER,        IPP_TAG_JOB },
-  { "gamma-default",           IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
-  { "hue",                     IPP_TAG_INTEGER,        IPP_TAG_JOB },
-  { "hue-default",             IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
-  { "job-k-limit",             IPP_TAG_INTEGER,        IPP_TAG_JOB },
-  { "job-page-limit",          IPP_TAG_INTEGER,        IPP_TAG_JOB },
-  { "job-priority",            IPP_TAG_INTEGER,        IPP_TAG_JOB },
-  { "job-quota-period",                IPP_TAG_INTEGER,        IPP_TAG_JOB },
-  { "job-uuid",                        IPP_TAG_URI,            IPP_TAG_JOB },
-  { "landscape",               IPP_TAG_BOOLEAN,        IPP_TAG_JOB },
-  { "media",                   IPP_TAG_KEYWORD,        IPP_TAG_JOB },
-  { "mirror",                  IPP_TAG_BOOLEAN,        IPP_TAG_JOB },
-  { "mirror-default",          IPP_TAG_BOOLEAN,        IPP_TAG_PRINTER },
-  { "natural-scaling",         IPP_TAG_INTEGER,        IPP_TAG_JOB },
-  { "natural-scaling-default", IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
-  { "notify-charset",          IPP_TAG_CHARSET,        IPP_TAG_SUBSCRIPTION },
-  { "notify-events",           IPP_TAG_KEYWORD,        IPP_TAG_SUBSCRIPTION },
-  { "notify-events-default",   IPP_TAG_KEYWORD,        IPP_TAG_PRINTER },
-  { "notify-lease-duration",   IPP_TAG_INTEGER,        IPP_TAG_SUBSCRIPTION },
-  { "notify-lease-duration-default", IPP_TAG_INTEGER,  IPP_TAG_PRINTER },
-  { "notify-natural-language", IPP_TAG_LANGUAGE,       IPP_TAG_SUBSCRIPTION },
-  { "notify-pull-method",      IPP_TAG_KEYWORD,        IPP_TAG_SUBSCRIPTION },
-  { "notify-recipient-uri",    IPP_TAG_URI,            IPP_TAG_SUBSCRIPTION },
-  { "notify-time-interval",    IPP_TAG_INTEGER,        IPP_TAG_SUBSCRIPTION },
-  { "notify-user-data",                IPP_TAG_STRING,         IPP_TAG_SUBSCRIPTION },
-  { "number-up",               IPP_TAG_INTEGER,        IPP_TAG_JOB },
-  { "number-up-default",       IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
-  { "orientation-requested",   IPP_TAG_ENUM,           IPP_TAG_JOB },
-  { "orientation-requested-default", IPP_TAG_ENUM,     IPP_TAG_PRINTER },
-  { "page-bottom",             IPP_TAG_INTEGER,        IPP_TAG_JOB },
-  { "page-bottom-default",     IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
-  { "page-left",               IPP_TAG_INTEGER,        IPP_TAG_JOB },
-  { "page-left-default",       IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
-  { "page-ranges",             IPP_TAG_RANGE,          IPP_TAG_JOB },
-  { "page-ranges-default",     IPP_TAG_RANGE,          IPP_TAG_PRINTER },
-  { "page-right",              IPP_TAG_INTEGER,        IPP_TAG_JOB },
-  { "page-right-default",      IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
-  { "page-top",                        IPP_TAG_INTEGER,        IPP_TAG_JOB },
-  { "page-top-default",                IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
-  { "penwidth",                        IPP_TAG_INTEGER,        IPP_TAG_JOB },
-  { "penwidth-default",                IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
-  { "ppi",                     IPP_TAG_INTEGER,        IPP_TAG_JOB },
-  { "ppi-default",             IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
-  { "prettyprint",             IPP_TAG_BOOLEAN,        IPP_TAG_JOB },
-  { "prettyprint-default",     IPP_TAG_BOOLEAN,        IPP_TAG_PRINTER },
-  { "print-quality",           IPP_TAG_ENUM,           IPP_TAG_JOB },
-  { "print-quality-default",   IPP_TAG_ENUM,           IPP_TAG_PRINTER },
-  { "printer-error-policy",    IPP_TAG_NAME,           IPP_TAG_PRINTER },
-  { "printer-info",            IPP_TAG_TEXT,           IPP_TAG_PRINTER },
-  { "printer-is-accepting-jobs",IPP_TAG_BOOLEAN,       IPP_TAG_PRINTER },
-  { "printer-is-shared",       IPP_TAG_BOOLEAN,        IPP_TAG_PRINTER },
-  { "printer-location",                IPP_TAG_TEXT,           IPP_TAG_PRINTER },
-  { "printer-make-and-model",  IPP_TAG_TEXT,           IPP_TAG_PRINTER },
-  { "printer-more-info",       IPP_TAG_URI,            IPP_TAG_PRINTER },
-  { "printer-op-policy",       IPP_TAG_NAME,           IPP_TAG_PRINTER },
-  { "printer-resolution",      IPP_TAG_RESOLUTION,     IPP_TAG_JOB },
-  { "printer-state",           IPP_TAG_ENUM,           IPP_TAG_PRINTER },
-  { "printer-state-change-time",IPP_TAG_INTEGER,       IPP_TAG_PRINTER },
-  { "printer-state-reasons",   IPP_TAG_KEYWORD,        IPP_TAG_PRINTER },
-  { "printer-type",            IPP_TAG_ENUM,           IPP_TAG_PRINTER },
-  { "printer-uri",             IPP_TAG_URI,            IPP_TAG_OPERATION },
-  { "queued-job-count",                IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
-  { "raw",                     IPP_TAG_MIMETYPE,       IPP_TAG_OPERATION },
-  { "requesting-user-name-allowed",    IPP_TAG_NAME,   IPP_TAG_PRINTER },
-  { "requesting-user-name-denied",     IPP_TAG_NAME,   IPP_TAG_PRINTER },
-  { "resolution",              IPP_TAG_RESOLUTION,     IPP_TAG_JOB },
-  { "resolution-default",      IPP_TAG_RESOLUTION,     IPP_TAG_PRINTER },
-  { "saturation",              IPP_TAG_INTEGER,        IPP_TAG_JOB },
-  { "saturation-default",      IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
-  { "scaling",                 IPP_TAG_INTEGER,        IPP_TAG_JOB },
-  { "scaling-default",         IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
-  { "sides",                   IPP_TAG_KEYWORD,        IPP_TAG_JOB },
-  { "sides-default",           IPP_TAG_KEYWORD,        IPP_TAG_PRINTER },
-  { "wrap",                    IPP_TAG_BOOLEAN,        IPP_TAG_JOB },
-  { "wrap-default",            IPP_TAG_BOOLEAN,        IPP_TAG_PRINTER }
+  { 1, "auth-info",            IPP_TAG_TEXT,           IPP_TAG_JOB },
+  { 1, "auth-info-required",   IPP_TAG_KEYWORD,        IPP_TAG_PRINTER },
+  { 0, "blackplot",            IPP_TAG_BOOLEAN,        IPP_TAG_JOB },
+  { 0, "blackplot-default",    IPP_TAG_BOOLEAN,        IPP_TAG_PRINTER },
+  { 0, "brightness",           IPP_TAG_INTEGER,        IPP_TAG_JOB },
+  { 0, "brightness-default",   IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
+  { 0, "columns",              IPP_TAG_INTEGER,        IPP_TAG_JOB },
+  { 0, "columns-default",      IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
+  { 0, "compression",          IPP_TAG_KEYWORD,        IPP_TAG_OPERATION },
+  { 0, "copies",               IPP_TAG_INTEGER,        IPP_TAG_JOB },
+  { 0, "copies-default",       IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
+  { 0, "device-uri",           IPP_TAG_URI,            IPP_TAG_PRINTER },
+  { 0, "document-format",      IPP_TAG_MIMETYPE,       IPP_TAG_OPERATION },
+  { 0, "document-format-default", IPP_TAG_MIMETYPE,    IPP_TAG_PRINTER },
+  { 1, "exclude-schemes",      IPP_TAG_NAME,           IPP_TAG_OPERATION },
+  { 1, "finishings",           IPP_TAG_ENUM,           IPP_TAG_JOB },
+  { 1, "finishings-default",   IPP_TAG_ENUM,           IPP_TAG_PRINTER },
+  { 0, "fit-to-page",          IPP_TAG_BOOLEAN,        IPP_TAG_JOB },
+  { 0, "fit-to-page-default",  IPP_TAG_BOOLEAN,        IPP_TAG_PRINTER },
+  { 0, "fitplot",              IPP_TAG_BOOLEAN,        IPP_TAG_JOB },
+  { 0, "fitplot-default",      IPP_TAG_BOOLEAN,        IPP_TAG_PRINTER },
+  { 0, "gamma",                        IPP_TAG_INTEGER,        IPP_TAG_JOB },
+  { 0, "gamma-default",                IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
+  { 0, "hue",                  IPP_TAG_INTEGER,        IPP_TAG_JOB },
+  { 0, "hue-default",          IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
+  { 1, "include-schemes",      IPP_TAG_NAME,           IPP_TAG_OPERATION },
+  { 0, "job-impressions",      IPP_TAG_INTEGER,        IPP_TAG_JOB },
+  { 0, "job-k-limit",          IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
+  { 0, "job-page-limit",       IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
+  { 0, "job-priority",         IPP_TAG_INTEGER,        IPP_TAG_JOB },
+  { 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 },
+  { 0, "job-uuid",             IPP_TAG_URI,            IPP_TAG_JOB },
+  { 0, "landscape",            IPP_TAG_BOOLEAN,        IPP_TAG_JOB },
+  { 1, "marker-change-time",   IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
+  { 1, "marker-colors",                IPP_TAG_NAME,           IPP_TAG_PRINTER },
+  { 1, "marker-high-levels",   IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
+  { 1, "marker-levels",                IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
+  { 1, "marker-low-levels",    IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
+  { 0, "marker-message",       IPP_TAG_TEXT,           IPP_TAG_PRINTER },
+  { 1, "marker-names",         IPP_TAG_NAME,           IPP_TAG_PRINTER },
+  { 1, "marker-types",         IPP_TAG_KEYWORD,        IPP_TAG_PRINTER },
+  { 1, "media",                        IPP_TAG_KEYWORD,        IPP_TAG_JOB },
+  { 0, "media-col",            IPP_TAG_BEGIN_COLLECTION, IPP_TAG_JOB },
+  { 0, "media-col-default",    IPP_TAG_BEGIN_COLLECTION, IPP_TAG_PRINTER },
+  { 0, "media-color",          IPP_TAG_KEYWORD,        IPP_TAG_JOB },
+  { 1, "media-default",                IPP_TAG_KEYWORD,        IPP_TAG_PRINTER },
+  { 0, "media-key",            IPP_TAG_KEYWORD,        IPP_TAG_JOB },
+  { 0, "media-size",           IPP_TAG_BEGIN_COLLECTION, IPP_TAG_JOB },
+  { 0, "media-type",           IPP_TAG_KEYWORD,        IPP_TAG_JOB },
+  { 0, "mirror",               IPP_TAG_BOOLEAN,        IPP_TAG_JOB },
+  { 0, "mirror-default",       IPP_TAG_BOOLEAN,        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 },
+  { 1, "notify-events",                IPP_TAG_KEYWORD,        IPP_TAG_SUBSCRIPTION },
+  { 1, "notify-events-default",        IPP_TAG_KEYWORD,        IPP_TAG_PRINTER },
+  { 0, "notify-lease-duration",        IPP_TAG_INTEGER,        IPP_TAG_SUBSCRIPTION },
+  { 0, "notify-lease-duration-default", IPP_TAG_INTEGER, IPP_TAG_PRINTER },
+  { 0, "notify-natural-language", IPP_TAG_LANGUAGE,    IPP_TAG_SUBSCRIPTION },
+  { 0, "notify-pull-method",   IPP_TAG_KEYWORD,        IPP_TAG_SUBSCRIPTION },
+  { 0, "notify-recipient-uri", IPP_TAG_URI,            IPP_TAG_SUBSCRIPTION },
+  { 0, "notify-time-interval", IPP_TAG_INTEGER,        IPP_TAG_SUBSCRIPTION },
+  { 0, "notify-user-data",     IPP_TAG_STRING,         IPP_TAG_SUBSCRIPTION },
+  { 0, "number-up",            IPP_TAG_INTEGER,        IPP_TAG_JOB },
+  { 0, "number-up-default",    IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
+  { 0, "orientation-requested",        IPP_TAG_ENUM,           IPP_TAG_JOB },
+  { 0, "orientation-requested-default", IPP_TAG_ENUM,  IPP_TAG_PRINTER },
+  { 0, "page-bottom",          IPP_TAG_INTEGER,        IPP_TAG_JOB },
+  { 0, "page-bottom-default",  IPP_TAG_INTEGER,        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 },
+  { 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 },
+  { 0, "page-top-default",     IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
+  { 0, "penwidth",             IPP_TAG_INTEGER,        IPP_TAG_JOB },
+  { 0, "penwidth-default",     IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
+  { 0, "port-monitor",         IPP_TAG_NAME,           IPP_TAG_PRINTER },
+  { 0, "ppi",                  IPP_TAG_INTEGER,        IPP_TAG_JOB },
+  { 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-quality",                IPP_TAG_ENUM,           IPP_TAG_JOB },
+  { 0, "print-quality-default",        IPP_TAG_ENUM,           IPP_TAG_PRINTER },
+  { 1, "printer-commands",     IPP_TAG_KEYWORD,        IPP_TAG_PRINTER },
+  { 0, "printer-error-policy", IPP_TAG_NAME,           IPP_TAG_PRINTER },
+  { 0, "printer-info",         IPP_TAG_TEXT,           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-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 },
+  { 0, "printer-resolution",   IPP_TAG_RESOLUTION,     IPP_TAG_JOB },
+  { 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 },
+  { 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 },
+  { 0, "queued-job-count",     IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
+  { 0, "raw",                  IPP_TAG_MIMETYPE,       IPP_TAG_OPERATION },
+  { 1, "requested-attributes", IPP_TAG_NAME,           IPP_TAG_OPERATION },
+  { 1, "requesting-user-name-allowed", IPP_TAG_NAME,   IPP_TAG_PRINTER },
+  { 1, "requesting-user-name-denied", IPP_TAG_NAME,    IPP_TAG_PRINTER },
+  { 0, "resolution",           IPP_TAG_RESOLUTION,     IPP_TAG_JOB },
+  { 0, "resolution-default",   IPP_TAG_RESOLUTION,     IPP_TAG_PRINTER },
+  { 0, "saturation",           IPP_TAG_INTEGER,        IPP_TAG_JOB },
+  { 0, "saturation-default",   IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
+  { 0, "scaling",              IPP_TAG_INTEGER,        IPP_TAG_JOB },
+  { 0, "scaling-default",      IPP_TAG_INTEGER,        IPP_TAG_PRINTER },
+  { 0, "sides",                        IPP_TAG_KEYWORD,        IPP_TAG_JOB },
+  { 0, "sides-default",                IPP_TAG_KEYWORD,        IPP_TAG_PRINTER },
+  { 0, "wrap",                 IPP_TAG_BOOLEAN,        IPP_TAG_JOB },
+  { 0, "wrap-default",         IPP_TAG_BOOLEAN,        IPP_TAG_PRINTER },
+  { 0, "x-dimension",          IPP_TAG_INTEGER,        IPP_TAG_JOB },
+  { 0, "y-dimension",          IPP_TAG_INTEGER,        IPP_TAG_JOB }
 };
 
 
@@ -166,7 +187,7 @@ cupsEncodeOptions(ipp_t         *ipp,               /* I - Request to add to */
                  int           num_options,    /* I - Number of options */
                  cups_option_t *options)       /* I - Options */
 {
-  DEBUG_printf(("cupsEncodeOptions(%p, %d, %p)\n", ipp, num_options, options));
+  DEBUG_printf(("cupsEncodeOptions(%p, %d, %p)", ipp, num_options, options));
 
  /*
   * Add the options in the proper groups & order...
@@ -185,7 +206,7 @@ cupsEncodeOptions(ipp_t         *ipp,               /* I - Request to add to */
  * function multiple times for each group, or use cupsEncodeOptions()
  * to add the standard groups.
  *
- * @since CUPS 1.2@
+ * @since CUPS 1.2/Mac OS X 10.5@
  */
 
 void
@@ -200,14 +221,18 @@ cupsEncodeOptions2(
   char         *s,                     /* Pointer into option value */
                *val,                   /* Pointer to option value */
                *copy,                  /* Copy of option value */
-               *sep;                   /* Option separator */
+               *sep,                   /* Option separator */
+               quote;                  /* Quote character */
   ipp_attribute_t *attr;               /* IPP attribute */
   ipp_tag_t    value_tag;              /* IPP value tag */
   cups_option_t        *option;                /* Current option */
+  ipp_t                *collection;            /* Collection value */
+  int          num_cols;               /* Number of collection values */
+  cups_option_t        *cols;                  /* Collection values */
 
 
   DEBUG_printf(("cupsEncodeOptions2(ipp=%p, num_options=%d, options=%p, "
-                "group_tag=%x)\n", ipp, num_options, options, group_tag));
+                "group_tag=%x)", ipp, num_options, options, group_tag));
 
  /*
   * Range check input...
@@ -292,43 +317,30 @@ cupsEncodeOptions2(
     * Count the number of values...
     */
 
-    for (count = 1, sep = option->value; *sep; sep ++)
+    if (match && match->multivalue)
     {
-      if (*sep == '\'')
-      {
-       /*
-        * Skip quoted option value...
-       */
-
-        sep ++;
-
-        while (*sep && *sep != '\'')
-         sep ++;
-
-       if (!*sep)
-         sep --;
-      }
-      else if (*sep == '\"')
+      for (count = 1, sep = option->value, quote = 0; *sep; sep ++)
       {
-       /*
-        * Skip quoted option value...
-       */
-
-        sep ++;
-
-        while (*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 ++;
-
-       if (!*sep)
-         sep --;
       }
-      else if (*sep == ',')
-        count ++;
-      else if (*sep == '\\' && sep[1])
-        sep ++;
     }
+    else
+      count = 1;
 
-    DEBUG_printf(("cupsEncodeOptions2: option = \'%s\', count = %d\n",
+    DEBUG_printf(("2cupsEncodeOptions2: option=\"%s\", count=%d",
                   option->name, count));
 
    /*
@@ -341,7 +353,7 @@ cupsEncodeOptions2(
       * Ran out of memory!
       */
 
-      DEBUG_puts("cupsEncodeOptions2: Ran out of memory for attributes!");
+      DEBUG_puts("1cupsEncodeOptions2: Ran out of memory for attributes!");
       return;
     }
 
@@ -356,15 +368,7 @@ cupsEncodeOptions2(
     * Copy the name over...
     */
 
-    if ((attr->name = _cupsStrAlloc(option->name)) == NULL)
-    {
-     /*
-      * Ran out of memory!
-      */
-
-      DEBUG_puts("cupsEncodeOptions2: Ran out of memory for name!");
-      return;
-    }
+    attr->name = _cupsStrAlloc(option->name);
 
     if (count > 1)
     {
@@ -378,7 +382,8 @@ cupsEncodeOptions2(
        * Ran out of memory!
        */
 
-       DEBUG_puts("cupsEncodeOptions2: Ran out of memory for value copy!");
+       DEBUG_puts("1cupsEncodeOptions2: Ran out of memory for value copy!");
+       ippDeleteAttribute(ipp, attr);
        return;
       }
 
@@ -398,16 +403,47 @@ cupsEncodeOptions2(
     * Scan the value string for values...
     */
 
-    for (j = 0; j < count; val = sep, j ++)
+    for (j = 0, sep = val; j < count; val = sep, j ++)
     {
      /*
       * Find the end of this value and mark it if needed...
       */
 
-      if ((sep = strchr(val, ',')) != NULL)
-       *sep++ = '\0';
-      else
-       sep = val + strlen(val);
+      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...
@@ -421,10 +457,10 @@ cupsEncodeOptions2(
            * Integer/enumeration value...
            */
 
-            attr->values[j].integer = strtol(val, &s, 0);
+            attr->values[j].integer = strtol(val, &s, 10);
 
-            DEBUG_printf(("cupsEncodeOptions2: Added integer option value %d...\n",
-                         attr->values[j].integer));
+            DEBUG_printf(("2cupsEncodeOptions2: Added integer option value "
+                         "%d...", attr->values[j].integer));
             break;
 
        case IPP_TAG_BOOLEAN :
@@ -438,7 +474,7 @@ cupsEncodeOptions2(
 
              attr->values[j].boolean = 1;
 
-              DEBUG_puts("cupsEncodeOptions2: Added boolean true value...");
+              DEBUG_puts("2cupsEncodeOptions2: Added boolean true value...");
            }
            else
            {
@@ -448,7 +484,7 @@ cupsEncodeOptions2(
 
              attr->values[j].boolean = 0;
 
-              DEBUG_puts("cupsEncodeOptions2: Added boolean false value...");
+              DEBUG_puts("2cupsEncodeOptions2: Added boolean false value...");
            }
             break;
 
@@ -463,20 +499,20 @@ cupsEncodeOptions2(
              s = val;
            }
            else
-             attr->values[j].range.lower = strtol(val, &s, 0);
+             attr->values[j].range.lower = strtol(val, &s, 10);
 
            if (*s == '-')
            {
              if (s[1])
-               attr->values[j].range.upper = strtol(s + 1, NULL, 0);
+               attr->values[j].range.upper = 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(("cupsEncodeOptions2: Added range option value %d-%d...\n",
-                         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;
 
@@ -485,10 +521,10 @@ cupsEncodeOptions2(
            * Resolution...
            */
 
-           attr->values[j].resolution.xres = strtol(val, &s, 0);
+           attr->values[j].resolution.xres = strtol(val, &s, 10);
 
            if (*s == 'x')
-             attr->values[j].resolution.yres = strtol(s + 1, &s, 0);
+             attr->values[j].resolution.yres = strtol(s + 1, &s, 10);
            else
              attr->values[j].resolution.yres = attr->values[j].resolution.xres;
 
@@ -497,8 +533,8 @@ cupsEncodeOptions2(
             else
               attr->values[j].resolution.units = IPP_RES_PER_INCH;
 
-           DEBUG_printf(("cupsEncodeOptions2: Added resolution option value %s...\n",
-                         val));
+           DEBUG_printf(("2cupsEncodeOptions2: Added resolution option value "
+                         "%s...", val));
             break;
 
        case IPP_TAG_STRING :
@@ -507,24 +543,51 @@ cupsEncodeOptions2(
            */
 
             attr->values[j].unknown.length = (int)strlen(val);
-           attr->values[j].unknown.data   = _cupsStrAlloc(val);
+           attr->values[j].unknown.data   = strdup(val);
 
-            DEBUG_printf(("cupsEncodeOptions2: Added octet-string value \"%s\"...\n",
-                         attr->values[j].unknown.data));
+            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)
+           if ((attr->values[j].string.text = _cupsStrAlloc(val)) == NULL)
            {
             /*
              * Ran out of memory!
              */
 
-             DEBUG_puts("cupsEncodeOptions2: Ran out of memory for string!");
+             DEBUG_puts("1cupsEncodeOptions2: Ran out of memory for string!");
+
+             if (copy)
+               free(copy);
+
+             ippDeleteAttribute(ipp, attr);
              return;
            }
 
-           DEBUG_printf(("cupsEncodeOptions2: Added string value \"%s\"...\n",
+           DEBUG_printf(("2cupsEncodeOptions2: Added string value \"%s\"...",
                          val));
             break;
       }
@@ -573,5 +636,5 @@ compare_ipp_options(_ipp_option_t *a,       /* I - First option */
 
 
 /*
- * End of "$Id: encode.c 6386 2007-03-23 19:03:01Z mike $".
+ * End of "$Id: encode.c 7696 2008-06-26 00:54:42Z mike $".
  */