]> git.ipfire.org Git - thirdparty/cups.git/blame - doc/help/api-cups.html
Merge changes from CUPS 1.6svn-r10310.
[thirdparty/cups.git] / doc / help / api-cups.html
CommitLineData
745129be 1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
ef416fc2 2<html>
3<!-- SECTION: Programming -->
4<head>
0268488e
MS
5 <title>CUPS API </title>
6 <meta name="keywords" content="Programming">
7 <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
8 <meta name="creator" content="Mini-XML v2.7">
5a738aea
MS
9<style type="text/css"><!--
10BODY {
11 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
12}
13
14H1, H2, H3, H4, H5, H6, P, TD, TH {
15 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
16}
17
18KBD {
19 font-family: monaco, courier, monospace;
20 font-weight: bold;
21}
22
23PRE {
24 font-family: monaco, courier, monospace;
25}
26
27PRE.command {
10d09e33 28 border: dotted thin #7f7f7f;
5a738aea 29 margin-left: 36pt;
10d09e33 30 padding: 10px;
5a738aea
MS
31}
32
f11a948a
MS
33P.compact {
34 margin: 0;
35}
36
e4572d57
MS
37P.example {
38 font-style: italic;
39 margin-left: 36pt;
40}
41
5a738aea
MS
42PRE.example {
43 background: #eeeeee;
44 border: dotted thin #999999;
45 margin-left: 36pt;
178cb736 46 padding: 10pt;
5a738aea
MS
47}
48
49PRE.command EM, PRE.example EM {
50 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
51}
52
53P.command {
54 font-family: monaco, courier, monospace;
55 margin-left: 36pt;
56}
57
58P.formula {
59 font-style: italic;
60 margin-left: 36pt;
61}
62
63BLOCKQUOTE {
178cb736 64 background: #eeeeee;
5a738aea
MS
65 border: solid thin #999999;
66 padding: 10pt;
67}
68
e4572d57
MS
69A IMG {
70 border: none;
71}
72
73A:link:hover IMG {
74 background: #f0f0f0;
75 border-radius: 10px;
76 -moz-border-radius: 10px;
77}
78
5a738aea 79A:link, A:visited {
568fa3fa 80 font-weight: normal;
5a738aea 81 text-decoration: none;
5a738aea
MS
82}
83
84A:link:hover, A:visited:hover, A:active {
85 text-decoration: underline;
5a738aea
MS
86}
87
88SUB, SUP {
89 font-size: 50%;
90}
91
e4572d57
MS
92TR.data, TD.data, TR.data TD {
93 margin-top: 10pt;
94 padding: 5pt;
95 border-bottom: solid 1pt #999999;
96}
97
98TR.data TH {
99 border-bottom: solid 1pt #999999;
100 padding-top: 10pt;
101 padding-left: 5pt;
102 text-align: left;
103}
104
5a738aea
MS
105DIV.table TABLE {
106 border: solid thin #999999;
107 border-collapse: collapse;
108 border-spacing: 0;
109 margin-left: auto;
110 margin-right: auto;
111}
112
113DIV.table CAPTION {
114 caption-side: top;
115 font-size: 120%;
116 font-style: italic;
117 font-weight: bold;
118 margin-left: auto;
119 margin-right: auto;
120}
121
122DIV.table TABLE TD {
123 border: solid thin #cccccc;
124 padding-top: 5pt;
125}
126
127DIV.table TABLE TH {
128 background: #cccccc;
129 border: none;
130 border-bottom: solid thin #999999;
131}
132
133DIV.figure TABLE {
134 margin-left: auto;
135 margin-right: auto;
136}
137
138DIV.figure CAPTION {
139 caption-side: bottom;
140 font-size: 120%;
141 font-style: italic;
142 font-weight: bold;
143 margin-left: auto;
144 margin-right: auto;
145}
146
147TH.label {
5a738aea
MS
148 text-align: right;
149 vertical-align: top;
150}
151
e4572d57
MS
152TH.sublabel {
153 text-align: right;
154 font-weight: normal;
155}
156
5a738aea
MS
157HR {
158 border: solid thin;
159}
160
161SPAN.info {
e4572d57
MS
162 background: black;
163 border: thin solid black;
164 color: white;
5a738aea
MS
165 font-size: 80%;
166 font-style: italic;
167 font-weight: bold;
168 white-space: nowrap;
169}
170
171H2 SPAN.info, H3 SPAN.info, H4 SPAN.info {
172 float: right;
173 font-size: 100%;
174}
175
178cb736
MS
176H1.title {
177}
178
5a738aea
MS
179H2.title, H3.title {
180 border-bottom: solid 2pt #000000;
181}
182
e4572d57
MS
183DIV.indent, TABLE.indent {
184 margin-top: 2em;
185 margin-left: auto;
186 margin-right: auto;
187 width: 90%;
188}
189
190TABLE.indent {
191 border-collapse: collapse;
192}
193
194TABLE.indent TD, TABLE.indent TH {
195 padding: 0;
196}
197
198TABLE.list {
199 border-collapse: collapse;
200 margin-left: auto;
201 margin-right: auto;
202 width: 90%;
203}
204
205TABLE.list TH {
206 background: white;
207 border-bottom: solid thin #cccccc;
208 color: #444444;
209 padding-top: 10pt;
210 padding-left: 5pt;
211 text-align: left;
212 vertical-align: bottom;
213 white-space: nowrap;
214}
215
216TABLE.list TH A {
217 color: #4444cc;
218}
219
220TABLE.list TD {
221 border-bottom: solid thin #eeeeee;
222 padding-top: 5pt;
223 padding-left: 5pt;
224}
225
226TABLE.list TR:nth-child(even) {
227 background: #f8f8f8;
228}
229
230TABLE.list TR:nth-child(odd) {
231 background: #f4f4f4;
232}
233
5a738aea
MS
234DT {
235 margin-left: 36pt;
236 margin-top: 12pt;
237}
238
239DD {
240 margin-left: 54pt;
241}
242
243DL.category DT {
244 font-weight: bold;
245}
246
247P.summary {
248 margin-left: 36pt;
249 font-family: monaco, courier, monospace;
250}
251
5a738aea
MS
252DIV.summary TABLE {
253 border: solid thin #999999;
254 border-collapse: collapse;
255 border-spacing: 0;
256 margin: 10px;
257}
258
259DIV.summary TABLE TD, DIV.summary TABLE TH {
260 border: solid thin #999999;
261 padding: 5px;
262 text-align: left;
263 vertical-align: top;
264}
265
266DIV.summary TABLE THEAD TH {
267 background: #eeeeee;
268}
269
270/* API documentation styles... */
271div.body h1 {
272 margin: 0;
273}
274div.body h2 {
275 margin-top: 1.5em;
276}
277div.body h3, div.body h4, div.body h5 {
278 margin-bottom: 0.5em;
279 margin-top: 1.5em;
280}
281.class, .enumeration, .function, .struct, .typedef, .union {
282 border-bottom: solid thin #999999;
283 margin-bottom: 0;
284 margin-top: 2em;
285}
286.description {
287 margin-top: 0.5em;
288}
289code, p.code, pre, ul.code li {
290 font-family: monaco, courier, monospace;
291 font-size: 90%;
292}
293ul.code, ul.contents, ul.subcontents {
294 list-style-type: none;
295 margin: 0;
296 padding-left: 0;
297}
298ul.code li {
299 margin: 0;
300}
301ul.contents > li {
302 margin-top: 1em;
303}
304ul.contents li ul.code, ul.contents li ul.subcontents {
305 padding-left: 2em;
306}
307div.body dl {
308 margin-left: 0;
309 margin-top: 0;
310}
311div.body dt {
312 font-style: italic;
313 margin-left: 0;
314 margin-top: 0;
315}
316div.body dd {
317 margin-bottom: 0.5em;
318}
319
320/* This is just for the HTML files generated with the framedhelp target */
321div.contents {
322 background: #e8e8e8;
323 border: solid thin black;
324 padding: 10px;
325}
326div.contents h1 {
327 font-size: 110%;
328}
329div.contents h2 {
330 font-size: 100%;
331}
332div.contents ul.contents {
333 font-size: 80%;
334}
ac884b6a
MS
335div.contents ul.subcontents li {
336 margin-left: 1em;
337 text-indent: -1em;
338}
5a738aea 339--></style>
ef416fc2 340</head>
341<body>
5a738aea
MS
342<div class='body'>
343<!--
68b10830 344 "$Id$"
5a738aea 345
321d8d57 346 CUPS API header for CUPS.
5a738aea 347
321d8d57 348 Copyright 2008-2011 by Apple Inc.
5a738aea
MS
349
350 These coded instructions, statements, and computer programs are the
351 property of Apple Inc. and are protected by Federal copyright
352 law. Distribution and use rights are outlined in the file "LICENSE.txt"
353 which should have been included with this file. If this file is
354 file is missing or damaged, see the license at "http://www.cups.org/".
355-->
356
178cb736
MS
357<h1 class='title'>CUPS API</h1>
358
5a738aea
MS
359<div class='summary'><table summary='General Information'>
360<thead>
361<tr>
362 <th>Header</th>
363 <th>cups/cups.h</th>
364</tr>
365</thead>
366<tbody>
367<tr>
368 <th>Library</th>
369 <td>-lcups</td>
370</tr>
371<tr>
372 <th>See Also</th>
373 <td>Programming: <a href='api-overview.html' target='_top'>Introduction to CUPS Programming</a><br>
374 Programming: <a href='api-array.html' target='_top'>Array API</a><br>
375 Programming: <a href='api-filedir.html' target='_top'>File and Directory APIs</a><br>
376 Programming: <a href='api-filter.html' target='_top'>Filter and Backend Programming</a><br>
377 Programming: <a href='api-httpipp.html' target='_top'>HTTP and IPP APIs</a><br>
378 Programming: <a href='api-ppd.html' target='_top'>PPD API</a><br>
379 Programming: <a href='api-raster.html' target='_top'>Raster API</a></td>
380</tr>
381</tbody>
382</table></div>
383<h2 class="title">Contents</h2>
384<ul class="contents">
5a738aea 385<li><a href="#OVERVIEW">Overview</a><ul class="subcontents">
0268488e
MS
386 <li><a href="#CLIENTS_AND_SERVERS">Clients and Servers</a></li>
387 <li><a href="#PRINTERS_AND_CLASSES">Printers and Classes</a></li>
388 <li><a href="#OPTIONS">Options</a></li>
389 <li><a href="#PRINT_JOBS">Print Jobs</a></li>
390 <li><a href="#ERROR_HANDLING">Error Handling</a></li>
391 <li><a href="#PASSWORDS_AND_AUTHENTICATION">Passwords and Authentication</a></li>
5a738aea
MS
392</ul></li>
393<li><a href="#FUNCTIONS">Functions</a><ul class="code">
82f97232 394 <li><a href="#appleGetPaperSize" title="Get the default paper size.">appleGetPaperSize</a></li>
0268488e
MS
395 <li><a href="#cupsAddDest" title="Add a destination to the list of destinations.">cupsAddDest</a></li>
396 <li><a href="#cupsAddOption" title="Add an option to an option array.">cupsAddOption</a></li>
397 <li><a href="#cupsAdminCreateWindowsPPD" title="Create the Windows PPD file for a printer.">cupsAdminCreateWindowsPPD</a></li>
398 <li><a href="#cupsAdminExportSamba" title="Export a printer to Samba.">cupsAdminExportSamba</a></li>
399 <li><a href="#cupsAdminGetServerSettings" title="Get settings from the server.">cupsAdminGetServerSettings</a></li>
400 <li><a href="#cupsAdminSetServerSettings" title="Set settings on the server.">cupsAdminSetServerSettings</a></li>
401 <li><a href="#cupsCancelJob" title="Cancel a print job on the default server.">cupsCancelJob</a></li>
402 <li><a href="#cupsCancelJob2" title="Cancel or purge a print job.">cupsCancelJob2</a></li>
3e7fe0ca
MS
403 <li><a href="#cupsConnectDest" title="Connect to the server for a destination.">cupsConnectDest</a></li>
404 <li><a href="#cupsConnectDestBlock" title="Connect to the server for a destination.">cupsConnectDestBlock</a></li>
405 <li><a href="#cupsCopyDest" title="Callback block">cupsCopyDest</a></li>
0268488e
MS
406 <li><a href="#cupsCreateJob" title="Create an empty job for streaming.">cupsCreateJob</a></li>
407 <li><a href="#cupsEncryption" title="Get the current encryption settings.">cupsEncryption</a></li>
3e7fe0ca
MS
408 <li><a href="#cupsEnumDests" title="Enumerate available destinations with a callback function.">cupsEnumDests</a></li>
409 <li><a href="#cupsEnumDestsBlock" title="Enumerate available destinations with a block.">cupsEnumDestsBlock</a></li>
0268488e
MS
410 <li><a href="#cupsFinishDocument" title="Finish sending a document.">cupsFinishDocument</a></li>
411 <li><a href="#cupsFreeDests" title="Free the memory used by the list of destinations.">cupsFreeDests</a></li>
412 <li><a href="#cupsFreeJobs" title="Free memory used by job data.">cupsFreeJobs</a></li>
413 <li><a href="#cupsFreeOptions" title="Free all memory used by options.">cupsFreeOptions</a></li>
414 <li><a href="#cupsGetClasses" title="Get a list of printer classes from the default server.">cupsGetClasses</a></li>
415 <li><a href="#cupsGetDefault" title="Get the default printer or class for the default server.">cupsGetDefault</a></li>
416 <li><a href="#cupsGetDefault2" title="Get the default printer or class for the specified server.">cupsGetDefault2</a></li>
417 <li><a href="#cupsGetDest" title="Get the named destination from the list.">cupsGetDest</a></li>
418 <li><a href="#cupsGetDests" title="Get the list of destinations from the default server.">cupsGetDests</a></li>
419 <li><a href="#cupsGetDests2" title="Get the list of destinations from the specified server.">cupsGetDests2</a></li>
420 <li><a href="#cupsGetJobs" title="Get the jobs from the default server.">cupsGetJobs</a></li>
421 <li><a href="#cupsGetJobs2" title="Get the jobs from the specified server.">cupsGetJobs2</a></li>
422 <li><a href="#cupsGetNamedDest" title="Get options for the named destination.">cupsGetNamedDest</a></li>
423 <li><a href="#cupsGetOption" title="Get an option value.">cupsGetOption</a></li>
424 <li><a href="#cupsGetPPD" title="Get the PPD file for a printer on the default server.">cupsGetPPD</a></li>
425 <li><a href="#cupsGetPPD2" title="Get the PPD file for a printer from the specified server.">cupsGetPPD2</a></li>
426 <li><a href="#cupsGetPPD3" title="Get the PPD file for a printer on the specified
5a738aea 427server if it has changed.">cupsGetPPD3</a></li>
0268488e
MS
428 <li><a href="#cupsGetPassword" title="Get a password from the user.">cupsGetPassword</a></li>
429 <li><a href="#cupsGetPassword2" title="Get a password from the user using the advanced
aaf19ab0 430password callback.">cupsGetPassword2</a></li>
0268488e
MS
431 <li><a href="#cupsGetPrinters" title="Get a list of printers from the default server.">cupsGetPrinters</a></li>
432 <li><a href="#cupsGetServerPPD" title="Get an available PPD file from the server.">cupsGetServerPPD</a></li>
433 <li><a href="#cupsLangDefault" title="Return the default language.">cupsLangDefault</a></li>
434 <li><a href="#cupsLangEncoding" title="Return the character encoding (us-ascii, etc.)
5a738aea 435for the given language.">cupsLangEncoding</a></li>
0268488e
MS
436 <li><a href="#cupsLangFlush" title="Flush all language data out of the cache.">cupsLangFlush</a></li>
437 <li><a href="#cupsLangFree" title="Free language data.">cupsLangFree</a></li>
438 <li><a href="#cupsLangGet" title="Get a language.">cupsLangGet</a></li>
439 <li><a href="#cupsNotifySubject" title="Return the subject for the given notification message.">cupsNotifySubject</a></li>
440 <li><a href="#cupsNotifyText" title="Return the text for the given notification message.">cupsNotifyText</a></li>
441 <li><a href="#cupsParseOptions" title="Parse options from a command-line argument.">cupsParseOptions</a></li>
442 <li><a href="#cupsPrintFile" title="Print a file to a printer or class on the default server.">cupsPrintFile</a></li>
443 <li><a href="#cupsPrintFile2" title="Print a file to a printer or class on the specified
5a738aea 444server.">cupsPrintFile2</a></li>
0268488e 445 <li><a href="#cupsPrintFiles" title="Print one or more files to a printer or class on the
5a738aea 446default server.">cupsPrintFiles</a></li>
0268488e 447 <li><a href="#cupsPrintFiles2" title="Print one or more files to a printer or class on the
5a738aea 448specified server.">cupsPrintFiles2</a></li>
0268488e
MS
449 <li><a href="#cupsRemoveDest" title="Remove a destination from the destination list.">cupsRemoveDest</a></li>
450 <li><a href="#cupsRemoveOption" title="Remove an option from an option array.">cupsRemoveOption</a></li>
451 <li><a href="#cupsServer" title="Return the hostname/address of the current server.">cupsServer</a></li>
452 <li><a href="#cupsSetClientCertCB" title="Set the client certificate callback.">cupsSetClientCertCB</a></li>
453 <li><a href="#cupsSetCredentials" title="Set the default credentials to be used for SSL/TLS
10d09e33 454connections.">cupsSetCredentials</a></li>
0268488e
MS
455 <li><a href="#cupsSetDefaultDest" title="Set the default destination.">cupsSetDefaultDest</a></li>
456 <li><a href="#cupsSetDests" title="Save the list of destinations for the default server.">cupsSetDests</a></li>
457 <li><a href="#cupsSetDests2" title="Save the list of destinations for the specified server.">cupsSetDests2</a></li>
458 <li><a href="#cupsSetEncryption" title="Set the encryption preference.">cupsSetEncryption</a></li>
459 <li><a href="#cupsSetPasswordCB" title="Set the password callback for CUPS.">cupsSetPasswordCB</a></li>
460 <li><a href="#cupsSetPasswordCB2" title="Set the advanced password callback for CUPS.">cupsSetPasswordCB2</a></li>
461 <li><a href="#cupsSetServer" title="Set the default server name and port.">cupsSetServer</a></li>
462 <li><a href="#cupsSetServerCertCB" title="Set the server certificate callback.">cupsSetServerCertCB</a></li>
463 <li><a href="#cupsSetUser" title="Set the default user name.">cupsSetUser</a></li>
464 <li><a href="#cupsStartDocument" title="Add a document to a job created with cupsCreateJob().">cupsStartDocument</a></li>
465 <li><a href="#cupsTempFd" title="Creates a temporary file.">cupsTempFd</a></li>
466 <li><a href="#cupsTempFile" title="Generates a temporary filename.">cupsTempFile</a></li>
467 <li><a href="#cupsTempFile2" title="Creates a temporary CUPS file.">cupsTempFile2</a></li>
468 <li><a href="#cupsUser" title="Return the current user's name.">cupsUser</a></li>
8b450588 469</ul></li>
5a738aea 470<li><a href="#TYPES">Data Types</a><ul class="code">
3e7fe0ca
MS
471 <li><a href="#cups_client_cert_cb_t" title="Client credentials callback
472">cups_client_cert_cb_t</a></li>
473 <li><a href="#cups_dest_block_t" title="Destination enumeration block
474">cups_dest_block_t</a></li>
475 <li><a href="#cups_dest_cb_t" title="Destination enumeration callback
476">cups_dest_cb_t</a></li>
5a738aea 477 <li><a href="#cups_dest_t" title="Destination">cups_dest_t</a></li>
3e7fe0ca
MS
478 <li><a href="#cups_device_cb_t" title="Device callback
479">cups_device_cb_t</a></li>
480 <li><a href="#cups_dinfo_t" title="Destination capability and status
481information ">cups_dinfo_t</a></li>
5a738aea
MS
482 <li><a href="#cups_job_t" title="Job">cups_job_t</a></li>
483 <li><a href="#cups_option_t" title="Printer Options">cups_option_t</a></li>
3e7fe0ca
MS
484 <li><a href="#cups_password_cb2_t" title="New password callback
485">cups_password_cb2_t</a></li>
5a738aea
MS
486 <li><a href="#cups_password_cb_t" title="Password callback">cups_password_cb_t</a></li>
487 <li><a href="#cups_ptype_t" title="Printer type/capability bits">cups_ptype_t</a></li>
3e7fe0ca
MS
488 <li><a href="#cups_server_cert_cb_t" title="Server credentials callback
489">cups_server_cert_cb_t</a></li>
490 <li><a href="#cups_size_t" title="Media Size ">cups_size_t</a></li>
5a738aea
MS
491</ul></li>
492<li><a href="#STRUCTURES">Structures</a><ul class="code">
493 <li><a href="#cups_dest_s" title="Destination">cups_dest_s</a></li>
494 <li><a href="#cups_job_s" title="Job">cups_job_s</a></li>
495 <li><a href="#cups_option_s" title="Printer Options">cups_option_s</a></li>
3e7fe0ca 496 <li><a href="#cups_size_s" title="Media Size ">cups_size_s</a></li>
5a738aea 497</ul></li>
22c9029b
MS
498<li><a href="#VARIABLES">Variables</a><ul class="code">
499 <li><a href="#CF_RETURNS_RETAINED" title="Get the Apple language identifier associated with a
500locale ID.">CF_RETURNS_RETAINED</a></li>
501</ul></li>
5a738aea 502<li><a href="#ENUMERATIONS">Constants</a><ul class="code">
3e7fe0ca
MS
503 <li><a href="#cups_ptype_e" title="Printer type/capability bit
504constants">cups_ptype_e</a></li>
5a738aea 505</ul></li>
0268488e 506</ul>
ef416fc2 507<!--
68b10830 508 "$Id$"
ef416fc2 509
eac3a0a0 510 API introduction for CUPS.
ef416fc2 511
eac3a0a0 512 Copyright 2007-2011 by Apple Inc.
bc44d920 513 Copyright 1997-2006 by Easy Software Products, all rights reserved.
ef416fc2 514
515 These coded instructions, statements, and computer programs are the
bc44d920 516 property of Apple Inc. and are protected by Federal copyright
517 law. Distribution and use rights are outlined in the file "LICENSE.txt"
518 which should have been included with this file. If this file is
519 file is missing or damaged, see the license at "http://www.cups.org/".
ef416fc2 520-->
521
5a738aea
MS
522<h2 class='title'><a name='OVERVIEW'>Overview</a></h2>
523
524<p>The CUPS API provides the convenience functions needed to support
525applications, filters, printer drivers, and backends that need to interface
526with the CUPS scheduler.</p>
ef416fc2 527
568fa3fa
MS
528<h3><a name='CLIENTS_AND_SERVERS'>Clients and Servers</a></h3>
529
530<p>CUPS is based on the Internet Printing Protocol ("IPP"), which allows
531clients (applications) to communicate with a server (the scheduler) to get a
532list of printers, send print jobs, and so forth. You identify which server
533you want to communicate with using a pointer to the opaque structure
534<code>http_t</code>. All of the examples in this document use the
535<code>CUPS_HTTP_DEFAULT</code> constant, referring to the default connection
536to the scheduler. The <a href='api-httpipp.html' target='_top'>HTTP and IPP
537APIs</a> document provides more information on server connections.</p>
538
5a738aea 539<h3><a name='PRINTERS_AND_CLASSES'>Printers and Classes</a></h3>
ecdc0628 540
5a738aea
MS
541<p>Printers and classes (collections of printers) are accessed through
542the <a href="#cups_dest_t"><code>cups_dest_t</code></a> structure which
543includes the name (<code>name</code>), instance (<code>instance</code> -
568fa3fa
MS
544a way of selecting certain saved options/settings), and the options and
545attributes associated with that destination (<code>num_options</code> and
5a738aea
MS
546<code>options</code>). Destinations are created using the
547<a href="#cupsGetDests"><code>cupsGetDests</code></a> function and freed
548using the <a href='#cupsFreeDests'><code>cupsFreeDests</code></a> function.
549The <a href='#cupsGetDest'><code>cupsGetDest</code></a> function finds a
550specific destination for printing:</p>
ef416fc2 551
5a738aea
MS
552<pre class='example'>
553#include &lt;cups/cups.h&gt;
ef416fc2 554
5a738aea
MS
555<a href='#cups_dest_t'>cups_dest_t</a> *dests;
556int num_dests = <a href='#cupsGetDests'>cupsGetDests</a>(&amp;dests);
557<a href='#cups_dest_t'>cups_dest_t</a> *dest = <a href='#cupsGetDest'>cupsGetDest</a>("name", NULL, num_dests, dests);
ef416fc2 558
eac3a0a0 559/* do something with dest */
ef416fc2 560
5a738aea 561<a href='#cupsFreeDests'>cupsFreeDests</a>(num_dests, dests);
ef416fc2 562</pre>
563
5a738aea
MS
564<p>Passing <code>NULL</code> to
565<a href='#cupsGetDest'><code>cupsGetDest</code></a> for the destination name
566will return the default destination. Similarly, passing a <code>NULL</code>
567instance will return the default instance for that destination.</p>
ef416fc2 568
5a738aea
MS
569<div class='table'><table summary='Table 1: Printer Attributes' width='80%'>
570<caption>Table 1: <a name='TABLE1'>Printer Attributes</a></caption>
571<thead>
572<tr>
573 <th>Attribute Name</th>
574 <th>Description</th>
575</tr>
576</thead>
ef416fc2 577<tbody>
5a738aea
MS
578<tr>
579 <td>"auth-info-required"</td>
580 <td>The type of authentication required for printing to this
581 destination: "none", "username,password", "domain,username,password",
582 or "negotiate" (Kerberos)</td>
583</tr>
584<tr>
585 <td>"printer-info"</td>
586 <td>The human-readable description of the destination such as "My
587 Laser Printer".</td>
588</tr>
589<tr>
590 <td>"printer-is-accepting-jobs"</td>
aaf19ab0
MS
591 <td>"true" if the destination is accepting new jobs, "false" if
592 not.</td>
5a738aea
MS
593</tr>
594<tr>
595 <td>"printer-is-shared"</td>
aaf19ab0
MS
596 <td>"true" if the destination is being shared with other computers,
597 "false" if not.</td>
5a738aea
MS
598</tr>
599<tr>
600 <td>"printer-location"</td>
601 <td>The human-readable location of the destination such as "Lab 4".</td>
602</tr>
603<tr>
604 <td>"printer-make-and-model"</td>
605 <td>The human-readable make and model of the destination such as "HP
606 LaserJet 4000 Series".</td>
607</tr>
608<tr>
609 <td>"printer-state"</td>
610 <td>"3" if the destination is idle, "4" if the destination is printing
611 a job, and "5" if the destination is stopped.</td>
612</tr>
613<tr>
614 <td>"printer-state-change-time"</td>
615 <td>The UNIX time when the destination entered the current state.</td>
616</tr>
617<tr>
618 <td>"printer-state-reasons"</td>
619 <td>Additional comma-delimited state keywords for the destination
620 such as "media-tray-empty-error" and "toner-low-warning".</td>
621</tr>
622<tr>
623 <td>"printer-type"</td>
624 <td>The <a href='#cups_printer_t'><code>cups_printer_t</code></a>
625 value associated with the destination.</td>
626</tr>
627</tbody>
628</table></div>
629
630<h3><a name='OPTIONS'>Options</a></h3>
631
632<p>Options are stored in arrays of
633<a href='#cups_option_t'><code>cups_option_t</code></a> structures. Each
634option has a name (<code>name</code>) and value (<code>value</code>)
635associated with it. The <a href='#cups_dest_t'><code>cups_dest_t</code></a>
636<code>num_options</code> and <code>options</code> members contain the
637default options for a particular destination, along with several informational
638attributes about the destination as shown in <a href='#TABLE1'>Table 1</a>.
639The <a href='#cupsGetOption'><code>cupsGetOption</code></a> function gets
640the value for the named option. For example, the following code lists the
641available destinations and their human-readable descriptions:</p>
642
643<pre class='example'>
644#include &lt;cups/cups.h&gt;
645
646<a href='#cups_dest_t'>cups_dest_t</a> *dests;
647int num_dests = <a href='#cupsGetDests'>cupsGetDests</a>(&amp;dests);
648<a href='#cups_dest_t'>cups_dest_t</a> *dest;
649int i;
650const char *value;
651
652for (i = num_dests, dest = dests; i > 0; i --, dest ++)
653 if (dest->instance == NULL)
654 {
655 value = <a href='#cupsGetOption'>cupsGetOption</a>("printer-info", dest->num_options, dest->options);
656 printf("%s (%s)\n", dest->name, value ? value : "no description");
657 }
658
659<a href='#cupsFreeDests'>cupsFreeDests</a>(num_dests, dests);
660</pre>
661
662<p>You can create your own option arrays using the
663<a href='#cupsAddOption'><code>cupsAddOption</code></a> function, which
664adds a single named option to an array:</p>
665
666<pre class='example'>
667#include &lt;cups/cups.h&gt;
668
669int num_options = 0;
670<a href='#cups_option_t'>cups_option_t</a> *options = NULL;
671
672/* The returned num_options value is updated as needed */
673num_options = <a href='#cupsAddOption'>cupsAddOption</a>("first", "value", num_options, &amp;options);
674
675/* This adds a second option value */
676num_options = <a href='#cupsAddOption'>cupsAddOption</a>("second", "value", num_options, &amp;options);
677
678/* This replaces the first option we added */
679num_options = <a href='#cupsAddOption'>cupsAddOption</a>("first", "new value", num_options, &amp;options);
680</pre>
681
682<p>Use a <code>for</code> loop to copy the options from a destination:</p>
683
684<pre class='example'>
685#include &lt;cups/cups.h&gt;
686
687int i;
688int num_options = 0;
689<a href='#cups_option_t'>cups_option_t</a> *options = NULL;
690<a href='#cups_dest_t'>cups_dest_t</a> *dest;
691
692for (i = 0; i < dest->num_options; i ++)
568fa3fa
MS
693 num_options = <a href='#cupsAddOption'>cupsAddOption</a>(dest->options[i].name, dest->options[i].value,
694 num_options, &amp;options);
5a738aea
MS
695</pre>
696
697<p>Use the <a href='#cupsFreeOptions'><code>cupsFreeOptions</code></a>
698function to free the options array when you are done using it:</p>
699
700<pre class='example'>
701<a href='#cupsFreeOptions'>cupsFreeOptions</a>(num_options, options);
702</pre>
703
704<h3><a name='PRINT_JOBS'>Print Jobs</a></h3>
705
706<p>Print jobs are identified by a locally-unique job ID number from 1 to
7072<sup>31</sup>-1 and have options and one or more files for printing to a
708single destination. The <a href='#cupsPrintFile'><code>cupsPrintFile</code></a>
709function creates a new job with one file. The following code prints the CUPS
710test page file:</p>
711
712<pre class='example'>
713#include &lt;cups/cups.h&gt;
714
715<a href='#cups_dest_t'>cups_dest_t</a> *dest;
716int num_options;
717<a href='#cups_option_t'>cups_option_t</a> *options;
718int job_id;
719
720/* Print a single file */
568fa3fa
MS
721job_id = <a href='#cupsPrintFile'>cupsPrintFile</a>(dest->name, "/usr/share/cups/data/testprint.ps",
722 "Test Print", num_options, options);
5a738aea
MS
723</pre>
724
725<p>The <a href='#cupsPrintFiles'><code>cupsPrintFiles</code></a> function
726creates a job with multiple files. The files are provided in a
727<code>char *</code> array:</p>
728
729<pre class='example'>
730#include &lt;cups/cups.h&gt;
731
732<a href='#cups_dest_t'>cups_dest_t</a> *dest;
733int num_options;
734<a href='#cups_option_t'>cups_option_t</a> *options;
735int job_id;
736char *files[3] = { "file1.pdf", "file2.pdf", "file3.pdf" };
737
738/* Print three files */
739job_id = <a href='#cupsPrintFiles'>cupsPrintFiles</a>(dest->name, 3, files, "Test Print", num_options, options);
740</pre>
741
742<p>Finally, the <a href='#cupsCreateJob'><code>cupsCreateJob</code></a>
743function creates a new job with no files in it. Files are added using the
744<a href='#cupsStartDocument'><code>cupsStartDocument</code></a>,
745<a href='api-httpipp.html#cupsWriteRequestData'><code>cupsWriteRequestData</code></a>,
746and <a href='#cupsFinishDocument'><code>cupsFinishDocument</code></a> functions.
747The following example creates a job with 10 text files for printing:</p>
748
749<pre class='example'>
750#include &lt;cups/cups.h&gt;
751
752<a href='#cups_dest_t'>cups_dest_t</a> *dest;
753int num_options;
754<a href='#cups_option_t'>cups_option_t</a> *options;
755int job_id;
756int i;
757char buffer[1024];
758
759/* Create the job */
568fa3fa
MS
760job_id = <a href='#cupsCreateJob'>cupsCreateJob</a>(CUPS_HTTP_DEFAULT, dest->name, "10 Text Files",
761 num_options, options);
5a738aea
MS
762
763/* If the job is created, add 10 files */
764if (job_id > 0)
765{
766 for (i = 1; i &lt;= 10; i ++)
767 {
768 snprintf(buffer, sizeof(buffer), "file%d.txt", i);
769
568fa3fa
MS
770 <a href='#cupsStartDocument'>cupsStartDocument</a>(CUPS_HTTP_DEFAULT, dest->name, job_id, buffer,
771 CUPS_FORMAT_TEXT, i == 10);
5a738aea
MS
772
773 snprintf(buffer, sizeof(buffer),
774 "File %d\n"
775 "\n"
776 "One fish,\n"
777 "Two fish,\n
778 "Red fish,\n
779 "Blue fish\n", i);
780
781 /* cupsWriteRequestData can be called as many times as needed */
782 <a href='#cupsWriteRequestData'>cupsWriteRequestData</a>(CUPS_HTTP_DEFAULT, buffer, strlen(buffer));
783
784 <a href='#cupsFinishDocument'>cupsFinishDocument</a>(CUPS_HTTP_DEFAULT, dest->name);
785 }
786}
787</pre>
788
789<p>Once you have created a job, you can monitor its status using the
790<a href='#cupsGetJobs'><code>cupsGetJobs</code></a> function, which returns
791an array of <a href='#cups_job_t'><code>cups_job_t</code></a> structures.
792Each contains the job ID (<code>id</code>), destination name
793(<code>dest</code>), title (<code>title</code>), and other information
794associated with the job. The job array is freed using the
795<a href='#cupsFreeJobs'><code>cupsFreeJobs</code></a> function. The following
796example monitors a specific job ID, showing the current job state once every
7975 seconds until the job is completed:</p>
798
799<pre class='example'>
800#include &lt;cups/cups.h&gt;
801
802<a href='#cups_dest_t'>cups_dest_t</a> *dest;
803int job_id;
804int num_jobs;
805<a href='#cups_job_t'>cups_job_t</a> *jobs;
806int i;
807ipp_jstate_t job_state = IPP_JOB_PENDING;
808
809while (job_state &lt; IPP_JOB_STOPPED)
810{
811 /* Get my jobs (1) with any state (-1) */
812 num_jobs = <a href='#cupsGetJobs'>cupsGetJobs</a>(&amp;jobs, dest->name, 1, -1);
813
814 /* Loop to find my job */
815 job_state = IPP_JOB_COMPLETED;
816
817 for (i = 0; i &lt; num_jobs; i ++)
818 if (jobs[i].id == job_id)
819 {
820 job_state = jobs[i].state;
821 break;
822 }
823
824 /* Free the job array */
825 <a href='#cupsFreeJobs'>cupsFreeJobs</a>(num_jobs, jobs);
826
827 /* Show the current state */
828 switch (job_state)
829 {
830 case IPP_JOB_PENDING :
831 printf("Job %d is pending.\n", job_id);
832 break;
833 case IPP_JOB_HELD :
834 printf("Job %d is held.\n", job_id);
835 break;
836 case IPP_JOB_PROCESSING :
837 printf("Job %d is processing.\n", job_id);
838 break;
839 case IPP_JOB_STOPPED :
840 printf("Job %d is stopped.\n", job_id);
841 break;
842 case IPP_JOB_CANCELED :
843 printf("Job %d is canceled.\n", job_id);
844 break;
845 case IPP_JOB_ABORTED :
846 printf("Job %d is aborted.\n", job_id);
847 break;
848 case IPP_JOB_COMPLETED :
849 printf("Job %d is completed.\n", job_id);
850 break;
851 }
852
853 /* Sleep if the job is not finished */
854 if (job_state &lt; IPP_JOB_STOPPED)
855 sleep(5);
856}
857</pre>
858
859<p>To cancel a job, use the
860<a href='#cupsCancelJob'><code>cupsCancelJob</code></a> function with the
861job ID:</p>
862
568fa3fa 863<pre class='example'>
5a738aea
MS
864#include &lt;cups/cups.h&gt;
865
866<a href='#cups_dest_t'>cups_dest_t</a> *dest;
867int job_id;
868
869<a href='#cupsCancelJob'>cupsCancelJob</a>(dest->name, job_id);
870</pre>
871
872<h3><a name='ERROR_HANDLING'>Error Handling</a></h3>
873
874<p>If any of the CUPS API printing functions returns an error, the reason for
875that error can be found by calling the
876<a href='#cupsLastError'><code>cupsLastError</code></a> and
877<a href='#cupsLastErrorString'><code>cupsLastErrorString</code></a> functions.
878<a href='#cupsLastError'><code>cupsLastError</code></a> returns the last IPP
879error code
880(<a href='api-httpipp.html#ipp_status_t'><code>ipp_status_t</code></a>)
881that was encountered, while
882<a href='#cupsLastErrorString'><code>cupsLastErrorString</code></a> returns
883a (localized) human-readable string that can be shown to the user. For example,
884if any of the job creation functions returns a job ID of 0, you can use
885<a href='#cupsLastErrorString'><code>cupsLastErrorString</code></a> to show
886the reason why the job could not be created:</p>
887
888<pre class='example'>
889#include &lt;cups/cups.h&gt;
890
891int job_id;
892
893if (job_id == 0)
894 puts(cupsLastErrorString());
895</pre>
896
897<h3><a name='PASSWORDS_AND_AUTHENTICATION'>Passwords and Authentication</a></h3>
898
899<p>CUPS supports authentication of any request, including submission of print
900jobs. The default mechanism for getting the username and password is to use the
901login user and a password from the console.</p>
902
903<p>To support other types of applications, in particular Graphical User
904Interfaces ("GUIs"), the CUPS API provides functions to set the default
905username and to register a callback function that returns a password string.</p>
906
907<p>The <a href="#cupsSetPasswordCB"><code>cupsSetPasswordCB</code></a>
908function is used to set a password callback in your program. Only one
909function can be used at any time.</p>
910
911<p>The <a href="#cupsSetUser"><code>cupsSetUser</code></a> function sets the
912current username for authentication. This function can be called by your
913password callback function to change the current username as needed.</p>
914
915<p>The following example shows a simple password callback that gets a
916username and password from the user:</p>
917
918<pre class='example'>
919#include &lt;cups/cups.h&gt;
920
921const char *
922my_password_cb(const char *prompt)
923{
924 char user[65];
925
926
927 puts(prompt);
928
929 /* Get a username from the user */
930 printf("Username: ");
931 if (fgets(user, sizeof(user), stdin) == NULL)
932 return (NULL);
933
934 /* Strip the newline from the string and set the user */
935 user[strlen(user) - 1] = '\0';
936
937 <a href='#cupsSetUser'>cupsSetUser</a>(user);
938
939 /* Use getpass() to ask for the password... */
940 return (getpass("Password: "));
941}
942
943<a href='#cupsSetPasswordCB'>cupsSetPasswordCB</a>(my_password_cb);
944</pre>
945
946<p>Similarly, a GUI could display the prompt string in a window with input
947fields for the username and password. The username should default to the
948string returned by the <a href="#cupsUser"><code>cupsUser</code></a>
949function.</p>
950<h2 class="title"><a name="FUNCTIONS">Functions</a></h2>
82f97232
MS
951<h3 class="function"><a name="appleGetPaperSize">appleGetPaperSize</a></h3>
952<p class="description">Get the default paper size.</p>
953<p class="code">
954char *appleGetPaperSize (<br>
955&nbsp;&nbsp;&nbsp;&nbsp;char *name,<br>
956&nbsp;&nbsp;&nbsp;&nbsp;int namesize<br>
957);</p>
958<h4 class="parameters">Parameters</h4>
959<dl>
960<dt>name</dt>
961<dd class="description">Paper size name buffer</dd>
962<dt>namesize</dt>
963<dd class="description">Size of buffer</dd>
964</dl>
965<h4 class="returnvalue">Return Value</h4>
966<p class="description">Default paper size</p>
5a738aea
MS
967<h3 class="function"><a name="cupsAddDest">cupsAddDest</a></h3>
968<p class="description">Add a destination to the list of destinations.</p>
969<p class="code">
970int cupsAddDest (<br>
971&nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
972&nbsp;&nbsp;&nbsp;&nbsp;const char *instance,<br>
973&nbsp;&nbsp;&nbsp;&nbsp;int num_dests,<br>
974&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_t">cups_dest_t</a> **dests<br>
975);</p>
976<h4 class="parameters">Parameters</h4>
977<dl>
978<dt>name</dt>
979<dd class="description">Destination name</dd>
980<dt>instance</dt>
981<dd class="description">Instance name or <code>NULL</code> for none/primary</dd>
982<dt>num_dests</dt>
983<dd class="description">Number of destinations</dd>
984<dt>dests</dt>
985<dd class="description">Destinations</dd>
986</dl>
987<h4 class="returnvalue">Return Value</h4>
988<p class="description">New number of destinations</p>
989<h4 class="discussion">Discussion</h4>
990<p class="discussion">This function cannot be used to add a new class or printer queue,
2abf387c 991it only adds a new container of saved options for the named
5a738aea
MS
992destination or instance.<br>
993<br>
994If the named destination already exists, the destination list is
2abf387c 995returned unchanged. Adding a new instance of a destination creates
5a738aea
MS
996a copy of that destination's options.<br>
997<br>
998Use the <a href="#cupsSaveDests"><code>cupsSaveDests</code></a> function to save the updated list of
999destinations to the user's lpoptions file.</p>
1000<h3 class="function"><a name="cupsAddOption">cupsAddOption</a></h3>
1001<p class="description">Add an option to an option array.</p>
1002<p class="code">
1003int cupsAddOption (<br>
1004&nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
1005&nbsp;&nbsp;&nbsp;&nbsp;const char *value,<br>
1006&nbsp;&nbsp;&nbsp;&nbsp;int num_options,<br>
1007&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_option_t">cups_option_t</a> **options<br>
1008);</p>
1009<h4 class="parameters">Parameters</h4>
1010<dl>
1011<dt>name</dt>
1012<dd class="description">Name of option</dd>
1013<dt>value</dt>
1014<dd class="description">Value of option</dd>
1015<dt>num_options</dt>
1016<dd class="description">Number of options</dd>
1017<dt>options</dt>
1018<dd class="description">Pointer to options</dd>
1019</dl>
1020<h4 class="returnvalue">Return Value</h4>
1021<p class="description">Number of options</p>
1022<h4 class="discussion">Discussion</h4>
1023<p class="discussion">New option arrays can be initialized simply by passing 0 for the
1024&quot;num_options&quot; parameter.</p>
426c6a59
MS
1025<h3 class="function"><span class="info">&nbsp;CUPS 1.2/Mac OS X 10.5&nbsp;</span><a name="cupsAdminCreateWindowsPPD">cupsAdminCreateWindowsPPD</a></h3>
1026<p class="description">Create the Windows PPD file for a printer.</p>
1027<p class="code">
1028char *cupsAdminCreateWindowsPPD (<br>
1029&nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1030&nbsp;&nbsp;&nbsp;&nbsp;const char *dest,<br>
1031&nbsp;&nbsp;&nbsp;&nbsp;char *buffer,<br>
1032&nbsp;&nbsp;&nbsp;&nbsp;int bufsize<br>
1033);</p>
1034<h4 class="parameters">Parameters</h4>
1035<dl>
1036<dt>http</dt>
1037<dd class="description">Connection to server or <code>CUPS_HTTP_DEFAULT</code></dd>
1038<dt>dest</dt>
1039<dd class="description">Printer or class</dd>
1040<dt>buffer</dt>
1041<dd class="description">Filename buffer</dd>
1042<dt>bufsize</dt>
1043<dd class="description">Size of filename buffer</dd>
1044</dl>
1045<h4 class="returnvalue">Return Value</h4>
1046<p class="description">PPD file or NULL</p>
1047<h3 class="function"><span class="info">&nbsp;CUPS 1.2/Mac OS X 10.5&nbsp;</span><a name="cupsAdminExportSamba">cupsAdminExportSamba</a></h3>
1048<p class="description">Export a printer to Samba.</p>
1049<p class="code">
1050int cupsAdminExportSamba (<br>
1051&nbsp;&nbsp;&nbsp;&nbsp;const char *dest,<br>
1052&nbsp;&nbsp;&nbsp;&nbsp;const char *ppd,<br>
1053&nbsp;&nbsp;&nbsp;&nbsp;const char *samba_server,<br>
1054&nbsp;&nbsp;&nbsp;&nbsp;const char *samba_user,<br>
1055&nbsp;&nbsp;&nbsp;&nbsp;const char *samba_password,<br>
1056&nbsp;&nbsp;&nbsp;&nbsp;FILE *logfile<br>
1057);</p>
1058<h4 class="parameters">Parameters</h4>
1059<dl>
1060<dt>dest</dt>
1061<dd class="description">Destination to export</dd>
1062<dt>ppd</dt>
1063<dd class="description">PPD file</dd>
1064<dt>samba_server</dt>
1065<dd class="description">Samba server</dd>
1066<dt>samba_user</dt>
1067<dd class="description">Samba username</dd>
1068<dt>samba_password</dt>
1069<dd class="description">Samba password</dd>
1070<dt>logfile</dt>
1071<dd class="description">Log file, if any</dd>
1072</dl>
1073<h4 class="returnvalue">Return Value</h4>
1074<p class="description">1 on success, 0 on failure</p>
1075<h3 class="function"><span class="info">&nbsp;CUPS 1.3/Mac OS X 10.5&nbsp;</span><a name="cupsAdminGetServerSettings">cupsAdminGetServerSettings</a></h3>
1076<p class="description">Get settings from the server.</p>
1077<p class="code">
1078int cupsAdminGetServerSettings (<br>
1079&nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1080&nbsp;&nbsp;&nbsp;&nbsp;int *num_settings,<br>
1081&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_option_t">cups_option_t</a> **settings<br>
1082);</p>
1083<h4 class="parameters">Parameters</h4>
1084<dl>
1085<dt>http</dt>
1086<dd class="description">Connection to server or <code>CUPS_HTTP_DEFAULT</code></dd>
1087<dt>num_settings</dt>
1088<dd class="description">Number of settings</dd>
1089<dt>settings</dt>
1090<dd class="description">Settings</dd>
1091</dl>
1092<h4 class="returnvalue">Return Value</h4>
1093<p class="description">1 on success, 0 on failure</p>
1094<h4 class="discussion">Discussion</h4>
1095<p class="discussion">The returned settings should be freed with cupsFreeOptions() when
1096you are done with them.
1097
1098</p>
1099<h3 class="function"><span class="info">&nbsp;CUPS 1.3/Mac OS X 10.5&nbsp;</span><a name="cupsAdminSetServerSettings">cupsAdminSetServerSettings</a></h3>
1100<p class="description">Set settings on the server.</p>
1101<p class="code">
1102int cupsAdminSetServerSettings (<br>
1103&nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1104&nbsp;&nbsp;&nbsp;&nbsp;int num_settings,<br>
1105&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_option_t">cups_option_t</a> *settings<br>
1106);</p>
1107<h4 class="parameters">Parameters</h4>
1108<dl>
1109<dt>http</dt>
1110<dd class="description">Connection to server or <code>CUPS_HTTP_DEFAULT</code></dd>
1111<dt>num_settings</dt>
1112<dd class="description">Number of settings</dd>
1113<dt>settings</dt>
1114<dd class="description">Settings</dd>
1115</dl>
1116<h4 class="returnvalue">Return Value</h4>
1117<p class="description">1 on success, 0 on failure</p>
5a738aea
MS
1118<h3 class="function"><a name="cupsCancelJob">cupsCancelJob</a></h3>
1119<p class="description">Cancel a print job on the default server.</p>
1120<p class="code">
1121int cupsCancelJob (<br>
1122&nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
1123&nbsp;&nbsp;&nbsp;&nbsp;int job_id<br>
1124);</p>
1125<h4 class="parameters">Parameters</h4>
1126<dl>
1127<dt>name</dt>
1128<dd class="description">Name of printer or class</dd>
1129<dt>job_id</dt>
568fa3fa 1130<dd class="description">Job ID, <code>CUPS_JOBID_CURRENT</code> for the current job, or <code>CUPS_JOBID_ALL</code> for all jobs</dd>
5a738aea
MS
1131</dl>
1132<h4 class="returnvalue">Return Value</h4>
1133<p class="description">1 on success, 0 on failure</p>
1134<h4 class="discussion">Discussion</h4>
1135<p class="discussion">Pass <code>CUPS_JOBID_ALL</code> to cancel all jobs or <code>CUPS_JOBID_CURRENT</code>
1136to cancel the current job on the named destination.<br>
1137<br>
1138Use the <a href="#cupsLastError"><code>cupsLastError</code></a> and <a href="#cupsLastErrorString"><code>cupsLastErrorString</code></a> functions to get
1139the cause of any failure.</p>
178cb736 1140<h3 class="function"><span class="info">&nbsp;CUPS 1.4/Mac OS X 10.6&nbsp;</span><a name="cupsCancelJob2">cupsCancelJob2</a></h3>
5a738aea
MS
1141<p class="description">Cancel or purge a print job.</p>
1142<p class="code">
1143ipp_status_t cupsCancelJob2 (<br>
1144&nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1145&nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
1146&nbsp;&nbsp;&nbsp;&nbsp;int job_id,<br>
1147&nbsp;&nbsp;&nbsp;&nbsp;int purge<br>
1148);</p>
1149<h4 class="parameters">Parameters</h4>
1150<dl>
1151<dt>http</dt>
568fa3fa 1152<dd class="description">Connection to server or <code>CUPS_HTTP_DEFAULT</code></dd>
5a738aea
MS
1153<dt>name</dt>
1154<dd class="description">Name of printer or class</dd>
1155<dt>job_id</dt>
568fa3fa 1156<dd class="description">Job ID, <code>CUPS_JOBID_CURRENT</code> for the current job, or <code>CUPS_JOBID_ALL</code> for all jobs</dd>
5a738aea
MS
1157<dt>purge</dt>
1158<dd class="description">1 to purge, 0 to cancel</dd>
1159</dl>
1160<h4 class="returnvalue">Return Value</h4>
1161<p class="description">IPP status</p>
1162<h4 class="discussion">Discussion</h4>
1163<p class="discussion">Canceled jobs remain in the job history while purged jobs are removed
1164from the job history.<br>
1165<br>
1166Pass <code>CUPS_JOBID_ALL</code> to cancel all jobs or <code>CUPS_JOBID_CURRENT</code>
1167to cancel the current job on the named destination.<br>
1168<br>
1169Use the <a href="#cupsLastError"><code>cupsLastError</code></a> and <a href="#cupsLastErrorString"><code>cupsLastErrorString</code></a> functions to get
bc44d920 1170the cause of any failure.
5a738aea 1171
3e7fe0ca
MS
1172</p>
1173<h3 class="function"><span class="info">&nbsp;CUPS 1.6&nbsp;</span><a name="cupsConnectDest">cupsConnectDest</a></h3>
1174<p class="description">Connect to the server for a destination.</p>
1175<p class="code">
1176http_t *cupsConnectDest (<br>
1177&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_t">cups_dest_t</a> *dest,<br>
1178&nbsp;&nbsp;&nbsp;&nbsp;unsigned flags,<br>
1179&nbsp;&nbsp;&nbsp;&nbsp;int msec,<br>
1180&nbsp;&nbsp;&nbsp;&nbsp;int *cancel,<br>
1181&nbsp;&nbsp;&nbsp;&nbsp;char *resource,<br>
1182&nbsp;&nbsp;&nbsp;&nbsp;size_t resourcesize,<br>
1183&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_cb_t">cups_dest_cb_t</a> cb,<br>
1184&nbsp;&nbsp;&nbsp;&nbsp;void *user_data<br>
1185);</p>
1186<h4 class="parameters">Parameters</h4>
1187<dl>
1188<dt>dest</dt>
1189<dd class="description">Destination</dd>
1190<dt>flags</dt>
1191<dd class="description">Connection flags</dd>
1192<dt>msec</dt>
1193<dd class="description">Timeout in milliseconds</dd>
1194<dt>cancel</dt>
1195<dd class="description">Pointer to &quot;cancel&quot; variable</dd>
1196<dt>resource</dt>
1197<dd class="description">Resource buffer</dd>
1198<dt>resourcesize</dt>
1199<dd class="description">Size of resource buffer</dd>
1200<dt>cb</dt>
1201<dd class="description">Callback function</dd>
1202<dt>user_data</dt>
1203<dd class="description">User data pointer</dd>
1204</dl>
1205<h4 class="returnvalue">Return Value</h4>
1206<p class="description">Connection to server or <code>NULL</code></p>
1207<h4 class="discussion">Discussion</h4>
1208<p class="discussion">Connect to the destination, returning a new http_t connection object and
1209optionally the resource path to use for the destination. These calls will
1210block until a connection is made, the timeout expires, the integer pointed
1211to by &quot;cancel&quot; is non-zero, or the callback function (or block) returns 0,
1212The caller is responsible for calling httpClose() on the returned object.
1213
1214</p>
1215<h3 class="function"><span class="info">&nbsp;CUPS 1.6&nbsp;</span><a name="cupsConnectDestBlock">cupsConnectDestBlock</a></h3>
1216<p class="description">Connect to the server for a destination.</p>
1217<p class="code">
1218http_t *cupsConnectDestBlock (<br>
1219&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_t">cups_dest_t</a> *dest,<br>
1220&nbsp;&nbsp;&nbsp;&nbsp;unsigned flags,<br>
1221&nbsp;&nbsp;&nbsp;&nbsp;int msec,<br>
1222&nbsp;&nbsp;&nbsp;&nbsp;int *cancel,<br>
1223&nbsp;&nbsp;&nbsp;&nbsp;char *resource,<br>
1224&nbsp;&nbsp;&nbsp;&nbsp;size_t resourcesize,<br>
1225&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_block_t">cups_dest_block_t</a> block<br>
1226);</p>
1227<h4 class="parameters">Parameters</h4>
1228<dl>
1229<dt>dest</dt>
1230<dd class="description">Destination</dd>
1231<dt>flags</dt>
1232<dd class="description">Connection flags</dd>
1233<dt>msec</dt>
1234<dd class="description">Timeout in milliseconds</dd>
1235<dt>cancel</dt>
1236<dd class="description">Pointer to &quot;cancel&quot; variable</dd>
1237<dt>resource</dt>
1238<dd class="description">Resource buffer</dd>
1239<dt>resourcesize</dt>
1240<dd class="description">Size of resource buffer</dd>
1241<dt>block</dt>
1242<dd class="description">Callback block</dd>
1243</dl>
1244<h4 class="returnvalue">Return Value</h4>
1245<p class="description">Connection to server or <code>NULL</code></p>
1246<h4 class="discussion">Discussion</h4>
1247<p class="discussion">Connect to the destination, returning a new http_t connection object and
1248optionally the resource path to use for the destination. These calls will
1249block until a connection is made, the timeout expires, the integer pointed
1250to by &quot;cancel&quot; is non-zero, or the callback function (or block) returns 0,
1251The caller is responsible for calling httpClose() on the returned object.
1252
1253</p>
1254<h3 class="function"><a name="cupsCopyDest">cupsCopyDest</a></h3>
1255<p class="description">Callback block</p>
1256<p class="code">
1257int cupsCopyDest (<br>
1258&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_t">cups_dest_t</a> *dest,<br>
1259&nbsp;&nbsp;&nbsp;&nbsp;int num_dests,<br>
1260&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_t">cups_dest_t</a> **dests<br>
1261);</p>
1262<h4 class="parameters">Parameters</h4>
1263<dl>
1264<dt>dest</dt>
1265<dt>num_dests</dt>
1266<dt>dests</dt>
1267</dl>
1268<h4 class="returnvalue">Return Value</h4>
1269<p class="description">Copy a destination.</p>
1270<p class="discussion">Make a copy of the destination to an array of destinations (or just a single
1271copy) - for use with the cupsEnumDests* functions. The caller is responsible
1272for calling cupsFreeDests() on the returned object(s).
1273
5a738aea 1274</p>
178cb736 1275<h3 class="function"><span class="info">&nbsp;CUPS 1.4/Mac OS X 10.6&nbsp;</span><a name="cupsCreateJob">cupsCreateJob</a></h3>
568fa3fa 1276<p class="description">Create an empty job for streaming.</p>
5a738aea
MS
1277<p class="code">
1278int cupsCreateJob (<br>
1279&nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1280&nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
1281&nbsp;&nbsp;&nbsp;&nbsp;const char *title,<br>
1282&nbsp;&nbsp;&nbsp;&nbsp;int num_options,<br>
1283&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_option_t">cups_option_t</a> *options<br>
1284);</p>
1285<h4 class="parameters">Parameters</h4>
1286<dl>
1287<dt>http</dt>
568fa3fa 1288<dd class="description">Connection to server or <code>CUPS_HTTP_DEFAULT</code></dd>
5a738aea 1289<dt>name</dt>
568fa3fa 1290<dd class="description">Destination name</dd>
5a738aea
MS
1291<dt>title</dt>
1292<dd class="description">Title of job</dd>
1293<dt>num_options</dt>
1294<dd class="description">Number of options</dd>
1295<dt>options</dt>
1296<dd class="description">Options</dd>
1297</dl>
1298<h4 class="returnvalue">Return Value</h4>
1299<p class="description">Job ID or 0 on error</p>
1300<h4 class="discussion">Discussion</h4>
568fa3fa
MS
1301<p class="discussion">Use this function when you want to stream print data using the
1302<a href="#cupsStartDocument"><code>cupsStartDocument</code></a>, <a href="#cupsWriteRequestData"><code>cupsWriteRequestData</code></a>, and
1303<a href="#cupsFinishDocument"><code>cupsFinishDocument</code></a> functions. If you have one or more files to
1304print, use the <a href="#cupsPrintFile2"><code>cupsPrintFile2</code></a> or <a href="#cupsPrintFiles2"><code>cupsPrintFiles2</code></a> function
1305instead.
5a738aea
MS
1306
1307</p>
1308<h3 class="function"><a name="cupsEncryption">cupsEncryption</a></h3>
aaf19ab0 1309<p class="description">Get the current encryption settings.</p>
5a738aea
MS
1310<p class="code">
1311http_encryption_t cupsEncryption (void);</p>
1312<h4 class="returnvalue">Return Value</h4>
1313<p class="description">Encryption settings</p>
1314<h4 class="discussion">Discussion</h4>
1315<p class="discussion">The default encryption setting comes from the CUPS_ENCRYPTION
568fa3fa 1316environment variable, then the ~/.cups/client.conf file, and finally the
ef416fc2 1317/etc/cups/client.conf file. If not set, the default is
aaf19ab0
MS
1318<code>HTTP_ENCRYPT_IF_REQUESTED</code>.<br>
1319<br>
1320Note: The current encryption setting is tracked separately for each thread
1321in a program. Multi-threaded programs that override the setting via the
1322<a href="#cupsSetEncryption"><code>cupsSetEncryption</code></a> function need to do so in each thread for the same
1323setting to be used.</p>
3e7fe0ca
MS
1324<h3 class="function"><span class="info">&nbsp;CUPS 1.6&nbsp;</span><a name="cupsEnumDests">cupsEnumDests</a></h3>
1325<p class="description">Enumerate available destinations with a callback function.</p>
1326<p class="code">
1327int cupsEnumDests (<br>
1328&nbsp;&nbsp;&nbsp;&nbsp;unsigned flags,<br>
1329&nbsp;&nbsp;&nbsp;&nbsp;int msec,<br>
1330&nbsp;&nbsp;&nbsp;&nbsp;int *cancel,<br>
1331&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_ptype_t">cups_ptype_t</a> type,<br>
1332&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_ptype_t">cups_ptype_t</a> mask,<br>
1333&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_cb_t">cups_dest_cb_t</a> cb,<br>
1334&nbsp;&nbsp;&nbsp;&nbsp;void *user_data<br>
1335);</p>
1336<h4 class="parameters">Parameters</h4>
1337<dl>
1338<dt>flags</dt>
1339<dd class="description">Enumeration flags</dd>
1340<dt>msec</dt>
1341<dd class="description">Timeout in milliseconds,
1342-1 for indefinite</dd>
1343<dt>cancel</dt>
1344<dd class="description">Pointer to &quot;cancel&quot; variable</dd>
1345<dt>type</dt>
1346<dd class="description">Printer type bits</dd>
1347<dt>mask</dt>
1348<dd class="description">Mask for printer type bits</dd>
1349<dt>cb</dt>
1350<dd class="description">Callback function</dd>
1351<dt>user_data</dt>
1352<dd class="description">User data</dd>
1353</dl>
1354<h4 class="returnvalue">Return Value</h4>
1355<p class="description">1 on success, 0 on failure</p>
1356<h4 class="discussion">Discussion</h4>
1357<p class="discussion">Destinations are enumerated from one or more sources. The callback function
1358receives the <code>user_data</code> pointer, destination name, instance, number of
1359options, and options which can be used as input to the <a href="#cupsAddDest"><code>cupsAddDest</code></a>
1360function. The function must return 1 to continue enumeration or 0 to stop.<br>
1361<br>
1362Enumeration happens on the current thread and does not return until all
1363destinations have been enumerated or the callback function returns 0.
1364
1365</p>
1366<h3 class="function"><span class="info">&nbsp;CUPS 1.6&nbsp;</span><a name="cupsEnumDestsBlock">cupsEnumDestsBlock</a></h3>
1367<p class="description">Enumerate available destinations with a block.</p>
1368<p class="code">
1369int cupsEnumDestsBlock (<br>
1370&nbsp;&nbsp;&nbsp;&nbsp;unsigned flags,<br>
1371&nbsp;&nbsp;&nbsp;&nbsp;int timeout,<br>
1372&nbsp;&nbsp;&nbsp;&nbsp;int *cancel,<br>
1373&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_ptype_t">cups_ptype_t</a> type,<br>
1374&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_ptype_t">cups_ptype_t</a> mask,<br>
1375&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_block_t">cups_dest_block_t</a> block<br>
1376);</p>
1377<h4 class="parameters">Parameters</h4>
1378<dl>
1379<dt>flags</dt>
1380<dd class="description">Enumeration flags</dd>
1381<dt>timeout</dt>
1382<dd class="description">Timeout in milliseconds, 0 for indefinite</dd>
1383<dt>cancel</dt>
1384<dd class="description">Pointer to &quot;cancel&quot; variable</dd>
1385<dt>type</dt>
1386<dd class="description">Printer type bits</dd>
1387<dt>mask</dt>
1388<dd class="description">Mask for printer type bits</dd>
1389<dt>block</dt>
1390<dd class="description">Block</dd>
1391</dl>
1392<h4 class="returnvalue">Return Value</h4>
1393<p class="description">1 on success, 0 on failure</p>
1394<h4 class="discussion">Discussion</h4>
1395<p class="discussion">Destinations are enumerated from one or more sources. The block receives the
1396destination name, instance, number of options, and options which can be used
1397as input to the <a href="#cupsAddDest"><code>cupsAddDest</code></a> function. The block must return 1 to
1398continue enumeration or 0 to stop.<br>
1399<br>
1400Enumeration happens on the current thread and does not return until all
1401destinations have been enumerated or the block returns 0.
1402
1403</p>
178cb736 1404<h3 class="function"><span class="info">&nbsp;CUPS 1.4/Mac OS X 10.6&nbsp;</span><a name="cupsFinishDocument">cupsFinishDocument</a></h3>
5a738aea
MS
1405<p class="description">Finish sending a document.</p>
1406<p class="code">
1407ipp_status_t cupsFinishDocument (<br>
1408&nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1409&nbsp;&nbsp;&nbsp;&nbsp;const char *name<br>
1410);</p>
1411<h4 class="parameters">Parameters</h4>
1412<dl>
1413<dt>http</dt>
568fa3fa 1414<dd class="description">Connection to server or <code>CUPS_HTTP_DEFAULT</code></dd>
5a738aea 1415<dt>name</dt>
568fa3fa 1416<dd class="description">Destination name</dd>
5a738aea
MS
1417</dl>
1418<h4 class="returnvalue">Return Value</h4>
1419<p class="description">Status of document submission</p>
1420<h4 class="discussion">Discussion</h4>
1421<p class="discussion">The document must have been started using <a href="#cupsStartDocument"><code>cupsStartDocument</code></a>.
1422
1423</p>
1424<h3 class="function"><a name="cupsFreeDests">cupsFreeDests</a></h3>
1425<p class="description">Free the memory used by the list of destinations.</p>
1426<p class="code">
1427void cupsFreeDests (<br>
1428&nbsp;&nbsp;&nbsp;&nbsp;int num_dests,<br>
1429&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_t">cups_dest_t</a> *dests<br>
1430);</p>
1431<h4 class="parameters">Parameters</h4>
1432<dl>
1433<dt>num_dests</dt>
1434<dd class="description">Number of destinations</dd>
1435<dt>dests</dt>
1436<dd class="description">Destinations</dd>
1437</dl>
1438<h3 class="function"><a name="cupsFreeJobs">cupsFreeJobs</a></h3>
1439<p class="description">Free memory used by job data.</p>
1440<p class="code">
1441void cupsFreeJobs (<br>
1442&nbsp;&nbsp;&nbsp;&nbsp;int num_jobs,<br>
1443&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_job_t">cups_job_t</a> *jobs<br>
1444);</p>
1445<h4 class="parameters">Parameters</h4>
1446<dl>
1447<dt>num_jobs</dt>
1448<dd class="description">Number of jobs</dd>
1449<dt>jobs</dt>
1450<dd class="description">Jobs</dd>
1451</dl>
1452<h3 class="function"><a name="cupsFreeOptions">cupsFreeOptions</a></h3>
1453<p class="description">Free all memory used by options.</p>
1454<p class="code">
1455void cupsFreeOptions (<br>
1456&nbsp;&nbsp;&nbsp;&nbsp;int num_options,<br>
1457&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_option_t">cups_option_t</a> *options<br>
1458);</p>
1459<h4 class="parameters">Parameters</h4>
1460<dl>
1461<dt>num_options</dt>
1462<dd class="description">Number of options</dd>
1463<dt>options</dt>
1464<dd class="description">Pointer to options</dd>
1465</dl>
1466<h3 class="function"><span class="info">&nbsp;DEPRECATED&nbsp;</span><a name="cupsGetClasses">cupsGetClasses</a></h3>
1467<p class="description">Get a list of printer classes from the default server.</p>
1468<p class="code">
1469int cupsGetClasses (<br>
1470&nbsp;&nbsp;&nbsp;&nbsp;char ***classes<br>
1471);</p>
1472<h4 class="parameters">Parameters</h4>
1473<dl>
1474<dt>classes</dt>
1475<dd class="description">Classes</dd>
1476</dl>
1477<h4 class="returnvalue">Return Value</h4>
1478<p class="description">Number of classes</p>
1479<h4 class="discussion">Discussion</h4>
1480<p class="discussion">This function is deprecated - use <a href="#cupsGetDests"><code>cupsGetDests</code></a> instead.
1481
1482</p>
1483<h3 class="function"><a name="cupsGetDefault">cupsGetDefault</a></h3>
1484<p class="description">Get the default printer or class for the default server.</p>
1485<p class="code">
1486const char *cupsGetDefault (void);</p>
1487<h4 class="returnvalue">Return Value</h4>
1488<p class="description">Default printer or <code>NULL</code></p>
1489<h4 class="discussion">Discussion</h4>
1490<p class="discussion">This function returns the default printer or class as defined by
ef416fc2 1491the LPDEST or PRINTER environment variables. If these environment
1492variables are not set, the server default destination is returned.
5a738aea
MS
1493Applications should use the <a href="#cupsGetDests"><code>cupsGetDests</code></a> and <a href="#cupsGetDest"><code>cupsGetDest</code></a>
1494functions to get the user-defined default printer, as this function does
1495not support the lpoptions-defined default printer.</p>
426c6a59 1496<h3 class="function"><span class="info">&nbsp;CUPS 1.1.21/Mac OS X 10.4&nbsp;</span><a name="cupsGetDefault2">cupsGetDefault2</a></h3>
5a738aea
MS
1497<p class="description">Get the default printer or class for the specified server.</p>
1498<p class="code">
1499const char *cupsGetDefault2 (<br>
1500&nbsp;&nbsp;&nbsp;&nbsp;http_t *http<br>
1501);</p>
1502<h4 class="parameters">Parameters</h4>
1503<dl>
1504<dt>http</dt>
568fa3fa 1505<dd class="description">Connection to server or <code>CUPS_HTTP_DEFAULT</code></dd>
5a738aea
MS
1506</dl>
1507<h4 class="returnvalue">Return Value</h4>
1508<p class="description">Default printer or <code>NULL</code></p>
1509<h4 class="discussion">Discussion</h4>
1510<p class="discussion">This function returns the default printer or class as defined by
ef416fc2 1511the LPDEST or PRINTER environment variables. If these environment
1512variables are not set, the server default destination is returned.
5a738aea
MS
1513Applications should use the <a href="#cupsGetDests"><code>cupsGetDests</code></a> and <a href="#cupsGetDest"><code>cupsGetDest</code></a>
1514functions to get the user-defined default printer, as this function does
1515not support the lpoptions-defined default printer.
1516
1517</p>
1518<h3 class="function"><a name="cupsGetDest">cupsGetDest</a></h3>
1519<p class="description">Get the named destination from the list.</p>
1520<p class="code">
1521<a href="#cups_dest_t">cups_dest_t</a> *cupsGetDest (<br>
1522&nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
1523&nbsp;&nbsp;&nbsp;&nbsp;const char *instance,<br>
1524&nbsp;&nbsp;&nbsp;&nbsp;int num_dests,<br>
1525&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_t">cups_dest_t</a> *dests<br>
1526);</p>
1527<h4 class="parameters">Parameters</h4>
1528<dl>
1529<dt>name</dt>
1530<dd class="description">Destination name or <code>NULL</code> for the default destination</dd>
1531<dt>instance</dt>
1532<dd class="description">Instance name or <code>NULL</code></dd>
1533<dt>num_dests</dt>
1534<dd class="description">Number of destinations</dd>
1535<dt>dests</dt>
1536<dd class="description">Destinations</dd>
1537</dl>
1538<h4 class="returnvalue">Return Value</h4>
1539<p class="description">Destination pointer or <code>NULL</code></p>
1540<h4 class="discussion">Discussion</h4>
1541<p class="discussion">Use the <a href="#cupsGetDests"><code>cupsGetDests</code></a> or <a href="#cupsGetDests2"><code>cupsGetDests2</code></a> functions to get a
1542list of supported destinations for the current user.</p>
1543<h3 class="function"><a name="cupsGetDests">cupsGetDests</a></h3>
1544<p class="description">Get the list of destinations from the default server.</p>
1545<p class="code">
1546int cupsGetDests (<br>
1547&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_t">cups_dest_t</a> **dests<br>
1548);</p>
1549<h4 class="parameters">Parameters</h4>
1550<dl>
1551<dt>dests</dt>
1552<dd class="description">Destinations</dd>
1553</dl>
1554<h4 class="returnvalue">Return Value</h4>
1555<p class="description">Number of destinations</p>
1556<h4 class="discussion">Discussion</h4>
1557<p class="discussion">Starting with CUPS 1.2, the returned list of destinations include the
ecdc0628 1558printer-info, printer-is-accepting-jobs, printer-is-shared,
1559printer-make-and-model, printer-state, printer-state-change-time,
426c6a59
MS
1560printer-state-reasons, and printer-type attributes as options. CUPS 1.4
1561adds the marker-change-time, marker-colors, marker-high-levels,
1562marker-levels, marker-low-levels, marker-message, marker-names,
1563marker-types, and printer-commands attributes as well.<br>
5a738aea
MS
1564<br>
1565Use the <a href="#cupsFreeDests"><code>cupsFreeDests</code></a> function to free the destination list and
1566the <a href="#cupsGetDest"><code>cupsGetDest</code></a> function to find a particular destination.</p>
426c6a59 1567<h3 class="function"><span class="info">&nbsp;CUPS 1.1.21/Mac OS X 10.4&nbsp;</span><a name="cupsGetDests2">cupsGetDests2</a></h3>
5a738aea
MS
1568<p class="description">Get the list of destinations from the specified server.</p>
1569<p class="code">
1570int cupsGetDests2 (<br>
1571&nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1572&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_t">cups_dest_t</a> **dests<br>
1573);</p>
1574<h4 class="parameters">Parameters</h4>
1575<dl>
1576<dt>http</dt>
568fa3fa 1577<dd class="description">Connection to server or <code>CUPS_HTTP_DEFAULT</code></dd>
5a738aea
MS
1578<dt>dests</dt>
1579<dd class="description">Destinations</dd>
1580</dl>
1581<h4 class="returnvalue">Return Value</h4>
1582<p class="description">Number of destinations</p>
1583<h4 class="discussion">Discussion</h4>
1584<p class="discussion">Starting with CUPS 1.2, the returned list of destinations include the
ecdc0628 1585printer-info, printer-is-accepting-jobs, printer-is-shared,
1586printer-make-and-model, printer-state, printer-state-change-time,
426c6a59
MS
1587printer-state-reasons, and printer-type attributes as options. CUPS 1.4
1588adds the marker-change-time, marker-colors, marker-high-levels,
1589marker-levels, marker-low-levels, marker-message, marker-names,
1590marker-types, and printer-commands attributes as well.<br>
5a738aea
MS
1591<br>
1592Use the <a href="#cupsFreeDests"><code>cupsFreeDests</code></a> function to free the destination list and
1593the <a href="#cupsGetDest"><code>cupsGetDest</code></a> function to find a particular destination.
ef416fc2 1594
5a738aea
MS
1595</p>
1596<h3 class="function"><a name="cupsGetJobs">cupsGetJobs</a></h3>
1597<p class="description">Get the jobs from the default server.</p>
1598<p class="code">
1599int cupsGetJobs (<br>
1600&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_job_t">cups_job_t</a> **jobs,<br>
1601&nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
1602&nbsp;&nbsp;&nbsp;&nbsp;int myjobs,<br>
1603&nbsp;&nbsp;&nbsp;&nbsp;int whichjobs<br>
1604);</p>
1605<h4 class="parameters">Parameters</h4>
1606<dl>
1607<dt>jobs</dt>
1608<dd class="description">Job data</dd>
1609<dt>name</dt>
568fa3fa 1610<dd class="description"><code>NULL</code> = all destinations, otherwise show jobs for named destination</dd>
5a738aea
MS
1611<dt>myjobs</dt>
1612<dd class="description">0 = all users, 1 = mine</dd>
1613<dt>whichjobs</dt>
1614<dd class="description"><code>CUPS_WHICHJOBS_ALL</code>, <code>CUPS_WHICHJOBS_ACTIVE</code>, or <code>CUPS_WHICHJOBS_COMPLETED</code></dd>
1615</dl>
1616<h4 class="returnvalue">Return Value</h4>
1617<p class="description">Number of jobs</p>
1618<h4 class="discussion">Discussion</h4>
1619<p class="discussion">A &quot;whichjobs&quot; value of <code>CUPS_WHICHJOBS_ALL</code> returns all jobs regardless
1620of state, while <code>CUPS_WHICHJOBS_ACTIVE</code> returns jobs that are
1621pending, processing, or held and <code>CUPS_WHICHJOBS_COMPLETED</code> returns
1622jobs that are stopped, canceled, aborted, or completed.</p>
426c6a59 1623<h3 class="function"><span class="info">&nbsp;CUPS 1.1.21/Mac OS X 10.4&nbsp;</span><a name="cupsGetJobs2">cupsGetJobs2</a></h3>
5a738aea
MS
1624<p class="description">Get the jobs from the specified server.</p>
1625<p class="code">
1626int cupsGetJobs2 (<br>
1627&nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1628&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_job_t">cups_job_t</a> **jobs,<br>
1629&nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
1630&nbsp;&nbsp;&nbsp;&nbsp;int myjobs,<br>
1631&nbsp;&nbsp;&nbsp;&nbsp;int whichjobs<br>
1632);</p>
1633<h4 class="parameters">Parameters</h4>
1634<dl>
1635<dt>http</dt>
568fa3fa 1636<dd class="description">Connection to server or <code>CUPS_HTTP_DEFAULT</code></dd>
5a738aea
MS
1637<dt>jobs</dt>
1638<dd class="description">Job data</dd>
1639<dt>name</dt>
568fa3fa 1640<dd class="description"><code>NULL</code> = all destinations, otherwise show jobs for named destination</dd>
5a738aea
MS
1641<dt>myjobs</dt>
1642<dd class="description">0 = all users, 1 = mine</dd>
1643<dt>whichjobs</dt>
1644<dd class="description"><code>CUPS_WHICHJOBS_ALL</code>, <code>CUPS_WHICHJOBS_ACTIVE</code>, or <code>CUPS_WHICHJOBS_COMPLETED</code></dd>
1645</dl>
1646<h4 class="returnvalue">Return Value</h4>
1647<p class="description">Number of jobs</p>
1648<h4 class="discussion">Discussion</h4>
1649<p class="discussion">A &quot;whichjobs&quot; value of <code>CUPS_WHICHJOBS_ALL</code> returns all jobs regardless
1650of state, while <code>CUPS_WHICHJOBS_ACTIVE</code> returns jobs that are
1651pending, processing, or held and <code>CUPS_WHICHJOBS_COMPLETED</code> returns
1652jobs that are stopped, canceled, aborted, or completed.
1653
1654</p>
178cb736 1655<h3 class="function"><span class="info">&nbsp;CUPS 1.4/Mac OS X 10.6&nbsp;</span><a name="cupsGetNamedDest">cupsGetNamedDest</a></h3>
5a738aea
MS
1656<p class="description">Get options for the named destination.</p>
1657<p class="code">
1658<a href="#cups_dest_t">cups_dest_t</a> *cupsGetNamedDest (<br>
1659&nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1660&nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
1661&nbsp;&nbsp;&nbsp;&nbsp;const char *instance<br>
1662);</p>
1663<h4 class="parameters">Parameters</h4>
1664<dl>
1665<dt>http</dt>
568fa3fa 1666<dd class="description">Connection to server or <code>CUPS_HTTP_DEFAULT</code></dd>
5a738aea 1667<dt>name</dt>
568fa3fa 1668<dd class="description">Destination name or <code>NULL</code> for the default destination</dd>
5a738aea
MS
1669<dt>instance</dt>
1670<dd class="description">Instance name or <code>NULL</code></dd>
1671</dl>
1672<h4 class="returnvalue">Return Value</h4>
1673<p class="description">Destination or <code>NULL</code></p>
1674<h4 class="discussion">Discussion</h4>
1675<p class="discussion">This function is optimized for retrieving a single destination and should
1676be used instead of <a href="#cupsGetDests"><code>cupsGetDests</code></a> and <a href="#cupsGetDest"><code>cupsGetDest</code></a> when you either
1677know the name of the destination or want to print to the default destination.
1678If <code>NULL</code> is returned, the destination does not exist or there is no
1679default destination.<br>
1680<br>
1681If &quot;http&quot; is <code>CUPS_HTTP_DEFAULT</code>, the connection to the default print
1682server will be used.<br>
1683<br>
1684If &quot;name&quot; is <code>NULL</code>, the default printer for the current user will be
1685returned.<br>
1686<br>
1687The returned destination must be freed using <a href="#cupsFreeDests"><code>cupsFreeDests</code></a> with a
1688&quot;num_dests&quot; value of 1.
1689
1690</p>
1691<h3 class="function"><a name="cupsGetOption">cupsGetOption</a></h3>
1692<p class="description">Get an option value.</p>
1693<p class="code">
1694const char *cupsGetOption (<br>
1695&nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
1696&nbsp;&nbsp;&nbsp;&nbsp;int num_options,<br>
1697&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_option_t">cups_option_t</a> *options<br>
1698);</p>
1699<h4 class="parameters">Parameters</h4>
1700<dl>
1701<dt>name</dt>
1702<dd class="description">Name of option</dd>
1703<dt>num_options</dt>
1704<dd class="description">Number of options</dd>
1705<dt>options</dt>
1706<dd class="description">Options</dd>
1707</dl>
1708<h4 class="returnvalue">Return Value</h4>
1709<p class="description">Option value or <code>NULL</code></p>
1710<h3 class="function"><a name="cupsGetPPD">cupsGetPPD</a></h3>
1711<p class="description">Get the PPD file for a printer on the default server.</p>
1712<p class="code">
1713const char *cupsGetPPD (<br>
1714&nbsp;&nbsp;&nbsp;&nbsp;const char *name<br>
1715);</p>
1716<h4 class="parameters">Parameters</h4>
1717<dl>
1718<dt>name</dt>
568fa3fa 1719<dd class="description">Destination name</dd>
5a738aea
MS
1720</dl>
1721<h4 class="returnvalue">Return Value</h4>
1722<p class="description">Filename for PPD file</p>
1723<h4 class="discussion">Discussion</h4>
1724<p class="discussion">For classes, <code>cupsGetPPD</code> returns the PPD file for the first printer
568fa3fa
MS
1725in the class.<br>
1726<br>
1727The returned filename is stored in a static buffer and is overwritten with
4e6f60f0
MS
1728each call to <code>cupsGetPPD</code> or <a href="#cupsGetPPD2"><code>cupsGetPPD2</code></a>. The caller &quot;owns&quot; the
1729file that is created and must <code>unlink</code> the returned filename.</p>
426c6a59 1730<h3 class="function"><span class="info">&nbsp;CUPS 1.1.21/Mac OS X 10.4&nbsp;</span><a name="cupsGetPPD2">cupsGetPPD2</a></h3>
5a738aea
MS
1731<p class="description">Get the PPD file for a printer from the specified server.</p>
1732<p class="code">
1733const char *cupsGetPPD2 (<br>
1734&nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1735&nbsp;&nbsp;&nbsp;&nbsp;const char *name<br>
1736);</p>
1737<h4 class="parameters">Parameters</h4>
1738<dl>
1739<dt>http</dt>
568fa3fa 1740<dd class="description">Connection to server or <code>CUPS_HTTP_DEFAULT</code></dd>
5a738aea 1741<dt>name</dt>
568fa3fa 1742<dd class="description">Destination name</dd>
5a738aea
MS
1743</dl>
1744<h4 class="returnvalue">Return Value</h4>
1745<p class="description">Filename for PPD file</p>
1746<h4 class="discussion">Discussion</h4>
1747<p class="discussion">For classes, <code>cupsGetPPD2</code> returns the PPD file for the first printer
568fa3fa
MS
1748in the class.<br>
1749<br>
1750The returned filename is stored in a static buffer and is overwritten with
4e6f60f0
MS
1751each call to <a href="#cupsGetPPD"><code>cupsGetPPD</code></a> or <code>cupsGetPPD2</code>. The caller &quot;owns&quot; the
1752file that is created and must <code>unlink</code> the returned filename.
5a738aea
MS
1753
1754</p>
178cb736 1755<h3 class="function"><span class="info">&nbsp;CUPS 1.4/Mac OS X 10.6&nbsp;</span><a name="cupsGetPPD3">cupsGetPPD3</a></h3>
5a738aea
MS
1756<p class="description">Get the PPD file for a printer on the specified
1757server if it has changed.</p>
1758<p class="code">
1759http_status_t cupsGetPPD3 (<br>
1760&nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1761&nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
1762&nbsp;&nbsp;&nbsp;&nbsp;time_t *modtime,<br>
1763&nbsp;&nbsp;&nbsp;&nbsp;char *buffer,<br>
1764&nbsp;&nbsp;&nbsp;&nbsp;size_t bufsize<br>
1765);</p>
1766<h4 class="parameters">Parameters</h4>
1767<dl>
1768<dt>http</dt>
1769<dd class="description">HTTP connection or <code>CUPS_HTTP_DEFAULT</code></dd>
1770<dt>name</dt>
568fa3fa 1771<dd class="description">Destination name</dd>
5a738aea
MS
1772<dt>modtime</dt>
1773<dd class="description">Modification time</dd>
1774<dt>buffer</dt>
1775<dd class="description">Filename buffer</dd>
1776<dt>bufsize</dt>
1777<dd class="description">Size of filename buffer</dd>
1778</dl>
1779<h4 class="returnvalue">Return Value</h4>
1780<p class="description">HTTP status</p>
1781<h4 class="discussion">Discussion</h4>
1782<p class="discussion">The &quot;modtime&quot; parameter contains the modification time of any
2e4ff8af 1783locally-cached content and is updated with the time from the PPD file on
5a738aea
MS
1784the server.<br>
1785<br>
1786The &quot;buffer&quot; parameter contains the local PPD filename. If it contains
2e4ff8af 1787the empty string, a new temporary file is created, otherwise the existing
4e6f60f0
MS
1788file will be overwritten as needed. The caller &quot;owns&quot; the file that is
1789created and must <code>unlink</code> the returned filename.<br>
5a738aea
MS
1790<br>
1791On success, <code>HTTP_OK</code> is returned for a new PPD file and
1792<code>HTTP_NOT_MODIFIED</code> if the existing PPD file is up-to-date. Any other
1793status is an error.<br>
1794<br>
1795For classes, <code>cupsGetPPD3</code> returns the PPD file for the first printer
568fa3fa
MS
1796in the class.
1797
1798</p>
5a738aea
MS
1799<h3 class="function"><a name="cupsGetPassword">cupsGetPassword</a></h3>
1800<p class="description">Get a password from the user.</p>
1801<p class="code">
1802const char *cupsGetPassword (<br>
1803&nbsp;&nbsp;&nbsp;&nbsp;const char *prompt<br>
1804);</p>
1805<h4 class="parameters">Parameters</h4>
1806<dl>
1807<dt>prompt</dt>
1808<dd class="description">Prompt string</dd>
1809</dl>
1810<h4 class="returnvalue">Return Value</h4>
1811<p class="description">Password</p>
1812<h4 class="discussion">Discussion</h4>
1813<p class="discussion">Uses the current password callback function. Returns <code>NULL</code> if the
aaf19ab0
MS
1814user does not provide a password.<br>
1815<br>
1816Note: The current password callback function is tracked separately for each
1817thread in a program. Multi-threaded programs that override the setting via
1818the <a href="#cupsSetPasswordCB"><code>cupsSetPasswordCB</code></a> or <a href="#cupsSetPasswordCB2"><code>cupsSetPasswordCB2</code></a> functions need to
1819do so in each thread for the same function to be used.</p>
178cb736 1820<h3 class="function"><span class="info">&nbsp;CUPS 1.4/Mac OS X 10.6&nbsp;</span><a name="cupsGetPassword2">cupsGetPassword2</a></h3>
f11a948a 1821<p class="description">Get a password from the user using the advanced
aaf19ab0 1822password callback.</p>
f11a948a
MS
1823<p class="code">
1824const char *cupsGetPassword2 (<br>
1825&nbsp;&nbsp;&nbsp;&nbsp;const char *prompt,<br>
1826&nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1827&nbsp;&nbsp;&nbsp;&nbsp;const char *method,<br>
1828&nbsp;&nbsp;&nbsp;&nbsp;const char *resource<br>
1829);</p>
1830<h4 class="parameters">Parameters</h4>
1831<dl>
1832<dt>prompt</dt>
1833<dd class="description">Prompt string</dd>
1834<dt>http</dt>
1835<dd class="description">Connection to server or <code>CUPS_HTTP_DEFAULT</code></dd>
1836<dt>method</dt>
1837<dd class="description">Request method (&quot;GET&quot;, &quot;POST&quot;, &quot;PUT&quot;)</dd>
1838<dt>resource</dt>
1839<dd class="description">Resource path</dd>
1840</dl>
1841<h4 class="returnvalue">Return Value</h4>
1842<p class="description">Password</p>
1843<h4 class="discussion">Discussion</h4>
1844<p class="discussion">Uses the current password callback function. Returns <code>NULL</code> if the
aaf19ab0
MS
1845user does not provide a password.<br>
1846<br>
1847Note: The current password callback function is tracked separately for each
1848thread in a program. Multi-threaded programs that override the setting via
1849the <a href="#cupsSetPasswordCB"><code>cupsSetPasswordCB</code></a> or <a href="#cupsSetPasswordCB2"><code>cupsSetPasswordCB2</code></a> functions need to
1850do so in each thread for the same function to be used.
f11a948a
MS
1851
1852</p>
5a738aea
MS
1853<h3 class="function"><span class="info">&nbsp;DEPRECATED&nbsp;</span><a name="cupsGetPrinters">cupsGetPrinters</a></h3>
1854<p class="description">Get a list of printers from the default server.</p>
1855<p class="code">
1856int cupsGetPrinters (<br>
1857&nbsp;&nbsp;&nbsp;&nbsp;char ***printers<br>
1858);</p>
1859<h4 class="parameters">Parameters</h4>
1860<dl>
1861<dt>printers</dt>
1862<dd class="description">Printers</dd>
1863</dl>
1864<h4 class="returnvalue">Return Value</h4>
1865<p class="description">Number of printers</p>
1866<h4 class="discussion">Discussion</h4>
1867<p class="discussion">This function is deprecated - use <a href="#cupsGetDests"><code>cupsGetDests</code></a> instead.
1868
1869</p>
426c6a59 1870<h3 class="function"><span class="info">&nbsp;CUPS 1.3/Mac OS X 10.5&nbsp;</span><a name="cupsGetServerPPD">cupsGetServerPPD</a></h3>
5a738aea
MS
1871<p class="description">Get an available PPD file from the server.</p>
1872<p class="code">
1873char *cupsGetServerPPD (<br>
1874&nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
1875&nbsp;&nbsp;&nbsp;&nbsp;const char *name<br>
1876);</p>
1877<h4 class="parameters">Parameters</h4>
1878<dl>
1879<dt>http</dt>
568fa3fa 1880<dd class="description">Connection to server or <code>CUPS_HTTP_DEFAULT</code></dd>
5a738aea
MS
1881<dt>name</dt>
1882<dd class="description">Name of PPD file (&quot;ppd-name&quot;)</dd>
1883</dl>
1884<h4 class="returnvalue">Return Value</h4>
1885<p class="description">Name of PPD file or <code>NULL</code> on error</p>
1886<h4 class="discussion">Discussion</h4>
1887<p class="discussion">This function returns the named PPD file from the server. The
1888list of available PPDs is provided by the IPP <code>CUPS_GET_PPDS</code>
1889operation.<br>
1890<br>
1891You must remove (unlink) the PPD file when you are finished with
bc44d920 1892it. The PPD filename is stored in a static location that will be
5a738aea
MS
1893overwritten on the next call to <a href="#cupsGetPPD"><code>cupsGetPPD</code></a>, <a href="#cupsGetPPD2"><code>cupsGetPPD2</code></a>,
1894or <a href="#cupsGetServerPPD"><code>cupsGetServerPPD</code></a>.
1895
1896</p>
1897<h3 class="function"><a name="cupsLangDefault">cupsLangDefault</a></h3>
1898<p class="description">Return the default language.</p>
1899<p class="code">
1900cups_lang_t *cupsLangDefault (void);</p>
1901<h4 class="returnvalue">Return Value</h4>
1902<p class="description">Language data</p>
1903<h3 class="function"><a name="cupsLangEncoding">cupsLangEncoding</a></h3>
1904<p class="description">Return the character encoding (us-ascii, etc.)
1905for the given language.</p>
1906<p class="code">
1907const char *cupsLangEncoding (<br>
1908&nbsp;&nbsp;&nbsp;&nbsp;cups_lang_t *lang<br>
1909);</p>
1910<h4 class="parameters">Parameters</h4>
1911<dl>
1912<dt>lang</dt>
1913<dd class="description">Language data</dd>
1914</dl>
1915<h4 class="returnvalue">Return Value</h4>
1916<p class="description">Character encoding</p>
1917<h3 class="function"><a name="cupsLangFlush">cupsLangFlush</a></h3>
1918<p class="description">Flush all language data out of the cache.</p>
1919<p class="code">
1920void cupsLangFlush (void);</p>
1921<h3 class="function"><a name="cupsLangFree">cupsLangFree</a></h3>
1922<p class="description">Free language data.</p>
1923<p class="code">
1924void cupsLangFree (<br>
1925&nbsp;&nbsp;&nbsp;&nbsp;cups_lang_t *lang<br>
1926);</p>
1927<h4 class="parameters">Parameters</h4>
1928<dl>
1929<dt>lang</dt>
1930<dd class="description">Language to free</dd>
1931</dl>
1932<h4 class="discussion">Discussion</h4>
1933<p class="discussion">This does not actually free anything; use <a href="#cupsLangFlush"><code>cupsLangFlush</code></a> for that.</p>
1934<h3 class="function"><a name="cupsLangGet">cupsLangGet</a></h3>
1935<p class="description">Get a language.</p>
1936<p class="code">
1937cups_lang_t *cupsLangGet (<br>
1938&nbsp;&nbsp;&nbsp;&nbsp;const char *language<br>
1939);</p>
1940<h4 class="parameters">Parameters</h4>
1941<dl>
1942<dt>language</dt>
1943<dd class="description">Language or locale</dd>
1944</dl>
1945<h4 class="returnvalue">Return Value</h4>
1946<p class="description">Language data</p>
426c6a59 1947<h3 class="function"><span class="info">&nbsp;CUPS 1.2/Mac OS X 10.5&nbsp;</span><a name="cupsNotifySubject">cupsNotifySubject</a></h3>
5a738aea
MS
1948<p class="description">Return the subject for the given notification message.</p>
1949<p class="code">
1950char *cupsNotifySubject (<br>
1951&nbsp;&nbsp;&nbsp;&nbsp;cups_lang_t *lang,<br>
1952&nbsp;&nbsp;&nbsp;&nbsp;ipp_t *event<br>
1953);</p>
1954<h4 class="parameters">Parameters</h4>
1955<dl>
1956<dt>lang</dt>
1957<dd class="description">Language data</dd>
1958<dt>event</dt>
1959<dd class="description">Event data</dd>
1960</dl>
1961<h4 class="returnvalue">Return Value</h4>
1962<p class="description">Subject string or <code>NULL</code></p>
1963<h4 class="discussion">Discussion</h4>
568fa3fa 1964<p class="discussion">The returned string must be freed by the caller using <code>free</code>.
5a738aea
MS
1965
1966</p>
426c6a59 1967<h3 class="function"><span class="info">&nbsp;CUPS 1.2/Mac OS X 10.5&nbsp;</span><a name="cupsNotifyText">cupsNotifyText</a></h3>
5a738aea
MS
1968<p class="description">Return the text for the given notification message.</p>
1969<p class="code">
1970char *cupsNotifyText (<br>
1971&nbsp;&nbsp;&nbsp;&nbsp;cups_lang_t *lang,<br>
1972&nbsp;&nbsp;&nbsp;&nbsp;ipp_t *event<br>
1973);</p>
1974<h4 class="parameters">Parameters</h4>
1975<dl>
1976<dt>lang</dt>
1977<dd class="description">Language data</dd>
1978<dt>event</dt>
1979<dd class="description">Event data</dd>
1980</dl>
1981<h4 class="returnvalue">Return Value</h4>
1982<p class="description">Message text or <code>NULL</code></p>
1983<h4 class="discussion">Discussion</h4>
1984<p class="discussion">The returned string must be freed by the caller using <code>free</code>.
1985
1986</p>
1987<h3 class="function"><a name="cupsParseOptions">cupsParseOptions</a></h3>
1988<p class="description">Parse options from a command-line argument.</p>
1989<p class="code">
1990int cupsParseOptions (<br>
1991&nbsp;&nbsp;&nbsp;&nbsp;const char *arg,<br>
1992&nbsp;&nbsp;&nbsp;&nbsp;int num_options,<br>
1993&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_option_t">cups_option_t</a> **options<br>
1994);</p>
1995<h4 class="parameters">Parameters</h4>
1996<dl>
1997<dt>arg</dt>
1998<dd class="description">Argument to parse</dd>
1999<dt>num_options</dt>
2000<dd class="description">Number of options</dd>
2001<dt>options</dt>
2002<dd class="description">Options found</dd>
2003</dl>
2004<h4 class="returnvalue">Return Value</h4>
2005<p class="description">Number of options found</p>
2006<h4 class="discussion">Discussion</h4>
2007<p class="discussion">This function converts space-delimited name/value pairs according
ef416fc2 2008to the PAPI text option ABNF specification. Collection values
2009(&quot;name={a=... b=... c=...}&quot;) are stored with the curley brackets
5a738aea
MS
2010intact - use <code>cupsParseOptions</code> on the value to extract the
2011collection attributes.</p>
2012<h3 class="function"><a name="cupsPrintFile">cupsPrintFile</a></h3>
2013<p class="description">Print a file to a printer or class on the default server.</p>
2014<p class="code">
2015int cupsPrintFile (<br>
2016&nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
2017&nbsp;&nbsp;&nbsp;&nbsp;const char *filename,<br>
2018&nbsp;&nbsp;&nbsp;&nbsp;const char *title,<br>
2019&nbsp;&nbsp;&nbsp;&nbsp;int num_options,<br>
2020&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_option_t">cups_option_t</a> *options<br>
2021);</p>
2022<h4 class="parameters">Parameters</h4>
2023<dl>
2024<dt>name</dt>
568fa3fa 2025<dd class="description">Destination name</dd>
5a738aea
MS
2026<dt>filename</dt>
2027<dd class="description">File to print</dd>
2028<dt>title</dt>
2029<dd class="description">Title of job</dd>
2030<dt>num_options</dt>
2031<dd class="description">Number of options</dd>
2032<dt>options</dt>
2033<dd class="description">Options</dd>
2034</dl>
2035<h4 class="returnvalue">Return Value</h4>
2036<p class="description">Job ID or 0 on error</p>
426c6a59 2037<h3 class="function"><span class="info">&nbsp;CUPS 1.1.21/Mac OS X 10.4&nbsp;</span><a name="cupsPrintFile2">cupsPrintFile2</a></h3>
5a738aea
MS
2038<p class="description">Print a file to a printer or class on the specified
2039server.</p>
2040<p class="code">
2041int cupsPrintFile2 (<br>
2042&nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
2043&nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
2044&nbsp;&nbsp;&nbsp;&nbsp;const char *filename,<br>
2045&nbsp;&nbsp;&nbsp;&nbsp;const char *title,<br>
2046&nbsp;&nbsp;&nbsp;&nbsp;int num_options,<br>
2047&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_option_t">cups_option_t</a> *options<br>
2048);</p>
2049<h4 class="parameters">Parameters</h4>
2050<dl>
2051<dt>http</dt>
568fa3fa 2052<dd class="description">Connection to server</dd>
5a738aea 2053<dt>name</dt>
568fa3fa 2054<dd class="description">Destination name</dd>
5a738aea
MS
2055<dt>filename</dt>
2056<dd class="description">File to print</dd>
2057<dt>title</dt>
2058<dd class="description">Title of job</dd>
2059<dt>num_options</dt>
2060<dd class="description">Number of options</dd>
2061<dt>options</dt>
2062<dd class="description">Options</dd>
2063</dl>
2064<h4 class="returnvalue">Return Value</h4>
2065<p class="description">Job ID or 0 on error</p>
2066<h3 class="function"><a name="cupsPrintFiles">cupsPrintFiles</a></h3>
2067<p class="description">Print one or more files to a printer or class on the
2068default server.</p>
2069<p class="code">
2070int cupsPrintFiles (<br>
2071&nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
2072&nbsp;&nbsp;&nbsp;&nbsp;int num_files,<br>
2073&nbsp;&nbsp;&nbsp;&nbsp;const char **files,<br>
2074&nbsp;&nbsp;&nbsp;&nbsp;const char *title,<br>
2075&nbsp;&nbsp;&nbsp;&nbsp;int num_options,<br>
2076&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_option_t">cups_option_t</a> *options<br>
2077);</p>
2078<h4 class="parameters">Parameters</h4>
2079<dl>
2080<dt>name</dt>
568fa3fa 2081<dd class="description">Destination name</dd>
5a738aea
MS
2082<dt>num_files</dt>
2083<dd class="description">Number of files</dd>
2084<dt>files</dt>
2085<dd class="description">File(s) to print</dd>
2086<dt>title</dt>
2087<dd class="description">Title of job</dd>
2088<dt>num_options</dt>
2089<dd class="description">Number of options</dd>
2090<dt>options</dt>
2091<dd class="description">Options</dd>
2092</dl>
2093<h4 class="returnvalue">Return Value</h4>
2094<p class="description">Job ID or 0 on error</p>
426c6a59 2095<h3 class="function"><span class="info">&nbsp;CUPS 1.1.21/Mac OS X 10.4&nbsp;</span><a name="cupsPrintFiles2">cupsPrintFiles2</a></h3>
5a738aea
MS
2096<p class="description">Print one or more files to a printer or class on the
2097specified server.</p>
2098<p class="code">
2099int cupsPrintFiles2 (<br>
2100&nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
2101&nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
2102&nbsp;&nbsp;&nbsp;&nbsp;int num_files,<br>
2103&nbsp;&nbsp;&nbsp;&nbsp;const char **files,<br>
2104&nbsp;&nbsp;&nbsp;&nbsp;const char *title,<br>
2105&nbsp;&nbsp;&nbsp;&nbsp;int num_options,<br>
2106&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_option_t">cups_option_t</a> *options<br>
2107);</p>
2108<h4 class="parameters">Parameters</h4>
2109<dl>
2110<dt>http</dt>
568fa3fa 2111<dd class="description">Connection to server or <code>CUPS_HTTP_DEFAULT</code></dd>
5a738aea 2112<dt>name</dt>
568fa3fa 2113<dd class="description">Destination name</dd>
5a738aea
MS
2114<dt>num_files</dt>
2115<dd class="description">Number of files</dd>
2116<dt>files</dt>
2117<dd class="description">File(s) to print</dd>
2118<dt>title</dt>
2119<dd class="description">Title of job</dd>
2120<dt>num_options</dt>
2121<dd class="description">Number of options</dd>
2122<dt>options</dt>
2123<dd class="description">Options</dd>
2124</dl>
2125<h4 class="returnvalue">Return Value</h4>
2126<p class="description">Job ID or 0 on error</p>
426c6a59 2127<h3 class="function"><span class="info">&nbsp;CUPS 1.3/Mac OS X 10.5&nbsp;</span><a name="cupsRemoveDest">cupsRemoveDest</a></h3>
5a738aea
MS
2128<p class="description">Remove a destination from the destination list.</p>
2129<p class="code">
2130int cupsRemoveDest (<br>
2131&nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
2132&nbsp;&nbsp;&nbsp;&nbsp;const char *instance,<br>
2133&nbsp;&nbsp;&nbsp;&nbsp;int num_dests,<br>
2134&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_t">cups_dest_t</a> **dests<br>
2135);</p>
2136<h4 class="parameters">Parameters</h4>
2137<dl>
2138<dt>name</dt>
2139<dd class="description">Destination name</dd>
2140<dt>instance</dt>
2141<dd class="description">Instance name or <code>NULL</code></dd>
2142<dt>num_dests</dt>
2143<dd class="description">Number of destinations</dd>
2144<dt>dests</dt>
2145<dd class="description">Destinations</dd>
2146</dl>
2147<h4 class="returnvalue">Return Value</h4>
2148<p class="description">New number of destinations</p>
2149<h4 class="discussion">Discussion</h4>
2150<p class="discussion">Removing a destination/instance does not delete the class or printer
f7deaa1a 2151queue, merely the lpoptions for that destination/instance. Use the
5a738aea
MS
2152<a href="#cupsSetDests"><code>cupsSetDests</code></a> or <a href="#cupsSetDests2"><code>cupsSetDests2</code></a> functions to save the new
2153options for the user.
2154
2155</p>
426c6a59 2156<h3 class="function"><span class="info">&nbsp;CUPS 1.2/Mac OS X 10.5&nbsp;</span><a name="cupsRemoveOption">cupsRemoveOption</a></h3>
5a738aea
MS
2157<p class="description">Remove an option from an option array.</p>
2158<p class="code">
2159int cupsRemoveOption (<br>
2160&nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
2161&nbsp;&nbsp;&nbsp;&nbsp;int num_options,<br>
2162&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_option_t">cups_option_t</a> **options<br>
2163);</p>
2164<h4 class="parameters">Parameters</h4>
2165<dl>
2166<dt>name</dt>
2167<dd class="description">Option name</dd>
2168<dt>num_options</dt>
2169<dd class="description">Current number of options</dd>
2170<dt>options</dt>
2171<dd class="description">Options</dd>
2172</dl>
2173<h4 class="returnvalue">Return Value</h4>
2174<p class="description">New number of options</p>
2175<h3 class="function"><a name="cupsServer">cupsServer</a></h3>
aaf19ab0 2176<p class="description">Return the hostname/address of the current server.</p>
5a738aea
MS
2177<p class="code">
2178const char *cupsServer (void);</p>
2179<h4 class="returnvalue">Return Value</h4>
2180<p class="description">Server name</p>
2181<h4 class="discussion">Discussion</h4>
aaf19ab0
MS
2182<p class="discussion">The default server comes from the CUPS_SERVER environment variable, then the
2183~/.cups/client.conf file, and finally the /etc/cups/client.conf file. If not
2184set, the default is the local system - either &quot;localhost&quot; or a domain socket
2185path.<br>
2186<br>
2187The returned value can be a fully-qualified hostname, a numeric IPv4 or IPv6
2188address, or a domain socket pathname.<br>
2189<br>
2190Note: The current server is tracked separately for each thread in a program.
2191Multi-threaded programs that override the server via the
2192<a href="#cupsSetServer"><code>cupsSetServer</code></a> function need to do so in each thread for the same
2193server to be used.</p>
321d8d57 2194<h3 class="function"><span class="info">&nbsp;CUPS 1.5/Mac OS X 10.7&nbsp;</span><a name="cupsSetClientCertCB">cupsSetClientCertCB</a></h3>
10d09e33
MS
2195<p class="description">Set the client certificate callback.</p>
2196<p class="code">
2197void cupsSetClientCertCB (<br>
2198&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_client_cert_cb_t">cups_client_cert_cb_t</a> cb,<br>
2199&nbsp;&nbsp;&nbsp;&nbsp;void *user_data<br>
2200);</p>
2201<h4 class="parameters">Parameters</h4>
2202<dl>
2203<dt>cb</dt>
2204<dd class="description">Callback function</dd>
2205<dt>user_data</dt>
2206<dd class="description">User data pointer</dd>
2207</dl>
2208<h4 class="discussion">Discussion</h4>
2209<p class="discussion">Pass <code>NULL</code> to restore the default callback.<br>
2210<br>
2211Note: The current certificate callback is tracked separately for each thread
2212in a program. Multi-threaded programs that override the callback need to do
2213so in each thread for the same callback to be used.
2214
2215</p>
321d8d57 2216<h3 class="function"><span class="info">&nbsp;CUPS 1.5/Mac OS X 10.7&nbsp;</span><a name="cupsSetCredentials">cupsSetCredentials</a></h3>
10d09e33
MS
2217<p class="description">Set the default credentials to be used for SSL/TLS
2218connections.</p>
2219<p class="code">
2220int cupsSetCredentials (<br>
2221&nbsp;&nbsp;&nbsp;&nbsp;cups_array_t *credentials<br>
2222);</p>
2223<h4 class="parameters">Parameters</h4>
2224<dl>
2225<dt>credentials</dt>
2226<dd class="description">Array of credentials</dd>
2227</dl>
2228<h4 class="returnvalue">Return Value</h4>
2229<p class="description">Status of call (0 = success)</p>
2230<h4 class="discussion">Discussion</h4>
2231<p class="discussion">Note: The default credentials are tracked separately for each thread in a
2232program. Multi-threaded programs that override the setting need to do so in
2233each thread for the same setting to be used.
2234
2235</p>
426c6a59 2236<h3 class="function"><span class="info">&nbsp;CUPS 1.3/Mac OS X 10.5&nbsp;</span><a name="cupsSetDefaultDest">cupsSetDefaultDest</a></h3>
5a738aea
MS
2237<p class="description">Set the default destination.</p>
2238<p class="code">
2239void cupsSetDefaultDest (<br>
2240&nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
2241&nbsp;&nbsp;&nbsp;&nbsp;const char *instance,<br>
2242&nbsp;&nbsp;&nbsp;&nbsp;int num_dests,<br>
2243&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_t">cups_dest_t</a> *dests<br>
2244);</p>
2245<h4 class="parameters">Parameters</h4>
2246<dl>
2247<dt>name</dt>
2248<dd class="description">Destination name</dd>
2249<dt>instance</dt>
2250<dd class="description">Instance name or <code>NULL</code></dd>
2251<dt>num_dests</dt>
2252<dd class="description">Number of destinations</dd>
2253<dt>dests</dt>
2254<dd class="description">Destinations</dd>
2255</dl>
2256<h3 class="function"><a name="cupsSetDests">cupsSetDests</a></h3>
2257<p class="description">Save the list of destinations for the default server.</p>
2258<p class="code">
2259void cupsSetDests (<br>
2260&nbsp;&nbsp;&nbsp;&nbsp;int num_dests,<br>
2261&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_t">cups_dest_t</a> *dests<br>
2262);</p>
2263<h4 class="parameters">Parameters</h4>
2264<dl>
2265<dt>num_dests</dt>
2266<dd class="description">Number of destinations</dd>
2267<dt>dests</dt>
2268<dd class="description">Destinations</dd>
2269</dl>
2270<h4 class="discussion">Discussion</h4>
2271<p class="discussion">This function saves the destinations to /etc/cups/lpoptions when run
2272as root and ~/.cups/lpoptions when run as a normal user.</p>
426c6a59 2273<h3 class="function"><span class="info">&nbsp;CUPS 1.1.21/Mac OS X 10.4&nbsp;</span><a name="cupsSetDests2">cupsSetDests2</a></h3>
5a738aea
MS
2274<p class="description">Save the list of destinations for the specified server.</p>
2275<p class="code">
2276int cupsSetDests2 (<br>
2277&nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
2278&nbsp;&nbsp;&nbsp;&nbsp;int num_dests,<br>
2279&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dest_t">cups_dest_t</a> *dests<br>
2280);</p>
2281<h4 class="parameters">Parameters</h4>
2282<dl>
2283<dt>http</dt>
568fa3fa 2284<dd class="description">Connection to server or <code>CUPS_HTTP_DEFAULT</code></dd>
5a738aea
MS
2285<dt>num_dests</dt>
2286<dd class="description">Number of destinations</dd>
2287<dt>dests</dt>
2288<dd class="description">Destinations</dd>
2289</dl>
2290<h4 class="returnvalue">Return Value</h4>
2291<p class="description">0 on success, -1 on error</p>
2292<h4 class="discussion">Discussion</h4>
2293<p class="discussion">This function saves the destinations to /etc/cups/lpoptions when run
80ca4592 2294as root and ~/.cups/lpoptions when run as a normal user.
ef416fc2 2295
5a738aea
MS
2296</p>
2297<h3 class="function"><a name="cupsSetEncryption">cupsSetEncryption</a></h3>
2298<p class="description">Set the encryption preference.</p>
2299<p class="code">
2300void cupsSetEncryption (<br>
2301&nbsp;&nbsp;&nbsp;&nbsp;http_encryption_t e<br>
2302);</p>
2303<h4 class="parameters">Parameters</h4>
2304<dl>
2305<dt>e</dt>
2306<dd class="description">New encryption preference</dd>
2307</dl>
aaf19ab0
MS
2308<h4 class="discussion">Discussion</h4>
2309<p class="discussion">The default encryption setting comes from the CUPS_ENCRYPTION
2310environment variable, then the ~/.cups/client.conf file, and finally the
2311/etc/cups/client.conf file. If not set, the default is
2312<code>HTTP_ENCRYPT_IF_REQUESTED</code>.<br>
2313<br>
2314Note: The current encryption setting is tracked separately for each thread
2315in a program. Multi-threaded programs that override the setting need to do
2316so in each thread for the same setting to be used.</p>
5a738aea
MS
2317<h3 class="function"><a name="cupsSetPasswordCB">cupsSetPasswordCB</a></h3>
2318<p class="description">Set the password callback for CUPS.</p>
2319<p class="code">
2320void cupsSetPasswordCB (<br>
2321&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_password_cb_t">cups_password_cb_t</a> cb<br>
2322);</p>
2323<h4 class="parameters">Parameters</h4>
2324<dl>
2325<dt>cb</dt>
2326<dd class="description">Callback function</dd>
2327</dl>
2328<h4 class="discussion">Discussion</h4>
aaf19ab0
MS
2329<p class="discussion">Pass <code>NULL</code> to restore the default (console) password callback, which
2330reads the password from the console. Programs should call either this
2331function or <a href="#cupsSetPasswordCB2"><code>cupsSetPasswordCB2</code></a>, as only one callback can be registered
2332by a program per thread.<br>
2333<br>
2334Note: The current password callback is tracked separately for each thread
2335in a program. Multi-threaded programs that override the callback need to do
2336so in each thread for the same callback to be used.</p>
178cb736 2337<h3 class="function"><span class="info">&nbsp;CUPS 1.4/Mac OS X 10.6&nbsp;</span><a name="cupsSetPasswordCB2">cupsSetPasswordCB2</a></h3>
f11a948a
MS
2338<p class="description">Set the advanced password callback for CUPS.</p>
2339<p class="code">
2340void cupsSetPasswordCB2 (<br>
2341&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_password_cb2_t">cups_password_cb2_t</a> cb,<br>
2342&nbsp;&nbsp;&nbsp;&nbsp;void *user_data<br>
2343);</p>
2344<h4 class="parameters">Parameters</h4>
2345<dl>
2346<dt>cb</dt>
2347<dd class="description">Callback function</dd>
2348<dt>user_data</dt>
2349<dd class="description">User data pointer</dd>
2350</dl>
2351<h4 class="discussion">Discussion</h4>
aaf19ab0
MS
2352<p class="discussion">Pass <code>NULL</code> to restore the default (console) password callback, which
2353reads the password from the console. Programs should call either this
2354function or <a href="#cupsSetPasswordCB2"><code>cupsSetPasswordCB2</code></a>, as only one callback can be registered
2355by a program per thread.<br>
2356<br>
2357Note: The current password callback is tracked separately for each thread
2358in a program. Multi-threaded programs that override the callback need to do
2359so in each thread for the same callback to be used.
f11a948a
MS
2360
2361</p>
5a738aea 2362<h3 class="function"><a name="cupsSetServer">cupsSetServer</a></h3>
aaf19ab0 2363<p class="description">Set the default server name and port.</p>
5a738aea
MS
2364<p class="code">
2365void cupsSetServer (<br>
2366&nbsp;&nbsp;&nbsp;&nbsp;const char *server<br>
2367);</p>
2368<h4 class="parameters">Parameters</h4>
2369<dl>
2370<dt>server</dt>
2371<dd class="description">Server name</dd>
2372</dl>
2373<h4 class="discussion">Discussion</h4>
2374<p class="discussion">The &quot;server&quot; string can be a fully-qualified hostname, a numeric
aaf19ab0
MS
2375IPv4 or IPv6 address, or a domain socket pathname. Hostnames and numeric IP
2376addresses can be optionally followed by a colon and port number to override
2377the default port 631, e.g. &quot;hostname:8631&quot;. Pass <code>NULL</code> to restore the
2378default server name and port.<br>
2379<br>
2380Note: The current server is tracked separately for each thread in a program.
2381Multi-threaded programs that override the server need to do so in each
2382thread for the same server to be used.</p>
321d8d57 2383<h3 class="function"><span class="info">&nbsp;CUPS 1.5/Mac OS X 10.7&nbsp;</span><a name="cupsSetServerCertCB">cupsSetServerCertCB</a></h3>
10d09e33
MS
2384<p class="description">Set the server certificate callback.</p>
2385<p class="code">
2386void cupsSetServerCertCB (<br>
2387&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_server_cert_cb_t">cups_server_cert_cb_t</a> cb,<br>
2388&nbsp;&nbsp;&nbsp;&nbsp;void *user_data<br>
2389);</p>
2390<h4 class="parameters">Parameters</h4>
2391<dl>
2392<dt>cb</dt>
2393<dd class="description">Callback function</dd>
2394<dt>user_data</dt>
2395<dd class="description">User data pointer</dd>
2396</dl>
2397<h4 class="discussion">Discussion</h4>
2398<p class="discussion">Pass <code>NULL</code> to restore the default callback.<br>
2399<br>
2400Note: The current credentials callback is tracked separately for each thread
2401in a program. Multi-threaded programs that override the callback need to do
2402so in each thread for the same callback to be used.
2403
2404</p>
5a738aea
MS
2405<h3 class="function"><a name="cupsSetUser">cupsSetUser</a></h3>
2406<p class="description">Set the default user name.</p>
2407<p class="code">
2408void cupsSetUser (<br>
2409&nbsp;&nbsp;&nbsp;&nbsp;const char *user<br>
2410);</p>
2411<h4 class="parameters">Parameters</h4>
2412<dl>
2413<dt>user</dt>
2414<dd class="description">User name</dd>
2415</dl>
2416<h4 class="discussion">Discussion</h4>
aaf19ab0
MS
2417<p class="discussion">Pass <code>NULL</code> to restore the default user name.<br>
2418<br>
2419Note: The current user name is tracked separately for each thread in a
2420program. Multi-threaded programs that override the user name need to do so
2421in each thread for the same user name to be used.</p>
178cb736 2422<h3 class="function"><span class="info">&nbsp;CUPS 1.4/Mac OS X 10.6&nbsp;</span><a name="cupsStartDocument">cupsStartDocument</a></h3>
5a738aea
MS
2423<p class="description">Add a document to a job created with cupsCreateJob().</p>
2424<p class="code">
2425http_status_t cupsStartDocument (<br>
2426&nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
2427&nbsp;&nbsp;&nbsp;&nbsp;const char *name,<br>
2428&nbsp;&nbsp;&nbsp;&nbsp;int job_id,<br>
2429&nbsp;&nbsp;&nbsp;&nbsp;const char *docname,<br>
2430&nbsp;&nbsp;&nbsp;&nbsp;const char *format,<br>
2431&nbsp;&nbsp;&nbsp;&nbsp;int last_document<br>
2432);</p>
2433<h4 class="parameters">Parameters</h4>
2434<dl>
2435<dt>http</dt>
568fa3fa 2436<dd class="description">Connection to server or <code>CUPS_HTTP_DEFAULT</code></dd>
5a738aea 2437<dt>name</dt>
568fa3fa 2438<dd class="description">Destination name</dd>
5a738aea
MS
2439<dt>job_id</dt>
2440<dd class="description">Job ID from <a href="#cupsCreateJob"><code>cupsCreateJob</code></a></dd>
2441<dt>docname</dt>
2442<dd class="description">Name of document</dd>
2443<dt>format</dt>
2444<dd class="description">MIME type or <code>CUPS_FORMAT_foo</code></dd>
2445<dt>last_document</dt>
2446<dd class="description">1 for last document in job, 0 otherwise</dd>
2447</dl>
2448<h4 class="returnvalue">Return Value</h4>
2449<p class="description">HTTP status of request</p>
2450<h4 class="discussion">Discussion</h4>
2451<p class="discussion">Use <a href="#cupsWriteRequestData"><code>cupsWriteRequestData</code></a> to write data for the document and
2452<a href="#cupsFinishDocument"><code>cupsFinishDocument</code></a> to finish the document and get the submission status.<br>
2453<br>
2454The MIME type constants <code>CUPS_FORMAT_AUTO</code>, <code>CUPS_FORMAT_PDF</code>,
2455<code>CUPS_FORMAT_POSTSCRIPT</code>, <code>CUPS_FORMAT_RAW</code>, and
2456<code>CUPS_FORMAT_TEXT</code> are provided for the &quot;format&quot; argument, although
2457any supported MIME type string can be supplied.
bc44d920 2458
5a738aea
MS
2459</p>
2460<h3 class="function"><a name="cupsTempFd">cupsTempFd</a></h3>
2461<p class="description">Creates a temporary file.</p>
2462<p class="code">
2463int cupsTempFd (<br>
2464&nbsp;&nbsp;&nbsp;&nbsp;char *filename,<br>
2465&nbsp;&nbsp;&nbsp;&nbsp;int len<br>
2466);</p>
2467<h4 class="parameters">Parameters</h4>
2468<dl>
2469<dt>filename</dt>
2470<dd class="description">Pointer to buffer</dd>
2471<dt>len</dt>
2472<dd class="description">Size of buffer</dd>
2473</dl>
2474<h4 class="returnvalue">Return Value</h4>
2475<p class="description">New file descriptor or -1 on error</p>
2476<h4 class="discussion">Discussion</h4>
2477<p class="discussion">The temporary filename is returned in the filename buffer.
2478The temporary file is opened for reading and writing.</p>
2479<h3 class="function"><span class="info">&nbsp;DEPRECATED&nbsp;</span><a name="cupsTempFile">cupsTempFile</a></h3>
2480<p class="description">Generates a temporary filename.</p>
2481<p class="code">
2482char *cupsTempFile (<br>
2483&nbsp;&nbsp;&nbsp;&nbsp;char *filename,<br>
2484&nbsp;&nbsp;&nbsp;&nbsp;int len<br>
2485);</p>
2486<h4 class="parameters">Parameters</h4>
2487<dl>
2488<dt>filename</dt>
2489<dd class="description">Pointer to buffer</dd>
2490<dt>len</dt>
2491<dd class="description">Size of buffer</dd>
2492</dl>
2493<h4 class="returnvalue">Return Value</h4>
568fa3fa 2494<p class="description">Filename or <code>NULL</code> on error</p>
5a738aea
MS
2495<h4 class="discussion">Discussion</h4>
2496<p class="discussion">The temporary filename is returned in the filename buffer.
2497This function is deprecated - use <a href="#cupsTempFd"><code>cupsTempFd</code></a> or
2498<a href="#cupsTempFile2"><code>cupsTempFile2</code></a> instead.
ef416fc2 2499
5a738aea 2500</p>
426c6a59 2501<h3 class="function"><span class="info">&nbsp;CUPS 1.2/Mac OS X 10.5&nbsp;</span><a name="cupsTempFile2">cupsTempFile2</a></h3>
5a738aea
MS
2502<p class="description">Creates a temporary CUPS file.</p>
2503<p class="code">
2504cups_file_t *cupsTempFile2 (<br>
2505&nbsp;&nbsp;&nbsp;&nbsp;char *filename,<br>
2506&nbsp;&nbsp;&nbsp;&nbsp;int len<br>
2507);</p>
2508<h4 class="parameters">Parameters</h4>
2509<dl>
2510<dt>filename</dt>
2511<dd class="description">Pointer to buffer</dd>
2512<dt>len</dt>
2513<dd class="description">Size of buffer</dd>
2514</dl>
2515<h4 class="returnvalue">Return Value</h4>
568fa3fa 2516<p class="description">CUPS file or <code>NULL</code> on error</p>
5a738aea
MS
2517<h4 class="discussion">Discussion</h4>
2518<p class="discussion">The temporary filename is returned in the filename buffer.
2519The temporary file is opened for writing.
bc44d920 2520
5a738aea
MS
2521</p>
2522<h3 class="function"><a name="cupsUser">cupsUser</a></h3>
2523<p class="description">Return the current user's name.</p>
2524<p class="code">
2525const char *cupsUser (void);</p>
2526<h4 class="returnvalue">Return Value</h4>
2527<p class="description">User name</p>
aaf19ab0
MS
2528<h4 class="discussion">Discussion</h4>
2529<p class="discussion">Note: The current user name is tracked separately for each thread in a
2530program. Multi-threaded programs that override the user name with the
2531<a href="#cupsSetUser"><code>cupsSetUser</code></a> function need to do so in each thread for the same user
2532name to be used.</p>
5a738aea 2533<h2 class="title"><a name="TYPES">Data Types</a></h2>
321d8d57 2534<h3 class="typedef"><span class="info">&nbsp;CUPS 1.5/Mac OS X 10.7&nbsp;</span><a name="cups_client_cert_cb_t">cups_client_cert_cb_t</a></h3>
3e7fe0ca
MS
2535<p class="description">Client credentials callback
2536</p>
10d09e33
MS
2537<p class="code">
2538typedef int (*cups_client_cert_cb_t)(http_t *http, void *tls, cups_array_t *distinguished_names, void *user_data);
2539</p>
3e7fe0ca
MS
2540<h3 class="typedef"><span class="info">&nbsp;CUPS 1.6&nbsp;</span><a name="cups_dest_block_t">cups_dest_block_t</a></h3>
2541<p class="description">Destination enumeration block
2542</p>
2543<p class="code">
2544typedef int (*cups_dest_block_t(unsigned flags, <a href="#cups_dest_t">cups_dest_t</a> *dest);
2545</p>
2546<h3 class="typedef"><span class="info">&nbsp;CUPS 1.6&nbsp;</span><a name="cups_dest_cb_t">cups_dest_cb_t</a></h3>
2547<p class="description">Destination enumeration callback
2548</p>
2549<p class="code">
2550typedef int (*cups_dest_cb_t)(void *user_data, unsigned flags, <a href="#cups_dest_t">cups_dest_t</a> *dest);
2551</p>
5a738aea
MS
2552<h3 class="typedef"><a name="cups_dest_t">cups_dest_t</a></h3>
2553<p class="description">Destination</p>
2554<p class="code">
2555typedef struct <a href="#cups_dest_s">cups_dest_s</a> cups_dest_t;
2556</p>
178cb736 2557<h3 class="typedef"><span class="info">&nbsp;CUPS 1.4/Mac OS X 10.6&nbsp;</span><a name="cups_device_cb_t">cups_device_cb_t</a></h3>
3e7fe0ca
MS
2558<p class="description">Device callback
2559</p>
ae71f5de 2560<p class="code">
06d4e77b 2561typedef void (*cups_device_cb_t)(const char *device_class, const char *device_id, const char *device_info, const char *device_make_and_model, const char *device_uri, const char *device_location, void *user_data);
ae71f5de 2562</p>
3e7fe0ca
MS
2563<h3 class="typedef"><span class="info">&nbsp;CUPS 1.6&nbsp;</span><a name="cups_dinfo_t">cups_dinfo_t</a></h3>
2564<p class="description">Destination capability and status
2565information </p>
2566<p class="code">
2567typedef struct _cups_dinfo_s cups_dinfo_t;
2568</p>
5a738aea
MS
2569<h3 class="typedef"><a name="cups_job_t">cups_job_t</a></h3>
2570<p class="description">Job</p>
2571<p class="code">
2572typedef struct <a href="#cups_job_s">cups_job_s</a> cups_job_t;
2573</p>
2574<h3 class="typedef"><a name="cups_option_t">cups_option_t</a></h3>
2575<p class="description">Printer Options</p>
2576<p class="code">
2577typedef struct <a href="#cups_option_s">cups_option_s</a> cups_option_t;
2578</p>
178cb736 2579<h3 class="typedef"><span class="info">&nbsp;CUPS 1.4/Mac OS X 10.6&nbsp;</span><a name="cups_password_cb2_t">cups_password_cb2_t</a></h3>
3e7fe0ca
MS
2580<p class="description">New password callback
2581</p>
f11a948a
MS
2582<p class="code">
2583typedef const char *(*cups_password_cb2_t)(const char *prompt, http_t *http, const char *method, const char *resource, void *user_data);
2584</p>
5a738aea
MS
2585<h3 class="typedef"><a name="cups_password_cb_t">cups_password_cb_t</a></h3>
2586<p class="description">Password callback</p>
2587<p class="code">
ae71f5de 2588typedef const char *(*cups_password_cb_t)(const char *prompt);
5a738aea
MS
2589</p>
2590<h3 class="typedef"><a name="cups_ptype_t">cups_ptype_t</a></h3>
2591<p class="description">Printer type/capability bits</p>
2592<p class="code">
ef416fc2 2593typedef unsigned cups_ptype_t;
5a738aea 2594</p>
321d8d57 2595<h3 class="typedef"><span class="info">&nbsp;CUPS 1.5/Mac OS X 10.7&nbsp;</span><a name="cups_server_cert_cb_t">cups_server_cert_cb_t</a></h3>
3e7fe0ca
MS
2596<p class="description">Server credentials callback
2597</p>
10d09e33
MS
2598<p class="code">
2599typedef int (*cups_server_cert_cb_t)(http_t *http, void *tls, cups_array_t *certs, void *user_data);
2600</p>
3e7fe0ca
MS
2601<h3 class="typedef"><span class="info">&nbsp;CUPS 1.6&nbsp;</span><a name="cups_size_t">cups_size_t</a></h3>
2602<p class="description">Media Size </p>
2603<p class="code">
2604typedef struct <a href="#cups_size_s">cups_size_s</a> cups_size_t;
2605</p>
5a738aea
MS
2606<h2 class="title"><a name="STRUCTURES">Structures</a></h2>
2607<h3 class="struct"><a name="cups_dest_s">cups_dest_s</a></h3>
2608<p class="description">Destination</p>
2609<p class="code">struct cups_dest_s {<br>
2610&nbsp;&nbsp;&nbsp;&nbsp;char *name, *instance;<br>
2611&nbsp;&nbsp;&nbsp;&nbsp;int is_default;<br>
2612&nbsp;&nbsp;&nbsp;&nbsp;int num_options;<br>
2613&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_option_t">cups_option_t</a> *options;<br>
2614};</p>
2615<h4 class="members">Members</h4>
2616<dl>
2617<dt>instance </dt>
2618<dd class="description">Local instance name or NULL</dd>
2619<dt>is_default </dt>
2620<dd class="description">Is this printer the default?</dd>
2621<dt>num_options </dt>
2622<dd class="description">Number of options</dd>
2623<dt>options </dt>
2624<dd class="description">Options</dd>
2625</dl>
2626<h3 class="struct"><a name="cups_job_s">cups_job_s</a></h3>
2627<p class="description">Job</p>
2628<p class="code">struct cups_job_s {<br>
2629&nbsp;&nbsp;&nbsp;&nbsp;time_t completed_time;<br>
2630&nbsp;&nbsp;&nbsp;&nbsp;time_t creation_time;<br>
2631&nbsp;&nbsp;&nbsp;&nbsp;char *dest;<br>
2632&nbsp;&nbsp;&nbsp;&nbsp;char *format;<br>
2633&nbsp;&nbsp;&nbsp;&nbsp;int id;<br>
2634&nbsp;&nbsp;&nbsp;&nbsp;int priority;<br>
2635&nbsp;&nbsp;&nbsp;&nbsp;time_t processing_time;<br>
2636&nbsp;&nbsp;&nbsp;&nbsp;int size;<br>
2637&nbsp;&nbsp;&nbsp;&nbsp;ipp_jstate_t state;<br>
2638&nbsp;&nbsp;&nbsp;&nbsp;char *title;<br>
2639&nbsp;&nbsp;&nbsp;&nbsp;char *user;<br>
2640};</p>
2641<h4 class="members">Members</h4>
2642<dl>
2643<dt>completed_time </dt>
2644<dd class="description">Time the job was completed</dd>
2645<dt>creation_time </dt>
2646<dd class="description">Time the job was created</dd>
2647<dt>dest </dt>
2648<dd class="description">Printer or class name</dd>
2649<dt>format </dt>
2650<dd class="description">Document format</dd>
2651<dt>id </dt>
2652<dd class="description">The job ID</dd>
2653<dt>priority </dt>
2654<dd class="description">Priority (1-100)</dd>
2655<dt>processing_time </dt>
2656<dd class="description">Time the job was processed</dd>
2657<dt>size </dt>
2658<dd class="description">Size in kilobytes</dd>
2659<dt>state </dt>
2660<dd class="description">Job state</dd>
2661<dt>title </dt>
2662<dd class="description">Title/job name</dd>
2663<dt>user </dt>
2664<dd class="description">User the submitted the job</dd>
2665</dl>
2666<h3 class="struct"><a name="cups_option_s">cups_option_s</a></h3>
2667<p class="description">Printer Options</p>
2668<p class="code">struct cups_option_s {<br>
2669&nbsp;&nbsp;&nbsp;&nbsp;char *name;<br>
2670&nbsp;&nbsp;&nbsp;&nbsp;char *value;<br>
2671};</p>
2672<h4 class="members">Members</h4>
2673<dl>
2674<dt>name </dt>
2675<dd class="description">Name of option</dd>
2676<dt>value </dt>
2677<dd class="description">Value of option</dd>
2678</dl>
3e7fe0ca
MS
2679<h3 class="struct"><span class="info">&nbsp;CUPS 1.6&nbsp;</span><a name="cups_size_s">cups_size_s</a></h3>
2680<p class="description">Media Size </p>
2681<p class="code">struct cups_size_s {<br>
2682&nbsp;&nbsp;&nbsp;&nbsp;char media[128];<br>
2683&nbsp;&nbsp;&nbsp;&nbsp;int width, length, bottom, left, right, top;<br>
2684};</p>
2685<h4 class="members">Members</h4>
2686<dl>
2687<dt>media[128] </dt>
2688<dd class="description">Media name to use</dd>
2689<dt>top </dt>
2690<dd class="description">Top margin in hundredths of
2691millimeters</dd>
2692</dl>
22c9029b
MS
2693<h2 class="title"><a name="VARIABLES">Variables</a></h2>
2694<h3 class="variable"><a name="CF_RETURNS_RETAINED">CF_RETURNS_RETAINED</a></h3>
2695<p class="description">Get the Apple language identifier associated with a
2696locale ID.</p>
2697<p class="code">const char *locale) CF_RETURNS_RETAINED;</p>
5a738aea
MS
2698<h2 class="title"><a name="ENUMERATIONS">Constants</a></h2>
2699<h3 class="enumeration"><a name="cups_ptype_e">cups_ptype_e</a></h3>
3e7fe0ca
MS
2700<p class="description">Printer type/capability bit
2701constants</p>
5a738aea
MS
2702<h4 class="constants">Constants</h4>
2703<dl>
426c6a59 2704<dt>CUPS_PRINTER_AUTHENTICATED <span class="info">&nbsp;CUPS 1.2/Mac OS X 10.5&nbsp;</span></dt>
3e7fe0ca
MS
2705<dd class="description">Printer requires authentication
2706</dd>
5a738aea
MS
2707<dt>CUPS_PRINTER_BIND </dt>
2708<dd class="description">Can bind output</dd>
2709<dt>CUPS_PRINTER_BW </dt>
2710<dd class="description">Can do B&amp;W printing</dd>
2711<dt>CUPS_PRINTER_CLASS </dt>
2712<dd class="description">Printer class</dd>
2713<dt>CUPS_PRINTER_COLLATE </dt>
2714<dd class="description">Can collage copies</dd>
2715<dt>CUPS_PRINTER_COLOR </dt>
2716<dd class="description">Can do color printing</dd>
426c6a59 2717<dt>CUPS_PRINTER_COMMANDS <span class="info">&nbsp;CUPS 1.2/Mac OS X 10.5&nbsp;</span></dt>
3e7fe0ca
MS
2718<dd class="description">Printer supports maintenance commands
2719</dd>
5a738aea
MS
2720<dt>CUPS_PRINTER_COPIES </dt>
2721<dd class="description">Can do copies</dd>
2722<dt>CUPS_PRINTER_COVER </dt>
2723<dd class="description">Can cover output</dd>
2724<dt>CUPS_PRINTER_DEFAULT </dt>
2725<dd class="description">Default printer on network</dd>
426c6a59 2726<dt>CUPS_PRINTER_DELETE <span class="info">&nbsp;CUPS 1.2/Mac OS X 10.5&nbsp;</span></dt>
3e7fe0ca
MS
2727<dd class="description">Delete printer
2728</dd>
5a738aea
MS
2729<dt>CUPS_PRINTER_DUPLEX </dt>
2730<dd class="description">Can do duplexing</dd>
2731<dt>CUPS_PRINTER_FAX </dt>
2732<dd class="description">Fax queue</dd>
5a738aea
MS
2733<dt>CUPS_PRINTER_LARGE </dt>
2734<dd class="description">Can do D/E/A1/A0</dd>
2735<dt>CUPS_PRINTER_LOCAL </dt>
2736<dd class="description">Local printer or class</dd>
2737<dt>CUPS_PRINTER_MEDIUM </dt>
2738<dd class="description">Can do Tabloid/B/C/A3/A2</dd>
178cb736 2739<dt>CUPS_PRINTER_MFP <span class="info">&nbsp;CUPS 1.4/Mac OS X 10.6&nbsp;</span></dt>
3e7fe0ca
MS
2740<dd class="description">Printer with scanning capabilities
2741</dd>
426c6a59 2742<dt>CUPS_PRINTER_NOT_SHARED <span class="info">&nbsp;CUPS 1.2/Mac OS X 10.5&nbsp;</span></dt>
3e7fe0ca
MS
2743<dd class="description">Printer is not shared
2744</dd>
5a738aea
MS
2745<dt>CUPS_PRINTER_PUNCH </dt>
2746<dd class="description">Can punch output</dd>
2747<dt>CUPS_PRINTER_REJECTING </dt>
2748<dd class="description">Printer is rejecting jobs</dd>
2749<dt>CUPS_PRINTER_REMOTE </dt>
2750<dd class="description">Remote printer or class</dd>
178cb736 2751<dt>CUPS_PRINTER_SCANNER <span class="info">&nbsp;CUPS 1.4/Mac OS X 10.6&nbsp;</span></dt>
3e7fe0ca
MS
2752<dd class="description">Scanner-only device
2753</dd>
5a738aea
MS
2754<dt>CUPS_PRINTER_SMALL </dt>
2755<dd class="description">Can do Letter/Legal/A4</dd>
2756<dt>CUPS_PRINTER_SORT </dt>
2757<dd class="description">Can sort output</dd>
2758<dt>CUPS_PRINTER_STAPLE </dt>
2759<dd class="description">Can staple output</dd>
2760<dt>CUPS_PRINTER_VARIABLE </dt>
2761<dd class="description">Can do variable sizes</dd>
2762</dl>
2763</div>
ef416fc2 2764</body>
2765</html>