]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Merge changes from cups-api.1.6 branch - ipp_t and friends are now private types
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Wed, 2 Nov 2011 05:35:38 +0000 (05:35 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Wed, 2 Nov 2011 05:35:38 +0000 (05:35 +0000)
with public accessors.

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10097 7a7537e8-13f0-0310-91df-b6672ffda945

28 files changed:
cgi-bin/cgi-private.h
cups/encode.c
cups/http.c
cups/http.h
cups/ipp-private.h
cups/ipp-support.c
cups/ipp.c
cups/ipp.h
cups/libcups_s.exp
cups/testipp.c
notifier/mailto.c
notifier/rss.c
notifier/testnotify.c
scheduler/ipp.c
scheduler/printers.c
scheduler/testsub.c
test/5.1-lpadmin.sh
test/5.2-lpc.sh
test/5.3-lpq.sh
test/5.4-lpstat.sh
test/5.5-lp.sh
test/5.6-lpr.sh
test/5.7-lprm.sh
test/5.8-cancel.sh
test/5.9-lpinfo.sh
test/ippserver.c
test/ipptool.c
test/run-stp-tests.sh

index a2c4e9d7abe6b66d3affc3b658c1cfd1c6fdbc61..1f9690273900f32e92b90e601f88bacdc4a12822 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Private CGI definitions for CUPS.
  *
- *   Copyright 2007-2010 by Apple Inc.
+ *   Copyright 2007-2011 by Apple Inc.
  *   Copyright 1997-2006 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -21,6 +21,7 @@
 #include <cups/debug-private.h>
 #include <cups/language-private.h>
 #include <cups/string-private.h>
+#include <cups/ipp-private.h>  /* TODO: Update so we don't need this */
 
 
 /*
index 51acfd6e63b9dc8be0823c6dc5249111a5cf3e2d..1ec32b520fa5adfb0828301519828686e8f967a9 100644 (file)
@@ -343,7 +343,8 @@ cupsEncodeOptions2(
     * Allocate memory for the attribute values...
     */
 
-    if ((attr = _ippAddAttr(ipp, count)) == NULL)
+    if ((attr = ippAddStrings(ipp, group_tag, value_tag, option->name, count,
+                              NULL, NULL)) == NULL)
     {
      /*
       * Ran out of memory!
@@ -353,19 +354,6 @@ cupsEncodeOptions2(
       return;
     }
 
-   /*
-    * Now figure out what type of value we have...
-    */
-
-    attr->group_tag = group_tag;
-    attr->value_tag = value_tag;
-
-   /*
-    * Copy the name over...
-    */
-
-    attr->name = _cupsStrAlloc(option->name);
-
     if (count > 1)
     {
      /*
index 952297b56aa194d1eb473bdd5e2295b281b05796..db99174b0706f81bbe851fa65fe1b5156a33791c 100644 (file)
  *
  * Contents:
  *
- *   httpAddCredential()       - Allocates and adds a single credential to an
- *                               array.
- *   _httpBIOMethods()         - Get the OpenSSL BIO methods for HTTP
- *                               connections.
- *   httpBlocking()            - Set blocking/non-blocking behavior on a
- *                               connection.
- *   httpCheck()               - Check to see if there is a pending response
- *                               from the server.
- *   httpClearCookie()         - Clear the cookie value(s).
- *   httpClearFields()         - Clear HTTP request fields.
- *   httpClose()               - Close an HTTP connection.
- *   httpConnect()             - Connect to a HTTP server.
- *   httpConnectEncrypt()      - Connect to a HTTP server using encryption.
- *   httpCopyCredentials()     - Copy the credentials associated with an
- *                               encrypted connection.
- *   _httpCreate()             - Create an unconnected HTTP connection.
- *   _httpCreateCredentials()  - Create credentials in the internal format.
- *   httpDelete()              - Send a DELETE request to the server.
- *   _httpDisconnect()         - Disconnect a HTTP connection.
- *   httpEncryption()          - Set the required encryption on the link.
- *   httpError()               - Get the last error on a connection.
- *   httpFlush()               - Flush data from a HTTP connection.
- *   httpFlushWrite()          - Flush data in write buffer.
- *   _httpFreeCredentials()    - Free internal credentials.
- *   httpFreeCredentials()     - Free an array of credentials.
- *   httpGet()                 - Send a GET request to the server.
- *   httpGetAuthString()       - Get the current authorization string.
- *   httpGetBlocking()         - Get the blocking/non-block state of a
- *                               connection.
- *   httpGetCookie()           - Get any cookie data from the response.
- *   httpGetFd()               - Get the file descriptor associated with a
- *                               connection.
- *   httpGetField()            - Get a field value from a request/response.
- *   httpGetLength()           - Get the amount of data remaining from the
- *                               content-length or transfer-encoding fields.
- *   httpGetLength2()          - Get the amount of data remaining from the
- *                               content-length or transfer-encoding fields.
- *   httpGetStatus()           - Get the status of the last HTTP request.
- *   httpGetSubField()         - Get a sub-field value.
- *   httpGetSubField2()        - Get a sub-field value.
- *   httpGets()                - Get a line of text from a HTTP connection.
- *   httpHead()                - Send a HEAD request to the server.
- *   httpInitialize()          - Initialize the HTTP interface library and set
- *                               the default HTTP proxy (if any).
- *   httpOptions()             - Send an OPTIONS request to the server.
- *   _httpPeek()               - Peek at data from a HTTP connection.
- *   httpPost()                - Send a POST request to the server.
- *   httpPrintf()              - Print a formatted string to a HTTP connection.
- *   httpPut()                 - Send a PUT request to the server.
- *   httpRead()                - Read data from a HTTP connection.
- *   httpRead2()               - Read data from a HTTP connection.
- *   _httpReadCDSA()           - Read function for the CDSA library.
- *   _httpReadGNUTLS()         - Read function for the GNU TLS library.
- *   httpReconnect()           - Reconnect to a HTTP server.
- *   httpSetAuthString()       - Set the current authorization string.
- *   httpSetCredentials()      - Set the credentials associated with an
- *                               encrypted connection.
- *   httpSetCookie()           - Set the cookie value(s).
- *   httpSetExpect()           - Set the Expect: header in a request.
- *   httpSetField()            - Set the value of an HTTP header.
- *   httpSetLength()           - Set the content-length and content-encoding.
- *   httpSetTimeout()          - Set read/write timeouts and an optional
- *                               callback.
- *   httpTrace()               - Send an TRACE request to the server.
- *   _httpUpdate()             - Update the current HTTP status for incoming
- *                               data.
- *   httpUpdate()              - Update the current HTTP state for incoming
- *                               data.
- *   _httpWait()               - Wait for data available on a connection (no
- *                               flush).
- *   httpWait()                - Wait for data available on a connection.
- *   httpWrite()               - Write data to a HTTP connection.
- *   httpWrite2()              - Write data to a HTTP connection.
- *   _httpWriteCDSA()          - Write function for the CDSA library.
- *   _httpWriteGNUTLS()        - Write function for the GNU TLS library.
- *   http_bio_ctrl()           - Control the HTTP connection.
- *   http_bio_free()           - Free OpenSSL data.
- *   http_bio_new()            - Initialize an OpenSSL BIO structure.
- *   http_bio_puts()           - Send a string for OpenSSL.
- *   http_bio_read()           - Read data for OpenSSL.
- *   http_bio_write()          - Write data for OpenSSL.
- *   http_debug_hex()          - Do a hex dump of a buffer.
- *   http_field()              - Return the field index for a field name.
- *   http_read_ssl()           - Read from a SSL/TLS connection.
- *   http_locking_cb()         - Lock/unlock a thread's mutex.
- *   http_send()               - Send a request with all fields and the trailing
- *                               blank line.
- *   http_set_credentials()    - Set the SSL/TLS credentials.
- *   http_set_timeout()        - Set the socket timeout values.
- *   http_set_wait()           - Set the default wait value for reads.
- *   http_setup_ssl()          - Set up SSL/TLS support on a connection.
- *   http_shutdown_ssl()       - Shut down SSL/TLS on a connection.
- *   http_threadid_cb()        - Return the current thread ID.
- *   http_upgrade()            - Force upgrade to TLS encryption.
- *   http_write()              - Write a buffer to a HTTP connection.
- *   http_write_chunk()        - Write a chunked buffer.
- *   http_write_ssl()          - Write to a SSL/TLS connection.
+ *   httpAddCredential()      - Allocates and adds a single credential to an
+ *                             array.
+ *   _httpBIOMethods()       - Get the OpenSSL BIO methods for HTTP
+ *                             connections.
+ *   httpBlocking()          - Set blocking/non-blocking behavior on a
+ *                             connection.
+ *   httpCheck()             - Check to see if there is a pending response
+ *                             from the server.
+ *   httpClearCookie()       - Clear the cookie value(s).
+ *   httpClearFields()       - Clear HTTP request fields.
+ *   httpClose()             - Close an HTTP connection.
+ *   httpConnect()           - Connect to a HTTP server.
+ *   httpConnectEncrypt()     - Connect to a HTTP server using encryption.
+ *   httpCopyCredentials()    - Copy the credentials associated with an
+ *                             encrypted connection.
+ *   _httpCreate()           - Create an unconnected HTTP connection.
+ *   _httpCreateCredentials() - Create credentials in the internal format.
+ *   httpDelete()            - Send a DELETE request to the server.
+ *   _httpDisconnect()       - Disconnect a HTTP connection.
+ *   httpEncryption()        - Set the required encryption on the link.
+ *   httpError()             - Get the last error on a connection.
+ *   httpFlush()             - Flush data from a HTTP connection.
+ *   httpFlushWrite()        - Flush data in write buffer.
+ *   _httpFreeCredentials()   - Free internal credentials.
+ *   httpFreeCredentials()    - Free an array of credentials.
+ *   httpGet()               - Send a GET request to the server.
+ *   httpGetAuthString()      - Get the current authorization string.
+ *   httpGetBlocking()       - Get the blocking/non-block state of a
+ *                             connection.
+ *   httpGetCookie()         - Get any cookie data from the response.
+ *   httpGetFd()             - Get the file descriptor associated with a
+ *                             connection.
+ *   httpGetField()          - Get a field value from a request/response.
+ *   httpGetLength()         - Get the amount of data remaining from the
+ *                             content-length or transfer-encoding fields.
+ *   httpGetLength2()        - Get the amount of data remaining from the
+ *                             content-length or transfer-encoding fields.
+ *   httpGets()              - Get a line of text from a HTTP connection.
+ *   httpGetState()          - Get the current state of the HTTP request.
+ *   httpGetStatus()         - Get the status of the last HTTP request.
+ *   httpGetSubField()       - Get a sub-field value.
+ *   httpGetSubField2()       - Get a sub-field value.
+ *   httpGetVersion()        - Get the HTTP version at the other end.
+ *   httpHead()              - Send a HEAD request to the server.
+ *   httpInitialize()        - Initialize the HTTP interface library and set
+ *                             the default HTTP proxy (if any).
+ *   httpOptions()           - Send an OPTIONS request to the server.
+ *   _httpPeek()             - Peek at data from a HTTP connection.
+ *   httpPost()              - Send a POST request to the server.
+ *   httpPrintf()            - Print a formatted string to a HTTP connection.
+ *   httpPut()               - Send a PUT request to the server.
+ *   httpRead()              - Read data from a HTTP connection.
+ *   httpRead2()             - Read data from a HTTP connection.
+ *   _httpReadCDSA()         - Read function for the CDSA library.
+ *   _httpReadGNUTLS()       - Read function for the GNU TLS library.
+ *   httpReconnect()         - Reconnect to a HTTP server.
+ *   httpSetAuthString()      - Set the current authorization string.
+ *   httpSetCredentials()     - Set the credentials associated with an
+ *                             encrypted connection.
+ *   httpSetCookie()         - Set the cookie value(s).
+ *   httpSetExpect()         - Set the Expect: header in a request.
+ *   httpSetField()          - Set the value of an HTTP header.
+ *   httpSetLength()         - Set the content-length and content-encoding.
+ *   httpSetTimeout()        - Set read/write timeouts and an optional
+ *                             callback.
+ *   httpTrace()             - Send an TRACE request to the server.
+ *   _httpUpdate()           - Update the current HTTP status for incoming
+ *                             data.
+ *   httpUpdate()            - Update the current HTTP state for incoming
+ *                             data.
+ *   _httpWait()             - Wait for data available on a connection (no
+ *                             flush).
+ *   httpWait()              - Wait for data available on a connection.
+ *   httpWrite()             - Write data to a HTTP connection.
+ *   httpWrite2()            - Write data to a HTTP connection.
+ *   _httpWriteCDSA()        - Write function for the CDSA library.
+ *   _httpWriteGNUTLS()       - Write function for the GNU TLS library.
+ *   http_bio_ctrl()         - Control the HTTP connection.
+ *   http_bio_free()         - Free OpenSSL data.
+ *   http_bio_new()          - Initialize an OpenSSL BIO structure.
+ *   http_bio_puts()         - Send a string for OpenSSL.
+ *   http_bio_read()         - Read data for OpenSSL.
+ *   http_bio_write()        - Write data for OpenSSL.
+ *   http_debug_hex()        - Do a hex dump of a buffer.
+ *   http_field()            - Return the field index for a field name.
+ *   http_read_ssl()         - Read from a SSL/TLS connection.
+ *   http_send()             - Send a request with all fields and the trailing
+ *                             blank line.
+ *   http_set_credentials()   - Set the SSL/TLS credentials.
+ *   http_set_timeout()       - Set the socket timeout values.
+ *   http_set_wait()         - Set the default wait value for reads.
+ *   http_setup_ssl()        - Set up SSL/TLS support on a connection.
+ *   http_shutdown_ssl()      - Shut down SSL/TLS on a connection.
+ *   http_upgrade()          - Force upgrade to TLS encryption.
+ *   http_write()            - Write a buffer to a HTTP connection.
+ *   http_write_chunk()       - Write a chunked buffer.
+ *   http_write_ssl()        - Write to a SSL/TLS connection.
  */
 
 /*
@@ -1116,167 +1116,6 @@ httpGetLength2(http_t *http)            /* I - Connection to server */
 }
 
 
-/*
- * 'httpGetStatus()' - Get the status of the last HTTP request.
- *
- * @since CUPS 1.2/Mac OS X 10.5@
- */
-
-http_status_t                          /* O - HTTP status */
-httpGetStatus(http_t *http)            /* I - Connection to server */
-{
-  return (http ? http->status : HTTP_ERROR);
-}
-
-
-/*
- * 'httpGetSubField()' - Get a sub-field value.
- *
- * @deprecated@
- */
-
-char *                                 /* O - Value or NULL */
-httpGetSubField(http_t       *http,    /* I - Connection to server */
-                http_field_t field,    /* I - Field index */
-                const char   *name,    /* I - Name of sub-field */
-               char         *value)    /* O - Value string */
-{
-  return (httpGetSubField2(http, field, name, value, HTTP_MAX_VALUE));
-}
-
-
-/*
- * 'httpGetSubField2()' - Get a sub-field value.
- *
- * @since CUPS 1.2/Mac OS X 10.5@
- */
-
-char *                                 /* O - Value or NULL */
-httpGetSubField2(http_t       *http,   /* I - Connection to server */
-                 http_field_t field,   /* I - Field index */
-                 const char   *name,   /* I - Name of sub-field */
-                char         *value,   /* O - Value string */
-                int          valuelen) /* I - Size of value buffer */
-{
-  const char   *fptr;                  /* Pointer into field */
-  char         temp[HTTP_MAX_VALUE],   /* Temporary buffer for name */
-               *ptr,                   /* Pointer into string buffer */
-               *end;                   /* End of value buffer */
-
-  DEBUG_printf(("2httpGetSubField2(http=%p, field=%d, name=\"%s\", value=%p, "
-                "valuelen=%d)", http, field, name, value, valuelen));
-
-  if (!http || !name || !value || valuelen < 2 ||
-      field <= HTTP_FIELD_UNKNOWN || field >= HTTP_FIELD_MAX)
-    return (NULL);
-
-  end = value + valuelen - 1;
-
-  for (fptr = http->fields[field]; *fptr;)
-  {
-   /*
-    * Skip leading whitespace...
-    */
-
-    while (_cups_isspace(*fptr))
-      fptr ++;
-
-    if (*fptr == ',')
-    {
-      fptr ++;
-      continue;
-    }
-
-   /*
-    * Get the sub-field name...
-    */
-
-    for (ptr = temp;
-         *fptr && *fptr != '=' && !_cups_isspace(*fptr) &&
-            ptr < (temp + sizeof(temp) - 1);
-         *ptr++ = *fptr++);
-
-    *ptr = '\0';
-
-    DEBUG_printf(("4httpGetSubField2: name=\"%s\"", temp));
-
-   /*
-    * Skip trailing chars up to the '='...
-    */
-
-    while (_cups_isspace(*fptr))
-      fptr ++;
-
-    if (!*fptr)
-      break;
-
-    if (*fptr != '=')
-      continue;
-
-   /*
-    * Skip = and leading whitespace...
-    */
-
-    fptr ++;
-
-    while (_cups_isspace(*fptr))
-      fptr ++;
-
-    if (*fptr == '\"')
-    {
-     /*
-      * Read quoted string...
-      */
-
-      for (ptr = value, fptr ++;
-           *fptr && *fptr != '\"' && ptr < end;
-          *ptr++ = *fptr++);
-
-      *ptr = '\0';
-
-      while (*fptr && *fptr != '\"')
-        fptr ++;
-
-      if (*fptr)
-        fptr ++;
-    }
-    else
-    {
-     /*
-      * Read unquoted string...
-      */
-
-      for (ptr = value;
-           *fptr && !_cups_isspace(*fptr) && *fptr != ',' && ptr < end;
-          *ptr++ = *fptr++);
-
-      *ptr = '\0';
-
-      while (*fptr && !_cups_isspace(*fptr) && *fptr != ',')
-        fptr ++;
-    }
-
-    DEBUG_printf(("4httpGetSubField2: value=\"%s\"", value));
-
-   /*
-    * See if this is the one...
-    */
-
-    if (!strcmp(name, temp))
-    {
-      DEBUG_printf(("3httpGetSubField2: Returning \"%s\"", value));
-      return (value);
-    }
-  }
-
-  value[0] = '\0';
-
-  DEBUG_puts("3httpGetSubField2: Returning NULL");
-
-  return (NULL);
-}
-
-
 /*
  * 'httpGets()' - Get a line of text from a HTTP connection.
  */
@@ -1457,6 +1296,189 @@ httpGets(char   *line,                  /* I - Line to read into */
 }
 
 
+/*
+ * 'httpGetState()' - Get the current state of the HTTP request.
+ */
+
+http_state_t                           /* O - HTTP state */
+httpGetState(http_t *http)             /* I - Connection to server */
+{
+  return (http ? http->state : HTTP_ERROR);
+}
+
+
+/*
+ * 'httpGetStatus()' - Get the status of the last HTTP request.
+ *
+ * @since CUPS 1.2/Mac OS X 10.5@
+ */
+
+http_status_t                          /* O - HTTP status */
+httpGetStatus(http_t *http)            /* I - Connection to server */
+{
+  return (http ? http->status : HTTP_ERROR);
+}
+
+
+/*
+ * 'httpGetSubField()' - Get a sub-field value.
+ *
+ * @deprecated@
+ */
+
+char *                                 /* O - Value or NULL */
+httpGetSubField(http_t       *http,    /* I - Connection to server */
+                http_field_t field,    /* I - Field index */
+                const char   *name,    /* I - Name of sub-field */
+               char         *value)    /* O - Value string */
+{
+  return (httpGetSubField2(http, field, name, value, HTTP_MAX_VALUE));
+}
+
+
+/*
+ * 'httpGetSubField2()' - Get a sub-field value.
+ *
+ * @since CUPS 1.2/Mac OS X 10.5@
+ */
+
+char *                                 /* O - Value or NULL */
+httpGetSubField2(http_t       *http,   /* I - Connection to server */
+                 http_field_t field,   /* I - Field index */
+                 const char   *name,   /* I - Name of sub-field */
+                char         *value,   /* O - Value string */
+                int          valuelen) /* I - Size of value buffer */
+{
+  const char   *fptr;                  /* Pointer into field */
+  char         temp[HTTP_MAX_VALUE],   /* Temporary buffer for name */
+               *ptr,                   /* Pointer into string buffer */
+               *end;                   /* End of value buffer */
+
+  DEBUG_printf(("2httpGetSubField2(http=%p, field=%d, name=\"%s\", value=%p, "
+                "valuelen=%d)", http, field, name, value, valuelen));
+
+  if (!http || !name || !value || valuelen < 2 ||
+      field <= HTTP_FIELD_UNKNOWN || field >= HTTP_FIELD_MAX)
+    return (NULL);
+
+  end = value + valuelen - 1;
+
+  for (fptr = http->fields[field]; *fptr;)
+  {
+   /*
+    * Skip leading whitespace...
+    */
+
+    while (_cups_isspace(*fptr))
+      fptr ++;
+
+    if (*fptr == ',')
+    {
+      fptr ++;
+      continue;
+    }
+
+   /*
+    * Get the sub-field name...
+    */
+
+    for (ptr = temp;
+         *fptr && *fptr != '=' && !_cups_isspace(*fptr) &&
+            ptr < (temp + sizeof(temp) - 1);
+         *ptr++ = *fptr++);
+
+    *ptr = '\0';
+
+    DEBUG_printf(("4httpGetSubField2: name=\"%s\"", temp));
+
+   /*
+    * Skip trailing chars up to the '='...
+    */
+
+    while (_cups_isspace(*fptr))
+      fptr ++;
+
+    if (!*fptr)
+      break;
+
+    if (*fptr != '=')
+      continue;
+
+   /*
+    * Skip = and leading whitespace...
+    */
+
+    fptr ++;
+
+    while (_cups_isspace(*fptr))
+      fptr ++;
+
+    if (*fptr == '\"')
+    {
+     /*
+      * Read quoted string...
+      */
+
+      for (ptr = value, fptr ++;
+           *fptr && *fptr != '\"' && ptr < end;
+          *ptr++ = *fptr++);
+
+      *ptr = '\0';
+
+      while (*fptr && *fptr != '\"')
+        fptr ++;
+
+      if (*fptr)
+        fptr ++;
+    }
+    else
+    {
+     /*
+      * Read unquoted string...
+      */
+
+      for (ptr = value;
+           *fptr && !_cups_isspace(*fptr) && *fptr != ',' && ptr < end;
+          *ptr++ = *fptr++);
+
+      *ptr = '\0';
+
+      while (*fptr && !_cups_isspace(*fptr) && *fptr != ',')
+        fptr ++;
+    }
+
+    DEBUG_printf(("4httpGetSubField2: value=\"%s\"", value));
+
+   /*
+    * See if this is the one...
+    */
+
+    if (!strcmp(name, temp))
+    {
+      DEBUG_printf(("3httpGetSubField2: Returning \"%s\"", value));
+      return (value);
+    }
+  }
+
+  value[0] = '\0';
+
+  DEBUG_puts("3httpGetSubField2: Returning NULL");
+
+  return (NULL);
+}
+
+
+/*
+ * 'httpGetVersion()' - Get the HTTP version at the other end.
+ */
+
+http_version_t                         /* O - Version number */
+httpGetVersion(http_t *http)           /* I - Connection to server */
+{
+  return (http ? http->version : HTTP_1_0);
+}
+
+
 /*
  * 'httpHead()' - Send a HEAD request to the server.
  */
index 21e7cce2ea30ca1e6b2233df55357dc9dd1bb8e4..68156580aa6a586d920e7f654a6bd0f79d5c8f6d 100644 (file)
@@ -459,7 +459,12 @@ extern void                httpFreeCredentials(cups_array_t *certs) _CUPS_API_1_5;
 extern int             httpSetCredentials(http_t *http, cups_array_t *certs)
                                           _CUPS_API_1_5;
 extern void            httpSetTimeout(http_t *http, double timeout,
-                                      http_timeout_cb_t cb, void *user_data);
+                                      http_timeout_cb_t cb, void *user_data)
+                                      _CUPS_API_1_5;
+
+/**** New in CUPS 1.6 ****/
+extern http_state_t    httpGetState(http_t *http) _CUPS_API_1_6;
+extern http_version_t  httpGetVersion(http_t *http) _CUPS_API_1_6;
 
 
 /*
index 8a473c110abd3e32e686abc98bc52eb33426fa07..4600882b05ee103566eb6f2313236629d8d1cd08 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Private IPP definitions for CUPS.
  *
- *   Copyright 2007-2010 by Apple Inc.
+ *   Copyright 2007-2011 by Apple Inc.
  *   Copyright 1997-2006 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -46,6 +46,103 @@ extern "C" {
  * Structures...
  */
 
+typedef union _ipp_request_u           /**** Request Header ****/
+{
+  struct                               /* Any Header */
+  {
+    ipp_uchar_t        version[2];             /* Protocol version number */
+    int                op_status;              /* Operation ID or status code*/
+    int                request_id;             /* Request ID */
+  }            any;
+
+  struct                               /* Operation Header */
+  {
+    ipp_uchar_t        version[2];             /* Protocol version number */
+    ipp_op_t   operation_id;           /* Operation ID */
+    int                request_id;             /* Request ID */
+  }            op;
+
+  struct                               /* Status Header */
+  {
+    ipp_uchar_t        version[2];             /* Protocol version number */
+    ipp_status_t status_code;          /* Status code */
+    int                request_id;             /* Request ID */
+  }            status;
+
+  /**** New in CUPS 1.1.19 ****/
+  struct                               /* Event Header @since CUPS 1.1.19/Mac OS X 10.3@ */
+  {
+    ipp_uchar_t        version[2];             /* Protocol version number */
+    ipp_status_t status_code;          /* Status code */
+    int                request_id;             /* Request ID */
+  }            event;
+} _ipp_request_t;
+
+/**** New in CUPS 1.1.19 ****/
+
+typedef union _ipp_value_u             /**** Attribute Value ****/
+{
+  int          integer;                /* Integer/enumerated value */
+
+  char         boolean;                /* Boolean value */
+
+  ipp_uchar_t  date[11];               /* Date/time value */
+
+  struct
+  {
+    int                xres,                   /* Horizontal resolution */
+               yres;                   /* Vertical resolution */
+    ipp_res_t  units;                  /* Resolution units */
+  }            resolution;             /* Resolution value */
+
+  struct
+  {
+    int                lower,                  /* Lower value */
+               upper;                  /* Upper value */
+  }            range;                  /* Range of integers value */
+
+  struct
+  {
+    char       *language;              /* Language code */
+    char       *text;                  /* String */
+  }            string;                 /* String with language value */
+
+  struct
+  {
+    int                length;                 /* Length of attribute */
+    void       *data;                  /* Data in attribute */
+  }            unknown;                /* Unknown attribute type */
+
+/**** New in CUPS 1.1.19 ****/
+  ipp_t                *collection;            /* Collection value @since CUPS 1.1.19/Mac OS X 10.3@ */
+} _ipp_value_t;
+
+struct _ipp_attribute_s                /**** Attribute ****/
+{
+  ipp_attribute_t *next;               /* Next attribute in list */
+  ipp_tag_t    group_tag,              /* Job/Printer/Operation group tag */
+               value_tag;              /* What type of value is it? */
+  char         *name;                  /* Name of attribute */
+  int          num_values;             /* Number of values */
+  _ipp_value_t values[1];              /* Values */
+};
+
+struct _ipp_s                          /**** IPP Request/Response/Notification ****/
+{
+  ipp_state_t          state;          /* State of request */
+  _ipp_request_t       request;        /* Request header */
+  ipp_attribute_t      *attrs;         /* Attributes */
+  ipp_attribute_t      *last;          /* Last attribute in list */
+  ipp_attribute_t      *current;       /* Current attribute (for read/write) */
+  ipp_tag_t            curtag;         /* Current attribute group tag */
+
+/**** New in CUPS 1.2 ****/
+  ipp_attribute_t      *prev;          /* Previous attribute (for read) @since CUPS 1.2/Mac OS X 10.5@ */
+
+/**** New in CUPS 1.4.4 ****/
+  int                  use;            /* Use count @since CUPS 1.4.4/Mac OS X 10.6.?@ */
+};
+
 typedef struct _ipp_buffer_s           /**** Read/write buffer ****/
 {
   unsigned char                d[IPP_BUF_SIZE];/* Data buffer */
@@ -66,11 +163,7 @@ typedef struct                              /**** Attribute mapping data ****/
  * Prototypes for private functions...
  */
 
-extern ipp_attribute_t *_ippAddAttr(ipp_t *ipp, int num_values);
-extern size_t          _ippAttrString(ipp_attribute_t *attr, char *buffer,
-                                      size_t bufsize);
 extern _ipp_option_t   *_ippFindOption(const char *name);
-extern void            _ippFreeAttr(ipp_attribute_t *attr);
 
 
 /*
index 6f0c7c08ac0e216ebb5a5b7fbc90a73c1249dfc1..60211121a994d1746b19ada3851ee426dd83650c 100644 (file)
  *
  * Contents:
  *
- *   _ippAttrString() - Convert the attribute's value to a string.
- *   ippErrorString() - Return a name for the given status code.
- *   ippErrorValue()  - Return a status code for the given name.
- *   ippOpString()    - Return a name for the given operation id.
- *   ippOpValue()     - Return an operation id for the given name.
- *   ippPort()        - Return the default IPP port number.
- *   ippSetPort()     - Set the default port number.
- *   ippTagString()   - Return the tag name corresponding to a tag value.
- *   ippTagValue()    - Return the tag value corresponding to a tag name.
- *   ipp_col_string() - Convert a collection to a string.
+ *   ippAttributeString() - Convert the attribute's value to a string.
+ *   ippEnumString()     - Return a string corresponding to the enum value.
+ *   ippEnumValue()      - Return the value associated with a given enum
+ *                         string.
+ *   ippErrorString()    - Return a name for the given status code.
+ *   ippErrorValue()     - Return a status code for the given name.
+ *   ippOpString()       - Return a name for the given operation id.
+ *   ippOpValue()        - Return an operation id for the given name.
+ *   ippPort()           - Return the default IPP port number.
+ *   ippSetPort()        - Set the default port number.
+ *   ippTagString()      - Return the tag name corresponding to a tag value.
+ *   ippTagValue()       - Return the tag value corresponding to a tag name.
+ *   ipp_col_string()    - Convert a collection to a string.
  */
 
 /*
  */
 
 static const char * const ipp_status_oks[] =   /* "OK" status codes */
-               {
+               {                               /* (name) = abandoned standard value */
                  "successful-ok",
                  "successful-ok-ignored-or-substituted-attributes",
                  "successful-ok-conflicting-attributes",
                  "successful-ok-ignored-subscriptions",
-                 "successful-ok-ignored-notifications",
+                 "(successful-ok-ignored-notifications)",
                  "successful-ok-too-many-events",
-                 "successful-ok-but-cancel-subscription",
+                 "(successful-ok-but-cancel-subscription)",
                  "successful-ok-events-complete"
                },
                * const ipp_status_400s[] =     /* Client errors */
-               {
+               {                               /* (name) = abandoned standard value */
                  "client-error-bad-request",
                  "client-error-forbidden",
                  "client-error-not-authenticated",
@@ -74,8 +77,8 @@ static const char * const ipp_status_oks[] =  /* "OK" status codes */
                  "client-error-attributes-not-settable",
                  "client-error-ignored-all-subscriptions",
                  "client-error-too-many-subscriptions",
-                 "client-error-ignored-all-notifications",
-                 "client-error-print-support-file-not-found"
+                 "(client-error-ignored-all-notifications)",
+                 "(client-error-client-print-support-file-not-found)"
                },
                * const ipp_status_500s[] =             /* Server errors */
                {
@@ -97,7 +100,7 @@ static const char * const ipp_status_oks[] = /* "OK" status codes */
                  "cups-pki-error",
                  "cups-upgrade-required"
                };
-static char    * const ipp_std_ops[] =
+static const char * const ipp_std_ops[] =
                {
                  /* 0x0000 - 0x000f */
                  "0x00",
@@ -131,13 +134,13 @@ static char       * const ipp_std_ops[] =
                  "Renew-Subscription",
                  "Cancel-Subscription",
                  "Get-Notifications",
-                 "Send-Notifications",
-                 "0x1e",
-                 "0x1f",
+                 "(Send-Notifications)",
+                 "(Get-Resource-Attributes)",
+                 "(Get-Resource-Data)",
 
                  /* 0x0020 - 0x002f */
-                 "0x20",
-                 "Get-Printer-Support-Files",
+                 "(Get-Resources)",
+                 "(Get-Printer-Support-Files)",
                  "Enable-Printer",
                  "Disable-Printer",
                  "Pause-Printer-After-Current-Job",
@@ -206,7 +209,8 @@ static char * const ipp_std_ops[] =
                                        /* 0x06 */
                  "event-notification-attributes-tag",
                                        /* 0x07 */
-                 "0x08",               /* 0x08 */
+                 "(resource-attributes-tag)",
+                                       /* 0x08 */
                  "document-attributes-tag",
                                        /* 0x09 */
                  "0x0a",               /* 0x0a */
@@ -275,22 +279,115 @@ static char      * const ipp_std_ops[] =
                  "mimeMediaType",      /* 0x49 */
                  "memberAttrName"      /* 0x4a */
                };
-static const char * const job_states[] =
-{                                      /* job-state enums */
-  "pending",
-  "pending-held",
-  "processing",
-  "processing-stopped",
-  "canceled",
-  "aborted",
-  "completed"
-};
-static const char * const printer_states[] =
-{                                      /* printer-state enums */
-  "idle",
-  "processing",
-  "stopped",
-};
+static const char * const ipp_document_states[] =
+               {                       /* document-state-enums */
+                 "pending",
+                 "4",
+                 "processing",
+                 "6",
+                 "canceled",
+                 "aborted",
+                 "completed"
+               },
+               * const ipp_finishings[] =
+               {                       /* finishings enums */
+                 "none",
+                 "staple",
+                 "punch",
+                 "cover",
+                 "bind",
+                 "saddle-stitch",
+                 "edge-stitch",
+                 "fold",
+                 "trim",
+                 "bale",
+                 "booklet-maker",
+                 "jog-offset",
+                 "15",
+                 "16",
+                 "17",
+                 "18",
+                 "19",
+                 "staple-top-left",
+                 "staple-bottom-left",
+                 "staple-top-right",
+                 "staple-bottom-right",
+                 "edge-stitch-left",
+                 "edge-stitch-top",
+                 "edge-stitch-right",
+                 "edge-stitch-bottom",
+                 "staple-dual-left",
+                 "staple-dual-top",
+                 "staple-dual-right",
+                 "staple-dual-bottom",
+                 "32",
+                 "33",
+                 "34",
+                 "35",
+                 "36",
+                 "37",
+                 "38",
+                 "39",
+                 "40",
+                 "41",
+                 "42",
+                 "43",
+                 "44",
+                 "45",
+                 "46",
+                 "47",
+                 "48",
+                 "49",
+                 "bind-left",
+                 "bind-top",
+                 "bind-right",
+                 "bind-bottom",
+                 "54",
+                 "55",
+                 "56",
+                 "57",
+                 "58",
+                 "59",
+                 "trim-after-pages",
+                 "trim-after-documents",
+                 "trim-after-copies",
+                 "trim-after-job"
+               },
+               * const ipp_job_collation_types[] =
+               {                       /* job-collation-type enums */
+                 "uncollated-sheets",
+                 "collated-documents",
+                 "uncollated-documents"
+               },
+               * const ipp_job_states[] =
+               {                       /* job-state enums */
+                 "pending",
+                 "pending-held",
+                 "processing",
+                 "processing-stopped",
+                 "canceled",
+                 "aborted",
+                 "completed"
+               },
+               * const ipp_orientation_requesteds[] =
+               {                       /* orientation-requested enums */
+                 "portrait",
+                 "landscape",
+                 "reverse-landscape",
+                 "reverse-portrait"
+               },
+               * const ipp_print_qualities[] =
+               {                       /* print-quality enums */
+                 "draft",
+                 "normal",
+                 "high"
+               },
+               * const ipp_printer_states[] =
+               {                       /* printer-state enums */
+                 "idle",
+                 "processing",
+                 "stopped",
+               };
 
 
 /*
@@ -301,24 +398,27 @@ static size_t     ipp_col_string(ipp_t *col, char *buffer, size_t bufsize);
 
 
 /*
- * '_ippAttrString()' - Convert the attribute's value to a string.
+ * 'ippAttributeString()' - Convert the attribute's value to a string.
  *
  * Returns the number of bytes that would be written, not including the
  * trailing nul. The buffer pointer can be NULL to get the required length,
  * just like (v)snprintf.
+ *
+ * @since CUPS 1.6@
  */
 
 size_t                                 /* O - Number of bytes less nul */
-_ippAttrString(ipp_attribute_t *attr,  /* I - Attribute */
-               char            *buffer,        /* I - String buffer or NULL */
-               size_t          bufsize)        /* I - Size of string buffer */
+ippAttributeString(
+    ipp_attribute_t *attr,             /* I - Attribute */
+    char            *buffer,           /* I - String buffer or NULL */
+    size_t          bufsize)           /* I - Size of string buffer */
 {
   int          i;                      /* Looping var */
   char         *bufptr,                /* Pointer into buffer */
                *bufend,                /* End of buffer */
                temp[256];              /* Temporary string */
   const char   *ptr;                   /* Pointer into string */
-  ipp_value_t  *val;                   /* Current value */
+  _ipp_value_t *val;                   /* Current value */
 
 
   if (!attr || !attr->name)
@@ -348,40 +448,13 @@ _ippAttrString(ipp_attribute_t *attr,     /* I - Attribute */
     switch (attr->value_tag & ~IPP_TAG_COPY)
     {
       case IPP_TAG_ENUM :
-          if (!strcmp(attr->name, "printer-state") &&
-              val->integer >= IPP_PRINTER_IDLE &&
-              val->integer <= IPP_PRINTER_STOPPED)
-          {
-            ptr = printer_states[val->integer - IPP_PRINTER_IDLE];
+          ptr = ippEnumString(attr->name, val->integer);
 
-            if (buffer && bufptr < bufend)
-              strlcpy(bufptr, ptr, bufend - bufptr + 1);
-
-            bufptr += strlen(ptr);
-            break;
-          }
-          else if (!strcmp(attr->name, "job-state") &&
-                  val->integer >= IPP_JOB_PENDING &&
-                  val->integer <= IPP_JOB_COMPLETED)
-          {
-            ptr = job_states[val->integer - IPP_JOB_PENDING];
-
-            if (buffer && bufptr < bufend)
-              strlcpy(bufptr, ptr, bufend - bufptr + 1);
-
-            bufptr += strlen(ptr);
-            break;
-          }
-          else if (!strcmp(attr->name, "operations-supported"))
-          {
-            ptr = ippOpString(val->integer);
-
-            if (buffer && bufptr < bufend)
-              strlcpy(bufptr, ptr, bufend - bufptr + 1);
+          if (buffer && bufptr < bufend)
+            strlcpy(bufptr, ptr, bufend - bufptr + 1);
 
-            bufptr += strlen(ptr);
-            break;
-          }
+          bufptr += strlen(ptr);
+          break;
 
       case IPP_TAG_INTEGER :
           if (buffer && bufptr < bufend)
@@ -459,7 +532,7 @@ _ippAttrString(ipp_attribute_t *attr,       /* I - Attribute */
 
           for (ptr = val->string.text; *ptr; ptr ++)
           {
-            if (*ptr == '\\' || *ptr == '\"')
+            if (*ptr == '\\' || *ptr == '\"' || *ptr == '[')
             {
               if (buffer && bufptr < bufend)
                 *bufptr = '\\';
@@ -470,6 +543,25 @@ _ippAttrString(ipp_attribute_t *attr,      /* I - Attribute */
               *bufptr = *ptr;
             bufptr ++;
           }
+
+          if (val->string.language)
+          {
+           /*
+            * Add "[language]" to end of string...
+            */
+
+            if (buffer && bufptr < bufend)
+              *bufptr = '[';
+            bufptr ++;
+
+            if (buffer && bufptr < bufend)
+              strlcpy(bufptr, val->string.language, bufend - bufptr);
+            bufptr += strlen(val->string.language);
+
+            if (buffer && bufptr < bufend)
+              *bufptr = ']';
+            bufptr ++;
+          }
           break;
 
       case IPP_TAG_BEGIN_COLLECTION :
@@ -529,6 +621,159 @@ _ippAttrString(ipp_attribute_t *attr,     /* I - Attribute */
 }
 
 
+/*
+ * 'ippEnumString()' - Return a string corresponding to the enum value.
+ */
+
+const char *                           /* O - Enum string */
+ippEnumString(const char *attrname,    /* I - Attribute name */
+              int        enumvalue)    /* I - Enum value */
+{
+  _cups_globals_t *cg = _cupsGlobals();        /* Pointer to library globals */
+
+
+ /*
+  * Check for standard enum values...
+  */
+
+  if (!strcmp(attrname, "document-state") &&
+      enumvalue >= 3 &&
+      enumvalue <= (3 + (int)(sizeof(ipp_document_states) /
+                              sizeof(ipp_document_states[0]))))
+    return (ipp_document_states[enumvalue - 3]);
+  else if ((!strcmp(attrname, "finishings") ||
+            !strcmp(attrname, "finishings-actual") ||
+            !strcmp(attrname, "finishings-default") ||
+            !strcmp(attrname, "finishings-ready") ||
+            !strcmp(attrname, "finishings-supported")) &&
+           enumvalue >= 3 &&
+           enumvalue <= (3 + (int)(sizeof(ipp_finishings) / sizeof(ipp_finishings[0]))))
+    return (ipp_finishings[enumvalue - 3]);
+  else if ((!strcmp(attrname, "job-collation-type") ||
+            !strcmp(attrname, "job-collation-type-actual")) &&
+           enumvalue >= 3 &&
+           enumvalue <= (3 + (int)(sizeof(ipp_job_collation_types) /
+                                   sizeof(ipp_job_collation_types[0]))))
+    return (ipp_job_collation_types[enumvalue - 3]);
+  else if (!strcmp(attrname, "job-state") &&
+          enumvalue >= IPP_JOB_PENDING && enumvalue <= IPP_JOB_COMPLETED)
+    return (ipp_job_states[enumvalue - IPP_JOB_PENDING]);
+  else if (!strcmp(attrname, "operations-supported"))
+    return (ippOpString((ipp_op_t)enumvalue));
+  else if ((!strcmp(attrname, "orientation-requested") ||
+            !strcmp(attrname, "orientation-requested-actual") ||
+            !strcmp(attrname, "orientation-requested-default") ||
+            !strcmp(attrname, "orientation-requested-supported")) &&
+           enumvalue >= 3 &&
+           enumvalue <= (3 + (int)(sizeof(ipp_orientation_requesteds) /
+                                   sizeof(ipp_orientation_requesteds[0]))))
+    return (ipp_orientation_requesteds[enumvalue - 3]);
+  else if ((!strcmp(attrname, "print-quality") ||
+            !strcmp(attrname, "print-quality-actual") ||
+            !strcmp(attrname, "print-quality-default") ||
+            !strcmp(attrname, "print-quality-supported")) &&
+           enumvalue >= 3 &&
+           enumvalue <= (3 + (int)(sizeof(ipp_print_qualities) /
+                                   sizeof(ipp_print_qualities[0]))))
+    return (ipp_print_qualities[enumvalue - 3]);
+  else if (!strcmp(attrname, "printer-state") &&
+           enumvalue >= IPP_PRINTER_IDLE && enumvalue <= IPP_PRINTER_STOPPED)
+    return (ipp_printer_states[enumvalue - IPP_PRINTER_IDLE]);
+
+ /*
+  * Not a standard enum value, just return the decimal equivalent...
+  */
+
+  snprintf(cg->ipp_unknown, sizeof(cg->ipp_unknown), "%d", enumvalue);
+  return (cg->ipp_unknown);
+}
+
+
+/*
+ * 'ippEnumValue()' - Return the value associated with a given enum string.
+ */
+
+int                                    /* O - Enum value or -1 if unknown */
+ippEnumValue(const char *attrname,     /* I - Attribute name */
+             const char *enumstring)   /* I - Enum string */
+{
+  int          i,                      /* Looping var */
+               num_strings;            /* Number of strings to compare */
+  const char * const *strings;         /* Strings to compare */
+
+
+ /*
+  * If the string is just a number, return it...
+  */
+
+  if (isdigit(*enumstring & 255))
+    return (strtol(enumstring, NULL, 0));
+
+ /*
+  * Otherwise look up the string...
+  */
+
+  if (!strcmp(attrname, "document-state"))
+  {
+    num_strings = (int)(sizeof(ipp_document_states) / sizeof(ipp_document_states[0]));
+    strings     = ipp_document_states;
+  }
+  else if (!strcmp(attrname, "finishings") ||
+          !strcmp(attrname, "finishings-actual") ||
+          !strcmp(attrname, "finishings-default") ||
+          !strcmp(attrname, "finishings-ready") ||
+          !strcmp(attrname, "finishings-supported"))
+  {
+    num_strings = (int)(sizeof(ipp_finishings) / sizeof(ipp_finishings[0]));
+    strings     = ipp_finishings;
+  }
+  else if (!strcmp(attrname, "job-collation-type") ||
+           !strcmp(attrname, "job-collation-type-actual"))
+  {
+    num_strings = (int)(sizeof(ipp_job_collation_types) /
+                        sizeof(ipp_job_collation_types[0]));
+    strings     = ipp_job_collation_types;
+  }
+  else if (!strcmp(attrname, "job-state"))
+  {
+    num_strings = (int)(sizeof(ipp_job_states) / sizeof(ipp_job_states[0]));
+    strings     = ipp_job_states;
+  }
+  else if (!strcmp(attrname, "operations-supported"))
+    return (ippOpValue(enumstring));
+  else if (!strcmp(attrname, "orientation-requested") ||
+           !strcmp(attrname, "orientation-requested-actual") ||
+           !strcmp(attrname, "orientation-requested-default") ||
+           !strcmp(attrname, "orientation-requested-supported"))
+  {
+    num_strings = (int)(sizeof(ipp_orientation_requesteds) /
+                        sizeof(ipp_orientation_requesteds[0]));
+    strings     = ipp_orientation_requesteds;
+  }
+  else if (!strcmp(attrname, "print-quality") ||
+           !strcmp(attrname, "print-quality-actual") ||
+           !strcmp(attrname, "print-quality-default") ||
+           !strcmp(attrname, "print-quality-supported"))
+  {
+    num_strings = (int)(sizeof(ipp_print_qualities) / sizeof(ipp_print_qualities[0]));
+    strings     = ipp_print_qualities;
+  }
+  else if (!strcmp(attrname, "printer-state"))
+  {
+    num_strings = (int)(sizeof(ipp_printer_states) / sizeof(ipp_printer_states[0]));
+    strings     = ipp_printer_states;
+  }
+  else
+    return (-1);
+
+  for (i = 0; i < num_strings; i ++)
+    if (!strcmp(enumstring, strings[i]))
+      return (i + 3);
+
+  return (-1);
+}
+
+
 /*
  * 'ippErrorString()' - Return a name for the given status code.
  */
@@ -811,9 +1056,9 @@ ipp_col_string(ipp_t  *col,                /* I - Collection attribute */
       bufptr += strlen(attr->name) + 1;
 
     if (buffer && bufptr < bufend)
-      bufptr += _ippAttrString(attr, bufptr, bufend - bufptr + 1);
+      bufptr += ippAttributeString(attr, bufptr, bufend - bufptr + 1);
     else
-      bufptr += _ippAttrString(attr, temp, sizeof(temp));
+      bufptr += ippAttributeString(attr, temp, sizeof(temp));
   }
 
   if (buffer && bufptr < bufend)
index 3f9b04b3b90442d885d7b1e55051c3f2ac59693c..b269252a5dd1c576ed0eb24f7da4870eb6a9f995 100644 (file)
  *
  * Contents:
  *
- *   ippAddBoolean()        - Add a boolean attribute to an IPP message.
- *   ippAddBooleans()       - Add an array of boolean values.
- *   ippAddDate()           - Add a date attribute to an IPP message.
- *   ippAddInteger()        - Add a integer attribute to an IPP message.
- *   ippAddIntegers()       - Add an array of integer values.
+ *   ippAddBoolean()       - Add a boolean attribute to an IPP message.
+ *   ippAddBooleans()      - Add an array of boolean values.
+ *   ippAddCollection()     - Add a collection value.
+ *   ippAddCollections()    - Add an array of collection values.
+ *   ippAddDate()          - Add a date attribute to an IPP message.
+ *   ippAddInteger()       - Add a integer attribute to an IPP message.
+ *   ippAddIntegers()      - Add an array of integer values.
  *   ippAddOctetString()    - Add an octetString value to an IPP message.
- *   ippAddString()         - Add a language-encoded string to an IPP message.
- *   ippAddStrings()        - Add language-encoded strings to an IPP message.
- *   ippAddRange()          - Add a range of values to an IPP message.
- *   ippAddRanges()         - Add ranges of values to an IPP message.
+ *   ippAddOutOfBand()     - Add an out-of-band value to an IPP message.
+ *   ippAddRange()         - Add a range of values to an IPP message.
+ *   ippAddRanges()        - Add ranges of values to an IPP message.
  *   ippAddResolution()     - Add a resolution value to an IPP message.
  *   ippAddResolutions()    - Add resolution values to an IPP message.
- *   ippAddSeparator()      - Add a group separator to an IPP message.
- *   ippDateToTime()        - Convert from RFC 1903 Date/Time format to
- *                            UNIX time in seconds.
- *   ippDelete()            - Delete an IPP message.
+ *   ippAddSeparator()     - Add a group separator to an IPP message.
+ *   ippAddString()        - Add a language-encoded string to an IPP message.
+ *   ippAddStrings()       - Add language-encoded strings to an IPP message.
+ *   ippCopyAttribute()     - Copy an attribute.
+ *   ippCopyAttributes()    - Copy attributes from one IPP message to another.
+ *   ippDateToTime()       - Convert from RFC 1903 Date/Time format to UNIX
+ *                           time in seconds.
+ *   ippDelete()           - Delete an IPP message.
  *   ippDeleteAttribute()   - Delete a single attribute in an IPP message.
+ *   ippDeleteValues()     - Delete values in an attribute.
  *   ippFindAttribute()     - Find a named attribute in a request...
  *   ippFindNextAttribute() - Find the next named attribute in a request...
- *   ippLength()            - Compute the length of an IPP message.
- *   ippNew()               - Allocate a new IPP message.
- *   ippNewRequest()        - Allocate a new IPP message.
- *   ippRead()              - Read data for an IPP message from a HTTP
- *                            connection.
- *   ippReadFile()          - Read data for an IPP message from a file.
- *   ippReadIO()            - Read data for an IPP message.
- *   ippTimeToDate()        - Convert from UNIX time to RFC 1903 format.
- *   ippWrite()             - Write data for an IPP message to a HTTP
- *                            connection.
- *   ippWriteFile()         - Write data for an IPP message to a file.
- *   ippWriteIO()           - Write data for an IPP message.
- *   _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...
- *   ipp_read_file()        - Read IPP data from a file.
- *   ipp_write_file()       - Write IPP data to a file.
+ *   ippFirstAttribute()    - Return the first attribute in the message.
+ *   ippGetBoolean()       - Get a boolean value for an attribute.
+ *   ippGetCollection()     - Get a collection value for an attribute.
+ *   ippGetCount()         - Get the number of values in an attribute.
+ *   ippGetGroupTag()      - Get the group associated with an attribute.
+ *   ippGetInteger()       - Get the integer/enum value for an attribute.
+ *   ippGetName()          - Get the attribute name.
+ *   ippGetOperation()     - Get the operation ID in an IPP message.
+ *   ippGetRequestId()     - Get the request ID from an IPP message.
+ *   ippGetResolution()     - Get a resolution value for an attribute.
+ *   ippGetStatusCode()     - Get the status code from an IPP response or event
+ *                           message.
+ *   ippGetString()        - Get the string and optionally the language code
+ *                           for an attribute.
+ *   ippGetValueTag()      - Get the value tag for an attribute.
+ *   ippGetVersion()       - Get the major and minor version number from an
+ *                           IPP message.
+ *   ippLength()           - Compute the length of an IPP message.
+ *   ippNextAttribute()     - Return the next attribute in the message.
+ *   ippNew()              - Allocate a new IPP message.
+ *   ippNewRequest()       - Allocate a new IPP request message.
+ *   ippRead()             - Read data for an IPP message from a HTTP
+ *                           connection.
+ *   ippReadFile()         - Read data for an IPP message from a file.
+ *   ippReadIO()           - Read data for an IPP message.
+ *   ippSetBoolean()       - Set a boolean value in an attribute.
+ *   ippSetCollection()     - Set a collection value in an attribute.
+ *   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.
+ *   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.
+ *   ippSetResolution()     - Set a resolution value in an attribute.
+ *   ippSetStatusCode()     - Set the status code in an IPP response or event
+ *                           message.
+ *   ippSetString()        - Set a string value in an attribute.
+ *   ippSetValueTag()      - Set the value tag of an attribute.
+ *   ippSetVersion()       - Set the version number in an IPP message.
+ *   ippTimeToDate()       - Convert from UNIX time to RFC 1903 format.
+ *   ippWrite()            - Write data for an IPP message to a HTTP
+ *                           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 message.
+ *   ipp_buffer_get()      - Get a read/write buffer.
+ *   ipp_buffer_release()   - Release a read/write buffer.
+ *   ipp_free_values()     - Free attribute values.
+ *   ipp_get_code()        - Convert a C locale/charset name into an IPP
+ *                           language/charset code.
+ *   ipp_lang_code()       - Convert a C locale name into an IPP language
+ *                           code.
+ *   ipp_length()          - Compute the length of an IPP message or
+ *                           collection value.
+ *   ipp_read_http()       - Semi-blocking read on a HTTP connection...
+ *   ipp_read_file()       - Read IPP data from a file.
+ *   ipp_set_value()       - Get the value element from an attribute,
+ *                           expanding it as needed.
+ *   ipp_write_file()      - Write IPP data to a file.
  */
 
 /*
  * Local functions...
  */
 
+static ipp_attribute_t *ipp_add_attr(ipp_t *ipp, const char *name, ipp_tag_t  group_tag,
+                                     ipp_tag_t value_tag, int num_values);
 static unsigned char   *ipp_buffer_get(void);
 static void            ipp_buffer_release(unsigned char *b);
+static void            ipp_free_values(ipp_attribute_t *attr, int element, int count);
+static char            *ipp_get_code(const char *locale, char *buffer, size_t bufsize);
+static char            *ipp_lang_code(const char *locale, char *buffer, size_t bufsize);
 static size_t          ipp_length(ipp_t *ipp, int collection);
 static ssize_t         ipp_read_http(http_t *http, ipp_uchar_t *buffer,
                                      size_t length);
 static ssize_t         ipp_read_file(int *fd, ipp_uchar_t *buffer,
                                      size_t length);
+static _ipp_value_t    *ipp_set_value(ipp_t *ipp, ipp_attribute_t **attr, int element);
 static ssize_t         ipp_write_file(int *fd, ipp_uchar_t *buffer,
                                       size_t length);
 
 
 /*
  * 'ippAddBoolean()' - Add a boolean attribute to an IPP message.
+ *
+ * The @code ipp@ parameter refers to an IPP message previously created using the
+ * @link ippNew@ or @link ippNewRequest@ functions.
+ *
+ * The @code group@ parameter specifies the IPP attribute group tag: none
+ * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
+ * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
+ * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
+ * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
  */
 
 ipp_attribute_t *                      /* O - New attribute */
@@ -97,15 +158,21 @@ ippAddBoolean(ipp_t      *ipp,             /* I - IPP message */
   DEBUG_printf(("ippAddBoolean(ipp=%p, group=%02x(%s), name=\"%s\", value=%d)",
                 ipp, group, ippTagString(group), name, value));
 
-  if (!ipp || !name)
+ /*
+  * Range check input...
+  */
+
+  if (!ipp || !name || group < IPP_TAG_ZERO ||
+      group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE)
     return (NULL);
 
-  if ((attr = _ippAddAttr(ipp, 1)) == NULL)
+ /*
+  * Create the attribute...
+  */
+
+  if ((attr = ipp_add_attr(ipp, name, group, IPP_TAG_BOOLEAN, 1)) == NULL)
     return (NULL);
 
-  attr->name              = _cupsStrAlloc(name);
-  attr->group_tag         = group;
-  attr->value_tag         = IPP_TAG_BOOLEAN;
   attr->values[0].boolean = value;
 
   return (attr);
@@ -114,6 +181,15 @@ ippAddBoolean(ipp_t      *ipp,             /* I - IPP message */
 
 /*
  * 'ippAddBooleans()' - Add an array of boolean values.
+ *
+ * The @code ipp@ parameter refers to an IPP message previously created using the
+ * @link ippNew@ or @link ippNewRequest@ functions.
+ *
+ * The @code group@ parameter specifies the IPP attribute group tag: none
+ * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
+ * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
+ * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
+ * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
  */
 
 ipp_attribute_t *                      /* O - New attribute */
@@ -125,28 +201,36 @@ ippAddBooleans(ipp_t      *ipp,           /* I - IPP message */
 {
   int                  i;              /* Looping var */
   ipp_attribute_t      *attr;          /* New attribute */
-  ipp_value_t          *value;         /* Current value */
+  _ipp_value_t         *value;         /* Current value */
 
 
   DEBUG_printf(("ippAddBooleans(ipp=%p, group=%02x(%s), name=\"%s\", "
                 "num_values=%d, values=%p)", ipp, group, ippTagString(group),
                 name, num_values, values));
 
-  if (!ipp || !name || num_values < 1)
-    return (NULL);
+ /*
+  * Range check input...
+  */
 
-  if ((attr = _ippAddAttr(ipp, num_values)) == NULL)
+  if (!ipp || !name || group < IPP_TAG_ZERO ||
+      group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
+      num_values < 1)
     return (NULL);
 
-  attr->name      = _cupsStrAlloc(name);
-  attr->group_tag = group;
-  attr->value_tag = IPP_TAG_BOOLEAN;
+ /*
+  * Create the attribute...
+  */
+
+  if ((attr = ipp_add_attr(ipp, name, group, IPP_TAG_BOOLEAN, num_values)) == NULL)
+    return (NULL);
 
-  if (values != NULL)
-    for (i = 0, value = attr->values;
-        i < num_values;
-        i ++, value ++)
-      value->boolean = values[i];
+  if (values)
+  {
+    for (i = num_values, value = attr->values;
+        i > 0;
+        i --, value ++)
+      value->boolean = *values++;
+  }
 
   return (attr);
 }
@@ -155,6 +239,15 @@ ippAddBooleans(ipp_t      *ipp,            /* I - IPP message */
 /*
  * 'ippAddCollection()' - Add a collection value.
  *
+ * The @code ipp@ parameter refers to an IPP message previously created using the
+ * @link ippNew@ or @link ippNewRequest@ functions.
+ *
+ * The @code group@ parameter specifies the IPP attribute group tag: none
+ * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
+ * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
+ * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
+ * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
+ *
  * @since CUPS 1.1.19/Mac OS X 10.3@
  */
 
@@ -170,15 +263,21 @@ ippAddCollection(ipp_t      *ipp, /* I - IPP message */
   DEBUG_printf(("ippAddCollection(ipp=%p, group=%02x(%s), name=\"%s\", "
                 "value=%p)", ipp, group, ippTagString(group), name, value));
 
-  if (!ipp || !name)
+ /*
+  * Range check input...
+  */
+
+  if (!ipp || !name || group < IPP_TAG_ZERO ||
+      group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE)
     return (NULL);
 
-  if ((attr = _ippAddAttr(ipp, 1)) == NULL)
+ /*
+  * Create the attribute...
+  */
+
+  if ((attr = ipp_add_attr(ipp, name, group, IPP_TAG_BEGIN_COLLECTION, 1)) == NULL)
     return (NULL);
 
-  attr->name                 = _cupsStrAlloc(name);
-  attr->group_tag            = group;
-  attr->value_tag            = IPP_TAG_BEGIN_COLLECTION;
   attr->values[0].collection = value;
 
   value->use ++;
@@ -190,6 +289,15 @@ ippAddCollection(ipp_t      *ipp,  /* I - IPP message */
 /*
  * 'ippAddCollections()' - Add an array of collection values.
  *
+ * The @code ipp@ parameter refers to an IPP message previously created using the
+ * @link ippNew@ or @link ippNewRequest@ functions.
+ *
+ * The @code group@ parameter specifies the IPP attribute group tag: none
+ * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
+ * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
+ * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
+ * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
+ *
  * @since CUPS 1.1.19/Mac OS X 10.3@
  */
 
@@ -203,30 +311,37 @@ ippAddCollections(
 {
   int                  i;              /* Looping var */
   ipp_attribute_t      *attr;          /* New attribute */
-  ipp_value_t          *value;         /* Current value */
+  _ipp_value_t         *value;         /* Current value */
 
 
   DEBUG_printf(("ippAddCollections(ipp=%p, group=%02x(%s), name=\"%s\", "
                 "num_values=%d, values=%p)", ipp, group, ippTagString(group),
                 name, num_values, values));
 
-  if (!ipp || !name || num_values < 1)
-    return (NULL);
+ /*
+  * Range check input...
+  */
 
-  if ((attr = _ippAddAttr(ipp, num_values)) == NULL)
+  if (!ipp || !name || group < IPP_TAG_ZERO ||
+      group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
+      num_values < 1)
     return (NULL);
 
-  attr->name      = _cupsStrAlloc(name);
-  attr->group_tag = group;
-  attr->value_tag = IPP_TAG_BEGIN_COLLECTION;
+ /*
+  * Create the attribute...
+  */
+
+  if ((attr = ipp_add_attr(ipp, name, group, IPP_TAG_BEGIN_COLLECTION,
+                           num_values)) == NULL)
+    return (NULL);
 
-  if (values != NULL)
+  if (values)
   {
-    for (i = 0, value = attr->values;
-        i < num_values;
-        i ++, value ++)
+    for (i = num_values, value = attr->values;
+        i > 0;
+        i --, value ++)
     {
-      value->collection = (ipp_t *)values[i];
+      value->collection = (ipp_t *)*values++;
       value->collection->use ++;
     }
   }
@@ -237,6 +352,15 @@ ippAddCollections(
 
 /*
  * 'ippAddDate()' - Add a date attribute to an IPP message.
+ *
+ * The @code ipp@ parameter refers to an IPP message previously created using the
+ * @link ippNew@ or @link ippNewRequest@ functions.
+ *
+ * The @code group@ parameter specifies the IPP attribute group tag: none
+ * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
+ * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
+ * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
+ * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
  */
 
 ipp_attribute_t *                      /* O - New attribute */
@@ -251,15 +375,21 @@ ippAddDate(ipp_t             *ipp,        /* I - IPP message */
   DEBUG_printf(("ippAddDate(ipp=%p, group=%02x(%s), name=\"%s\", value=%p)",
                 ipp, group, ippTagString(group), name, value));
 
-  if (!ipp || !name || !value)
+ /*
+  * Range check input...
+  */
+
+  if (!ipp || !name || !value || group < IPP_TAG_ZERO ||
+      group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE)
     return (NULL);
 
-  if ((attr = _ippAddAttr(ipp, 1)) == NULL)
+ /*
+  * Create the attribute...
+  */
+
+  if ((attr = ipp_add_attr(ipp, name, group, IPP_TAG_DATE, 1)) == NULL)
     return (NULL);
 
-  attr->name      = _cupsStrAlloc(name);
-  attr->group_tag = group;
-  attr->value_tag = IPP_TAG_DATE;
   memcpy(attr->values[0].date, value, 11);
 
   return (attr);
@@ -268,12 +398,24 @@ ippAddDate(ipp_t             *ipp,        /* I - IPP message */
 
 /*
  * 'ippAddInteger()' - Add a integer attribute to an IPP message.
+ *
+ * The @code ipp@ parameter refers to an IPP message previously created using the
+ * @link ippNew@ or @link ippNewRequest@ functions.
+ *
+ * The @code group@ parameter specifies the IPP attribute group tag: none
+ * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
+ * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
+ * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
+ * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
+ *
+ * Supported values include enum (@code IPP_TAG_ENUM@) and integer
+ * (@code IPP_TAG_INTEGER@).
  */
 
 ipp_attribute_t *                      /* O - New attribute */
 ippAddInteger(ipp_t      *ipp,         /* I - IPP message */
               ipp_tag_t  group,                /* I - IPP group */
-             ipp_tag_t  type,          /* I - Type of attribute */
+             ipp_tag_t  value_tag,     /* I - Type of attribute */
               const char *name,                /* I - Name of attribute */
               int        value)                /* I - Value of attribute */
 {
@@ -282,17 +424,40 @@ ippAddInteger(ipp_t      *ipp,            /* I - IPP message */
 
   DEBUG_printf(("ippAddInteger(ipp=%p, group=%02x(%s), type=%02x(%s), "
                 "name=\"%s\", value=%d)", ipp, group, ippTagString(group),
-               type, ippTagString(type), name, value));
+               value_tag, ippTagString(value_tag), name, value));
 
-  if (!ipp || !name)
+  value_tag &= IPP_TAG_MASK;
+
+ /*
+  * Special-case for legacy usage: map out-of-band attributes to new ippAddOutOfBand
+  * function...
+  */
+
+  if (value_tag >= IPP_TAG_UNSUPPORTED_VALUE && value_tag <= IPP_TAG_ADMINDEFINE)
+    return (ippAddOutOfBand(ipp, group, value_tag, name));
+
+ /*
+  * Range check input...
+  */
+
+#if 0
+  if (!ipp || !name || group < IPP_TAG_ZERO ||
+      group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
+      (value_tag != IPP_TAG_INTEGER && value_tag != IPP_TAG_ENUM))
+    return (NULL);
+#else
+  if (!ipp || !name || group < IPP_TAG_ZERO ||
+      group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE)
     return (NULL);
+#endif /* 0 */
 
-  if ((attr = _ippAddAttr(ipp, 1)) == NULL)
+ /*
+  * Create the attribute...
+  */
+
+  if ((attr = ipp_add_attr(ipp, name, group, value_tag, 1)) == NULL)
     return (NULL);
 
-  attr->name              = _cupsStrAlloc(name);
-  attr->group_tag         = group;
-  attr->value_tag         = type;
   attr->values[0].integer = value;
 
   return (attr);
@@ -301,41 +466,71 @@ ippAddInteger(ipp_t      *ipp,            /* I - IPP message */
 
 /*
  * 'ippAddIntegers()' - Add an array of integer values.
+ *
+ * The @code ipp@ parameter refers to an IPP message previously created using the
+ * @link ippNew@ or @link ippNewRequest@ functions.
+ *
+ * The @code group@ parameter specifies the IPP attribute group tag: none
+ * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
+ * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
+ * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
+ * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
+ *
+ * Supported values include enum (@code IPP_TAG_ENUM@) and integer
+ * (@code IPP_TAG_INTEGER@).
  */
 
 ipp_attribute_t *                      /* O - New attribute */
 ippAddIntegers(ipp_t      *ipp,                /* I - IPP message */
                ipp_tag_t  group,       /* I - IPP group */
-              ipp_tag_t  type,         /* I - Type of attribute */
+              ipp_tag_t  value_tag,    /* I - Type of attribute */
               const char *name,        /* I - Name of attribute */
               int        num_values,   /* I - Number of values */
               const int  *values)      /* I - Values */
 {
   int                  i;              /* Looping var */
   ipp_attribute_t      *attr;          /* New attribute */
-  ipp_value_t          *value;         /* Current value */
+  _ipp_value_t         *value;         /* Current value */
 
 
   DEBUG_printf(("ippAddIntegers(ipp=%p, group=%02x(%s), type=%02x(%s), "
                 "name=\"%s\", num_values=%d, values=%p)", ipp,
-               group, ippTagString(group), type, ippTagString(type), name,
+               group, ippTagString(group), value_tag, ippTagString(value_tag), name,
                num_values, values));
 
-  if (!ipp || !name || num_values < 1)
-    return (NULL);
+  value_tag &= IPP_TAG_MASK;
+
+ /*
+  * Range check input...
+  */
 
-  if ((attr = _ippAddAttr(ipp, num_values)) == NULL)
+#if 0
+  if (!ipp || !name || group < IPP_TAG_ZERO ||
+      group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
+      (value_tag != IPP_TAG_INTEGER && value_tag != IPP_TAG_ENUM) ||
+      num_values < 1)
+    return (NULL);
+#else
+  if (!ipp || !name || group < IPP_TAG_ZERO ||
+      group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
+      num_values < 1)
     return (NULL);
+#endif /* 0 */
 
-  attr->name      = _cupsStrAlloc(name);
-  attr->group_tag = group;
-  attr->value_tag = type;
+ /*
+  * Create the attribute...
+  */
+
+  if ((attr = ipp_add_attr(ipp, name, group, value_tag, num_values)) == NULL)
+    return (NULL);
 
-  if (values != NULL)
-    for (i = 0, value = attr->values;
-        i < num_values;
-        i ++, value ++)
-      value->integer = values[i];
+  if (values)
+  {
+    for (i = num_values, value = attr->values;
+        i > 0;
+        i --, value ++)
+      value->integer = *values++;
+  }
 
   return (attr);
 }
@@ -344,6 +539,15 @@ ippAddIntegers(ipp_t      *ipp,            /* I - IPP message */
 /*
  * 'ippAddOctetString()' - Add an octetString value to an IPP message.
  *
+ * The @code ipp@ parameter refers to an IPP message previously created using the
+ * @link ippNew@ or @link ippNewRequest@ functions.
+ *
+ * The @code group@ parameter specifies the IPP attribute group tag: none
+ * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
+ * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
+ * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
+ * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
+ *
  * @since CUPS 1.2/Mac OS X 10.5@
  */
 
@@ -357,19 +561,17 @@ ippAddOctetString(ipp_t      *ipp,        /* I - IPP message */
   ipp_attribute_t      *attr;          /* New attribute */
 
 
-  if (ipp == NULL || name == NULL)
+  if (!ipp || !name || group < IPP_TAG_ZERO ||
+      group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE)
     return (NULL);
 
-  if ((attr = _ippAddAttr(ipp, 1)) == NULL)
+  if ((attr = ipp_add_attr(ipp, name, group, IPP_TAG_STRING, 1)) == NULL)
     return (NULL);
 
  /*
   * Initialize the attribute data...
   */
 
-  attr->name                     = _cupsStrAlloc(name);
-  attr->group_tag                = group;
-  attr->value_tag                = IPP_TAG_STRING;
   attr->values[0].unknown.length = datalen;
 
   if (data)
@@ -392,164 +594,74 @@ ippAddOctetString(ipp_t      *ipp,       /* I - IPP message */
 
 
 /*
- * 'ippAddString()' - Add a language-encoded string to an IPP message.
+ * 'ippAddOutOfBand()' - Add an out-of-band value to an IPP message.
+ *
+ * The @code ipp@ parameter refers to an IPP message previously created using the
+ * @link ippNew@ or @link ippNewRequest@ functions.
+ *
+ * The @code group@ parameter specifies the IPP attribute group tag: none
+ * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
+ * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
+ * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
+ * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
+ *
+ * Supported out-of-band values include unsupported-value
+ * (@code IPP_TAG_UNSUPPORTED_VALUE@), default (@code IPP_TAG_DEFAULT@), unknown
+ * (@code IPP_TAG_UNKNOWN@), no-value (@code IPP_TAG_NOVALUE@), not-settable
+ * (@code IPP_TAG_NOTSETTABLE@), delete-attribute (@code IPP_TAG_DELETEATTR@), and
+ * admin-define (@code IPP_TAG_ADMINDEFINE@).
+ *
+ * @since CUPS 1.6@
  */
 
-ipp_attribute_t *                      /* O - New attribute */
-ippAddString(ipp_t      *ipp,          /* I - IPP message */
-             ipp_tag_t  group,         /* I - IPP group */
-            ipp_tag_t  type,           /* I - Type of attribute */
-             const char *name,         /* I - Name of attribute */
-             const char *charset,      /* I - Character set */
-             const char *value)                /* I - Value */
+ipp_attribute_t        *                       /* O - New attribute */
+ippAddOutOfBand(ipp_t      *ipp,       /* I - IPP message */
+                ipp_tag_t  group,      /* I - IPP group */
+                ipp_tag_t  value_tag,  /* I - Type of attribute */
+               const char *name)       /* I - Name of attribute */
 {
-  ipp_attribute_t      *attr;          /* New attribute */
-  char                 buffer[1024],   /* Language/charset value buffer */
-                       *bufptr;        /* Pointer into buffer */
-
-
-  DEBUG_printf(("ippAddString(ipp=%p, group=%02x(%s), type=%02x(%s), "
-                "name=\"%s\", charset=\"%s\", value=\"%s\")", ipp,
-               group, ippTagString(group), type, ippTagString(type), name,
-               charset, value));
-
-  if (!ipp || !name)
-    return (NULL);
-
-  if ((attr = _ippAddAttr(ipp, 1)) == NULL)
-    return (NULL);
-
- /*
-  * Force value to be English for the POSIX locale...
-  */
-
-  if (type == IPP_TAG_LANGUAGE && !_cups_strcasecmp(value, "C"))
-    value = "en";
+  DEBUG_printf(("ippAddOutOfBand(ipp=%p, group=%02x(%s), value_tag=%02x(%s), "
+                "name=\"%s\")", ipp, group, ippTagString(group), value_tag,
+                ippTagString(value_tag), name));
 
- /*
-  * Convert language and charset values to lowercase and change _ to - as
-  * needed...
-  */
-
-  if ((type == IPP_TAG_LANGUAGE || type == IPP_TAG_CHARSET) && value)
-  {
-    strlcpy(buffer, value, sizeof(buffer));
-    value = buffer;
-
-    for (bufptr = buffer; *bufptr; bufptr ++)
-      if (*bufptr == '_')
-        *bufptr = '-';
-      else
-        *bufptr = tolower(*bufptr & 255);
-  }
+  value_tag &= IPP_TAG_MASK;
 
  /*
-  * Initialize the attribute data...
+  * Range check input...
   */
 
-  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);
-}
-
-
-/*
- * 'ippAddStrings()' - Add language-encoded strings to an IPP message.
- */
-
-ipp_attribute_t *                      /* O - New attribute */
-ippAddStrings(
-    ipp_t              *ipp,           /* I - IPP message */
-    ipp_tag_t          group,          /* I - IPP group */
-    ipp_tag_t          type,           /* I - Type of attribute */
-    const char         *name,          /* I - Name of attribute */
-    int                num_values,     /* I - Number of values */
-    const char         *charset,       /* I - Character set */
-    const char * const *values)                /* I - Values */
-{
-  int                  i;              /* Looping var */
-  ipp_attribute_t      *attr;          /* New attribute */
-  ipp_value_t          *value;         /* Current value */
-  char                 buffer[1024],   /* Language/charset value buffer */
-                       *bufptr;        /* Pointer into buffer */
-
-
-  DEBUG_printf(("ippAddStrings(ipp=%p, group=%02x(%s), type=%02x(%s), "
-                "name=\"%s\", num_values=%d, charset=\"%s\", values=%p)", ipp,
-               group, ippTagString(group), type, ippTagString(type), name,
-               num_values, charset, values));
-
-  if (!ipp || !name || num_values < 1)
-    return (NULL);
-
-  if ((attr = _ippAddAttr(ipp, num_values)) == NULL)
+  if (!ipp || !name || group < IPP_TAG_ZERO ||
+      group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
+      (value_tag != IPP_TAG_UNSUPPORTED_VALUE &&
+       value_tag != IPP_TAG_DEFAULT &&
+       value_tag != IPP_TAG_UNKNOWN &&
+       value_tag != IPP_TAG_NOVALUE &&
+       value_tag != IPP_TAG_NOTSETTABLE &&
+       value_tag != IPP_TAG_DELETEATTR &&
+       value_tag != IPP_TAG_ADMINDEFINE))
     return (NULL);
 
  /*
-  * Initialize the attribute data...
+  * Create the attribute...
   */
 
-  attr->name      = _cupsStrAlloc(name);
-  attr->group_tag = group;
-  attr->value_tag = type;
-
-  for (i = 0, value = attr->values;
-       i < num_values;
-       i ++, value ++)
-  {
-    if (i == 0)
-      value->string.charset = ((int)type & IPP_TAG_COPY) ? (char *)charset :
-                                   charset ? _cupsStrAlloc(charset) : NULL;
-    else
-      value->string.charset = attr->values[0].string.charset;
-
-    if (values != NULL)
-    {
-      if ((int)type & IPP_TAG_COPY)
-        value->string.text = (char *)values[i];
-      else if (type == IPP_TAG_LANGUAGE && !_cups_strcasecmp(values[i], "C"))
-      {
-       /*
-       * Force language to be English for the POSIX locale...
-       */
-
-       value->string.text = ((int)type & IPP_TAG_COPY) ? "en" :
-                                      _cupsStrAlloc("en");
-      }
-      else if (type == IPP_TAG_LANGUAGE || type == IPP_TAG_CHARSET)
-      {
-       /*
-       * Convert language values to lowercase and change _ to - as needed...
-       */
-
-       strlcpy(buffer, values[i], sizeof(buffer));
-
-       for (bufptr = buffer; *bufptr; bufptr ++)
-         if (*bufptr == '_')
-           *bufptr = '-';
-         else
-           *bufptr = tolower(*bufptr & 255);
-
-       value->string.text = _cupsStrAlloc(buffer);
-      }
-      else
-       value->string.text = _cupsStrAlloc(values[i]);
-
-    }
-  }
-
-  return (attr);
+  return (ipp_add_attr(ipp, name, group, value_tag, 1));
 }
 
 
 /*
  * 'ippAddRange()' - Add a range of values to an IPP message.
+ *
+ * The @code ipp@ parameter refers to an IPP message previously created using the
+ * @link ippNew@ or @link ippNewRequest@ functions.
+ *
+ * The @code group@ parameter specifies the IPP attribute group tag: none
+ * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
+ * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
+ * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
+ * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
+ *
+ * The @code lower@ parameter must be less than or equal to the @code upper@ parameter.
  */
 
 ipp_attribute_t *                      /* O - New attribute */
@@ -566,15 +678,21 @@ ippAddRange(ipp_t      *ipp,              /* I - IPP message */
                 "upper=%d)", ipp, group, ippTagString(group), name, lower,
                upper));
 
-  if (!ipp || !name)
+ /*
+  * Range check input...
+  */
+
+  if (!ipp || !name || group < IPP_TAG_ZERO ||
+      group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE)
     return (NULL);
 
-  if ((attr = _ippAddAttr(ipp, 1)) == NULL)
+ /*
+  * Create the attribute...
+  */
+
+  if ((attr = ipp_add_attr(ipp, name, group, IPP_TAG_RANGE, 1)) == NULL)
     return (NULL);
 
-  attr->name                  = _cupsStrAlloc(name);
-  attr->group_tag             = group;
-  attr->value_tag             = IPP_TAG_RANGE;
   attr->values[0].range.lower = lower;
   attr->values[0].range.upper = upper;
 
@@ -584,6 +702,15 @@ ippAddRange(ipp_t      *ipp,               /* I - IPP message */
 
 /*
  * 'ippAddRanges()' - Add ranges of values to an IPP message.
+ *
+ * The @code ipp@ parameter refers to an IPP message previously created using the
+ * @link ippNew@ or @link ippNewRequest@ functions.
+ *
+ * The @code group@ parameter specifies the IPP attribute group tag: none
+ * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
+ * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
+ * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
+ * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
  */
 
 ipp_attribute_t *                      /* O - New attribute */
@@ -596,31 +723,39 @@ ippAddRanges(ipp_t      *ipp,             /* I - IPP message */
 {
   int                  i;              /* Looping var */
   ipp_attribute_t      *attr;          /* New attribute */
-  ipp_value_t          *value;         /* Current value */
+  _ipp_value_t         *value;         /* Current value */
 
 
   DEBUG_printf(("ippAddRanges(ipp=%p, group=%02x(%s), name=\"%s\", "
                 "num_values=%d, lower=%p, upper=%p)", ipp, group,
                ippTagString(group), name, num_values, lower, upper));
 
-  if (!ipp || !name || num_values < 1)
-    return (NULL);
+ /*
+  * Range check input...
+  */
 
-  if ((attr = _ippAddAttr(ipp, num_values)) == NULL)
+  if (!ipp || !name || group < IPP_TAG_ZERO ||
+      group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
+      num_values < 1)
     return (NULL);
 
-  attr->name      = _cupsStrAlloc(name);
-  attr->group_tag = group;
-  attr->value_tag = IPP_TAG_RANGE;
+ /*
+  * Create the attribute...
+  */
+
+  if ((attr = ipp_add_attr(ipp, name, group, IPP_TAG_RANGE, num_values)) == NULL)
+    return (NULL);
 
-  if (lower != NULL && upper != NULL)
-    for (i = 0, value = attr->values;
-        i < num_values;
-        i ++, value ++)
+  if (lower && upper)
+  {
+    for (i = num_values, value = attr->values;
+        i > 0;
+        i --, value ++)
     {
-      value->range.lower = lower[i];
-      value->range.upper = upper[i];
+      value->range.lower = *lower++;
+      value->range.upper = *upper++;
     }
+  }
 
   return (attr);
 }
@@ -628,6 +763,15 @@ ippAddRanges(ipp_t      *ipp,              /* I - IPP message */
 
 /*
  * 'ippAddResolution()' - Add a resolution value to an IPP message.
+ *
+ * The @code ipp@ parameter refers to an IPP message previously created using the
+ * @link ippNew@ or @link ippNewRequest@ functions.
+ *
+ * The @code group@ parameter specifies the IPP attribute group tag: none
+ * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
+ * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
+ * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
+ * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
  */
 
 ipp_attribute_t *                      /* O - New attribute */
@@ -645,15 +789,23 @@ ippAddResolution(ipp_t      *ipp, /* I - IPP message */
                 "units=%d, xres=%d, yres=%d)", ipp, group,
                ippTagString(group), name, units, xres, yres));
 
-  if (!ipp || !name)
+ /*
+  * Range check input...
+  */
+
+  if (!ipp || !name || group < IPP_TAG_ZERO ||
+      group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
+      units < IPP_RES_PER_INCH || units > IPP_RES_PER_CM ||
+      xres < 0 || yres < 0)
     return (NULL);
 
-  if ((attr = _ippAddAttr(ipp, 1)) == NULL)
+ /*
+  * Create the attribute...
+  */
+
+  if ((attr = ipp_add_attr(ipp, name, group, IPP_TAG_RESOLUTION, 1)) == NULL)
     return (NULL);
 
-  attr->name                       = _cupsStrAlloc(name);
-  attr->group_tag                  = group;
-  attr->value_tag                  = IPP_TAG_RESOLUTION;
   attr->values[0].resolution.xres  = xres;
   attr->values[0].resolution.yres  = yres;
   attr->values[0].resolution.units = units;
@@ -664,6 +816,15 @@ ippAddResolution(ipp_t      *ipp,  /* I - IPP message */
 
 /*
  * 'ippAddResolutions()' - Add resolution values to an IPP message.
+ *
+ * The @code ipp@ parameter refers to an IPP message previously created using the
+ * @link ippNew@ or @link ippNewRequest@ functions.
+ *
+ * The @code group@ parameter specifies the IPP attribute group tag: none
+ * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
+ * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
+ * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
+ * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
  */
 
 ipp_attribute_t *                      /* O - New attribute */
@@ -677,32 +838,41 @@ ippAddResolutions(ipp_t      *ipp,        /* I - IPP message */
 {
   int                  i;              /* Looping var */
   ipp_attribute_t      *attr;          /* New attribute */
-  ipp_value_t          *value;         /* Current value */
+  _ipp_value_t         *value;         /* Current value */
 
 
   DEBUG_printf(("ippAddResolutions(ipp=%p, group=%02x(%s), name=\"%s\", "
                 "num_value=%d, units=%d, xres=%p, yres=%p)", ipp, group,
                ippTagString(group), name, num_values, units, xres, yres));
 
-  if (!ipp || !name || num_values < 1)
-    return (NULL);
+ /*
+  * Range check input...
+  */
 
-  if ((attr = _ippAddAttr(ipp, num_values)) == NULL)
+  if (!ipp || !name || group < IPP_TAG_ZERO ||
+      group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
+      num_values < 1 ||
+      units < IPP_RES_PER_INCH || units > IPP_RES_PER_CM)
     return (NULL);
 
-  attr->name      = _cupsStrAlloc(name);
-  attr->group_tag = group;
-  attr->value_tag = IPP_TAG_RESOLUTION;
+ /*
+  * Create the attribute...
+  */
+
+  if ((attr = ipp_add_attr(ipp, name, group, IPP_TAG_RESOLUTION, num_values)) == NULL)
+    return (NULL);
 
-  if (xres != NULL && yres != NULL)
-    for (i = 0, value = attr->values;
-        i < num_values;
-        i ++, value ++)
+  if (xres && yres)
+  {
+    for (i = num_values, value = attr->values;
+        i > 0;
+        i --, value ++)
     {
-      value->resolution.xres  = xres[i];
-      value->resolution.yres  = yres[i];
+      value->resolution.xres  = *xres++;
+      value->resolution.yres  = *yres++;
       value->resolution.units = units;
     }
+  }
 
   return (attr);
 }
@@ -710,1123 +880,2808 @@ ippAddResolutions(ipp_t      *ipp,    /* I - IPP message */
 
 /*
  * 'ippAddSeparator()' - Add a group separator to an IPP message.
+ *
+ * The @code ipp@ parameter refers to an IPP message previously created using the
+ * @link ippNew@ or @link ippNewRequest@ functions.
  */
 
 ipp_attribute_t *                      /* O - New attribute */
 ippAddSeparator(ipp_t *ipp)            /* I - IPP message */
 {
-  ipp_attribute_t      *attr;          /* New attribute */
-
-
   DEBUG_printf(("ippAddSeparator(ipp=%p)", ipp));
 
-  if (!ipp)
-    return (NULL);
+ /*
+  * Range check input...
+  */
 
-  if ((attr = _ippAddAttr(ipp, 0)) == NULL)
+  if (!ipp)
     return (NULL);
 
-  attr->group_tag = IPP_TAG_ZERO;
-  attr->value_tag = IPP_TAG_ZERO;
+ /*
+  * Create the attribute...
+  */
 
-  return (attr);
+  return (ipp_add_attr(ipp, NULL, IPP_TAG_ZERO, IPP_TAG_ZERO, 0));
 }
 
 
 /*
- * 'ippDateToTime()' - Convert from RFC 1903 Date/Time format to UNIX time
- *                     in seconds.
+ * 'ippAddString()' - Add a language-encoded string to an IPP message.
+ *
+ * The @code ipp@ parameter refers to an IPP message previously created using the
+ * @link ippNew@ or @link ippNewRequest@ functions.
+ *
+ * The @code group@ parameter specifies the IPP attribute group tag: none
+ * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
+ * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
+ * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
+ * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
+ *
+ * Supported string values include charset (@code IPP_TAG_CHARSET@), keyword
+ * (@code IPP_TAG_KEYWORD@), language (@code IPP_TAG_LANGUAGE@), mimeMediaType
+ * (@code IPP_TAG_MIMETYPE@), name (@code IPP_TAG_NAME@), nameWithLanguage
+ * (@code IPP_TAG_NAMELANG), text (@code IPP_TAG_TEXT@), textWithLanguage
+ * (@code IPP_TAG_TEXTLANG@), uri (@code IPP_TAG_URI@), and uriScheme
+ * (@code IPP_TAG_URISCHEME@).
+ *
+ * The @code language@ parameter must be non-@code NULL@ for nameWithLanguage and
+ * textWithLanguage string values and must be @code NULL@ for all other string values.
  */
 
-time_t                                 /* O - UNIX time value */
-ippDateToTime(const ipp_uchar_t *date) /* I - RFC 1903 date info */
+ipp_attribute_t *                      /* O - New attribute */
+ippAddString(ipp_t      *ipp,          /* I - IPP message */
+             ipp_tag_t  group,         /* I - IPP group */
+            ipp_tag_t  value_tag,      /* I - Type of attribute */
+             const char *name,         /* I - Name of attribute */
+             const char *language,     /* I - Language code */
+             const char *value)                /* I - Value */
 {
-  struct tm    unixdate;               /* UNIX date/time info */
-  time_t       t;                      /* Computed time */
-
+  ipp_tag_t            temp_tag;       /* Temporary value tag (masked) */
+  ipp_attribute_t      *attr;          /* New attribute */
+  char                 code[32];       /* Charset/language code buffer */
 
-  if (!date)
-    return (0);
 
-  memset(&unixdate, 0, sizeof(unixdate));
+  DEBUG_printf(("ippAddString(ipp=%p, group=%02x(%s), value_tag=%02x(%s), "
+                "name=\"%s\", language=\"%s\", value=\"%s\")", ipp,
+               group, ippTagString(group), value_tag, ippTagString(value_tag), name,
+               language, value));
 
  /*
-  * RFC-1903 date/time format is:
-  *
-  *    Byte(s)  Description
-  *    -------  -----------
-  *    0-1      Year (0 to 65535)
-  *    2        Month (1 to 12)
-  *    3        Day (1 to 31)
-  *    4        Hours (0 to 23)
-  *    5        Minutes (0 to 59)
-  *    6        Seconds (0 to 60, 60 = "leap second")
-  *    7        Deciseconds (0 to 9)
-  *    8        +/- UTC
-  *    9        UTC hours (0 to 11)
-  *    10       UTC minutes (0 to 59)
+  * Range check input...
   */
 
-  unixdate.tm_year = ((date[0] << 8) | date[1]) - 1900;
-  unixdate.tm_mon  = date[2] - 1;
-  unixdate.tm_mday = date[3];
-  unixdate.tm_hour = date[4];
-  unixdate.tm_min  = date[5];
-  unixdate.tm_sec  = date[6];
-
-  t = mktime(&unixdate);
-
-  if (date[8] == '-')
-    t += date[9] * 3600 + date[10] * 60;
-  else
-    t -= date[9] * 3600 + date[10] * 60;
-
-  return (t);
-}
+  temp_tag = (ipp_tag_t)((int)value_tag & IPP_TAG_MASK);
 
+#if 0
+  if (!ipp || !name || group < IPP_TAG_ZERO ||
+      group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
+      (temp_tag < IPP_TAG_TEXT && temp_tag != IPP_TAG_TEXTLANG &&
+       temp_tag != IPP_TAG_NAMELANG) || temp_tag > IPP_TAG_MIMETYPE)
+    return (NULL);
 
-/*
- * 'ippDelete()' - Delete an IPP message.
- */
+  if ((temp_tag == IPP_TAG_TEXTLANG || temp_tag == IPP_TAG_NAMELANG)
+          != (language != NULL))
+    return (NULL);
+#else
+  if (!ipp || !name || group < IPP_TAG_ZERO ||
+      group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE)
+    return (NULL);
+#endif /* 0 */
 
-void
-ippDelete(ipp_t *ipp)                  /* I - IPP message */
-{
-  ipp_attribute_t      *attr,          /* Current attribute */
-                       *next;          /* Next attribute */
+ /*
+  * See if we need to map charset, language, or locale values...
+  */
 
+  if (language && ((int)value_tag & IPP_TAG_COPY) &&
+      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) &&
+           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) &&
+           strcmp(value, ipp_lang_code(value, code, sizeof(code))))
+    value_tag = temp_tag;              /* Don't do a fast copy */
 
-  DEBUG_printf(("ippDelete(ipp=%p)", ipp));
+ /*
+  * Create the attribute...
+  */
 
-  if (!ipp)
-    return;
+  if ((attr = ipp_add_attr(ipp, name, group, value_tag, 1)) == NULL)
+    return (NULL);
 
-  ipp->use --;
-  if (ipp->use > 0)
-    return;
+ /*
+  * Initialize the attribute data...
+  */
 
-  for (attr = ipp->attrs; attr != NULL; attr = next)
+  if ((int)value_tag & IPP_TAG_COPY)
   {
-    next = attr->next;
-    _ippFreeAttr(attr);
+    attr->values[0].string.language = (char *)language;
+    attr->values[0].string.text     = (char *)value;
+  }
+  else
+  {
+    if (language)
+      attr->values[0].string.language = _cupsStrAlloc(ipp_lang_code(language, code,
+                                                     sizeof(code)));
+
+    if (value_tag == IPP_TAG_CHARSET)
+      attr->values[0].string.text = _cupsStrAlloc(ipp_get_code(value, code,
+                                                               sizeof(code)));
+    else if (value_tag == IPP_TAG_LANGUAGE)
+      attr->values[0].string.text = _cupsStrAlloc(ipp_lang_code(value, code,
+                                                                sizeof(code)));
+    else
+      attr->values[0].string.text = _cupsStrAlloc(value);
   }
 
-  free(ipp);
+  return (attr);
 }
 
 
 /*
- * 'ippDeleteAttribute()' - Delete a single attribute in an IPP message.
+ * 'ippAddStrings()' - Add language-encoded strings to an IPP message.
  *
- * @since CUPS 1.1.19/Mac OS X 10.3@
+ * The @code ipp@ parameter refers to an IPP message previously created using the
+ * @link ippNew@ or @link ippNewRequest@ functions.
+ *
+ * The @code group@ parameter specifies the IPP attribute group tag: none
+ * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
+ * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
+ * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
+ * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
+ *
+ * Supported string values include charset (@code IPP_TAG_CHARSET@), keyword
+ * (@code IPP_TAG_KEYWORD@), language (@code IPP_TAG_LANGUAGE@), mimeMediaType
+ * (@code IPP_TAG_MIMETYPE@), name (@code IPP_TAG_NAME@), nameWithLanguage
+ * (@code IPP_TAG_NAMELANG), text (@code IPP_TAG_TEXT@), textWithLanguage
+ * (@code IPP_TAG_TEXTLANG@), uri (@code IPP_TAG_URI@), and uriScheme
+ * (@code IPP_TAG_URISCHEME@).
+ *
+ * The @code language@ parameter must be non-@code NULL@ for nameWithLanguage and
+ * textWithLanguage string values and must be @code NULL@ for all other string values.
  */
 
-void
-ippDeleteAttribute(
-    ipp_t           *ipp,              /* I - IPP message */
-    ipp_attribute_t *attr)             /* I - Attribute to delete */
+ipp_attribute_t *                      /* O - New attribute */
+ippAddStrings(
+    ipp_t              *ipp,           /* I - IPP message */
+    ipp_tag_t          group,          /* I - IPP group */
+    ipp_tag_t          value_tag,      /* I - Type of attribute */
+    const char         *name,          /* I - Name of attribute */
+    int                num_values,     /* I - Number of values */
+    const char         *language,      /* I - Language code (@code NULL@ for default) */
+    const char * const *values)                /* I - Values */
 {
-  ipp_attribute_t      *current,       /* Current attribute */
-                       *prev;          /* Previous attribute */
+  int                  i;              /* Looping var */
+  ipp_tag_t            temp_tag;       /* Temporary value tag (masked) */
+  ipp_attribute_t      *attr;          /* New attribute */
+  _ipp_value_t         *value;         /* Current value */
+  char                 code[32];       /* Language/charset value buffer */
 
 
-  DEBUG_printf(("ippDeleteAttribute(ipp=%p, attr=%p(%s))", ipp, attr,
-                attr ? attr->name : "(null)"));
+  DEBUG_printf(("ippAddStrings(ipp=%p, group=%02x(%s), value_tag=%02x(%s), "
+                "name=\"%s\", num_values=%d, language=\"%s\", values=%p)", ipp,
+               group, ippTagString(group), value_tag, ippTagString(value_tag), name,
+               num_values, language, values));
 
  /*
-  * Find the attribute in the list...
+  * Range check input...
   */
 
-  for (current = ipp->attrs, prev = NULL;
-       current != NULL && current != attr;
-       prev = current, current = current->next);
+  temp_tag = (ipp_tag_t)((int)value_tag & IPP_TAG_MASK);
+
+#if 0
+  if (!ipp || !name || group < IPP_TAG_ZERO ||
+      group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
+      (temp_tag < IPP_TAG_TEXT && temp_tag != IPP_TAG_TEXTLANG &&
+       temp_tag != IPP_TAG_NAMELANG) || temp_tag > IPP_TAG_MIMETYPE ||
+      num_values < 1)
+    return (NULL);
+
+  if ((temp_tag == IPP_TAG_TEXTLANG || temp_tag == IPP_TAG_NAMELANG)
+          != (language != NULL))
+    return (NULL);
+#else
+  if (!ipp || !name || group < IPP_TAG_ZERO ||
+      group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
+      num_values < 1)
+    return (NULL);
+#endif /* 0 */
+
+ /*
+  * See if we need to map charset, language, or locale values...
+  */
 
-  if (current)
+  if (language && ((int)value_tag & IPP_TAG_COPY) &&
+      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))
   {
-   /*
-    * Found it, remove the attribute from the list...
-    */
+    for (i = 0; i < num_values; i ++)
+      if (strcmp(values[i], ipp_get_code(values[i], code, sizeof(code))))
+      {
+       value_tag = temp_tag;           /* Don't do a fast copy */
+        break;
+      }
+  }
+  else if (values && value_tag == (ipp_tag_t)(IPP_TAG_LANGUAGE | IPP_TAG_COPY))
+  {
+    for (i = 0; i < num_values; i ++)
+      if (strcmp(values[i], ipp_lang_code(values[i], code, sizeof(code))))
+      {
+       value_tag = temp_tag;           /* Don't do a fast copy */
+        break;
+      }
+  }
 
-    if (prev)
-      prev->next = current->next;
-    else
-      ipp->attrs = current->next;
+ /*
+  * Create the attribute...
+  */
 
-    if (current == ipp->last)
-      ipp->last = prev;
+  if ((attr = ipp_add_attr(ipp, name, group, value_tag, num_values)) == NULL)
+    return (NULL);
 
-   /*
-    * Free memory used by the attribute...
-    */
+ /*
+  * Initialize the attribute data...
+  */
+
+  for (i = num_values, value = attr->values;
+       i > 0;
+       i --, value ++)
+  {
+    if (language)
+    {
+      if (value == attr->values)
+      {
+        if ((int)value_tag & IPP_TAG_COPY)
+          value->string.language = (char *)language;
+        else
+          value->string.language = _cupsStrAlloc(ipp_lang_code(language, code,
+                                                               sizeof(code)));
+      }
+      else
+       value->string.language = attr->values[0].string.language;
+    }
 
-    _ippFreeAttr(current);
+    if (values)
+    {
+      if ((int)value_tag & IPP_TAG_COPY)
+        value->string.text = (char *)*values++;
+      else if (value_tag == IPP_TAG_CHARSET)
+       value->string.text = _cupsStrAlloc(ipp_get_code(*values++, code, sizeof(code)));
+      else if (value_tag == IPP_TAG_LANGUAGE)
+       value->string.text = _cupsStrAlloc(ipp_lang_code(*values++, code, sizeof(code)));
+      else
+       value->string.text = _cupsStrAlloc(*values++);
+    }
   }
+
+  return (attr);
 }
 
 
 /*
- * 'ippFindAttribute()' - Find a named attribute in a request...
+ * 'ippCopyAttribute()' - Copy an attribute.
+ *
+ * The specified attribute, @code attr@, is copied to the destination IPP message.
+ * When @code quickcopy@ is non-zero, a "shallow" reference copy of the attribute is
+ * created - this should only be done as long as the original source IPP message will
+ * not be freed for the life of the destination.
+ *
+ * @since CUPS 1.6@
  */
 
-ipp_attribute_t        *                       /* O - Matching attribute */
-ippFindAttribute(ipp_t      *ipp,      /* I - IPP message */
-                 const char *name,     /* I - Name of attribute */
-                ipp_tag_t  type)       /* I - Type of attribute */
+
+ipp_attribute_t *                      /* O - New attribute */
+ippCopyAttribute(
+    ipp_t           *dst,              /* I - Destination IPP message */
+    ipp_attribute_t *srcattr,          /* I - Attribute to copy */
+    int             quickcopy)         /* I - 1 for a referenced copy, 0 for normal */
 {
-  DEBUG_printf(("2ippFindAttribute(ipp=%p, name=\"%s\", type=%02x(%s))", ipp,
-                name, type, ippTagString(type)));
+  int                  i;              /* Looping var */
+  ipp_attribute_t      *dstattr;       /* Destination attribute */
+  _ipp_value_t         *srcval,        /* Source value */
+                       *dstval;        /* Destination value */
 
-  if (!ipp || !name)
-    return (NULL);
+
+  DEBUG_printf(("ippCopyAttribute(dst=%p, srcattr=%p, quickcopy=%d)", dst, srcattr,
+                quickcopy));
 
  /*
-  * Reset the current pointer...
+  * Range check input...
   */
 
-  ipp->current = NULL;
+  if (!dst || !srcattr)
+    return (NULL);
 
  /*
-  * Search for the attribute...
+  * Copy it...
   */
 
-  return (ippFindNextAttribute(ipp, name, type));
-}
+  quickcopy = quickcopy ? IPP_TAG_COPY : 0;
 
+  switch (srcattr->value_tag & ~IPP_TAG_COPY)
+  {
+    case IPP_TAG_ZERO :
+        dstattr = ippAddSeparator(dst);
+       break;
 
-/*
- * 'ippFindNextAttribute()' - Find the next named attribute in a request...
- */
+    case IPP_TAG_INTEGER :
+    case IPP_TAG_ENUM :
+        dstattr = ippAddIntegers(dst, srcattr->group_tag, srcattr->value_tag,
+                                srcattr->name, srcattr->num_values, NULL);
+        if (!dstattr)
+          break;
+
+        for (i = srcattr->num_values, srcval = srcattr->values, dstval = dstattr->values;
+             i > 0;
+             i --, srcval ++, dstval ++)
+         dstval->integer = srcval->integer;
+        break;
 
-ipp_attribute_t        *                       /* O - Matching attribute */
-ippFindNextAttribute(ipp_t      *ipp,  /* I - IPP message */
-                     const char *name, /* I - Name of attribute */
-                    ipp_tag_t  type)   /* I - Type of attribute */
-{
-  ipp_attribute_t      *attr;          /* Current atttribute */
-  ipp_tag_t            value_tag;      /* Value tag */
+    case IPP_TAG_BOOLEAN :
+        dstattr = ippAddBooleans(dst, srcattr->group_tag, srcattr->name,
+                               srcattr->num_values, NULL);
+        if (!dstattr)
+          break;
+
+        for (i = srcattr->num_values, srcval = srcattr->values, dstval = dstattr->values;
+             i > 0;
+             i --, srcval ++, dstval ++)
+         dstval->boolean = srcval->boolean;
+        break;
 
+    case IPP_TAG_TEXT :
+    case IPP_TAG_NAME :
+    case IPP_TAG_KEYWORD :
+    case IPP_TAG_URI :
+    case IPP_TAG_URISCHEME :
+    case IPP_TAG_CHARSET :
+    case IPP_TAG_LANGUAGE :
+    case IPP_TAG_MIMETYPE :
+        dstattr = ippAddStrings(dst, srcattr->group_tag,
+                               (ipp_tag_t)(srcattr->value_tag | quickcopy),
+                               srcattr->name, srcattr->num_values, NULL, NULL);
+        if (!dstattr)
+          break;
 
-  DEBUG_printf(("2ippFindNextAttribute(ipp=%p, name=\"%s\", type=%02x(%s))",
-                ipp, name, type, ippTagString(type)));
+        if (quickcopy)
+       {
+         for (i = srcattr->num_values, srcval = srcattr->values,
+                  dstval = dstattr->values;
+              i > 0;
+              i --, srcval ++, dstval ++)
+           dstval->string.text = srcval->string.text;
+        }
+       else if (srcattr->value_tag & IPP_TAG_COPY)
+       {
+         for (i = srcattr->num_values, srcval = srcattr->values,
+                  dstval = dstattr->values;
+              i > 0;
+              i --, srcval ++, dstval ++)
+           dstval->string.text = _cupsStrAlloc(srcval->string.text);
+       }
+       else
+       {
+         for (i = srcattr->num_values, srcval = srcattr->values,
+                  dstval = dstattr->values;
+              i > 0;
+              i --, srcval ++, dstval ++)
+           dstval->string.text = _cupsStrRetain(srcval->string.text);
+       }
+        break;
 
-  if (!ipp || !name)
-    return (NULL);
+    case IPP_TAG_DATE :
+        if (srcattr->num_values != 1)
+          return (NULL);
 
-  if (ipp->current)
-  {
-    ipp->prev = ipp->current;
-    attr      = ipp->current->next;
-  }
-  else
-  {
-    ipp->prev = NULL;
-    attr      = ipp->attrs;
-  }
+        dstattr = ippAddDate(dst, srcattr->group_tag, srcattr->name,
+                            srcattr->values[0].date);
+        break;
 
-  for (; attr != NULL; ipp->prev = attr, attr = attr->next)
-  {
-    DEBUG_printf(("4ippFindAttribute: attr=%p, name=\"%s\"", attr,
-                  attr->name));
+    case IPP_TAG_RESOLUTION :
+        dstattr = ippAddResolutions(dst, srcattr->group_tag, srcattr->name,
+                                   srcattr->num_values, IPP_RES_PER_INCH,
+                                   NULL, NULL);
+        if (!dstattr)
+          break;
+
+        for (i = srcattr->num_values, srcval = srcattr->values, dstval = dstattr->values;
+             i > 0;
+             i --, srcval ++, dstval ++)
+       {
+         dstval->resolution.xres  = srcval->resolution.xres;
+         dstval->resolution.yres  = srcval->resolution.yres;
+         dstval->resolution.units = srcval->resolution.units;
+       }
+        break;
 
-    value_tag = (ipp_tag_t)(attr->value_tag & IPP_TAG_MASK);
+    case IPP_TAG_RANGE :
+        dstattr = ippAddRanges(dst, srcattr->group_tag, srcattr->name,
+                              srcattr->num_values, NULL, NULL);
+        if (!dstattr)
+          break;
+
+        for (i = srcattr->num_values, srcval = srcattr->values, dstval = dstattr->values;
+             i > 0;
+             i --, srcval ++, dstval ++)
+       {
+         dstval->range.lower = srcval->range.lower;
+         dstval->range.upper = srcval->range.upper;
+       }
+        break;
 
-    if (attr->name != NULL && _cups_strcasecmp(attr->name, name) == 0 &&
-        (value_tag == type || type == IPP_TAG_ZERO ||
-        (value_tag == IPP_TAG_TEXTLANG && type == IPP_TAG_TEXT) ||
-        (value_tag == IPP_TAG_NAMELANG && type == IPP_TAG_NAME)))
-    {
-      ipp->current = attr;
+    case IPP_TAG_TEXTLANG :
+    case IPP_TAG_NAMELANG :
+        dstattr = ippAddStrings(dst, srcattr->group_tag,
+                               (ipp_tag_t)(srcattr->value_tag | quickcopy),
+                               srcattr->name, srcattr->num_values, NULL, NULL);
+        if (!dstattr)
+          break;
 
-      return (attr);
-    }
-  }
+        if (quickcopy)
+       {
+         for (i = srcattr->num_values, srcval = srcattr->values,
+                  dstval = dstattr->values;
+              i > 0;
+              i --, srcval ++, dstval ++)
+         {
+            dstval->string.language = srcval->string.language;
+           dstval->string.text     = srcval->string.text;
+          }
+        }
+       else if (srcattr->value_tag & IPP_TAG_COPY)
+       {
+         for (i = srcattr->num_values, srcval = srcattr->values,
+                  dstval = dstattr->values;
+              i > 0;
+              i --, srcval ++, dstval ++)
+         {
+           if (srcval == srcattr->values)
+              dstval->string.language = _cupsStrAlloc(srcval->string.language);
+           else
+              dstval->string.language = dstattr->values[0].string.language;
 
-  ipp->current = NULL;
-  ipp->prev    = NULL;
+           dstval->string.text = _cupsStrAlloc(srcval->string.text);
+          }
+        }
+       else
+       {
+         for (i = srcattr->num_values, srcval = srcattr->values,
+                  dstval = dstattr->values;
+              i > 0;
+              i --, srcval ++, dstval ++)
+         {
+           if (srcval == srcattr->values)
+              dstval->string.language = _cupsStrRetain(srcval->string.language);
+           else
+              dstval->string.language = dstattr->values[0].string.language;
 
-  return (NULL);
-}
+           dstval->string.text = _cupsStrRetain(srcval->string.text);
+          }
+        }
+        break;
+
+    case IPP_TAG_BEGIN_COLLECTION :
+        dstattr = ippAddCollections(dst, srcattr->group_tag, srcattr->name,
+                                   srcattr->num_values, NULL);
+        if (!dstattr)
+          break;
+
+        for (i = srcattr->num_values, srcval = srcattr->values, dstval = dstattr->values;
+             i > 0;
+             i --, srcval ++, dstval ++)
+       {
+         dstval->collection = srcval->collection;
+         srcval->collection->use ++;
+       }
+        break;
 
+    case IPP_TAG_STRING :
+    default :
+        /* TODO: Implement quick copy for unknown/octetString values */
+        dstattr = ippAddIntegers(dst, srcattr->group_tag, srcattr->value_tag,
+                                srcattr->name, srcattr->num_values, NULL);
+        if (!dstattr)
+          break;
+
+        for (i = srcattr->num_values, srcval = srcattr->values, dstval = dstattr->values;
+             i > 0;
+             i --, srcval ++, dstval ++)
+       {
+         dstval->unknown.length = srcval->unknown.length;
 
-/*
- * 'ippLength()' - Compute the length of an IPP message.
- */
+         if (dstval->unknown.length > 0)
+         {
+           if ((dstval->unknown.data = malloc(dstval->unknown.length)) == NULL)
+             dstval->unknown.length = 0;
+           else
+             memcpy(dstval->unknown.data, srcval->unknown.data, dstval->unknown.length);
+         }
+       }
+        break; /* anti-compiler-warning-code */
+  }
 
-size_t                                 /* O - Size of IPP message */
-ippLength(ipp_t *ipp)                  /* I - IPP message */
-{
-  return (ipp_length(ipp, 0));
+  return (dstattr);
 }
 
 
 /*
- * 'ippNew()' - Allocate a new IPP message.
+ * 'ippCopyAttributes()' - Copy attributes from one IPP message to another.
+ *
+ * Zero or more attributes are copied from the source IPP message, @code@ src, to the
+ * destination IPP message, @code dst@. When @code quickcopy@ is non-zero, a "shallow"
+ * reference copy of the attribute is created - this should only be done as long as the
+ * original source IPP message will not be freed for the life of the destination.
+ *
+ * The @code cb@ and @code context@ parameters provide a generic way to "filter" the
+ * attributes that are copied - the function must return 1 to copy the attribute or
+ * 0 to skip it. The function may also choose to do a partial copy of the source attribute
+ * itself.
+ *
+ * @since CUPS 1.6@
  */
 
-ipp_t *                                        /* O - New IPP message */
-ippNew(void)
+int                                    /* O - 1 on success, 0 on error */
+ippCopyAttributes(
+    ipp_t        *dst,                 /* I - Destination IPP message */
+    ipp_t        *src,                 /* I - Source IPP message */
+    int          quickcopy,            /* I - 1 for a referenced copy, 0 for normal */
+    ipp_copycb_t cb,                   /* I - Copy callback or @code NULL@ for none */
+    void         *context)             /* I - Context pointer */
 {
-  ipp_t        *temp;                          /* New IPP message */
+  ipp_attribute_t      *srcattr;       /* Source attribute */
 
 
-  DEBUG_puts("ippNew()");
+  DEBUG_printf(("ippCopyAttributes(dst=%p, src=%p, quickcopy=%d, cb=%p, context=%p)",
+                dst, src, quickcopy, cb, context));
 
-  if ((temp = (ipp_t *)calloc(1, sizeof(ipp_t))) != NULL)
-  {
-   /*
-    * Default to IPP 1.1...
-    */
+ /*
+  * Range check input...
+  */
 
-    temp->request.any.version[0] = 1;
-    temp->request.any.version[1] = 1;
-    temp->use                    = 1;
-  }
+  if (!dst || !src)
+    return (0);
 
-  DEBUG_printf(("1ippNew: Returning %p", temp));
+ /*
+  * Loop through source attributes and copy as needed...
+  */
 
-  return (temp);
+  for (srcattr = src->attrs; srcattr; srcattr = srcattr->next)
+    if (!cb || (*cb)(context, dst, srcattr))
+      if (!ippCopyAttribute(dst, srcattr, quickcopy))
+        return (0);
+
+  return (1);
 }
 
 
 /*
- *  'ippNewRequest()' - Allocate a new IPP request message.
- *
- * The new request message is initialized with the attributes-charset and
- * attributes-natural-language attributes added. The
- * attributes-natural-language value is derived from the current locale.
- *
- * @since CUPS 1.2/Mac OS X 10.5@
+ * 'ippDateToTime()' - Convert from RFC 1903 Date/Time format to UNIX time
+ *                     in seconds.
  */
 
-ipp_t *                                        /* O - IPP request message */
-ippNewRequest(ipp_op_t op)             /* I - Operation code */
+time_t                                 /* O - UNIX time value */
+ippDateToTime(const ipp_uchar_t *date) /* I - RFC 1903 date info */
 {
-  ipp_t                *request;               /* IPP request message */
-  cups_lang_t  *language;              /* Current language localization */
+  struct tm    unixdate;               /* UNIX date/time info */
+  time_t       t;                      /* Computed time */
 
 
-  DEBUG_printf(("ippNewRequest(op=%02x(%s))", op, ippOpString(op)));
+  if (!date)
+    return (0);
+
+  memset(&unixdate, 0, sizeof(unixdate));
 
  /*
-  * Create a new IPP message...
+  * RFC-1903 date/time format is:
+  *
+  *    Byte(s)  Description
+  *    -------  -----------
+  *    0-1      Year (0 to 65535)
+  *    2        Month (1 to 12)
+  *    3        Day (1 to 31)
+  *    4        Hours (0 to 23)
+  *    5        Minutes (0 to 59)
+  *    6        Seconds (0 to 60, 60 = "leap second")
+  *    7        Deciseconds (0 to 9)
+  *    8        +/- UTC
+  *    9        UTC hours (0 to 11)
+  *    10       UTC minutes (0 to 59)
   */
 
-  if ((request = ippNew()) == NULL)
-    return (NULL);
+  unixdate.tm_year = ((date[0] << 8) | date[1]) - 1900;
+  unixdate.tm_mon  = date[2] - 1;
+  unixdate.tm_mday = date[3];
+  unixdate.tm_hour = date[4];
+  unixdate.tm_min  = date[5];
+  unixdate.tm_sec  = date[6];
 
- /*
-  * Set the operation and request ID...
-  */
+  t = mktime(&unixdate);
 
-  request->request.op.operation_id = op;
-  request->request.op.request_id   = 1;
+  if (date[8] == '-')
+    t += date[9] * 3600 + date[10] * 60;
+  else
+    t -= date[9] * 3600 + date[10] * 60;
+
+  return (t);
+}
+
+
+/*
+ * 'ippDelete()' - Delete an IPP message.
+ */
+
+void
+ippDelete(ipp_t *ipp)                  /* I - IPP message */
+{
+  ipp_attribute_t      *attr,          /* Current attribute */
+                       *next;          /* Next attribute */
+
+
+  DEBUG_printf(("ippDelete(ipp=%p)", ipp));
+
+  if (!ipp)
+    return;
+
+  ipp->use --;
+  if (ipp->use > 0)
+    return;
+
+  for (attr = ipp->attrs; attr != NULL; attr = next)
+  {
+    next = attr->next;
+
+    ipp_free_values(attr, 0, attr->num_values);
+
+    if (attr->name)
+      _cupsStrFree(attr->name);
+
+    free(attr);
+  }
+
+  free(ipp);
+}
+
+
+/*
+ * 'ippDeleteAttribute()' - Delete a single attribute in an IPP message.
+ *
+ * @since CUPS 1.1.19/Mac OS X 10.3@
+ */
+
+void
+ippDeleteAttribute(
+    ipp_t           *ipp,              /* I - IPP message */
+    ipp_attribute_t *attr)             /* I - Attribute to delete */
+{
+  ipp_attribute_t      *current,       /* Current attribute */
+                       *prev;          /* Previous attribute */
+
+
+  DEBUG_printf(("ippDeleteAttribute(ipp=%p, attr=%p(%s))", ipp, attr,
+                attr ? attr->name : "(null)"));
 
  /*
-  * Use UTF-8 as the character set...
+  * Range check input...
   */
 
-  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
-               "attributes-charset", NULL, "utf-8");
+  if (!attr)
+    return;
 
  /*
-  * Get the language from the current locale...
+  * Find the attribute in the list...
   */
 
-  language = cupsLangDefault();
+  if (ipp)
+  {
+    for (current = ipp->attrs, prev = NULL;
+        current;
+        prev = current, current = current->next)
+      if (current == attr)
+      {
+       /*
+       * Found it, remove the attribute from the list...
+       */
+    
+       if (prev)
+         prev->next = current->next;
+       else
+         ipp->attrs = current->next;
+    
+       if (current == ipp->last)
+         ipp->last = prev;
 
-  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
-               "attributes-natural-language", NULL, language->language);
+        break;
+      }
+
+    if (!current)
+      return;
+  }
 
  /*
-  * Return the new request...
+  * Free memory used by the attribute...
   */
 
-  return (request);
+  ipp_free_values(attr, 0, attr->num_values);
+
+  if (attr->name)
+    _cupsStrFree(attr->name);
+
+  free(attr);
 }
 
 
 /*
- * 'ippRead()' - Read data for an IPP message from a HTTP connection.
+ * 'ippDeleteValues()' - Delete values in an attribute.
+ *
+ * The @code element@ parameter specifies the first value to delete, starting at 0. It
+ * must be less than the number of values returned by @link ippGetCount@.
+ *
+ * Deleting all values in an attribute deletes the attribute.
+ *
+ * @since CUPS 1.6@
  */
 
-ipp_state_t                            /* O - Current state */
-ippRead(http_t *http,                  /* I - HTTP connection */
-        ipp_t  *ipp)                   /* I - IPP data */
+int                                    /* O - 1 on success, 0 on failure */
+ippDeleteValues(
+    ipp_t           *ipp,              /* I - IPP message */
+    ipp_attribute_t *attr,             /* I - Attribute */
+    int             element,           /* I - Index of first value to delete (0-based) */
+    int             count)             /* I - Number of values to delete */
 {
-  DEBUG_printf(("ippRead(http=%p, ipp=%p), data_remaining=" CUPS_LLFMT,
-                http, ipp, CUPS_LLCAST (http ? http->data_remaining : -1)));
+ /*
+  * Range check input...
+  */
 
-  if (!http)
-    return (IPP_ERROR);
+  if (!ipp || !attr || element < 0 || element >= attr->num_values || count <= 0 ||
+      (element + count) >= attr->num_values)
+    return (0);
 
-  DEBUG_printf(("2ippRead: http->state=%d, http->used=%d", http->state,
-                http->used));
+ /*
+  * If we are deleting all values, just delete the attribute entirely.
+  */
 
-  return (ippReadIO(http, (ipp_iocb_t)ipp_read_http, http->blocking, NULL,
-                    ipp));
+  if (count == attr->num_values)
+  {
+    ippDeleteAttribute(ipp, attr);
+    return (1);
+  }
+
+ /*
+  * Otherwise free the values in question and return.
+  */
+
+  ipp_free_values(attr, element, count);
+
+  return (1);
 }
 
 
 /*
- * 'ippReadFile()' - Read data for an IPP message from a file.
- *
- * @since CUPS 1.1.19/Mac OS X 10.3@
+ * 'ippFindAttribute()' - Find a named attribute in a request...
  */
 
-ipp_state_t                            /* O - Current state */
-ippReadFile(int   fd,                  /* I - HTTP data */
-            ipp_t *ipp)                        /* I - IPP data */
+ipp_attribute_t        *                       /* O - Matching attribute */
+ippFindAttribute(ipp_t      *ipp,      /* I - IPP message */
+                 const char *name,     /* I - Name of attribute */
+                ipp_tag_t  type)       /* I - Type of attribute */
 {
-  DEBUG_printf(("ippReadFile(fd=%d, ipp=%p)", fd, ipp));
+  DEBUG_printf(("2ippFindAttribute(ipp=%p, name=\"%s\", type=%02x(%s))", ipp,
+                name, type, ippTagString(type)));
 
-  return (ippReadIO(&fd, (ipp_iocb_t)ipp_read_file, 1, NULL, ipp));
+  if (!ipp || !name)
+    return (NULL);
+
+ /*
+  * Reset the current pointer...
+  */
+
+  ipp->current = NULL;
+
+ /*
+  * Search for the attribute...
+  */
+
+  return (ippFindNextAttribute(ipp, name, type));
 }
 
 
 /*
- * 'ippReadIO()' - Read data for an IPP message.
- *
- * @since CUPS 1.2/Mac OS X 10.5@
+ * 'ippFindNextAttribute()' - Find the next named attribute in a request...
  */
 
-ipp_state_t                            /* O - Current state */
-ippReadIO(void       *src,             /* I - Data source */
-          ipp_iocb_t cb,               /* I - Read callback function */
-         int        blocking,          /* I - Use blocking IO? */
-         ipp_t      *parent,           /* I - Parent request, if any */
-          ipp_t      *ipp)             /* I - IPP data */
+ipp_attribute_t        *                       /* O - Matching attribute */
+ippFindNextAttribute(ipp_t      *ipp,  /* I - IPP message */
+                     const char *name, /* I - Name of attribute */
+                    ipp_tag_t  type)   /* I - Type of attribute */
 {
-  int                  n;              /* Length of data */
-  unsigned char                *buffer,        /* Data buffer */
-                       string[IPP_MAX_NAME],
-                                       /* Small string buffer */
-                       *bufptr;        /* Pointer into buffer */
-  ipp_attribute_t      *attr;          /* Current attribute */
-  ipp_tag_t            tag;            /* Current tag */
-  ipp_tag_t            value_tag;      /* Current value tag */
-  ipp_value_t          *value;         /* Current value */
+  ipp_attribute_t      *attr;          /* Current atttribute */
+  ipp_tag_t            value_tag;      /* Value tag */
 
 
-  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->state));
+  DEBUG_printf(("2ippFindNextAttribute(ipp=%p, name=\"%s\", type=%02x(%s))",
+                ipp, name, type, ippTagString(type)));
 
-  if (!src || !ipp)
-    return (IPP_ERROR);
+  if (!ipp || !name)
+    return (NULL);
 
-  if ((buffer = ipp_buffer_get()) == NULL)
+  if (ipp->current)
   {
-    DEBUG_puts("1ippReadIO: Unable to get read buffer.");
-    return (IPP_ERROR);
+    ipp->prev = ipp->current;
+    attr      = ipp->current->next;
+  }
+  else
+  {
+    ipp->prev = NULL;
+    attr      = ipp->attrs;
   }
 
-  switch (ipp->state)
+  for (; attr != NULL; ipp->prev = attr, attr = attr->next)
   {
-    case IPP_IDLE :
-        ipp->state ++; /* Avoid common problem... */
+    DEBUG_printf(("4ippFindAttribute: attr=%p, name=\"%s\"", attr,
+                  attr->name));
 
-    case IPP_HEADER :
-        if (parent == NULL)
-       {
-        /*
-          * Get the request header...
-         */
+    value_tag = (ipp_tag_t)(attr->value_tag & IPP_TAG_MASK);
+
+    if (attr->name != NULL && _cups_strcasecmp(attr->name, name) == 0 &&
+        (value_tag == type || type == IPP_TAG_ZERO ||
+        (value_tag == IPP_TAG_TEXTLANG && type == IPP_TAG_TEXT) ||
+        (value_tag == IPP_TAG_NAMELANG && type == IPP_TAG_NAME)))
+    {
+      ipp->current = attr;
+
+      return (attr);
+    }
+  }
+
+  ipp->current = NULL;
+  ipp->prev    = NULL;
+
+  return (NULL);
+}
+
+
+/*
+ * 'ippFirstAttribute()' - Return the first attribute in the message.
+ *
+ * @since CUPS 1.6@
+ */
+
+ipp_attribute_t        *                       /* O - First attribute or @code NULL@ if none */
+ippFirstAttribute(ipp_t *ipp)          /* I - IPP message */
+{
+ /*
+  * Range check input...
+  */
+
+  if (!ipp)
+    return (NULL);
+
+ /*
+  * Return the first attribute...
+  */
+
+  return (ipp->current = ipp->attrs);
+}
+
+
+/*
+ * 'ippGetBoolean()' - Get a boolean value for an attribute.
+ *
+ * The @code element@ parameter specifies which value to get from 0 to
+ * @link ippGetCount(attr)@ - 1.
+ *
+ * @since CUPS 1.6@
+ */
+
+int                                    /* O - Boolean value or -1 on error */
+ippGetBoolean(ipp_attribute_t *attr,   /* I - IPP attribute */
+              int             element) /* I - Value number (0-based) */
+{
+ /*
+  * Range check input...
+  */
+
+  if (!attr || attr->value_tag != IPP_TAG_BOOLEAN ||
+      element < 0 || element >= attr->num_values)
+    return (-1);
+
+ /*
+  * Return the value...
+  */
+
+  return (attr->values[element].boolean);
+}
+
+
+/*
+ * 'ippGetCollection()' - Get a collection value for an attribute.
+ *
+ * The @code element@ parameter specifies which value to get from 0 to
+ * @link ippGetCount(attr)@ - 1.
+ *
+ * @since CUPS 1.6@
+ */
+
+ipp_t *                                        /* O - Collection value or @code NULL@ on error */
+ippGetCollection(
+    ipp_attribute_t *attr,             /* I - IPP attribute */
+    int             element)           /* I - Value number (0-based) */
+{
+ /*
+  * Range check input...
+  */
+
+  if (!attr || attr->value_tag != IPP_TAG_BEGIN_COLLECTION ||
+      element < 0 || element >= attr->num_values)
+    return (NULL);
+
+ /*
+  * Return the value...
+  */
+
+  return (attr->values[element].collection);
+}
+
+
+/*
+ * 'ippGetCount()' - Get the number of values in an attribute.
+ *
+ * @since CUPS 1.6@
+ */
+
+int                                    /* O - Number of values or -1 on error */
+ippGetCount(ipp_attribute_t *attr)     /* I - IPP attribute */
+{
+ /*
+  * Range check input...
+  */
+
+  if (!attr)
+    return (-1);
+
+ /*
+  * Return the number of values...
+  */
+
+  return (attr->num_values);
+}
+
+
+/*
+ * 'ippGetGroupTag()' - Get the group associated with an attribute.
+ *
+ * @since CUPS 1.6@
+ */
+
+ipp_tag_t                              /* O - Group tag or @code IPP_TAG_ZERO@ on error */
+ippGetGroupTag(ipp_attribute_t *attr)  /* I - IPP attribute */
+{
+ /*
+  * Range check input...
+  */
+
+  if (!attr)
+    return (IPP_TAG_ZERO);
+
+ /*
+  * Return the group...
+  */
+
+  return (attr->group_tag);
+}
+
+
+/*
+ * 'ippGetInteger()' - Get the integer/enum value for an attribute.
+ *
+ * The @code element@ parameter specifies which value to get from 0 to
+ * @link ippGetCount(attr)@ - 1.
+ *
+ * @since CUPS 1.6@
+ */
+
+int                                    /* O - Value or -1 on error */
+ippGetInteger(ipp_attribute_t *attr,   /* I - IPP attribute */
+              int             element) /* I - Value number (0-based) */
+{
+ /*
+  * Range check input...
+  */
+
+  if (!attr || (attr->value_tag != IPP_TAG_INTEGER && attr->value_tag != IPP_TAG_ENUM) ||
+      element < 0 || element >= attr->num_values)
+    return (-1);
+
+ /*
+  * Return the value...
+  */
+
+  return (attr->values[element].integer);
+}
+
+
+/*
+ * 'ippGetName()' - Get the attribute name.
+ *
+ * @since CUPS 1.6@
+ */
+
+const char *                           /* O - Attribute name or @code NULL@ for separators */
+ippGetName(ipp_attribute_t *attr)      /* I - IPP attribute */
+{
+ /*
+  * Range check input...
+  */
+
+  if (!attr)
+    return (NULL);
+
+ /*
+  * Return the name...
+  */
+
+  return (attr->name);
+}
+
+
+/*
+ * 'ippGetOperation()' - Get the operation ID in an IPP message.
+ *
+ * @since CUPS 1.6@
+ */
+
+ipp_op_t                               /* O - Operation ID or -1 on error */
+ippGetOperation(ipp_t *ipp)            /* I - IPP request message */
+{
+ /*
+  * Range check input...
+  */
+
+  if (!ipp)
+    return ((ipp_op_t)-1);
+
+ /*
+  * Return the value...
+  */
+
+  return (ipp->request.op.operation_id);
+}
+
+
+/*
+ * 'ippGetRequestId()' - Get the request ID from an IPP message.
+ *
+ * @since CUPS 1.6@
+ */
+
+int                                    /* O - Request ID or -1 on error */
+ippGetRequestId(ipp_t *ipp)            /* I - IPP message */
+{
+ /*
+  * Range check input...
+  */
+
+  if (!ipp)
+    return (-1);
+
+ /*
+  * Return the request ID...
+  */
+
+  return (ipp->request.any.request_id);
+}
+
+
+/*
+ * 'ippGetResolution()' - Get a resolution value for an attribute.
+ *
+ * The @code element@ parameter specifies which value to get from 0 to
+ * @link ippGetCount(attr)@ - 1.
+ *
+ * @since CUPS 1.6@
+ */
+
+int                                    /* O - Horizontal/cross feed resolution or -1 */
+ippGetResolution(
+    ipp_attribute_t *attr,             /* I - IPP attribute */
+    int             element,           /* I - Value number (0-based) */
+    int             *yres,             /* O - Vertical/feed resolution */
+    ipp_res_t       *units)            /* O - Units for resolution */
+{
+ /*
+  * Range check input...
+  */
+
+  if (!attr || attr->value_tag != IPP_TAG_RESOLUTION ||
+      element < 0 || element >= attr->num_values)
+    return (-1);
+
+ /*
+  * Return the value...
+  */
+
+  if (yres)
+    *yres = attr->values[element].resolution.yres;
+
+  if (units)
+    *units = attr->values[element].resolution.units;
+
+  return (attr->values[element].resolution.xres);
+}
+
+
+/*
+ * 'ippGetStatusCode()' - Get the status code from an IPP response or event message.
+ *
+ * @since CUPS 1.6@
+ */
+
+ipp_status_t                           /* O - Status code in IPP message */
+ippGetStatusCode(ipp_t *ipp)           /* I - IPP response or event message */
+{
+ /*
+  * Range check input...
+  */
+
+  if (!ipp)
+    return (IPP_INTERNAL_ERROR);
+
+ /*
+  * Return the value...
+  */
+
+  return (ipp->request.status.status_code);
+}
+
+
+/*
+ * 'ippGetString()' - Get the string and optionally the language code for an attribute.
+ *
+ * The @code element@ parameter specifies which value to get from 0 to
+ * @link ippGetCount(attr)@ - 1.
+ *
+ * @since CUPS 1.6@
+ */
+
+const char *
+ippGetString(ipp_attribute_t *attr,    /* I - IPP attribute */
+             int             element,  /* I - Value number (0-based) */
+            const char      **language)/* O - Language code (@code NULL@ for don't care) */
+{
+ /*
+  * Range check input...
+  */
+
+  if (!attr || element < 0 || element >= attr->num_values ||
+      (attr->value_tag != IPP_TAG_TEXTLANG && attr->value_tag != IPP_TAG_NAMELANG &&
+       (attr->value_tag < IPP_TAG_TEXT || attr->value_tag > IPP_TAG_MIMETYPE)))
+    return (NULL);
+
+ /*
+  * Return the value...
+  */
+
+  if (language)
+    *language = attr->values[element].string.language;
+
+  return (attr->values[element].string.text);
+}
+
+
+/*
+ * 'ippGetValueTag()' - Get the value tag for an attribute.
+ *
+ * @since CUPS 1.6@
+ */
+
+ipp_tag_t                              /* O - Value tag or @code IPP_TAG_ZERO@ on error */
+ippGetValueTag(ipp_attribute_t *attr)  /* I - IPP attribute */
+{
+ /*
+  * Range check input...
+  */
+
+  if (!attr)
+    return (IPP_TAG_ZERO);
+
+ /*
+  * Return the value...
+  */
+
+  return (attr->value_tag);
+}
+
+
+/*
+ * 'ippGetVersion()' - Get the major and minor version number from an IPP message.
+ *
+ * @since CUPS 1.6@
+ */
+
+int                                    /* O - Major version number or -1 on error */
+ippGetVersion(ipp_t *ipp,              /* I - IPP message */
+              int   *minor)            /* O - Minor version number or @code NULL@ */
+{
+ /*
+  * Range check input...
+  */
+
+  if (!ipp)
+  {
+    if (minor)
+      *minor = -1;
+
+    return (-1);
+  }
+
+ /*
+  * Return the value...
+  */
+
+  if (minor)
+    *minor = ipp->request.any.version[1];
+
+  return (ipp->request.any.version[0]);
+}
+
+
+/*
+ * 'ippLength()' - Compute the length of an IPP message.
+ */
+
+size_t                                 /* O - Size of IPP message */
+ippLength(ipp_t *ipp)                  /* I - IPP message */
+{
+  return (ipp_length(ipp, 0));
+}
+
+
+/*
+ * 'ippNextAttribute()' - Return the next attribute in the message.
+ *
+ * @since CUPS 1.6@
+ */
+
+ipp_attribute_t *                      /* O - Next attribute or @code NULL@ if none */
+ippNextAttribute(ipp_t *ipp)           /* I - IPP message */
+{
+ /*
+  * Range check input...
+  */
+
+  if (!ipp || !ipp->current)
+    return (NULL);
+
+ /*
+  * Return the next attribute...
+  */
+
+  return (ipp->current = ipp->current->next);
+}
+
+
+/*
+ * 'ippNew()' - Allocate a new IPP message.
+ */
+
+ipp_t *                                        /* O - New IPP message */
+ippNew(void)
+{
+  ipp_t        *temp;                          /* New IPP message */
+
+
+  DEBUG_puts("ippNew()");
+
+  if ((temp = (ipp_t *)calloc(1, sizeof(ipp_t))) != NULL)
+  {
+   /*
+    * Default to IPP 1.1...
+    */
+
+    temp->request.any.version[0] = 1;
+    temp->request.any.version[1] = 1;
+    temp->use                    = 1;
+  }
+
+  DEBUG_printf(("1ippNew: Returning %p", temp));
+
+  return (temp);
+}
+
+
+/*
+ *  'ippNewRequest()' - Allocate a new IPP request message.
+ *
+ * The new request message is initialized with the attributes-charset and
+ * attributes-natural-language attributes added. The
+ * attributes-natural-language value is derived from the current locale.
+ *
+ * @since CUPS 1.2/Mac OS X 10.5@
+ */
+
+ipp_t *                                        /* O - IPP request message */
+ippNewRequest(ipp_op_t op)             /* I - Operation code */
+{
+  ipp_t                *request;               /* IPP request message */
+  cups_lang_t  *language;              /* Current language localization */
+
+
+  DEBUG_printf(("ippNewRequest(op=%02x(%s))", op, ippOpString(op)));
+
+ /*
+  * Create a new IPP message...
+  */
+
+  if ((request = ippNew()) == NULL)
+    return (NULL);
+
+ /*
+  * Set the operation and request ID...
+  */
+
+  request->request.op.operation_id = op;
+  request->request.op.request_id   = 1;
+
+ /*
+  * Use UTF-8 as the character set...
+  */
+
+  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
+               "attributes-charset", NULL, "utf-8");
+
+ /*
+  * Get the language from the current locale...
+  */
+
+  language = cupsLangDefault();
+
+  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
+               "attributes-natural-language", NULL, language->language);
+
+ /*
+  * Return the new request...
+  */
+
+  return (request);
+}
+
+
+/*
+ * 'ippRead()' - Read data for an IPP message from a HTTP connection.
+ */
+
+ipp_state_t                            /* O - Current state */
+ippRead(http_t *http,                  /* I - HTTP connection */
+        ipp_t  *ipp)                   /* I - IPP data */
+{
+  DEBUG_printf(("ippRead(http=%p, ipp=%p), data_remaining=" CUPS_LLFMT,
+                http, ipp, CUPS_LLCAST (http ? http->data_remaining : -1)));
+
+  if (!http)
+    return (IPP_ERROR);
+
+  DEBUG_printf(("2ippRead: http->state=%d, http->used=%d", http->state,
+                http->used));
+
+  return (ippReadIO(http, (ipp_iocb_t)ipp_read_http, http->blocking, NULL,
+                    ipp));
+}
+
+
+/*
+ * 'ippReadFile()' - Read data for an IPP message from a file.
+ *
+ * @since CUPS 1.1.19/Mac OS X 10.3@
+ */
+
+ipp_state_t                            /* O - Current state */
+ippReadFile(int   fd,                  /* I - HTTP data */
+            ipp_t *ipp)                        /* I - IPP data */
+{
+  DEBUG_printf(("ippReadFile(fd=%d, ipp=%p)", fd, ipp));
+
+  return (ippReadIO(&fd, (ipp_iocb_t)ipp_read_file, 1, NULL, ipp));
+}
+
+
+/*
+ * 'ippReadIO()' - Read data for an IPP message.
+ *
+ * @since CUPS 1.2/Mac OS X 10.5@
+ */
+
+ipp_state_t                            /* O - Current state */
+ippReadIO(void       *src,             /* I - Data source */
+          ipp_iocb_t cb,               /* I - Read callback function */
+         int        blocking,          /* I - Use blocking IO? */
+         ipp_t      *parent,           /* I - Parent request, if any */
+          ipp_t      *ipp)             /* I - IPP data */
+{
+  int                  n;              /* Length of data */
+  unsigned char                *buffer,        /* Data buffer */
+                       string[IPP_MAX_NAME],
+                                       /* Small string buffer */
+                       *bufptr;        /* Pointer into buffer */
+  ipp_attribute_t      *attr;          /* Current attribute */
+  ipp_tag_t            tag;            /* Current tag */
+  ipp_tag_t            value_tag;      /* Current value tag */
+  _ipp_value_t         *value;         /* Current value */
+
+
+  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->state));
+
+  if (!src || !ipp)
+    return (IPP_ERROR);
+
+  if ((buffer = ipp_buffer_get()) == NULL)
+  {
+    DEBUG_puts("1ippReadIO: Unable to get read buffer.");
+    return (IPP_ERROR);
+  }
+
+  switch (ipp->state)
+  {
+    case IPP_IDLE :
+        ipp->state ++; /* Avoid common problem... */
+
+    case IPP_HEADER :
+        if (parent == NULL)
+       {
+        /*
+          * Get the request header...
+         */
 
           if ((*cb)(src, buffer, 8) < 8)
          {
-           DEBUG_puts("1ippReadIO: Unable to read header.");
+           DEBUG_puts("1ippReadIO: Unable to read header.");
+           ipp_buffer_release(buffer);
+           return (IPP_ERROR);
+         }
+
+        /*
+          * Then copy the request header over...
+         */
+
+          ipp->request.any.version[0]  = buffer[0];
+          ipp->request.any.version[1]  = buffer[1];
+          ipp->request.any.op_status   = (buffer[2] << 8) | buffer[3];
+          ipp->request.any.request_id  = (((((buffer[4] << 8) | buffer[5]) << 8) |
+                                        buffer[6]) << 8) | buffer[7];
+
+          DEBUG_printf(("2ippReadIO: version=%d.%d", buffer[0], buffer[1]));
+         DEBUG_printf(("2ippReadIO: op_status=%04x",
+                       ipp->request.any.op_status));
+         DEBUG_printf(("2ippReadIO: request_id=%d",
+                       ipp->request.any.request_id));
+        }
+
+        ipp->state   = IPP_ATTRIBUTE;
+       ipp->current = NULL;
+       ipp->curtag  = IPP_TAG_ZERO;
+       ipp->prev    = ipp->last;
+
+       /*
+        * If blocking is disabled, stop here...
+       */
+
+        if (!blocking)
+         break;
+
+    case IPP_ATTRIBUTE :
+        for (;;)
+       {
+         if ((*cb)(src, buffer, 1) < 1)
+         {
+           DEBUG_puts("1ippReadIO: Callback returned EOF/error");
+           ipp_buffer_release(buffer);
+           return (IPP_ERROR);
+         }
+
+         DEBUG_printf(("2ippReadIO: ipp->current=%p, ipp->prev=%p",
+                       ipp->current, ipp->prev));
+
+        /*
+         * Read this attribute...
+         */
+
+          tag = (ipp_tag_t)buffer[0];
+          if (tag == IPP_TAG_EXTENSION)
+          {
+           /*
+            * Read 32-bit "extension" tag...
+            */
+
+           if ((*cb)(src, buffer, 4) < 1)
+           {
+             DEBUG_puts("1ippReadIO: Callback returned EOF/error");
+             ipp_buffer_release(buffer);
+             return (IPP_ERROR);
+           }
+
+           tag = (ipp_tag_t)((((((buffer[0] << 8) | buffer[1]) << 8) |
+                               buffer[2]) << 8) | buffer[3]);
+
+            if (tag & IPP_TAG_COPY)
+            {
+             /*
+              * Fail if the high bit is set in the tag...
+              */
+
+             _cupsSetError(IPP_ERROR, _("IPP extension tag larger than 0x7FFFFFFF."), 1);
+             DEBUG_printf(("1ippReadIO: bad name length %d.", n));
+             ipp_buffer_release(buffer);
+             return (IPP_ERROR);
+            }
+          }
+
+         if (tag == IPP_TAG_END)
+         {
+          /*
+           * No more attributes left...
+           */
+
+            DEBUG_puts("2ippReadIO: IPP_TAG_END.");
+
+           ipp->state = IPP_DATA;
+           break;
+         }
+          else if (tag < IPP_TAG_UNSUPPORTED_VALUE)
+         {
+          /*
+           * Group tag...  Set the current group and continue...
+           */
+
+            if (ipp->curtag == tag)
+             ipp->prev = ippAddSeparator(ipp);
+            else if (ipp->current)
+             ipp->prev = ipp->current;
+
+           ipp->curtag  = tag;
+           ipp->current = NULL;
+           DEBUG_printf(("2ippReadIO: group tag=%x(%s), ipp->prev=%p", tag,
+                         ippTagString(tag), ipp->prev));
+           continue;
+         }
+
+          DEBUG_printf(("2ippReadIO: value tag=%x(%s)", tag,
+                       ippTagString(tag)));
+
+         /*
+         * Get the name...
+         */
+
+          if ((*cb)(src, buffer, 2) < 2)
+         {
+           DEBUG_puts("1ippReadIO: unable to read name length.");
+           ipp_buffer_release(buffer);
+           return (IPP_ERROR);
+         }
+
+          n = (buffer[0] << 8) | buffer[1];
+
+          if (n >= IPP_BUF_SIZE)
+         {
+           _cupsSetError(IPP_ERROR, _("IPP name larger than 32767 bytes."), 1);
+           DEBUG_printf(("1ippReadIO: bad name length %d.", n));
+           ipp_buffer_release(buffer);
+           return (IPP_ERROR);
+         }
+
+          DEBUG_printf(("2ippReadIO: name length=%d", n));
+
+          if (n == 0 && tag != IPP_TAG_MEMBERNAME &&
+             tag != IPP_TAG_END_COLLECTION)
+         {
+          /*
+           * More values for current attribute...
+           */
+
+            if (ipp->current == NULL)
+           {
+             _cupsSetError(IPP_ERROR, _("IPP attribute has no name."), 1);
+             DEBUG_puts("1ippReadIO: Attribute without name and no current.");
+             ipp_buffer_release(buffer);
+             return (IPP_ERROR);
+           }
+
+            attr      = ipp->current;
+           value_tag = (ipp_tag_t)(attr->value_tag & IPP_TAG_MASK);
+
+          /*
+           * Make sure we aren't adding a new value of a different
+           * type...
+           */
+
+           if (value_tag == IPP_TAG_ZERO)
+           {
+            /*
+             * Setting the value of a collection member...
+             */
+
+             attr->value_tag = tag;
+           }
+           else if (value_tag == IPP_TAG_TEXTLANG ||
+                    value_tag == IPP_TAG_NAMELANG ||
+                    (value_tag >= IPP_TAG_TEXT &&
+                     value_tag <= IPP_TAG_MIMETYPE))
+            {
+            /*
+             * String values can sometimes come across in different
+             * forms; accept sets of differing values...
+             */
+
+             if (tag != IPP_TAG_TEXTLANG && tag != IPP_TAG_NAMELANG &&
+                 (tag < IPP_TAG_TEXT || tag > IPP_TAG_MIMETYPE) &&
+                 tag != IPP_TAG_NOVALUE)
+             {
+               _cupsSetError(IPP_ERROR,
+                             _("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)));
+               ipp_buffer_release(buffer);
+               return (IPP_ERROR);
+             }
+
+              if (value_tag != tag)
+              {
+                DEBUG_printf(("1ippReadIO: Converting %s attribute from %s to %s.",
+                              attr->name, ippTagString(value_tag), ippTagString(tag)));
+               ippSetValueTag(ipp, &attr, tag);
+             }
+            }
+           else if (value_tag == IPP_TAG_INTEGER ||
+                    value_tag == IPP_TAG_RANGE)
+            {
+            /*
+             * Integer and rangeOfInteger values can sometimes be mixed; accept
+             * sets of differing values...
+             */
+
+             if (tag != IPP_TAG_INTEGER && tag != IPP_TAG_RANGE)
+             {
+               _cupsSetError(IPP_ERROR,
+                             _("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)));
+               ipp_buffer_release(buffer);
+               return (IPP_ERROR);
+             }
+
+              if (value_tag == IPP_TAG_INTEGER && tag == IPP_TAG_RANGE)
+              {
+               /*
+                * Convert integer values to rangeOfInteger values...
+                */
+
+               DEBUG_printf(("1ippReadIO: Converting %s attribute to "
+                             "rangeOfInteger.", attr->name));
+                ippSetValueTag(ipp, &attr, IPP_TAG_RANGE);
+              }
+            }
+           else if (value_tag != tag)
+           {
+             _cupsSetError(IPP_ERROR,
+                           _("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)));
+             ipp_buffer_release(buffer);
+             return (IPP_ERROR);
+            }
+
+           /*
+           * Finally, reallocate the attribute array as needed...
+           */
+
+           if ((value = ipp_set_value(ipp, &attr, attr->num_values)) == NULL)
+           {
+             ipp_buffer_release(buffer);
+             return (IPP_ERROR);
+           }
+         }
+         else if (tag == IPP_TAG_MEMBERNAME)
+         {
+          /*
+           * Name must be length 0!
+           */
+
+           if (n)
+           {
+             _cupsSetError(IPP_ERROR, _("IPP member name is not empty."), 1);
+             DEBUG_puts("1ippReadIO: member name not empty.");
+             ipp_buffer_release(buffer);
+             return (IPP_ERROR);
+           }
+
+            if (ipp->current)
+             ipp->prev = ipp->current;
+
+           attr = ipp->current = ipp_add_attr(ipp, NULL, ipp->curtag, IPP_TAG_ZERO, 1);
+
+           DEBUG_printf(("2ippReadIO: membername, ipp->current=%p, ipp->prev=%p",
+                         ipp->current, ipp->prev));
+
+           attr->num_values = 0;
+           value            = attr->values;
+         }
+         else if (tag != IPP_TAG_END_COLLECTION)
+         {
+          /*
+           * New attribute; read the name and add it...
+           */
+
+           if ((*cb)(src, buffer, n) < n)
+           {
+             DEBUG_puts("1ippReadIO: unable to read name.");
+             ipp_buffer_release(buffer);
+             return (IPP_ERROR);
+           }
+
+           buffer[n] = '\0';
+
+            if (ipp->current)
+             ipp->prev = ipp->current;
+
+           if ((attr = ipp->current = ipp_add_attr(ipp, (char *)buffer, ipp->curtag, tag,
+                                                   1)) == NULL)
+           {
+             _cupsSetHTTPError(HTTP_ERROR);
+             DEBUG_puts("1ippReadIO: unable to allocate attribute.");
+             ipp_buffer_release(buffer);
+             return (IPP_ERROR);
+           }
+
+           DEBUG_printf(("2ippReadIO: name=\"%s\", ipp->current=%p, "
+                         "ipp->prev=%p", buffer, ipp->current, ipp->prev));
+
+           attr->num_values = 0;
+           value            = attr->values;
+         }
+         else
+         {
+           attr  = NULL;
+           value = NULL;
+         }
+
+         if ((*cb)(src, buffer, 2) < 2)
+         {
+           DEBUG_puts("1ippReadIO: unable to read value length.");
+           ipp_buffer_release(buffer);
+           return (IPP_ERROR);
+         }
+
+         n = (buffer[0] << 8) | buffer[1];
+          DEBUG_printf(("2ippReadIO: value length=%d", n));
+
+         if (n >= IPP_BUF_SIZE)
+         {
+           _cupsSetError(IPP_ERROR,
+                         _("IPP value larger than 32767 bytes."), 1);
+           DEBUG_printf(("1ippReadIO: bad value length %d.", n));
            ipp_buffer_release(buffer);
            return (IPP_ERROR);
          }
 
+         switch (tag)
+         {
+           case IPP_TAG_INTEGER :
+           case IPP_TAG_ENUM :
+               if (n != 4)
+               {
+                 if (tag == IPP_TAG_INTEGER)
+                   _cupsSetError(IPP_ERROR,
+                                 _("IPP integer value not 4 bytes."), 1);
+                 else
+                   _cupsSetError(IPP_ERROR,
+                                 _("IPP enum value not 4 bytes."), 1);
+                 DEBUG_printf(("1ippReadIO: bad value length %d.", n));
+                 ipp_buffer_release(buffer);
+                 return (IPP_ERROR);
+               }
+
+               if ((*cb)(src, buffer, 4) < 4)
+               {
+                 DEBUG_puts("1ippReadIO: Unable to read integer value.");
+                 ipp_buffer_release(buffer);
+                 return (IPP_ERROR);
+               }
+
+               n = (((((buffer[0] << 8) | buffer[1]) << 8) | buffer[2]) << 8) |
+                   buffer[3];
+
+                if (attr->value_tag == IPP_TAG_RANGE)
+                  value->range.lower = value->range.upper = n;
+                else
+                 value->integer = n;
+               break;
+
+           case IPP_TAG_BOOLEAN :
+               if (n != 1)
+               {
+                 _cupsSetError(IPP_ERROR, _("IPP boolean value not 1 byte."),
+                               1);
+                 DEBUG_printf(("1ippReadIO: bad value length %d.", n));
+                 ipp_buffer_release(buffer);
+                 return (IPP_ERROR);
+               }
+
+               if ((*cb)(src, buffer, 1) < 1)
+               {
+                 DEBUG_puts("1ippReadIO: Unable to read boolean value.");
+                 ipp_buffer_release(buffer);
+                 return (IPP_ERROR);
+               }
+
+                value->boolean = buffer[0];
+               break;
+
+            case IPP_TAG_NOVALUE :
+           case IPP_TAG_NOTSETTABLE :
+           case IPP_TAG_DELETEATTR :
+           case IPP_TAG_ADMINDEFINE :
+              /*
+               * These value types are not supposed to have values, however
+               * some vendors (Brother) do not implement IPP correctly and so
+               * we need to map non-empty values to text...
+               */
+
+               if (attr->value_tag == tag)
+               {
+                 if (n == 0)
+                   break;
+
+                 attr->value_tag = IPP_TAG_TEXT;
+               }
+
+           case IPP_TAG_TEXT :
+           case IPP_TAG_NAME :
+           case IPP_TAG_KEYWORD :
+           case IPP_TAG_URI :
+           case IPP_TAG_URISCHEME :
+           case IPP_TAG_CHARSET :
+           case IPP_TAG_LANGUAGE :
+           case IPP_TAG_MIMETYPE :
+               if ((*cb)(src, buffer, n) < n)
+               {
+                 DEBUG_puts("1ippReadIO: unable to read string value.");
+                 ipp_buffer_release(buffer);
+                 return (IPP_ERROR);
+               }
+
+               buffer[n] = '\0';
+               value->string.text = _cupsStrAlloc((char *)buffer);
+               DEBUG_printf(("2ippReadIO: value=\"%s\"", value->string.text));
+               break;
+
+           case IPP_TAG_DATE :
+               if (n != 11)
+               {
+                 _cupsSetError(IPP_ERROR, _("IPP date value not 11 bytes."), 1);
+                 DEBUG_printf(("1ippReadIO: bad value length %d.", n));
+                 ipp_buffer_release(buffer);
+                 return (IPP_ERROR);
+               }
+
+               if ((*cb)(src, value->date, 11) < 11)
+               {
+                 DEBUG_puts("1ippReadIO: Unable to read date value.");
+                 ipp_buffer_release(buffer);
+                 return (IPP_ERROR);
+               }
+               break;
+
+           case IPP_TAG_RESOLUTION :
+               if (n != 9)
+               {
+                 _cupsSetError(IPP_ERROR,
+                               _("IPP resolution value not 9 bytes."), 1);
+                 DEBUG_printf(("1ippReadIO: bad value length %d.", n));
+                 ipp_buffer_release(buffer);
+                 return (IPP_ERROR);
+               }
+
+               if ((*cb)(src, buffer, 9) < 9)
+               {
+                 DEBUG_puts("1ippReadIO: Unable to read resolution value.");
+                 ipp_buffer_release(buffer);
+                 return (IPP_ERROR);
+               }
+
+                value->resolution.xres =
+                   (((((buffer[0] << 8) | buffer[1]) << 8) | buffer[2]) << 8) |
+                   buffer[3];
+                value->resolution.yres =
+                   (((((buffer[4] << 8) | buffer[5]) << 8) | buffer[6]) << 8) |
+                   buffer[7];
+                value->resolution.units =
+                   (ipp_res_t)buffer[8];
+               break;
+
+           case IPP_TAG_RANGE :
+               if (n != 8)
+               {
+                 _cupsSetError(IPP_ERROR,
+                               _("IPP rangeOfInteger value not 8 bytes."), 1);
+                 DEBUG_printf(("1ippReadIO: bad value length %d.", n));
+                 ipp_buffer_release(buffer);
+                 return (IPP_ERROR);
+               }
+
+               if ((*cb)(src, buffer, 8) < 8)
+               {
+                 DEBUG_puts("1ippReadIO: Unable to read range value.");
+                 ipp_buffer_release(buffer);
+                 return (IPP_ERROR);
+               }
+
+                value->range.lower =
+                   (((((buffer[0] << 8) | buffer[1]) << 8) | buffer[2]) << 8) |
+                   buffer[3];
+                value->range.upper =
+                   (((((buffer[4] << 8) | buffer[5]) << 8) | buffer[6]) << 8) |
+                   buffer[7];
+               break;
+
+           case IPP_TAG_TEXTLANG :
+           case IPP_TAG_NAMELANG :
+               if (n < 4)
+               {
+                 if (tag == IPP_TAG_TEXTLANG)
+                   _cupsSetError(IPP_ERROR,
+                                 _("IPP textWithLanguage value less than "
+                                   "minimum 4 bytes."), 1);
+                 else
+                   _cupsSetError(IPP_ERROR,
+                                 _("IPP nameWithLanguage value less than "
+                                   "minimum 4 bytes."), 1);
+                 DEBUG_printf(("1ippReadIO: bad value length %d.", n));
+                 ipp_buffer_release(buffer);
+                 return (IPP_ERROR);
+               }
+
+               if ((*cb)(src, buffer, n) < n)
+               {
+                 DEBUG_puts("1ippReadIO: Unable to read string w/language "
+                            "value.");
+                 ipp_buffer_release(buffer);
+                 return (IPP_ERROR);
+               }
+
+                bufptr = buffer;
+
+              /*
+               * text-with-language and name-with-language are composite
+               * values:
+               *
+               *    language-length
+               *    language
+               *    text-length
+               *    text
+               */
+
+               n = (bufptr[0] << 8) | bufptr[1];
+
+               if ((bufptr + 2 + n) >= (buffer + IPP_BUF_SIZE) ||
+                   n >= sizeof(string))
+               {
+                 _cupsSetError(IPP_ERROR,
+                               _("IPP language length overflows value."), 1);
+                 DEBUG_printf(("1ippReadIO: bad value length %d.", n));
+                 ipp_buffer_release(buffer);
+                 return (IPP_ERROR);
+               }
+
+               memcpy(string, bufptr + 2, n);
+               string[n] = '\0';
+
+               value->string.language = _cupsStrAlloc((char *)string);
+
+                bufptr += 2 + n;
+               n = (bufptr[0] << 8) | bufptr[1];
+
+               if ((bufptr + 2 + n) >= (buffer + IPP_BUF_SIZE))
+               {
+                 _cupsSetError(IPP_ERROR,
+                               _("IPP string length overflows value."), 1);
+                 DEBUG_printf(("1ippReadIO: bad value length %d.", n));
+                 ipp_buffer_release(buffer);
+                 return (IPP_ERROR);
+               }
+
+               bufptr[2 + n] = '\0';
+                value->string.text = _cupsStrAlloc((char *)bufptr + 2);
+               break;
+
+            case IPP_TAG_BEGIN_COLLECTION :
+              /*
+               * Oh, boy, here comes a collection value, so read it...
+               */
+
+                value->collection = ippNew();
+
+                if (n > 0)
+               {
+                 _cupsSetError(IPP_ERROR,
+                               _("IPP begCollection value not 0 bytes."), 1);
+                 DEBUG_puts("1ippReadIO: begCollection tag with value length "
+                            "> 0.");
+                 ipp_buffer_release(buffer);
+                 return (IPP_ERROR);
+               }
+
+               if (ippReadIO(src, cb, 1, ipp, value->collection) == IPP_ERROR)
+               {
+                 DEBUG_puts("1ippReadIO: Unable to read collection value.");
+                 ipp_buffer_release(buffer);
+                 return (IPP_ERROR);
+               }
+                break;
+
+            case IPP_TAG_END_COLLECTION :
+               ipp_buffer_release(buffer);
+
+                if (n > 0)
+               {
+                 _cupsSetError(IPP_ERROR,
+                               _("IPP endCollection value not 0 bytes."), 1);
+                 DEBUG_puts("1ippReadIO: endCollection tag with value length "
+                            "> 0.");
+                 return (IPP_ERROR);
+               }
+
+               DEBUG_puts("1ippReadIO: endCollection tag...");
+               return (ipp->state = IPP_DATA);
+
+            case IPP_TAG_MEMBERNAME :
+              /*
+               * The value the name of the member in the collection, which
+               * we need to carry over...
+               */
+
+               if ((*cb)(src, buffer, n) < n)
+               {
+                 DEBUG_puts("1ippReadIO: Unable to read member name value.");
+                 ipp_buffer_release(buffer);
+                 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
+               * empty value...
+               */
+
+                attr->num_values --;
+
+               DEBUG_printf(("2ippReadIO: member name=\"%s\"", attr->name));
+               break;
+
+            default : /* Other unsupported values */
+                value->unknown.length = n;
+               if (n > 0)
+               {
+                 if ((value->unknown.data = malloc(n)) == NULL)
+                 {
+                   _cupsSetHTTPError(HTTP_ERROR);
+                   DEBUG_puts("1ippReadIO: Unable to allocate value");
+                   ipp_buffer_release(buffer);
+                   return (IPP_ERROR);
+                 }
+
+                 if ((*cb)(src, value->unknown.data, n) < n)
+                 {
+                   DEBUG_puts("1ippReadIO: Unable to read unsupported value.");
+                   ipp_buffer_release(buffer);
+                   return (IPP_ERROR);
+                 }
+               }
+               else
+                 value->unknown.data = NULL;
+               break;
+         }
+
+          attr->num_values ++;
+
         /*
-          * Then copy the request header over...
+          * If blocking is disabled, stop here...
          */
 
-          ipp->request.any.version[0]  = buffer[0];
-          ipp->request.any.version[1]  = buffer[1];
-          ipp->request.any.op_status   = (buffer[2] << 8) | buffer[3];
-          ipp->request.any.request_id  = (((((buffer[4] << 8) | buffer[5]) << 8) |
-                                        buffer[6]) << 8) | buffer[7];
+          if (!blocking)
+           break;
+       }
+        break;
 
-          DEBUG_printf(("2ippReadIO: version=%d.%d", buffer[0], buffer[1]));
-         DEBUG_printf(("2ippReadIO: op_status=%04x",
-                       ipp->request.any.op_status));
-         DEBUG_printf(("2ippReadIO: request_id=%d",
-                       ipp->request.any.request_id));
-        }
+    case IPP_DATA :
+        break;
 
-        ipp->state   = IPP_ATTRIBUTE;
-       ipp->current = NULL;
-       ipp->curtag  = IPP_TAG_ZERO;
-       ipp->prev    = ipp->last;
+    default :
+        break; /* anti-compiler-warning-code */
+  }
 
-       /*
-        * If blocking is disabled, stop here...
-       */
+  DEBUG_printf(("1ippReadIO: returning ipp->state=%d.", ipp->state));
+  ipp_buffer_release(buffer);
 
-        if (!blocking)
-         break;
+  return (ipp->state);
+}
 
-    case IPP_ATTRIBUTE :
-        for (;;)
-       {
-         if ((*cb)(src, buffer, 1) < 1)
-         {
-           DEBUG_puts("1ippReadIO: Callback returned EOF/error");
-           ipp_buffer_release(buffer);
-           return (IPP_ERROR);
-         }
 
-         DEBUG_printf(("2ippReadIO: ipp->current=%p, ipp->prev=%p",
-                       ipp->current, ipp->prev));
+/*
+ * 'ippSetBoolean()' - Set a boolean value in an attribute.
+ *
+ * The @code ipp@ parameter refers to the IPP message containing the attribute that was
+ * previously created using the @link ippNew@ or @link ippNewRequest@ 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.6@
+ */
 
-        /*
-         * Read this attribute...
-         */
+int                                    /* O  - 1 on success, 0 on failure */
+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 */
+{
+  _ipp_value_t *value;                 /* Current value */
 
-          tag = (ipp_tag_t)buffer[0];
 
-         if (tag == IPP_TAG_END)
-         {
-          /*
-           * No more attributes left...
-           */
+ /*
+  * Range check input...
+  */
 
-            DEBUG_puts("2ippReadIO: IPP_TAG_END.");
+  if (!ipp || !attr || !*attr || (*attr)->value_tag != IPP_TAG_BOOLEAN ||
+      element < 0 || element > (*attr)->num_values)
+    return (0);
 
-           ipp->state = IPP_DATA;
-           break;
-         }
-          else if (tag < IPP_TAG_UNSUPPORTED_VALUE)
-         {
-          /*
-           * Group tag...  Set the current group and continue...
-           */
+ /*
+  * Set the value and return...
+  */
 
-            if (ipp->curtag == tag)
-             ipp->prev = ippAddSeparator(ipp);
-            else if (ipp->current)
-             ipp->prev = ipp->current;
+  if ((value = ipp_set_value(ipp, attr, element)) != NULL)
+    value->boolean = boolvalue;
 
-           ipp->curtag  = tag;
-           ipp->current = NULL;
-           DEBUG_printf(("2ippReadIO: group tag=%x(%s), ipp->prev=%p", tag,
-                         ippTagString(tag), ipp->prev));
-           continue;
-         }
+  return (value != NULL);
+}
 
-          DEBUG_printf(("2ippReadIO: value tag=%x(%s)", tag,
-                       ippTagString(tag)));
 
-         /*
-         * Get the name...
-         */
+/*
+ * 'ippSetCollection()' - Set a collection value in an attribute.
+ *
+ * The @code ipp@ parameter refers to the IPP message containing the attribute that was
+ * previously created using the @link ippNew@ or @link ippNewRequest@ 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.6@
+ */
 
-          if ((*cb)(src, buffer, 2) < 2)
-         {
-           DEBUG_puts("1ippReadIO: unable to read name length.");
-           ipp_buffer_release(buffer);
-           return (IPP_ERROR);
-         }
+int                                    /* O  - 1 on success, 0 on failure */
+ippSetCollection(
+    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 */
+{
+  _ipp_value_t *value;                 /* Current value */
 
-          n = (buffer[0] << 8) | buffer[1];
 
-          if (n >= IPP_BUF_SIZE)
-         {
-           _cupsSetError(IPP_ERROR, _("IPP name larger than 32767 bytes."), 1);
-           DEBUG_printf(("1ippReadIO: bad name length %d.", n));
-           ipp_buffer_release(buffer);
-           return (IPP_ERROR);
-         }
+ /*
+  * Range check input...
+  */
 
-          DEBUG_printf(("2ippReadIO: name length=%d", n));
+  if (!ipp || !attr || !*attr || (*attr)->value_tag != IPP_TAG_BEGIN_COLLECTION ||
+      element < 0 || element > (*attr)->num_values || !colvalue)
+    return (0);
 
-          if (n == 0 && tag != IPP_TAG_MEMBERNAME &&
-             tag != IPP_TAG_END_COLLECTION)
-         {
-          /*
-           * More values for current attribute...
-           */
+ /*
+  * Set the value and return...
+  */
 
-            if (ipp->current == NULL)
-           {
-             _cupsSetError(IPP_ERROR, _("IPP attribute has no name."), 1);
-             DEBUG_puts("1ippReadIO: Attribute without name and no current.");
-             ipp_buffer_release(buffer);
-             return (IPP_ERROR);
-           }
+  if ((value = ipp_set_value(ipp, attr, element)) != NULL)
+  {
+    if (value->collection)
+      ippDelete(value->collection);
+    
+    value->collection = colvalue;
+    colvalue->use ++;
+  }
 
-            attr      = ipp->current;
-           value_tag = (ipp_tag_t)(attr->value_tag & IPP_TAG_MASK);
+  return (value != NULL);
+}
 
-          /*
-           * Make sure we aren't adding a new value of a different
-           * type...
-           */
 
-           if (value_tag == IPP_TAG_ZERO)
-           {
-            /*
-             * Setting the value of a collection member...
-             */
+/*
+ * 'ippSetGroupTag()' - Set the group tag of an attribute.
+ *
+ * The @code ipp@ parameter refers to the IPP message containing the attribute that was
+ * previously created using the @link ippNew@ or @link ippNewRequest@ functions.
+ *
+ * The @code attr@ parameter may be modified as a result of setting the value.
+ *
+ * The @code group@ parameter specifies the IPP attribute group tag: none
+ * (@code IPP_TAG_ZERO@, for member attributes), document (@code IPP_TAG_DOCUMENT@),
+ * event notification (@code IPP_TAG_EVENT_NOTIFICATION@), operation
+ * (@code IPP_TAG_OPERATION@), printer (@code IPP_TAG_PRINTER@), subscription
+ * (@code IPP_TAG_SUBSCRIPTION@), or unsupported (@code IPP_TAG_UNSUPPORTED_GROUP@).
+ *
+ * @since CUPS 1.6@
+ */
 
-             attr->value_tag = tag;
-           }
-           else if (value_tag == IPP_TAG_TEXTLANG ||
-                    value_tag == IPP_TAG_NAMELANG ||
-                    (value_tag >= IPP_TAG_TEXT &&
-                     value_tag <= IPP_TAG_MIMETYPE))
-            {
-            /*
-             * String values can sometimes come across in different
-             * forms; accept sets of differing values...
-             */
+int                                    /* O  - 1 on success, 0 on failure */
+ippSetGroupTag(
+    ipp_t           *ipp,              /* I  - IPP message */
+    ipp_attribute_t **attr,            /* IO - Attribute */
+    ipp_tag_t       group_tag)         /* I  - Group tag */
+{
+ /*
+  * Range check input - group tag must be 0x01 to 0x0F, per RFC 2911...
+  */
 
-             if (tag != IPP_TAG_TEXTLANG && tag != IPP_TAG_NAMELANG &&
-                 (tag < IPP_TAG_TEXT || tag > IPP_TAG_MIMETYPE) &&
-                 tag != IPP_TAG_NOVALUE)
-             {
-               _cupsSetError(IPP_ERROR,
-                             _("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)));
-               ipp_buffer_release(buffer);
-               return (IPP_ERROR);
-             }
-            }
-           else if (value_tag == IPP_TAG_INTEGER ||
-                    value_tag == IPP_TAG_RANGE)
-            {
-            /*
-             * Integer and rangeOfInteger values can sometimes be mixed; accept
-             * sets of differing values...
-             */
+  if (!ipp || !attr || group_tag < IPP_TAG_ZERO || group_tag == IPP_TAG_END ||
+      group_tag >= IPP_TAG_UNSUPPORTED_VALUE)
+    return (0);
 
-             if (tag != IPP_TAG_INTEGER && tag != IPP_TAG_RANGE)
-             {
-               _cupsSetError(IPP_ERROR,
-                             _("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)));
-               ipp_buffer_release(buffer);
-               return (IPP_ERROR);
-             }
+ /*
+  * Set the group tag and return...
+  */
 
-              if (value_tag == IPP_TAG_INTEGER && tag == IPP_TAG_RANGE)
-              {
-               /*
-                * Convert integer values to rangeOfInteger values...
-                */
+  (*attr)->group_tag = group_tag;
 
-               int i;                  /* Looping var */
+  return (1);
+}
+  
 
-               DEBUG_printf(("1ippReadIO: Converting %s attribute to "
-                             "rangeOfInteger.", attr->name));
+/*
+ * 'ippSetInteger()' - Set an integer or enum value in an attribute.
+ *
+ * The @code ipp@ parameter refers to the IPP message containing the attribute that was
+ * previously created using the @link ippNew@ or @link ippNewRequest@ 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.6@
+ */
 
-               attr->value_tag = IPP_TAG_RANGE;
+int                                    /* O  - 1 on success, 0 on failure */
+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 */
+{
+  _ipp_value_t *value;                 /* Current value */
 
-                for (i = attr->num_values, value = attr->values;
-                     i > 0;
-                     i --, value ++)
-                {
-                  n                  = value->integer;
-                  value->range.lower = value->range.upper = n;
-                }
-              }
-            }
-           else if (value_tag != tag)
-           {
-             _cupsSetError(IPP_ERROR,
-                           _("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)));
-             ipp_buffer_release(buffer);
-             return (IPP_ERROR);
-            }
 
-           /*
-           * Finally, reallocate the attribute array as needed...
-           */
+ /*
+  * Range check input...
+  */
+
+  if (!ipp || !attr || !*attr ||
+      ((*attr)->value_tag != IPP_TAG_INTEGER && (*attr)->value_tag != IPP_TAG_ENUM) ||
+      element < 0 || element > (*attr)->num_values)
+    return (0);
+
+ /*
+  * Set the value and return...
+  */
+
+  if ((value = ipp_set_value(ipp, attr, element)) != NULL)
+    value->integer = intvalue;
+
+  return (value != NULL);
+}
+
+
+/*
+ * 'ippSetName()' - Set the name of an attribute.
+ *
+ * The @code ipp@ parameter refers to the IPP message containing the attribute that was
+ * previously created using the @link ippNew@ or @link ippNewRequest@ functions.
+ *
+ * The @code attr@ parameter may be modified as a result of setting the value.
+ *
+ * @since CUPS 1.6@
+ */
+
+int                                    /* O  - 1 on success, 0 on failure */
+ippSetName(ipp_t           *ipp,       /* I  - IPP message */
+          ipp_attribute_t **attr,      /* IO - IPP attribute */
+          const char      *name)       /* I  - Attribute name */
+{
+  char *temp;                          /* Temporary name value */
+
 
-           if (attr->num_values == 1 ||
-               (attr->num_values > 0 &&
-                (attr->num_values & (IPP_MAX_VALUES - 1)) == 0))
-           {
-             ipp_attribute_t   *temp;  /* Pointer to new buffer */
+ /*
+  * Range check input...
+  */
 
-              DEBUG_printf(("2ippReadIO: reallocating for up to %d values...",
-                           attr->num_values + IPP_MAX_VALUES));
+  if (!ipp || !attr || !*attr)
+    return (0);
 
            /*
-             * Reallocate memory...
-             */
+ /*
+  * Set the value and return...
+  */
 
-              if ((temp = realloc(attr, sizeof(ipp_attribute_t) +
-                                       (attr->num_values + IPP_MAX_VALUES - 1) *
-                                       sizeof(ipp_value_t))) == NULL)
-             {
-               _cupsSetHTTPError(HTTP_ERROR);
-               DEBUG_puts("1ippReadIO: Unable to resize attribute");
-               ipp_buffer_release(buffer);
-               return (IPP_ERROR);
-             }
+  if ((temp = _cupsStrAlloc(name)) != NULL)
+  {
+    if ((*attr)->name)
+      _cupsStrFree((*attr)->name);
+    
+    (*attr)->name = temp;
+  }
 
-              if (temp != attr)
-             {
-               /*
-               * Reset pointers in the list...
-               */
+  return (temp != NULL);
+}
 
-               if (ipp->prev)
-                 ipp->prev->next = temp;
-               else
-                 ipp->attrs = temp;
 
-               attr = ipp->current = ipp->last = temp;
-             }
-           }
-         }
-         else if (tag == IPP_TAG_MEMBERNAME)
-         {
-          /*
-           * Name must be length 0!
-           */
+/*
+ * 'ippSetOperation()' - Set the operation ID in an IPP request message.
+ *
+ * The @code ipp@ parameter refers to an IPP message previously created using the
+ * @link ippNew@ or @link ippNewRequest@ functions.
+ *
+ * @since CUPS 1.6@
+ */
 
-           if (n)
-           {
-             _cupsSetError(IPP_ERROR, _("IPP member name is not empty."), 1);
-             DEBUG_puts("1ippReadIO: member name not empty.");
-             ipp_buffer_release(buffer);
-             return (IPP_ERROR);
-           }
+int                                    /* O - 1 on success, 0 on failure */
+ippSetOperation(ipp_t    *ipp,         /* I - IPP request message */
+                ipp_op_t op)           /* I - Operation ID */
+{
+ /*
+  * Range check input...
+  */
 
-            if (ipp->current)
-             ipp->prev = ipp->current;
+  if (!ipp)
+    return (0);
 
-           attr = ipp->current = _ippAddAttr(ipp, 1);
+ /*
+  * Set the operation and return...
+  */
 
-           DEBUG_printf(("2ippReadIO: membername, ipp->current=%p, "
-                         "ipp->prev=%p", ipp->current, ipp->prev));
+  ipp->request.op.operation_id = op;
 
-           attr->group_tag  = ipp->curtag;
-           attr->value_tag  = IPP_TAG_ZERO;
-           attr->num_values = 0;
-         }
-         else if (tag != IPP_TAG_END_COLLECTION)
-         {
-          /*
-           * New attribute; read the name and add it...
-           */
+  return (1);
+}
 
-           if ((*cb)(src, buffer, n) < n)
-           {
-             DEBUG_puts("1ippReadIO: unable to read name.");
-             ipp_buffer_release(buffer);
-             return (IPP_ERROR);
-           }
 
-           buffer[n] = '\0';
+/*
+ * 'ippSetRange()' - Set a rangeOfInteger value in an attribute.
+ *
+ * The @code ipp@ parameter refers to the IPP message containing the attribute that was
+ * previously created using the @link ippNew@ or @link ippNewRequest@ 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.6@
+ */
 
-            if (ipp->current)
-             ipp->prev = ipp->current;
+int                                    /* O  - 1 on success, 0 on failure */
+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 */
+           int             uppervalue) /* I  - Upper bound for range */
+{
+  _ipp_value_t *value;                 /* Current value */
 
-           if ((attr = ipp->current = _ippAddAttr(ipp, 1)) == NULL)
-           {
-             _cupsSetHTTPError(HTTP_ERROR);
-             DEBUG_puts("1ippReadIO: unable to allocate attribute.");
-             ipp_buffer_release(buffer);
-             return (IPP_ERROR);
-           }
 
-           DEBUG_printf(("2ippReadIO: name=\"%s\", ipp->current=%p, "
-                         "ipp->prev=%p", buffer, ipp->current, ipp->prev));
+ /*
+  * Range check input...
+  */
 
-           attr->group_tag  = ipp->curtag;
-           attr->value_tag  = tag;
-           attr->name       = _cupsStrAlloc((char *)buffer);
-           attr->num_values = 0;
-         }
-         else
-           attr = NULL;
+  if (!ipp || !attr || !*attr || (*attr)->value_tag != IPP_TAG_RANGE ||
+      element < 0 || element > (*attr)->num_values || lowervalue > uppervalue)
+    return (0);
 
-          if (tag != IPP_TAG_END_COLLECTION)
-            value = attr->values + attr->num_values;
-         else
-           value = NULL;
+ /*
+  * Set the value and return...
+  */
 
-         if ((*cb)(src, buffer, 2) < 2)
-         {
-           DEBUG_puts("1ippReadIO: unable to read value length.");
-           ipp_buffer_release(buffer);
-           return (IPP_ERROR);
-         }
+  if ((value = ipp_set_value(ipp, attr, element)) != NULL)
+  {
+    value->range.lower = lowervalue;
+    value->range.upper = uppervalue;
+  }
 
-         n = (buffer[0] << 8) | buffer[1];
-          DEBUG_printf(("2ippReadIO: value length=%d", n));
+  return (value != NULL);
+}
 
-         if (n >= IPP_BUF_SIZE)
-         {
-           _cupsSetError(IPP_ERROR,
-                         _("IPP value larger than 32767 bytes."), 1);
-           DEBUG_printf(("1ippReadIO: bad value length %d.", n));
-           ipp_buffer_release(buffer);
-           return (IPP_ERROR);
-         }
 
-         switch (tag)
-         {
-           case IPP_TAG_INTEGER :
-           case IPP_TAG_ENUM :
-               if (n != 4)
-               {
-                 if (tag == IPP_TAG_INTEGER)
-                   _cupsSetError(IPP_ERROR,
-                                 _("IPP integer value not 4 bytes."), 1);
-                 else
-                   _cupsSetError(IPP_ERROR,
-                                 _("IPP enum value not 4 bytes."), 1);
-                 DEBUG_printf(("1ippReadIO: bad value length %d.", n));
-                 ipp_buffer_release(buffer);
-                 return (IPP_ERROR);
-               }
+/*
+ * 'ippSetRequestId()' - Set the request ID in an IPP message.
+ *
+ * The @code ipp@ parameter refers to an IPP message previously created using the
+ * @link ippNew@ or @link ippNewRequest@ functions.
+ *
+ * The @code request_id@ parameter must be greater than 0.
+ *
+ * @since CUPS 1.6@
+ */
 
-               if ((*cb)(src, buffer, 4) < 4)
-               {
-                 DEBUG_puts("1ippReadIO: Unable to read integer value.");
-                 ipp_buffer_release(buffer);
-                 return (IPP_ERROR);
-               }
+int                                    /* O - 1 on success, 0 on failure */
+ippSetRequestId(ipp_t *ipp,            /* I - IPP message */
+                int   request_id)      /* I - Request ID */
+{
+ /*
+  * Range check input; not checking request_id values since ipptool wants to send
+  * invalid values for conformance testing and a bad request_id does not affect the
+  * encoding of a message...
+  */
 
-               n = (((((buffer[0] << 8) | buffer[1]) << 8) | buffer[2]) << 8) |
-                   buffer[3];
+  if (!ipp)
+    return (0);
 
-                if (attr->value_tag == IPP_TAG_RANGE)
-                  value->range.lower = value->range.upper = n;
-                else
-                 value->integer = n;
-               break;
+ /*
+  * Set the request ID and return...
+  */
 
-           case IPP_TAG_BOOLEAN :
-               if (n != 1)
-               {
-                 _cupsSetError(IPP_ERROR, _("IPP boolean value not 1 byte."),
-                               1);
-                 DEBUG_printf(("1ippReadIO: bad value length %d.", n));
-                 ipp_buffer_release(buffer);
-                 return (IPP_ERROR);
-               }
+  ipp->request.any.request_id = request_id;
 
-               if ((*cb)(src, buffer, 1) < 1)
-               {
-                 DEBUG_puts("1ippReadIO: Unable to read boolean value.");
-                 ipp_buffer_release(buffer);
-                 return (IPP_ERROR);
-               }
+  return (1);
+}
 
-                value->boolean = buffer[0];
-               break;
 
-            case IPP_TAG_NOVALUE :
-           case IPP_TAG_NOTSETTABLE :
-           case IPP_TAG_DELETEATTR :
-           case IPP_TAG_ADMINDEFINE :
-              /*
-               * These value types are not supposed to have values, however
-               * some vendors (Brother) do not implement IPP correctly and so
-               * we need to map non-empty values to text...
-               */
+/*
+ * 'ippSetResolution()' - Set a resolution value in an attribute.
+ *
+ * The @code ipp@ parameter refers to the IPP message containing the attribute that was
+ * previously created using the @link ippNew@ or @link ippNewRequest@ 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.6@
+ */
 
-               if (attr->value_tag == tag)
-               {
-                 if (n == 0)
-                   break;
+int                                    /* O  - 1 on success, 0 on failure */
+ippSetResolution(
+    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 */
+    int             xresvalue,         /* I  - Horizontal/cross feed resolution */
+    int             yresvalue)         /* I  - Vertical/feed resolution */
+{
+  _ipp_value_t *value;                 /* Current value */
 
-                 attr->value_tag = IPP_TAG_TEXT;
-               }
 
-           case IPP_TAG_TEXT :
-           case IPP_TAG_NAME :
-           case IPP_TAG_KEYWORD :
-           case IPP_TAG_URI :
-           case IPP_TAG_URISCHEME :
-           case IPP_TAG_CHARSET :
-           case IPP_TAG_LANGUAGE :
-           case IPP_TAG_MIMETYPE :
-               if ((*cb)(src, buffer, n) < n)
-               {
-                 DEBUG_puts("1ippReadIO: unable to read string value.");
-                 ipp_buffer_release(buffer);
-                 return (IPP_ERROR);
-               }
+ /*
+  * Range check input...
+  */
 
-               buffer[n] = '\0';
-               value->string.text = _cupsStrAlloc((char *)buffer);
-               DEBUG_printf(("2ippReadIO: value=\"%s\"", value->string.text));
-               break;
+  if (!ipp || !attr || !*attr || (*attr)->value_tag != IPP_TAG_RESOLUTION ||
+      element < 0 || element > (*attr)->num_values || xresvalue <= 0 || yresvalue <= 0 ||
+      unitsvalue < IPP_RES_PER_INCH || unitsvalue > IPP_RES_PER_CM)
+    return (0);
 
-           case IPP_TAG_DATE :
-               if (n != 11)
-               {
-                 _cupsSetError(IPP_ERROR, _("IPP date value not 11 bytes."),
-                               1);
-                 DEBUG_printf(("1ippReadIO: bad value length %d.", n));
-                 ipp_buffer_release(buffer);
-                 return (IPP_ERROR);
-               }
+ /*
+  * Set the value and return...
+  */
 
-               if ((*cb)(src, value->date, 11) < 11)
-               {
-                 DEBUG_puts("1ippReadIO: Unable to read date value.");
-                 ipp_buffer_release(buffer);
-                 return (IPP_ERROR);
-               }
-               break;
+  if ((value = ipp_set_value(ipp, attr, element)) != NULL)
+  {
+    value->resolution.units = unitsvalue;
+    value->resolution.xres  = xresvalue;
+    value->resolution.yres  = yresvalue;
+  }
 
-           case IPP_TAG_RESOLUTION :
-               if (n != 9)
-               {
-                 _cupsSetError(IPP_ERROR,
-                               _("IPP resolution value not 9 bytes."), 1);
-                 DEBUG_printf(("1ippReadIO: bad value length %d.", n));
-                 ipp_buffer_release(buffer);
-                 return (IPP_ERROR);
-               }
+  return (value != NULL);
+}
 
-               if ((*cb)(src, buffer, 9) < 9)
-               {
-                 DEBUG_puts("1ippReadIO: Unable to read resolution value.");
-                 ipp_buffer_release(buffer);
-                 return (IPP_ERROR);
-               }
 
-                value->resolution.xres =
-                   (((((buffer[0] << 8) | buffer[1]) << 8) | buffer[2]) << 8) |
-                   buffer[3];
-                value->resolution.yres =
-                   (((((buffer[4] << 8) | buffer[5]) << 8) | buffer[6]) << 8) |
-                   buffer[7];
-                value->resolution.units =
-                   (ipp_res_t)buffer[8];
-               break;
+/*
+ * 'ippSetStatusCode()' - Set the status code in an IPP response or event message.
+ *
+ * The @code ipp@ parameter refers to an IPP message previously created using the
+ * @link ippNew@ or @link ippNewRequest@ functions.
+ *
+ * @since CUPS 1.6@
+ */
+
+int                                    /* O - 1 on success, 0 on failure */
+ippSetStatusCode(ipp_t        *ipp,    /* I - IPP response or event message */
+                 ipp_status_t status)  /* I - Status code */
+{
+ /*
+  * Range check input...
+  */
+
+  if (!ipp)
+    return (0);
 
-           case IPP_TAG_RANGE :
-               if (n != 8)
-               {
-                 _cupsSetError(IPP_ERROR,
-                               _("IPP rangeOfInteger value not 8 bytes."), 1);
-                 DEBUG_printf(("1ippReadIO: bad value length %d.", n));
-                 ipp_buffer_release(buffer);
-                 return (IPP_ERROR);
-               }
+ /*
+  * Set the status code and return...
+  */
 
-               if ((*cb)(src, buffer, 8) < 8)
-               {
-                 DEBUG_puts("1ippReadIO: Unable to read range value.");
-                 ipp_buffer_release(buffer);
-                 return (IPP_ERROR);
-               }
+  ipp->request.status.status_code = status;
 
-                value->range.lower =
-                   (((((buffer[0] << 8) | buffer[1]) << 8) | buffer[2]) << 8) |
-                   buffer[3];
-                value->range.upper =
-                   (((((buffer[4] << 8) | buffer[5]) << 8) | buffer[6]) << 8) |
-                   buffer[7];
-               break;
+  return (1);
 
-           case IPP_TAG_TEXTLANG :
-           case IPP_TAG_NAMELANG :
-               if (n < 4)
-               {
-                 if (tag == IPP_TAG_TEXTLANG)
-                   _cupsSetError(IPP_ERROR,
-                                 _("IPP textWithLanguage value less than "
-                                   "minimum 4 bytes."), 1);
-                 else
-                   _cupsSetError(IPP_ERROR,
-                                 _("IPP nameWithLanguage value less than "
-                                   "minimum 4 bytes."), 1);
-                 DEBUG_printf(("1ippReadIO: bad value length %d.", n));
-                 ipp_buffer_release(buffer);
-                 return (IPP_ERROR);
-               }
+}
 
-               if ((*cb)(src, buffer, n) < n)
-               {
-                 DEBUG_puts("1ippReadIO: Unable to read string w/language "
-                            "value.");
-                 ipp_buffer_release(buffer);
-                 return (IPP_ERROR);
-               }
 
-                bufptr = buffer;
+/*
+ * 'ippSetString()' - Set a string value in an attribute.
+ *
+ * The @code ipp@ parameter refers to the IPP message containing the attribute that was
+ * previously created using the @link ippNew@ or @link ippNewRequest@ 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.6@
+ */
 
-              /*
-               * text-with-language and name-with-language are composite
-               * values:
-               *
-               *    language-length
-               *    language
-               *    text-length
-               *    text
-               *
-               * The "charset" field name is an unfortunate typo from
-               * CUPS 1.0...
-               */
+int                                    /* O  - 1 on success, 0 on failure */
+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 */
+{
+  char         *temp;                  /* Temporary string */
+  _ipp_value_t *value;                 /* Current value */
 
-               n = (bufptr[0] << 8) | bufptr[1];
 
-               if ((bufptr + 2 + n) >= (buffer + IPP_BUF_SIZE) ||
-                   n >= sizeof(string))
-               {
-                 _cupsSetError(IPP_ERROR,
-                               _("IPP language length overflows value."), 1);
-                 DEBUG_printf(("1ippReadIO: bad value length %d.", n));
-                 ipp_buffer_release(buffer);
-                 return (IPP_ERROR);
-               }
+ /*
+  * Range check input...
+  */
 
-               memcpy(string, bufptr + 2, n);
-               string[n] = '\0';
+  if (!ipp || !attr || !*attr || (*attr)->value_tag != IPP_TAG_INTEGER ||
+      element < 0 || element > (*attr)->num_values || !strvalue)
+    return (0);
 
-               value->string.charset = _cupsStrAlloc((char *)string);
+ /*
+  * Set the value and return...
+  */
 
-                bufptr += 2 + n;
-               n = (bufptr[0] << 8) | bufptr[1];
+  if ((value = ipp_set_value(ipp, attr, element)) != NULL)
+  {
+    if (element > 0)
+      value->string.language = (*attr)->values[0].string.language;
 
-               if ((bufptr + 2 + n) >= (buffer + IPP_BUF_SIZE))
-               {
-                 _cupsSetError(IPP_ERROR,
-                               _("IPP string length overflows value."), 1);
-                 DEBUG_printf(("1ippReadIO: bad value length %d.", n));
-                 ipp_buffer_release(buffer);
-                 return (IPP_ERROR);
-               }
+    if ((int)((*attr)->value_tag) & IPP_TAG_COPY)
+      value->string.text = (char *)strvalue;
+    else if ((temp = _cupsStrAlloc(strvalue)) != NULL)
+    {
+      if (value->string.text)
+        _cupsStrFree(value->string.text);
 
-               bufptr[2 + n] = '\0';
-                value->string.text = _cupsStrAlloc((char *)bufptr + 2);
-               break;
+      value->string.text = temp;
+    }
+    else
+      return (0);
+  }
 
-            case IPP_TAG_BEGIN_COLLECTION :
-              /*
-               * Oh, boy, here comes a collection value, so read it...
-               */
+  return (value != NULL);
+}
 
-                value->collection = ippNew();
 
-                if (n > 0)
-               {
-                 _cupsSetError(IPP_ERROR,
-                               _("IPP begCollection value not 0 bytes."), 1);
-                 DEBUG_puts("1ippReadIO: begCollection tag with value length "
-                            "> 0.");
-                 ipp_buffer_release(buffer);
-                 return (IPP_ERROR);
-               }
+/*
+ * 'ippSetValueTag()' - Set the value tag of an attribute.
+ *
+ * The @code ipp@ parameter refers to the IPP message containing the attribute that was
+ * previously created using the @link ippNew@ or @link ippNewRequest@ functions.
+ *
+ * The @code attr@ parameter may be modified as a result of setting the value.
+ *
+ * Integer (@code IPP_TAG_INTEGER@) values can be promoted to rangeOfInteger
+ * (@code IPP_TAG_RANGE@) values, the various string tags can be promoted to name
+ * (@code IPP_TAG_NAME@) or nameWithLanguage (@code IPP_TAG_NAMELANG@) values, text
+ * (@code IPP_TAG_TEXT@) values can be promoted to textWithLanguage
+ * (@code IPP_TAG_TEXTLANG@) values, and all values can be demoted to the various
+ * out-of-band value tags such as no-value (@code IPP_TAG_NOVALUE@). All other changes
+ * will be rejected.
+ *
+ * Promoting a string attribute to nameWithLanguage or textWithLanguage adds the language
+ * code in the "attributes-natural-language" attribute or, if not present, the language
+ * code for the current locale.
+ *
+ * @since CUPS 1.6@
+ */
 
-               if (ippReadIO(src, cb, 1, ipp, value->collection) == IPP_ERROR)
-               {
-                 DEBUG_puts("1ippReadIO: Unable to read collection value.");
-                 ipp_buffer_release(buffer);
-                 return (IPP_ERROR);
-               }
-                break;
+int                                    /* O  - 1 on success, 0 on failure */
+ippSetValueTag(
+    ipp_t          *ipp,               /* I  - IPP message */
+    ipp_attribute_t **attr,            /* IO - IPP attribute */
+    ipp_tag_t       value_tag)         /* I  - Value tag */
+{
+  int          i;                      /* Looping var */
+  _ipp_value_t *value;                 /* Current value */
+  int          integer;                /* Current integer value */
+  cups_lang_t  *language;              /* Current language */
+  char         code[32];               /* Language code */
+  ipp_tag_t    temp_tag;               /* Temporary value tag */
 
-            case IPP_TAG_END_COLLECTION :
-               ipp_buffer_release(buffer);
 
-                if (n > 0)
-               {
-                 _cupsSetError(IPP_ERROR,
-                               _("IPP endCollection value not 0 bytes."), 1);
-                 DEBUG_puts("1ippReadIO: endCollection tag with value length "
-                            "> 0.");
-                 return (IPP_ERROR);
-               }
+ /*
+  * Range check input...
+  */
 
-               DEBUG_puts("1ippReadIO: endCollection tag...");
-               return (ipp->state = IPP_DATA);
+  if (!ipp || !attr)
+    return (0);
 
-            case IPP_TAG_MEMBERNAME :
-              /*
-               * The value the name of the member in the collection, which
-               * we need to carry over...
-               */
+ /*
+  * If there is no change, return immediately...
+  */
 
-               if ((*cb)(src, buffer, n) < n)
-               {
-                 DEBUG_puts("1ippReadIO: Unable to read member name value.");
-                 ipp_buffer_release(buffer);
-                 return (IPP_ERROR);
-               }
+  if (value_tag == (*attr)->value_tag)
+    return (1);
 
-               buffer[n] = '\0';
-               attr->name = _cupsStrAlloc((char *)buffer);
+ /*
+  * Otherwise implement changes as needed...
+  */
 
-               /*
-               * Since collection members are encoded differently than
-               * regular attributes, make sure we don't start with an
-               * empty value...
-               */
+  temp_tag = (ipp_tag_t)((int)((*attr)->value_tag) & IPP_TAG_MASK);
 
-                attr->num_values --;
+  switch (value_tag)
+  {
+    case IPP_TAG_UNSUPPORTED_VALUE :
+    case IPP_TAG_DEFAULT :
+    case IPP_TAG_UNKNOWN :
+    case IPP_TAG_NOVALUE :
+    case IPP_TAG_NOTSETTABLE :
+    case IPP_TAG_DELETEATTR :
+    case IPP_TAG_ADMINDEFINE :
+       /*
+        * Free any existing values...
+        */
 
-               DEBUG_printf(("2ippReadIO: member name=\"%s\"", attr->name));
-               break;
+        if ((*attr)->num_values > 0)
+          ipp_free_values(*attr, 0, (*attr)->num_values);
 
-            default : /* Other unsupported values */
-                value->unknown.length = n;
-               if (n > 0)
-               {
-                 if ((value->unknown.data = malloc(n)) == NULL)
-                 {
-                   _cupsSetHTTPError(HTTP_ERROR);
-                   DEBUG_puts("1ippReadIO: Unable to allocate value");
-                   ipp_buffer_release(buffer);
-                   return (IPP_ERROR);
-                 }
+       /*
+        * Set out-of-band value...
+        */
 
-                 if ((*cb)(src, value->unknown.data, n) < n)
-                 {
-                   DEBUG_puts("1ippReadIO: Unable to read unsupported value.");
-                   ipp_buffer_release(buffer);
-                   return (IPP_ERROR);
-                 }
-               }
-               else
-                 value->unknown.data = NULL;
-               break;
-         }
+        (*attr)->value_tag = value_tag;
+        break;
 
-          attr->num_values ++;
+    case IPP_TAG_RANGE :
+        if (temp_tag != IPP_TAG_INTEGER)
+          return (0);
+
+        for (i = (*attr)->num_values, value = (*attr)->values;
+             i > 0;
+             i --, value ++)
+        {
+          integer            = value->integer;
+          value->range.lower = value->range.upper = integer;
+        }
 
-        /*
-          * If blocking is disabled, stop here...
-         */
+        (*attr)->value_tag = IPP_TAG_RANGE;
+        break;
 
-          if (!blocking)
-           break;
-       }
+    case IPP_TAG_NAME :
+        if (temp_tag != IPP_TAG_KEYWORD && temp_tag != IPP_TAG_URI &&
+            temp_tag != IPP_TAG_URISCHEME && temp_tag != IPP_TAG_LANGUAGE &&
+            temp_tag != IPP_TAG_MIMETYPE)
+          return (0);
+
+        (*attr)->value_tag = (ipp_tag_t)(IPP_TAG_NAME | ((*attr)->value_tag & IPP_TAG_COPY));
         break;
 
-    case IPP_DATA :
+    case IPP_TAG_NAMELANG :
+    case IPP_TAG_TEXTLANG :
+        if (value_tag == IPP_TAG_NAMELANG &&
+            (temp_tag != IPP_TAG_NAME && temp_tag != IPP_TAG_KEYWORD &&
+             temp_tag != IPP_TAG_URI && temp_tag != IPP_TAG_URISCHEME &&
+             temp_tag != IPP_TAG_LANGUAGE && temp_tag != IPP_TAG_MIMETYPE))
+          return (0);
+
+        if (value_tag == IPP_TAG_TEXTLANG && temp_tag != IPP_TAG_TEXT)
+          return (0);
+
+        if (ipp->attrs && ipp->attrs->next && ipp->attrs->next->name &&
+            !strcmp(ipp->attrs->next->name, "attributes-natural-language"))
+        {
+         /*
+          * Use the language code from the IPP message...
+          */
+
+         (*attr)->values[0].string.language =
+             _cupsStrAlloc(ipp->attrs->next->values[0].string.text);
+        }
+        else
+        {
+         /*
+          * Otherwise, use the language code corresponding to the locale...
+          */
+
+         language = cupsLangDefault();
+         (*attr)->values[0].string.language = _cupsStrAlloc(ipp_lang_code(language->language,
+                                                                       code,
+                                                                       sizeof(code)));
+        }
+
+        for (i = (*attr)->num_values - 1, value = (*attr)->values + 1;
+             i > 0;
+             i --, value ++)
+          value->string.language = (*attr)->values[0].string.language;
+
+        if ((int)(*attr)->value_tag & IPP_TAG_COPY)
+        {
+         /*
+          * Make copies of all values...
+          */
+
+         for (i = (*attr)->num_values, value = (*attr)->values;
+              i > 0;
+              i --, value ++)
+           value->string.text = _cupsStrAlloc(value->string.text);
+        }
+
+        (*attr)->value_tag = IPP_TAG_NAMELANG;
         break;
 
+    case IPP_TAG_KEYWORD :
+        if (temp_tag == IPP_TAG_NAME || temp_tag == IPP_TAG_NAMELANG)
+          break;                       /* Silently "allow" name -> keyword */
+
     default :
-        break; /* anti-compiler-warning-code */
+        return (0);
   }
 
-  DEBUG_printf(("1ippReadIO: returning ipp->state=%d.", ipp->state));
-  ipp_buffer_release(buffer);
+  return (1);
+}
+
+
+/*
+ * 'ippSetVersion()' - Set the version number in an IPP message.
+ *
+ * The @code ipp@ parameter refers to an IPP message previously created using the
+ * @link ippNew@ or @link ippNewRequest@ functions.
+ *
+ * The valid version numbers are currently 1.0, 1.1, 2.0, 2.1, and 2.2.
+ *
+ * @since CUPS 1.6@
+ */
+
+int                                    /* O - 1 on success, 0 on failure */
+ippSetVersion(ipp_t *ipp,              /* I - IPP message */
+              int   major,             /* I - Major version number (major.minor) */
+              int   minor)             /* I - Minor version number (major.minor) */
+{
+ /*
+  * Range check input...
+  */
+
+  if (!ipp || major < 0 || minor < 0)
+    return (0);
+
+ /*
+  * Set the version number...
+  */
+
+  ipp->request.any.version[0] = major;
+  ipp->request.any.version[1] = minor;
 
-  return (ipp->state);
+  return (1);
 }
 
 
@@ -1931,7 +3786,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
   unsigned char                *buffer,        /* Data buffer */
                        *bufptr;        /* Pointer into buffer */
   ipp_attribute_t      *attr;          /* Current attribute */
-  ipp_value_t          *value;         /* Current value */
+  _ipp_value_t         *value;         /* Current value */
 
 
   DEBUG_printf(("ippWriteIO(dst=%p, cb=%p, blocking=%d, parent=%p, ipp=%p)",
@@ -2044,9 +3899,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
                        ippTagString(attr->value_tag)));
 
          /*
-         * Write the attribute tag and name.  The current implementation
-         * does not support the extension value tags above 0x7f, so all
-         * value tags are 1 byte.
+         * Write the attribute tag and name.
          *
          * The attribute name length does not include the trailing nul
          * character in the source string.
@@ -2061,7 +3914,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
            * overflow the buffer...
            */
 
-            if ((n = (int)strlen(attr->name)) > (IPP_BUF_SIZE - 4))
+            if ((n = (int)strlen(attr->name)) > (IPP_BUF_SIZE - 8))
            {
              DEBUG_printf(("1ippWriteIO: Attribute name too long (%d)", n));
              ipp_buffer_release(buffer);
@@ -2077,7 +3930,17 @@ ippWriteIO(void       *dst,              /* I - Destination */
             DEBUG_printf(("2ippWriteIO: writing name=%d,\"%s\"", n,
                          attr->name));
 
-            *bufptr++ = attr->value_tag;
+            if (attr->value_tag > 0xff)
+            {
+              *bufptr++ = IPP_TAG_EXTENSION;
+             *bufptr++ = attr->value_tag >> 24;
+             *bufptr++ = attr->value_tag >> 16;
+             *bufptr++ = attr->value_tag >> 8;
+             *bufptr++ = attr->value_tag;
+            }
+            else
+             *bufptr++ = attr->value_tag;
+
            *bufptr++ = n >> 8;
            *bufptr++ = n;
            memcpy(bufptr, attr->name, n);
@@ -2090,7 +3953,7 @@ ippWriteIO(void       *dst,               /* I - Destination */
            * overflow the buffer...
            */
 
-            if ((n = (int)strlen(attr->name)) > (IPP_BUF_SIZE - 7))
+            if ((n = (int)strlen(attr->name)) > (IPP_BUF_SIZE - 12))
            {
              DEBUG_printf(("1ippWriteIO: Attribute name too long (%d)", n));
              ipp_buffer_release(buffer);
@@ -2118,7 +3981,17 @@ ippWriteIO(void       *dst,              /* I - Destination */
            memcpy(bufptr, attr->name, n);
            bufptr += n;
 
-            *bufptr++ = attr->value_tag;
+            if (attr->value_tag > 0xff)
+            {
+              *bufptr++ = IPP_TAG_EXTENSION;
+             *bufptr++ = attr->value_tag >> 24;
+             *bufptr++ = attr->value_tag >> 16;
+             *bufptr++ = attr->value_tag >> 8;
+             *bufptr++ = attr->value_tag;
+            }
+            else
+             *bufptr++ = attr->value_tag;
+
             *bufptr++ = 0;
             *bufptr++ = 0;
          }
@@ -2129,6 +4002,17 @@ ippWriteIO(void       *dst,              /* I - Destination */
 
          switch (attr->value_tag & ~IPP_TAG_COPY)
          {
+           case IPP_TAG_UNSUPPORTED_VALUE :
+           case IPP_TAG_DEFAULT :
+           case IPP_TAG_UNKNOWN :
+           case IPP_TAG_NOVALUE :
+           case IPP_TAG_NOTSETTABLE :
+           case IPP_TAG_DELETEATTR :
+           case IPP_TAG_ADMINDEFINE :
+               *bufptr++ = 0;
+               *bufptr++ = 0;
+               break;
+
            case IPP_TAG_INTEGER :
            case IPP_TAG_ENUM :
                for (i = 0, value = attr->values;
@@ -2501,8 +4385,8 @@ ippWriteIO(void       *dst,               /* I - Destination */
 
                   n = 4;
 
-                 if (value->string.charset != NULL)
-                    n += (int)strlen(value->string.charset);
+                 if (value->string.language != NULL)
+                    n += (int)strlen(value->string.language);
 
                  if (value->string.text != NULL)
                     n += (int)strlen(value->string.text);
@@ -2532,19 +4416,19 @@ ippWriteIO(void       *dst,             /* I - Destination */
                  *bufptr++ = n >> 8;
                  *bufptr++ = n;
 
-                 /* Length of charset */
-                 if (value->string.charset != NULL)
-                   n = (int)strlen(value->string.charset);
+                 /* Length of language */
+                 if (value->string.language != NULL)
+                   n = (int)strlen(value->string.language);
                  else
                    n = 0;
 
                  *bufptr++ = n >> 8;
                  *bufptr++ = n;
 
-                 /* Charset */
+                 /* Language */
                  if (n > 0)
                  {
-                   memcpy(bufptr, value->string.charset, n);
+                   memcpy(bufptr, value->string.language, n);
                    bufptr += n;
                  }
 
@@ -2782,122 +4666,71 @@ ippWriteIO(void       *dst,            /* I - Destination */
 
 
 /*
- * '_ippAddAttr()' - Add a new attribute to the request.
+ * 'ipp_add_attr()' - Add a new attribute to the message.
  */
 
-ipp_attribute_t *                      /* O - New attribute */
-_ippAddAttr(ipp_t *ipp,                        /* I - IPP message */
-            int   num_values)          /* I - Number of values */
+static ipp_attribute_t *               /* O - New attribute */
+ipp_add_attr(ipp_t      *ipp,          /* I - IPP message */
+             const char *name,         /* I - Attribute name or NULL */
+             ipp_tag_t  group_tag,     /* I - Group tag or IPP_TAG_ZERO */
+             ipp_tag_t  value_tag,     /* I - Value tag or IPP_TAG_ZERO */
+             int        num_values)    /* I - Number of values */
 {
+  int                  alloc_values;   /* Number of values to allocate */
   ipp_attribute_t      *attr;          /* New attribute */
 
 
-  DEBUG_printf(("4_ippAddAttr(ipp=%p, num_values=%d)", ipp, num_values));
+  DEBUG_printf(("4ipp_add_attr(ipp=%p, name=\"%s\", group_tag=0x%x, value_tag=0x%x, "
+                "num_values=%d)", ipp, name, group_tag, value_tag, num_values));
+
+ /*
+  * Range check input...
+  */
 
   if (!ipp || num_values < 0)
     return (NULL);
 
-  attr = calloc(sizeof(ipp_attribute_t) +
-                (num_values - 1) * sizeof(ipp_value_t), 1);
-
-  if (attr != NULL)
-  {
-    attr->num_values = num_values;
-
-    if (ipp->last == NULL)
-      ipp->attrs = attr;
-    else
-      ipp->last->next = attr;
-
-    ipp->last = attr;
-  }
-
-  DEBUG_printf(("5_ippAddAttr: Returning %p", attr));
-
-  return (attr);
-}
-
-
-/*
- * '_ippFreeAttr()' - Free an attribute.
- */
-
-void
-_ippFreeAttr(ipp_attribute_t *attr)    /* I - Attribute to free */
-{
-  int          i;                      /* Looping var */
-  ipp_value_t  *value;                 /* Current value */
+ /*
+  * Allocate memory, rounding the allocation up as needed...
+  */
 
+  if (num_values <= 1)
+    alloc_values = num_values;
+  else
+    alloc_values = (num_values + IPP_MAX_VALUES - 1) & ~(IPP_MAX_VALUES - 1);
 
-  DEBUG_printf(("4_ippFreeAttr(attr=%p)", attr));
+  attr = calloc(sizeof(ipp_attribute_t) +
+                (alloc_values - 1) * sizeof(_ipp_value_t), 1);
 
-  switch (attr->value_tag)
+  if (attr)
   {
-    case IPP_TAG_TEXT :
-    case IPP_TAG_NAME :
-    case IPP_TAG_RESERVED_STRING :
-    case IPP_TAG_KEYWORD :
-    case IPP_TAG_URI :
-    case IPP_TAG_URISCHEME :
-    case IPP_TAG_CHARSET :
-    case IPP_TAG_LANGUAGE :
-    case IPP_TAG_MIMETYPE :
-       for (i = 0, value = attr->values;
-            i < attr->num_values;
-            i ++, value ++)
-         _cupsStrFree(value->string.text);
-       break;
+   /*
+    * Initialize attribute...
+    */
 
-    case IPP_TAG_TEXTLANG :
-    case IPP_TAG_NAMELANG :
-       for (i = 0, value = attr->values;
-            i < attr->num_values;
-            i ++, value ++)
-       {
-         if (value->string.charset && i == 0)
-           _cupsStrFree(value->string.charset);
-         _cupsStrFree(value->string.text);
-       }
-       break;
+    if (name)
+      attr->name = _cupsStrAlloc(name);
 
-    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;
+    attr->group_tag  = group_tag;
+    attr->value_tag  = value_tag;
+    attr->num_values = num_values;
 
-    case IPP_TAG_BEGIN_COLLECTION :
-       for (i = 0, value = attr->values;
-            i < attr->num_values;
-            i ++, value ++)
-          ippDelete(value->collection);
-       break;
+   /*
+    * Add it to the end of the linked list...
+    */
 
-    case IPP_TAG_STRING :
-       for (i = 0, value = attr->values;
-            i < attr->num_values;
-            i ++, value ++)
-         free(value->unknown.data);
-        break;
+    if (ipp->last)
+      ipp->last->next = attr;
+    else
+      ipp->attrs = attr;
 
-    default :
-        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;
+    ipp->prev = ipp->last;
+    ipp->last = ipp->current = attr;
   }
 
-  if (attr->name)
-    _cupsStrFree(attr->name);
+  DEBUG_printf(("5ipp_add_attr: Returning %p", attr));
 
-  free(attr);
+  return (attr);
 }
 
 
@@ -2942,6 +4775,157 @@ ipp_buffer_release(unsigned char *b)    /* I - Buffer to release */
 }
 
 
+/*
+ * 'ipp_free_values()' - Free attribute values.
+ */
+
+static void
+ipp_free_values(ipp_attribute_t *attr, /* I - Attribute to free values from */
+                int             element,/* I - First value to free */
+                int             count) /* I - Number of values to free */
+{
+  int          i;                      /* Looping var */
+  _ipp_value_t *value;                 /* Current value */
+
+
+  DEBUG_printf(("4ipp_free_values(attr=%p, element=%d, count=%d)", attr, element, count));
+
+  if (!(attr->value_tag & IPP_TAG_COPY))
+  {
+   /*
+    * Free values as needed...
+    */
+
+    switch (attr->value_tag)
+    {
+      case IPP_TAG_TEXTLANG :
+      case IPP_TAG_NAMELANG :
+         if (element == 0 && count == attr->num_values && attr->values[0].string.language)
+           _cupsStrFree(attr->values[0].string.language);
+  
+      case IPP_TAG_TEXT :
+      case IPP_TAG_NAME :
+      case IPP_TAG_RESERVED_STRING :
+      case IPP_TAG_KEYWORD :
+      case IPP_TAG_URI :
+      case IPP_TAG_URISCHEME :
+      case IPP_TAG_CHARSET :
+      case IPP_TAG_LANGUAGE :
+      case IPP_TAG_MIMETYPE :
+         for (i = count, value = attr->values + element;
+              i > 0;
+              i --, value ++)
+           _cupsStrFree(value->string.text);
+         break;
+  
+      case IPP_TAG_DEFAULT :
+      case IPP_TAG_UNKNOWN :
+      case IPP_TAG_NOVALUE :
+      case IPP_TAG_NOTSETTABLE :
+      case IPP_TAG_DELETEATTR :
+      case IPP_TAG_ADMINDEFINE :
+      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 = count, value = attr->values + element;
+              i > 0;
+              i --, value ++)
+           ippDelete(value->collection);
+         break;
+  
+      case IPP_TAG_STRING :
+      default :
+         for (i = count, value = attr->values + element;
+              i > 0;
+              i --, value ++)
+           if (value->unknown.data)
+             free(value->unknown.data);
+         break;
+    }
+  }
+
+ /*
+  * If we are not freeing values from the end, move the remaining values up...
+  */
+
+  if ((element + count) < attr->num_values)
+    memmove(attr->values + element, attr->values + element + count,
+            (attr->num_values - count - element) * sizeof(_ipp_value_t));
+
+  attr->num_values -= count;
+}
+
+
+/*
+ * 'ipp_get_code()' - Convert a C locale/charset name into an IPP language/charset code.
+ *
+ * This typically converts strings of the form "ll_CC", "ll-REGION", and "CHARSET_NUMBER"
+ * to "ll-cc", "ll-region", and "charset-number", respectively.
+ */
+
+static char *                          /* O - Language code string */
+ipp_get_code(const char *value,                /* I - Locale/charset string */
+             char       *buffer,       /* I - String buffer */
+             size_t     bufsize)       /* I - Size of string buffer */
+{
+  char *bufptr,                        /* Pointer into buffer */
+       *bufend;                        /* End of buffer */
+
+
+ /*
+  * Convert values to lowercase and change _ to - as needed...
+  */
+
+  for (bufptr = buffer, bufend = buffer + bufsize - 1;
+       *value && bufptr < bufend;
+       value ++)
+    if (*value == '_')
+      *bufptr++ = '-';
+    else
+      *bufptr++ = _cups_tolower(*value);
+
+  *bufptr = '\0';
+
+ /*
+  * Return the converted string...
+  */
+
+  return (buffer);
+}
+
+
+/*
+ * 'ipp_lang_code()' - Convert a C locale name into an IPP language code.
+ *
+ * This typically converts strings of the form "ll_CC" and "ll-REGION" to "ll-cc" and
+ * "ll-region", respectively.  It also converts the "C" (POSIX) locale to "en".
+ */
+
+static char *                          /* O - Language code string */
+ipp_lang_code(const char *locale,      /* I - Locale string */
+              char       *buffer,      /* I - String buffer */
+              size_t     bufsize)      /* I - Size of string buffer */
+{
+ /*
+  * Map POSIX ("C") locale to generic English, otherwise convert the locale string as-is.
+  */
+
+  if (!_cups_strcasecmp(locale, "c"))
+  {
+    strlcpy(buffer, "en", bufsize);
+    return (buffer);
+  }
+  else
+    return (ipp_get_code(locale, buffer, bufsize));
+}
+
+
 /*
  * 'ipp_length()' - Compute the length of an IPP message or collection value.
  */
@@ -2951,14 +4935,19 @@ ipp_length(ipp_t *ipp,                  /* I - IPP message or collection */
            int   collection)           /* I - 1 if a collection, 0 otherwise */
 {
   int                  i;              /* Looping var */
-  int                  bytes;          /* Number of bytes */
+  size_t               bytes;          /* Number of bytes */
   ipp_attribute_t      *attr;          /* Current attribute */
   ipp_tag_t            group;          /* Current group */
-  ipp_value_t          *value;         /* Current value */
+  _ipp_value_t         *value;         /* Current value */
+
 
+  DEBUG_printf(("3ipp_length(ipp=%p, collection=%d)", ipp, collection));
 
-  if (ipp == NULL)
+  if (!ipp)
+  {
+    DEBUG_puts("4ipp_length: Returning 0 bytes");
     return (0);
+  }
 
  /*
   * Start with 8 bytes for the IPP message header...
@@ -2986,12 +4975,15 @@ ipp_length(ipp_t *ipp,                  /* I - IPP message or collection */
     if (!attr->name)
       continue;
 
-    DEBUG_printf(("9ipp_length: attr->name=\"%s\", attr->num_values=%d, "
-                  "bytes=%d", attr->name, attr->num_values, bytes));
+    DEBUG_printf(("5ipp_length: attr->name=\"%s\", attr->num_values=%d, "
+                  "bytes=" CUPS_LLFMT, attr->name, attr->num_values, CUPS_LLCAST bytes));
 
-    bytes += (int)strlen(attr->name);  /* Name */
-    bytes += attr->num_values;         /* Value tag for each value */
+    if (attr->value_tag < IPP_TAG_EXTENSION)
+      bytes += attr->num_values;       /* Value tag for each value */
+    else
+      bytes += 5 * attr->num_values;   /* Value tag for each value */
     bytes += 2 * attr->num_values;     /* Name lengths */
+    bytes += (int)strlen(attr->name);  /* Name */
     bytes += 2 * attr->num_values;     /* Value lengths */
 
     if (collection)
@@ -2999,6 +4991,15 @@ ipp_length(ipp_t *ipp,                   /* I - IPP message or collection */
 
     switch (attr->value_tag & ~IPP_TAG_COPY)
     {
+      case IPP_TAG_UNSUPPORTED_VALUE :
+      case IPP_TAG_DEFAULT :
+      case IPP_TAG_UNKNOWN :
+      case IPP_TAG_NOVALUE :
+      case IPP_TAG_NOTSETTABLE :
+      case IPP_TAG_DELETEATTR :
+      case IPP_TAG_ADMINDEFINE :
+          break;
+
       case IPP_TAG_INTEGER :
       case IPP_TAG_ENUM :
           bytes += 4 * attr->num_values;
@@ -3019,8 +5020,8 @@ ipp_length(ipp_t *ipp,                    /* I - IPP message or collection */
          for (i = 0, value = attr->values;
               i < attr->num_values;
               i ++, value ++)
-           if (value->string.text != NULL)
-             bytes += (int)strlen(value->string.text);
+           if (value->string.text)
+             bytes += strlen(value->string.text);
          break;
 
       case IPP_TAG_DATE :
@@ -3043,11 +5044,11 @@ ipp_length(ipp_t *ipp,                  /* I - IPP message or collection */
               i < attr->num_values;
               i ++, value ++)
          {
-           if (value->string.charset != NULL)
-             bytes += (int)strlen(value->string.charset);
+           if (value->string.language)
+             bytes += strlen(value->string.language);
 
-           if (value->string.text != NULL)
-             bytes += (int)strlen(value->string.text);
+           if (value->string.text)
+             bytes += strlen(value->string.text);
          }
          break;
 
@@ -3055,7 +5056,7 @@ ipp_length(ipp_t *ipp,                    /* I - IPP message or collection */
          for (i = 0, value = attr->values;
               i < attr->num_values;
               i ++, value ++)
-            bytes += (int)ipp_length(value->collection, 1);
+            bytes += ipp_length(value->collection, 1);
          break;
 
       default :
@@ -3077,7 +5078,7 @@ ipp_length(ipp_t *ipp,                    /* I - IPP message or collection */
   else
     bytes ++;
 
-  DEBUG_printf(("8ipp_length: Returning %d bytes", bytes));
+  DEBUG_printf(("4ipp_length: Returning " CUPS_LLFMT " bytes", CUPS_LLCAST bytes));
 
   return (bytes);
 }
@@ -3231,6 +5232,126 @@ ipp_read_file(int         *fd,          /* I - File descriptor */
 }
 
 
+/*
+ * 'ipp_set_value()' - Get the value element from an attribute, expanding it as needed.
+ */
+
+static _ipp_value_t *                  /* O  - IPP value element or NULL on error */
+ipp_set_value(ipp_t           *ipp,    /* I  - IPP message */
+              ipp_attribute_t **attr,  /* IO - IPP attribute */
+              int             element) /* I  - Value number (0-based) */
+{
+  ipp_attribute_t      *temp,          /* New attribute pointer */
+                       *current,       /* Current attribute in list */
+                       *prev;          /* Previous attribute in list */
+  int                  alloc_values;   /* Allocated values */
+
+
+ /*
+  * If we are setting an existing value element, return it...
+  */
+
+  temp = *attr;
+
+  if (temp->num_values <= 1)
+    alloc_values = temp->num_values;
+  else
+    alloc_values = (temp->num_values + IPP_MAX_VALUES - 1) & ~(IPP_MAX_VALUES - 1);
+
+  if (element < alloc_values)
+    return (temp->values + element);
+
+ /*
+  * Otherwise re-allocate the attribute - we allocate in groups of IPP_MAX_VALUE values
+  * when num_values > 1.
+  */
+
+  if (alloc_values < IPP_MAX_VALUES)
+    alloc_values = IPP_MAX_VALUES;
+  else
+    alloc_values += IPP_MAX_VALUES;
+
+  DEBUG_printf(("4ipp_set_value: Reallocating for up to %d values.", alloc_values));
+
+ /*
+  * Reallocate memory...
+  */
+
+  if ((temp = realloc(temp, sizeof(ipp_attribute_t) +
+                           (temp->num_values + IPP_MAX_VALUES - 1) *
+                           sizeof(_ipp_value_t))) == NULL)
+  {
+    _cupsSetHTTPError(HTTP_ERROR);
+    DEBUG_puts("4ipp_set_value: Unable to resize attribute.");
+    return (NULL);
+  }
+
+ /*
+  * Zero the new memory...
+  */
+
+  memset(temp->values + temp->num_values, 0,
+         (alloc_values - temp->num_values) * sizeof(_ipp_value_t));
+
+  if (temp != *attr)
+  {
+   /*
+    * Reset pointers in the list...
+    */
+
+    if (ipp->current == *attr && ipp->prev)
+    {
+     /*
+      * Use current "previous" pointer...
+      */
+
+      prev = ipp->prev;
+    }
+    else
+    {
+     /*
+      * Find this attribute in the linked list...
+      */
+
+      for (prev = NULL, current = ipp->attrs;
+          current && current != *attr;
+          prev = current, current = current->next);
+
+      if (!current)
+      {
+       /*
+       * This is a serious error!
+       */
+
+       *attr = temp;
+       _cupsSetError(IPP_ERROR, _("IPP attribute is not a member of the message."), 1);
+       DEBUG_puts("4ipp_set_value: Unable to find attribute in message.");
+       return (NULL);
+      }
+    }
+
+    if (prev)
+      prev->next = temp;
+    else
+      ipp->attrs = temp;
+
+    ipp->current = temp;
+    ipp->prev    = prev;
+
+    if (ipp->last == *attr)
+      ipp->last = temp;
+
+    *attr = temp;
+  }
+
+ /*
+  * Return the value element...
+  */
+
+  return (temp->values + element);
+}
+
+
 /*
  * 'ipp_write_file()' - Write IPP data to a file.
  */
@@ -3248,29 +5369,6 @@ 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$".
  */
index e4b38ff0f8bdb9be1c546fa58d37ca99b0dd44f9..817ccc4f1fa1ef67471e2e3d498c01073200a4d4 100644 (file)
@@ -63,54 +63,14 @@ extern "C" {
  * Types and structures...
  */
 
-typedef enum ipp_tag_e                 /**** Format tags for attributes ****/
+typedef enum ipp_dstate_e              /**** Document states ****/
 {
-  IPP_TAG_ZERO = 0x00,                 /* Zero tag - used for separators */
-  IPP_TAG_OPERATION,                   /* Operation group */
-  IPP_TAG_JOB,                         /* Job group */
-  IPP_TAG_END,                         /* End-of-attributes */
-  IPP_TAG_PRINTER,                     /* Printer group */
-  IPP_TAG_UNSUPPORTED_GROUP,           /* Unsupported attributes group */
-  IPP_TAG_SUBSCRIPTION,                        /* Subscription group */
-  IPP_TAG_EVENT_NOTIFICATION,          /* Event group */
-  IPP_TAG_DOCUMENT = 0x09,             /* Document group */
-  IPP_TAG_UNSUPPORTED_VALUE = 0x10,    /* Unsupported value */
-  IPP_TAG_DEFAULT,                     /* Default value */
-  IPP_TAG_UNKNOWN,                     /* Unknown value */
-  IPP_TAG_NOVALUE,                     /* No-value value */
-  IPP_TAG_NOTSETTABLE = 0x15,          /* Not-settable value */
-  IPP_TAG_DELETEATTR,                  /* Delete-attribute value */
-  IPP_TAG_ADMINDEFINE,                 /* Admin-defined value */
-  IPP_TAG_INTEGER = 0x21,              /* Integer value */
-  IPP_TAG_BOOLEAN,                     /* Boolean value */
-  IPP_TAG_ENUM,                                /* Enumeration value */
-  IPP_TAG_STRING = 0x30,               /* Octet string value */
-  IPP_TAG_DATE,                                /* Date/time value */
-  IPP_TAG_RESOLUTION,                  /* Resolution value */
-  IPP_TAG_RANGE,                       /* Range value */
-  IPP_TAG_BEGIN_COLLECTION,            /* Beginning of collection value */
-  IPP_TAG_TEXTLANG,                    /* Text-with-language value */
-  IPP_TAG_NAMELANG,                    /* Name-with-language value */
-  IPP_TAG_END_COLLECTION,              /* End of collection value */
-  IPP_TAG_TEXT = 0x41,                 /* Text value */
-  IPP_TAG_NAME,                                /* Name value */
-  IPP_TAG_RESERVED_STRING,             /* Reserved for future string value @private@ */
-  IPP_TAG_KEYWORD,                     /* Keyword value */
-  IPP_TAG_URI,                         /* URI value */
-  IPP_TAG_URISCHEME,                   /* URI scheme value */
-  IPP_TAG_CHARSET,                     /* Character set value */
-  IPP_TAG_LANGUAGE,                    /* Language value */
-  IPP_TAG_MIMETYPE,                    /* MIME media type value */
-  IPP_TAG_MEMBERNAME,                  /* Collection member name value */
-  IPP_TAG_MASK = 0x7fffffff,           /* Mask for copied attribute values */
-  IPP_TAG_COPY = -0x7fffffff-1         /* Bitflag for copied attribute values */
-} ipp_tag_t;
-
-typedef enum ipp_res_e                 /**** Resolution units ****/
-{
-  IPP_RES_PER_INCH = 3,                        /* Pixels per inch */
-  IPP_RES_PER_CM                       /* Pixels per centimeter */
-} ipp_res_t;
+  IPP_DOCUMENT_PENDING = 3,
+  IPP_DOCUMENT_PROCESSING = 5,
+  IPP_DOCUMENT_CANCELED = 7,
+  IPP_DOCUMENT_ABORTED,
+  IPP_DOCUMENT_COMPLETED
+} ipp_dstate_t;
 
 typedef enum ipp_finish_e              /**** Finishings ****/
 {
@@ -141,23 +101,19 @@ typedef enum ipp_finish_e         /**** Finishings ****/
   IPP_FINISHINGS_BIND_LEFT = 50,       /* Bind on left */
   IPP_FINISHINGS_BIND_TOP,             /* Bind on top */
   IPP_FINISHINGS_BIND_RIGHT,           /* Bind on right */
-  IPP_FINISHINGS_BIND_BOTTOM           /* Bind on bottom */
+  IPP_FINISHINGS_BIND_BOTTOM,          /* Bind on bottom */
+  IPP_FINISHINGS_TRIM_AFTER_PAGES = 60,        /* Trim output after each page */
+  IPP_FINISHINGS_TRIM_AFTER_DOCUMENTS, /* Trim output after each document */
+  IPP_FINISHINGS_TRIM_AFTER_COPIES,    /* Trim output after each copy */
+  IPP_FINISHINGS_TRIM_AFTER_JOB                /* Trim output after job */
 } ipp_finish_t;
 
-typedef enum ipp_orient_e              /**** Orientation values ****/
+typedef enum ipp_jcollate_e            /**** Job collation types ****/
 {
-  IPP_PORTRAIT = 3,                    /* No rotation */
-  IPP_LANDSCAPE,                       /* 90 degrees counter-clockwise */
-  IPP_REVERSE_LANDSCAPE,               /* 90 degrees clockwise */
-  IPP_REVERSE_PORTRAIT                 /* 180 degrees */
-} ipp_orient_t;
-
-typedef enum ipp_quality_e             /**** Qualities ****/
-{
-  IPP_QUALITY_DRAFT = 3,               /* Draft quality */
-  IPP_QUALITY_NORMAL,                  /* Normal quality */
-  IPP_QUALITY_HIGH                     /* High quality */
-} ipp_quality_t;
+  IPP_JOB_UNCOLLATED_SHEETS = 3,
+  IPP_JOB_COLLATED_DOCUMENTS,
+  IPP_JOB_UNCOLLATED_DOCUMENTS
+} ipp_jcollate_t;
 
 typedef enum ipp_jstate_e              /**** Job states ****/
 {
@@ -168,24 +124,9 @@ typedef enum ipp_jstate_e          /**** Job states ****/
   IPP_JOB_CANCELED,                    /* Job has been canceled */
   IPP_JOB_ABORTED,                     /* Job has aborted due to error */
   IPP_JOB_COMPLETED                    /* Job has completed successfully */
-} ipp_jstate_t;
+  /* Legacy name for canceled state */
 #define IPP_JOB_CANCELLED IPP_JOB_CANCELED
-
-typedef enum ipp_pstate_e              /**** Printer states ****/
-{
-  IPP_PRINTER_IDLE = 3,                        /* Printer is idle */
-  IPP_PRINTER_PROCESSING,              /* Printer is working */
-  IPP_PRINTER_STOPPED                  /* Printer is stopped */
-} ipp_pstate_t;
-
-typedef enum ipp_state_e               /**** IPP states ****/
-{
-  IPP_ERROR = -1,                      /* An error occurred */
-  IPP_IDLE,                            /* Nothing is happening/request completed */
-  IPP_HEADER,                          /* The request header needs to be sent/received */
-  IPP_ATTRIBUTE,                       /* One or more attributes need to be sent/received */
-  IPP_DATA                             /* IPP request data needs to be sent/received */
-} ipp_state_t;
+} ipp_jstate_t;
 
 typedef enum ipp_op_e                  /**** IPP operations ****/
 {
@@ -216,7 +157,10 @@ typedef enum ipp_op_e                      /**** IPP operations ****/
   IPP_CANCEL_SUBSCRIPTION,             /* Cancel a subscription @since CUPS 1.2/Mac OS X 10.5@ */
   IPP_GET_NOTIFICATIONS,               /* Get notification events @since CUPS 1.2/Mac OS X 10.5@ */
   IPP_SEND_NOTIFICATIONS,              /* Send notification events @private@ */
-  IPP_GET_PRINT_SUPPORT_FILES = 0x0021,        /* Get printer support files @private@ */
+  IPP_GET_RESOURCE_ATTRIBUTES,         /* Get resource attributes @private@ */
+  IPP_GET_RESOURCE_DATA,               /* Get resource data @private@ */
+  IPP_GET_RESOURCES,                   /* Get list of resources @private@ */
+  IPP_GET_PRINT_SUPPORT_FILES,         /* Get printer support files @private@ */
   IPP_ENABLE_PRINTER,                  /* Start a printer */
   IPP_DISABLE_PRINTER,                 /* Stop a printer */
   IPP_PAUSE_PRINTER_AFTER_CURRENT_JOB, /* Stop printer after the current job @private@ */
@@ -260,11 +204,48 @@ typedef enum ipp_op_e                     /**** IPP operations ****/
   CUPS_AUTHENTICATE_JOB,               /* Authenticate a job @since CUPS 1.2/Mac OS X 10.5@ */
   CUPS_GET_PPD,                                /* Get a PPD file @since CUPS 1.3/Mac OS X 10.5@ */
   CUPS_GET_DOCUMENT = 0x4027           /* Get a document file @since CUPS 1.4/Mac OS X 10.6@ */
-} ipp_op_t;
 
-/* Old names for the operations */
+  /* Legacy names for the add operations */
 #define CUPS_ADD_PRINTER       CUPS_ADD_MODIFY_PRINTER
 #define CUPS_ADD_CLASS         CUPS_ADD_MODIFY_CLASS
+} ipp_op_t;
+
+typedef enum ipp_orient_e              /**** Orientation values ****/
+{
+  IPP_PORTRAIT = 3,                    /* No rotation */
+  IPP_LANDSCAPE,                       /* 90 degrees counter-clockwise */
+  IPP_REVERSE_LANDSCAPE,               /* 90 degrees clockwise */
+  IPP_REVERSE_PORTRAIT                 /* 180 degrees */
+} ipp_orient_t;
+
+typedef enum ipp_pstate_e              /**** Printer states ****/
+{
+  IPP_PRINTER_IDLE = 3,                        /* Printer is idle */
+  IPP_PRINTER_PROCESSING,              /* Printer is working */
+  IPP_PRINTER_STOPPED                  /* Printer is stopped */
+} ipp_pstate_t;
+
+typedef enum ipp_quality_e             /**** Qualities ****/
+{
+  IPP_QUALITY_DRAFT = 3,               /* Draft quality */
+  IPP_QUALITY_NORMAL,                  /* Normal quality */
+  IPP_QUALITY_HIGH                     /* High quality */
+} ipp_quality_t;
+
+typedef enum ipp_res_e                 /**** Resolution units ****/
+{
+  IPP_RES_PER_INCH = 3,                        /* Pixels per inch */
+  IPP_RES_PER_CM                       /* Pixels per centimeter */
+} ipp_res_t;
+
+typedef enum ipp_state_e               /**** IPP states ****/
+{
+  IPP_ERROR = -1,                      /* An error occurred */
+  IPP_IDLE,                            /* Nothing is happening/request completed */
+  IPP_HEADER,                          /* The request header needs to be sent/received */
+  IPP_ATTRIBUTE,                       /* One or more attributes need to be sent/received */
+  IPP_DATA                             /* IPP request data needs to be sent/received */
+} ipp_state_t;
 
 typedef enum ipp_status_e              /**** IPP status codes ****/
 {
@@ -272,9 +253,9 @@ typedef enum ipp_status_e           /**** IPP status codes ****/
   IPP_OK_SUBST,                                /* successful-ok-ignored-or-substituted-attributes */
   IPP_OK_CONFLICT,                     /* successful-ok-conflicting-attributes */
   IPP_OK_IGNORED_SUBSCRIPTIONS,                /* successful-ok-ignored-subscriptions */
-  IPP_OK_IGNORED_NOTIFICATIONS,                /* successful-ok-ignored-notifications */
+  IPP_OK_IGNORED_NOTIFICATIONS,                /* successful-ok-ignored-notifications @private@ */
   IPP_OK_TOO_MANY_EVENTS,              /* successful-ok-too-many-events */
-  IPP_OK_BUT_CANCEL_SUBSCRIPTION,      /* successful-ok-but-cancel-subscription */
+  IPP_OK_BUT_CANCEL_SUBSCRIPTION,      /* successful-ok-but-cancel-subscription @private@ */
   IPP_OK_EVENTS_COMPLETE,              /* successful-ok-events-complete */
   IPP_REDIRECTION_OTHER_SITE = 0x200,  /* redirection-other-site @private@ */
   CUPS_SEE_OTHER = 0x280,              /* cups-see-other */
@@ -300,8 +281,12 @@ typedef enum ipp_status_e          /**** IPP status codes ****/
   IPP_ATTRIBUTES_NOT_SETTABLE,         /* client-error-attributes-not-settable */
   IPP_IGNORED_ALL_SUBSCRIPTIONS,       /* client-error-ignored-all-subscriptions */
   IPP_TOO_MANY_SUBSCRIPTIONS,          /* client-error-too-many-subscriptions */
-  IPP_IGNORED_ALL_NOTIFICATIONS,       /* client-error-ignored-all-notifications */
-  IPP_PRINT_SUPPORT_FILE_NOT_FOUND,    /* client-error-print-support-file-not-found */
+  IPP_IGNORED_ALL_NOTIFICATIONS,       /* client-error-ignored-all-notifications @private@ */
+  IPP_PRINT_SUPPORT_FILE_NOT_FOUND,    /* client-error-print-support-file-not-found @private@ */
+  IPP_DOCUMENT_PASSWORD_ERROR,         /* client-error-document-password-error */
+  IPP_DOCUMENT_PERMISSION_ERROR,       /* client-error-document-permission-error */
+  IPP_DOCUMENT_SECURITY_ERROR,         /* client-error-document-security-error */
+  IPP_DOCUMENT_UNPRINTABLE_ERROR,      /* client-error-document-unprintable-error */
 
   IPP_INTERNAL_ERROR = 0x0500,         /* server-error-internal-error */
   IPP_OPERATION_NOT_SUPPORTED,         /* server-error-operation-not-supported */
@@ -318,112 +303,69 @@ typedef enum ipp_status_e                /**** IPP status codes ****/
   IPP_AUTHENTICATION_CANCELED = 0x1000,        /* Authentication canceled by user @since CUPS 1.5/Mac OS X 10.7@ */
   IPP_PKI_ERROR,                       /* Error negotiating a secure connection @since CUPS 1.5/Mac OS X 10.7@ */
   IPP_UPGRADE_REQUIRED                 /* TLS upgrade required */
-} ipp_status_t;
-#define IPP_ERROR_JOB_CANCELLED IPP_ERROR_JOB_CANCELED
 
-typedef unsigned char ipp_uchar_t;     /**** Unsigned 8-bit integer/character ****/
-
-/**** New in CUPS 1.2 ****/
-typedef ssize_t        (*ipp_iocb_t)(void *, ipp_uchar_t *, size_t);
-                                       /**** IPP IO Callback Function @since CUPS 1.2/Mac OS X 10.5@ ****/
-
-typedef union ipp_request_u            /**** Request Header ****/
-{
-  struct                               /* Any Header */
-  {
-    ipp_uchar_t        version[2];             /* Protocol version number */
-    int                op_status;              /* Operation ID or status code*/
-    int                request_id;             /* Request ID */
-  }            any;
-
-  struct                               /* Operation Header */
-  {
-    ipp_uchar_t        version[2];             /* Protocol version number */
-    ipp_op_t   operation_id;           /* Operation ID */
-    int                request_id;             /* Request ID */
-  }            op;
-
-  struct                               /* Status Header */
-  {
-    ipp_uchar_t        version[2];             /* Protocol version number */
-    ipp_status_t status_code;          /* Status code */
-    int                request_id;             /* Request ID */
-  }            status;
-
-  /**** New in CUPS 1.1.19 ****/
-  struct                               /* Event Header @since CUPS 1.1.19/Mac OS X 10.3@ */
-  {
-    ipp_uchar_t        version[2];             /* Protocol version number */
-    ipp_status_t status_code;          /* Status code */
-    int                request_id;             /* Request ID */
-  }            event;
-} ipp_request_t;
+  /* Legacy name for canceled status */
+#define IPP_ERROR_JOB_CANCELLED IPP_ERROR_JOB_CANCELED
 
-/**** New in CUPS 1.1.19 ****/
-typedef struct ipp_s ipp_t;
+} ipp_status_t;
 
-typedef union ipp_value_u              /**** Attribute Value ****/
+typedef enum ipp_tag_e                 /**** Format tags for attributes ****/
 {
-  int          integer;                /* Integer/enumerated value */
-
-  char         boolean;                /* Boolean value */
-
-  ipp_uchar_t  date[11];               /* Date/time value */
-
-  struct
-  {
-    int                xres,                   /* Horizontal resolution */
-               yres;                   /* Vertical resolution */
-    ipp_res_t  units;                  /* Resolution units */
-  }            resolution;             /* Resolution value */
-
-  struct
-  {
-    int                lower,                  /* Lower value */
-               upper;                  /* Upper value */
-  }            range;                  /* Range of integers value */
-
-  struct
-  {
-    char       *charset;               /* Character set */
-    char       *text;                  /* String */
-  }            string;                 /* String with language value */
-
-  struct
-  {
-    int                length;                 /* Length of attribute */
-    void       *data;                  /* Data in attribute */
-  }            unknown;                /* Unknown attribute type */
-
-/**** New in CUPS 1.1.19 ****/
-  ipp_t                *collection;            /* Collection value @since CUPS 1.1.19/Mac OS X 10.3@ */
-} ipp_value_t;
+  IPP_TAG_ZERO = 0x00,                 /* Zero tag - used for separators */
+  IPP_TAG_OPERATION,                   /* Operation group */
+  IPP_TAG_JOB,                         /* Job group */
+  IPP_TAG_END,                         /* End-of-attributes */
+  IPP_TAG_PRINTER,                     /* Printer group */
+  IPP_TAG_UNSUPPORTED_GROUP,           /* Unsupported attributes group */
+  IPP_TAG_SUBSCRIPTION,                        /* Subscription group */
+  IPP_TAG_EVENT_NOTIFICATION,          /* Event group */
+  IPP_TAG_RESOURCE,                    /* Resource group @private@ */
+  IPP_TAG_DOCUMENT,                    /* Document group */
+  IPP_TAG_UNSUPPORTED_VALUE = 0x10,    /* Unsupported value */
+  IPP_TAG_DEFAULT,                     /* Default value */
+  IPP_TAG_UNKNOWN,                     /* Unknown value */
+  IPP_TAG_NOVALUE,                     /* No-value value */
+  IPP_TAG_NOTSETTABLE = 0x15,          /* Not-settable value */
+  IPP_TAG_DELETEATTR,                  /* Delete-attribute value */
+  IPP_TAG_ADMINDEFINE,                 /* Admin-defined value */
+  IPP_TAG_INTEGER = 0x21,              /* Integer value */
+  IPP_TAG_BOOLEAN,                     /* Boolean value */
+  IPP_TAG_ENUM,                                /* Enumeration value */
+  IPP_TAG_STRING = 0x30,               /* Octet string value */
+  IPP_TAG_DATE,                                /* Date/time value */
+  IPP_TAG_RESOLUTION,                  /* Resolution value */
+  IPP_TAG_RANGE,                       /* Range value */
+  IPP_TAG_BEGIN_COLLECTION,            /* Beginning of collection value */
+  IPP_TAG_TEXTLANG,                    /* Text-with-language value */
+  IPP_TAG_NAMELANG,                    /* Name-with-language value */
+  IPP_TAG_END_COLLECTION,              /* End of collection value */
+  IPP_TAG_TEXT = 0x41,                 /* Text value */
+  IPP_TAG_NAME,                                /* Name value */
+  IPP_TAG_RESERVED_STRING,             /* Reserved for future string value @private@ */
+  IPP_TAG_KEYWORD,                     /* Keyword value */
+  IPP_TAG_URI,                         /* URI value */
+  IPP_TAG_URISCHEME,                   /* URI scheme value */
+  IPP_TAG_CHARSET,                     /* Character set value */
+  IPP_TAG_LANGUAGE,                    /* Language value */
+  IPP_TAG_MIMETYPE,                    /* MIME media type value */
+  IPP_TAG_MEMBERNAME,                  /* Collection member name value */
+  IPP_TAG_EXTENSION = 0x7f,            /* Extension point for 32-bit tags */
+  IPP_TAG_MASK = 0x7fffffff,           /* Mask for copied attribute values @private@ */
+  /* The following expression is used to avoid compiler warnings with +/-0x80000000 */
+  IPP_TAG_COPY = -0x7fffffff-1         /* Bitflag for copied attribute values @private@ */
+} ipp_tag_t;
 
-typedef struct ipp_attribute_s         /**** Attribute ****/
-{
-  struct ipp_attribute_s *next;                /* Next attribute in list */
-  ipp_tag_t    group_tag,              /* Job/Printer/Operation group tag */
-               value_tag;              /* What type of value is it? */
-  char         *name;                  /* Name of attribute */
-  int          num_values;             /* Number of values */
-  ipp_value_t  values[1];              /* Values */
-} ipp_attribute_t;
-
-struct ipp_s                           /**** IPP Request/Response/Notification ****/
-{
-  ipp_state_t  state;                  /* State of request */
-  ipp_request_t        request;                /* Request header */
-  ipp_attribute_t *attrs;              /* Attributes */
-  ipp_attribute_t *last;               /* Last attribute in list */
-  ipp_attribute_t *current;            /* Current attribute (for read/write) */
-  ipp_tag_t    curtag;                 /* Current attribute group tag */
+typedef unsigned char ipp_uchar_t;     /**** Unsigned 8-bit integer/character ****/
+typedef struct _ipp_s ipp_t;           /**** IPP request/response data ****/
+typedef struct _ipp_attribute_s ipp_attribute_t;
+                                       /**** IPP attribute ****/
 
 /**** New in CUPS 1.2 ****/
-  ipp_attribute_t *prev;               /* Previous attribute (for read) @since CUPS 1.2/Mac OS X 10.5@ */
+typedef ssize_t        (*ipp_iocb_t)(void *context, ipp_uchar_t *buffer, size_t bytes);
+                                       /**** IPP IO Callback Function @since CUPS 1.2/Mac OS X 10.5@ ****/
 
-/**** New in CUPS 1.4.4 ****/
-  int          use;                    /* Use count @since CUPS 1.4.4/Mac OS X 10.6.?@ */
-};
+/**** New in CUPS 1.6 ****/
+typedef int (*ipp_copycb_t)(void *context, ipp_t *dst, ipp_attribute_t *attr);
 
 
 /*
@@ -438,10 +380,10 @@ extern ipp_attribute_t    *ippAddBooleans(ipp_t *ipp, ipp_tag_t group,
 extern ipp_attribute_t *ippAddDate(ipp_t *ipp, ipp_tag_t group,
                                    const char *name, const ipp_uchar_t *value);
 extern ipp_attribute_t *ippAddInteger(ipp_t *ipp, ipp_tag_t group,
-                                      ipp_tag_t type, const char *name,
+                                      ipp_tag_t value_tag, const char *name,
                                       int value);
 extern ipp_attribute_t *ippAddIntegers(ipp_t *ipp, ipp_tag_t group,
-                                       ipp_tag_t type, const char *name,
+                                       ipp_tag_t value_tag, const char *name,
                                        int num_values, const int *values);
 extern ipp_attribute_t *ippAddRange(ipp_t *ipp, ipp_tag_t group,
                                     const char *name, int lower, int upper);
@@ -457,19 +399,19 @@ extern ipp_attribute_t    *ippAddResolutions(ipp_t *ipp, ipp_tag_t group,
                                           const int *yres);
 extern ipp_attribute_t *ippAddSeparator(ipp_t *ipp);
 extern ipp_attribute_t *ippAddString(ipp_t *ipp, ipp_tag_t group,
-                                     ipp_tag_t type, const char *name,
-                                     const char *charset, const char *value);
+                                     ipp_tag_t value_tag, const char *name,
+                                     const char *language, const char *value);
 extern ipp_attribute_t *ippAddStrings(ipp_t *ipp, ipp_tag_t group,
-                                      ipp_tag_t type, const char *name,
-                                      int num_values, const char *charset,
+                                      ipp_tag_t value_tag, const char *name,
+                                      int num_values, const char *language,
                                       const char * const *values);
 extern time_t          ippDateToTime(const ipp_uchar_t *date);
 extern void            ippDelete(ipp_t *ipp);
 extern const char      *ippErrorString(ipp_status_t error);
 extern ipp_attribute_t *ippFindAttribute(ipp_t *ipp, const char *name,
-                                         ipp_tag_t type);
+                                         ipp_tag_t value_tag);
 extern ipp_attribute_t *ippFindNextAttribute(ipp_t *ipp, const char *name,
-                                             ipp_tag_t type);
+                                             ipp_tag_t value_tag);
 extern size_t          ippLength(ipp_t *ipp);
 extern ipp_t           *ippNew(void);
 extern ipp_state_t     ippRead(http_t *http, ipp_t *ipp);
@@ -488,7 +430,7 @@ extern void         ippDeleteAttribute(ipp_t *ipp, ipp_attribute_t *attr) _CUPS_API_1_1
 extern ipp_state_t     ippReadFile(int fd, ipp_t *ipp) _CUPS_API_1_1_19;
 extern ipp_state_t     ippWriteFile(int fd, ipp_t *ipp) _CUPS_API_1_1_19;
 
-/**** New in CUPS 1.2 ****/
+/**** New in CUPS 1.2/Mac OS X 10.5 ****/
 extern ipp_attribute_t *ippAddOctetString(ipp_t *ipp, ipp_tag_t group,
                                           const char *name,
                                           const void *data, int datalen) _CUPS_API_1_2;
@@ -501,10 +443,70 @@ extern ipp_state_t        ippReadIO(void *src, ipp_iocb_t cb, int blocking,
 extern ipp_state_t     ippWriteIO(void *dst, ipp_iocb_t cb, int blocking,
                                   ipp_t *parent, ipp_t *ipp) _CUPS_API_1_2;
 
-/**** New in CUPS 1.4 ****/
+/**** New in CUPS 1.4/Mac OS X 10.6 ****/
 extern const char      *ippTagString(ipp_tag_t tag) _CUPS_API_1_4;
 extern ipp_tag_t       ippTagValue(const char *name) _CUPS_API_1_4;
 
+/**** New in CUPS 1.6 ****/
+extern ipp_attribute_t *ippAddOutOfBand(ipp_t *ipp, ipp_tag_t group, ipp_tag_t value_tag,
+                                        const char *name);
+extern size_t          ippAttributeString(ipp_attribute_t *attr, char *buffer,
+                                          size_t bufsize) _CUPS_API_1_6;
+extern ipp_attribute_t *ippCopyAttribute(ipp_t *dst, ipp_attribute_t *attr,
+                                        int quickcopy) _CUPS_API_1_6;
+extern int             ippCopyAttributes(ipp_t *dst, ipp_t *src,
+                                         int quickcopy, ipp_copycb_t cb, void *context)
+                                         _CUPS_API_1_6;
+extern int             ippDeleteValues(ipp_t *ipp, ipp_attribute_t *attr, int element,
+                                       int count) _CUPS_API_1_6;
+extern const char      *ippEnumString(const char *attrname, int enumvalue) _CUPS_API_1_6;
+extern int             ippEnumValue(const char *attrname, const char *enumstring)
+                                    _CUPS_API_1_6;
+extern ipp_attribute_t *ippFirstAttribute(ipp_t *ipp) _CUPS_API_1_6;
+extern int             ippGetBoolean(ipp_attribute_t *attr, int element)
+                                     _CUPS_API_1_6;
+extern ipp_t           *ippGetCollection(ipp_attribute_t *attr,
+                                         int element) _CUPS_API_1_6;
+extern int             ippGetCount(ipp_attribute_t *attr) _CUPS_API_1_6;
+extern ipp_tag_t       ippGetGroupTag(ipp_attribute_t *attr) _CUPS_API_1_6;
+extern int             ippGetInteger(ipp_attribute_t *attr, int element)
+                                     _CUPS_API_1_6;
+extern const char      *ippGetName(ipp_attribute_t *attr) _CUPS_API_1_6;
+extern ipp_op_t                ippGetOperation(ipp_t *ipp) _CUPS_API_1_6;
+extern int             ippGetRequestId(ipp_t *ipp) _CUPS_API_1_6;
+extern int             ippGetResolution(ipp_attribute_t *attr, int element,
+                                        int *yres, ipp_res_t *units) _CUPS_API_1_6;
+extern ipp_status_t    ippGetStatusCode(ipp_t *ipp) _CUPS_API_1_6;
+extern const char      *ippGetString(ipp_attribute_t *attr, int element,
+                                     const char **language) _CUPS_API_1_6;
+extern ipp_tag_t       ippGetValueTag(ipp_attribute_t *attr) _CUPS_API_1_6;
+extern int             ippGetVersion(ipp_t *ipp, int *minor) _CUPS_API_1_6;
+extern ipp_attribute_t *ippNextAttribute(ipp_t *ipp) _CUPS_API_1_6;
+extern int             ippSetBoolean(ipp_t *ipp, ipp_attribute_t **attr,
+                                     int element, int boolvalue) _CUPS_API_1_6;
+extern int             ippSetCollection(ipp_t *ipp, ipp_attribute_t **attr,
+                                        int element, ipp_t *colvalue) _CUPS_API_1_6;
+extern int             ippSetGroupTag(ipp_t *ipp, ipp_attribute_t **attr,
+                                      ipp_tag_t group_tag) _CUPS_API_1_6;
+extern int             ippSetInteger(ipp_t *ipp, ipp_attribute_t **attr,
+                                     int element, int intvalue) _CUPS_API_1_6;
+extern int             ippSetName(ipp_t *ipp, ipp_attribute_t **attr, const char *name)
+                                  _CUPS_API_1_6;
+extern int             ippSetOperation(ipp_t *ipp, ipp_op_t op) _CUPS_API_1_6;
+extern int             ippSetRange(ipp_t *ipp, ipp_attribute_t **attr, int element,
+                                   int lowervalue, int uppervalue) _CUPS_API_1_6;
+extern int             ippSetRequestId(ipp_t *ipp, int request_id)
+                                       _CUPS_API_1_6;
+extern int             ippSetResolution(ipp_t *ipp, ipp_attribute_t **attr,
+                                        int element, ipp_res_t unitsvalue,
+                                        int xresvalue, int yresvalue) _CUPS_API_1_6;
+extern int             ippSetStatusCode(ipp_t *ipp, ipp_status_t status) _CUPS_API_1_6;
+extern int             ippSetString(ipp_t *ipp, ipp_attribute_t **attr,
+                                    int element, const char *strvalue) _CUPS_API_1_6;
+extern int             ippSetValueTag(ipp_t *ipp, ipp_attribute_t **attr,
+                                      ipp_tag_t value_tag) _CUPS_API_1_6;
+extern int             ippSetVersion(ipp_t *ipp, int major, int minor) _CUPS_API_1_6;
+
 
 /*
  * C++ magic...
index 4d095537a0118a9b3a28f9b7b284449f2d81e1b9..f500e771207c4ca568ce80da7eb298315cf7d699 100644 (file)
@@ -50,9 +50,7 @@ _httpPeek
 _httpResolveURI
 _httpSetTimeout
 _httpWait
-_ippAddAttr
 _ippFindOption
-_ippFreeAttr
 _ppdFreeLanguages
 _ppdGetEncoding
 _ppdGetLanguages
index 14afc8d5f0c4846d5c9cb16927e20395b15e3098..bdab8742479be509954ae07a0152be3502598df7 100644 (file)
@@ -758,7 +758,7 @@ print_attributes(ipp_t *ipp,                /* I - IPP request */
   int                  i;              /* Looping var */
   ipp_tag_t            group;          /* Current group */
   ipp_attribute_t      *attr;          /* Current attribute */
-  ipp_value_t          *val;           /* Current value */
+  _ipp_value_t         *val;           /* Current value */
   static const char * const tags[] =   /* Value/group tag strings */
                        {
                          "reserved-00",
index 9c7e40d853e49cbcfc06d2537c72345f54aa526a..7b2f8a1a2b0dd925bb77810c00881aba6280f845 100644 (file)
@@ -632,7 +632,7 @@ print_attributes(ipp_t *ipp,                /* I - IPP request */
       fprintf(stderr, "DEBUG: %*s%s:\n\n", indent - 4, "", ippTagString(group));
     }
 
-    _ippAttrString(attr, buffer, sizeof(buffer));
+    ippAttributeString(attr, buffer, sizeof(buffer));
 
     fprintf(stderr, "DEBUG: %*s%s (%s%s) %s", indent, "", attr->name,
             attr->num_values > 1 ? "1setOf " : "",
index 1094a38534facf4e7febd002bf74be827054c723..80fad631edc9f1f4c68a1abbffade00433e0bce0 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   RSS notifier for CUPS.
  *
- *   Copyright 2007-2010 by Apple Inc.
+ *   Copyright 2007-2011 by Apple Inc.
  *   Copyright 2007 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -33,6 +33,7 @@
 #include <cups/string-private.h>
 #include <cups/array.h>
 #include <sys/select.h>
+#include <cups/ipp-private.h>  /* TODO: Update so we don't need this */
 
 
 /*
index 9b675743d29ec7da4d728fbca9b528a150a6e6d5..c42bd84fc9f4eec0df9f2f9c7dff3d236f192dd6 100644 (file)
@@ -113,7 +113,7 @@ print_attributes(ipp_t *ipp,                /* I - IPP request */
       fprintf(stderr, "DEBUG: %*s%s:\n\n", indent - 4, "", ippTagString(group));
     }
 
-    _ippAttrString(attr, buffer, sizeof(buffer));
+    ippAttributeString(attr, buffer, sizeof(buffer));
 
     fprintf(stderr, "DEBUG: %*s%s (%s%s) %s", indent, "", attr->name,
             attr->num_values > 1 ? "1setOf " : "",
index b9903d160818311e3b412122e1436565e5a246d1..f54232fcd4a72bb7960383db55171aa1a06910cc 100644 (file)
@@ -45,7 +45,6 @@
  *                                 feed URI.
  *   check_quotas()              - Check quotas for a printer and user.
  *   close_job()                 - Close a multi-file job.
- *   copy_attribute()            - Copy a single attribute.
  *   copy_attrs()                - Copy attributes from one request to another.
  *   copy_banner()               - Copy a banner file to the requests directory
  *                                 for the specified job.
@@ -169,8 +168,6 @@ static void cancel_job(cupsd_client_t *con, ipp_attribute_t *uri);
 static void    cancel_subscription(cupsd_client_t *con, int id);
 static int     check_rss_recipient(const char *recipient);
 static int     check_quotas(cupsd_client_t *con, cupsd_printer_t *p);
-static ipp_attribute_t *copy_attribute(ipp_t *to, ipp_attribute_t *attr,
-                                       int quickcopy);
 static void    close_job(cupsd_client_t *con, ipp_attribute_t *uri);
 static void    copy_attrs(ipp_t *to, ipp_t *from, cups_array_t *ra,
                           ipp_tag_t group, int quickcopy,
@@ -1717,10 +1714,10 @@ add_job(cupsd_client_t  *con,           /* I - Client connection */
            {
              _cupsStrFree(attr->values[i].string.text);
              attr->values[i].string.text = NULL;
-             if (attr->values[i].string.charset)
+             if (attr->values[i].string.language)
              {
-               _cupsStrFree(attr->values[i].string.charset);
-               attr->values[i].string.charset = NULL;
+               _cupsStrFree(attr->values[i].string.language);
+               attr->values[i].string.language = NULL;
              }
             }
 
@@ -2298,7 +2295,7 @@ add_job_subscriptions(
       * Free and remove this attribute...
       */
 
-      _ippFreeAttr(attr);
+      ippDeleteAttribute(NULL, attr);
 
       if (prev)
         prev->next = next;
@@ -5048,192 +5045,6 @@ close_job(cupsd_client_t  *con,         /* I - Client connection */
 }
 
 
-/*
- * 'copy_attribute()' - Copy a single attribute.
- */
-
-static ipp_attribute_t *               /* O - New attribute */
-copy_attribute(
-    ipp_t           *to,               /* O - Destination request/response */
-    ipp_attribute_t *attr,             /* I - Attribute to copy */
-    int             quickcopy)         /* I - Do a quick copy? */
-{
-  int                  i;              /* Looping var */
-  ipp_attribute_t      *toattr;        /* Destination attribute */
-
-
-  cupsdLogMessage(CUPSD_LOG_DEBUG2,
-                  "copy_attribute(%p, %p[%s,%x,%x])", to, attr,
-                 attr->name ? attr->name : "(null)", attr->group_tag,
-                 attr->value_tag);
-
-  switch (attr->value_tag & ~IPP_TAG_COPY)
-  {
-    case IPP_TAG_ZERO :
-        toattr = ippAddSeparator(to);
-       break;
-
-    case IPP_TAG_INTEGER :
-    case IPP_TAG_ENUM :
-        toattr = ippAddIntegers(to, attr->group_tag, attr->value_tag,
-                               attr->name, attr->num_values, NULL);
-
-        for (i = 0; i < attr->num_values; i ++)
-         toattr->values[i].integer = attr->values[i].integer;
-        break;
-
-    case IPP_TAG_BOOLEAN :
-        toattr = ippAddBooleans(to, attr->group_tag, attr->name,
-                               attr->num_values, NULL);
-
-        for (i = 0; i < attr->num_values; i ++)
-         toattr->values[i].boolean = attr->values[i].boolean;
-        break;
-
-    case IPP_TAG_STRING :
-    case IPP_TAG_TEXT :
-    case IPP_TAG_NAME :
-    case IPP_TAG_KEYWORD :
-    case IPP_TAG_URI :
-    case IPP_TAG_URISCHEME :
-    case IPP_TAG_CHARSET :
-    case IPP_TAG_LANGUAGE :
-    case IPP_TAG_MIMETYPE :
-        toattr = ippAddStrings(to, attr->group_tag,
-                              (ipp_tag_t)(attr->value_tag | quickcopy),
-                              attr->name, attr->num_values, NULL, NULL);
-
-        if (quickcopy)
-       {
-          for (i = 0; i < attr->num_values; i ++)
-           toattr->values[i].string.text = attr->values[i].string.text;
-        }
-       else if (attr->value_tag & IPP_TAG_COPY)
-       {
-          for (i = 0; i < attr->num_values; i ++)
-           toattr->values[i].string.text =
-               _cupsStrAlloc(attr->values[i].string.text);
-       }
-       else
-       {
-          for (i = 0; i < attr->num_values; i ++)
-           toattr->values[i].string.text =
-               _cupsStrRetain(attr->values[i].string.text);
-       }
-        break;
-
-    case IPP_TAG_DATE :
-        toattr = ippAddDate(to, attr->group_tag, attr->name,
-                           attr->values[0].date);
-        break;
-
-    case IPP_TAG_RESOLUTION :
-        toattr = ippAddResolutions(to, attr->group_tag, attr->name,
-                                  attr->num_values, IPP_RES_PER_INCH,
-                                  NULL, NULL);
-
-        for (i = 0; i < attr->num_values; i ++)
-       {
-         toattr->values[i].resolution.xres  = attr->values[i].resolution.xres;
-         toattr->values[i].resolution.yres  = attr->values[i].resolution.yres;
-         toattr->values[i].resolution.units = attr->values[i].resolution.units;
-       }
-        break;
-
-    case IPP_TAG_RANGE :
-        toattr = ippAddRanges(to, attr->group_tag, attr->name,
-                             attr->num_values, NULL, NULL);
-
-        for (i = 0; i < attr->num_values; i ++)
-       {
-         toattr->values[i].range.lower = attr->values[i].range.lower;
-         toattr->values[i].range.upper = attr->values[i].range.upper;
-       }
-        break;
-
-    case IPP_TAG_TEXTLANG :
-    case IPP_TAG_NAMELANG :
-        toattr = ippAddStrings(to, attr->group_tag,
-                              (ipp_tag_t)(attr->value_tag | quickcopy),
-                              attr->name, attr->num_values, NULL, NULL);
-
-        if (quickcopy)
-       {
-          for (i = 0; i < attr->num_values; i ++)
-         {
-            toattr->values[i].string.charset = attr->values[i].string.charset;
-           toattr->values[i].string.text    = attr->values[i].string.text;
-          }
-        }
-       else if (attr->value_tag & IPP_TAG_COPY)
-       {
-          for (i = 0; i < attr->num_values; i ++)
-         {
-           if (!i)
-              toattr->values[i].string.charset =
-                 _cupsStrAlloc(attr->values[i].string.charset);
-           else
-              toattr->values[i].string.charset =
-                 toattr->values[0].string.charset;
-
-           toattr->values[i].string.text =
-               _cupsStrAlloc(attr->values[i].string.text);
-          }
-        }
-       else
-       {
-          for (i = 0; i < attr->num_values; i ++)
-         {
-           if (!i)
-              toattr->values[i].string.charset =
-                 _cupsStrRetain(attr->values[i].string.charset);
-           else
-              toattr->values[i].string.charset =
-                 toattr->values[0].string.charset;
-
-           toattr->values[i].string.text =
-               _cupsStrRetain(attr->values[i].string.text);
-          }
-        }
-        break;
-
-    case IPP_TAG_BEGIN_COLLECTION :
-        toattr = ippAddCollections(to, attr->group_tag, attr->name,
-                                  attr->num_values, NULL);
-
-        for (i = 0; i < attr->num_values; i ++)
-       {
-         toattr->values[i].collection = attr->values[i].collection;
-         attr->values[i].collection->use ++;
-       }
-        break;
-
-    default :
-        toattr = ippAddIntegers(to, attr->group_tag, attr->value_tag,
-                               attr->name, attr->num_values, NULL);
-
-        for (i = 0; i < attr->num_values; i ++)
-       {
-         toattr->values[i].unknown.length = attr->values[i].unknown.length;
-
-         if (toattr->values[i].unknown.length > 0)
-         {
-           if ((toattr->values[i].unknown.data =
-                    malloc(toattr->values[i].unknown.length)) == NULL)
-             toattr->values[i].unknown.length = 0;
-           else
-             memcpy(toattr->values[i].unknown.data,
-                    attr->values[i].unknown.data,
-                    toattr->values[i].unknown.length);
-         }
-       }
-        break; /* anti-compiler-warning-code */
-  }
-
-  return (toattr);
-}
-
-
 /*
  * 'copy_attrs()' - Copy attributes from one request to another.
  */
@@ -5301,7 +5112,7 @@ copy_attrs(ipp_t        *to,              /* I - Destination request */
           !strcmp(fromattr->name, "media-col-database")))
        continue;
 
-      copy_attribute(to, fromattr, quickcopy);
+      ippCopyAttribute(to, fromattr, quickcopy);
     }
   }
 }
@@ -9741,14 +9552,14 @@ read_job_ticket(cupsd_client_t *con)    /* I - Client connection */
       if (con->request->last == attr2)
         con->request->last = prev2;
 
-      _ippFreeAttr(attr2);
+      ippDeleteAttribute(NULL, attr2);
     }
 
    /*
     * Add new option by copying it...
     */
 
-    copy_attribute(con->request, attr, 0);
+    ippCopyAttribute(con->request, attr, 0);
   }
 
  /*
@@ -11205,9 +11016,8 @@ set_job_attrs(cupsd_client_t  *con,     /* I - Client connection */
       send_ipp_status(con, IPP_ATTRIBUTES_NOT_SETTABLE,
                       _("%s cannot be changed."), attr->name);
 
-      if ((attr2 = copy_attribute(con->response, attr, 0)) != NULL)
-        attr2->group_tag = IPP_TAG_UNSUPPORTED_GROUP;
-
+      attr2 = ippCopyAttribute(con->response, attr, 0);
+      ippSetGroupTag(con->response, &attr2, IPP_TAG_UNSUPPORTED_GROUP);
       continue;
     }
 
@@ -11221,8 +11031,8 @@ set_job_attrs(cupsd_client_t  *con,     /* I - Client connection */
       {
        send_ipp_status(con, IPP_REQUEST_VALUE, _("Bad job-priority value."));
 
-       if ((attr2 = copy_attribute(con->response, attr, 0)) != NULL)
-          attr2->group_tag = IPP_TAG_UNSUPPORTED_GROUP;
+       attr2 = ippCopyAttribute(con->response, attr, 0);
+       ippSetGroupTag(con->response, &attr2, IPP_TAG_UNSUPPORTED_GROUP);
       }
       else if (job->state_value >= IPP_JOB_PROCESSING)
       {
@@ -11251,8 +11061,8 @@ set_job_attrs(cupsd_client_t  *con,     /* I - Client connection */
       {
        send_ipp_status(con, IPP_REQUEST_VALUE, _("Bad job-state value."));
 
-       if ((attr2 = copy_attribute(con->response, attr, 0)) != NULL)
-          attr2->group_tag = IPP_TAG_UNSUPPORTED_GROUP;
+       attr2 = ippCopyAttribute(con->response, attr, 0);
+       ippSetGroupTag(con->response, &attr2, IPP_TAG_UNSUPPORTED_GROUP);
       }
       else
       {
@@ -11326,13 +11136,13 @@ set_job_attrs(cupsd_client_t  *con,   /* I - Client connection */
       if (job->attrs->last == attr2)
         job->attrs->last = job->attrs->prev;
 
-      _ippFreeAttr(attr2);
+      ippDeleteAttribute(NULL, attr2);
 
      /*
       * Then copy the attribute...
       */
 
-      copy_attribute(job->attrs, attr, 0);
+      ippCopyAttribute(job->attrs, attr, 0);
 
      /*
       * See if the job-name or job-hold-until is being changed.
@@ -11373,7 +11183,7 @@ set_job_attrs(cupsd_client_t  *con,     /* I - Client connection */
         if (attr2 == job->attrs->last)
          job->attrs->last = job->attrs->prev;
 
-        _ippFreeAttr(attr2);
+        ippDeleteAttribute(NULL, attr2);
 
         event |= CUPSD_EVENT_JOB_CONFIG_CHANGED;
       }
@@ -11384,7 +11194,7 @@ set_job_attrs(cupsd_client_t  *con,     /* I - Client connection */
       * Add new option by copying it...
       */
 
-      copy_attribute(job->attrs, attr, 0);
+      ippCopyAttribute(job->attrs, attr, 0);
 
       event |= CUPSD_EVENT_JOB_CONFIG_CHANGED;
     }
index 69208018debc276ae5a1ead3198f6f9be0608a53..959a107da0a86b20977844ba1db79adb5c384d0d 100644 (file)
@@ -3941,7 +3941,7 @@ load_ppd(cupsd_printer_t *p)              /* I - Printer */
   _pwg_map_t   *pwgsource,             /* Current PWG source */
                *pwgtype;               /* Current PWG type */
   ipp_attribute_t *attr;               /* Attribute data */
-  ipp_value_t  *val;                   /* Attribute value */
+  _ipp_value_t *val;                   /* Attribute value */
   int          num_finishings,         /* Number of finishings */
                finishings[5];          /* finishings-supported values */
   int          num_qualities,          /* Number of print-quality values */
index 55b17b888d21da934c2830d746d645fcf4c37f95..69c7791f796f49a11448eabb980b80af4624e842 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Scheduler notification tester for CUPS.
  *
- *   Copyright 2007-2010 by Apple Inc.
+ *   Copyright 2007-2011 by Apple Inc.
  *   Copyright 2006-2007 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -28,6 +28,7 @@
 #include <cups/debug-private.h>
 #include <cups/string-private.h>
 #include <signal.h>
+#include <cups/ipp-private.h>  /* TODO: Update so we don't need this */
 
 
 /*
@@ -302,7 +303,7 @@ print_attributes(ipp_t *ipp,                /* I - IPP request */
   int                  i;              /* Looping var */
   ipp_tag_t            group;          /* Current group */
   ipp_attribute_t      *attr;          /* Current attribute */
-  ipp_value_t          *val;           /* Current value */
+  _ipp_value_t         *val;           /* Current value */
   static const char * const tags[] =   /* Value/group tag strings */
                        {
                          "reserved-00",
index c96ccfcf6fe286234c33eaa6017633fd8f3841b3..cf116c32307d2937c2e65e495876b6484dc0b57e 100644 (file)
@@ -17,7 +17,7 @@
 echo "Add Printer Test"
 echo ""
 echo "    lpadmin -p Test3 -v file:/dev/null -E -m drv:///sample.drv/deskjet.ppd"
-../systemv/lpadmin -p Test3 -v file:/dev/null -E -m drv:///sample.drv/deskjet.ppd 2>&1
+$VALGRIND ../systemv/lpadmin -p Test3 -v file:/dev/null -E -m drv:///sample.drv/deskjet.ppd 2>&1
 if test $? != 0; then
        echo "    FAILED"
        exit 1
@@ -29,7 +29,7 @@ echo ""
 echo "Modify Printer Test"
 echo ""
 echo "    lpadmin -p Test3 -v file:/tmp/Test3 -o PageSize=A4"
-../systemv/lpadmin -p Test3 -v file:/tmp/Test3 -o PageSize=A4 2>&1
+$VALGRIND ../systemv/lpadmin -p Test3 -v file:/tmp/Test3 -o PageSize=A4 2>&1
 if test $? != 0; then
        echo "    FAILED"
        exit 1
@@ -41,7 +41,7 @@ echo ""
 echo "Delete Printer Test"
 echo ""
 echo "    lpadmin -x Test3"
-../systemv/lpadmin -x Test3 2>&1
+$VALGRIND ../systemv/lpadmin -x Test3 2>&1
 if test $? != 0; then
        echo "    FAILED"
        exit 1
index c1a3f6ce2d3a23441815d787ecfa114c2ca950fb..f1957a8b2a898091b2dc2cf4b536f779dcdfb0a7 100644 (file)
@@ -17,7 +17,7 @@
 echo "LPC Test"
 echo ""
 echo "    lpc status"
-../berkeley/lpc status 2>&1
+$VALGRIND ../berkeley/lpc status 2>&1
 if test $? != 0; then
        echo "    FAILED"
        exit 1
index ef895ebc30e98deda80268a8aa9a92a72e8944f7..03087d2ccf537d88e175856cee9eaea29efb8a4c 100644 (file)
@@ -17,7 +17,7 @@
 echo "LPQ Test"
 echo ""
 echo "    lpq -P Test1"
-../berkeley/lpq -P Test1 2>&1
+$VALGRIND ../berkeley/lpq -P Test1 2>&1
 if test $? != 0; then
        echo "    FAILED"
        exit 1
index 83c8585bb8a9bf366b15513d345aeba2e5dd984d..c69003e42c46c583e4563dd5e3d67e2262087ff4 100644 (file)
@@ -4,7 +4,7 @@
 #
 #   Test the lpstat command.
 #
-#   Copyright 2007-2009 by Apple Inc.
+#   Copyright 2007-2011 by Apple Inc.
 #   Copyright 1997-2005 by Easy Software Products, all rights reserved.
 #
 #   These coded instructions, statements, and computer programs are the
@@ -17,7 +17,7 @@
 echo "LPSTAT Test"
 echo ""
 echo "    lpstat -t"
-../systemv/lpstat -t 2>&1
+$VALGRIND ../systemv/lpstat -t 2>&1
 if test $? != 0; then
        echo "    FAILED"
        exit 1
@@ -29,7 +29,7 @@ echo ""
 echo "LPSTAT Test"
 echo ""
 echo "    lpstat -H"
-server="`../systemv/lpstat -H 2>&1`"
+server="`$VALGRIND ../systemv/lpstat -H 2>&1`"
 if test $? != 0 -o "x$server" != xlocalhost:8631; then
        echo "    FAILED ($server)"
        exit 1
index 442ce5f8d0a6c8020b47576b38335fcc45756830..1acd881c4a8c35edd3fcf2ef99089469155ec5ad 100644 (file)
@@ -17,7 +17,7 @@
 echo "LP Default Test"
 echo ""
 echo "    lp testfile.pdf"
-../systemv/lp testfile.pdf 2>&1
+$VALGRIND ../systemv/lp testfile.pdf 2>&1
 if test $? != 0; then
        echo "    FAILED"
        exit 1
@@ -29,7 +29,7 @@ echo ""
 echo "LP Destination Test"
 echo ""
 echo "    lp -d Test2 testfile.jpg"
-../systemv/lp -d Test2 testfile.jpg 2>&1
+$VALGRIND ../systemv/lp -d Test2 testfile.jpg 2>&1
 if test $? != 0; then
        echo "    FAILED"
        exit 1
@@ -41,7 +41,7 @@ echo ""
 echo "LP Options Test"
 echo ""
 echo "    lp -d Test1 -P 1-4 -o job-sheets=classified,classified testfile.pdf"
-../systemv/lp -d Test1 -P 1-4 -o job-sheets=classified,classified testfile.pdf 2>&1
+$VALGRIND ../systemv/lp -d Test1 -P 1-4 -o job-sheets=classified,classified testfile.pdf 2>&1
 if test $? != 0; then
        echo "    FAILED"
        exit 1
@@ -58,12 +58,12 @@ i=0
 while test $i -lt $1; do
        j=1
        while test $j -le $2; do
-               ../systemv/lp -d test-$j testfile.jpg 2>&1
+               $VALGRIND ../systemv/lp -d test-$j testfile.jpg 2>&1
                j=`expr $j + 1`
        done
 
-       ../systemv/lp -d Test1 testfile.jpg 2>&1 &
-       ../systemv/lp -d Test2 testfile.jpg 2>&1 &
+       $VALGRIND ../systemv/lp -d Test1 testfile.jpg 2>&1 &
+       $VALGRIND ../systemv/lp -d Test2 testfile.jpg 2>&1 &
        lppid=$!
 
        i=`expr $i + 1`
index 64bbeb1133435b8fc3fda8d4652bd750be59dee6..8e9b982c0b896df94f8943d1bc9f955df776c323 100644 (file)
@@ -17,7 +17,7 @@
 echo "LPR Default Test"
 echo ""
 echo "    lpr testfile.pdf"
-../berkeley/lpr testfile.pdf 2>&1
+$VALGRIND ../berkeley/lpr testfile.pdf 2>&1
 if test $? != 0; then
        echo "    FAILED"
        exit 1
@@ -29,7 +29,7 @@ echo ""
 echo "LPR Destination Test"
 echo ""
 echo "    lpr -P Test2 testfile.jpg"
-../berkeley/lpr -P Test2 testfile.jpg 2>&1
+$VALGRIND ../berkeley/lpr -P Test2 testfile.jpg 2>&1
 if test $? != 0; then
        echo "    FAILED"
        exit 1
@@ -41,7 +41,7 @@ echo ""
 echo "LPR Options Test"
 echo ""
 echo "    lpr -P Test1 -o number-up=4 -o job-sheets=standard,none testfile.pdf"
-../berkeley/lpr -P Test1 -o number-up=4 -o job-sheets=standard,none testfile.pdf 2>&1
+$VALGRIND ../berkeley/lpr -P Test1 -o number-up=4 -o job-sheets=standard,none testfile.pdf 2>&1
 if test $? != 0; then
        echo "    FAILED"
        exit 1
@@ -58,12 +58,12 @@ i=0
 while test $i -lt $1; do
        j=1
        while test $j -le $2; do
-               ../berkeley/lpr -P test-$j testfile.jpg 2>&1
+               $VALGRIND ../berkeley/lpr -P test-$j testfile.jpg 2>&1
                j=`expr $j + 1`
        done
 
-       ../berkeley/lpr -P Test1 testfile.jpg 2>&1 &
-       ../berkeley/lpr -P Test2 testfile.jpg 2>&1 &
+       $VALGRIND ../berkeley/lpr -P Test1 testfile.jpg 2>&1 &
+       $VALGRIND ../berkeley/lpr -P Test2 testfile.jpg 2>&1 &
        lprpid=$!
 
        i=`expr $i + 1`
index e1ba395dfa74fb9ab9d366ead8a0f0aa9108d69e..482052d8631a7097bfad594a7982690c71ecc792 100644 (file)
@@ -4,7 +4,7 @@
 #
 #   Test the lprm command.
 #
-#   Copyright 2007 by Apple Inc.
+#   Copyright 2007-2011 by Apple Inc.
 #   Copyright 1997-2005 by Easy Software Products, all rights reserved.
 #
 #   These coded instructions, statements, and computer programs are the
@@ -17,9 +17,9 @@
 echo "LPRM Current Test"
 echo ""
 echo "    lpr -o job-hold-until=indefinite testfile.jpg"
-../berkeley/lpr -o job-hold-until=indefinite testfile.jpg 2>&1
+$VALGRIND ../berkeley/lpr -o job-hold-until=indefinite testfile.jpg 2>&1
 echo "    lprm"
-../berkeley/lprm 2>&1
+$VALGRIND ../berkeley/lprm 2>&1
 if test $? != 0; then
        echo "    FAILED"
        exit 1
@@ -31,9 +31,9 @@ echo ""
 echo "LPRM Destination Test"
 echo ""
 echo "    lpr -P Test1 -o job-hold-until=indefinite testfile.jpg"
-../berkeley/lpr -P Test1 -o job-hold-until=indefinite testfile.jpg 2>&1
+$VALGRIND ../berkeley/lpr -P Test1 -o job-hold-until=indefinite testfile.jpg 2>&1
 echo "    lprm Test1"
-../berkeley/lprm Test1 2>&1
+$VALGRIND ../berkeley/lprm Test1 2>&1
 if test $? != 0; then
        echo "    FAILED"
        exit 1
index ddc346040a22d33e685330ea5962f240add51967..3b2379a416c608dba19a3bdda135da3c661b45f9 100644 (file)
@@ -4,7 +4,7 @@
 #
 #   Test the cancel command.
 #
-#   Copyright 2007-2008 by Apple Inc.
+#   Copyright 2007-2011 by Apple Inc.
 #   Copyright 1997-2006 by Easy Software Products, all rights reserved.
 #
 #   These coded instructions, statements, and computer programs are the
@@ -17,9 +17,9 @@
 echo "Cancel Destination Test"
 echo ""
 echo "    lp -d Test1 -o job-hold-until=indefinite testfile.jpg"
-../systemv/lp -d Test1 -o job-hold-until=indefinite testfile.jpg 2>&1
+$VALGRIND ../systemv/lp -d Test1 -o job-hold-until=indefinite testfile.jpg 2>&1
 echo "    cancel Test1"
-../systemv/cancel Test1 2>&1
+$VALGRIND ../systemv/cancel Test1 2>&1
 if test $? != 0; then
        echo "    FAILED"
        exit 1
@@ -31,7 +31,7 @@ echo ""
 echo "Cancel All Test"
 echo ""
 echo "    cancel -a"
-../systemv/cancel -a 2>&1
+$VALGRIND ../systemv/cancel -a 2>&1
 if test $? != 0; then
        echo "    FAILED"
        exit 1
index d9bff8308b2c76b1685fc1bba4294023dc839d2c..adb041b0ad6a122acd732294f9ce9a2a6e35c65c 100644 (file)
@@ -4,7 +4,7 @@
 #
 #   Test the lpinfo command.
 #
-#   Copyright 2007-2008 by Apple Inc.
+#   Copyright 2007-2011 by Apple Inc.
 #   Copyright 1997-2005 by Easy Software Products, all rights reserved.
 #
 #   These coded instructions, statements, and computer programs are the
@@ -17,7 +17,7 @@
 echo "LPINFO Devices Test"
 echo ""
 echo "    lpinfo -v"
-../systemv/lpinfo -v 2>&1
+$VALGRIND ../systemv/lpinfo -v 2>&1
 if test $? != 0; then
        echo "    FAILED"
        exit 1
@@ -29,7 +29,7 @@ echo ""
 echo "LPINFO Drivers Test"
 echo ""
 echo "    lpinfo -m"
-../systemv/lpinfo -m 2>&1
+$VALGRIND ../systemv/lpinfo -m 2>&1
 if test $? != 0; then
        echo "    FAILED"
        exit 1
@@ -41,7 +41,7 @@ echo ""
 echo "LPINFO Drivers Test"
 echo ""
 echo "    lpinfo -m | grep -q sample.drv"
-../systemv/lpinfo -m | grep -q sample.drv 2>&1
+$VALGRIND ../systemv/lpinfo -m | grep -q sample.drv 2>&1
 if test $? != 0; then
        echo "    FAILED"
        exit 1
index 23b4ed9701b4f63210ce68db2ee5e21efc5a7832..ec05bda54e85bb63915c79035560945361f3f347 100644 (file)
@@ -18,7 +18,6 @@
  *   main()                      - Main entry to the sample server.
  *   clean_jobs()                - Clean out old (completed) jobs.
  *   compare_jobs()              - Compare two jobs.
- *   copy_attribute()            - Copy a single attribute.
  *   copy_attributes()           - Copy attributes from one request to
  *                                 another.
  *   copy_job_attrs()            - Copy job attributes to the response.
@@ -254,8 +253,6 @@ typedef struct _ipp_client_s                /**** Client data ****/
 
 static void            clean_jobs(_ipp_printer_t *printer);
 static int             compare_jobs(_ipp_job_t *a, _ipp_job_t *b);
-static ipp_attribute_t *copy_attribute(ipp_t *to, ipp_attribute_t *attr,
-                                       ipp_tag_t group_tag, int quickcopy);
 static void            copy_attributes(ipp_t *to, ipp_t *from, cups_array_t *ra,
                                        ipp_tag_t group_tag, int quickcopy);
 static void            copy_job_attributes(_ipp_client_t *client,
@@ -576,191 +573,6 @@ compare_jobs(_ipp_job_t *a,               /* I - First job */
 }
 
 
-/*
- * 'copy_attribute()' - Copy a single attribute.
- */
-
-static ipp_attribute_t *               /* O - New attribute */
-copy_attribute(
-    ipp_t           *to,               /* O - Destination request/response */
-    ipp_attribute_t *attr,             /* I - Attribute to copy */
-    ipp_tag_t       group_tag,         /* I - Group to put the copy in */
-    int             quickcopy)         /* I - Do a quick copy? */
-{
-  int                  i;              /* Looping var */
-  ipp_attribute_t      *toattr;        /* Destination attribute */
-
-
-  if (Verbosity && attr->name)
-  {
-    char       buffer[2048];           /* Attribute value */
-
-    _ippAttrString(attr, buffer, sizeof(buffer));
-
-    fprintf(stderr, "Copying %s (%s%s) %s\n", attr->name,
-           attr->num_values > 1 ? "1setOf " : "",
-           ippTagString(attr->value_tag & ~IPP_TAG_COPY), buffer);
-  }
-
-  switch (attr->value_tag & ~IPP_TAG_COPY)
-  {
-    case IPP_TAG_ZERO :
-        toattr = ippAddSeparator(to);
-       break;
-
-    case IPP_TAG_INTEGER :
-    case IPP_TAG_ENUM :
-        toattr = ippAddIntegers(to, group_tag, attr->value_tag,
-                               attr->name, attr->num_values, NULL);
-
-        for (i = 0; i < attr->num_values; i ++)
-         toattr->values[i].integer = attr->values[i].integer;
-        break;
-
-    case IPP_TAG_BOOLEAN :
-        toattr = ippAddBooleans(to, group_tag, attr->name,
-                               attr->num_values, NULL);
-
-        for (i = 0; i < attr->num_values; i ++)
-         toattr->values[i].boolean = attr->values[i].boolean;
-        break;
-
-    case IPP_TAG_TEXT :
-    case IPP_TAG_NAME :
-    case IPP_TAG_KEYWORD :
-    case IPP_TAG_URI :
-    case IPP_TAG_URISCHEME :
-    case IPP_TAG_CHARSET :
-    case IPP_TAG_LANGUAGE :
-    case IPP_TAG_MIMETYPE :
-        toattr = ippAddStrings(to, group_tag,
-                              (ipp_tag_t)(attr->value_tag | quickcopy),
-                              attr->name, attr->num_values, NULL, NULL);
-
-        if (quickcopy)
-       {
-          for (i = 0; i < attr->num_values; i ++)
-           toattr->values[i].string.text = attr->values[i].string.text;
-        }
-       else
-       {
-          for (i = 0; i < attr->num_values; i ++)
-           toattr->values[i].string.text =
-               _cupsStrAlloc(attr->values[i].string.text);
-       }
-        break;
-
-    case IPP_TAG_DATE :
-        toattr = ippAddDate(to, group_tag, attr->name,
-                           attr->values[0].date);
-        break;
-
-    case IPP_TAG_RESOLUTION :
-        toattr = ippAddResolutions(to, group_tag, attr->name,
-                                  attr->num_values, IPP_RES_PER_INCH,
-                                  NULL, NULL);
-
-        for (i = 0; i < attr->num_values; i ++)
-       {
-         toattr->values[i].resolution.xres  = attr->values[i].resolution.xres;
-         toattr->values[i].resolution.yres  = attr->values[i].resolution.yres;
-         toattr->values[i].resolution.units = attr->values[i].resolution.units;
-       }
-        break;
-
-    case IPP_TAG_RANGE :
-        toattr = ippAddRanges(to, group_tag, attr->name,
-                             attr->num_values, NULL, NULL);
-
-        for (i = 0; i < attr->num_values; i ++)
-       {
-         toattr->values[i].range.lower = attr->values[i].range.lower;
-         toattr->values[i].range.upper = attr->values[i].range.upper;
-       }
-        break;
-
-    case IPP_TAG_TEXTLANG :
-    case IPP_TAG_NAMELANG :
-        toattr = ippAddStrings(to, group_tag,
-                              (ipp_tag_t)(attr->value_tag | quickcopy),
-                              attr->name, attr->num_values, NULL, NULL);
-
-        if (quickcopy)
-       {
-          for (i = 0; i < attr->num_values; i ++)
-         {
-            toattr->values[i].string.charset = attr->values[i].string.charset;
-           toattr->values[i].string.text    = attr->values[i].string.text;
-          }
-        }
-       else
-       {
-          for (i = 0; i < attr->num_values; i ++)
-         {
-           if (!i)
-              toattr->values[i].string.charset =
-                 _cupsStrAlloc(attr->values[i].string.charset);
-           else
-              toattr->values[i].string.charset =
-                 toattr->values[0].string.charset;
-
-           toattr->values[i].string.text =
-               _cupsStrAlloc(attr->values[i].string.text);
-          }
-        }
-        break;
-
-    case IPP_TAG_BEGIN_COLLECTION :
-        toattr = ippAddCollections(to, group_tag, attr->name,
-                                  attr->num_values, NULL);
-
-        for (i = 0; i < attr->num_values; i ++)
-       {
-         toattr->values[i].collection = attr->values[i].collection;
-         attr->values[i].collection->use ++;
-       }
-        break;
-
-    case IPP_TAG_STRING :
-        if (quickcopy)
-       {
-         toattr = ippAddOctetString(to, group_tag, attr->name, NULL, 0);
-         toattr->value_tag |= quickcopy;
-         toattr->values[0].unknown.data   = attr->values[0].unknown.data;
-         toattr->values[0].unknown.length = attr->values[0].unknown.length;
-       }
-       else
-         toattr = ippAddOctetString(to, attr->group_tag, attr->name,
-                                    attr->values[0].unknown.data,
-                                    attr->values[0].unknown.length);
-        break;
-
-    default :
-        toattr = ippAddIntegers(to, group_tag, attr->value_tag,
-                               attr->name, attr->num_values, NULL);
-
-        for (i = 0; i < attr->num_values; i ++)
-       {
-         toattr->values[i].unknown.length = attr->values[i].unknown.length;
-
-         if (toattr->values[i].unknown.length > 0)
-         {
-           if ((toattr->values[i].unknown.data =
-                    malloc(toattr->values[i].unknown.length)) == NULL)
-             toattr->values[i].unknown.length = 0;
-           else
-             memcpy(toattr->values[i].unknown.data,
-                    attr->values[i].unknown.data,
-                    toattr->values[i].unknown.length);
-         }
-       }
-        break; /* anti-compiler-warning-code */
-  }
-
-  return (toattr);
-}
-
-
 /*
  * 'copy_attributes()' - Copy attributes from one request to another.
  */
@@ -789,7 +601,7 @@ copy_attributes(ipp_t        *to,   /* I - Destination request */
       continue;
 
     if (!ra || cupsArrayFind(ra, fromattr->name))
-      copy_attribute(to, fromattr, fromattr->group_tag, quickcopy);
+      ippCopyAttribute(to, fromattr, quickcopy);
   }
 }
 
@@ -1215,7 +1027,7 @@ create_printer(const char *servername,    /* I - Server hostname (NULL for default)
                                        /* media-size-supported value */
   ipp_t                        *media_col_default;
                                        /* media-col-default value */
-  ipp_value_t          *media_col_value;
+  _ipp_value_t         *media_col_value;
                                        /* Current media-col-database value */
   int                  k_supported;    /* Maximum file size supported */
 #ifdef HAVE_STATVFS
@@ -2084,7 +1896,7 @@ debug_attributes(const char *title,       /* I - Title */
 
     if (attr->name)
     {
-      _ippAttrString(attr, buffer, sizeof(buffer));
+      ippAttributeString(attr, buffer, sizeof(buffer));
       fprintf(stderr, "    %s (%s%s) %s\n", attr->name,
              attr->num_values > 1 ? "1setOf " : "",
              ippTagString(attr->value_tag), buffer);
@@ -4978,12 +4790,16 @@ respond_unsupported(
     _ipp_client_t   *client,           /* I - Client */
     ipp_attribute_t *attr)             /* I - Atribute */
 {
+  ipp_attribute_t      *temp;          /* Copy of attribute */
+
+
   if (!client->response->attrs)
     respond_ipp(client, IPP_ATTRIBUTES, "Unsupported %s %s%s value.",
                attr->name, attr->num_values > 1 ? "1setOf " : "",
                ippTagString(attr->value_tag));
 
-  copy_attribute(client->response, attr, IPP_TAG_UNSUPPORTED_GROUP, 0);
+  temp = ippCopyAttribute(client->response, attr, 0);
+  ippSetGroupTag(client->response, &temp, IPP_TAG_UNSUPPORTED_GROUP);
 }
 
 
index 4930f099c6582262a75d3bbf12f5193012aa3170..c9060905d57b90ecf69426489436754488a21b20 100644 (file)
@@ -1146,7 +1146,7 @@ do_tests(_cups_vars_t *vars,              /* I - Variables */
 
          if ((tempcol = realloc(lastcol, sizeof(ipp_attribute_t) +
                                          (lastcol->num_values + 1) *
-                                         sizeof(ipp_value_t))) == NULL)
+                                         sizeof(_ipp_value_t))) == NULL)
          {
            print_fatal_error("Unable to allocate memory on line %d.", linenum);
            pass = 0;
@@ -1499,21 +1499,22 @@ do_tests(_cups_vars_t *vars,            /* I - Variables */
        }
 
         expand_variables(vars, token, temp, sizeof(token));
+        attrptr = NULL;
 
         switch (value)
        {
          case IPP_TAG_BOOLEAN :
              if (!_cups_strcasecmp(token, "true"))
-               ippAddBoolean(request, group, attr, 1);
+               attrptr = ippAddBoolean(request, group, attr, 1);
               else
-               ippAddBoolean(request, group, attr, atoi(token));
+               attrptr = ippAddBoolean(request, group, attr, atoi(token));
              break;
 
          case IPP_TAG_INTEGER :
          case IPP_TAG_ENUM :
              if (!strchr(token, ','))
-               ippAddInteger(request, group, value, attr,
-                             strtol(token, &tokenptr, 0));
+               attrptr = ippAddInteger(request, group, value, attr,
+                                       strtol(token, &tokenptr, 0));
              else
              {
                int     values[100],    /* Values */
@@ -1532,7 +1533,7 @@ do_tests(_cups_vars_t *vars,              /* I - Variables */
                  num_values ++;
                }
 
-               ippAddIntegers(request, group, value, attr, num_values, values);
+               attrptr = ippAddIntegers(request, group, value, attr, num_values, values);
              }
 
              if (!tokenptr || *tokenptr)
@@ -1568,14 +1569,14 @@ do_tests(_cups_vars_t *vars,            /* I - Variables */
                }
 
                if (!_cups_strcasecmp(ptr, "dpi"))
-                 ippAddResolution(request, group, attr, IPP_RES_PER_INCH,
-                                  xres, yres);
+                 attrptr = ippAddResolution(request, group, attr, IPP_RES_PER_INCH,
+                                            xres, yres);
                else if (!_cups_strcasecmp(ptr, "dpc"))
-                 ippAddResolution(request, group, attr, IPP_RES_PER_CM,
-                                  xres, yres);
+                 attrptr = ippAddResolution(request, group, attr, IPP_RES_PER_CM,
+                                            xres, yres);
                else
-                 ippAddResolution(request, group, attr, (ipp_res_t)0,
-                                  xres, yres);
+                 attrptr = ippAddResolution(request, group, attr, (ipp_res_t)0,
+                                            xres, yres);
              }
              break;
 
@@ -1600,8 +1601,8 @@ do_tests(_cups_vars_t *vars,              /* I - Variables */
                  goto test_exit;
                }
 
-               ippAddRanges(request, group, attr, num_vals / 2, lowers,
-                            uppers);
+               attrptr = ippAddRanges(request, group, attr, num_vals / 2, lowers,
+                                      uppers);
              }
              break;
 
@@ -1613,7 +1614,7 @@ do_tests(_cups_vars_t *vars,              /* I - Variables */
 
                 if (col)
                 {
-                 lastcol = ippAddCollection(request, group, attr, col);
+                 attrptr = lastcol = ippAddCollection(request, group, attr, col);
                  ippDelete(col);
                }
                else
@@ -1648,7 +1649,7 @@ do_tests(_cups_vars_t *vars,              /* I - Variables */
          case IPP_TAG_LANGUAGE :
          case IPP_TAG_MIMETYPE :
              if (!strchr(token, ','))
-               ippAddString(request, group, value, attr, NULL, token);
+               attrptr = ippAddString(request, group, value, attr, NULL, token);
              else
              {
               /*
@@ -1670,11 +1671,19 @@ do_tests(_cups_vars_t *vars,            /* I - Variables */
                  num_values ++;
                }
 
-               ippAddStrings(request, group, value, attr, num_values,
-                             NULL, (const char **)values);
+               attrptr = ippAddStrings(request, group, value, attr, num_values,
+                                       NULL, (const char **)values);
              }
              break;
        }
+
+       if (!attrptr)
+       {
+         print_fatal_error("Unable to add attribute on line %d: %s", linenum,
+                           cupsLastErrorString());
+         pass = 0;
+         goto test_exit;
+       }
       }
       else if (!_cups_strcasecmp(token, "FILE"))
       {
@@ -2438,7 +2447,7 @@ do_tests(_cups_vars_t *vars,              /* I - Variables */
          }
 
          if (found)
-           _ippAttrString(found, buffer, sizeof(buffer));
+           ippAttributeString(found, buffer, sizeof(buffer));
 
          if (found &&
              !with_value(expect->with_value, expect->with_regex, found, 0,
@@ -2572,7 +2581,7 @@ do_tests(_cups_vars_t *vars,              /* I - Variables */
             attrptr = ippFindNextAttribute(response, displayed[i],
                                            IPP_TAG_ZERO))
        {
-         width = _ippAttrString(attrptr, NULL, 0);
+         width = ippAttributeString(attrptr, NULL, 0);
          if (width > widths[i])
            widths[i] = width;
        }
@@ -3225,7 +3234,7 @@ get_collection(_cups_vars_t *vars,        /* I  - Variables */
 
        if ((tempcol = realloc(lastcol, sizeof(ipp_attribute_t) +
                                        (lastcol->num_values + 1) *
-                                       sizeof(ipp_value_t))) == NULL)
+                                       sizeof(_ipp_value_t))) == NULL)
        {
          print_fatal_error("Unable to allocate memory on line %d.", *linenum);
          goto col_error;
@@ -3746,14 +3755,14 @@ print_attr(ipp_attribute_t *attr,       /* I  - Attribute to print */
            if (Output == _CUPS_OUTPUT_PLIST)
            {
              fputs("<dict><key>language</key><string>", stdout);
-             print_xml_string(NULL, attr->values[i].string.charset);
+             print_xml_string(NULL, attr->values[i].string.language);
              fputs("</string><key>string</key><string>", stdout);
              print_xml_string(NULL, attr->values[i].string.text);
              puts("</string></dict>");
            }
            else
-             printf("\"%s\"(%s) ", attr->values[i].string.text,
-                    attr->values[i].string.charset);
+             printf("\"%s\"[%s] ", attr->values[i].string.text,
+                    attr->values[i].string.language);
          break;
 
       case IPP_TAG_BEGIN_COLLECTION :
@@ -3807,7 +3816,7 @@ print_attr(ipp_attribute_t *attr, /* I  - Attribute to print */
             ippTagString(attr->value_tag));
     }
 
-    _ippAttrString(attr, buffer, sizeof(buffer));
+    ippAttributeString(attr, buffer, sizeof(buffer));
     puts(buffer);
   }
 }
@@ -3879,8 +3888,8 @@ print_col(ipp_t *col)                     /* I - Collection attribute to print */
       case IPP_TAG_TEXTLANG :
       case IPP_TAG_NAMELANG :
          for (i = 0; i < attr->num_values; i ++)
-           printf("\"%s\",%s ", attr->values[i].string.text,
-                  attr->values[i].string.charset);
+           printf("\"%s\"[%s] ", attr->values[i].string.text,
+                  attr->values[i].string.language);
          break;
 
       case IPP_TAG_BEGIN_COLLECTION :
@@ -3950,7 +3959,7 @@ print_csv(
           break;
         else if (!strcmp(current->name, displayed[i]))
         {
-          _ippAttrString(current, buffer, maxlength);
+          ippAttributeString(current, buffer, maxlength);
           break;
         }
       }
@@ -4071,7 +4080,7 @@ print_line(
           break;
         else if (!strcmp(current->name, displayed[i]))
         {
-          _ippAttrString(current, buffer, maxlength);
+          ippAttributeString(current, buffer, maxlength);
           break;
         }
       }
index be213d2c5db462001098ae8964e87231a4b34682..284a3047420097c532195267c9af2222869d9e69 100755 (executable)
@@ -203,12 +203,17 @@ echo ""
 
 case "$usevalgrind" in
        Y* | y*)
-               valgrind="valgrind --tool=memcheck --log-file=/tmp/cups-$user/log/valgrind.%p --error-limit=no --leak-check=yes --trace-children=yes --read-var-info=yes"
+               VALGRIND="valgrind --tool=memcheck --log-file=/tmp/cups-$user/log/valgrind.%p --error-limit=no --leak-check=yes --trace-children=yes --read-var-info=yes"
+               if test `uname` = Darwin; then
+                       VALGRIND="$VALGRIND --dsymutil=yes"
+               fi
+               export VALGRIND
                echo "Using Valgrind; log files can be found in /tmp/cups-$user/log..."
                ;;
 
        *)
-               valgrind=""
+               VALGRIND=""
+               export VALGRIND
                ;;
 esac
 
@@ -510,14 +515,14 @@ export LC_MESSAGES
 #
 
 echo "Starting scheduler:"
-echo "    $valgrind ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 &"
+echo "    $VALGRIND ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 &"
 echo ""
 
-if test `uname` = Darwin -a "x$valgrind" = x; then
+if test `uname` = Darwin -a "x$VALGRIND" = x; then
        DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib
        ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 &
 else
-       $valgrind ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 &
+       $VALGRIND ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 &
 fi
 
 cupsd=$!
@@ -604,7 +609,7 @@ for file in 4*.test; do
        echo $ac_n "Performing $file: $ac_c"
        echo "" >>$strfile
 
-       ./ipptool -tI ipp://localhost:$port/printers $file >> $strfile
+       $VALGRIND ./ipptool -tI ipp://localhost:$port/printers $file >> $strfile
        status=$?
 
        if test $status != 0; then