]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/ipp.c
Load cups into easysw/current.
[thirdparty/cups.git] / cups / ipp.c
index be6f0bbc96965a4aae3eba5e33220d05fd98c178..cc22e2bf5ca3640cfe8686dae11d9de08efb7b59 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: ipp.c 5023 2006-01-29 14:39:44Z mike $"
+ * "$Id$"
  *
  *   Internet Printing Protocol support functions for the Common UNIX
  *   Printing System (CUPS).
@@ -57,8 +57,8 @@
  *                            connection.
  *   ippWriteFile()         - Write data for an IPP message to a file.
  *   ippWriteIO()           - Write data for an IPP message.
- *   _ipp_add_attr()        - Add a new attribute to the request.
- *   _ipp_free_attr()       - Free an attribute.
+ *   _ippAddAttr()          - Add a new attribute to the request.
+ *   _ippFreeAttr()         - Free an attribute.
  *   ipp_length()           - Compute the length of an IPP message or
  *                            collection value.
  *   ipp_read_http()        - Semi-blocking read on a HTTP connection...
@@ -111,10 +111,10 @@ ippAddBoolean(ipp_t      *ipp,            /* I - IPP message */
   if (ipp == NULL || name == NULL)
     return (NULL);
 
-  if ((attr = _ipp_add_attr(ipp, 1)) == NULL)
+  if ((attr = _ippAddAttr(ipp, 1)) == NULL)
     return (NULL);
 
-  attr->name              = strdup(name);
+  attr->name              = _cupsStrAlloc(name);
   attr->group_tag         = group;
   attr->value_tag         = IPP_TAG_BOOLEAN;
   attr->values[0].boolean = value;
@@ -145,10 +145,10 @@ ippAddBooleans(ipp_t      *ipp,           /* I - IPP message */
   if (ipp == NULL || name == NULL || num_values < 1)
     return (NULL);
 
-  if ((attr = _ipp_add_attr(ipp, num_values)) == NULL)
+  if ((attr = _ippAddAttr(ipp, num_values)) == NULL)
     return (NULL);
 
-  attr->name      = strdup(name);
+  attr->name      = _cupsStrAlloc(name);
   attr->group_tag = group;
   attr->value_tag = IPP_TAG_BOOLEAN;
 
@@ -183,10 +183,10 @@ ippAddCollection(ipp_t      *ipp, /* I - IPP message */
   if (ipp == NULL || name == NULL)
     return (NULL);
 
-  if ((attr = _ipp_add_attr(ipp, 1)) == NULL)
+  if ((attr = _ippAddAttr(ipp, 1)) == NULL)
     return (NULL);
 
-  attr->name                 = strdup(name);
+  attr->name                 = _cupsStrAlloc(name);
   attr->group_tag            = group;
   attr->value_tag            = IPP_TAG_BEGIN_COLLECTION;
   attr->values[0].collection = value;
@@ -220,10 +220,10 @@ ippAddCollections(
   if (ipp == NULL || name == NULL || num_values < 1)
     return (NULL);
 
-  if ((attr = _ipp_add_attr(ipp, num_values)) == NULL)
+  if ((attr = _ippAddAttr(ipp, num_values)) == NULL)
     return (NULL);
 
-  attr->name      = strdup(name);
+  attr->name      = _cupsStrAlloc(name);
   attr->group_tag = group;
   attr->value_tag = IPP_TAG_BEGIN_COLLECTION;
 
@@ -256,10 +256,10 @@ ippAddDate(ipp_t             *ipp,        /* I - IPP message */
   if (ipp == NULL || name == NULL || value == NULL)
     return (NULL);
 
-  if ((attr = _ipp_add_attr(ipp, 1)) == NULL)
+  if ((attr = _ippAddAttr(ipp, 1)) == NULL)
     return (NULL);
 
-  attr->name      = strdup(name);
+  attr->name      = _cupsStrAlloc(name);
   attr->group_tag = group;
   attr->value_tag = IPP_TAG_DATE;
   memcpy(attr->values[0].date, value, 11);
@@ -288,10 +288,10 @@ ippAddInteger(ipp_t      *ipp,            /* I - IPP message */
   if (ipp == NULL || name == NULL)
     return (NULL);
 
-  if ((attr = _ipp_add_attr(ipp, 1)) == NULL)
+  if ((attr = _ippAddAttr(ipp, 1)) == NULL)
     return (NULL);
 
-  attr->name              = strdup(name);
+  attr->name              = _cupsStrAlloc(name);
   attr->group_tag         = group;
   attr->value_tag         = type;
   attr->values[0].integer = value;
@@ -320,10 +320,10 @@ ippAddIntegers(ipp_t      *ipp,           /* I - IPP message */
   if (ipp == NULL || name == NULL || num_values < 1)
     return (NULL);
 
-  if ((attr = _ipp_add_attr(ipp, num_values)) == NULL)
+  if ((attr = _ippAddAttr(ipp, num_values)) == NULL)
     return (NULL);
 
-  attr->name      = strdup(name);
+  attr->name      = _cupsStrAlloc(name);
   attr->group_tag = group;
   attr->value_tag = type;
 
@@ -356,14 +356,14 @@ ippAddOctetString(ipp_t      *ipp,        /* I - IPP message */
   if (ipp == NULL || name == NULL)
     return (NULL);
 
-  if ((attr = _ipp_add_attr(ipp, 1)) == NULL)
+  if ((attr = _ippAddAttr(ipp, 1)) == NULL)
     return (NULL);
 
  /*
   * Initialize the attribute data...
   */
 
-  attr->name                     = strdup(name);
+  attr->name                     = _cupsStrAlloc(name);
   attr->group_tag                = group;
   attr->value_tag                = IPP_TAG_STRING;
   attr->values[0].unknown.length = datalen;
@@ -395,50 +395,51 @@ ippAddString(ipp_t      *ipp,             /* I - IPP message */
              const char *value)                /* I - Value */
 {
   ipp_attribute_t      *attr;          /* New attribute */
+  char                 buffer[1024],   /* Language/charset value buffer */
+                       *bufptr;        /* Pointer into buffer */
 
 
   if (ipp == NULL || name == NULL)
     return (NULL);
 
-  if ((attr = _ipp_add_attr(ipp, 1)) == NULL)
+  if ((attr = _ippAddAttr(ipp, 1)) == NULL)
     return (NULL);
 
  /*
   * Force value to be English for the POSIX locale...
   */
 
-  if (type == IPP_TAG_LANGUAGE && strcasecmp(value, "C") == 0)
+  if (type == IPP_TAG_LANGUAGE && !strcasecmp(value, "C"))
     value = "en";
 
- /*
-  * Initialize the attribute data...
-  */
-
-  attr->name                      = strdup(name);
-  attr->group_tag                 = group;
-  attr->value_tag                 = type;
-  attr->values[0].string.charset  = ((int)type & IPP_TAG_COPY) ? (char *)charset :
-                                    charset ? strdup(charset) : NULL;
-  attr->values[0].string.text     = ((int)type & IPP_TAG_COPY) ? (char *)value :
-                                    value ? strdup(value) : NULL;
-
  /*
   * Convert language values to lowercase and change _ to - as needed...
   */
 
-  if ((type == IPP_TAG_LANGUAGE || type == IPP_TAG_CHARSET) &&
-      attr->values[0].string.text)
+  if ((type == IPP_TAG_LANGUAGE || type == IPP_TAG_CHARSET) && value)
   {
-    char *p;
+    strlcpy(buffer, value, sizeof(buffer));
+    value = buffer;
 
-
-    for (p = attr->values[0].string.text; *p; p ++)
-      if (*p == '_')
-        *p = '-';
+    for (bufptr = buffer; *bufptr; bufptr ++)
+      if (*bufptr == '_')
+        *bufptr = '-';
       else
-        *p = tolower(*p & 255);
+        *bufptr = tolower(*bufptr & 255);
   }
 
+ /*
+  * Initialize the attribute data...
+  */
+
+  attr->name                     = _cupsStrAlloc(name);
+  attr->group_tag                = group;
+  attr->value_tag                = type;
+  attr->values[0].string.charset = ((int)type & IPP_TAG_COPY) ? (char *)charset :
+                                   charset ? _cupsStrAlloc(charset) : NULL;
+  attr->values[0].string.text    = ((int)type & IPP_TAG_COPY) ? (char *)value :
+                                   value ? _cupsStrAlloc(value) : NULL;
+
   return (attr);
 }
 
@@ -465,14 +466,14 @@ ippAddStrings(
   if (ipp == NULL || name == NULL || num_values < 1)
     return (NULL);
 
-  if ((attr = _ipp_add_attr(ipp, num_values)) == NULL)
+  if ((attr = _ippAddAttr(ipp, num_values)) == NULL)
     return (NULL);
 
  /*
   * Initialize the attribute data...
   */
 
-  attr->name      = strdup(name);
+  attr->name      = _cupsStrAlloc(name);
   attr->group_tag = group;
   attr->value_tag = type;
 
@@ -482,7 +483,7 @@ ippAddStrings(
   {
     if (i == 0)
       value->string.charset = ((int)type & IPP_TAG_COPY) ? (char *)charset :
-                                   charset ? strdup(charset) : NULL;
+                                   charset ? _cupsStrAlloc(charset) : NULL;
     else
       value->string.charset = attr->values[0].string.charset;
 
@@ -492,12 +493,12 @@ ippAddStrings(
       * Force language to be English for the POSIX locale...
       */
 
-      if (type == IPP_TAG_LANGUAGE && strcasecmp(values[i], "C") == 0)
+      if (type == IPP_TAG_LANGUAGE && !strcasecmp(values[i], "C"))
        value->string.text = ((int)type & IPP_TAG_COPY) ? "en" :
-                                      strdup("en");
+                                      _cupsStrAlloc("en");
       else
        value->string.text = ((int)type & IPP_TAG_COPY) ? (char *)values[i] :
-                                      strdup(values[i]);
+                                      _cupsStrAlloc(values[i]);
     }
   }
 
@@ -522,10 +523,10 @@ ippAddRange(ipp_t      *ipp,              /* I - IPP message */
   if (ipp == NULL || name == NULL)
     return (NULL);
 
-  if ((attr = _ipp_add_attr(ipp, 1)) == NULL)
+  if ((attr = _ippAddAttr(ipp, 1)) == NULL)
     return (NULL);
 
-  attr->name                  = strdup(name);
+  attr->name                  = _cupsStrAlloc(name);
   attr->group_tag             = group;
   attr->value_tag             = IPP_TAG_RANGE;
   attr->values[0].range.lower = lower;
@@ -555,10 +556,10 @@ ippAddRanges(ipp_t      *ipp,             /* I - IPP message */
   if (ipp == NULL || name == NULL || num_values < 1)
     return (NULL);
 
-  if ((attr = _ipp_add_attr(ipp, num_values)) == NULL)
+  if ((attr = _ippAddAttr(ipp, num_values)) == NULL)
     return (NULL);
 
-  attr->name      = strdup(name);
+  attr->name      = _cupsStrAlloc(name);
   attr->group_tag = group;
   attr->value_tag = IPP_TAG_RANGE;
 
@@ -593,10 +594,10 @@ ippAddResolution(ipp_t      *ipp, /* I - IPP message */
   if (ipp == NULL || name == NULL)
     return (NULL);
 
-  if ((attr = _ipp_add_attr(ipp, 1)) == NULL)
+  if ((attr = _ippAddAttr(ipp, 1)) == NULL)
     return (NULL);
 
-  attr->name                       = strdup(name);
+  attr->name                       = _cupsStrAlloc(name);
   attr->group_tag                  = group;
   attr->value_tag                  = IPP_TAG_RESOLUTION;
   attr->values[0].resolution.xres  = xres;
@@ -628,10 +629,10 @@ ippAddResolutions(ipp_t      *ipp,        /* I - IPP message */
   if (ipp == NULL || name == NULL || num_values < 1)
     return (NULL);
 
-  if ((attr = _ipp_add_attr(ipp, num_values)) == NULL)
+  if ((attr = _ippAddAttr(ipp, num_values)) == NULL)
     return (NULL);
 
-  attr->name      = strdup(name);
+  attr->name      = _cupsStrAlloc(name);
   attr->group_tag = group;
   attr->value_tag = IPP_TAG_RESOLUTION;
 
@@ -664,7 +665,7 @@ ippAddSeparator(ipp_t *ipp)         /* I - IPP message */
   if (ipp == NULL)
     return (NULL);
 
-  if ((attr = _ipp_add_attr(ipp, 0)) == NULL)
+  if ((attr = _ippAddAttr(ipp, 0)) == NULL)
     return (NULL);
 
   attr->group_tag = IPP_TAG_ZERO;
@@ -742,7 +743,7 @@ ippDelete(ipp_t *ipp)                       /* I - IPP message */
   for (attr = ipp->attrs; attr != NULL; attr = next)
   {
     next = attr->next;
-    _ipp_free_attr(attr);
+    _ippFreeAttr(attr);
   }
 
   free(ipp);
@@ -790,7 +791,7 @@ ippDeleteAttribute(
     * Free memory used by the attribute...
     */
 
-    _ipp_free_attr(current);
+    _ippFreeAttr(current);
   }
 }
 
@@ -1011,7 +1012,7 @@ ippReadFile(int   fd,                     /* I - HTTP data */
 /*
  * 'ippReadIO()' - Read data for an IPP message.
  *
- * @since CUPS 1.1.19@
+ * @since CUPS 1.2@
  */
 
 ipp_state_t                            /* O - Current state */
@@ -1023,6 +1024,7 @@ ippReadIO(void       *src,                /* I - Data source */
 {
   int                  n;              /* Length of data */
   unsigned char                buffer[32768],  /* Data buffer */
+                       string[255],    /* Small string buffer */
                        *bufptr;        /* Pointer into buffer */
   ipp_attribute_t      *attr;          /* Current attribute */
   ipp_tag_t            tag;            /* Current tag */
@@ -1032,6 +1034,7 @@ ippReadIO(void       *src,                /* I - Data source */
 
   DEBUG_printf(("ippReadIO(%p, %p, %d, %p, %p)\n", src, cb, blocking,
                 parent, ipp));
+  DEBUG_printf(("ippReadIO: ipp->state=%d\n", ipp->state));
 
   if (src == NULL || ipp == NULL)
     return (IPP_ERROR);
@@ -1252,7 +1255,7 @@ ippReadIO(void       *src,                /* I - Data source */
             if (ipp->current)
              ipp->prev = ipp->current;
 
-           attr = ipp->current = _ipp_add_attr(ipp, 1);
+           attr = ipp->current = _ippAddAttr(ipp, 1);
 
            DEBUG_printf(("ippReadIO: membername, ipp->current=%p, ipp->prev=%p\n",
                          ipp->current, ipp->prev));
@@ -1278,14 +1281,14 @@ ippReadIO(void       *src,              /* I - Data source */
             if (ipp->current)
              ipp->prev = ipp->current;
 
-           attr = ipp->current = _ipp_add_attr(ipp, 1);
+           attr = ipp->current = _ippAddAttr(ipp, 1);
 
            DEBUG_printf(("ippReadIO: name=\'%s\', ipp->current=%p, ipp->prev=%p\n",
                          buffer, ipp->current, ipp->prev));
 
            attr->group_tag  = ipp->curtag;
            attr->value_tag  = tag;
-           attr->name       = strdup((char *)buffer);
+           attr->name       = _cupsStrAlloc((char *)buffer);
            attr->num_values = 0;
          }
          else
@@ -1338,14 +1341,14 @@ ippReadIO(void       *src,              /* I - Data source */
            case IPP_TAG_CHARSET :
            case IPP_TAG_LANGUAGE :
            case IPP_TAG_MIMETYPE :
-                value->string.text = calloc(n + 1, 1);
-
-               if ((*cb)(src, (ipp_uchar_t *)value->string.text, n) < n)
+               if ((*cb)(src, buffer, n) < n)
                {
-                 DEBUG_puts("ippReadIO: Unable to read string value!");
+                 DEBUG_puts("ippReadIO: unable to read name!");
                  return (IPP_ERROR);
                }
 
+               buffer[n] = '\0';
+               value->string.text = _cupsStrAlloc((char *)buffer);
                DEBUG_printf(("ippReadIO: value = \'%s\'\n",
                              value->string.text));
                break;
@@ -1414,18 +1417,24 @@ ippReadIO(void       *src,              /* I - Data source */
 
                n = (bufptr[0] << 8) | bufptr[1];
 
-                value->string.charset = calloc(n + 1, 1);
+                if (n >= sizeof(string))
+               {
+                 memcpy(string, bufptr + 2, sizeof(string) - 1);
+                 string[sizeof(string) - 1] = '\0';
+               }
+               else
+               {
+                 memcpy(string, bufptr + 2, n);
+                 string[n] = '\0';
+                }
 
-               memcpy(value->string.charset,
-                      bufptr + 2, n);
+               value->string.charset = _cupsStrAlloc((char *)string);
 
                 bufptr += 2 + n;
                n = (bufptr[0] << 8) | bufptr[1];
 
-                value->string.text = calloc(n + 1, 1);
-
-               memcpy(value->string.text,
-                      bufptr + 2, n);
+               bufptr[2 + n] = '\0';
+                value->string.text = _cupsStrAlloc((char *)bufptr + 2);
                break;
 
             case IPP_TAG_BEGIN_COLLECTION :
@@ -1461,18 +1470,19 @@ ippReadIO(void       *src,              /* I - Data source */
 
             case IPP_TAG_MEMBERNAME :
               /*
-               * The value is the name of the member in the collection,
-               * which we need to carry over...
+               * The value the name of the member in the collection, which
+               * we need to carry over...
                */
 
-               attr->name = calloc(n + 1, 1);
-
-               if ((*cb)(src, (ipp_uchar_t *)attr->name, n) < n)
+               if ((*cb)(src, buffer, n) < n)
                {
                  DEBUG_puts("ippReadIO: Unable to read member name value!");
                  return (IPP_ERROR);
                }
 
+               buffer[n] = '\0';
+               attr->name = _cupsStrAlloc((char *)buffer);
+
                /*
                * Since collection members are encoded differently than
                * regular attributes, make sure we don't start with an
@@ -1518,6 +1528,8 @@ ippReadIO(void       *src,                /* I - Data source */
         break; /* anti-compiler-warning-code */
   }
 
+  DEBUG_printf(("ippReadIO: returning ipp->state=%d!\n", ipp->state));
+
   return (ipp->state);
 }
 
@@ -1609,7 +1621,7 @@ ippWriteFile(int   fd,                    /* I - HTTP data */
 /*
  * 'ippWriteIO()' - Write data for an IPP message.
  *
- * @since CUPS 1.1.19@
+ * @since CUPS 1.2@
  */
 
 ipp_state_t                            /* O - Current state */
@@ -1663,7 +1675,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
 
           if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
          {
-           DEBUG_puts("ippWrite: Could not write IPP header...");
+           DEBUG_puts("ippWriteIO: Could not write IPP header...");
            return (IPP_ERROR);
          }
        }
@@ -1677,9 +1689,9 @@ ippWriteIO(void       *dst,               /* I - Destination */
        ipp->current = ipp->attrs;
        ipp->curtag  = IPP_TAG_ZERO;
 
-        DEBUG_printf(("ippWrite: version=%d.%d\n", buffer[0], buffer[1]));
-       DEBUG_printf(("ippWrite: op_status=%04x\n", ipp->request.any.op_status));
-       DEBUG_printf(("ippWrite: request_id=%d\n", ipp->request.any.request_id));
+        DEBUG_printf(("ippWriteIO: version=%d.%d\n", buffer[0], buffer[1]));
+       DEBUG_printf(("ippWriteIO: op_status=%04x\n", ipp->request.any.op_status));
+       DEBUG_printf(("ippWriteIO: request_id=%d\n", ipp->request.any.request_id));
 
        /*
         * If blocking is disabled, stop here...
@@ -1711,7 +1723,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
             if (attr->group_tag == IPP_TAG_ZERO)
              continue;
 
-            DEBUG_printf(("ippWrite: wrote group tag = %x\n", attr->group_tag));
+            DEBUG_printf(("ippWriteIO: wrote group tag = %x\n", attr->group_tag));
            *bufptr++ = attr->group_tag;
          }
          else if (attr->group_tag == IPP_TAG_ZERO)
@@ -1742,8 +1754,8 @@ ippWriteIO(void       *dst,               /* I - Destination */
            * Write the value tag, name length, and name string...
            */
 
-            DEBUG_printf(("ippWrite: writing value tag = %x\n", attr->value_tag));
-            DEBUG_printf(("ippWrite: writing name = %d, \'%s\'\n", n, attr->name));
+            DEBUG_printf(("ippWriteIO: writing value tag = %x\n", attr->value_tag));
+            DEBUG_printf(("ippWriteIO: writing name = %d, \'%s\'\n", n, attr->name));
 
             *bufptr++ = attr->value_tag;
            *bufptr++ = n >> 8;
@@ -1766,11 +1778,11 @@ ippWriteIO(void       *dst,             /* I - Destination */
            * and empty name for the collection member attribute...
            */
 
-            DEBUG_printf(("ippWrite: writing value tag = %x\n",
+            DEBUG_printf(("ippWriteIO: writing value tag = %x\n",
                          IPP_TAG_MEMBERNAME));
-            DEBUG_printf(("ippWrite: writing name = %d, \'%s\'\n", n, attr->name));
-            DEBUG_printf(("ippWrite: writing value tag = %x\n", attr->value_tag));
-            DEBUG_puts("ippWrite: writing name = 0, \'\'\n");
+            DEBUG_printf(("ippWriteIO: writing name = %d, \'%s\'\n", n, attr->name));
+            DEBUG_printf(("ippWriteIO: writing value tag = %x\n", attr->value_tag));
+            DEBUG_puts("ippWriteIO: writing name = 0, \'\'\n");
 
             *bufptr++ = IPP_TAG_MEMBERNAME;
            *bufptr++ = 0;
@@ -1801,7 +1813,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                  {
                     if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                    {
-                     DEBUG_puts("ippWrite: Could not write IPP attribute...");
+                     DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
                      return (IPP_ERROR);
                    }
 
@@ -1845,7 +1857,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                  {
                     if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                    {
-                     DEBUG_puts("ippWrite: Could not write IPP attribute...");
+                     DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
                      return (IPP_ERROR);
                    }
 
@@ -1896,15 +1908,15 @@ ippWriteIO(void       *dst,             /* I - Destination */
                    * values with a zero-length name...
                    */
 
-                   DEBUG_printf(("ippWrite: writing value tag = %x\n",
+                   DEBUG_printf(("ippWriteIO: writing value tag = %x\n",
                                  attr->value_tag));
-                   DEBUG_printf(("ippWrite: writing name = 0, \'\'\n"));
+                   DEBUG_printf(("ippWriteIO: writing name = 0, \'\'\n"));
 
                     if ((sizeof(buffer) - (bufptr - buffer)) < 3)
                    {
                       if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                      {
-                       DEBUG_puts("ippWrite: Could not write IPP attribute...");
+                       DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
                        return (IPP_ERROR);
                      }
 
@@ -1924,14 +1936,14 @@ ippWriteIO(void       *dst,             /* I - Destination */
                   if (n > (sizeof(buffer) - 2))
                    return (IPP_ERROR);
 
-                  DEBUG_printf(("ippWrite: writing string = %d, \'%s\'\n", n,
+                  DEBUG_printf(("ippWriteIO: writing string = %d, \'%s\'\n", n,
                                value->string.text));
 
                   if ((int)(sizeof(buffer) - (bufptr - buffer)) < (n + 2))
                  {
                     if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                    {
-                     DEBUG_puts("ippWrite: Could not write IPP attribute...");
+                     DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
                      return (IPP_ERROR);
                    }
 
@@ -1968,7 +1980,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                  {
                     if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                    {
-                     DEBUG_puts("ippWrite: Could not write IPP attribute...");
+                     DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
                      return (IPP_ERROR);
                    }
 
@@ -2011,7 +2023,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                  {
                     if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                    {
-                     DEBUG_puts("ippWrite: Could not write IPP attribute...");
+                     DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
                      return (IPP_ERROR);
                    }
 
@@ -2062,7 +2074,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                  {
                     if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                    {
-                     DEBUG_puts("ippWrite: Could not write IPP attribute...");
+                     DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
                      return (IPP_ERROR);
                    }
 
@@ -2119,7 +2131,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                    {
                       if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                      {
-                       DEBUG_puts("ippWrite: Could not write IPP attribute...");
+                       DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
                        return (IPP_ERROR);
                      }
 
@@ -2156,7 +2168,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                  {
                     if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                    {
-                     DEBUG_puts("ippWrite: Could not write IPP attribute...");
+                     DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
                      return (IPP_ERROR);
                    }
 
@@ -2217,7 +2229,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                  {
                     if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                    {
-                     DEBUG_puts("ippWrite: Could not write IPP attribute...");
+                     DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
                      return (IPP_ERROR);
                    }
 
@@ -2245,7 +2257,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
 
                   if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                  {
-                   DEBUG_puts("ippWrite: Could not write IPP attribute...");
+                   DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
                    return (IPP_ERROR);
                  }
 
@@ -2278,7 +2290,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                    {
                       if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                      {
-                       DEBUG_puts("ippWrite: Could not write IPP attribute...");
+                       DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
                        return (IPP_ERROR);
                      }
 
@@ -2306,7 +2318,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                  {
                     if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
                    {
-                     DEBUG_puts("ippWrite: Could not write IPP attribute...");
+                     DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
                      return (IPP_ERROR);
                    }
 
@@ -2333,11 +2345,11 @@ ippWriteIO(void       *dst,             /* I - Destination */
 
           if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
          {
-           DEBUG_puts("ippWrite: Could not write IPP attribute...");
+           DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
            return (IPP_ERROR);
          }
 
-          DEBUG_printf(("ippWrite: wrote %d bytes\n", bufptr - buffer));
+          DEBUG_printf(("ippWriteIO: wrote %d bytes\n", bufptr - buffer));
 
         /*
           * If blocking is disabled, stop here...
@@ -2371,7 +2383,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
 
          if ((*cb)(dst, buffer, n) < 0)
          {
-           DEBUG_puts("ippWrite: Could not write IPP end-tag...");
+           DEBUG_puts("ippWriteIO: Could not write IPP end-tag...");
            return (IPP_ERROR);
          }
 
@@ -2391,17 +2403,17 @@ ippWriteIO(void       *dst,             /* I - Destination */
 
 
 /*
- * '_ipp_add_attr()' - Add a new attribute to the request.
+ * '_ippAddAttr()' - Add a new attribute to the request.
  */
 
 ipp_attribute_t *                      /* O - New attribute */
-_ipp_add_attr(ipp_t *ipp,              /* I - IPP message */
-              int   num_values)                /* I - Number of values */
+_ippAddAttr(ipp_t *ipp,                        /* I - IPP message */
+            int   num_values)          /* I - Number of values */
 {
   ipp_attribute_t      *attr;          /* New attribute */
 
 
-  DEBUG_printf(("_ipp_add_attr(%p, %d)\n", ipp, num_values));
+  DEBUG_printf(("_ippAddAttr(%p, %d)\n", ipp, num_values));
 
   if (ipp == NULL || num_values < 0)
     return (NULL);
@@ -2421,24 +2433,24 @@ _ipp_add_attr(ipp_t *ipp,               /* I - IPP message */
     ipp->last = attr;
   }
 
-  DEBUG_printf(("_ipp_add_attr(): %p\n", attr));
+  DEBUG_printf(("_ippAddAttr(): %p\n", attr));
 
   return (attr);
 }
 
 
 /*
- * '_ipp_free_attr()' - Free an attribute.
+ * '_ippFreeAttr()' - Free an attribute.
  */
 
 void
-_ipp_free_attr(ipp_attribute_t *attr)  /* I - Attribute to free */
+_ippFreeAttr(ipp_attribute_t *attr)    /* I - Attribute to free */
 {
   int          i;                      /* Looping var */
   ipp_value_t  *value;                 /* Current value */
 
 
-  DEBUG_printf(("_ipp_free_attr(): %p\n", attr));
+  DEBUG_printf(("_ippFreeAttr(): %p\n", attr));
 
   switch (attr->value_tag)
   {
@@ -2454,7 +2466,7 @@ _ipp_free_attr(ipp_attribute_t *attr)     /* I - Attribute to free */
        for (i = 0, value = attr->values;
             i < attr->num_values;
             i ++, value ++)
-         free(value->string.text);
+         _cupsStrFree(value->string.text);
        break;
 
     case IPP_TAG_TEXTLANG :
@@ -2464,17 +2476,40 @@ _ipp_free_attr(ipp_attribute_t *attr)   /* I - Attribute to free */
             i ++, value ++)
        {
          if (value->string.charset && i == 0)
-           free(value->string.charset);
-         free(value->string.text);
+           _cupsStrFree(value->string.charset);
+         _cupsStrFree(value->string.text);
        }
        break;
 
+    case IPP_TAG_INTEGER :
+    case IPP_TAG_ENUM :
+    case IPP_TAG_BOOLEAN :
+    case IPP_TAG_DATE :
+    case IPP_TAG_RESOLUTION :
+    case IPP_TAG_RANGE :
+       break;
+
+    case IPP_TAG_BEGIN_COLLECTION :
+       for (i = 0, value = attr->values;
+            i < attr->num_values;
+            i ++, value ++)
+          ippDelete(value->collection);
+       break;
+
     default :
-        break; /* anti-compiler-warning-code */
+        if (!((int)attr->value_tag & IPP_TAG_COPY))
+       {
+         for (i = 0, value = attr->values;
+              i < attr->num_values;
+              i ++, value ++)
+            if (value->unknown.data)
+             free(value->unknown.data);
+        }
+       break;
   }
 
   if (attr->name)
-    free(attr->name);
+    _cupsStrFree(attr->name);
 
   free(attr);
 }
@@ -2594,14 +2629,14 @@ ipp_length(ipp_t *ipp,                  /* I - IPP message or collection */
          for (i = 0, value = attr->values;
               i < attr->num_values;
               i ++, value ++)
-            bytes += ipp_length(attr->values[i].collection, 1);
+            bytes += ipp_length(value->collection, 1);
          break;
 
       default :
          for (i = 0, value = attr->values;
               i < attr->num_values;
               i ++, value ++)
-            bytes += attr->values[0].unknown.length;
+            bytes += value->unknown.length;
          break;
     }
   }
@@ -2707,10 +2742,10 @@ ipp_read_http(http_t      *http,        /* I - Client connection */
       if (!http->blocking)
       {
        /*
-        * Wait up to 1 second for more data on non-blocking sockets...
+        * Wait up to 10 seconds for more data on non-blocking sockets...
        */
 
-       if (!httpWait(http, 1000))
+       if (!httpWait(http, 10000))
        {
         /*
           * Signal no data...
@@ -2765,6 +2800,29 @@ ipp_write_file(int         *fd,          /* I - File descriptor */
 }
 
 
+#ifdef __linux
+/*
+ * The following symbol definitions are provided only for KDE
+ * compatibility during the CUPS 1.2 testing period and will be
+ * removed in a future release of CUPS.  These are PRIVATE APIs
+ * from CUPS 1.1.x that the KDE developers chose to use...
+ */
+
+ipp_attribute_t *                      /* O - New attribute */
+_ipp_add_attr(ipp_t *ipp,              /* I - IPP message */
+              int   num_values)                /* I - Number of values */
+{
+  return (_ippAddAttr(ipp, num_values));
+}
+
+void
+_ipp_free_attr(ipp_attribute_t *attr)  /* I - Attribute to free */
+{
+  _ippFreeAttr(attr);
+}
+#endif /* __linux */
+
+
 /*
- * End of "$Id: ipp.c 5023 2006-01-29 14:39:44Z mike $".
+ * End of "$Id$".
  */