]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Factor out the option to IPP attribute encoding code into a new private API.
authorMichael R Sweet <michaelrsweet@gmail.com>
Thu, 14 Dec 2017 19:23:51 +0000 (14:23 -0500)
committerMichael R Sweet <michaelrsweet@gmail.com>
Thu, 14 Dec 2017 19:23:51 +0000 (14:23 -0500)
cups/cups-private.h
cups/encode.c

index 2f65faf7cd94a7800539602a58af789c779947ac..847f5e32adc19294b6be9fc537248b4a5de13b76 100644 (file)
@@ -231,6 +231,7 @@ extern void         _cupsBufferRelease(char *b);
 
 extern http_t          *_cupsConnect(void);
 extern char            *_cupsCreateDest(const char *name, const char *info, const char *device_id, const char *device_uri, char *uri, size_t urisize);
+extern void            _cupsEncodeOption(ipp_t *ipp, ipp_tag_t group_tag, _ipp_option_t *map, const char *name, const char *value);
 extern int             _cupsGet1284Values(const char *device_id,
                                           cups_option_t **values);
 extern const char      *_cupsGetDestResource(cups_dest_t *dest, char *resource,
index dddf6522b2526bea748eef247f9dc24270ec7410..55152690d438a228dacc44478766fde4995f7c9f 100644 (file)
@@ -150,14 +150,16 @@ static const _ipp_option_t ipp_options[] =
   { 0, "job-cancel-after-default", IPP_TAG_INTEGER,    IPP_TAG_PRINTER },
   { 0, "job-hold-until",       IPP_TAG_KEYWORD,        IPP_TAG_JOB },
   { 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-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 },
@@ -183,6 +185,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 },
@@ -191,8 +195,18 @@ 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 },
@@ -319,6 +333,297 @@ static const _ipp_option_t ipp_options[] =
 static int     compare_ipp_options(_ipp_option_t *a, _ipp_option_t *b);
 
 
+/*
+ * '_cupsEncodeOption()' - Encode a single option as an IPP attribute.
+ */
+
+void
+_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 */
+                       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));
+
+ /*
+  * Figure out the attribute syntax for encoding...
+  */
+
+  if (!map)
+    map = _ippFindOption(name);
+
+  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;
+
+ /*
+  * Count the number of values...
+  */
+
+  if (map && map->multivalue)
+  {
+    for (count = 1, sep = (char *)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(("2_cupsEncodeOption: value_tag=%s, count=%d", ippTagString(value_tag), count));
+
+ /*
+  * Allocate memory for the attribute values...
+  */
+
+  if ((attr = ippAddStrings(ipp, group_tag, value_tag, name, count, NULL, NULL)) == NULL)
+  {
+   /*
+    * Ran out of memory!
+    */
+
+    DEBUG_puts("1_cupsEncodeOption: Ran out of memory for attributes.");
+    return;
+  }
+
+  if (count > 1)
+  {
+   /*
+    * Make a copy of the value we can fiddle with...
+    */
+
+    if ((copy = strdup(value)) == NULL)
+    {
+     /*
+      * Ran out of memory!
+      */
+
+      DEBUG_puts("1_cupsEncodeOption: 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  = (char *)value;
+    copy = NULL;
+  }
+
+ /*
+  * Scan the value string for values...
+  */
+
+  for (i = 0, sep = val; i < count; val = sep, i ++)
+  {
+   /*
+    * 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...
+         */
+
+         memmove(sep, sep + 1, strlen(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...
+         */
+
+         ippSetInteger(ipp, &attr, i, (int)strtol(val, &s, 10));
+         break;
+
+      case IPP_TAG_BOOLEAN :
+         if (!_cups_strcasecmp(val, "true") || !_cups_strcasecmp(val, "on") || !_cups_strcasecmp(val, "yes"))
+         {
+          /*
+           * Boolean value - true...
+           */
+
+            ippSetBoolean(ipp, &attr, i, 1);
+         }
+         else
+         {
+          /*
+           * Boolean value - false...
+           */
+
+            ippSetBoolean(ipp, &attr, i, 0);
+         }
+         break;
+
+      case IPP_TAG_RANGE :
+          {
+          /*
+           * Range...
+           */
+
+           int lower, upper;           /* Lower and upper ranges... */
+
+           if (*val == '-')
+           {
+             lower = 1;
+             s     = val;
+           }
+           else
+             lower = (int)strtol(val, &s, 10);
+
+           if (*s == '-')
+           {
+             if (s[1])
+               upper = (int)strtol(s + 1, NULL, 10);
+             else
+               upper = 2147483647;
+           }
+           else
+             upper = lower;
+
+            ippSetRange(ipp, &attr, i, lower, upper);
+         }
+         break;
+
+      case IPP_TAG_RESOLUTION :
+          {
+          /*
+           * Resolution...
+           */
+           int         xres, yres;     /* Resolution values */
+           ipp_res_t   units;          /* Resolution units */
+
+           xres = (int)strtol(val, &s, 10);
+
+           if (*s == 'x')
+             yres = (int)strtol(s + 1, &s, 10);
+           else
+             yres = xres;
+
+           if (!_cups_strcasecmp(s, "dpc") || !_cups_strcasecmp(s, "dpcm"))
+             units = IPP_RES_PER_CM;
+           else
+             units = IPP_RES_PER_INCH;
+
+           ippSetResolution(ipp, &attr, i, units, xres, yres);
+          }
+         break;
+
+      case IPP_TAG_STRING :
+        /*
+         * octetString
+         */
+
+          ippSetOctetString(ipp, &attr, i, val, (int)strlen(val));
+         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;
+         }
+
+         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;
+    }
+  }
+
+  if (copy)
+    free(copy);
+}
+
+
 /*
  * 'cupsEncodeOptions()' - Encode printer options into IPP attributes.
  *
@@ -361,19 +666,10 @@ cupsEncodeOptions2(
     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 */
+  int                  i;              /* Looping var */
+  char                 *val;           /* Pointer to option value */
   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 */
   ipp_op_t             op;             /* Operation for this request */
   const ipp_op_t       *ops;           /* List of allowed operations */
 
@@ -393,24 +689,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");
   }
 
  /*
@@ -421,14 +711,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;
 
    /*
@@ -462,12 +749,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)
        {
@@ -488,8 +772,7 @@ cupsEncodeOptions2(
       else
         ops = ipp_set_printer;
 
-      if (!_cups_strcasecmp(option->value, "true") ||
-          !_cups_strcasecmp(option->value, "false"))
+      if (!_cups_strcasecmp(option->value, "true") || !_cups_strcasecmp(option->value, "false"))
        value_tag = IPP_TAG_BOOLEAN;
       else
        value_tag = IPP_TAG_NAME;
@@ -511,277 +794,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 += 2;
-      }
-    }
-    else
-      count = 1;
-
-    DEBUG_printf(("2cupsEncodeOptions2: option=\"%s\", value=\"%s\", count=%d", option->name, option->value, 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...
-           */
-
-           memmove(sep, sep + 1, strlen(sep));
-           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);
   }
 }