]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/ipp.c
Merge changes from CUPS 1.5b1-r9798.
[thirdparty/cups.git] / cups / ipp.c
index 2a516c1901d24848bf08d0d74e379d88276eba81..a04fb30a5aeca9da749765bfccb0be37781e33ad 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Internet Printing Protocol functions for CUPS.
  *
- *   Copyright 2007-2010 by Apple Inc.
+ *   Copyright 2007-2011 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
  * Include necessary headers...
  */
 
-#include "http-private.h"
-#include "globals.h"
-#include "debug.h"
-#include <stdlib.h>
-#include <errno.h>
+#include "cups-private.h"
 #ifdef WIN32
 #  include <io.h>
 #endif /* WIN32 */
@@ -185,6 +181,8 @@ ippAddCollection(ipp_t      *ipp,   /* I - IPP message */
   attr->value_tag            = IPP_TAG_BEGIN_COLLECTION;
   attr->values[0].collection = value;
 
+  value->use ++;
+
   return (attr);
 }
 
@@ -223,10 +221,15 @@ ippAddCollections(
   attr->value_tag = IPP_TAG_BEGIN_COLLECTION;
 
   if (values != NULL)
+  {
     for (i = 0, value = attr->values;
         i < num_values;
         i ++, value ++)
+    {
       value->collection = (ipp_t *)values[i];
+      value->collection->use ++;
+    }
+  }
 
   return (attr);
 }
@@ -420,7 +423,7 @@ ippAddString(ipp_t      *ipp,               /* I - IPP message */
   * Force value to be English for the POSIX locale...
   */
 
-  if (type == IPP_TAG_LANGUAGE && !strcasecmp(value, "C"))
+  if (type == IPP_TAG_LANGUAGE && !_cups_strcasecmp(value, "C"))
     value = "en";
 
  /*
@@ -510,7 +513,7 @@ ippAddStrings(
     {
       if ((int)type & IPP_TAG_COPY)
         value->string.text = (char *)values[i];
-      else if (type == IPP_TAG_LANGUAGE && !strcasecmp(values[i], "C"))
+      else if (type == IPP_TAG_LANGUAGE && !_cups_strcasecmp(values[i], "C"))
       {
        /*
        * Force language to be English for the POSIX locale...
@@ -798,6 +801,10 @@ ippDelete(ipp_t *ipp)                      /* I - IPP message */
   if (!ipp)
     return;
 
+  ipp->use --;
+  if (ipp->use > 0)
+    return;
+
   for (attr = ipp->attrs; attr != NULL; attr = next)
   {
     next = attr->next;
@@ -923,7 +930,7 @@ ippFindNextAttribute(ipp_t      *ipp,       /* I - IPP message */
 
     value_tag = (ipp_tag_t)(attr->value_tag & IPP_TAG_MASK);
 
-    if (attr->name != NULL && strcasecmp(attr->name, name) == 0 &&
+    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)))
@@ -972,6 +979,7 @@ ippNew(void)
 
     temp->request.any.version[0] = 1;
     temp->request.any.version[1] = 1;
+    temp->use                    = 1;
   }
 
   DEBUG_printf(("1ippNew: Returning %p", temp));
@@ -1263,7 +1271,9 @@ ippReadIO(void       *src,                /* I - Data source */
 
              attr->value_tag = tag;
            }
-           else if ((value_tag >= IPP_TAG_TEXTLANG &&
+           else if (value_tag == IPP_TAG_TEXTLANG ||
+                    value_tag == IPP_TAG_NAMELANG ||
+                    (value_tag >= IPP_TAG_TEXT &&
                      value_tag <= IPP_TAG_MIMETYPE))
             {
             /*
@@ -1271,8 +1281,9 @@ ippReadIO(void       *src,                /* I - Data source */
              * forms; accept sets of differing values...
              */
 
-             if ((tag < IPP_TAG_TEXTLANG || tag > IPP_TAG_MIMETYPE) &&
-                 tag != IPP_TAG_NOVALUE)
+             if (tag != IPP_TAG_TEXTLANG && tag != IPP_TAG_NAMELANG &&
+                 (tag < IPP_TAG_TEXT || tag > IPP_TAG_MIMETYPE) &&
+                 tag != IPP_TAG_NOVALUE)
              {
                DEBUG_printf(("1ippReadIO: 1setOf value tag %x(%s) != %x(%s)",
                              value_tag, ippTagString(value_tag), tag,
@@ -2754,6 +2765,7 @@ _ippFreeAttr(ipp_attribute_t *attr)       /* I - Attribute to free */
   {
     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 :
@@ -3013,7 +3025,7 @@ ipp_read_http(http_t      *http,  /* I - Client connection */
   int          tbytes,                 /* Total bytes read */
                bytes;                  /* Bytes read this pass */
   char         len[32];                /* Length string */
-  
+
 
   DEBUG_printf(("7ipp_read_http(http=%p, buffer=%p, length=%d)",
                 http, buffer, (int)length));