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