]> git.ipfire.org Git - thirdparty/cups.git/blob - doc/help/api-array.html
Load cups into easysw/current.
[thirdparty/cups.git] / doc / help / api-array.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
2 <html>
3 <!-- SECTION: Programming -->
4 <head>
5 <title>Array API</title>
6 <meta name='keywords' content='Programming'>
7 <meta name='creator' content='Mini-XML v2.3'>
8 <style type='text/css'><!--
9 h1, h2, h3, p { font-family: sans-serif; text-align: justify; }
10 tt, pre a:link, pre a:visited, tt a:link, tt a:visited { font-weight: bold; color: #7f0000; }
11 pre { font-weight: bold; color: #7f0000; margin-left: 2em; }
12 span.info { background: #000000; border: solid thin #000000; color: #ffffff; font-size: 80%; font-style: italic; font-weight: bold; white-space: nowrap; }
13 h3 span.info { float: right; font-size: 100%; }
14 h1.title, h2.title, h3.title { border-bottom: solid 2px #000000; }
15 --></style>
16 </head>
17 <body>
18 <!--
19 "$Id: api-array.shtml 5138 2006-02-21 10:49:06Z mike $"
20
21 Array API introduction for the Common UNIX Printing System (CUPS).
22
23 Copyright 1997-2006 by Easy Software Products.
24
25 These coded instructions, statements, and computer programs are the
26 property of Easy Software Products and are protected by Federal
27 copyright law. Distribution and use rights are outlined in the file
28 "LICENSE.txt" which should have been included with this file. If this
29 file is missing or damaged please contact Easy Software Products
30 at:
31
32 Attn: CUPS Licensing Information
33 Easy Software Products
34 44141 Airport View Drive, Suite 204
35 Hollywood, Maryland 20636 USA
36
37 Voice: (301) 373-9600
38 EMail: cups-info@cups.org
39 WWW: http://www.cups.org
40 -->
41
42 <h2 class='title'>Introduction</h2>
43
44 <p>The CUPS array API provides a high-performance generic array
45 container. The contents of the array container can be sorted and
46 the container itself is designed for optimal speed and memory
47 usage under a wide variety of conditions.</p>
48
49 <p>The CUPS scheduler (<tt>cupsd</tt>) and many of the CUPS API
50 functions use the array API to efficiently manage large lists of
51 data.</p>
52
53 <h2 class='title'>General Usage</h2>
54
55 <p>The <var>&lt;cups/array.h&gt;</var> header file must be
56 included to use the <tt>cupsArray</tt> functions.</p>
57
58 <p>Programs using these functions must be linked to the CUPS
59 library: <var>libcups.a</var>, <var>libcups.so.2</var>,
60 <var>libcups.2.dylib</var>, <var>libcups_s.a</var>, or
61 <var>libcups2.lib</var> depending on the platform. The following
62 command compiles <var>myprogram.c</var> using GCC and the CUPS
63 library:</p>
64
65 <pre class='command'>
66 <kbd>gcc -o myprogram myprogram.c -lcups</kbd>
67 </pre>
68
69 <h2 class='title'>Compatibility</h2>
70
71 <p>All of these functions require CUPS 1.2 or higher.</p>
72 <h2 class='title'>Contents</h2>
73 <ul>
74 <li><a href='#FUNCTIONS'>Functions</a></li>
75 <li><a href='#TYPES'>Types</a></li>
76 </ul>
77 <!-- NEW PAGE -->
78 <h2 class='title'><a name='FUNCTIONS'>Functions</a></h2>
79 <ul>
80 <li><a href='#cupsArrayAdd'><tt>cupsArrayAdd()</tt></a> </li>
81 <li><a href='#cupsArrayClear'><tt>cupsArrayClear()</tt></a> </li>
82 <li><a href='#cupsArrayCount'><tt>cupsArrayCount()</tt></a> </li>
83 <li><a href='#cupsArrayCurrent'><tt>cupsArrayCurrent()</tt></a> </li>
84 <li><a href='#cupsArrayDelete'><tt>cupsArrayDelete()</tt></a> </li>
85 <li><a href='#cupsArrayDup'><tt>cupsArrayDup()</tt></a> </li>
86 <li><a href='#cupsArrayFind'><tt>cupsArrayFind()</tt></a> </li>
87 <li><a href='#cupsArrayFirst'><tt>cupsArrayFirst()</tt></a> </li>
88 <li><a href='#cupsArrayGetIndex'><tt>cupsArrayGetIndex()</tt></a> <span class='info'>&nbsp;CUPS 1.3&nbsp;</span></li>
89 <li><a href='#cupsArrayGetInsert'><tt>cupsArrayGetInsert()</tt></a> <span class='info'>&nbsp;CUPS 1.3&nbsp;</span></li>
90 <li><a href='#cupsArrayIndex'><tt>cupsArrayIndex()</tt></a> </li>
91 <li><a href='#cupsArrayInsert'><tt>cupsArrayInsert()</tt></a> </li>
92 <li><a href='#cupsArrayLast'><tt>cupsArrayLast()</tt></a> </li>
93 <li><a href='#cupsArrayNew'><tt>cupsArrayNew()</tt></a> </li>
94 <li><a href='#cupsArrayNext'><tt>cupsArrayNext()</tt></a> </li>
95 <li><a href='#cupsArrayPrev'><tt>cupsArrayPrev()</tt></a> </li>
96 <li><a href='#cupsArrayRemove'><tt>cupsArrayRemove()</tt></a> </li>
97 <li><a href='#cupsArrayRestore'><tt>cupsArrayRestore()</tt></a> </li>
98 <li><a href='#cupsArraySave'><tt>cupsArraySave()</tt></a> </li>
99 <li><a href='#cupsArrayUserData'><tt>cupsArrayUserData()</tt></a> </li>
100 </ul>
101 <!-- NEW PAGE -->
102 <h3 class='title'><a name='cupsArrayAdd'>cupsArrayAdd()</a></h3>
103 <h4>Description</h4>
104 <p>Add an element to the array.
105
106 When adding an element to a sorted array, non-unique elements are
107 appended at the end of the run. For unsorted arrays, the element
108 is inserted at the end of the array.</p>
109 <h4>Syntax</h4>
110 <pre>
111 int
112 cupsArrayAdd(
113 <a href='#cups_array_t'>cups_array_t</a> * a,
114 void * e);
115 </pre>
116 <h4>Arguments</h4>
117 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
118 <thead><tr><th>Name</th><th>Description</th></tr></thead>
119 <tbody>
120 <tr><td><tt>a</tt></td><td>Array</td></tr>
121 <tr><td><tt>e</tt></td><td>Element</td></tr>
122 </tbody></table></div>
123 <h4>Returns</h4>
124 <p>1 on success, 0 on failure</p>
125 <!-- NEW PAGE -->
126 <h3 class='title'><a name='cupsArrayClear'>cupsArrayClear()</a></h3>
127 <h4>Description</h4>
128 <p>Clear the array.</p>
129 <h4>Syntax</h4>
130 <pre>
131 void
132 cupsArrayClear(
133 <a href='#cups_array_t'>cups_array_t</a> * a);
134 </pre>
135 <h4>Arguments</h4>
136 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
137 <thead><tr><th>Name</th><th>Description</th></tr></thead>
138 <tbody>
139 <tr><td><tt>a</tt></td><td>Array</td></tr>
140 </tbody></table></div>
141 <h4>Returns</h4>
142 <p>Nothing.</p>
143 <!-- NEW PAGE -->
144 <h3 class='title'><a name='cupsArrayCount'>cupsArrayCount()</a></h3>
145 <h4>Description</h4>
146 <p>Get the number of elements in the array.</p>
147 <h4>Syntax</h4>
148 <pre>
149 int
150 cupsArrayCount(
151 <a href='#cups_array_t'>cups_array_t</a> * a);
152 </pre>
153 <h4>Arguments</h4>
154 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
155 <thead><tr><th>Name</th><th>Description</th></tr></thead>
156 <tbody>
157 <tr><td><tt>a</tt></td><td>Array</td></tr>
158 </tbody></table></div>
159 <h4>Returns</h4>
160 <p>Number of elements</p>
161 <!-- NEW PAGE -->
162 <h3 class='title'><a name='cupsArrayCurrent'>cupsArrayCurrent()</a></h3>
163 <h4>Description</h4>
164 <p>Return the current element in the array.</p>
165 <h4>Syntax</h4>
166 <pre>
167 void *
168 cupsArrayCurrent(
169 <a href='#cups_array_t'>cups_array_t</a> * a);
170 </pre>
171 <h4>Arguments</h4>
172 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
173 <thead><tr><th>Name</th><th>Description</th></tr></thead>
174 <tbody>
175 <tr><td><tt>a</tt></td><td>Array</td></tr>
176 </tbody></table></div>
177 <h4>Returns</h4>
178 <p>Element</p>
179 <!-- NEW PAGE -->
180 <h3 class='title'><a name='cupsArrayDelete'>cupsArrayDelete()</a></h3>
181 <h4>Description</h4>
182 <p>Free all memory used by the array.</p>
183 <h4>Syntax</h4>
184 <pre>
185 void
186 cupsArrayDelete(
187 <a href='#cups_array_t'>cups_array_t</a> * a);
188 </pre>
189 <h4>Arguments</h4>
190 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
191 <thead><tr><th>Name</th><th>Description</th></tr></thead>
192 <tbody>
193 <tr><td><tt>a</tt></td><td>Array</td></tr>
194 </tbody></table></div>
195 <h4>Returns</h4>
196 <p>Nothing.</p>
197 <!-- NEW PAGE -->
198 <h3 class='title'><a name='cupsArrayDup'>cupsArrayDup()</a></h3>
199 <h4>Description</h4>
200 <p>Duplicate the array.</p>
201 <h4>Syntax</h4>
202 <pre>
203 <a href='#cups_array_t'>cups_array_t</a> *
204 cupsArrayDup(
205 <a href='#cups_array_t'>cups_array_t</a> * a);
206 </pre>
207 <h4>Arguments</h4>
208 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
209 <thead><tr><th>Name</th><th>Description</th></tr></thead>
210 <tbody>
211 <tr><td><tt>a</tt></td><td>Array</td></tr>
212 </tbody></table></div>
213 <h4>Returns</h4>
214 <p>Duplicate array</p>
215 <!-- NEW PAGE -->
216 <h3 class='title'><a name='cupsArrayFind'>cupsArrayFind()</a></h3>
217 <h4>Description</h4>
218 <p>Find an element in the array.</p>
219 <h4>Syntax</h4>
220 <pre>
221 void *
222 cupsArrayFind(
223 <a href='#cups_array_t'>cups_array_t</a> * a,
224 void * e);
225 </pre>
226 <h4>Arguments</h4>
227 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
228 <thead><tr><th>Name</th><th>Description</th></tr></thead>
229 <tbody>
230 <tr><td><tt>a</tt></td><td>Array</td></tr>
231 <tr><td><tt>e</tt></td><td>Element</td></tr>
232 </tbody></table></div>
233 <h4>Returns</h4>
234 <p>Element found or NULL</p>
235 <!-- NEW PAGE -->
236 <h3 class='title'><a name='cupsArrayFirst'>cupsArrayFirst()</a></h3>
237 <h4>Description</h4>
238 <p>Get the first element in the array.</p>
239 <h4>Syntax</h4>
240 <pre>
241 void *
242 cupsArrayFirst(
243 <a href='#cups_array_t'>cups_array_t</a> * a);
244 </pre>
245 <h4>Arguments</h4>
246 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
247 <thead><tr><th>Name</th><th>Description</th></tr></thead>
248 <tbody>
249 <tr><td><tt>a</tt></td><td>Array</td></tr>
250 </tbody></table></div>
251 <h4>Returns</h4>
252 <p>First element or NULL</p>
253 <!-- NEW PAGE -->
254 <h3 class='title'><span class='info'>&nbsp;CUPS 1.3&nbsp;</span><a name='cupsArrayGetIndex'>cupsArrayGetIndex()</a></h3>
255 <h4>Description</h4>
256 <p>Get the index of the current element.
257
258 </p>
259 <h4>Syntax</h4>
260 <pre>
261 int
262 cupsArrayGetIndex(
263 <a href='#cups_array_t'>cups_array_t</a> * a);
264 </pre>
265 <h4>Arguments</h4>
266 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
267 <thead><tr><th>Name</th><th>Description</th></tr></thead>
268 <tbody>
269 <tr><td><tt>a</tt></td><td>Array</td></tr>
270 </tbody></table></div>
271 <h4>Returns</h4>
272 <p>Index of the current element</p>
273 <!-- NEW PAGE -->
274 <h3 class='title'><span class='info'>&nbsp;CUPS 1.3&nbsp;</span><a name='cupsArrayGetInsert'>cupsArrayGetInsert()</a></h3>
275 <h4>Description</h4>
276 <p>Get the index of the last inserted element.
277
278 </p>
279 <h4>Syntax</h4>
280 <pre>
281 int
282 cupsArrayGetInsert(
283 <a href='#cups_array_t'>cups_array_t</a> * a);
284 </pre>
285 <h4>Arguments</h4>
286 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
287 <thead><tr><th>Name</th><th>Description</th></tr></thead>
288 <tbody>
289 <tr><td><tt>a</tt></td><td>Array</td></tr>
290 </tbody></table></div>
291 <h4>Returns</h4>
292 <p>Index of the last inserted element</p>
293 <!-- NEW PAGE -->
294 <h3 class='title'><a name='cupsArrayIndex'>cupsArrayIndex()</a></h3>
295 <h4>Description</h4>
296 <p>Get the N-th element in the array.</p>
297 <h4>Syntax</h4>
298 <pre>
299 void *
300 cupsArrayIndex(
301 <a href='#cups_array_t'>cups_array_t</a> * a,
302 int n);
303 </pre>
304 <h4>Arguments</h4>
305 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
306 <thead><tr><th>Name</th><th>Description</th></tr></thead>
307 <tbody>
308 <tr><td><tt>a</tt></td><td>Array</td></tr>
309 <tr><td><tt>n</tt></td><td>Index into array, starting at 0</td></tr>
310 </tbody></table></div>
311 <h4>Returns</h4>
312 <p>N-th element or NULL</p>
313 <!-- NEW PAGE -->
314 <h3 class='title'><a name='cupsArrayInsert'>cupsArrayInsert()</a></h3>
315 <h4>Description</h4>
316 <p>Insert an element in the array.
317
318 When inserting an element in a sorted array, non-unique elements are
319 inserted at the beginning of the run. For unsorted arrays, the element
320 is inserted at the beginning of the array.</p>
321 <h4>Syntax</h4>
322 <pre>
323 int
324 cupsArrayInsert(
325 <a href='#cups_array_t'>cups_array_t</a> * a,
326 void * e);
327 </pre>
328 <h4>Arguments</h4>
329 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
330 <thead><tr><th>Name</th><th>Description</th></tr></thead>
331 <tbody>
332 <tr><td><tt>a</tt></td><td>Array</td></tr>
333 <tr><td><tt>e</tt></td><td>Element</td></tr>
334 </tbody></table></div>
335 <h4>Returns</h4>
336 <p>0 on failure, 1 on success</p>
337 <!-- NEW PAGE -->
338 <h3 class='title'><a name='cupsArrayLast'>cupsArrayLast()</a></h3>
339 <h4>Description</h4>
340 <p>Get the last element in the array.</p>
341 <h4>Syntax</h4>
342 <pre>
343 void *
344 cupsArrayLast(
345 <a href='#cups_array_t'>cups_array_t</a> * a);
346 </pre>
347 <h4>Arguments</h4>
348 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
349 <thead><tr><th>Name</th><th>Description</th></tr></thead>
350 <tbody>
351 <tr><td><tt>a</tt></td><td>Array</td></tr>
352 </tbody></table></div>
353 <h4>Returns</h4>
354 <p>Last element or NULL</p>
355 <!-- NEW PAGE -->
356 <h3 class='title'><a name='cupsArrayNew'>cupsArrayNew()</a></h3>
357 <h4>Description</h4>
358 <p>Create a new array.</p>
359 <h4>Syntax</h4>
360 <pre>
361 <a href='#cups_array_t'>cups_array_t</a> *
362 cupsArrayNew(
363 <a href='#cups_array_func_t'>cups_array_func_t</a> f,
364 void * d);
365 </pre>
366 <h4>Arguments</h4>
367 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
368 <thead><tr><th>Name</th><th>Description</th></tr></thead>
369 <tbody>
370 <tr><td><tt>f</tt></td><td>Comparison function</td></tr>
371 <tr><td><tt>d</tt></td><td>User data</td></tr>
372 </tbody></table></div>
373 <h4>Returns</h4>
374 <p>Array</p>
375 <!-- NEW PAGE -->
376 <h3 class='title'><a name='cupsArrayNext'>cupsArrayNext()</a></h3>
377 <h4>Description</h4>
378 <p>Get the next element in the array.</p>
379 <h4>Syntax</h4>
380 <pre>
381 void *
382 cupsArrayNext(
383 <a href='#cups_array_t'>cups_array_t</a> * a);
384 </pre>
385 <h4>Arguments</h4>
386 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
387 <thead><tr><th>Name</th><th>Description</th></tr></thead>
388 <tbody>
389 <tr><td><tt>a</tt></td><td>Array</td></tr>
390 </tbody></table></div>
391 <h4>Returns</h4>
392 <p>Next element or NULL</p>
393 <!-- NEW PAGE -->
394 <h3 class='title'><a name='cupsArrayPrev'>cupsArrayPrev()</a></h3>
395 <h4>Description</h4>
396 <p>Get the previous element in the array.</p>
397 <h4>Syntax</h4>
398 <pre>
399 void *
400 cupsArrayPrev(
401 <a href='#cups_array_t'>cups_array_t</a> * a);
402 </pre>
403 <h4>Arguments</h4>
404 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
405 <thead><tr><th>Name</th><th>Description</th></tr></thead>
406 <tbody>
407 <tr><td><tt>a</tt></td><td>Array</td></tr>
408 </tbody></table></div>
409 <h4>Returns</h4>
410 <p>Previous element or NULL</p>
411 <!-- NEW PAGE -->
412 <h3 class='title'><a name='cupsArrayRemove'>cupsArrayRemove()</a></h3>
413 <h4>Description</h4>
414 <p>Remove an element from the array.</p>
415 <h4>Syntax</h4>
416 <pre>
417 int
418 cupsArrayRemove(
419 <a href='#cups_array_t'>cups_array_t</a> * a,
420 void * e);
421 </pre>
422 <h4>Arguments</h4>
423 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
424 <thead><tr><th>Name</th><th>Description</th></tr></thead>
425 <tbody>
426 <tr><td><tt>a</tt></td><td>Array</td></tr>
427 <tr><td><tt>e</tt></td><td>Element</td></tr>
428 </tbody></table></div>
429 <h4>Returns</h4>
430 <p>1 on success, 0 on failure</p>
431 <!-- NEW PAGE -->
432 <h3 class='title'><a name='cupsArrayRestore'>cupsArrayRestore()</a></h3>
433 <h4>Description</h4>
434 <p>Reset the current element to the last cupsArraySave.</p>
435 <h4>Syntax</h4>
436 <pre>
437 void *
438 cupsArrayRestore(
439 <a href='#cups_array_t'>cups_array_t</a> * a);
440 </pre>
441 <h4>Arguments</h4>
442 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
443 <thead><tr><th>Name</th><th>Description</th></tr></thead>
444 <tbody>
445 <tr><td><tt>a</tt></td><td>Array</td></tr>
446 </tbody></table></div>
447 <h4>Returns</h4>
448 <p>New current element</p>
449 <!-- NEW PAGE -->
450 <h3 class='title'><a name='cupsArraySave'>cupsArraySave()</a></h3>
451 <h4>Description</h4>
452 <p>Mark the current element for a later cupsArrayRestore.
453
454 The save/restore stack is guaranteed to be at least 32 elements deep.</p>
455 <h4>Syntax</h4>
456 <pre>
457 int
458 cupsArraySave(
459 <a href='#cups_array_t'>cups_array_t</a> * a);
460 </pre>
461 <h4>Arguments</h4>
462 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
463 <thead><tr><th>Name</th><th>Description</th></tr></thead>
464 <tbody>
465 <tr><td><tt>a</tt></td><td>Array</td></tr>
466 </tbody></table></div>
467 <h4>Returns</h4>
468 <p>1 on success, 0 on failure</p>
469 <!-- NEW PAGE -->
470 <h3 class='title'><a name='cupsArrayUserData'>cupsArrayUserData()</a></h3>
471 <h4>Description</h4>
472 <p>Return the user data for an array.</p>
473 <h4>Syntax</h4>
474 <pre>
475 void *
476 cupsArrayUserData(
477 <a href='#cups_array_t'>cups_array_t</a> * a);
478 </pre>
479 <h4>Arguments</h4>
480 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
481 <thead><tr><th>Name</th><th>Description</th></tr></thead>
482 <tbody>
483 <tr><td><tt>a</tt></td><td>Array</td></tr>
484 </tbody></table></div>
485 <h4>Returns</h4>
486 <p>User data</p>
487 <!-- NEW PAGE -->
488 <h2 class='title'><a name='TYPES'>Types</a></h2>
489 <ul>
490 <li><a href='#cups_array_func_t'><tt>cups_array_func_t</tt></a> </li>
491 <li><a href='#cups_array_t'><tt>cups_array_t</tt></a> </li>
492 </ul>
493 <!-- NEW PAGE -->
494 <h3 class='title'><a name='cups_array_func_t'>cups_array_func_t</a></h3>
495 <h4>Description</h4>
496 <p>Array comparison function</p>
497 <h4>Definition</h4>
498 <pre>
499 typedef int (*cups_array_func_t)(void *first, void *second, void *data);
500 </pre>
501 <!-- NEW PAGE -->
502 <h3 class='title'><a name='cups_array_t'>cups_array_t</a></h3>
503 <h4>Description</h4>
504 <p>CUPS array type</p>
505 <h4>Definition</h4>
506 <pre>
507 typedef struct _cups_array_s cups_array_t;
508 </pre>
509 </body>
510 </html>