]> git.ipfire.org Git - thirdparty/cups.git/blob - doc/help/api-cups.html
Merge changes from CUPS 1.4svn-r7282.
[thirdparty/cups.git] / doc / help / api-cups.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>CUPS API</title>
6 <meta name="keywords" content="Programming">
7 <meta name="creator" content="Mini-XML v2.5">
8 <style type="text/css"><!--
9 BODY {
10 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
11 }
12
13 H1, H2, H3, H4, H5, H6, P, TD, TH {
14 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
15 }
16
17 KBD {
18 font-family: monaco, courier, monospace;
19 font-weight: bold;
20 }
21
22 PRE {
23 font-family: monaco, courier, monospace;
24 }
25
26 PRE.command {
27 margin-left: 36pt;
28 }
29
30 PRE.example {
31 background: #eeeeee;
32 border: dotted thin #999999;
33 margin-left: 36pt;
34 padding: 10px;
35 }
36
37 PRE.command EM, PRE.example EM {
38 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
39 }
40
41 P.command {
42 font-family: monaco, courier, monospace;
43 margin-left: 36pt;
44 }
45
46 P.formula {
47 font-style: italic;
48 margin-left: 36pt;
49 }
50
51 BLOCKQUOTE {
52 background: #cccccc;
53 border: solid thin #999999;
54 padding: 10pt;
55 }
56
57 A:link, A:visited {
58 text-decoration: none;
59 font-weight: bold;
60 }
61
62 A:link:hover, A:visited:hover, A:active {
63 text-decoration: underline;
64 font-weight: bold;
65 }
66
67 SUB, SUP {
68 font-size: 50%;
69 }
70
71 DIV.table TABLE {
72 border: solid thin #999999;
73 border-collapse: collapse;
74 border-spacing: 0;
75 margin-left: auto;
76 margin-right: auto;
77 }
78
79 DIV.table CAPTION {
80 caption-side: top;
81 font-size: 120%;
82 font-style: italic;
83 font-weight: bold;
84 margin-left: auto;
85 margin-right: auto;
86 }
87
88 DIV.table TABLE TD {
89 border: solid thin #cccccc;
90 padding-top: 5pt;
91 }
92
93 DIV.table TABLE TH {
94 background: #cccccc;
95 border: none;
96 border-bottom: solid thin #999999;
97 }
98
99 DIV.figure TABLE {
100 margin-left: auto;
101 margin-right: auto;
102 }
103
104 DIV.figure CAPTION {
105 caption-side: bottom;
106 font-size: 120%;
107 font-style: italic;
108 font-weight: bold;
109 margin-left: auto;
110 margin-right: auto;
111 }
112
113 TH.label {
114 padding-top: 5pt;
115 text-align: right;
116 vertical-align: top;
117 }
118
119 HR {
120 border: solid thin;
121 }
122
123 SPAN.info {
124 background: #000000;
125 border: thin solid #000000;
126 color: #ffffff;
127 font-size: 80%;
128 font-style: italic;
129 font-weight: bold;
130 white-space: nowrap;
131 }
132
133 H2 SPAN.info, H3 SPAN.info, H4 SPAN.info {
134 float: right;
135 font-size: 100%;
136 }
137
138 H2.title, H3.title {
139 border-bottom: solid 2pt #000000;
140 }
141
142 DT {
143 margin-left: 36pt;
144 margin-top: 12pt;
145 }
146
147 DD {
148 margin-left: 54pt;
149 }
150
151 DL.category DT {
152 font-weight: bold;
153 }
154
155 P.summary {
156 margin-left: 36pt;
157 font-family: monaco, courier, monospace;
158 }
159
160 SPAN.message {
161 font-style: italic;
162 font-size: smaller;
163 }
164
165 DIV.summary TABLE {
166 border: solid thin #999999;
167 border-collapse: collapse;
168 border-spacing: 0;
169 margin: 10px;
170 }
171
172 DIV.summary TABLE TD, DIV.summary TABLE TH {
173 border: solid thin #999999;
174 padding: 5px;
175 text-align: left;
176 vertical-align: top;
177 }
178
179 DIV.summary TABLE THEAD TH {
180 background: #eeeeee;
181 }
182
183 /* API documentation styles... */
184 div.body h1 {
185 margin: 0;
186 }
187 div.body h2 {
188 margin-top: 1.5em;
189 }
190 div.body h3, div.body h4, div.body h5 {
191 margin-bottom: 0.5em;
192 margin-top: 1.5em;
193 }
194 .class, .enumeration, .function, .struct, .typedef, .union {
195 border-bottom: solid thin #999999;
196 margin-bottom: 0;
197 margin-top: 2em;
198 }
199 .description {
200 margin-top: 0.5em;
201 }
202 code, p.code, pre, ul.code li {
203 font-family: monaco, courier, monospace;
204 font-size: 90%;
205 }
206 ul.code, ul.contents, ul.subcontents {
207 list-style-type: none;
208 margin: 0;
209 padding-left: 0;
210 }
211 ul.code li {
212 margin: 0;
213 }
214 ul.contents > li {
215 margin-top: 1em;
216 }
217 ul.contents li ul.code, ul.contents li ul.subcontents {
218 padding-left: 2em;
219 }
220 div.body dl {
221 margin-left: 0;
222 margin-top: 0;
223 }
224 div.body dt {
225 font-style: italic;
226 margin-left: 0;
227 margin-top: 0;
228 }
229 div.body dd {
230 margin-bottom: 0.5em;
231 }
232
233 /* This is just for the HTML files generated with the framedhelp target */
234 div.contents {
235 background: #e8e8e8;
236 border: solid thin black;
237 padding: 10px;
238 }
239 div.contents h1 {
240 font-size: 110%;
241 }
242 div.contents h2 {
243 font-size: 100%;
244 }
245 div.contents ul.contents {
246 font-size: 80%;
247 }
248 --></style>
249 </head>
250 <body>
251 <div class='body'>
252 <!--
253 "$Id: api-cups.header 7279 2008-01-31 01:50:44Z mike $"
254
255 CUPS API header for the Common UNIX Printing System (CUPS).
256
257 Copyright 2008 by Apple Inc.
258
259 These coded instructions, statements, and computer programs are the
260 property of Apple Inc. and are protected by Federal copyright
261 law. Distribution and use rights are outlined in the file "LICENSE.txt"
262 which should have been included with this file. If this file is
263 file is missing or damaged, see the license at "http://www.cups.org/".
264 -->
265
266 <h1 class="title">CUPS API</h1>
267
268 <div class='summary'><table summary='General Information'>
269 <thead>
270 <tr>
271 <th>Header</th>
272 <th>cups/cups.h</th>
273 </tr>
274 </thead>
275 <tbody>
276 <tr>
277 <th>Library</th>
278 <td>-lcups</td>
279 </tr>
280 <tr>
281 <th>See Also</th>
282 <td>Programming: <a href='api-overview.html' target='_top'>Introduction to CUPS Programming</a><br>
283 Programming: <a href='api-array.html' target='_top'>Array API</a><br>
284 Programming: <a href='api-filedir.html' target='_top'>File and Directory APIs</a><br>
285 Programming: <a href='api-filter.html' target='_top'>Filter and Backend Programming</a><br>
286 Programming: <a href='api-httpipp.html' target='_top'>HTTP and IPP APIs</a><br>
287 Programming: <a href='api-ppd.html' target='_top'>PPD API</a><br>
288 Programming: <a href='api-raster.html' target='_top'>Raster API</a></td>
289 </tr>
290 </tbody>
291 </table></div>
292 <h2 class="title">Contents</h2>
293 <ul class="contents">
294 </li>
295 <li><a href="#OVERVIEW">Overview</a><ul class="subcontents">
296 <li><a href="#PRINTERS_AND_CLASSES">Printers and Classes</a></li>
297 <li><a href="#OPTIONS">Options</a></li>
298 <li><a href="#PRINT_JOBS">Print Jobs</a></li>
299 <li><a href="#ERROR_HANDLING">Error Handling</a></li>
300 <li><a href="#PASSWORDS_AND_AUTHENTICATION">Passwords and Authentication</a></li>
301 </ul></li>
302 <li><a href="#FUNCTIONS">Functions</a><ul class="code">
303 <li><a href="#cupsAddDest" title="Add a destination to the list of destinations.">cupsAddDest</a></li>
304 <li><a href="#cupsAddOption" title="Add an option to an option array.">cupsAddOption</a></li>
305 <li><a href="#cupsCancelJob" title="Cancel a print job on the default server.">cupsCancelJob</a></li>
306 <li><a href="#cupsCancelJob2" title="Cancel or purge a print job.">cupsCancelJob2</a></li>
307 <li><a href="#cupsCreateJob" title="Create an empty job.">cupsCreateJob</a></li>
308 <li><a href="#cupsEncryption" title="Get the default encryption settings.">cupsEncryption</a></li>
309 <li><a href="#cupsFinishDocument" title="Finish sending a document.">cupsFinishDocument</a></li>
310 <li><a href="#cupsFreeDests" title="Free the memory used by the list of destinations.">cupsFreeDests</a></li>
311 <li><a href="#cupsFreeJobs" title="Free memory used by job data.">cupsFreeJobs</a></li>
312 <li><a href="#cupsFreeOptions" title="Free all memory used by options.">cupsFreeOptions</a></li>
313 <li><a href="#cupsGetClasses" title="Get a list of printer classes from the default server.">cupsGetClasses</a></li>
314 <li><a href="#cupsGetDefault" title="Get the default printer or class for the default server.">cupsGetDefault</a></li>
315 <li><a href="#cupsGetDefault2" title="Get the default printer or class for the specified server.">cupsGetDefault2</a></li>
316 <li><a href="#cupsGetDest" title="Get the named destination from the list.">cupsGetDest</a></li>
317 <li><a href="#cupsGetDests" title="Get the list of destinations from the default server.">cupsGetDests</a></li>
318 <li><a href="#cupsGetDests2" title="Get the list of destinations from the specified server.">cupsGetDests2</a></li>
319 <li><a href="#cupsGetFd" title="Get a file from the server.">cupsGetFd</a></li>
320 <li><a href="#cupsGetFile" title="Get a file from the server.">cupsGetFile</a></li>
321 <li><a href="#cupsGetJobs" title="Get the jobs from the default server.">cupsGetJobs</a></li>
322 <li><a href="#cupsGetJobs2" title="Get the jobs from the specified server.">cupsGetJobs2</a></li>
323 <li><a href="#cupsGetNamedDest" title="Get options for the named destination.">cupsGetNamedDest</a></li>
324 <li><a href="#cupsGetOption" title="Get an option value.">cupsGetOption</a></li>
325 <li><a href="#cupsGetPPD" title="Get the PPD file for a printer on the default server.">cupsGetPPD</a></li>
326 <li><a href="#cupsGetPPD2" title="Get the PPD file for a printer from the specified server.">cupsGetPPD2</a></li>
327 <li><a href="#cupsGetPPD3" title="Get the PPD file for a printer on the specified
328 server if it has changed.">cupsGetPPD3</a></li>
329 <li><a href="#cupsGetPassword" title="Get a password from the user.">cupsGetPassword</a></li>
330 <li><a href="#cupsGetPrinters" title="Get a list of printers from the default server.">cupsGetPrinters</a></li>
331 <li><a href="#cupsGetServerPPD" title="Get an available PPD file from the server.">cupsGetServerPPD</a></li>
332 <li><a href="#cupsLangDefault" title="Return the default language.">cupsLangDefault</a></li>
333 <li><a href="#cupsLangEncoding" title="Return the character encoding (us-ascii, etc.)
334 for the given language.">cupsLangEncoding</a></li>
335 <li><a href="#cupsLangFlush" title="Flush all language data out of the cache.">cupsLangFlush</a></li>
336 <li><a href="#cupsLangFree" title="Free language data.">cupsLangFree</a></li>
337 <li><a href="#cupsLangGet" title="Get a language.">cupsLangGet</a></li>
338 <li><a href="#cupsLastError" title="Return the last IPP status code.">cupsLastError</a></li>
339 <li><a href="#cupsLastErrorString" title="Return the last IPP status-message.">cupsLastErrorString</a></li>
340 <li><a href="#cupsNotifySubject" title="Return the subject for the given notification message.">cupsNotifySubject</a></li>
341 <li><a href="#cupsNotifyText" title="Return the text for the given notification message.">cupsNotifyText</a></li>
342 <li><a href="#cupsParseOptions" title="Parse options from a command-line argument.">cupsParseOptions</a></li>
343 <li><a href="#cupsPrintFile" title="Print a file to a printer or class on the default server.">cupsPrintFile</a></li>
344 <li><a href="#cupsPrintFile2" title="Print a file to a printer or class on the specified
345 server.">cupsPrintFile2</a></li>
346 <li><a href="#cupsPrintFiles" title="Print one or more files to a printer or class on the
347 default server.">cupsPrintFiles</a></li>
348 <li><a href="#cupsPrintFiles2" title="Print one or more files to a printer or class on the
349 specified server.">cupsPrintFiles2</a></li>
350 <li><a href="#cupsPutFd" title="Put a file on the server.">cupsPutFd</a></li>
351 <li><a href="#cupsPutFile" title="Put a file on the server.">cupsPutFile</a></li>
352 <li><a href="#cupsRemoveDest" title="Remove a destination from the destination list.">cupsRemoveDest</a></li>
353 <li><a href="#cupsRemoveOption" title="Remove an option from an option array.">cupsRemoveOption</a></li>
354 <li><a href="#cupsServer" title="Return the hostname/address of the default server.">cupsServer</a></li>
355 <li><a href="#cupsSetDefaultDest" title="Set the default destination.">cupsSetDefaultDest</a></li>
356 <li><a href="#cupsSetDests" title="Save the list of destinations for the default server.">cupsSetDests</a></li>
357 <li><a href="#cupsSetDests2" title="Save the list of destinations for the specified server.">cupsSetDests2</a></li>
358 <li><a href="#cupsSetEncryption" title="Set the encryption preference.">cupsSetEncryption</a></li>
359 <li><a href="#cupsSetPasswordCB" title="Set the password callback for CUPS.">cupsSetPasswordCB</a></li>
360 <li><a href="#cupsSetServer" title="Set the default server name.">cupsSetServer</a></li>
361 <li><a href="#cupsSetUser" title="Set the default user name.">cupsSetUser</a></li>
362 <li><a href="#cupsStartDocument" title="Add a document to a job created with cupsCreateJob().">cupsStartDocument</a></li>
363 <li><a href="#cupsTempFd" title="Creates a temporary file.">cupsTempFd</a></li>
364 <li><a href="#cupsTempFile" title="Generates a temporary filename.">cupsTempFile</a></li>
365 <li><a href="#cupsTempFile2" title="Creates a temporary CUPS file.">cupsTempFile2</a></li>
366 <li><a href="#cupsUser" title="Return the current user's name.">cupsUser</a></li>
367 </ul>
368 <li><a href="#TYPES">Data Types</a><ul class="code">
369 <li><a href="#cups_dest_t" title="Destination">cups_dest_t</a></li>
370 <li><a href="#cups_job_t" title="Job">cups_job_t</a></li>
371 <li><a href="#cups_option_t" title="Printer Options">cups_option_t</a></li>
372 <li><a href="#cups_password_cb_t" title="Password callback">cups_password_cb_t</a></li>
373 <li><a href="#cups_ptype_t" title="Printer type/capability bits">cups_ptype_t</a></li>
374 </ul></li>
375 <li><a href="#STRUCTURES">Structures</a><ul class="code">
376 <li><a href="#cups_dest_s" title="Destination">cups_dest_s</a></li>
377 <li><a href="#cups_job_s" title="Job">cups_job_s</a></li>
378 <li><a href="#cups_option_s" title="Printer Options">cups_option_s</a></li>
379 </ul></li>
380 <li><a href="#ENUMERATIONS">Constants</a><ul class="code">
381 <li><a href="#cups_ptype_e" title="Printer type/capability bit constants">cups_ptype_e</a></li>
382 </ul></li>
383 </ul>
384 <!--
385 "$Id: api-cups.shtml 7258 2008-01-28 00:15:05Z mike $"
386
387 CUPS API introduction for the Common UNIX Printing System (CUPS).
388
389 Copyright 2007-2008 by Apple Inc.
390 Copyright 1997-2006 by Easy Software Products, all rights reserved.
391
392 These coded instructions, statements, and computer programs are the
393 property of Apple Inc. and are protected by Federal copyright
394 law. Distribution and use rights are outlined in the file "LICENSE.txt"
395 which should have been included with this file. If this file is
396 file is missing or damaged, see the license at "http://www.cups.org/".
397 -->
398
399 <h2 class='title'><a name='OVERVIEW'>Overview</a></h2>
400
401 <p>The CUPS API provides the convenience functions needed to support
402 applications, filters, printer drivers, and backends that need to interface
403 with the CUPS scheduler.</p>
404
405 <h3><a name='PRINTERS_AND_CLASSES'>Printers and Classes</a></h3>
406
407 <p>Printers and classes (collections of printers) are accessed through
408 the <a href="#cups_dest_t"><code>cups_dest_t</code></a> structure which
409 includes the name (<code>name</code>), instance (<code>instance</code> -
410 a way of selected certain saved options), and the options and attributes
411 associated with that destination (<code>num_options</code> and
412 <code>options</code>). Destinations are created using the
413 <a href="#cupsGetDests"><code>cupsGetDests</code></a> function and freed
414 using the <a href='#cupsFreeDests'><code>cupsFreeDests</code></a> function.
415 The <a href='#cupsGetDest'><code>cupsGetDest</code></a> function finds a
416 specific destination for printing:</p>
417
418 <pre class='example'>
419 #include &lt;cups/cups.h&gt;
420
421 <a href='#cups_dest_t'>cups_dest_t</a> *dests;
422 int num_dests = <a href='#cupsGetDests'>cupsGetDests</a>(&amp;dests);
423 <a href='#cups_dest_t'>cups_dest_t</a> *dest = <a href='#cupsGetDest'>cupsGetDest</a>("name", NULL, num_dests, dests);
424
425 /* do something wiith dest */
426
427 <a href='#cupsFreeDests'>cupsFreeDests</a>(num_dests, dests);
428 </pre>
429
430 <p>Passing <code>NULL</code> to
431 <a href='#cupsGetDest'><code>cupsGetDest</code></a> for the destination name
432 will return the default destination. Similarly, passing a <code>NULL</code>
433 instance will return the default instance for that destination.</p>
434
435 <div class='table'><table summary='Table 1: Printer Attributes' width='80%'>
436 <caption>Table 1: <a name='TABLE1'>Printer Attributes</a></caption>
437 <thead>
438 <tr>
439 <th>Attribute Name</th>
440 <th>Description</th>
441 </tr>
442 </thead>
443 <tbody>
444 <tr>
445 <td>"auth-info-required"</td>
446 <td>The type of authentication required for printing to this
447 destination: "none", "username,password", "domain,username,password",
448 or "negotiate" (Kerberos)</td>
449 </tr>
450 <tr>
451 <td>"printer-info"</td>
452 <td>The human-readable description of the destination such as "My
453 Laser Printer".</td>
454 </tr>
455 <tr>
456 <td>"printer-is-accepting-jobs"</td>
457 <td>"1" if the destination is accepting new jobs, "0" if not.</td>
458 </tr>
459 <tr>
460 <td>"printer-is-shared"</td>
461 <td>"1" if the destination is being shared with other computers, "0" if
462 not.</td>
463 </tr>
464 <tr>
465 <td>"printer-location"</td>
466 <td>The human-readable location of the destination such as "Lab 4".</td>
467 </tr>
468 <tr>
469 <td>"printer-make-and-model"</td>
470 <td>The human-readable make and model of the destination such as "HP
471 LaserJet 4000 Series".</td>
472 </tr>
473 <tr>
474 <td>"printer-state"</td>
475 <td>"3" if the destination is idle, "4" if the destination is printing
476 a job, and "5" if the destination is stopped.</td>
477 </tr>
478 <tr>
479 <td>"printer-state-change-time"</td>
480 <td>The UNIX time when the destination entered the current state.</td>
481 </tr>
482 <tr>
483 <td>"printer-state-reasons"</td>
484 <td>Additional comma-delimited state keywords for the destination
485 such as "media-tray-empty-error" and "toner-low-warning".</td>
486 </tr>
487 <tr>
488 <td>"printer-type"</td>
489 <td>The <a href='#cups_printer_t'><code>cups_printer_t</code></a>
490 value associated with the destination.</td>
491 </tr>
492 </tbody>
493 </table></div>
494
495 <h3><a name='OPTIONS'>Options</a></h3>
496
497 <p>Options are stored in arrays of
498 <a href='#cups_option_t'><code>cups_option_t</code></a> structures. Each
499 option has a name (<code>name</code>) and value (<code>value</code>)
500 associated with it. The <a href='#cups_dest_t'><code>cups_dest_t</code></a>
501 <code>num_options</code> and <code>options</code> members contain the
502 default options for a particular destination, along with several informational
503 attributes about the destination as shown in <a href='#TABLE1'>Table 1</a>.
504 The <a href='#cupsGetOption'><code>cupsGetOption</code></a> function gets
505 the value for the named option. For example, the following code lists the
506 available destinations and their human-readable descriptions:</p>
507
508 <pre class='example'>
509 #include &lt;cups/cups.h&gt;
510
511 <a href='#cups_dest_t'>cups_dest_t</a> *dests;
512 int num_dests = <a href='#cupsGetDests'>cupsGetDests</a>(&amp;dests);
513 <a href='#cups_dest_t'>cups_dest_t</a> *dest;
514 int i;
515 const char *value;
516
517 for (i = num_dests, dest = dests; i > 0; i --, dest ++)
518 if (dest->instance == NULL)
519 {
520 value = <a href='#cupsGetOption'>cupsGetOption</a>("printer-info", dest->num_options, dest->options);
521 printf("%s (%s)\n", dest->name, value ? value : "no description");
522 }
523
524 <a href='#cupsFreeDests'>cupsFreeDests</a>(num_dests, dests);
525 </pre>
526
527 <p>You can create your own option arrays using the
528 <a href='#cupsAddOption'><code>cupsAddOption</code></a> function, which
529 adds a single named option to an array:</p>
530
531 <pre class='example'>
532 #include &lt;cups/cups.h&gt;
533
534 int num_options = 0;
535 <a href='#cups_option_t'>cups_option_t</a> *options = NULL;
536
537 /* The returned num_options value is updated as needed */
538 num_options = <a href='#cupsAddOption'>cupsAddOption</a>("first", "value", num_options, &amp;options);
539
540 /* This adds a second option value */
541 num_options = <a href='#cupsAddOption'>cupsAddOption</a>("second", "value", num_options, &amp;options);
542
543 /* This replaces the first option we added */
544 num_options = <a href='#cupsAddOption'>cupsAddOption</a>("first", "new value", num_options, &amp;options);
545 </pre>
546
547 <p>Use a <code>for</code> loop to copy the options from a destination:</p>
548
549 <pre class='example'>
550 #include &lt;cups/cups.h&gt;
551
552 int i;
553 int num_options = 0;
554 <a href='#cups_option_t'>cups_option_t</a> *options = NULL;
555 <a href='#cups_dest_t'>cups_dest_t</a> *dest;
556
557 for (i = 0; i < dest->num_options; i ++)
558 num_options = <a href='#cupsAddOption'>cupsAddOption</a>(dest->options[i].name, dest->options[i].value, num_options, &amp;options);
559 </pre>
560
561 <p>Use the <a href='#cupsFreeOptions'><code>cupsFreeOptions</code></a>
562 function to free the options array when you are done using it:</p>
563
564 <pre class='example'>
565 <a href='#cupsFreeOptions'>cupsFreeOptions</a>(num_options, options);
566 </pre>
567
568 <h3><a name='PRINT_JOBS'>Print Jobs</a></h3>
569
570 <p>Print jobs are identified by a locally-unique job ID number from 1 to
571 2<sup>31</sup>-1 and have options and one or more files for printing to a
572 single destination. The <a href='#cupsPrintFile'><code>cupsPrintFile</code></a>
573 function creates a new job with one file. The following code prints the CUPS
574 test page file:</p>
575
576 <pre class='example'>
577 #include &lt;cups/cups.h&gt;
578
579 <a href='#cups_dest_t'>cups_dest_t</a> *dest;
580 int num_options;
581 <a href='#cups_option_t'>cups_option_t</a> *options;
582 int job_id;
583
584 /* Print a single file */
585 job_id = <a href='#cupsPrintFile'>cupsPrintFile</a>(dest->name, "/usr/share/cups/data/testprint.ps", "Test Print", num_options, options);
586 </pre>
587
588 <p>The <a href='#cupsPrintFiles'><code>cupsPrintFiles</code></a> function
589 creates a job with multiple files. The files are provided in a
590 <code>char *</code> array:</p>
591
592 <pre class='example'>
593 #include &lt;cups/cups.h&gt;
594
595 <a href='#cups_dest_t'>cups_dest_t</a> *dest;
596 int num_options;
597 <a href='#cups_option_t'>cups_option_t</a> *options;
598 int job_id;
599 char *files[3] = { "file1.pdf", "file2.pdf", "file3.pdf" };
600
601 /* Print three files */
602 job_id = <a href='#cupsPrintFiles'>cupsPrintFiles</a>(dest->name, 3, files, "Test Print", num_options, options);
603 </pre>
604
605 <p>Finally, the <a href='#cupsCreateJob'><code>cupsCreateJob</code></a>
606 function creates a new job with no files in it. Files are added using the
607 <a href='#cupsStartDocument'><code>cupsStartDocument</code></a>,
608 <a href='api-httpipp.html#cupsWriteRequestData'><code>cupsWriteRequestData</code></a>,
609 and <a href='#cupsFinishDocument'><code>cupsFinishDocument</code></a> functions.
610 The following example creates a job with 10 text files for printing:</p>
611
612 <pre class='example'>
613 #include &lt;cups/cups.h&gt;
614
615 <a href='#cups_dest_t'>cups_dest_t</a> *dest;
616 int num_options;
617 <a href='#cups_option_t'>cups_option_t</a> *options;
618 int job_id;
619 int i;
620 char buffer[1024];
621
622 /* Create the job */
623 job_id = <a href='#cupsCreateJob'>cupsCreateJob</a>(CUPS_HTTP_DEFAULT, dest->name, "10 Text Files", num_options, options);
624
625 /* If the job is created, add 10 files */
626 if (job_id > 0)
627 {
628 for (i = 1; i &lt;= 10; i ++)
629 {
630 snprintf(buffer, sizeof(buffer), "file%d.txt", i);
631
632 <a href='#cupsStartDocument'>cupsStartDocument</a>(CUPS_HTTP_DEFAULT, dest->name, job_id, buffer, CUPS_FORMAT_TEXT, i == 10);
633
634 snprintf(buffer, sizeof(buffer),
635 "File %d\n"
636 "\n"
637 "One fish,\n"
638 "Two fish,\n
639 "Red fish,\n
640 "Blue fish\n", i);
641
642 /* cupsWriteRequestData can be called as many times as needed */
643 <a href='#cupsWriteRequestData'>cupsWriteRequestData</a>(CUPS_HTTP_DEFAULT, buffer, strlen(buffer));
644
645 <a href='#cupsFinishDocument'>cupsFinishDocument</a>(CUPS_HTTP_DEFAULT, dest->name);
646 }
647 }
648 </pre>
649
650 <p>Once you have created a job, you can monitor its status using the
651 <a href='#cupsGetJobs'><code>cupsGetJobs</code></a> function, which returns
652 an array of <a href='#cups_job_t'><code>cups_job_t</code></a> structures.
653 Each contains the job ID (<code>id</code>), destination name
654 (<code>dest</code>), title (<code>title</code>), and other information
655 associated with the job. The job array is freed using the
656 <a href='#cupsFreeJobs'><code>cupsFreeJobs</code></a> function. The following
657 example monitors a specific job ID, showing the current job state once every
658 5 seconds until the job is completed:</p>
659
660 <pre class='example'>
661 #include &lt;cups/cups.h&gt;
662
663 <a href='#cups_dest_t'>cups_dest_t</a> *dest;
664 int job_id;
665 int num_jobs;
666 <a href='#cups_job_t'>cups_job_t</a> *jobs;
667 int i;
668 ipp_jstate_t job_state = IPP_JOB_PENDING;
669
670 while (job_state &lt; IPP_JOB_STOPPED)
671 {
672 /* Get my jobs (1) with any state (-1) */
673 num_jobs = <a href='#cupsGetJobs'>cupsGetJobs</a>(&amp;jobs, dest->name, 1, -1);
674
675 /* Loop to find my job */
676 job_state = IPP_JOB_COMPLETED;
677
678 for (i = 0; i &lt; num_jobs; i ++)
679 if (jobs[i].id == job_id)
680 {
681 job_state = jobs[i].state;
682 break;
683 }
684
685 /* Free the job array */
686 <a href='#cupsFreeJobs'>cupsFreeJobs</a>(num_jobs, jobs);
687
688 /* Show the current state */
689 switch (job_state)
690 {
691 case IPP_JOB_PENDING :
692 printf("Job %d is pending.\n", job_id);
693 break;
694 case IPP_JOB_HELD :
695 printf("Job %d is held.\n", job_id);
696 break;
697 case IPP_JOB_PROCESSING :
698 printf("Job %d is processing.\n", job_id);
699 break;
700 case IPP_JOB_STOPPED :
701 printf("Job %d is stopped.\n", job_id);
702 break;
703 case IPP_JOB_CANCELED :
704 printf("Job %d is canceled.\n", job_id);
705 break;
706 case IPP_JOB_ABORTED :
707 printf("Job %d is aborted.\n", job_id);
708 break;
709 case IPP_JOB_COMPLETED :
710 printf("Job %d is completed.\n", job_id);
711 break;
712 }
713
714 /* Sleep if the job is not finished */
715 if (job_state &lt; IPP_JOB_STOPPED)
716 sleep(5);
717 }
718 </pre>
719
720 <p>To cancel a job, use the
721 <a href='#cupsCancelJob'><code>cupsCancelJob</code></a> function with the
722 job ID:</p>
723
724 <pre class='exmaple'>
725 #include &lt;cups/cups.h&gt;
726
727 <a href='#cups_dest_t'>cups_dest_t</a> *dest;
728 int job_id;
729
730 <a href='#cupsCancelJob'>cupsCancelJob</a>(dest->name, job_id);
731 </pre>
732
733 <h3><a name='ERROR_HANDLING'>Error Handling</a></h3>
734
735 <p>If any of the CUPS API printing functions returns an error, the reason for
736 that error can be found by calling the
737 <a href='#cupsLastError'><code>cupsLastError</code></a> and
738 <a href='#cupsLastErrorString'><code>cupsLastErrorString</code></a> functions.
739 <a href='#cupsLastError'><code>cupsLastError</code></a> returns the last IPP
740 error code
741 (<a href='api-httpipp.html#ipp_status_t'><code>ipp_status_t</code></a>)
742 that was encountered, while
743 <a href='#cupsLastErrorString'><code>cupsLastErrorString</code></a> returns
744 a (localized) human-readable string that can be shown to the user. For example,
745 if any of the job creation functions returns a job ID of 0, you can use
746 <a href='#cupsLastErrorString'><code>cupsLastErrorString</code></a> to show
747 the reason why the job could not be created:</p>
748
749 <pre class='example'>
750 #include &lt;cups/cups.h&gt;
751
752 int job_id;
753
754 if (job_id == 0)
755 puts(cupsLastErrorString());
756 </pre>
757
758 <h3><a name='PASSWORDS_AND_AUTHENTICATION'>Passwords and Authentication</a></h3>
759
760 <p>CUPS supports authentication of any request, including submission of print
761 jobs. The default mechanism for getting the username and password is to use the
762 login user and a password from the console.</p>
763
764 <p>To support other types of applications, in particular Graphical User
765 Interfaces ("GUIs"), the CUPS API provides functions to set the default
766 username and to register a callback function that returns a password string.</p>
767
768 <p>The <a href="#cupsSetPasswordCB"><code>cupsSetPasswordCB</code></a>
769 function is used to set a password callback in your program. Only one
770 function can be used at any time.</p>
771
772 <p>The <a href="#cupsSetUser"><code>cupsSetUser</code></a> function sets the
773 current username for authentication. This function can be called by your
774 password callback function to change the current username as needed.</p>
775
776 <p>The following example shows a simple password callback that gets a
777 username and password from the user:</p>
778
779 <pre class='example'>
780 #include &lt;cups/cups.h&gt;
781
782 const char *
783 my_password_cb(const char *prompt)
784 {
785 char user[65];
786
787
788 puts(prompt);
789
790 /* Get a username from the user */
791 printf("Username: ");
792 if (fgets(user, sizeof(user), stdin) == NULL)
793 return (NULL);
794
795 /* Strip the newline from the string and set the user */
796 user[strlen(user) - 1] = '\0';
797
798 <a href='#cupsSetUser'>cupsSetUser</a>(user);
799
800 /* Use getpass() to ask for the password... */
801 return (getpass("Password: "));
802 }
803
804 <a href='#cupsSetPasswordCB'>cupsSetPasswordCB</a>(my_password_cb);
805 </pre>
806
807 <p>Similarly, a GUI could display the prompt string in a window with input
808 fields for the username and password. The username should default to the
809 string returned by the <a href="#cupsUser"><code>cupsUser</code></a>
810 function.</p>
811 <h2 class="title"><a name="FUNCTIONS">Functions</a></h2>
812 <h3 class="function"><a name="cupsAddDest">cupsAddDest</a></h3>
813 <p class="description">Add a destination to the list of destinations.</p>
814 <p class="code">
815 int cupsAddDest (<br>
816 &nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
817 &nbsp;&nbsp;&nbsp;&nbsp;const char *instance,<br>
818 &nbsp;&nbsp;&nbsp;&nbsp;int num_dests,<br>
819 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_t">cups_dest_t</a> **dests<br>
820 );</p>
821 <h4 class="parameters">Parameters</h4>
822 <dl>
823 <dt>name</dt>
824 <dd class="description">Destination name</dd>
825 <dt>instance</dt>
826 <dd class="description">Instance name or <code>NULL</code> for none/primary</dd>
827 <dt>num_dests</dt>
828 <dd class="description">Number of destinations</dd>
829 <dt>dests</dt>
830 <dd class="description">Destinations</dd>
831 </dl>
832 <h4 class="returnvalue">Return Value</h4>
833 <p class="description">New number of destinations</p>
834 <h4 class="discussion">Discussion</h4>
835 <p class="discussion">This function cannot be used to add a new class or printer queue,
836 it only adds a new container of saved options for the named
837 destination or instance.<br>
838 <br>
839 If the named destination already exists, the destination list is
840 returned unchanged. Adding a new instance of a destination creates
841 a copy of that destination's options.<br>
842 <br>
843 Use the <a href="#cupsSaveDests"><code>cupsSaveDests</code></a> function to save the updated list of
844 destinations to the user's lpoptions file.</p>
845 <h3 class="function"><a name="cupsAddOption">cupsAddOption</a></h3>
846 <p class="description">Add an option to an option array.</p>
847 <p class="code">
848 int cupsAddOption (<br>
849 &nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
850 &nbsp;&nbsp;&nbsp;&nbsp;const char *value,<br>
851 &nbsp;&nbsp;&nbsp;&nbsp;int num_options,<br>
852 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_option_t">cups_option_t</a> **options<br>
853 );</p>
854 <h4 class="parameters">Parameters</h4>
855 <dl>
856 <dt>name</dt>
857 <dd class="description">Name of option</dd>
858 <dt>value</dt>
859 <dd class="description">Value of option</dd>
860 <dt>num_options</dt>
861 <dd class="description">Number of options</dd>
862 <dt>options</dt>
863 <dd class="description">Pointer to options</dd>
864 </dl>
865 <h4 class="returnvalue">Return Value</h4>
866 <p class="description">Number of options</p>
867 <h4 class="discussion">Discussion</h4>
868 <p class="discussion">New option arrays can be initialized simply by passing 0 for the
869 &quot;num_options&quot; parameter.</p>
870 <h3 class="function"><a name="cupsCancelJob">cupsCancelJob</a></h3>
871 <p class="description">Cancel a print job on the default server.</p>
872 <p class="code">
873 int cupsCancelJob (<br>
874 &nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
875 &nbsp;&nbsp;&nbsp;&nbsp;int job_id<br>
876 );</p>
877 <h4 class="parameters">Parameters</h4>
878 <dl>
879 <dt>name</dt>
880 <dd class="description">Name of printer or class</dd>
881 <dt>job_id</dt>
882 <dd class="description">Job ID</dd>
883 </dl>
884 <h4 class="returnvalue">Return Value</h4>
885 <p class="description">1 on success, 0 on failure</p>
886 <h4 class="discussion">Discussion</h4>
887 <p class="discussion">Pass <code>CUPS_JOBID_ALL</code> to cancel all jobs or <code>CUPS_JOBID_CURRENT</code>
888 to cancel the current job on the named destination.<br>
889 <br>
890 Use the <a href="#cupsLastError"><code>cupsLastError</code></a> and <a href="#cupsLastErrorString"><code>cupsLastErrorString</code></a> functions to get
891 the cause of any failure.</p>
892 <h3 class="function"><span class="info">&nbsp;CUPS 1.4&nbsp;</span><a name="cupsCancelJob2">cupsCancelJob2</a></h3>
893 <p class="description">Cancel or purge a print job.</p>
894 <p class="code">
895 ipp_status_t cupsCancelJob2 (<br>
896 &nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
897 &nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
898 &nbsp;&nbsp;&nbsp;&nbsp;int job_id,<br>
899 &nbsp;&nbsp;&nbsp;&nbsp;int purge<br>
900 );</p>
901 <h4 class="parameters">Parameters</h4>
902 <dl>
903 <dt>http</dt>
904 <dd class="description">HTTP connection or <code>CUPS_HTTP_DEFAULT</code></dd>
905 <dt>name</dt>
906 <dd class="description">Name of printer or class</dd>
907 <dt>job_id</dt>
908 <dd class="description">Job ID or 0 for the current job, -1 for all jobs</dd>
909 <dt>purge</dt>
910 <dd class="description">1 to purge, 0 to cancel</dd>
911 </dl>
912 <h4 class="returnvalue">Return Value</h4>
913 <p class="description">IPP status</p>
914 <h4 class="discussion">Discussion</h4>
915 <p class="discussion">Canceled jobs remain in the job history while purged jobs are removed
916 from the job history.<br>
917 <br>
918 Pass <code>CUPS_JOBID_ALL</code> to cancel all jobs or <code>CUPS_JOBID_CURRENT</code>
919 to cancel the current job on the named destination.<br>
920 <br>
921 Use the <a href="#cupsLastError"><code>cupsLastError</code></a> and <a href="#cupsLastErrorString"><code>cupsLastErrorString</code></a> functions to get
922 the cause of any failure.
923
924 </p>
925 <h3 class="function"><span class="info">&nbsp;CUPS 1.4&nbsp;</span><a name="cupsCreateJob">cupsCreateJob</a></h3>
926 <p class="description">Create an empty job.</p>
927 <p class="code">
928 int cupsCreateJob (<br>
929 &nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
930 &nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
931 &nbsp;&nbsp;&nbsp;&nbsp;const char *title,<br>
932 &nbsp;&nbsp;&nbsp;&nbsp;int num_options,<br>
933 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_option_t">cups_option_t</a> *options<br>
934 );</p>
935 <h4 class="parameters">Parameters</h4>
936 <dl>
937 <dt>http</dt>
938 <dd class="description">HTTP connection or <code>CUPS_HTTP_DEFAULT</code></dd>
939 <dt>name</dt>
940 <dd class="description">Printer or class name</dd>
941 <dt>title</dt>
942 <dd class="description">Title of job</dd>
943 <dt>num_options</dt>
944 <dd class="description">Number of options</dd>
945 <dt>options</dt>
946 <dd class="description">Options</dd>
947 </dl>
948 <h4 class="returnvalue">Return Value</h4>
949 <p class="description">Job ID or 0 on error</p>
950 <h4 class="discussion">Discussion</h4>
951 <p class="discussion">Submit files for printing to the job using the <a href="#cupsStartDocument"><code>cupsStartDocument</code></a>,
952 <a href="#cupsWriteRequestData"><code>cupsWriteRequestData</code></a>, and <a href="#cupsFinishDocument"><code>cupsFinishDocument</code></a> functions.
953
954 </p>
955 <h3 class="function"><a name="cupsEncryption">cupsEncryption</a></h3>
956 <p class="description">Get the default encryption settings.</p>
957 <p class="code">
958 http_encryption_t cupsEncryption (void);</p>
959 <h4 class="returnvalue">Return Value</h4>
960 <p class="description">Encryption settings</p>
961 <h4 class="discussion">Discussion</h4>
962 <p class="discussion">The default encryption setting comes from the CUPS_ENCRYPTION
963 environment variable, then the ~/.cupsrc file, and finally the
964 /etc/cups/client.conf file. If not set, the default is
965 <code>HTTP_ENCRYPT_IF_REQUESTED</code>.</p>
966 <h3 class="function"><span class="info">&nbsp;CUPS 1.4&nbsp;</span><a name="cupsFinishDocument">cupsFinishDocument</a></h3>
967 <p class="description">Finish sending a document.</p>
968 <p class="code">
969 ipp_status_t cupsFinishDocument (<br>
970 &nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
971 &nbsp;&nbsp;&nbsp;&nbsp;const char *name<br>
972 );</p>
973 <h4 class="parameters">Parameters</h4>
974 <dl>
975 <dt>http</dt>
976 <dd class="description">HTTP connection or <code>CUPS_HTTP_DEFAULT</code></dd>
977 <dt>name</dt>
978 <dd class="description">Printer or class name</dd>
979 </dl>
980 <h4 class="returnvalue">Return Value</h4>
981 <p class="description">Status of document submission</p>
982 <h4 class="discussion">Discussion</h4>
983 <p class="discussion">The document must have been started using <a href="#cupsStartDocument"><code>cupsStartDocument</code></a>.
984
985 </p>
986 <h3 class="function"><a name="cupsFreeDests">cupsFreeDests</a></h3>
987 <p class="description">Free the memory used by the list of destinations.</p>
988 <p class="code">
989 void cupsFreeDests (<br>
990 &nbsp;&nbsp;&nbsp;&nbsp;int num_dests,<br>
991 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_t">cups_dest_t</a> *dests<br>
992 );</p>
993 <h4 class="parameters">Parameters</h4>
994 <dl>
995 <dt>num_dests</dt>
996 <dd class="description">Number of destinations</dd>
997 <dt>dests</dt>
998 <dd class="description">Destinations</dd>
999 </dl>
1000 <h3 class="function"><a name="cupsFreeJobs">cupsFreeJobs</a></h3>
1001 <p class="description">Free memory used by job data.</p>
1002 <p class="code">
1003 void cupsFreeJobs (<br>
1004 &nbsp;&nbsp;&nbsp;&nbsp;int num_jobs,<br>
1005 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_job_t">cups_job_t</a> *jobs<br>
1006 );</p>
1007 <h4 class="parameters">Parameters</h4>
1008 <dl>
1009 <dt>num_jobs</dt>
1010 <dd class="description">Number of jobs</dd>
1011 <dt>jobs</dt>
1012 <dd class="description">Jobs</dd>
1013 </dl>
1014 <h3 class="function"><a name="cupsFreeOptions">cupsFreeOptions</a></h3>
1015 <p class="description">Free all memory used by options.</p>
1016 <p class="code">
1017 void cupsFreeOptions (<br>
1018 &nbsp;&nbsp;&nbsp;&nbsp;int num_options,<br>
1019 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_option_t">cups_option_t</a> *options<br>
1020 );</p>
1021 <h4 class="parameters">Parameters</h4>
1022 <dl>
1023 <dt>num_options</dt>
1024 <dd class="description">Number of options</dd>
1025 <dt>options</dt>
1026 <dd class="description">Pointer to options</dd>
1027 </dl>
1028 <h3 class="function"><span class="info">&nbsp;DEPRECATED&nbsp;</span><a name="cupsGetClasses">cupsGetClasses</a></h3>
1029 <p class="description">Get a list of printer classes from the default server.</p>
1030 <p class="code">
1031 int cupsGetClasses (<br>
1032 &nbsp;&nbsp;&nbsp;&nbsp;char ***classes<br>
1033 );</p>
1034 <h4 class="parameters">Parameters</h4>
1035 <dl>
1036 <dt>classes</dt>
1037 <dd class="description">Classes</dd>
1038 </dl>
1039 <h4 class="returnvalue">Return Value</h4>
1040 <p class="description">Number of classes</p>
1041 <h4 class="discussion">Discussion</h4>
1042 <p class="discussion">This function is deprecated - use <a href="#cupsGetDests"><code>cupsGetDests</code></a> instead.
1043
1044 </p>
1045 <h3 class="function"><a name="cupsGetDefault">cupsGetDefault</a></h3>
1046 <p class="description">Get the default printer or class for the default server.</p>
1047 <p class="code">
1048 const char *cupsGetDefault (void);</p>
1049 <h4 class="returnvalue">Return Value</h4>
1050 <p class="description">Default printer or <code>NULL</code></p>
1051 <h4 class="discussion">Discussion</h4>
1052 <p class="discussion">This function returns the default printer or class as defined by
1053 the LPDEST or PRINTER environment variables. If these environment
1054 variables are not set, the server default destination is returned.
1055 Applications should use the <a href="#cupsGetDests"><code>cupsGetDests</code></a> and <a href="#cupsGetDest"><code>cupsGetDest</code></a>
1056 functions to get the user-defined default printer, as this function does
1057 not support the lpoptions-defined default printer.</p>
1058 <h3 class="function"><span class="info">&nbsp;CUPS 1.1.21&nbsp;</span><a name="cupsGetDefault2">cupsGetDefault2</a></h3>
1059 <p class="description">Get the default printer or class for the specified server.</p>
1060 <p class="code">
1061 const char *cupsGetDefault2 (<br>
1062 &nbsp;&nbsp;&nbsp;&nbsp;http_t *http<br>
1063 );</p>
1064 <h4 class="parameters">Parameters</h4>
1065 <dl>
1066 <dt>http</dt>
1067 <dd class="description">HTTP connection or <code>CUPS_HTTP_DEFAULT</code></dd>
1068 </dl>
1069 <h4 class="returnvalue">Return Value</h4>
1070 <p class="description">Default printer or <code>NULL</code></p>
1071 <h4 class="discussion">Discussion</h4>
1072 <p class="discussion">This function returns the default printer or class as defined by
1073 the LPDEST or PRINTER environment variables. If these environment
1074 variables are not set, the server default destination is returned.
1075 Applications should use the <a href="#cupsGetDests"><code>cupsGetDests</code></a> and <a href="#cupsGetDest"><code>cupsGetDest</code></a>
1076 functions to get the user-defined default printer, as this function does
1077 not support the lpoptions-defined default printer.
1078
1079 </p>
1080 <h3 class="function"><a name="cupsGetDest">cupsGetDest</a></h3>
1081 <p class="description">Get the named destination from the list.</p>
1082 <p class="code">
1083 <a href="#cups_dest_t">cups_dest_t</a> *cupsGetDest (<br>
1084 &nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
1085 &nbsp;&nbsp;&nbsp;&nbsp;const char *instance,<br>
1086 &nbsp;&nbsp;&nbsp;&nbsp;int num_dests,<br>
1087 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_t">cups_dest_t</a> *dests<br>
1088 );</p>
1089 <h4 class="parameters">Parameters</h4>
1090 <dl>
1091 <dt>name</dt>
1092 <dd class="description">Destination name or <code>NULL</code> for the default destination</dd>
1093 <dt>instance</dt>
1094 <dd class="description">Instance name or <code>NULL</code></dd>
1095 <dt>num_dests</dt>
1096 <dd class="description">Number of destinations</dd>
1097 <dt>dests</dt>
1098 <dd class="description">Destinations</dd>
1099 </dl>
1100 <h4 class="returnvalue">Return Value</h4>
1101 <p class="description">Destination pointer or <code>NULL</code></p>
1102 <h4 class="discussion">Discussion</h4>
1103 <p class="discussion">Use the <a href="#cupsGetDests"><code>cupsGetDests</code></a> or <a href="#cupsGetDests2"><code>cupsGetDests2</code></a> functions to get a
1104 list of supported destinations for the current user.</p>
1105 <h3 class="function"><a name="cupsGetDests">cupsGetDests</a></h3>
1106 <p class="description">Get the list of destinations from the default server.</p>
1107 <p class="code">
1108 int cupsGetDests (<br>
1109 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_t">cups_dest_t</a> **dests<br>
1110 );</p>
1111 <h4 class="parameters">Parameters</h4>
1112 <dl>
1113 <dt>dests</dt>
1114 <dd class="description">Destinations</dd>
1115 </dl>
1116 <h4 class="returnvalue">Return Value</h4>
1117 <p class="description">Number of destinations</p>
1118 <h4 class="discussion">Discussion</h4>
1119 <p class="discussion">Starting with CUPS 1.2, the returned list of destinations include the
1120 printer-info, printer-is-accepting-jobs, printer-is-shared,
1121 printer-make-and-model, printer-state, printer-state-change-time,
1122 printer-state-reasons, and printer-type attributes as options.<br>
1123 <br>
1124 Use the <a href="#cupsFreeDests"><code>cupsFreeDests</code></a> function to free the destination list and
1125 the <a href="#cupsGetDest"><code>cupsGetDest</code></a> function to find a particular destination.</p>
1126 <h3 class="function"><span class="info">&nbsp;CUPS 1.1.21&nbsp;</span><a name="cupsGetDests2">cupsGetDests2</a></h3>
1127 <p class="description">Get the list of destinations from the specified server.</p>
1128 <p class="code">
1129 int cupsGetDests2 (<br>
1130 &nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1131 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_t">cups_dest_t</a> **dests<br>
1132 );</p>
1133 <h4 class="parameters">Parameters</h4>
1134 <dl>
1135 <dt>http</dt>
1136 <dd class="description">HTTP connection or <code>CUPS_HTTP_DEFAULT</code></dd>
1137 <dt>dests</dt>
1138 <dd class="description">Destinations</dd>
1139 </dl>
1140 <h4 class="returnvalue">Return Value</h4>
1141 <p class="description">Number of destinations</p>
1142 <h4 class="discussion">Discussion</h4>
1143 <p class="discussion">Starting with CUPS 1.2, the returned list of destinations include the
1144 printer-info, printer-is-accepting-jobs, printer-is-shared,
1145 printer-make-and-model, printer-state, printer-state-change-time,
1146 printer-state-reasons, and printer-type attributes as options.<br>
1147 <br>
1148 Use the <a href="#cupsFreeDests"><code>cupsFreeDests</code></a> function to free the destination list and
1149 the <a href="#cupsGetDest"><code>cupsGetDest</code></a> function to find a particular destination.
1150
1151 </p>
1152 <h3 class="function"><span class="info">&nbsp;CUPS 1.1.20&nbsp;</span><a name="cupsGetFd">cupsGetFd</a></h3>
1153 <p class="description">Get a file from the server.</p>
1154 <p class="code">
1155 http_status_t cupsGetFd (<br>
1156 &nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1157 &nbsp;&nbsp;&nbsp;&nbsp;const char *resource,<br>
1158 &nbsp;&nbsp;&nbsp;&nbsp;int fd<br>
1159 );</p>
1160 <h4 class="parameters">Parameters</h4>
1161 <dl>
1162 <dt>http</dt>
1163 <dd class="description">HTTP connection to server or <code>CUPS_HTTP_DEFAULT</code></dd>
1164 <dt>resource</dt>
1165 <dd class="description">Resource name</dd>
1166 <dt>fd</dt>
1167 <dd class="description">File descriptor</dd>
1168 </dl>
1169 <h4 class="returnvalue">Return Value</h4>
1170 <p class="description">HTTP status</p>
1171 <h4 class="discussion">Discussion</h4>
1172 <p class="discussion">This function returns <code>HTTP_OK</code> when the file is successfully retrieved.
1173
1174 </p>
1175 <h3 class="function"><span class="info">&nbsp;CUPS 1.1.20&nbsp;</span><a name="cupsGetFile">cupsGetFile</a></h3>
1176 <p class="description">Get a file from the server.</p>
1177 <p class="code">
1178 http_status_t cupsGetFile (<br>
1179 &nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1180 &nbsp;&nbsp;&nbsp;&nbsp;const char *resource,<br>
1181 &nbsp;&nbsp;&nbsp;&nbsp;const char *filename<br>
1182 );</p>
1183 <h4 class="parameters">Parameters</h4>
1184 <dl>
1185 <dt>http</dt>
1186 <dd class="description">HTTP connection to server or <code>CUPS_HTTP_DEFAULT</code></dd>
1187 <dt>resource</dt>
1188 <dd class="description">Resource name</dd>
1189 <dt>filename</dt>
1190 <dd class="description">Filename</dd>
1191 </dl>
1192 <h4 class="returnvalue">Return Value</h4>
1193 <p class="description">HTTP status</p>
1194 <h4 class="discussion">Discussion</h4>
1195 <p class="discussion">This function returns <code>HTTP_OK</code> when the file is successfully retrieved.
1196
1197 </p>
1198 <h3 class="function"><a name="cupsGetJobs">cupsGetJobs</a></h3>
1199 <p class="description">Get the jobs from the default server.</p>
1200 <p class="code">
1201 int cupsGetJobs (<br>
1202 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_job_t">cups_job_t</a> **jobs,<br>
1203 &nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
1204 &nbsp;&nbsp;&nbsp;&nbsp;int myjobs,<br>
1205 &nbsp;&nbsp;&nbsp;&nbsp;int whichjobs<br>
1206 );</p>
1207 <h4 class="parameters">Parameters</h4>
1208 <dl>
1209 <dt>jobs</dt>
1210 <dd class="description">Job data</dd>
1211 <dt>name</dt>
1212 <dd class="description"><code>NULL</code> = all destinations, otherwise show jobs for mydest</dd>
1213 <dt>myjobs</dt>
1214 <dd class="description">0 = all users, 1 = mine</dd>
1215 <dt>whichjobs</dt>
1216 <dd class="description"><code>CUPS_WHICHJOBS_ALL</code>, <code>CUPS_WHICHJOBS_ACTIVE</code>, or <code>CUPS_WHICHJOBS_COMPLETED</code></dd>
1217 </dl>
1218 <h4 class="returnvalue">Return Value</h4>
1219 <p class="description">Number of jobs</p>
1220 <h4 class="discussion">Discussion</h4>
1221 <p class="discussion">A &quot;whichjobs&quot; value of <code>CUPS_WHICHJOBS_ALL</code> returns all jobs regardless
1222 of state, while <code>CUPS_WHICHJOBS_ACTIVE</code> returns jobs that are
1223 pending, processing, or held and <code>CUPS_WHICHJOBS_COMPLETED</code> returns
1224 jobs that are stopped, canceled, aborted, or completed.</p>
1225 <h3 class="function"><span class="info">&nbsp;CUPS 1.1.21&nbsp;</span><a name="cupsGetJobs2">cupsGetJobs2</a></h3>
1226 <p class="description">Get the jobs from the specified server.</p>
1227 <p class="code">
1228 int cupsGetJobs2 (<br>
1229 &nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1230 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_job_t">cups_job_t</a> **jobs,<br>
1231 &nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
1232 &nbsp;&nbsp;&nbsp;&nbsp;int myjobs,<br>
1233 &nbsp;&nbsp;&nbsp;&nbsp;int whichjobs<br>
1234 );</p>
1235 <h4 class="parameters">Parameters</h4>
1236 <dl>
1237 <dt>http</dt>
1238 <dd class="description">HTTP connection or <code>CUPS_HTTP_DEFAULT</code></dd>
1239 <dt>jobs</dt>
1240 <dd class="description">Job data</dd>
1241 <dt>name</dt>
1242 <dd class="description"><code>NULL</code> = all destinations, otherwise show jobs for mydest</dd>
1243 <dt>myjobs</dt>
1244 <dd class="description">0 = all users, 1 = mine</dd>
1245 <dt>whichjobs</dt>
1246 <dd class="description"><code>CUPS_WHICHJOBS_ALL</code>, <code>CUPS_WHICHJOBS_ACTIVE</code>, or <code>CUPS_WHICHJOBS_COMPLETED</code></dd>
1247 </dl>
1248 <h4 class="returnvalue">Return Value</h4>
1249 <p class="description">Number of jobs</p>
1250 <h4 class="discussion">Discussion</h4>
1251 <p class="discussion">A &quot;whichjobs&quot; value of <code>CUPS_WHICHJOBS_ALL</code> returns all jobs regardless
1252 of state, while <code>CUPS_WHICHJOBS_ACTIVE</code> returns jobs that are
1253 pending, processing, or held and <code>CUPS_WHICHJOBS_COMPLETED</code> returns
1254 jobs that are stopped, canceled, aborted, or completed.
1255
1256 </p>
1257 <h3 class="function"><span class="info">&nbsp;CUPS 1.4&nbsp;</span><a name="cupsGetNamedDest">cupsGetNamedDest</a></h3>
1258 <p class="description">Get options for the named destination.</p>
1259 <p class="code">
1260 <a href="#cups_dest_t">cups_dest_t</a> *cupsGetNamedDest (<br>
1261 &nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1262 &nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
1263 &nbsp;&nbsp;&nbsp;&nbsp;const char *instance<br>
1264 );</p>
1265 <h4 class="parameters">Parameters</h4>
1266 <dl>
1267 <dt>http</dt>
1268 <dd class="description">HTTP connection or <code>CUPS_HTTP_DEFAULT</code></dd>
1269 <dt>name</dt>
1270 <dd class="description">Destination name or <code>NULL</code></dd>
1271 <dt>instance</dt>
1272 <dd class="description">Instance name or <code>NULL</code></dd>
1273 </dl>
1274 <h4 class="returnvalue">Return Value</h4>
1275 <p class="description">Destination or <code>NULL</code></p>
1276 <h4 class="discussion">Discussion</h4>
1277 <p class="discussion">This function is optimized for retrieving a single destination and should
1278 be used instead of <a href="#cupsGetDests"><code>cupsGetDests</code></a> and <a href="#cupsGetDest"><code>cupsGetDest</code></a> when you either
1279 know the name of the destination or want to print to the default destination.
1280 If <code>NULL</code> is returned, the destination does not exist or there is no
1281 default destination.<br>
1282 <br>
1283 If &quot;http&quot; is <code>CUPS_HTTP_DEFAULT</code>, the connection to the default print
1284 server will be used.<br>
1285 <br>
1286 If &quot;name&quot; is <code>NULL</code>, the default printer for the current user will be
1287 returned.<br>
1288 <br>
1289 The returned destination must be freed using <a href="#cupsFreeDests"><code>cupsFreeDests</code></a> with a
1290 &quot;num_dests&quot; value of 1.
1291
1292 </p>
1293 <h3 class="function"><a name="cupsGetOption">cupsGetOption</a></h3>
1294 <p class="description">Get an option value.</p>
1295 <p class="code">
1296 const char *cupsGetOption (<br>
1297 &nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
1298 &nbsp;&nbsp;&nbsp;&nbsp;int num_options,<br>
1299 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_option_t">cups_option_t</a> *options<br>
1300 );</p>
1301 <h4 class="parameters">Parameters</h4>
1302 <dl>
1303 <dt>name</dt>
1304 <dd class="description">Name of option</dd>
1305 <dt>num_options</dt>
1306 <dd class="description">Number of options</dd>
1307 <dt>options</dt>
1308 <dd class="description">Options</dd>
1309 </dl>
1310 <h4 class="returnvalue">Return Value</h4>
1311 <p class="description">Option value or <code>NULL</code></p>
1312 <h3 class="function"><a name="cupsGetPPD">cupsGetPPD</a></h3>
1313 <p class="description">Get the PPD file for a printer on the default server.</p>
1314 <p class="code">
1315 const char *cupsGetPPD (<br>
1316 &nbsp;&nbsp;&nbsp;&nbsp;const char *name<br>
1317 );</p>
1318 <h4 class="parameters">Parameters</h4>
1319 <dl>
1320 <dt>name</dt>
1321 <dd class="description">Printer name</dd>
1322 </dl>
1323 <h4 class="returnvalue">Return Value</h4>
1324 <p class="description">Filename for PPD file</p>
1325 <h4 class="discussion">Discussion</h4>
1326 <p class="discussion">For classes, <code>cupsGetPPD</code> returns the PPD file for the first printer
1327 in the class.</p>
1328 <h3 class="function"><span class="info">&nbsp;CUPS 1.1.21&nbsp;</span><a name="cupsGetPPD2">cupsGetPPD2</a></h3>
1329 <p class="description">Get the PPD file for a printer from the specified server.</p>
1330 <p class="code">
1331 const char *cupsGetPPD2 (<br>
1332 &nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1333 &nbsp;&nbsp;&nbsp;&nbsp;const char *name<br>
1334 );</p>
1335 <h4 class="parameters">Parameters</h4>
1336 <dl>
1337 <dt>http</dt>
1338 <dd class="description">HTTP connection or <code>CUPS_HTTP_DEFAULT</code></dd>
1339 <dt>name</dt>
1340 <dd class="description">Printer name</dd>
1341 </dl>
1342 <h4 class="returnvalue">Return Value</h4>
1343 <p class="description">Filename for PPD file</p>
1344 <h4 class="discussion">Discussion</h4>
1345 <p class="discussion">For classes, <code>cupsGetPPD2</code> returns the PPD file for the first printer
1346 in the class.
1347
1348 </p>
1349 <h3 class="function"><a name="cupsGetPPD3">cupsGetPPD3</a></h3>
1350 <p class="description">Get the PPD file for a printer on the specified
1351 server if it has changed.</p>
1352 <p class="code">
1353 http_status_t cupsGetPPD3 (<br>
1354 &nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1355 &nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
1356 &nbsp;&nbsp;&nbsp;&nbsp;time_t *modtime,<br>
1357 &nbsp;&nbsp;&nbsp;&nbsp;char *buffer,<br>
1358 &nbsp;&nbsp;&nbsp;&nbsp;size_t bufsize<br>
1359 );</p>
1360 <h4 class="parameters">Parameters</h4>
1361 <dl>
1362 <dt>http</dt>
1363 <dd class="description">HTTP connection or <code>CUPS_HTTP_DEFAULT</code></dd>
1364 <dt>name</dt>
1365 <dd class="description">Printer name</dd>
1366 <dt>modtime</dt>
1367 <dd class="description">Modification time</dd>
1368 <dt>buffer</dt>
1369 <dd class="description">Filename buffer</dd>
1370 <dt>bufsize</dt>
1371 <dd class="description">Size of filename buffer</dd>
1372 </dl>
1373 <h4 class="returnvalue">Return Value</h4>
1374 <p class="description">HTTP status</p>
1375 <h4 class="discussion">Discussion</h4>
1376 <p class="discussion">The &quot;modtime&quot; parameter contains the modification time of any
1377 locally-cached content and is updated with the time from the PPD file on
1378 the server.<br>
1379 <br>
1380 The &quot;buffer&quot; parameter contains the local PPD filename. If it contains
1381 the empty string, a new temporary file is created, otherwise the existing
1382 file will be overwritten as needed.<br>
1383 <br>
1384 On success, <code>HTTP_OK</code> is returned for a new PPD file and
1385 <code>HTTP_NOT_MODIFIED</code> if the existing PPD file is up-to-date. Any other
1386 status is an error.<br>
1387 <br>
1388 For classes, <code>cupsGetPPD3</code> returns the PPD file for the first printer
1389 in the class.</p>
1390 <h3 class="function"><a name="cupsGetPassword">cupsGetPassword</a></h3>
1391 <p class="description">Get a password from the user.</p>
1392 <p class="code">
1393 const char *cupsGetPassword (<br>
1394 &nbsp;&nbsp;&nbsp;&nbsp;const char *prompt<br>
1395 );</p>
1396 <h4 class="parameters">Parameters</h4>
1397 <dl>
1398 <dt>prompt</dt>
1399 <dd class="description">Prompt string</dd>
1400 </dl>
1401 <h4 class="returnvalue">Return Value</h4>
1402 <p class="description">Password</p>
1403 <h4 class="discussion">Discussion</h4>
1404 <p class="discussion">Uses the current password callback function. Returns <code>NULL</code> if the
1405 user does not provide a password.</p>
1406 <h3 class="function"><span class="info">&nbsp;DEPRECATED&nbsp;</span><a name="cupsGetPrinters">cupsGetPrinters</a></h3>
1407 <p class="description">Get a list of printers from the default server.</p>
1408 <p class="code">
1409 int cupsGetPrinters (<br>
1410 &nbsp;&nbsp;&nbsp;&nbsp;char ***printers<br>
1411 );</p>
1412 <h4 class="parameters">Parameters</h4>
1413 <dl>
1414 <dt>printers</dt>
1415 <dd class="description">Printers</dd>
1416 </dl>
1417 <h4 class="returnvalue">Return Value</h4>
1418 <p class="description">Number of printers</p>
1419 <h4 class="discussion">Discussion</h4>
1420 <p class="discussion">This function is deprecated - use <a href="#cupsGetDests"><code>cupsGetDests</code></a> instead.
1421
1422 </p>
1423 <h3 class="function"><span class="info">&nbsp;CUPS 1.3&nbsp;</span><a name="cupsGetServerPPD">cupsGetServerPPD</a></h3>
1424 <p class="description">Get an available PPD file from the server.</p>
1425 <p class="code">
1426 char *cupsGetServerPPD (<br>
1427 &nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1428 &nbsp;&nbsp;&nbsp;&nbsp;const char *name<br>
1429 );</p>
1430 <h4 class="parameters">Parameters</h4>
1431 <dl>
1432 <dt>http</dt>
1433 <dd class="description">HTTP connection or <code>CUPS_HTTP_DEFAULT</code></dd>
1434 <dt>name</dt>
1435 <dd class="description">Name of PPD file (&quot;ppd-name&quot;)</dd>
1436 </dl>
1437 <h4 class="returnvalue">Return Value</h4>
1438 <p class="description">Name of PPD file or <code>NULL</code> on error</p>
1439 <h4 class="discussion">Discussion</h4>
1440 <p class="discussion">This function returns the named PPD file from the server. The
1441 list of available PPDs is provided by the IPP <code>CUPS_GET_PPDS</code>
1442 operation.<br>
1443 <br>
1444 You must remove (unlink) the PPD file when you are finished with
1445 it. The PPD filename is stored in a static location that will be
1446 overwritten on the next call to <a href="#cupsGetPPD"><code>cupsGetPPD</code></a>, <a href="#cupsGetPPD2"><code>cupsGetPPD2</code></a>,
1447 or <a href="#cupsGetServerPPD"><code>cupsGetServerPPD</code></a>.
1448
1449 </p>
1450 <h3 class="function"><a name="cupsLangDefault">cupsLangDefault</a></h3>
1451 <p class="description">Return the default language.</p>
1452 <p class="code">
1453 cups_lang_t *cupsLangDefault (void);</p>
1454 <h4 class="returnvalue">Return Value</h4>
1455 <p class="description">Language data</p>
1456 <h3 class="function"><a name="cupsLangEncoding">cupsLangEncoding</a></h3>
1457 <p class="description">Return the character encoding (us-ascii, etc.)
1458 for the given language.</p>
1459 <p class="code">
1460 const char *cupsLangEncoding (<br>
1461 &nbsp;&nbsp;&nbsp;&nbsp;cups_lang_t *lang<br>
1462 );</p>
1463 <h4 class="parameters">Parameters</h4>
1464 <dl>
1465 <dt>lang</dt>
1466 <dd class="description">Language data</dd>
1467 </dl>
1468 <h4 class="returnvalue">Return Value</h4>
1469 <p class="description">Character encoding</p>
1470 <h3 class="function"><a name="cupsLangFlush">cupsLangFlush</a></h3>
1471 <p class="description">Flush all language data out of the cache.</p>
1472 <p class="code">
1473 void cupsLangFlush (void);</p>
1474 <h3 class="function"><a name="cupsLangFree">cupsLangFree</a></h3>
1475 <p class="description">Free language data.</p>
1476 <p class="code">
1477 void cupsLangFree (<br>
1478 &nbsp;&nbsp;&nbsp;&nbsp;cups_lang_t *lang<br>
1479 );</p>
1480 <h4 class="parameters">Parameters</h4>
1481 <dl>
1482 <dt>lang</dt>
1483 <dd class="description">Language to free</dd>
1484 </dl>
1485 <h4 class="discussion">Discussion</h4>
1486 <p class="discussion">This does not actually free anything; use <a href="#cupsLangFlush"><code>cupsLangFlush</code></a> for that.</p>
1487 <h3 class="function"><a name="cupsLangGet">cupsLangGet</a></h3>
1488 <p class="description">Get a language.</p>
1489 <p class="code">
1490 cups_lang_t *cupsLangGet (<br>
1491 &nbsp;&nbsp;&nbsp;&nbsp;const char *language<br>
1492 );</p>
1493 <h4 class="parameters">Parameters</h4>
1494 <dl>
1495 <dt>language</dt>
1496 <dd class="description">Language or locale</dd>
1497 </dl>
1498 <h4 class="returnvalue">Return Value</h4>
1499 <p class="description">Language data</p>
1500 <h3 class="function"><a name="cupsLastError">cupsLastError</a></h3>
1501 <p class="description">Return the last IPP status code.</p>
1502 <p class="code">
1503 ipp_status_t cupsLastError (void);</p>
1504 <h4 class="returnvalue">Return Value</h4>
1505 <p class="description">IPP status code from last request</p>
1506 <h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsLastErrorString">cupsLastErrorString</a></h3>
1507 <p class="description">Return the last IPP status-message.</p>
1508 <p class="code">
1509 const char *cupsLastErrorString (void);</p>
1510 <h4 class="returnvalue">Return Value</h4>
1511 <p class="description">status-message text from last request</p>
1512 <h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsNotifySubject">cupsNotifySubject</a></h3>
1513 <p class="description">Return the subject for the given notification message.</p>
1514 <p class="code">
1515 char *cupsNotifySubject (<br>
1516 &nbsp;&nbsp;&nbsp;&nbsp;cups_lang_t *lang,<br>
1517 &nbsp;&nbsp;&nbsp;&nbsp;ipp_t *event<br>
1518 );</p>
1519 <h4 class="parameters">Parameters</h4>
1520 <dl>
1521 <dt>lang</dt>
1522 <dd class="description">Language data</dd>
1523 <dt>event</dt>
1524 <dd class="description">Event data</dd>
1525 </dl>
1526 <h4 class="returnvalue">Return Value</h4>
1527 <p class="description">Subject string or <code>NULL</code></p>
1528 <h4 class="discussion">Discussion</h4>
1529 <p class="discussion">The returned string must be freed by the caller using free().
1530
1531 </p>
1532 <h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsNotifyText">cupsNotifyText</a></h3>
1533 <p class="description">Return the text for the given notification message.</p>
1534 <p class="code">
1535 char *cupsNotifyText (<br>
1536 &nbsp;&nbsp;&nbsp;&nbsp;cups_lang_t *lang,<br>
1537 &nbsp;&nbsp;&nbsp;&nbsp;ipp_t *event<br>
1538 );</p>
1539 <h4 class="parameters">Parameters</h4>
1540 <dl>
1541 <dt>lang</dt>
1542 <dd class="description">Language data</dd>
1543 <dt>event</dt>
1544 <dd class="description">Event data</dd>
1545 </dl>
1546 <h4 class="returnvalue">Return Value</h4>
1547 <p class="description">Message text or <code>NULL</code></p>
1548 <h4 class="discussion">Discussion</h4>
1549 <p class="discussion">The returned string must be freed by the caller using <code>free</code>.
1550
1551 </p>
1552 <h3 class="function"><a name="cupsParseOptions">cupsParseOptions</a></h3>
1553 <p class="description">Parse options from a command-line argument.</p>
1554 <p class="code">
1555 int cupsParseOptions (<br>
1556 &nbsp;&nbsp;&nbsp;&nbsp;const char *arg,<br>
1557 &nbsp;&nbsp;&nbsp;&nbsp;int num_options,<br>
1558 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_option_t">cups_option_t</a> **options<br>
1559 );</p>
1560 <h4 class="parameters">Parameters</h4>
1561 <dl>
1562 <dt>arg</dt>
1563 <dd class="description">Argument to parse</dd>
1564 <dt>num_options</dt>
1565 <dd class="description">Number of options</dd>
1566 <dt>options</dt>
1567 <dd class="description">Options found</dd>
1568 </dl>
1569 <h4 class="returnvalue">Return Value</h4>
1570 <p class="description">Number of options found</p>
1571 <h4 class="discussion">Discussion</h4>
1572 <p class="discussion">This function converts space-delimited name/value pairs according
1573 to the PAPI text option ABNF specification. Collection values
1574 (&quot;name={a=... b=... c=...}&quot;) are stored with the curley brackets
1575 intact - use <code>cupsParseOptions</code> on the value to extract the
1576 collection attributes.</p>
1577 <h3 class="function"><a name="cupsPrintFile">cupsPrintFile</a></h3>
1578 <p class="description">Print a file to a printer or class on the default server.</p>
1579 <p class="code">
1580 int cupsPrintFile (<br>
1581 &nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
1582 &nbsp;&nbsp;&nbsp;&nbsp;const char *filename,<br>
1583 &nbsp;&nbsp;&nbsp;&nbsp;const char *title,<br>
1584 &nbsp;&nbsp;&nbsp;&nbsp;int num_options,<br>
1585 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_option_t">cups_option_t</a> *options<br>
1586 );</p>
1587 <h4 class="parameters">Parameters</h4>
1588 <dl>
1589 <dt>name</dt>
1590 <dd class="description">Printer or class name</dd>
1591 <dt>filename</dt>
1592 <dd class="description">File to print</dd>
1593 <dt>title</dt>
1594 <dd class="description">Title of job</dd>
1595 <dt>num_options</dt>
1596 <dd class="description">Number of options</dd>
1597 <dt>options</dt>
1598 <dd class="description">Options</dd>
1599 </dl>
1600 <h4 class="returnvalue">Return Value</h4>
1601 <p class="description">Job ID or 0 on error</p>
1602 <h3 class="function"><span class="info">&nbsp;CUPS 1.1.21&nbsp;</span><a name="cupsPrintFile2">cupsPrintFile2</a></h3>
1603 <p class="description">Print a file to a printer or class on the specified
1604 server.</p>
1605 <p class="code">
1606 int cupsPrintFile2 (<br>
1607 &nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1608 &nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
1609 &nbsp;&nbsp;&nbsp;&nbsp;const char *filename,<br>
1610 &nbsp;&nbsp;&nbsp;&nbsp;const char *title,<br>
1611 &nbsp;&nbsp;&nbsp;&nbsp;int num_options,<br>
1612 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_option_t">cups_option_t</a> *options<br>
1613 );</p>
1614 <h4 class="parameters">Parameters</h4>
1615 <dl>
1616 <dt>http</dt>
1617 <dd class="description">HTTP connection</dd>
1618 <dt>name</dt>
1619 <dd class="description">Printer or class name</dd>
1620 <dt>filename</dt>
1621 <dd class="description">File to print</dd>
1622 <dt>title</dt>
1623 <dd class="description">Title of job</dd>
1624 <dt>num_options</dt>
1625 <dd class="description">Number of options</dd>
1626 <dt>options</dt>
1627 <dd class="description">Options</dd>
1628 </dl>
1629 <h4 class="returnvalue">Return Value</h4>
1630 <p class="description">Job ID or 0 on error</p>
1631 <h3 class="function"><a name="cupsPrintFiles">cupsPrintFiles</a></h3>
1632 <p class="description">Print one or more files to a printer or class on the
1633 default server.</p>
1634 <p class="code">
1635 int cupsPrintFiles (<br>
1636 &nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
1637 &nbsp;&nbsp;&nbsp;&nbsp;int num_files,<br>
1638 &nbsp;&nbsp;&nbsp;&nbsp;const char **files,<br>
1639 &nbsp;&nbsp;&nbsp;&nbsp;const char *title,<br>
1640 &nbsp;&nbsp;&nbsp;&nbsp;int num_options,<br>
1641 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_option_t">cups_option_t</a> *options<br>
1642 );</p>
1643 <h4 class="parameters">Parameters</h4>
1644 <dl>
1645 <dt>name</dt>
1646 <dd class="description">Printer or class name</dd>
1647 <dt>num_files</dt>
1648 <dd class="description">Number of files</dd>
1649 <dt>files</dt>
1650 <dd class="description">File(s) to print</dd>
1651 <dt>title</dt>
1652 <dd class="description">Title of job</dd>
1653 <dt>num_options</dt>
1654 <dd class="description">Number of options</dd>
1655 <dt>options</dt>
1656 <dd class="description">Options</dd>
1657 </dl>
1658 <h4 class="returnvalue">Return Value</h4>
1659 <p class="description">Job ID or 0 on error</p>
1660 <h3 class="function"><span class="info">&nbsp;CUPS 1.1.21&nbsp;</span><a name="cupsPrintFiles2">cupsPrintFiles2</a></h3>
1661 <p class="description">Print one or more files to a printer or class on the
1662 specified server.</p>
1663 <p class="code">
1664 int cupsPrintFiles2 (<br>
1665 &nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1666 &nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
1667 &nbsp;&nbsp;&nbsp;&nbsp;int num_files,<br>
1668 &nbsp;&nbsp;&nbsp;&nbsp;const char **files,<br>
1669 &nbsp;&nbsp;&nbsp;&nbsp;const char *title,<br>
1670 &nbsp;&nbsp;&nbsp;&nbsp;int num_options,<br>
1671 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_option_t">cups_option_t</a> *options<br>
1672 );</p>
1673 <h4 class="parameters">Parameters</h4>
1674 <dl>
1675 <dt>http</dt>
1676 <dd class="description">HTTP connection or <code>CUPS_HTTP_DEFAULT</code></dd>
1677 <dt>name</dt>
1678 <dd class="description">Printer or class name</dd>
1679 <dt>num_files</dt>
1680 <dd class="description">Number of files</dd>
1681 <dt>files</dt>
1682 <dd class="description">File(s) to print</dd>
1683 <dt>title</dt>
1684 <dd class="description">Title of job</dd>
1685 <dt>num_options</dt>
1686 <dd class="description">Number of options</dd>
1687 <dt>options</dt>
1688 <dd class="description">Options</dd>
1689 </dl>
1690 <h4 class="returnvalue">Return Value</h4>
1691 <p class="description">Job ID or 0 on error</p>
1692 <h3 class="function"><span class="info">&nbsp;CUPS 1.1.20&nbsp;</span><a name="cupsPutFd">cupsPutFd</a></h3>
1693 <p class="description">Put a file on the server.</p>
1694 <p class="code">
1695 http_status_t cupsPutFd (<br>
1696 &nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1697 &nbsp;&nbsp;&nbsp;&nbsp;const char *resource,<br>
1698 &nbsp;&nbsp;&nbsp;&nbsp;int fd<br>
1699 );</p>
1700 <h4 class="parameters">Parameters</h4>
1701 <dl>
1702 <dt>http</dt>
1703 <dd class="description">HTTP connection to server or <code>CUPS_HTTP_DEFAULT</code></dd>
1704 <dt>resource</dt>
1705 <dd class="description">Resource name</dd>
1706 <dt>fd</dt>
1707 <dd class="description">File descriptor</dd>
1708 </dl>
1709 <h4 class="returnvalue">Return Value</h4>
1710 <p class="description">HTTP status</p>
1711 <h4 class="discussion">Discussion</h4>
1712 <p class="discussion">This function returns <code>HTTP_CREATED</code> when the file is stored
1713 successfully.
1714
1715 </p>
1716 <h3 class="function"><span class="info">&nbsp;CUPS 1.1.20&nbsp;</span><a name="cupsPutFile">cupsPutFile</a></h3>
1717 <p class="description">Put a file on the server.</p>
1718 <p class="code">
1719 http_status_t cupsPutFile (<br>
1720 &nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1721 &nbsp;&nbsp;&nbsp;&nbsp;const char *resource,<br>
1722 &nbsp;&nbsp;&nbsp;&nbsp;const char *filename<br>
1723 );</p>
1724 <h4 class="parameters">Parameters</h4>
1725 <dl>
1726 <dt>http</dt>
1727 <dd class="description">HTTP connection to server or <code>CUPS_HTTP_DEFAULT</code></dd>
1728 <dt>resource</dt>
1729 <dd class="description">Resource name</dd>
1730 <dt>filename</dt>
1731 <dd class="description">Filename</dd>
1732 </dl>
1733 <h4 class="returnvalue">Return Value</h4>
1734 <p class="description">HTTP status</p>
1735 <h4 class="discussion">Discussion</h4>
1736 <p class="discussion">This function returns <code>HTTP_CREATED</code> when the file is stored
1737 successfully.
1738
1739 </p>
1740 <h3 class="function"><span class="info">&nbsp;CUPS 1.3&nbsp;</span><a name="cupsRemoveDest">cupsRemoveDest</a></h3>
1741 <p class="description">Remove a destination from the destination list.</p>
1742 <p class="code">
1743 int cupsRemoveDest (<br>
1744 &nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
1745 &nbsp;&nbsp;&nbsp;&nbsp;const char *instance,<br>
1746 &nbsp;&nbsp;&nbsp;&nbsp;int num_dests,<br>
1747 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_t">cups_dest_t</a> **dests<br>
1748 );</p>
1749 <h4 class="parameters">Parameters</h4>
1750 <dl>
1751 <dt>name</dt>
1752 <dd class="description">Destination name</dd>
1753 <dt>instance</dt>
1754 <dd class="description">Instance name or <code>NULL</code></dd>
1755 <dt>num_dests</dt>
1756 <dd class="description">Number of destinations</dd>
1757 <dt>dests</dt>
1758 <dd class="description">Destinations</dd>
1759 </dl>
1760 <h4 class="returnvalue">Return Value</h4>
1761 <p class="description">New number of destinations</p>
1762 <h4 class="discussion">Discussion</h4>
1763 <p class="discussion">Removing a destination/instance does not delete the class or printer
1764 queue, merely the lpoptions for that destination/instance. Use the
1765 <a href="#cupsSetDests"><code>cupsSetDests</code></a> or <a href="#cupsSetDests2"><code>cupsSetDests2</code></a> functions to save the new
1766 options for the user.
1767
1768 </p>
1769 <h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsRemoveOption">cupsRemoveOption</a></h3>
1770 <p class="description">Remove an option from an option array.</p>
1771 <p class="code">
1772 int cupsRemoveOption (<br>
1773 &nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
1774 &nbsp;&nbsp;&nbsp;&nbsp;int num_options,<br>
1775 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_option_t">cups_option_t</a> **options<br>
1776 );</p>
1777 <h4 class="parameters">Parameters</h4>
1778 <dl>
1779 <dt>name</dt>
1780 <dd class="description">Option name</dd>
1781 <dt>num_options</dt>
1782 <dd class="description">Current number of options</dd>
1783 <dt>options</dt>
1784 <dd class="description">Options</dd>
1785 </dl>
1786 <h4 class="returnvalue">Return Value</h4>
1787 <p class="description">New number of options</p>
1788 <h3 class="function"><a name="cupsServer">cupsServer</a></h3>
1789 <p class="description">Return the hostname/address of the default server.</p>
1790 <p class="code">
1791 const char *cupsServer (void);</p>
1792 <h4 class="returnvalue">Return Value</h4>
1793 <p class="description">Server name</p>
1794 <h4 class="discussion">Discussion</h4>
1795 <p class="discussion">The returned value can be a fully-qualified hostname, a numeric
1796 IPv4 or IPv6 address, or a domain socket pathname.</p>
1797 <h3 class="function"><span class="info">&nbsp;CUPS 1.3&nbsp;</span><a name="cupsSetDefaultDest">cupsSetDefaultDest</a></h3>
1798 <p class="description">Set the default destination.</p>
1799 <p class="code">
1800 void cupsSetDefaultDest (<br>
1801 &nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
1802 &nbsp;&nbsp;&nbsp;&nbsp;const char *instance,<br>
1803 &nbsp;&nbsp;&nbsp;&nbsp;int num_dests,<br>
1804 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_t">cups_dest_t</a> *dests<br>
1805 );</p>
1806 <h4 class="parameters">Parameters</h4>
1807 <dl>
1808 <dt>name</dt>
1809 <dd class="description">Destination name</dd>
1810 <dt>instance</dt>
1811 <dd class="description">Instance name or <code>NULL</code></dd>
1812 <dt>num_dests</dt>
1813 <dd class="description">Number of destinations</dd>
1814 <dt>dests</dt>
1815 <dd class="description">Destinations</dd>
1816 </dl>
1817 <h3 class="function"><a name="cupsSetDests">cupsSetDests</a></h3>
1818 <p class="description">Save the list of destinations for the default server.</p>
1819 <p class="code">
1820 void cupsSetDests (<br>
1821 &nbsp;&nbsp;&nbsp;&nbsp;int num_dests,<br>
1822 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_t">cups_dest_t</a> *dests<br>
1823 );</p>
1824 <h4 class="parameters">Parameters</h4>
1825 <dl>
1826 <dt>num_dests</dt>
1827 <dd class="description">Number of destinations</dd>
1828 <dt>dests</dt>
1829 <dd class="description">Destinations</dd>
1830 </dl>
1831 <h4 class="discussion">Discussion</h4>
1832 <p class="discussion">This function saves the destinations to /etc/cups/lpoptions when run
1833 as root and ~/.cups/lpoptions when run as a normal user.</p>
1834 <h3 class="function"><span class="info">&nbsp;CUPS 1.1.21&nbsp;</span><a name="cupsSetDests2">cupsSetDests2</a></h3>
1835 <p class="description">Save the list of destinations for the specified server.</p>
1836 <p class="code">
1837 int cupsSetDests2 (<br>
1838 &nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1839 &nbsp;&nbsp;&nbsp;&nbsp;int num_dests,<br>
1840 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_t">cups_dest_t</a> *dests<br>
1841 );</p>
1842 <h4 class="parameters">Parameters</h4>
1843 <dl>
1844 <dt>http</dt>
1845 <dd class="description">HTTP connection or <code>CUPS_HTTP_DEFAULT</code></dd>
1846 <dt>num_dests</dt>
1847 <dd class="description">Number of destinations</dd>
1848 <dt>dests</dt>
1849 <dd class="description">Destinations</dd>
1850 </dl>
1851 <h4 class="returnvalue">Return Value</h4>
1852 <p class="description">0 on success, -1 on error</p>
1853 <h4 class="discussion">Discussion</h4>
1854 <p class="discussion">This function saves the destinations to /etc/cups/lpoptions when run
1855 as root and ~/.cups/lpoptions when run as a normal user.
1856
1857 </p>
1858 <h3 class="function"><a name="cupsSetEncryption">cupsSetEncryption</a></h3>
1859 <p class="description">Set the encryption preference.</p>
1860 <p class="code">
1861 void cupsSetEncryption (<br>
1862 &nbsp;&nbsp;&nbsp;&nbsp;http_encryption_t e<br>
1863 );</p>
1864 <h4 class="parameters">Parameters</h4>
1865 <dl>
1866 <dt>e</dt>
1867 <dd class="description">New encryption preference</dd>
1868 </dl>
1869 <h3 class="function"><a name="cupsSetPasswordCB">cupsSetPasswordCB</a></h3>
1870 <p class="description">Set the password callback for CUPS.</p>
1871 <p class="code">
1872 void cupsSetPasswordCB (<br>
1873 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_password_cb_t">cups_password_cb_t</a> cb<br>
1874 );</p>
1875 <h4 class="parameters">Parameters</h4>
1876 <dl>
1877 <dt>cb</dt>
1878 <dd class="description">Callback function</dd>
1879 </dl>
1880 <h4 class="discussion">Discussion</h4>
1881 <p class="discussion">Pass <code>NULL</code> to restore the default (console) password callback.</p>
1882 <h3 class="function"><a name="cupsSetServer">cupsSetServer</a></h3>
1883 <p class="description">Set the default server name.</p>
1884 <p class="code">
1885 void cupsSetServer (<br>
1886 &nbsp;&nbsp;&nbsp;&nbsp;const char *server<br>
1887 );</p>
1888 <h4 class="parameters">Parameters</h4>
1889 <dl>
1890 <dt>server</dt>
1891 <dd class="description">Server name</dd>
1892 </dl>
1893 <h4 class="discussion">Discussion</h4>
1894 <p class="discussion">The &quot;server&quot; string can be a fully-qualified hostname, a numeric
1895 IPv4 or IPv6 address, or a domain socket pathname. Pass <code>NULL</code> to
1896 restore the default server name.</p>
1897 <h3 class="function"><a name="cupsSetUser">cupsSetUser</a></h3>
1898 <p class="description">Set the default user name.</p>
1899 <p class="code">
1900 void cupsSetUser (<br>
1901 &nbsp;&nbsp;&nbsp;&nbsp;const char *user<br>
1902 );</p>
1903 <h4 class="parameters">Parameters</h4>
1904 <dl>
1905 <dt>user</dt>
1906 <dd class="description">User name</dd>
1907 </dl>
1908 <h4 class="discussion">Discussion</h4>
1909 <p class="discussion">Pass <code>NULL</code> to restore the default user name.</p>
1910 <h3 class="function"><span class="info">&nbsp;CUPS 1.4&nbsp;</span><a name="cupsStartDocument">cupsStartDocument</a></h3>
1911 <p class="description">Add a document to a job created with cupsCreateJob().</p>
1912 <p class="code">
1913 http_status_t cupsStartDocument (<br>
1914 &nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1915 &nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
1916 &nbsp;&nbsp;&nbsp;&nbsp;int job_id,<br>
1917 &nbsp;&nbsp;&nbsp;&nbsp;const char *docname,<br>
1918 &nbsp;&nbsp;&nbsp;&nbsp;const char *format,<br>
1919 &nbsp;&nbsp;&nbsp;&nbsp;int last_document<br>
1920 );</p>
1921 <h4 class="parameters">Parameters</h4>
1922 <dl>
1923 <dt>http</dt>
1924 <dd class="description">HTTP connection or <code>CUPS_HTTP_DEFAULT</code></dd>
1925 <dt>name</dt>
1926 <dd class="description">Printer or class name</dd>
1927 <dt>job_id</dt>
1928 <dd class="description">Job ID from <a href="#cupsCreateJob"><code>cupsCreateJob</code></a></dd>
1929 <dt>docname</dt>
1930 <dd class="description">Name of document</dd>
1931 <dt>format</dt>
1932 <dd class="description">MIME type or <code>CUPS_FORMAT_foo</code></dd>
1933 <dt>last_document</dt>
1934 <dd class="description">1 for last document in job, 0 otherwise</dd>
1935 </dl>
1936 <h4 class="returnvalue">Return Value</h4>
1937 <p class="description">HTTP status of request</p>
1938 <h4 class="discussion">Discussion</h4>
1939 <p class="discussion">Use <a href="#cupsWriteRequestData"><code>cupsWriteRequestData</code></a> to write data for the document and
1940 <a href="#cupsFinishDocument"><code>cupsFinishDocument</code></a> to finish the document and get the submission status.<br>
1941 <br>
1942 The MIME type constants <code>CUPS_FORMAT_AUTO</code>, <code>CUPS_FORMAT_PDF</code>,
1943 <code>CUPS_FORMAT_POSTSCRIPT</code>, <code>CUPS_FORMAT_RAW</code>, and
1944 <code>CUPS_FORMAT_TEXT</code> are provided for the &quot;format&quot; argument, although
1945 any supported MIME type string can be supplied.
1946
1947 </p>
1948 <h3 class="function"><a name="cupsTempFd">cupsTempFd</a></h3>
1949 <p class="description">Creates a temporary file.</p>
1950 <p class="code">
1951 int cupsTempFd (<br>
1952 &nbsp;&nbsp;&nbsp;&nbsp;char *filename,<br>
1953 &nbsp;&nbsp;&nbsp;&nbsp;int len<br>
1954 );</p>
1955 <h4 class="parameters">Parameters</h4>
1956 <dl>
1957 <dt>filename</dt>
1958 <dd class="description">Pointer to buffer</dd>
1959 <dt>len</dt>
1960 <dd class="description">Size of buffer</dd>
1961 </dl>
1962 <h4 class="returnvalue">Return Value</h4>
1963 <p class="description">New file descriptor or -1 on error</p>
1964 <h4 class="discussion">Discussion</h4>
1965 <p class="discussion">The temporary filename is returned in the filename buffer.
1966 The temporary file is opened for reading and writing.</p>
1967 <h3 class="function"><span class="info">&nbsp;DEPRECATED&nbsp;</span><a name="cupsTempFile">cupsTempFile</a></h3>
1968 <p class="description">Generates a temporary filename.</p>
1969 <p class="code">
1970 char *cupsTempFile (<br>
1971 &nbsp;&nbsp;&nbsp;&nbsp;char *filename,<br>
1972 &nbsp;&nbsp;&nbsp;&nbsp;int len<br>
1973 );</p>
1974 <h4 class="parameters">Parameters</h4>
1975 <dl>
1976 <dt>filename</dt>
1977 <dd class="description">Pointer to buffer</dd>
1978 <dt>len</dt>
1979 <dd class="description">Size of buffer</dd>
1980 </dl>
1981 <h4 class="returnvalue">Return Value</h4>
1982 <p class="description">Filename or NULL on error</p>
1983 <h4 class="discussion">Discussion</h4>
1984 <p class="discussion">The temporary filename is returned in the filename buffer.
1985 This function is deprecated - use <a href="#cupsTempFd"><code>cupsTempFd</code></a> or
1986 <a href="#cupsTempFile2"><code>cupsTempFile2</code></a> instead.
1987
1988 </p>
1989 <h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsTempFile2">cupsTempFile2</a></h3>
1990 <p class="description">Creates a temporary CUPS file.</p>
1991 <p class="code">
1992 cups_file_t *cupsTempFile2 (<br>
1993 &nbsp;&nbsp;&nbsp;&nbsp;char *filename,<br>
1994 &nbsp;&nbsp;&nbsp;&nbsp;int len<br>
1995 );</p>
1996 <h4 class="parameters">Parameters</h4>
1997 <dl>
1998 <dt>filename</dt>
1999 <dd class="description">Pointer to buffer</dd>
2000 <dt>len</dt>
2001 <dd class="description">Size of buffer</dd>
2002 </dl>
2003 <h4 class="returnvalue">Return Value</h4>
2004 <p class="description">CUPS file or NULL on error</p>
2005 <h4 class="discussion">Discussion</h4>
2006 <p class="discussion">The temporary filename is returned in the filename buffer.
2007 The temporary file is opened for writing.
2008
2009 </p>
2010 <h3 class="function"><a name="cupsUser">cupsUser</a></h3>
2011 <p class="description">Return the current user's name.</p>
2012 <p class="code">
2013 const char *cupsUser (void);</p>
2014 <h4 class="returnvalue">Return Value</h4>
2015 <p class="description">User name</p>
2016 <h2 class="title"><a name="TYPES">Data Types</a></h2>
2017 <h3 class="typedef"><a name="cups_dest_t">cups_dest_t</a></h3>
2018 <p class="description">Destination</p>
2019 <p class="code">
2020 typedef struct <a href="#cups_dest_s">cups_dest_s</a> cups_dest_t;
2021 </p>
2022 <h3 class="typedef"><a name="cups_job_t">cups_job_t</a></h3>
2023 <p class="description">Job</p>
2024 <p class="code">
2025 typedef struct <a href="#cups_job_s">cups_job_s</a> cups_job_t;
2026 </p>
2027 <h3 class="typedef"><a name="cups_option_t">cups_option_t</a></h3>
2028 <p class="description">Printer Options</p>
2029 <p class="code">
2030 typedef struct <a href="#cups_option_s">cups_option_s</a> cups_option_t;
2031 </p>
2032 <h3 class="typedef"><a name="cups_password_cb_t">cups_password_cb_t</a></h3>
2033 <p class="description">Password callback</p>
2034 <p class="code">
2035 typedef const char *(*cups_password_cb_t)(const char *);
2036 </p>
2037 <h3 class="typedef"><a name="cups_ptype_t">cups_ptype_t</a></h3>
2038 <p class="description">Printer type/capability bits</p>
2039 <p class="code">
2040 typedef unsigned cups_ptype_t;
2041 </p>
2042 <h2 class="title"><a name="STRUCTURES">Structures</a></h2>
2043 <h3 class="struct"><a name="cups_dest_s">cups_dest_s</a></h3>
2044 <p class="description">Destination</p>
2045 <p class="code">struct cups_dest_s {<br>
2046 &nbsp;&nbsp;&nbsp;&nbsp;char *name, *instance;<br>
2047 &nbsp;&nbsp;&nbsp;&nbsp;int is_default;<br>
2048 &nbsp;&nbsp;&nbsp;&nbsp;int num_options;<br>
2049 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_option_t">cups_option_t</a> *options;<br>
2050 };</p>
2051 <h4 class="members">Members</h4>
2052 <dl>
2053 <dt>instance </dt>
2054 <dd class="description">Local instance name or NULL</dd>
2055 <dt>is_default </dt>
2056 <dd class="description">Is this printer the default?</dd>
2057 <dt>num_options </dt>
2058 <dd class="description">Number of options</dd>
2059 <dt>options </dt>
2060 <dd class="description">Options</dd>
2061 </dl>
2062 <h3 class="struct"><a name="cups_job_s">cups_job_s</a></h3>
2063 <p class="description">Job</p>
2064 <p class="code">struct cups_job_s {<br>
2065 &nbsp;&nbsp;&nbsp;&nbsp;time_t completed_time;<br>
2066 &nbsp;&nbsp;&nbsp;&nbsp;time_t creation_time;<br>
2067 &nbsp;&nbsp;&nbsp;&nbsp;char *dest;<br>
2068 &nbsp;&nbsp;&nbsp;&nbsp;char *format;<br>
2069 &nbsp;&nbsp;&nbsp;&nbsp;int id;<br>
2070 &nbsp;&nbsp;&nbsp;&nbsp;int priority;<br>
2071 &nbsp;&nbsp;&nbsp;&nbsp;time_t processing_time;<br>
2072 &nbsp;&nbsp;&nbsp;&nbsp;int size;<br>
2073 &nbsp;&nbsp;&nbsp;&nbsp;ipp_jstate_t state;<br>
2074 &nbsp;&nbsp;&nbsp;&nbsp;char *title;<br>
2075 &nbsp;&nbsp;&nbsp;&nbsp;char *user;<br>
2076 };</p>
2077 <h4 class="members">Members</h4>
2078 <dl>
2079 <dt>completed_time </dt>
2080 <dd class="description">Time the job was completed</dd>
2081 <dt>creation_time </dt>
2082 <dd class="description">Time the job was created</dd>
2083 <dt>dest </dt>
2084 <dd class="description">Printer or class name</dd>
2085 <dt>format </dt>
2086 <dd class="description">Document format</dd>
2087 <dt>id </dt>
2088 <dd class="description">The job ID</dd>
2089 <dt>priority </dt>
2090 <dd class="description">Priority (1-100)</dd>
2091 <dt>processing_time </dt>
2092 <dd class="description">Time the job was processed</dd>
2093 <dt>size </dt>
2094 <dd class="description">Size in kilobytes</dd>
2095 <dt>state </dt>
2096 <dd class="description">Job state</dd>
2097 <dt>title </dt>
2098 <dd class="description">Title/job name</dd>
2099 <dt>user </dt>
2100 <dd class="description">User the submitted the job</dd>
2101 </dl>
2102 <h3 class="struct"><a name="cups_option_s">cups_option_s</a></h3>
2103 <p class="description">Printer Options</p>
2104 <p class="code">struct cups_option_s {<br>
2105 &nbsp;&nbsp;&nbsp;&nbsp;char *name;<br>
2106 &nbsp;&nbsp;&nbsp;&nbsp;char *value;<br>
2107 };</p>
2108 <h4 class="members">Members</h4>
2109 <dl>
2110 <dt>name </dt>
2111 <dd class="description">Name of option</dd>
2112 <dt>value </dt>
2113 <dd class="description">Value of option</dd>
2114 </dl>
2115 <h2 class="title"><a name="ENUMERATIONS">Constants</a></h2>
2116 <h3 class="enumeration"><a name="cups_ptype_e">cups_ptype_e</a></h3>
2117 <p class="description">Printer type/capability bit constants</p>
2118 <h4 class="constants">Constants</h4>
2119 <dl>
2120 <dt>CUPS_PRINTER_AUTHENTICATED <span class="info">&nbsp;CUPS 1.2&nbsp;</span></dt>
2121 <dd class="description">Printer requires authentication </dd>
2122 <dt>CUPS_PRINTER_BIND </dt>
2123 <dd class="description">Can bind output</dd>
2124 <dt>CUPS_PRINTER_BW </dt>
2125 <dd class="description">Can do B&amp;W printing</dd>
2126 <dt>CUPS_PRINTER_CLASS </dt>
2127 <dd class="description">Printer class</dd>
2128 <dt>CUPS_PRINTER_COLLATE </dt>
2129 <dd class="description">Can collage copies</dd>
2130 <dt>CUPS_PRINTER_COLOR </dt>
2131 <dd class="description">Can do color printing</dd>
2132 <dt>CUPS_PRINTER_COMMANDS <span class="info">&nbsp;CUPS 1.2&nbsp;</span></dt>
2133 <dd class="description">Printer supports maintenance commands </dd>
2134 <dt>CUPS_PRINTER_COPIES </dt>
2135 <dd class="description">Can do copies</dd>
2136 <dt>CUPS_PRINTER_COVER </dt>
2137 <dd class="description">Can cover output</dd>
2138 <dt>CUPS_PRINTER_DEFAULT </dt>
2139 <dd class="description">Default printer on network</dd>
2140 <dt>CUPS_PRINTER_DELETE <span class="info">&nbsp;CUPS 1.2&nbsp;</span></dt>
2141 <dd class="description">Delete printer </dd>
2142 <dt>CUPS_PRINTER_DISCOVERED <span class="info">&nbsp;CUPS 1.3&nbsp;</span></dt>
2143 <dd class="description">Printer was automatically discovered and added </dd>
2144 <dt>CUPS_PRINTER_DUPLEX </dt>
2145 <dd class="description">Can do duplexing</dd>
2146 <dt>CUPS_PRINTER_FAX </dt>
2147 <dd class="description">Fax queue</dd>
2148 <dt>CUPS_PRINTER_IMPLICIT </dt>
2149 <dd class="description">Implicit class</dd>
2150 <dt>CUPS_PRINTER_LARGE </dt>
2151 <dd class="description">Can do D/E/A1/A0</dd>
2152 <dt>CUPS_PRINTER_LOCAL </dt>
2153 <dd class="description">Local printer or class</dd>
2154 <dt>CUPS_PRINTER_MEDIUM </dt>
2155 <dd class="description">Can do Tabloid/B/C/A3/A2</dd>
2156 <dt>CUPS_PRINTER_NOT_SHARED <span class="info">&nbsp;CUPS 1.2&nbsp;</span></dt>
2157 <dd class="description">Printer is not shared </dd>
2158 <dt>CUPS_PRINTER_PUNCH </dt>
2159 <dd class="description">Can punch output</dd>
2160 <dt>CUPS_PRINTER_REJECTING </dt>
2161 <dd class="description">Printer is rejecting jobs</dd>
2162 <dt>CUPS_PRINTER_REMOTE </dt>
2163 <dd class="description">Remote printer or class</dd>
2164 <dt>CUPS_PRINTER_SMALL </dt>
2165 <dd class="description">Can do Letter/Legal/A4</dd>
2166 <dt>CUPS_PRINTER_SORT </dt>
2167 <dd class="description">Can sort output</dd>
2168 <dt>CUPS_PRINTER_STAPLE </dt>
2169 <dd class="description">Can staple output</dd>
2170 <dt>CUPS_PRINTER_VARIABLE </dt>
2171 <dd class="description">Can do variable sizes</dd>
2172 </dl>
2173 </div>
2174 </body>
2175 </html>