1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
3 <!-- SECTION: Programming -->
5 <title>Array API
</title>
6 <meta name=
"keywords" content=
"Programming">
7 <meta name=
"creator" content=
"Mini-XML v2.5">
8 <style type=
"text/css"><!--
10 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
13 H1, H2, H3, H4, H5, H6, P, TD, TH {
14 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
18 font-family: monaco, courier, monospace;
23 font-family: monaco, courier, monospace;
32 border: dotted thin #999999;
37 PRE.command EM, PRE.example EM {
38 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
42 font-family: monaco, courier, monospace;
53 border: solid thin #999999;
59 text-decoration: none;
62 A:link:hover, A:visited:hover, A:active {
63 text-decoration: underline;
71 border: solid thin #999999;
72 border-collapse: collapse;
88 border: solid thin #cccccc;
95 border-bottom: solid thin #999999;
104 caption-side: bottom;
124 border: thin solid #000000;
132 H2 SPAN.info, H3 SPAN.info, H4 SPAN.info {
138 border-bottom: solid 2pt #000000;
156 font-family: monaco, courier, monospace;
165 border: solid thin #999999;
166 border-collapse: collapse;
171 DIV.summary TABLE TD, DIV.summary TABLE TH {
172 border: solid thin #999999;
178 DIV.summary TABLE THEAD TH {
182 /* API documentation styles... */
189 div.body h3, div.body h4, div.body h5 {
190 margin-bottom: 0.5em;
193 .class, .enumeration, .function, .struct, .typedef, .union {
194 border-bottom: solid thin #999999;
201 code, p.code, pre, ul.code li {
202 font-family: monaco, courier, monospace;
205 ul.code, ul.contents, ul.subcontents {
206 list-style-type: none;
216 ul.contents li ul.code, ul.contents li ul.subcontents {
229 margin-bottom: 0.5em;
232 /* This is just for the HTML files generated with the framedhelp target */
235 border: solid thin black;
244 div.contents ul.contents {
247 div.contents ul.subcontents li {
256 "$Id: api-array.header 7266 2008-01-29 02:15:29Z mike $"
258 Array API header for the Common UNIX Printing System (CUPS).
260 Copyright 2008 by Apple Inc.
262 These coded instructions, statements, and computer programs are the
263 property of Apple Inc. and are protected by Federal copyright
264 law. Distribution and use rights are outlined in the file "LICENSE.txt"
265 which should have been included with this file. If this file is
266 file is missing or damaged, see the license at "http://www.cups.org/".
269 <h1 class=
"title">Array API
</h1>
271 <div class='summary'
><table summary='General Information'
>
275 <th>cups/array.h
</th>
285 <td>Programming:
<a href='api-overview.html' target='_top'
>Introduction to CUPS Programming
</a></td>
289 <h2 class=
"title">Contents
</h2>
290 <ul class=
"contents">
292 <li><a href=
"#OVERVIEW">Overview
</a><ul class=
"subcontents">
293 <li><a href=
"#MANAGING_ARRAYS">Managing Arrays
</a></li>
294 <li><a href=
"#FINDING_AND_ENUMERATING">Finding and Enumerating Elements
</a></li>
296 <li><a href=
"#FUNCTIONS">Functions
</a><ul class=
"code">
297 <li><a href=
"#cupsArrayAdd" title=
"Add an element to the array.">cupsArrayAdd
</a></li>
298 <li><a href=
"#cupsArrayClear" title=
"Clear the array.">cupsArrayClear
</a></li>
299 <li><a href=
"#cupsArrayCount" title=
"Get the number of elements in the array.">cupsArrayCount
</a></li>
300 <li><a href=
"#cupsArrayCurrent" title=
"Return the current element in the array.">cupsArrayCurrent
</a></li>
301 <li><a href=
"#cupsArrayDelete" title=
"Free all memory used by the array.">cupsArrayDelete
</a></li>
302 <li><a href=
"#cupsArrayDup" title=
"Duplicate the array.">cupsArrayDup
</a></li>
303 <li><a href=
"#cupsArrayFind" title=
"Find an element in the array.">cupsArrayFind
</a></li>
304 <li><a href=
"#cupsArrayFirst" title=
"Get the first element in the array.">cupsArrayFirst
</a></li>
305 <li><a href=
"#cupsArrayGetIndex" title=
"Get the index of the current element.">cupsArrayGetIndex
</a></li>
306 <li><a href=
"#cupsArrayGetInsert" title=
"Get the index of the last inserted element.">cupsArrayGetInsert
</a></li>
307 <li><a href=
"#cupsArrayIndex" title=
"Get the N-th element in the array.">cupsArrayIndex
</a></li>
308 <li><a href=
"#cupsArrayInsert" title=
"Insert an element in the array.">cupsArrayInsert
</a></li>
309 <li><a href=
"#cupsArrayLast" title=
"Get the last element in the array.">cupsArrayLast
</a></li>
310 <li><a href=
"#cupsArrayNew" title=
"Create a new array.">cupsArrayNew
</a></li>
311 <li><a href=
"#cupsArrayNew2" title=
"Create a new array with hash.">cupsArrayNew2
</a></li>
312 <li><a href=
"#cupsArrayNext" title=
"Get the next element in the array.">cupsArrayNext
</a></li>
313 <li><a href=
"#cupsArrayPrev" title=
"Get the previous element in the array.">cupsArrayPrev
</a></li>
314 <li><a href=
"#cupsArrayRemove" title=
"Remove an element from the array.">cupsArrayRemove
</a></li>
315 <li><a href=
"#cupsArrayRestore" title=
"Reset the current element to the last cupsArraySave.">cupsArrayRestore
</a></li>
316 <li><a href=
"#cupsArraySave" title=
"Mark the current element for a later cupsArrayRestore.">cupsArraySave
</a></li>
317 <li><a href=
"#cupsArrayUserData" title=
"Return the user data for an array.">cupsArrayUserData
</a></li>
319 <li><a href=
"#TYPES">Data Types
</a><ul class=
"code">
320 <li><a href=
"#cups_ahash_func_t" title=
"Array hash function">cups_ahash_func_t
</a></li>
321 <li><a href=
"#cups_array_func_t" title=
"Array comparison function">cups_array_func_t
</a></li>
322 <li><a href=
"#cups_array_t" title=
"CUPS array type">cups_array_t
</a></li>
326 "$Id: api-array.shtml 7266 2008-01-29 02:15:29Z mike $"
328 Array API introduction for the Common UNIX Printing System (CUPS).
330 Copyright 2007-2008 by Apple Inc.
331 Copyright 1997-2006 by Easy Software Products, all rights reserved.
333 These coded instructions, statements, and computer programs are the
334 property of Apple Inc. and are protected by Federal copyright
335 law. Distribution and use rights are outlined in the file "LICENSE.txt"
336 which should have been included with this file. If this file is
337 file is missing or damaged, see the license at "http://www.cups.org/".
340 <h2 class='title'
><a name='OVERVIEW'
>Overview
</a></h2>
342 <p>The CUPS array API provides a high-performance generic array container.
343 The contents of the array container can be sorted and the container itself is
344 designed for optimal speed and memory usage under a wide variety of conditions.
345 Sorted arrays use a binary search algorithm from the last found or inserted
346 element to quickly find matching elements in the array. Arrays created with the
347 optional hash function can often find elements with a single lookup. The
348 <a href='#cups_array_t'
><code>cups_array_t
</code></a> type is used when
349 referring to a CUPS array.
</p>
351 <p>The CUPS scheduler (
<tt>cupsd
</tt>) and many of the CUPS API
352 functions use the array API to efficiently manage large lists of
355 <h3><a name='MANAGING_ARRAYS'
>Managing Arrays
</a></h3>
357 <p>Arrays are created using either the
358 <a href='#cupsArrayNew'
><code>cupsArrayNew
</code></a> or
359 <a href='#cupsArrayNew2'
><code>cupsArrayNew2
</code></a> functions. The
360 first function creates a new array with the specified callback function
361 and user data pointer:
</p>
363 <pre class='example'
>
364 #include
<cups/array.h
>
366 static int compare_func(void *first, void *second, void *user_data);
369 <a href='#cups_array_t'
>cups_array_t
</a> *array =
<a href='#cupsArrayNew'
>cupsArrayNew
</a>(compare_func, user_data);
372 <p>The comparison function (type
373 <a href=
"#cups_arrayfunc_t"><code>cups_arrayfunc_t
</code></a>) is called
374 whenever an element is added to the array and can be
<code>NULL
</code> to
375 create an unsorted array. The function returns -
1 if the first element should
376 come before the second,
0 if the first and second elements should have the same
377 ordering, and
1 if the first element should come after the second.
</p>
379 <p>The
"user_data" pointer is passed to your comparison function. Pass
380 <code>NULL
</code> if you do not need to associate the elements in your array
381 with additional information.
</p>
383 <p>The
<a href='#cupsArrayNew2'
><code>cupsArrayNew2
</code></a> function adds
384 two more arguments to support hashed lookups, which can potentially provide
385 instantaneous (
"O(1)") lookups in your array:
</p>
387 <pre class='example'
>
388 #include
<cups/array.h
>
390 #define HASH_SIZE
512 /* Size of hash table */
392 static int compare_func(void *first, void *second, void *user_data);
393 static int hash_func(void *element, void *user_data);
396 <a href='#cups_array_t'
>cups_array_t
</a> *array =
<a href='#cupsArrayNew2'
>cupsArrayNew2
</a>(compare_func, user_data, hash_func, HASH_SIZE);
399 <p>The hash function (type
400 <a href=
"#cups_ahash_func_t"><code>cups_ahash_func_t
</code></a>) returns a
401 number from
0 to (hash_size-
1) that (hopefully) uniquely identifies the
402 element and is called whenever you look up an element in the array with
403 <a href='#cupsArrayFind'
><code>cupsArrayFind
</code></a>. The hash size is
404 only limited by available memory, but generally should not be larger than
405 16384 to realize any performance improvement.
</p>
407 <p>Once you have created the array, you add elements using the
408 <a href='#cupsArrayAdd'
><code>cupsArrayAdd
</code></a>
409 <a href='#cupsArrayInsert'
><code>cupsArrayInsert
</code></a> functions.
410 The first function adds an element to the array, adding the new element
411 after any elements that have the same order, while the second inserts the
412 element before others with the same order. For unsorted arrays,
413 <a href='#cupsArrayAdd'
><code>cupsArrayAdd
</code></a> appends the elemnt to
414 the end of the array while
415 <a href='#cupsArrayInsert'
><code>cupsArrayInsert
</code></a> inserts the
416 element at the beginning of the array. For example, the following code
417 creates a sorted array of character strings:
</p>
419 <pre class='example'
>
420 #include
<cups/array.h
>
422 /* Use strcmp() to compare strings - it will ignore the user_data pointer */
423 <a href='#cups_array_t'
>cups_array_t
</a> *array =
<a href='#cupsArrayNew'
>cupsArrayNew
</a>((
<a href='#cups_array_func_t'
>cups_array_func_t
</a>)strcmp, NULL);
425 /* Add four strings to the array */
426 <a href='#cupsArrayAdd'
>cupsArrayAdd
</a>(array,
"One Fish");
427 <a href='#cupsArrayAdd'
>cupsArrayAdd
</a>(array,
"Two Fish");
428 <a href='#cupsArrayAdd'
>cupsArrayAdd
</a>(array,
"Red Fish");
429 <a href='#cupsArrayAdd'
>cupsArrayAdd
</a>(array,
"Blue Fish");
432 <p>Elements are removed using the
433 <a href='#cupsArrayRemove'
><code>cupsArrayRemove
</code></a> function, for
436 <pre class='example'
>
437 #include
<cups/array.h
>
439 /* Use strcmp() to compare strings - it will ignore the user_data pointer */
440 <a href='#cups_array_t'
>cups_array_t
</a> *array =
<a href='#cupsArrayNew'
>cupsArrayNew
</a>((
<a href='#cups_array_func_t'
>cups_array_func_t
</a>)strcmp, NULL);
442 /* Add four strings to the array */
443 <a href='#cupsArrayAdd'
>cupsArrayAdd
</a>(array,
"One Fish");
444 <a href='#cupsArrayAdd'
>cupsArrayAdd
</a>(array,
"Two Fish");
445 <a href='#cupsArrayAdd'
>cupsArrayAdd
</a>(array,
"Red Fish");
446 <a href='#cupsArrayAdd'
>cupsArrayAdd
</a>(array,
"Blue Fish");
448 /* Remove
"Red Fish" */
449 <a href='#cupsArrayRemove'
>cupsArrayRemove
</a>(array,
"Red Fish");
452 <p>Finally, you free the memory used by the array using the
453 <a href='#cupsArrayDelete'
><code>cupsArrayDelete
</code></a> function. All
454 of the memory for the array and hash table (if any) is freed, however
<em>CUPS
455 does not free the elements
</em> - if necessary, you must allocate and free the
456 elements yourself.
</p>
458 <h3><a name='FINDING_AND_ENUMERATING'
>Finding and Enumerating Elements
</a></h3>
460 <p>CUPS provides several functions to find and enumerate elements in an
461 array. Each one sets or updates a
"current index" into the array, such that
462 future lookups will start where the last one left off:
</p>
465 <dt><a href='#cupsArrayFind'
><code>cupsArrayFind
</code></a></dt>
466 <dd>Returns the first matching element .
</dd>
467 <dt><a href='#cupsArrayFirst'
><code>cupsArrayFirst
</code></a></dt>
468 <dd>Returns the first element in the array.
</dd>
469 <dt><a href='#cupsArrayIndex'
><code>cupsArrayIndex
</code></a></dt>
470 <dd>Returns the Nth element in the array.
</dd>
471 <dt><a href='#cupsArrayLast'
><code>cupsArrayLast
</code></a></dt>
472 <dd>Returns the last element in the array.
</dd>
473 <dt><a href='#cupsArrayNext'
><code>cupsArrayNext
</code></a></dt>
474 <dd>Returns the next element in the array.
</dd>
475 <dt><a href='#cupsArrayPrev'
><code>cupsArrayPrev
</code></a></dt>
476 <dd>Returns the previous element in the array.
</dd>
479 <p>Each of these functions returns
<code>NULL
</code> when there is no
480 corresponding element. For example, a simple
<code>for
</code> loop using the
481 <a href='#cupsArrayFirst'
><code>cupsArrayFirst
</code></a> and
482 <a href='#cupsArrayNext'
><code>cupsArrayNext
</code></a> functions will
483 enumerate all of the strings in our previous example:
</p>
485 <pre class='example'
>
486 #include
<cups/array.h
>
488 /* Use strcmp() to compare strings - it will ignore the user_data pointer */
489 <a href='#cups_array_t'
>cups_array_t
</a> *array =
<a href='#cupsArrayNew'
>cupsArrayNew
</a>((
<a href='#cups_array_func_t'
>cups_array_func_t
</a>)strcmp, NULL);
491 /* Add four strings to the array */
492 <a href='#cupsArrayAdd'
>cupsArrayAdd
</a>(array,
"One Fish");
493 <a href='#cupsArrayAdd'
>cupsArrayAdd
</a>(array,
"Two Fish");
494 <a href='#cupsArrayAdd'
>cupsArrayAdd
</a>(array,
"Red Fish");
495 <a href='#cupsArrayAdd'
>cupsArrayAdd
</a>(array,
"Blue Fish");
497 /* Show all of the strings in the array */
499 for (s = (char *)
<a href='#cupsArrayFirst'
>cupsArrayFirst
</a>(array); s != NULL; s = (char *)
<a href='#cupsArrayNext'
>cupsArrayNext
</a>(array))
502 <h2 class=
"title"><a name=
"FUNCTIONS">Functions
</a></h2>
503 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsArrayAdd">cupsArrayAdd
</a></h3>
504 <p class=
"description">Add an element to the array.
</p>
506 int cupsArrayAdd (
<br>
507 <a href=
"#cups_array_t">cups_array_t
</a> *a,
<br>
508 void *e
<br>
510 <h4 class=
"parameters">Parameters
</h4>
513 <dd class=
"description">Array
</dd>
515 <dd class=
"description">Element
</dd>
517 <h4 class=
"returnvalue">Return Value
</h4>
518 <p class=
"description">1 on success,
0 on failure
</p>
519 <h4 class=
"discussion">Discussion
</h4>
520 <p class=
"discussion">When adding an element to a sorted array, non-unique elements are
521 appended at the end of the run. For unsorted arrays, the element
522 is inserted at the end of the array.
525 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsArrayClear">cupsArrayClear
</a></h3>
526 <p class=
"description">Clear the array.
</p>
528 void cupsArrayClear (
<br>
529 <a href=
"#cups_array_t">cups_array_t
</a> *a
<br>
531 <h4 class=
"parameters">Parameters
</h4>
534 <dd class=
"description">Array
</dd>
536 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsArrayCount">cupsArrayCount
</a></h3>
537 <p class=
"description">Get the number of elements in the array.
</p>
539 int cupsArrayCount (
<br>
540 <a href=
"#cups_array_t">cups_array_t
</a> *a
<br>
542 <h4 class=
"parameters">Parameters
</h4>
545 <dd class=
"description">Array
</dd>
547 <h4 class=
"returnvalue">Return Value
</h4>
548 <p class=
"description">Number of elements
</p>
549 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsArrayCurrent">cupsArrayCurrent
</a></h3>
550 <p class=
"description">Return the current element in the array.
</p>
552 void *cupsArrayCurrent (
<br>
553 <a href=
"#cups_array_t">cups_array_t
</a> *a
<br>
555 <h4 class=
"parameters">Parameters
</h4>
558 <dd class=
"description">Array
</dd>
560 <h4 class=
"returnvalue">Return Value
</h4>
561 <p class=
"description">Element
</p>
562 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsArrayDelete">cupsArrayDelete
</a></h3>
563 <p class=
"description">Free all memory used by the array.
</p>
565 void cupsArrayDelete (
<br>
566 <a href=
"#cups_array_t">cups_array_t
</a> *a
<br>
568 <h4 class=
"parameters">Parameters
</h4>
571 <dd class=
"description">Array
</dd>
573 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsArrayDup">cupsArrayDup
</a></h3>
574 <p class=
"description">Duplicate the array.
</p>
576 <a href=
"#cups_array_t">cups_array_t
</a> *cupsArrayDup (
<br>
577 <a href=
"#cups_array_t">cups_array_t
</a> *a
<br>
579 <h4 class=
"parameters">Parameters
</h4>
582 <dd class=
"description">Array
</dd>
584 <h4 class=
"returnvalue">Return Value
</h4>
585 <p class=
"description">Duplicate array
</p>
586 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsArrayFind">cupsArrayFind
</a></h3>
587 <p class=
"description">Find an element in the array.
</p>
589 void *cupsArrayFind (
<br>
590 <a href=
"#cups_array_t">cups_array_t
</a> *a,
<br>
591 void *e
<br>
593 <h4 class=
"parameters">Parameters
</h4>
596 <dd class=
"description">Array
</dd>
598 <dd class=
"description">Element
</dd>
600 <h4 class=
"returnvalue">Return Value
</h4>
601 <p class=
"description">Element found or
<code>NULL
</code></p>
602 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsArrayFirst">cupsArrayFirst
</a></h3>
603 <p class=
"description">Get the first element in the array.
</p>
605 void *cupsArrayFirst (
<br>
606 <a href=
"#cups_array_t">cups_array_t
</a> *a
<br>
608 <h4 class=
"parameters">Parameters
</h4>
611 <dd class=
"description">Array
</dd>
613 <h4 class=
"returnvalue">Return Value
</h4>
614 <p class=
"description">First element or
<code>NULL
</code></p>
615 <h3 class=
"function"><span class=
"info"> CUPS
1.3 </span><a name=
"cupsArrayGetIndex">cupsArrayGetIndex
</a></h3>
616 <p class=
"description">Get the index of the current element.
</p>
618 int cupsArrayGetIndex (
<br>
619 <a href=
"#cups_array_t">cups_array_t
</a> *a
<br>
621 <h4 class=
"parameters">Parameters
</h4>
624 <dd class=
"description">Array
</dd>
626 <h4 class=
"returnvalue">Return Value
</h4>
627 <p class=
"description">Index of the current element
</p>
628 <h3 class=
"function"><span class=
"info"> CUPS
1.3 </span><a name=
"cupsArrayGetInsert">cupsArrayGetInsert
</a></h3>
629 <p class=
"description">Get the index of the last inserted element.
</p>
631 int cupsArrayGetInsert (
<br>
632 <a href=
"#cups_array_t">cups_array_t
</a> *a
<br>
634 <h4 class=
"parameters">Parameters
</h4>
637 <dd class=
"description">Array
</dd>
639 <h4 class=
"returnvalue">Return Value
</h4>
640 <p class=
"description">Index of the last inserted element
</p>
641 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsArrayIndex">cupsArrayIndex
</a></h3>
642 <p class=
"description">Get the N-th element in the array.
</p>
644 void *cupsArrayIndex (
<br>
645 <a href=
"#cups_array_t">cups_array_t
</a> *a,
<br>
646 int n
<br>
648 <h4 class=
"parameters">Parameters
</h4>
651 <dd class=
"description">Array
</dd>
653 <dd class=
"description">Index into array, starting at
0</dd>
655 <h4 class=
"returnvalue">Return Value
</h4>
656 <p class=
"description">N-th element or
<code>NULL
</code></p>
657 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsArrayInsert">cupsArrayInsert
</a></h3>
658 <p class=
"description">Insert an element in the array.
</p>
660 int cupsArrayInsert (
<br>
661 <a href=
"#cups_array_t">cups_array_t
</a> *a,
<br>
662 void *e
<br>
664 <h4 class=
"parameters">Parameters
</h4>
667 <dd class=
"description">Array
</dd>
669 <dd class=
"description">Element
</dd>
671 <h4 class=
"returnvalue">Return Value
</h4>
672 <p class=
"description">0 on failure,
1 on success
</p>
673 <h4 class=
"discussion">Discussion
</h4>
674 <p class=
"discussion">When inserting an element in a sorted array, non-unique elements are
675 inserted at the beginning of the run. For unsorted arrays, the element
676 is inserted at the beginning of the array.
679 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsArrayLast">cupsArrayLast
</a></h3>
680 <p class=
"description">Get the last element in the array.
</p>
682 void *cupsArrayLast (
<br>
683 <a href=
"#cups_array_t">cups_array_t
</a> *a
<br>
685 <h4 class=
"parameters">Parameters
</h4>
688 <dd class=
"description">Array
</dd>
690 <h4 class=
"returnvalue">Return Value
</h4>
691 <p class=
"description">Last element or
<code>NULL
</code></p>
692 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsArrayNew">cupsArrayNew
</a></h3>
693 <p class=
"description">Create a new array.
</p>
695 <a href=
"#cups_array_t">cups_array_t
</a> *cupsArrayNew (
<br>
696 <a href=
"#cups_array_func_t">cups_array_func_t
</a> f,
<br>
697 void *d
<br>
699 <h4 class=
"parameters">Parameters
</h4>
702 <dd class=
"description">Comparison function
</dd>
704 <dd class=
"description">User data
</dd>
706 <h4 class=
"returnvalue">Return Value
</h4>
707 <p class=
"description">Array
</p>
708 <h3 class=
"function"><span class=
"info"> CUPS
1.3 </span><a name=
"cupsArrayNew2">cupsArrayNew2
</a></h3>
709 <p class=
"description">Create a new array with hash.
</p>
711 <a href=
"#cups_array_t">cups_array_t
</a> *cupsArrayNew2 (
<br>
712 <a href=
"#cups_array_func_t">cups_array_func_t
</a> f,
<br>
713 void *d,
<br>
714 <a href=
"#cups_ahash_func_t">cups_ahash_func_t
</a> h,
<br>
715 int hsize
<br>
717 <h4 class=
"parameters">Parameters
</h4>
720 <dd class=
"description">Comparison function
</dd>
722 <dd class=
"description">User data
</dd>
724 <dd class=
"description">Hash function
</dd>
726 <dd class=
"description">Hash size
</dd>
728 <h4 class=
"returnvalue">Return Value
</h4>
729 <p class=
"description">Array
</p>
730 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsArrayNext">cupsArrayNext
</a></h3>
731 <p class=
"description">Get the next element in the array.
</p>
733 void *cupsArrayNext (
<br>
734 <a href=
"#cups_array_t">cups_array_t
</a> *a
<br>
736 <h4 class=
"parameters">Parameters
</h4>
739 <dd class=
"description">Array
</dd>
741 <h4 class=
"returnvalue">Return Value
</h4>
742 <p class=
"description">Next element or
<code>NULL
</code></p>
743 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsArrayPrev">cupsArrayPrev
</a></h3>
744 <p class=
"description">Get the previous element in the array.
</p>
746 void *cupsArrayPrev (
<br>
747 <a href=
"#cups_array_t">cups_array_t
</a> *a
<br>
749 <h4 class=
"parameters">Parameters
</h4>
752 <dd class=
"description">Array
</dd>
754 <h4 class=
"returnvalue">Return Value
</h4>
755 <p class=
"description">Previous element or
<code>NULL
</code></p>
756 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsArrayRemove">cupsArrayRemove
</a></h3>
757 <p class=
"description">Remove an element from the array.
</p>
759 int cupsArrayRemove (
<br>
760 <a href=
"#cups_array_t">cups_array_t
</a> *a,
<br>
761 void *e
<br>
763 <h4 class=
"parameters">Parameters
</h4>
766 <dd class=
"description">Array
</dd>
768 <dd class=
"description">Element
</dd>
770 <h4 class=
"returnvalue">Return Value
</h4>
771 <p class=
"description">1 on success,
0 on failure
</p>
772 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsArrayRestore">cupsArrayRestore
</a></h3>
773 <p class=
"description">Reset the current element to the last cupsArraySave.
</p>
775 void *cupsArrayRestore (
<br>
776 <a href=
"#cups_array_t">cups_array_t
</a> *a
<br>
778 <h4 class=
"parameters">Parameters
</h4>
781 <dd class=
"description">Array
</dd>
783 <h4 class=
"returnvalue">Return Value
</h4>
784 <p class=
"description">New current element
</p>
785 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsArraySave">cupsArraySave
</a></h3>
786 <p class=
"description">Mark the current element for a later cupsArrayRestore.
</p>
788 int cupsArraySave (
<br>
789 <a href=
"#cups_array_t">cups_array_t
</a> *a
<br>
791 <h4 class=
"parameters">Parameters
</h4>
794 <dd class=
"description">Array
</dd>
796 <h4 class=
"returnvalue">Return Value
</h4>
797 <p class=
"description">1 on success,
0 on failure
</p>
798 <h4 class=
"discussion">Discussion
</h4>
799 <p class=
"discussion">The save/restore stack is guaranteed to be at least
32 elements deep.
802 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsArrayUserData">cupsArrayUserData
</a></h3>
803 <p class=
"description">Return the user data for an array.
</p>
805 void *cupsArrayUserData (
<br>
806 <a href=
"#cups_array_t">cups_array_t
</a> *a
<br>
808 <h4 class=
"parameters">Parameters
</h4>
811 <dd class=
"description">Array
</dd>
813 <h4 class=
"returnvalue">Return Value
</h4>
814 <p class=
"description">User data
</p>
815 <h2 class=
"title"><a name=
"TYPES">Data Types
</a></h2>
816 <h3 class=
"typedef"><a name=
"cups_ahash_func_t">cups_ahash_func_t
</a></h3>
817 <p class=
"description">Array hash function
</p>
819 typedef int (*cups_ahash_func_t)(void *element, void *data);
821 <h3 class=
"typedef"><a name=
"cups_array_func_t">cups_array_func_t
</a></h3>
822 <p class=
"description">Array comparison function
</p>
824 typedef int (*cups_array_func_t)(void *first, void *second, void *data);
826 <h3 class=
"typedef"><a name=
"cups_array_t">cups_array_t
</a></h3>
827 <p class=
"description">CUPS array type
</p>
829 typedef struct _cups_array_s cups_array_t;