]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/array.c
Merge changes from CUPS 1.5svn-r8950.
[thirdparty/cups.git] / cups / array.c
index 19f97819de79442b643e22bbae68fdfc8862b9a6..957ed913b4cb4313c975689f3b1df57c2171bcec 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * "$Id: array.c 6649 2007-07-11 21:46:42Z mike $"
+ * "$Id: array.c 7616 2008-05-28 00:34:13Z mike $"
  *
  *   Sorted array routines for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -102,14 +102,14 @@ static int        cups_array_find(cups_array_t *a, void *e, int prev, int *rdiff);
  * appended at the end of the run of identical elements.  For unsorted arrays,
  * the element is appended to the end of the array.
  *
- * @since CUPS 1.2@
+ * @since CUPS 1.2/Mac OS X 10.5@
  */
 
 int                                    /* O - 1 on success, 0 on failure */
 cupsArrayAdd(cups_array_t *a,          /* I - Array */
              void         *e)          /* I - Element */
 {
-  DEBUG_printf(("cupsArrayAdd(a=%p, e=%p)\n", a, e));
+  DEBUG_printf(("2cupsArrayAdd(a=%p, e=%p)", a, e));
 
  /*
   * Range check input...
@@ -117,7 +117,7 @@ cupsArrayAdd(cups_array_t *a,               /* I - Array */
 
   if (!a || !e)
   {
-    DEBUG_puts("cupsArrayAdd: returning 0");
+    DEBUG_puts("3cupsArrayAdd: returning 0");
     return (0);
   }
 
@@ -136,7 +136,7 @@ cupsArrayAdd(cups_array_t *a,               /* I - Array */
  * The caller is responsible for freeing the memory used by the
  * elements themselves.
  *
- * @since CUPS 1.2@
+ * @since CUPS 1.2/Mac OS X 10.5@
  */
 
 void
@@ -165,7 +165,7 @@ cupsArrayClear(cups_array_t *a)             /* I - Array */
 /*
  * 'cupsArrayCount()' - Get the number of elements in the array.
  *
- * @since CUPS 1.2@
+ * @since CUPS 1.2/Mac OS X 10.5@
  */
 
 int                                    /* O - Number of elements */
@@ -192,7 +192,7 @@ cupsArrayCount(cups_array_t *a)             /* I - Array */
  * The current element is undefined until you call @link cupsArrayFind@,
  * @link cupsArrayFirst@, or @link cupsArrayIndex@, or @link cupsArrayLast@.
  *
- * @since CUPS 1.2@
+ * @since CUPS 1.2/Mac OS X 10.5@
  */
 
 void *                                 /* O - Element */
@@ -222,7 +222,7 @@ cupsArrayCurrent(cups_array_t *a)   /* I - Array */
  * The caller is responsible for freeing the memory used by the
  * elements themselves.
  *
- * @since CUPS 1.2@
+ * @since CUPS 1.2/Mac OS X 10.5@
  */
 
 void
@@ -253,7 +253,7 @@ cupsArrayDelete(cups_array_t *a)    /* I - Array */
 /*
  * 'cupsArrayDup()' - Duplicate the array.
  *
- * @since CUPS 1.2@
+ * @since CUPS 1.2/Mac OS X 10.5@
  */
 
 cups_array_t *                         /* O - Duplicate array */
@@ -319,7 +319,7 @@ cupsArrayDup(cups_array_t *a)               /* I - Array */
 /*
  * 'cupsArrayFind()' - Find an element in the array.
  *
- * @since CUPS 1.2@
+ * @since CUPS 1.2/Mac OS X 10.5@
  */
 
 void *                                 /* O - Element found or @code NULL@ */
@@ -414,7 +414,7 @@ cupsArrayFind(cups_array_t *a,              /* I - Array */
 /*
  * 'cupsArrayFirst()' - Get the first element in the array.
  *
- * @since CUPS 1.2@
+ * @since CUPS 1.2/Mac OS X 10.5@
  */
 
 void *                                 /* O - First element or @code NULL@ if the array is empty */
@@ -443,7 +443,7 @@ cupsArrayFirst(cups_array_t *a)             /* I - Array */
  * The current element is undefined until you call @link cupsArrayFind@,
  * @link cupsArrayFirst@, or @link cupsArrayIndex@, or @link cupsArrayLast@.
  *
- * @since CUPS 1.3@
+ * @since CUPS 1.3/Mac OS X 10.5@
  */
 
 int                                    /* O - Index of the current element, starting at 0 */
@@ -459,7 +459,7 @@ cupsArrayGetIndex(cups_array_t *a)  /* I - Array */
 /*
  * 'cupsArrayGetInsert()' - Get the index of the last inserted element.
  *
- * @since CUPS 1.3@
+ * @since CUPS 1.3/Mac OS X 10.5@
  */
 
 int                                    /* O - Index of the last inserted element, starting at 0 */
@@ -475,7 +475,7 @@ cupsArrayGetInsert(cups_array_t *a) /* I - Array */
 /*
  * 'cupsArrayIndex()' - Get the N-th element in the array.
  *
- * @since CUPS 1.2@
+ * @since CUPS 1.2/Mac OS X 10.5@
  */
 
 void *                                 /* O - N-th element or @code NULL@ */
@@ -498,14 +498,14 @@ cupsArrayIndex(cups_array_t *a,           /* I - Array */
  * inserted at the beginning of the run of identical elements.  For unsorted
  * arrays, the element is inserted at the beginning of the array.
  *
- * @since CUPS 1.2@
+ * @since CUPS 1.2/Mac OS X 10.5@
  */
 
 int                                    /* O - 0 on failure, 1 on success */
 cupsArrayInsert(cups_array_t *a,       /* I - Array */
                void         *e)        /* I - Element */
 {
-  DEBUG_printf(("cupsArrayInsert(a=%p, e=%p)\n", a, e));
+  DEBUG_printf(("2cupsArrayInsert(a=%p, e=%p)", a, e));
 
  /*
   * Range check input...
@@ -513,7 +513,7 @@ cupsArrayInsert(cups_array_t *a,    /* I - Array */
 
   if (!a || !e)
   {
-    DEBUG_puts("cupsArrayInsert: returning 0");
+    DEBUG_puts("3cupsArrayInsert: returning 0");
     return (0);
   }
 
@@ -528,7 +528,7 @@ cupsArrayInsert(cups_array_t *a,    /* I - Array */
 /*
  * 'cupsArrayLast()' - Get the last element in the array.
  *
- * @since CUPS 1.2@
+ * @since CUPS 1.2/Mac OS X 10.5@
  */
 
 void *                                 /* O - Last element or @code NULL@ if the array is empty */
@@ -559,7 +559,7 @@ cupsArrayLast(cups_array_t *a)              /* I - Array */
  * data pointer argument can safely be omitted when not required so functions
  * like @code strcmp@ can be used for sorted string arrays.
  *
- * @since CUPS 1.2@
+ * @since CUPS 1.2/Mac OS X 10.5@
  */
 
 cups_array_t *                         /* O - Array */
@@ -581,7 +581,7 @@ cupsArrayNew(cups_array_func_t f,   /* I - Comparison function or @code NULL@ for
  * The hash function ("h") is used to implement cached lookups with the
  * specified hash size ("hsize").
  *
- * @since CUPS 1.3@
+ * @since CUPS 1.3/Mac OS X 10.5@
  */
 
 cups_array_t *                         /* O - Array */
@@ -636,7 +636,7 @@ cupsArrayNew2(cups_array_func_t  f, /* I - Comparison function or @code NULL@ fo
  * @link cupsArrayFirst@, or @link cupsArrayIndex@, or @link cupsArrayLast@
  * to set the current element.
  *
- * @since CUPS 1.2@
+ * @since CUPS 1.2/Mac OS X 10.5@
  */
 
 void *                                 /* O - Next element or @code NULL@ */
@@ -669,7 +669,7 @@ cupsArrayNext(cups_array_t *a)              /* I - Array */
  * @link cupsArrayFirst@, or @link cupsArrayIndex@, or @link cupsArrayLast@
  * to set the current element.
  *
- * @since CUPS 1.2@
+ * @since CUPS 1.2/Mac OS X 10.5@
  */
 
 void *                                 /* O - Previous element or @code NULL@ */
@@ -702,7 +702,7 @@ cupsArrayPrev(cups_array_t *a)              /* I - Array */
  * The caller is responsible for freeing the memory used by the
  * removed element.
  *
- * @since CUPS 1.2@
+ * @since CUPS 1.2/Mac OS X 10.5@
  */
 
 int                                    /* O - 1 on success, 0 on failure */
@@ -764,7 +764,7 @@ cupsArrayRemove(cups_array_t *a,    /* I - Array */
 /*
  * 'cupsArrayRestore()' - Reset the current element to the last @link cupsArraySave@.
  *
- * @since CUPS 1.2@
+ * @since CUPS 1.2/Mac OS X 10.5@
  */
 
 void *                                 /* O - New current element */
@@ -795,7 +795,7 @@ cupsArrayRestore(cups_array_t *a)   /* I - Array */
  *
  * The save/restore stack is guaranteed to be at least 32 elements deep.
  *
- * @since CUPS 1.2@
+ * @since CUPS 1.2/Mac OS X 10.5@
  */
 
 int                                    /* O - 1 on success, 0 on failure */
@@ -817,7 +817,7 @@ cupsArraySave(cups_array_t *a)              /* I - Array */
 /*
  * 'cupsArrayUserData()' - Return the user data for an array.
  *
- * @since CUPS 1.2@
+ * @since CUPS 1.2/Mac OS X 10.5@
  */
 
 void *                                 /* O - User data */
@@ -833,7 +833,7 @@ cupsArrayUserData(cups_array_t *a)  /* I - Array */
 /*
  * 'cups_array_add()' - Insert or append an element to the array...
  *
- * @since CUPS 1.2@
+ * @since CUPS 1.2/Mac OS X 10.5@
  */
 
 static int                             /* O - 1 on success, 0 on failure */
@@ -846,7 +846,7 @@ cups_array_add(cups_array_t *a,             /* I - Array */
        diff;                           /* Comparison with current element */
 
 
-  DEBUG_printf(("cups_array_add(a=%p, e=%p, insert=%d)\n", a, e, insert));
+  DEBUG_printf(("7cups_array_add(a=%p, e=%p, insert=%d)", a, e, insert));
 
  /*
   * Verify we have room for the new element...
@@ -879,11 +879,11 @@ cups_array_add(cups_array_t *a,           /* I - Array */
       temp = realloc(a->elements, count * sizeof(void *));
     }
 
-    DEBUG_printf(("cups_array_add: count=%d\n", count));
+    DEBUG_printf(("9cups_array_add: count=%d", count));
 
     if (!temp)
     {
-      DEBUG_puts("cupsAddAdd: allocation failed, returning 0");
+      DEBUG_puts("9cups_array_add: allocation failed, returning 0");
       return (0);
     }
 
@@ -978,11 +978,11 @@ cups_array_add(cups_array_t *a,           /* I - Array */
       if (a->saved[i] >= current)
        a->saved[i] ++;
 
-    DEBUG_printf(("cups_array_add: insert element at index %d...\n", current));
+    DEBUG_printf(("9cups_array_add: insert element at index %d...", current));
   }
 #ifdef DEBUG
   else
-    DEBUG_printf(("cups_array_add: append element at %d...\n", current));
+    DEBUG_printf(("9cups_array_add: append element at %d...", current));
 #endif /* DEBUG */
 
   a->elements[current] = e;
@@ -991,11 +991,11 @@ cups_array_add(cups_array_t *a,           /* I - Array */
 
 #ifdef DEBUG
   for (current = 0; current < a->num_elements; current ++)
-    DEBUG_printf(("cups_array_add: a->elements[%d]=%p\n", current,
+    DEBUG_printf(("9cups_array_add: a->elements[%d]=%p", current,
                   a->elements[current]));
 #endif /* DEBUG */
 
-  DEBUG_puts("cups_array_add: returning 1");
+  DEBUG_puts("9cups_array_add: returning 1");
 
   return (1);
 }
@@ -1003,8 +1003,6 @@ cups_array_add(cups_array_t *a,           /* I - Array */
 
 /*
  * 'cups_array_find()' - Find an element in the array...
- *
- * @since CUPS 1.2@
  */
 
 static int                             /* O - Index of match */
@@ -1019,7 +1017,7 @@ cups_array_find(cups_array_t *a,  /* I - Array */
        diff;                           /* Comparison with current element */
 
 
-  DEBUG_printf(("cups_array_find(a=%p, e=%p, prev=%d, rdiff=%p)\n", a, e, prev,
+  DEBUG_printf(("7cups_array_find(a=%p, e=%p, prev=%d, rdiff=%p)", a, e, prev,
                 rdiff));
 
   if (a->compare)
@@ -1028,7 +1026,7 @@ cups_array_find(cups_array_t *a,  /* I - Array */
     * Do a binary search for the element...
     */
 
-    DEBUG_puts("cups_array_find: binary search");
+    DEBUG_puts("9cups_array_find: binary search");
 
     if (prev >= 0 && prev < a->num_elements)
     {
@@ -1044,7 +1042,7 @@ cups_array_find(cups_array_t *a,  /* I - Array */
         * Exact or edge match, return it!
        */
 
-        DEBUG_printf(("cups_array_find: Returning %d, diff=%d\n", prev, diff));
+        DEBUG_printf(("9cups_array_find: Returning %d, diff=%d", prev, diff));
 
        *rdiff = diff;
 
@@ -1084,7 +1082,7 @@ cups_array_find(cups_array_t *a,  /* I - Array */
       current = (left + right) / 2;
       diff    = (*(a->compare))(e, a->elements[current], a->data);
 
-      DEBUG_printf(("cups_array_find: left=%d, right=%d, current=%d, diff=%d\n",
+      DEBUG_printf(("9cups_array_find: left=%d, right=%d, current=%d, diff=%d",
                     left, right, current, diff));
 
       if (diff == 0)
@@ -1117,7 +1115,7 @@ cups_array_find(cups_array_t *a,  /* I - Array */
     * Do a linear pointer search...
     */
 
-    DEBUG_puts("cups_array_find: linear search");
+    DEBUG_puts("9cups_array_find: linear search");
 
     diff = 1;
 
@@ -1133,7 +1131,7 @@ cups_array_find(cups_array_t *a,  /* I - Array */
   * Return the closest element and the difference...
   */
 
-  DEBUG_printf(("cups_array_find: Returning %d, diff=%d\n", current, diff));
+  DEBUG_printf(("8cups_array_find: Returning %d, diff=%d", current, diff));
 
   *rdiff = diff;
 
@@ -1142,5 +1140,5 @@ cups_array_find(cups_array_t *a,  /* I - Array */
 
 
 /*
- * End of "$Id: array.c 6649 2007-07-11 21:46:42Z mike $".
+ * End of "$Id: array.c 7616 2008-05-28 00:34:13Z mike $".
  */