]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/ipp.c
Import CUPS v1.7.1
[thirdparty/cups.git] / cups / ipp.c
index 28b8961d7749a26f51455ea3619c2c12a1f73a5c..fe1ee2e74dbebd950d278aada8c71cdd0b24ec92 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * "$Id: ipp.c 10102 2011-11-02 23:52:39Z mike $"
+ * "$Id: ipp.c 11113 2013-07-10 14:08:39Z msweet $"
  *
  *   Internet Printing Protocol functions for CUPS.
  *
- *   Copyright 2007-2012 by Apple Inc.
+ *   Copyright 2007-2013 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -57,6 +57,7 @@
  *   ippGetGroupTag()       - Get the group associated with an attribute.
  *   ippGetInteger()        - Get the integer/enum value for an attribute.
  *   ippGetName()           - Get the attribute name.
+ *   ippGetOctetString()     - Get an octetString value from an IPP attribute.
  *   ippGetOperation()      - Get the operation ID in an IPP message.
  *   ippGetRange()          - Get a rangeOfInteger value from an attribute.
  *   ippGetRequestId()      - Get the request ID from an IPP message.
@@ -84,6 +85,7 @@
  *   ippSetGroupTag()       - Set the group tag of an attribute.
  *   ippSetInteger()        - Set an integer or enum value in an attribute.
  *   ippSetName()           - Set the name of an attribute.
+ *   ippSetOctetString()     - Set an octetString value in an IPP attribute.
  *   ippSetOperation()      - Set the operation ID in an IPP request message.
  *   ippSetRange()          - Set a rangeOfInteger value in an attribute.
  *   ippSetRequestId()      - Set the request ID in an IPP message.
@@ -503,7 +505,7 @@ ippAddInteger(ipp_t      *ipp,              /* I - IPP message */
                 "name=\"%s\", value=%d)", ipp, group, ippTagString(group),
                value_tag, ippTagString(value_tag), name, value));
 
-  value_tag &= IPP_TAG_MASK;
+  value_tag &= IPP_TAG_CUPS_MASK;
 
  /*
   * Special-case for legacy usage: map out-of-band attributes to new ippAddOutOfBand
@@ -575,7 +577,7 @@ ippAddIntegers(ipp_t      *ipp,             /* I - IPP message */
                group, ippTagString(group), value_tag, ippTagString(value_tag), name,
                num_values, values));
 
-  value_tag &= IPP_TAG_MASK;
+  value_tag &= IPP_TAG_CUPS_MASK;
 
  /*
   * Range check input...
@@ -702,7 +704,7 @@ ippAddOutOfBand(ipp_t      *ipp,    /* I - IPP message */
                 "name=\"%s\")", ipp, group, ippTagString(group), value_tag,
                 ippTagString(value_tag), name));
 
-  value_tag &= IPP_TAG_MASK;
+  value_tag &= IPP_TAG_CUPS_MASK;
 
  /*
   * Range check input...
@@ -1029,7 +1031,7 @@ ippAddString(ipp_t      *ipp,             /* I - IPP message */
   * Range check input...
   */
 
-  temp_tag = (ipp_tag_t)((int)value_tag & IPP_TAG_MASK);
+  temp_tag = (ipp_tag_t)((int)value_tag & IPP_TAG_CUPS_MASK);
 
 #if 0
   if (!ipp || !name || group < IPP_TAG_ZERO ||
@@ -1051,13 +1053,13 @@ ippAddString(ipp_t      *ipp,           /* I - IPP message */
   * See if we need to map charset, language, or locale values...
   */
 
-  if (language && ((int)value_tag & IPP_TAG_COPY) &&
+  if (language && ((int)value_tag & IPP_TAG_CUPS_CONST) &&
       strcmp(language, ipp_lang_code(language, code, sizeof(code))))
     value_tag = temp_tag;              /* Don't do a fast copy */
-  else if (value && value_tag == (ipp_tag_t)(IPP_TAG_CHARSET | IPP_TAG_COPY) &&
+  else if (value && value_tag == (ipp_tag_t)(IPP_TAG_CHARSET | IPP_TAG_CUPS_CONST) &&
            strcmp(value, ipp_get_code(value, code, sizeof(code))))
     value_tag = temp_tag;              /* Don't do a fast copy */
-  else if (value && value_tag == (ipp_tag_t)(IPP_TAG_LANGUAGE | IPP_TAG_COPY) &&
+  else if (value && value_tag == (ipp_tag_t)(IPP_TAG_LANGUAGE | IPP_TAG_CUPS_CONST) &&
            strcmp(value, ipp_lang_code(value, code, sizeof(code))))
     value_tag = temp_tag;              /* Don't do a fast copy */
 
@@ -1072,7 +1074,7 @@ ippAddString(ipp_t      *ipp,             /* I - IPP message */
   * Initialize the attribute data...
   */
 
-  if ((int)value_tag & IPP_TAG_COPY)
+  if ((int)value_tag & IPP_TAG_CUPS_CONST)
   {
     attr->values[0].string.language = (char *)language;
     attr->values[0].string.text     = (char *)value;
@@ -1129,7 +1131,7 @@ ippAddString(ipp_t      *ipp,             /* I - IPP message */
  * needed.  The formatted string is truncated as needed to the maximum length of
  * the corresponding value type.
  *
- * @since CUPS 1.7@
+ * @since CUPS 1.7/OS X 10.9@
  */
 
 ipp_attribute_t *                      /* O - New attribute */
@@ -1182,7 +1184,7 @@ ippAddStringf(ipp_t      *ipp,            /* I - IPP message */
  * stdarg pointer @code ap@.  The formatted string is truncated as needed to the
  * maximum length of the corresponding value type.
  *
- * @since CUPS 1.7@
+ * @since CUPS 1.7/OS X 10.9@
  */
 
 ipp_attribute_t *                      /* O - New attribute */
@@ -1208,7 +1210,7 @@ ippAddStringfv(ipp_t      *ipp,           /* I - IPP message */
       group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
       (value_tag < IPP_TAG_TEXT && value_tag != IPP_TAG_TEXTLANG &&
        value_tag != IPP_TAG_NAMELANG) || value_tag > IPP_TAG_MIMETYPE ||
-      !format || !ap)
+      !format)
     return (NULL);
 
   if ((value_tag == IPP_TAG_TEXTLANG || value_tag == IPP_TAG_NAMELANG)
@@ -1364,7 +1366,7 @@ ippAddStrings(
   * Range check input...
   */
 
-  temp_tag = (ipp_tag_t)((int)value_tag & IPP_TAG_MASK);
+  temp_tag = (ipp_tag_t)((int)value_tag & IPP_TAG_CUPS_MASK);
 
 #if 0
   if (!ipp || !name || group < IPP_TAG_ZERO ||
@@ -1388,10 +1390,10 @@ ippAddStrings(
   * See if we need to map charset, language, or locale values...
   */
 
-  if (language && ((int)value_tag & IPP_TAG_COPY) &&
+  if (language && ((int)value_tag & IPP_TAG_CUPS_CONST) &&
       strcmp(language, ipp_lang_code(language, code, sizeof(code))))
     value_tag = temp_tag;              /* Don't do a fast copy */
-  else if (values && value_tag == (ipp_tag_t)(IPP_TAG_CHARSET | IPP_TAG_COPY))
+  else if (values && value_tag == (ipp_tag_t)(IPP_TAG_CHARSET | IPP_TAG_CUPS_CONST))
   {
     for (i = 0; i < num_values; i ++)
       if (strcmp(values[i], ipp_get_code(values[i], code, sizeof(code))))
@@ -1400,7 +1402,7 @@ ippAddStrings(
         break;
       }
   }
-  else if (values && value_tag == (ipp_tag_t)(IPP_TAG_LANGUAGE | IPP_TAG_COPY))
+  else if (values && value_tag == (ipp_tag_t)(IPP_TAG_LANGUAGE | IPP_TAG_CUPS_CONST))
   {
     for (i = 0; i < num_values; i ++)
       if (strcmp(values[i], ipp_lang_code(values[i], code, sizeof(code))))
@@ -1429,7 +1431,7 @@ ippAddStrings(
     {
       if (value == attr->values)
       {
-        if ((int)value_tag & IPP_TAG_COPY)
+        if ((int)value_tag & IPP_TAG_CUPS_CONST)
           value->string.language = (char *)language;
         else
           value->string.language = _cupsStrAlloc(ipp_lang_code(language, code,
@@ -1441,7 +1443,7 @@ ippAddStrings(
 
     if (values)
     {
-      if ((int)value_tag & IPP_TAG_COPY)
+      if ((int)value_tag & IPP_TAG_CUPS_CONST)
         value->string.text = (char *)*values++;
       else if (value_tag == IPP_TAG_CHARSET)
        value->string.text = _cupsStrAlloc(ipp_get_code(*values++, code, sizeof(code)));
@@ -1464,7 +1466,7 @@ ippAddStrings(
  * enum value, or the value falls within one of the rangeOfInteger values for
  * the attribute.
  *
- * @since CUPS 1.7@
+ * @since CUPS 1.7/OS X 10.9@
  */
 
 int                                    /* O - 1 on a match, 0 on no match */
@@ -1515,7 +1517,7 @@ ippContainsInteger(
  * Returns non-zero when the attribute contains a matching charset, keyword,
  * language, mimeMediaType, name, text, URI, or URI scheme value.
  *
- * @since CUPS 1.7@
+ * @since CUPS 1.7/OS X 10.9@
  */
 
 int                                    /* O - 1 on a match, 0 on no match */
@@ -1621,9 +1623,9 @@ ippCopyAttribute(
   * Copy it...
   */
 
-  quickcopy = quickcopy ? IPP_TAG_COPY : 0;
+  quickcopy = quickcopy ? IPP_TAG_CUPS_CONST : 0;
 
-  switch (srcattr->value_tag & ~IPP_TAG_COPY)
+  switch (srcattr->value_tag & ~IPP_TAG_CUPS_CONST)
   {
     case IPP_TAG_ZERO :
         dstattr = ippAddSeparator(dst);
@@ -1676,7 +1678,7 @@ ippCopyAttribute(
               i --, srcval ++, dstval ++)
            dstval->string.text = srcval->string.text;
         }
-       else if (srcattr->value_tag & IPP_TAG_COPY)
+       else if (srcattr->value_tag & IPP_TAG_CUPS_CONST)
        {
          for (i = srcattr->num_values, srcval = srcattr->values,
                   dstval = dstattr->values;
@@ -1753,7 +1755,7 @@ ippCopyAttribute(
            dstval->string.text     = srcval->string.text;
           }
         }
-       else if (srcattr->value_tag & IPP_TAG_COPY)
+       else if (srcattr->value_tag & IPP_TAG_CUPS_CONST)
        {
          for (i = srcattr->num_values, srcval = srcattr->values,
                   dstval = dstattr->values;
@@ -2149,7 +2151,7 @@ ippFindNextAttribute(ipp_t      *ipp,     /* I - IPP message */
     DEBUG_printf(("4ippFindAttribute: attr=%p, name=\"%s\"", attr,
                   attr->name));
 
-    value_tag = (ipp_tag_t)(attr->value_tag & IPP_TAG_MASK);
+    value_tag = (ipp_tag_t)(attr->value_tag & IPP_TAG_CUPS_MASK);
 
     if (attr->name != NULL && _cups_strcasecmp(attr->name, name) == 0 &&
         (value_tag == type || type == IPP_TAG_ZERO ||
@@ -2382,6 +2384,45 @@ ippGetName(ipp_attribute_t *attr)        /* I - IPP attribute */
 }
 
 
+/*
+ * 'ippGetOctetString()' - Get an octetString value from an IPP attribute.
+ *
+ * The @code element@ parameter specifies which value to get from 0 to
+ * @link ippGetCount(attr)@ - 1.
+ *
+ * @since CUPS 1.7/OS X 10.9@
+ */
+
+void *                                 /* O - Pointer to octetString data */
+ippGetOctetString(
+    ipp_attribute_t *attr,             /* I - IPP attribute */
+    int             element,           /* I - Value number (0-based) */
+    int             *datalen)          /* O - Length of octetString data */
+{
+ /*
+  * Range check input...
+  */
+
+  if (!attr || attr->value_tag != IPP_TAG_STRING ||
+      element < 0 || element >= attr->num_values)
+  {
+    if (datalen)
+      *datalen = 0;
+
+    return (NULL);
+  }
+
+ /*
+  * Return the values...
+  */
+
+  if (datalen)
+    *datalen = attr->values[element].unknown.length;
+
+  return (attr->values[element].unknown.data);
+}
+
+
 /*
  * 'ippGetOperation()' - Get the operation ID in an IPP message.
  *
@@ -2520,7 +2561,7 @@ ippGetState(ipp_t *ipp)                   /* I - IPP message */
   */
 
   if (!ipp)
-    return (IPP_IDLE);
+    return (IPP_STATE_IDLE);
 
  /*
   * Return the value...
@@ -2544,7 +2585,7 @@ ippGetStatusCode(ipp_t *ipp)              /* I - IPP response or event message */
   */
 
   if (!ipp)
-    return (IPP_INTERNAL_ERROR);
+    return (IPP_STATUS_ERROR_INTERNAL);
 
  /*
   * Return the value...
@@ -2608,7 +2649,7 @@ ippGetValueTag(ipp_attribute_t *attr)     /* I - IPP attribute */
   * Return the value...
   */
 
-  return (attr->value_tag & IPP_TAG_MASK);
+  return (attr->value_tag & IPP_TAG_CUPS_MASK);
 }
 
 
@@ -2687,7 +2728,9 @@ ippNextAttribute(ipp_t *ipp)              /* I - IPP message */
 ipp_t *                                        /* O - New IPP message */
 ippNew(void)
 {
-  ipp_t        *temp;                          /* New IPP message */
+  ipp_t                        *temp;          /* New IPP message */
+  _cups_globals_t      *cg = _cupsGlobals();
+                                       /* Global data */
 
 
   DEBUG_puts("ippNew()");
@@ -2695,11 +2738,14 @@ ippNew(void)
   if ((temp = (ipp_t *)calloc(1, sizeof(ipp_t))) != NULL)
   {
    /*
-    * Default to IPP 2.0...
+    * Set default version - usually 2.0...
     */
 
-    temp->request.any.version[0] = 2;
-    temp->request.any.version[1] = 0;
+    if (cg->server_version == 0)
+      _cupsSetDefaults();
+
+    temp->request.any.version[0] = cg->server_version / 10;
+    temp->request.any.version[1] = cg->server_version % 10;
     temp->use                    = 1;
   }
 
@@ -2783,7 +2829,7 @@ ippNewRequest(ipp_op_t op)                /* I - Operation code */
  * "utf-8" and a value derived from the current locale are substituted,
  * respectively.
  *
- * @since CUPS 1.7@
+ * @since CUPS 1.7/OS X 10.9@
  */
 
 ipp_t *                                        /* O - IPP response message */
@@ -2893,7 +2939,7 @@ ippRead(http_t *http,                     /* I - HTTP connection */
                 http, ipp, CUPS_LLCAST (http ? http->data_remaining : -1)));
 
   if (!http)
-    return (IPP_ERROR);
+    return (IPP_STATE_ERROR);
 
   DEBUG_printf(("2ippRead: http->state=%d, http->used=%d", http->state,
                 http->used));
@@ -2945,23 +2991,23 @@ ippReadIO(void       *src,              /* I - Data source */
 
   DEBUG_printf(("ippReadIO(src=%p, cb=%p, blocking=%d, parent=%p, ipp=%p)",
                 src, cb, blocking, parent, ipp));
-  DEBUG_printf(("2ippReadIO: ipp->state=%d", ipp ? ipp->state : IPP_ERROR));
+  DEBUG_printf(("2ippReadIO: ipp->state=%d", ipp ? ipp->state : IPP_STATE_ERROR));
 
   if (!src || !ipp)
-    return (IPP_ERROR);
+    return (IPP_STATE_ERROR);
 
   if ((buffer = (unsigned char *)_cupsBufferGet(IPP_BUF_SIZE)) == NULL)
   {
     DEBUG_puts("1ippReadIO: Unable to get read buffer.");
-    return (IPP_ERROR);
+    return (IPP_STATE_ERROR);
   }
 
   switch (ipp->state)
   {
-    case IPP_IDLE :
+    case IPP_STATE_IDLE :
         ipp->state ++; /* Avoid common problem... */
 
-    case IPP_HEADER :
+    case IPP_STATE_HEADER :
         if (parent == NULL)
        {
         /*
@@ -2972,7 +3018,7 @@ ippReadIO(void       *src,                /* I - Data source */
          {
            DEBUG_puts("1ippReadIO: Unable to read header.");
            _cupsBufferRelease((char *)buffer);
-           return (IPP_ERROR);
+           return (IPP_STATE_ERROR);
          }
 
         /*
@@ -2992,7 +3038,7 @@ ippReadIO(void       *src,                /* I - Data source */
                        ipp->request.any.request_id));
         }
 
-        ipp->state   = IPP_ATTRIBUTE;
+        ipp->state   = IPP_STATE_ATTRIBUTE;
        ipp->current = NULL;
        ipp->curtag  = IPP_TAG_ZERO;
        ipp->prev    = ipp->last;
@@ -3004,14 +3050,14 @@ ippReadIO(void       *src,              /* I - Data source */
         if (!blocking)
          break;
 
-    case IPP_ATTRIBUTE :
+    case IPP_STATE_ATTRIBUTE :
         for (;;)
        {
          if ((*cb)(src, buffer, 1) < 1)
          {
            DEBUG_puts("1ippReadIO: Callback returned EOF/error");
            _cupsBufferRelease((char *)buffer);
-           return (IPP_ERROR);
+           return (IPP_STATE_ERROR);
          }
 
          DEBUG_printf(("2ippReadIO: ipp->current=%p, ipp->prev=%p",
@@ -3032,22 +3078,22 @@ ippReadIO(void       *src,              /* I - Data source */
            {
              DEBUG_puts("1ippReadIO: Callback returned EOF/error");
              _cupsBufferRelease((char *)buffer);
-             return (IPP_ERROR);
+             return (IPP_STATE_ERROR);
            }
 
            tag = (ipp_tag_t)((((((buffer[0] << 8) | buffer[1]) << 8) |
                                buffer[2]) << 8) | buffer[3]);
 
-            if (tag & IPP_TAG_COPY)
+            if (tag & IPP_TAG_CUPS_CONST)
             {
              /*
               * Fail if the high bit is set in the tag...
               */
 
-             _cupsSetError(IPP_INTERNAL_ERROR, _("IPP extension tag larger than 0x7FFFFFFF."), 1);
+             _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP extension tag larger than 0x7FFFFFFF."), 1);
              DEBUG_printf(("1ippReadIO: bad tag 0x%x.", tag));
              _cupsBufferRelease((char *)buffer);
-             return (IPP_ERROR);
+             return (IPP_STATE_ERROR);
             }
           }
 
@@ -3059,7 +3105,7 @@ ippReadIO(void       *src,                /* I - Data source */
 
             DEBUG_puts("2ippReadIO: IPP_TAG_END.");
 
-           ipp->state = IPP_DATA;
+           ipp->state = IPP_STATE_DATA;
            break;
          }
           else if (tag < IPP_TAG_UNSUPPORTED_VALUE)
@@ -3091,17 +3137,17 @@ ippReadIO(void       *src,              /* I - Data source */
          {
            DEBUG_puts("1ippReadIO: unable to read name length.");
            _cupsBufferRelease((char *)buffer);
-           return (IPP_ERROR);
+           return (IPP_STATE_ERROR);
          }
 
           n = (buffer[0] << 8) | buffer[1];
 
           if (n >= IPP_BUF_SIZE)
          {
-           _cupsSetError(IPP_INTERNAL_ERROR, _("IPP name larger than 32767 bytes."), 1);
+           _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP name larger than 32767 bytes."), 1);
            DEBUG_printf(("1ippReadIO: bad name length %d.", n));
            _cupsBufferRelease((char *)buffer);
-           return (IPP_ERROR);
+           return (IPP_STATE_ERROR);
          }
 
           DEBUG_printf(("2ippReadIO: name length=%d", n));
@@ -3115,14 +3161,14 @@ ippReadIO(void       *src,              /* I - Data source */
 
             if (ipp->current == NULL)
            {
-             _cupsSetError(IPP_INTERNAL_ERROR, _("IPP attribute has no name."), 1);
+             _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP attribute has no name."), 1);
              DEBUG_puts("1ippReadIO: Attribute without name and no current.");
              _cupsBufferRelease((char *)buffer);
-             return (IPP_ERROR);
+             return (IPP_STATE_ERROR);
            }
 
             attr      = ipp->current;
-           value_tag = (ipp_tag_t)(attr->value_tag & IPP_TAG_MASK);
+           value_tag = (ipp_tag_t)(attr->value_tag & IPP_TAG_CUPS_MASK);
 
           /*
            * Make sure we aren't adding a new value of a different
@@ -3151,14 +3197,14 @@ ippReadIO(void       *src,              /* I - Data source */
                  (tag < IPP_TAG_TEXT || tag > IPP_TAG_MIMETYPE) &&
                  tag != IPP_TAG_NOVALUE)
              {
-               _cupsSetError(IPP_INTERNAL_ERROR,
+               _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                              _("IPP 1setOf attribute with incompatible value "
                                "tags."), 1);
                DEBUG_printf(("1ippReadIO: 1setOf value tag %x(%s) != %x(%s)",
                              value_tag, ippTagString(value_tag), tag,
                              ippTagString(tag)));
                _cupsBufferRelease((char *)buffer);
-               return (IPP_ERROR);
+               return (IPP_STATE_ERROR);
              }
 
               if (value_tag != tag)
@@ -3178,14 +3224,14 @@ ippReadIO(void       *src,              /* I - Data source */
 
              if (tag != IPP_TAG_INTEGER && tag != IPP_TAG_RANGE)
              {
-               _cupsSetError(IPP_INTERNAL_ERROR,
+               _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                              _("IPP 1setOf attribute with incompatible value "
                                "tags."), 1);
                DEBUG_printf(("1ippReadIO: 1setOf value tag %x(%s) != %x(%s)",
                              value_tag, ippTagString(value_tag), tag,
                              ippTagString(tag)));
                _cupsBufferRelease((char *)buffer);
-               return (IPP_ERROR);
+               return (IPP_STATE_ERROR);
              }
 
               if (value_tag == IPP_TAG_INTEGER && tag == IPP_TAG_RANGE)
@@ -3201,14 +3247,14 @@ ippReadIO(void       *src,              /* I - Data source */
             }
            else if (value_tag != tag)
            {
-             _cupsSetError(IPP_INTERNAL_ERROR,
+             _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                            _("IPP 1setOf attribute with incompatible value "
                              "tags."), 1);
              DEBUG_printf(("1ippReadIO: value tag %x(%s) != %x(%s)",
                            value_tag, ippTagString(value_tag), tag,
                            ippTagString(tag)));
              _cupsBufferRelease((char *)buffer);
-             return (IPP_ERROR);
+             return (IPP_STATE_ERROR);
             }
 
            /*
@@ -3218,7 +3264,7 @@ ippReadIO(void       *src,                /* I - Data source */
            if ((value = ipp_set_value(ipp, &attr, attr->num_values)) == NULL)
            {
              _cupsBufferRelease((char *)buffer);
-             return (IPP_ERROR);
+             return (IPP_STATE_ERROR);
            }
          }
          else if (tag == IPP_TAG_MEMBERNAME)
@@ -3229,10 +3275,10 @@ ippReadIO(void       *src,              /* I - Data source */
 
            if (n)
            {
-             _cupsSetError(IPP_INTERNAL_ERROR, _("IPP member name is not empty."), 1);
+             _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP member name is not empty."), 1);
              DEBUG_puts("1ippReadIO: member name not empty.");
              _cupsBufferRelease((char *)buffer);
-             return (IPP_ERROR);
+             return (IPP_STATE_ERROR);
            }
 
             if (ipp->current)
@@ -3241,10 +3287,10 @@ ippReadIO(void       *src,              /* I - Data source */
            attr = ipp->current = ipp_add_attr(ipp, NULL, ipp->curtag, IPP_TAG_ZERO, 1);
            if (!attr)
            {
-             _cupsSetHTTPError(HTTP_ERROR);
+             _cupsSetHTTPError(HTTP_STATUS_ERROR);
              DEBUG_puts("1ippReadIO: unable to allocate attribute.");
              _cupsBufferRelease((char *)buffer);
-             return (IPP_ERROR);
+             return (IPP_STATE_ERROR);
            }
 
            DEBUG_printf(("2ippReadIO: membername, ipp->current=%p, ipp->prev=%p",
@@ -3262,7 +3308,7 @@ ippReadIO(void       *src,                /* I - Data source */
            {
              DEBUG_puts("1ippReadIO: unable to read name.");
              _cupsBufferRelease((char *)buffer);
-             return (IPP_ERROR);
+             return (IPP_STATE_ERROR);
            }
 
            buffer[n] = '\0';
@@ -3273,10 +3319,10 @@ ippReadIO(void       *src,              /* I - Data source */
            if ((attr = ipp->current = ipp_add_attr(ipp, (char *)buffer, ipp->curtag, tag,
                                                    1)) == NULL)
            {
-             _cupsSetHTTPError(HTTP_ERROR);
+             _cupsSetHTTPError(HTTP_STATUS_ERROR);
              DEBUG_puts("1ippReadIO: unable to allocate attribute.");
              _cupsBufferRelease((char *)buffer);
-             return (IPP_ERROR);
+             return (IPP_STATE_ERROR);
            }
 
            DEBUG_printf(("2ippReadIO: name=\"%s\", ipp->current=%p, "
@@ -3294,7 +3340,7 @@ ippReadIO(void       *src,                /* I - Data source */
          {
            DEBUG_puts("1ippReadIO: unable to read value length.");
            _cupsBufferRelease((char *)buffer);
-           return (IPP_ERROR);
+           return (IPP_STATE_ERROR);
          }
 
          n = (buffer[0] << 8) | buffer[1];
@@ -3302,11 +3348,11 @@ ippReadIO(void       *src,              /* I - Data source */
 
          if (n >= IPP_BUF_SIZE)
          {
-           _cupsSetError(IPP_INTERNAL_ERROR,
+           _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                          _("IPP value larger than 32767 bytes."), 1);
            DEBUG_printf(("1ippReadIO: bad value length %d.", n));
            _cupsBufferRelease((char *)buffer);
-           return (IPP_ERROR);
+           return (IPP_STATE_ERROR);
          }
 
          switch (tag)
@@ -3316,21 +3362,21 @@ ippReadIO(void       *src,              /* I - Data source */
                if (n != 4)
                {
                  if (tag == IPP_TAG_INTEGER)
-                   _cupsSetError(IPP_INTERNAL_ERROR,
+                   _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                                  _("IPP integer value not 4 bytes."), 1);
                  else
-                   _cupsSetError(IPP_INTERNAL_ERROR,
+                   _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                                  _("IPP enum value not 4 bytes."), 1);
                  DEBUG_printf(("1ippReadIO: bad integer value length %d.", n));
                  _cupsBufferRelease((char *)buffer);
-                 return (IPP_ERROR);
+                 return (IPP_STATE_ERROR);
                }
 
                if ((*cb)(src, buffer, 4) < 4)
                {
                  DEBUG_puts("1ippReadIO: Unable to read integer value.");
                  _cupsBufferRelease((char *)buffer);
-                 return (IPP_ERROR);
+                 return (IPP_STATE_ERROR);
                }
 
                n = (((((buffer[0] << 8) | buffer[1]) << 8) | buffer[2]) << 8) |
@@ -3345,18 +3391,18 @@ ippReadIO(void       *src,              /* I - Data source */
            case IPP_TAG_BOOLEAN :
                if (n != 1)
                {
-                 _cupsSetError(IPP_INTERNAL_ERROR, _("IPP boolean value not 1 byte."),
+                 _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP boolean value not 1 byte."),
                                1);
                  DEBUG_printf(("1ippReadIO: bad boolean value length %d.", n));
                  _cupsBufferRelease((char *)buffer);
-                 return (IPP_ERROR);
+                 return (IPP_STATE_ERROR);
                }
 
                if ((*cb)(src, buffer, 1) < 1)
                {
                  DEBUG_puts("1ippReadIO: Unable to read boolean value.");
                  _cupsBufferRelease((char *)buffer);
-                 return (IPP_ERROR);
+                 return (IPP_STATE_ERROR);
                }
 
                 value->boolean = buffer[0];
@@ -3394,7 +3440,7 @@ ippReadIO(void       *src,                /* I - Data source */
                  {
                    DEBUG_puts("1ippReadIO: unable to read string value.");
                    _cupsBufferRelease((char *)buffer);
-                   return (IPP_ERROR);
+                   return (IPP_STATE_ERROR);
                  }
                }
 
@@ -3406,35 +3452,35 @@ ippReadIO(void       *src,              /* I - Data source */
            case IPP_TAG_DATE :
                if (n != 11)
                {
-                 _cupsSetError(IPP_INTERNAL_ERROR, _("IPP date value not 11 bytes."), 1);
+                 _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("IPP date value not 11 bytes."), 1);
                  DEBUG_printf(("1ippReadIO: bad date value length %d.", n));
                  _cupsBufferRelease((char *)buffer);
-                 return (IPP_ERROR);
+                 return (IPP_STATE_ERROR);
                }
 
                if ((*cb)(src, value->date, 11) < 11)
                {
                  DEBUG_puts("1ippReadIO: Unable to read date value.");
                  _cupsBufferRelease((char *)buffer);
-                 return (IPP_ERROR);
+                 return (IPP_STATE_ERROR);
                }
                break;
 
            case IPP_TAG_RESOLUTION :
                if (n != 9)
                {
-                 _cupsSetError(IPP_INTERNAL_ERROR,
+                 _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                                _("IPP resolution value not 9 bytes."), 1);
                  DEBUG_printf(("1ippReadIO: bad resolution value length %d.", n));
                  _cupsBufferRelease((char *)buffer);
-                 return (IPP_ERROR);
+                 return (IPP_STATE_ERROR);
                }
 
                if ((*cb)(src, buffer, 9) < 9)
                {
                  DEBUG_puts("1ippReadIO: Unable to read resolution value.");
                  _cupsBufferRelease((char *)buffer);
-                 return (IPP_ERROR);
+                 return (IPP_STATE_ERROR);
                }
 
                 value->resolution.xres =
@@ -3450,19 +3496,19 @@ ippReadIO(void       *src,              /* I - Data source */
            case IPP_TAG_RANGE :
                if (n != 8)
                {
-                 _cupsSetError(IPP_INTERNAL_ERROR,
+                 _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                                _("IPP rangeOfInteger value not 8 bytes."), 1);
                  DEBUG_printf(("1ippReadIO: bad rangeOfInteger value length "
                                "%d.", n));
                  _cupsBufferRelease((char *)buffer);
-                 return (IPP_ERROR);
+                 return (IPP_STATE_ERROR);
                }
 
                if ((*cb)(src, buffer, 8) < 8)
                {
                  DEBUG_puts("1ippReadIO: Unable to read range value.");
                  _cupsBufferRelease((char *)buffer);
-                 return (IPP_ERROR);
+                 return (IPP_STATE_ERROR);
                }
 
                 value->range.lower =
@@ -3478,17 +3524,17 @@ ippReadIO(void       *src,              /* I - Data source */
                if (n < 4)
                {
                  if (tag == IPP_TAG_TEXTLANG)
-                   _cupsSetError(IPP_INTERNAL_ERROR,
+                   _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                                  _("IPP textWithLanguage value less than "
                                    "minimum 4 bytes."), 1);
                  else
-                   _cupsSetError(IPP_INTERNAL_ERROR,
+                   _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                                  _("IPP nameWithLanguage value less than "
                                    "minimum 4 bytes."), 1);
                  DEBUG_printf(("1ippReadIO: bad stringWithLanguage value "
                                "length %d.", n));
                  _cupsBufferRelease((char *)buffer);
-                 return (IPP_ERROR);
+                 return (IPP_STATE_ERROR);
                }
 
                if ((*cb)(src, buffer, n) < n)
@@ -3496,7 +3542,7 @@ ippReadIO(void       *src,                /* I - Data source */
                  DEBUG_puts("1ippReadIO: Unable to read string w/language "
                             "value.");
                  _cupsBufferRelease((char *)buffer);
-                 return (IPP_ERROR);
+                 return (IPP_STATE_ERROR);
                }
 
                 bufptr = buffer;
@@ -3516,21 +3562,21 @@ ippReadIO(void       *src,              /* I - Data source */
                if ((bufptr + 2 + n) >= (buffer + IPP_BUF_SIZE) ||
                    n >= sizeof(string))
                {
-                 _cupsSetError(IPP_INTERNAL_ERROR,
+                 _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                                _("IPP language length overflows value."), 1);
                  DEBUG_printf(("1ippReadIO: bad language value length %d.",
                                n));
                  _cupsBufferRelease((char *)buffer);
-                 return (IPP_ERROR);
+                 return (IPP_STATE_ERROR);
                }
                else if (n >= IPP_MAX_LANGUAGE)
                {
-                 _cupsSetError(IPP_INTERNAL_ERROR,
+                 _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                                _("IPP language length too large."), 1);
                  DEBUG_printf(("1ippReadIO: bad language value length %d.",
                                n));
                  _cupsBufferRelease((char *)buffer);
-                 return (IPP_ERROR);
+                 return (IPP_STATE_ERROR);
                }
 
                memcpy(string, bufptr + 2, n);
@@ -3543,11 +3589,11 @@ ippReadIO(void       *src,              /* I - Data source */
 
                if ((bufptr + 2 + n) >= (buffer + IPP_BUF_SIZE))
                {
-                 _cupsSetError(IPP_INTERNAL_ERROR,
+                 _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                                _("IPP string length overflows value."), 1);
                  DEBUG_printf(("1ippReadIO: bad string value length %d.", n));
                  _cupsBufferRelease((char *)buffer);
-                 return (IPP_ERROR);
+                 return (IPP_STATE_ERROR);
                }
 
                bufptr[2 + n] = '\0';
@@ -3563,19 +3609,19 @@ ippReadIO(void       *src,              /* I - Data source */
 
                 if (n > 0)
                {
-                 _cupsSetError(IPP_INTERNAL_ERROR,
+                 _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                                _("IPP begCollection value not 0 bytes."), 1);
                  DEBUG_puts("1ippReadIO: begCollection tag with value length "
                             "> 0.");
                  _cupsBufferRelease((char *)buffer);
-                 return (IPP_ERROR);
+                 return (IPP_STATE_ERROR);
                }
 
-               if (ippReadIO(src, cb, 1, ipp, value->collection) == IPP_ERROR)
+               if (ippReadIO(src, cb, 1, ipp, value->collection) == IPP_STATE_ERROR)
                {
                  DEBUG_puts("1ippReadIO: Unable to read collection value.");
                  _cupsBufferRelease((char *)buffer);
-                 return (IPP_ERROR);
+                 return (IPP_STATE_ERROR);
                }
                 break;
 
@@ -3584,15 +3630,15 @@ ippReadIO(void       *src,              /* I - Data source */
 
                 if (n > 0)
                {
-                 _cupsSetError(IPP_INTERNAL_ERROR,
+                 _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                                _("IPP endCollection value not 0 bytes."), 1);
                  DEBUG_puts("1ippReadIO: endCollection tag with value length "
                             "> 0.");
-                 return (IPP_ERROR);
+                 return (IPP_STATE_ERROR);
                }
 
                DEBUG_puts("1ippReadIO: endCollection tag...");
-               return (ipp->state = IPP_DATA);
+               return (ipp->state = IPP_STATE_DATA);
 
             case IPP_TAG_MEMBERNAME :
               /*
@@ -3602,25 +3648,25 @@ ippReadIO(void       *src,              /* I - Data source */
 
                 if (!attr)
                 {
-                 _cupsSetError(IPP_INTERNAL_ERROR,
+                 _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                                _("IPP memberName with no attribute."), 1);
                  DEBUG_puts("1ippReadIO: Member name without attribute.");
                  _cupsBufferRelease((char *)buffer);
-                 return (IPP_ERROR);
+                 return (IPP_STATE_ERROR);
                 }
                else if (n == 0)
                {
-                 _cupsSetError(IPP_INTERNAL_ERROR,
+                 _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                                _("IPP memberName value is empty."), 1);
                  DEBUG_puts("1ippReadIO: Empty member name value.");
                  _cupsBufferRelease((char *)buffer);
-                 return (IPP_ERROR);
+                 return (IPP_STATE_ERROR);
                }
                else if ((*cb)(src, buffer, n) < n)
                {
                  DEBUG_puts("1ippReadIO: Unable to read member name value.");
                  _cupsBufferRelease((char *)buffer);
-                 return (IPP_ERROR);
+                 return (IPP_STATE_ERROR);
                }
 
                buffer[n] = '\0';
@@ -3640,12 +3686,12 @@ ippReadIO(void       *src,              /* I - Data source */
             default : /* Other unsupported values */
                 if (tag == IPP_TAG_STRING && n > IPP_MAX_LENGTH)
                {
-                 _cupsSetError(IPP_INTERNAL_ERROR,
+                 _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                                _("IPP octetString length too large."), 1);
                  DEBUG_printf(("1ippReadIO: bad octetString value length %d.",
                                n));
                  _cupsBufferRelease((char *)buffer);
-                 return (IPP_ERROR);
+                 return (IPP_STATE_ERROR);
                }
 
                 value->unknown.length = n;
@@ -3654,17 +3700,17 @@ ippReadIO(void       *src,              /* I - Data source */
                {
                  if ((value->unknown.data = malloc(n)) == NULL)
                  {
-                   _cupsSetHTTPError(HTTP_ERROR);
+                   _cupsSetHTTPError(HTTP_STATUS_ERROR);
                    DEBUG_puts("1ippReadIO: Unable to allocate value");
                    _cupsBufferRelease((char *)buffer);
-                   return (IPP_ERROR);
+                   return (IPP_STATE_ERROR);
                  }
 
                  if ((*cb)(src, value->unknown.data, n) < n)
                  {
                    DEBUG_puts("1ippReadIO: Unable to read unsupported value.");
                    _cupsBufferRelease((char *)buffer);
-                   return (IPP_ERROR);
+                   return (IPP_STATE_ERROR);
                  }
                }
                else
@@ -3681,7 +3727,7 @@ ippReadIO(void       *src,                /* I - Data source */
        }
         break;
 
-    case IPP_DATA :
+    case IPP_STATE_DATA :
         break;
 
     default :
@@ -3710,7 +3756,7 @@ ippReadIO(void       *src,                /* I - Data source */
  */
 
 int                                    /* O  - 1 on success, 0 on failure */
-ippSetBoolean(ipp_t           *ipp,    /* IO - IPP message */
+ippSetBoolean(ipp_t           *ipp,    /* I  - IPP message */
               ipp_attribute_t **attr,  /* IO - IPP attribute */
               int             element, /* I  - Value number (0-based) */
               int             boolvalue)/* I  - Boolean value */
@@ -3753,7 +3799,7 @@ ippSetBoolean(ipp_t           *ipp,       /* IO - IPP message */
 
 int                                    /* O  - 1 on success, 0 on failure */
 ippSetCollection(
-    ipp_t           *ipp,              /* IO - IPP message */
+    ipp_t           *ipp,              /* I  - IPP message */
     ipp_attribute_t **attr,            /* IO - IPP attribute */
     int             element,           /* I  - Value number (0-based) */
     ipp_t           *colvalue)         /* I  - Collection value */
@@ -3801,7 +3847,7 @@ ippSetCollection(
  */
 
 int                                    /* O  - 1 on success, 0 on failure */
-ippSetDate(ipp_t             *ipp,     /* IO - IPP message */
+ippSetDate(ipp_t             *ipp,     /* I  - IPP message */
            ipp_attribute_t   **attr,   /* IO - IPP attribute */
            int               element,  /* I  - Value number (0-based) */
            const ipp_uchar_t *datevalue)/* I  - Date value */
@@ -3847,7 +3893,7 @@ ippSetDate(ipp_t             *ipp,        /* IO - IPP message */
 
 int                                    /* O  - 1 on success, 0 on failure */
 ippSetGroupTag(
-    ipp_t           *ipp,              /* IO - IPP message */
+    ipp_t           *ipp,              /* I  - IPP message */
     ipp_attribute_t **attr,            /* IO - Attribute */
     ipp_tag_t       group_tag)         /* I  - Group tag */
 {
@@ -3885,7 +3931,7 @@ ippSetGroupTag(
  */
 
 int                                    /* O  - 1 on success, 0 on failure */
-ippSetInteger(ipp_t           *ipp,    /* IO - IPP message */
+ippSetInteger(ipp_t           *ipp,    /* I  - IPP message */
               ipp_attribute_t **attr,  /* IO - IPP attribute */
               int             element, /* I  - Value number (0-based) */
               int             intvalue)        /* I  - Integer/enum value */
@@ -3925,7 +3971,7 @@ ippSetInteger(ipp_t           *ipp,       /* IO - IPP message */
  */
 
 int                                    /* O  - 1 on success, 0 on failure */
-ippSetName(ipp_t           *ipp,       /* IO - IPP message */
+ippSetName(ipp_t           *ipp,       /* I  - IPP message */
           ipp_attribute_t **attr,      /* IO - IPP attribute */
           const char      *name)       /* I  - Attribute name */
 {
@@ -3955,6 +4001,94 @@ ippSetName(ipp_t           *ipp, /* IO - IPP message */
 }
 
 
+/*
+ * 'ippSetOctetString()' - Set an octetString value in an IPP attribute.
+ *
+ * The @code ipp@ parameter refers to an IPP message previously created using
+ * the @link ippNew@, @link ippNewRequest@, or  @link ippNewResponse@ functions.
+ *
+ * The @code attr@ parameter may be modified as a result of setting the value.
+ *
+ * The @code element@ parameter specifies which value to set from 0 to
+ * @link ippGetCount(attr)@.
+ *
+ * @since CUPS 1.7/OS X 10.9@
+ */
+
+int                                    /* O  - 1 on success, 0 on failure */
+ippSetOctetString(
+    ipp_t           *ipp,              /* I  - IPP message */
+    ipp_attribute_t **attr,            /* IO - IPP attribute */
+    int             element,           /* I  - Value number (0-based) */
+    const void      *data,             /* I  - Pointer to octetString data */
+    int             datalen)           /* I  - Length of octetString data */
+{
+  _ipp_value_t *value;                 /* Current value */
+
+
+ /*
+  * Range check input...
+  */
+
+  if (!ipp || !attr || !*attr || (*attr)->value_tag != IPP_TAG_STRING ||
+      element < 0 || element > (*attr)->num_values ||
+      datalen < 0 || datalen > IPP_MAX_LENGTH)
+    return (0);
+
+ /*
+  * Set the value and return...
+  */
+
+  if ((value = ipp_set_value(ipp, attr, element)) != NULL)
+  {
+    if ((int)((*attr)->value_tag) & IPP_TAG_CUPS_CONST)
+    {
+     /*
+      * Just copy the pointer...
+      */
+
+      value->unknown.data   = (void *)data;
+      value->unknown.length = datalen;
+    }
+    else
+    {
+     /*
+      * Copy the data...
+      */
+
+      if (value->unknown.data)
+      {
+       /*
+       * Free previous data...
+       */
+
+       free(value->unknown.data);
+
+       value->unknown.data   = NULL;
+        value->unknown.length = 0;
+      }
+
+      if (datalen > 0)
+      {
+       void    *temp;                  /* Temporary data pointer */
+
+       if ((temp = malloc(datalen)) != NULL)
+       {
+         memcpy(temp, data, datalen);
+
+         value->unknown.data   = temp;
+         value->unknown.length = datalen;
+       }
+       else
+         return (0);
+      }
+    }
+  }
+
+  return (value != NULL);
+}
+
+
 /*
  * 'ippSetOperation()' - Set the operation ID in an IPP request message.
  *
@@ -4000,7 +4134,7 @@ ippSetOperation(ipp_t    *ipp,            /* I - IPP request message */
  */
 
 int                                    /* O  - 1 on success, 0 on failure */
-ippSetRange(ipp_t           *ipp,      /* IO - IPP message */
+ippSetRange(ipp_t           *ipp,      /* I  - IPP message */
             ipp_attribute_t **attr,    /* IO - IPP attribute */
             int             element,   /* I  - Value number (0-based) */
            int             lowervalue, /* I  - Lower bound for range */
@@ -4081,7 +4215,7 @@ ippSetRequestId(ipp_t *ipp,               /* I - IPP message */
 
 int                                    /* O  - 1 on success, 0 on failure */
 ippSetResolution(
-    ipp_t           *ipp,              /* IO - IPP message */
+    ipp_t           *ipp,              /* I  - IPP message */
     ipp_attribute_t **attr,            /* IO - IPP attribute */
     int             element,           /* I  - Value number (0-based) */
     ipp_res_t       unitsvalue,                /* I  - Resolution units */
@@ -4188,7 +4322,7 @@ ippSetStatusCode(ipp_t        *ipp,       /* I - IPP response or event message */
  */
 
 int                                    /* O  - 1 on success, 0 on failure */
-ippSetString(ipp_t           *ipp,     /* IO - IPP message */
+ippSetString(ipp_t           *ipp,     /* I  - IPP message */
              ipp_attribute_t **attr,   /* IO - IPP attribute */
              int             element,  /* I  - Value number (0-based) */
             const char      *strvalue) /* I  - String value */
@@ -4218,7 +4352,7 @@ ippSetString(ipp_t           *ipp,        /* IO - IPP message */
     if (element > 0)
       value->string.language = (*attr)->values[0].string.language;
 
-    if ((int)((*attr)->value_tag) & IPP_TAG_COPY)
+    if ((int)((*attr)->value_tag) & IPP_TAG_CUPS_CONST)
       value->string.text = (char *)strvalue;
     else if ((temp = _cupsStrAlloc(strvalue)) != NULL)
     {
@@ -4251,11 +4385,11 @@ ippSetString(ipp_t           *ipp,      /* IO - IPP message */
  * needed.  The formatted string is truncated as needed to the maximum length of
  * the corresponding value type.
  *
- * @since CUPS 1.7@
+ * @since CUPS 1.7/OS X 10.9@
  */
 
 int                                    /* O  - 1 on success, 0 on failure */
-ippSetStringf(ipp_t           *ipp,    /* IO - IPP message */
+ippSetStringf(ipp_t           *ipp,    /* I  - IPP message */
               ipp_attribute_t **attr,  /* IO - IPP attribute */
               int             element, /* I  - Value number (0-based) */
              const char      *format,  /* I  - Printf-style format string */
@@ -4289,11 +4423,11 @@ ippSetStringf(ipp_t           *ipp,     /* IO - IPP message */
  * needed.  The formatted string is truncated as needed to the maximum length of
  * the corresponding value type.
  *
- * @since CUPS 1.7@
+ * @since CUPS 1.7/OS X 10.9@
  */
 
 int                                    /* O  - 1 on success, 0 on failure */
-ippSetStringfv(ipp_t           *ipp,   /* IO - IPP message */
+ippSetStringfv(ipp_t           *ipp,   /* I  - IPP message */
                ipp_attribute_t **attr, /* IO - IPP attribute */
                int             element,        /* I  - Value number (0-based) */
               const char      *format, /* I  - Printf-style format string */
@@ -4318,7 +4452,7 @@ ippSetStringfv(ipp_t           *ipp,      /* IO - IPP message */
   if (!ipp || !attr || !*attr ||
       (value_tag < IPP_TAG_TEXT && value_tag != IPP_TAG_TEXTLANG &&
        value_tag != IPP_TAG_NAMELANG) || value_tag > IPP_TAG_MIMETYPE ||
-      !format || !ap)
+      !format)
     return (0);
 
  /*
@@ -4446,7 +4580,7 @@ ippSetStringfv(ipp_t           *ipp,      /* IO - IPP message */
 
 int                                    /* O  - 1 on success, 0 on failure */
 ippSetValueTag(
-    ipp_t          *ipp,               /* IO - IPP message */
+    ipp_t          *ipp,               /* I  - IPP message */
     ipp_attribute_t **attr,            /* IO - IPP attribute */
     ipp_tag_t       value_tag)         /* I  - Value tag */
 {
@@ -4476,7 +4610,7 @@ ippSetValueTag(
   * Otherwise implement changes as needed...
   */
 
-  temp_tag = (ipp_tag_t)((int)((*attr)->value_tag) & IPP_TAG_MASK);
+  temp_tag = (ipp_tag_t)((int)((*attr)->value_tag) & IPP_TAG_CUPS_MASK);
 
   switch (value_tag)
   {
@@ -4522,7 +4656,7 @@ ippSetValueTag(
             temp_tag != IPP_TAG_MIMETYPE)
           return (0);
 
-        (*attr)->value_tag = (ipp_tag_t)(IPP_TAG_NAME | ((*attr)->value_tag & IPP_TAG_COPY));
+        (*attr)->value_tag = (ipp_tag_t)(IPP_TAG_NAME | ((*attr)->value_tag & IPP_TAG_CUPS_CONST));
         break;
 
     case IPP_TAG_NAMELANG :
@@ -4563,7 +4697,7 @@ ippSetValueTag(
              i --, value ++)
           value->string.language = (*attr)->values[0].string.language;
 
-        if ((int)(*attr)->value_tag & IPP_TAG_COPY)
+        if ((int)(*attr)->value_tag & IPP_TAG_CUPS_CONST)
         {
          /*
           * Make copies of all values...
@@ -4679,7 +4813,7 @@ ippTimeToDate(time_t t)                   /* I - UNIX time value */
  * value tag.  1 is returned if the attribute is valid, 0 otherwise.  On
  * failure, cupsLastErrorString() is set to a human-readable message.
  *
- * @since CUPS 1.7@
+ * @since CUPS 1.7/OS X 10.9@
  */
 
 int                                    /* O - 1 if valid, 0 otherwise */
@@ -5106,14 +5240,14 @@ ippValidateAttribute(
                                       hostname, sizeof(hostname),
                                       &port, resource, sizeof(resource));
 
-         if (uri_status < HTTP_URI_OK)
+         if (uri_status < HTTP_URI_STATUS_OK)
          {
            ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST,
                          _("\"%s\": Bad URI value \"%s\" - %s "
                            "(RFC 2911 section 4.1.5)."), attr->name,
                          attr->values[i].string.text,
                          uri_status_strings[uri_status -
-                                            HTTP_URI_OVERFLOW]);
+                                            HTTP_URI_STATUS_OVERFLOW]);
            return (0);
          }
 
@@ -5318,7 +5452,7 @@ ippValidateAttribute(
  * attribute.  Like @link ippValidateAttribute@, cupsLastErrorString() is set
  * to a human-readable message on failure.
  *
- * @since CUPS 1.7@
+ * @since CUPS 1.7/OS X 10.9@
  */
 
 int                                    /* O - 1 if valid, 0 otherwise */
@@ -5349,7 +5483,7 @@ ippWrite(http_t *http,                    /* I - HTTP connection */
   DEBUG_printf(("ippWrite(http=%p, ipp=%p)", http, ipp));
 
   if (!http)
-    return (IPP_ERROR);
+    return (IPP_STATE_ERROR);
 
   return (ippWriteIO(http, (ipp_iocb_t)httpWrite2, http->blocking, NULL, ipp));
 }
@@ -5367,7 +5501,7 @@ ippWriteFile(int   fd,                    /* I - HTTP data */
 {
   DEBUG_printf(("ippWriteFile(fd=%d, ipp=%p)", fd, ipp));
 
-  ipp->state = IPP_IDLE;
+  ipp->state = IPP_STATE_IDLE;
 
   return (ippWriteIO(&fd, (ipp_iocb_t)ipp_write_file, 1, NULL, ipp));
 }
@@ -5398,20 +5532,20 @@ ippWriteIO(void       *dst,             /* I - Destination */
                 dst, cb, blocking, parent, ipp));
 
   if (!dst || !ipp)
-    return (IPP_ERROR);
+    return (IPP_STATE_ERROR);
 
   if ((buffer = (unsigned char *)_cupsBufferGet(IPP_BUF_SIZE)) == NULL)
   {
     DEBUG_puts("1ippWriteIO: Unable to get write buffer");
-    return (IPP_ERROR);
+    return (IPP_STATE_ERROR);
   }
 
   switch (ipp->state)
   {
-    case IPP_IDLE :
+    case IPP_STATE_IDLE :
         ipp->state ++; /* Avoid common problem... */
 
-    case IPP_HEADER :
+    case IPP_STATE_HEADER :
         if (parent == NULL)
        {
         /*
@@ -5444,7 +5578,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
          {
            DEBUG_puts("1ippWriteIO: Could not write IPP header...");
            _cupsBufferRelease((char *)buffer);
-           return (IPP_ERROR);
+           return (IPP_STATE_ERROR);
          }
        }
 
@@ -5453,7 +5587,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
        * in the request/response, with no current group.
        */
 
-        ipp->state   = IPP_ATTRIBUTE;
+        ipp->state   = IPP_STATE_ATTRIBUTE;
        ipp->current = ipp->attrs;
        ipp->curtag  = IPP_TAG_ZERO;
 
@@ -5466,7 +5600,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
         if (!blocking)
          break;
 
-    case IPP_ATTRIBUTE :
+    case IPP_STATE_ATTRIBUTE :
         while (ipp->current != NULL)
        {
         /*
@@ -5523,7 +5657,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
            {
              DEBUG_printf(("1ippWriteIO: Attribute name too long (%d)", n));
              _cupsBufferRelease((char *)buffer);
-             return (IPP_ERROR);
+             return (IPP_STATE_ERROR);
            }
 
            /*
@@ -5562,7 +5696,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
            {
              DEBUG_printf(("1ippWriteIO: Attribute name too long (%d)", n));
              _cupsBufferRelease((char *)buffer);
-             return (IPP_ERROR);
+             return (IPP_STATE_ERROR);
            }
 
            /*
@@ -5605,7 +5739,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
          * Now write the attribute value(s)...
          */
 
-         switch (attr->value_tag & ~IPP_TAG_COPY)
+         switch (attr->value_tag & ~IPP_TAG_CUPS_CONST)
          {
            case IPP_TAG_UNSUPPORTED_VALUE :
            case IPP_TAG_DEFAULT :
@@ -5631,7 +5765,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                      DEBUG_puts("1ippWriteIO: Could not write IPP "
                                 "attribute...");
                      _cupsBufferRelease((char *)buffer);
-                     return (IPP_ERROR);
+                     return (IPP_STATE_ERROR);
                    }
 
                    bufptr = buffer;
@@ -5677,7 +5811,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                      DEBUG_puts("1ippWriteIO: Could not write IPP "
                                 "attribute...");
                      _cupsBufferRelease((char *)buffer);
-                     return (IPP_ERROR);
+                     return (IPP_STATE_ERROR);
                    }
 
                    bufptr = buffer;
@@ -5738,7 +5872,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                        DEBUG_puts("1ippWriteIO: Could not write IPP "
                                   "attribute...");
                        _cupsBufferRelease((char *)buffer);
-                       return (IPP_ERROR);
+                       return (IPP_STATE_ERROR);
                      }
 
                      bufptr = buffer;
@@ -5758,7 +5892,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                  {
                    DEBUG_printf(("1ippWriteIO: String too long (%d)", n));
                    _cupsBufferRelease((char *)buffer);
-                   return (IPP_ERROR);
+                   return (IPP_STATE_ERROR);
                  }
 
                   DEBUG_printf(("2ippWriteIO: writing string=%d,\"%s\"", n,
@@ -5771,7 +5905,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                      DEBUG_puts("1ippWriteIO: Could not write IPP "
                                 "attribute...");
                      _cupsBufferRelease((char *)buffer);
-                     return (IPP_ERROR);
+                     return (IPP_STATE_ERROR);
                    }
 
                    bufptr = buffer;
@@ -5810,7 +5944,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                      DEBUG_puts("1ippWriteIO: Could not write IPP "
                                 "attribute...");
                      _cupsBufferRelease((char *)buffer);
-                     return (IPP_ERROR);
+                     return (IPP_STATE_ERROR);
                    }
 
                    bufptr = buffer;
@@ -5855,7 +5989,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                      DEBUG_puts("1ippWriteIO: Could not write IPP "
                                 "attribute...");
                      _cupsBufferRelease((char *)buffer);
-                     return (IPP_ERROR);
+                     return (IPP_STATE_ERROR);
                    }
 
                    bufptr = buffer;
@@ -5908,7 +6042,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                      DEBUG_puts("1ippWriteIO: Could not write IPP "
                                 "attribute...");
                      _cupsBufferRelease((char *)buffer);
-                     return (IPP_ERROR);
+                     return (IPP_STATE_ERROR);
                    }
 
                    bufptr = buffer;
@@ -5967,7 +6101,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                        DEBUG_puts("1ippWriteIO: Could not write IPP "
                                   "attribute...");
                        _cupsBufferRelease((char *)buffer);
-                       return (IPP_ERROR);
+                       return (IPP_STATE_ERROR);
                      }
 
                      bufptr = buffer;
@@ -6001,7 +6135,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                    DEBUG_printf(("1ippWriteIO: text/nameWithLanguage value "
                                  "too long (%d)", n));
                    _cupsBufferRelease((char *)buffer);
-                   return (IPP_ERROR);
+                   return (IPP_STATE_ERROR);
                   }
 
                   if ((int)(IPP_BUF_SIZE - (bufptr - buffer)) < (n + 2))
@@ -6011,7 +6145,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                      DEBUG_puts("1ippWriteIO: Could not write IPP "
                                 "attribute...");
                      _cupsBufferRelease((char *)buffer);
-                     return (IPP_ERROR);
+                     return (IPP_STATE_ERROR);
                    }
 
                    bufptr = buffer;
@@ -6074,7 +6208,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                      DEBUG_puts("1ippWriteIO: Could not write IPP "
                                 "attribute...");
                      _cupsBufferRelease((char *)buffer);
-                     return (IPP_ERROR);
+                     return (IPP_STATE_ERROR);
                    }
 
                    bufptr = buffer;
@@ -6104,7 +6238,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                    DEBUG_puts("1ippWriteIO: Could not write IPP "
                               "attribute...");
                    _cupsBufferRelease((char *)buffer);
-                   return (IPP_ERROR);
+                   return (IPP_STATE_ERROR);
                  }
 
                  bufptr = buffer;
@@ -6113,14 +6247,14 @@ ippWriteIO(void       *dst,             /* I - Destination */
                  * Then write the collection attribute...
                  */
 
-                  value->collection->state = IPP_IDLE;
+                  value->collection->state = IPP_STATE_IDLE;
 
                  if (ippWriteIO(dst, cb, 1, ipp,
-                                value->collection) == IPP_ERROR)
+                                value->collection) == IPP_STATE_ERROR)
                  {
                    DEBUG_puts("1ippWriteIO: Unable to write collection value");
                    _cupsBufferRelease((char *)buffer);
-                   return (IPP_ERROR);
+                   return (IPP_STATE_ERROR);
                  }
                }
                break;
@@ -6144,7 +6278,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                        DEBUG_puts("1ippWriteIO: Could not write IPP "
                                   "attribute...");
                        _cupsBufferRelease((char *)buffer);
-                       return (IPP_ERROR);
+                       return (IPP_STATE_ERROR);
                      }
 
                      bufptr = buffer;
@@ -6169,7 +6303,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                    DEBUG_printf(("1ippWriteIO: Data length too long (%d)",
                                  n));
                    _cupsBufferRelease((char *)buffer);
-                   return (IPP_ERROR);
+                   return (IPP_STATE_ERROR);
                  }
 
                   if ((int)(IPP_BUF_SIZE - (bufptr - buffer)) < (n + 2))
@@ -6179,7 +6313,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                      DEBUG_puts("1ippWriteIO: Could not write IPP "
                                 "attribute...");
                      _cupsBufferRelease((char *)buffer);
-                     return (IPP_ERROR);
+                     return (IPP_STATE_ERROR);
                    }
 
                    bufptr = buffer;
@@ -6209,7 +6343,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
            {
              DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
              _cupsBufferRelease((char *)buffer);
-             return (IPP_ERROR);
+             return (IPP_STATE_ERROR);
            }
 
            DEBUG_printf(("2ippWriteIO: wrote %d bytes",
@@ -6217,10 +6351,11 @@ ippWriteIO(void       *dst,             /* I - Destination */
          }
 
         /*
-          * If blocking is disabled, stop here...
+          * If blocking is disabled and we aren't at the end of the attribute
+          * list, stop here...
          */
 
-          if (!blocking)
+          if (!blocking && ipp->current)
            break;
        }
 
@@ -6250,14 +6385,14 @@ ippWriteIO(void       *dst,             /* I - Destination */
          {
            DEBUG_puts("1ippWriteIO: Could not write IPP end-tag...");
            _cupsBufferRelease((char *)buffer);
-           return (IPP_ERROR);
+           return (IPP_STATE_ERROR);
          }
 
-         ipp->state = IPP_DATA;
+         ipp->state = IPP_STATE_DATA;
        }
         break;
 
-    case IPP_DATA :
+    case IPP_STATE_DATA :
         break;
 
     default :
@@ -6355,7 +6490,7 @@ ipp_free_values(ipp_attribute_t *attr,    /* I - Attribute to free values from */
   DEBUG_printf(("4ipp_free_values(attr=%p, element=%d, count=%d)", attr,
                 element, count));
 
-  if (!(attr->value_tag & IPP_TAG_COPY))
+  if (!(attr->value_tag & IPP_TAG_CUPS_CONST))
   {
    /*
     * Free values as needed...
@@ -6570,7 +6705,7 @@ ipp_length(ipp_t *ipp,                    /* I - IPP message or collection */
     if (collection)
       bytes += 5;                      /* Add membername overhead */
 
-    switch (attr->value_tag & ~IPP_TAG_COPY)
+    switch (attr->value_tag & ~IPP_TAG_CUPS_CONST)
     {
       case IPP_TAG_UNSUPPORTED_VALUE :
       case IPP_TAG_DEFAULT :
@@ -6692,7 +6827,7 @@ ipp_read_http(http_t      *http,  /* I - Client connection */
     DEBUG_printf(("9ipp_read_http: tbytes=%d, http->state=%d", tbytes,
                   http->state));
 
-    if (http->state == HTTP_WAITING)
+    if (http->state == HTTP_STATE_WAITING)
       break;
 
     if (http->used == 0 && !http->blocking)
@@ -6836,7 +6971,7 @@ ipp_set_value(ipp_t           *ipp,       /* IO - IPP message */
   if ((temp = realloc(temp, sizeof(ipp_attribute_t) +
                            (alloc_values - 1) * sizeof(_ipp_value_t))) == NULL)
   {
-    _cupsSetHTTPError(HTTP_ERROR);
+    _cupsSetHTTPError(HTTP_STATUS_ERROR);
     DEBUG_puts("4ipp_set_value: Unable to resize attribute.");
     return (NULL);
   }
@@ -6879,7 +7014,7 @@ ipp_set_value(ipp_t           *ipp,       /* IO - IPP message */
        */
 
        *attr = temp;
-       _cupsSetError(IPP_INTERNAL_ERROR,
+       _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
                      _("IPP attribute is not a member of the message."), 1);
        DEBUG_puts("4ipp_set_value: Unable to find attribute in message.");
        return (NULL);
@@ -6929,5 +7064,5 @@ ipp_write_file(int         *fd,           /* I - File descriptor */
 
 
 /*
- * End of "$Id: ipp.c 10102 2011-11-02 23:52:39Z mike $".
+ * End of "$Id: ipp.c 11113 2013-07-10 14:08:39Z msweet $".
  */