1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
3 <!-- SECTION: Programming -->
5 <title>CUPS API
</title>
6 <meta name=
"keywords" content=
"Programming">
7 <meta name=
"creator" content=
"Mini-XML v2.5">
8 <style type=
"text/css"><!--
10 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
13 H1, H2, H3, H4, H5, H6, P, TD, TH {
14 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
18 font-family: monaco, courier, monospace;
23 font-family: monaco, courier, monospace;
32 border: dotted thin #999999;
37 PRE.command EM, PRE.example EM {
38 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
42 font-family: monaco, courier, monospace;
53 border: solid thin #999999;
59 text-decoration: none;
62 A:link:hover, A:visited:hover, A:active {
63 text-decoration: underline;
71 border: solid thin #999999;
72 border-collapse: collapse;
88 border: solid thin #cccccc;
95 border-bottom: solid thin #999999;
104 caption-side: bottom;
124 border: thin solid #000000;
132 H2 SPAN.info, H3 SPAN.info, H4 SPAN.info {
138 border-bottom: solid 2pt #000000;
156 font-family: monaco, courier, monospace;
165 border: solid thin #999999;
166 border-collapse: collapse;
171 DIV.summary TABLE TD, DIV.summary TABLE TH {
172 border: solid thin #999999;
178 DIV.summary TABLE THEAD TH {
182 /* API documentation styles... */
189 div.body h3, div.body h4, div.body h5 {
190 margin-bottom: 0.5em;
193 .class, .enumeration, .function, .struct, .typedef, .union {
194 border-bottom: solid thin #999999;
201 code, p.code, pre, ul.code li {
202 font-family: monaco, courier, monospace;
205 ul.code, ul.contents, ul.subcontents {
206 list-style-type: none;
216 ul.contents li ul.code, ul.contents li ul.subcontents {
229 margin-bottom: 0.5em;
232 /* This is just for the HTML files generated with the framedhelp target */
235 border: solid thin black;
244 div.contents ul.contents {
247 div.contents ul.subcontents li {
256 "$Id: api-cups.header 7279 2008-01-31 01:50:44Z mike $"
258 CUPS API header for the Common UNIX Printing System (CUPS).
260 Copyright 2008 by Apple Inc.
262 These coded instructions, statements, and computer programs are the
263 property of Apple Inc. and are protected by Federal copyright
264 law. Distribution and use rights are outlined in the file "LICENSE.txt"
265 which should have been included with this file. If this file is
266 file is missing or damaged, see the license at "http://www.cups.org/".
269 <h1 class=
"title">CUPS API
</h1>
271 <div class='summary'
><table summary='General Information'
>
285 <td>Programming:
<a href='api-overview.html' target='_top'
>Introduction to CUPS Programming
</a><br>
286 Programming:
<a href='api-array.html' target='_top'
>Array API
</a><br>
287 Programming:
<a href='api-filedir.html' target='_top'
>File and Directory APIs
</a><br>
288 Programming:
<a href='api-filter.html' target='_top'
>Filter and Backend Programming
</a><br>
289 Programming:
<a href='api-httpipp.html' target='_top'
>HTTP and IPP APIs
</a><br>
290 Programming:
<a href='api-ppd.html' target='_top'
>PPD API
</a><br>
291 Programming:
<a href='api-raster.html' target='_top'
>Raster API
</a></td>
295 <h2 class=
"title">Contents
</h2>
296 <ul class=
"contents">
298 <li><a href=
"#OVERVIEW">Overview
</a><ul class=
"subcontents">
299 <li><a href=
"#CLIENTS_AND_SERVERS">Clients and Servers
</a></li>
300 <li><a href=
"#PRINTERS_AND_CLASSES">Printers and Classes
</a></li>
301 <li><a href=
"#OPTIONS">Options
</a></li>
302 <li><a href=
"#PRINT_JOBS">Print Jobs
</a></li>
303 <li><a href=
"#ERROR_HANDLING">Error Handling
</a></li>
304 <li><a href=
"#PASSWORDS_AND_AUTHENTICATION">Passwords and Authentication
</a></li>
306 <li><a href=
"#FUNCTIONS">Functions
</a><ul class=
"code">
307 <li><a href=
"#cupsAddDest" title=
"Add a destination to the list of destinations.">cupsAddDest
</a></li>
308 <li><a href=
"#cupsAddOption" title=
"Add an option to an option array.">cupsAddOption
</a></li>
309 <li><a href=
"#cupsCancelJob" title=
"Cancel a print job on the default server.">cupsCancelJob
</a></li>
310 <li><a href=
"#cupsCancelJob2" title=
"Cancel or purge a print job.">cupsCancelJob2
</a></li>
311 <li><a href=
"#cupsCreateJob" title=
"Create an empty job for streaming.">cupsCreateJob
</a></li>
312 <li><a href=
"#cupsEncryption" title=
"Get the default encryption settings.">cupsEncryption
</a></li>
313 <li><a href=
"#cupsFinishDocument" title=
"Finish sending a document.">cupsFinishDocument
</a></li>
314 <li><a href=
"#cupsFreeDests" title=
"Free the memory used by the list of destinations.">cupsFreeDests
</a></li>
315 <li><a href=
"#cupsFreeJobs" title=
"Free memory used by job data.">cupsFreeJobs
</a></li>
316 <li><a href=
"#cupsFreeOptions" title=
"Free all memory used by options.">cupsFreeOptions
</a></li>
317 <li><a href=
"#cupsGetClasses" title=
"Get a list of printer classes from the default server.">cupsGetClasses
</a></li>
318 <li><a href=
"#cupsGetDefault" title=
"Get the default printer or class for the default server.">cupsGetDefault
</a></li>
319 <li><a href=
"#cupsGetDefault2" title=
"Get the default printer or class for the specified server.">cupsGetDefault2
</a></li>
320 <li><a href=
"#cupsGetDest" title=
"Get the named destination from the list.">cupsGetDest
</a></li>
321 <li><a href=
"#cupsGetDests" title=
"Get the list of destinations from the default server.">cupsGetDests
</a></li>
322 <li><a href=
"#cupsGetDests2" title=
"Get the list of destinations from the specified server.">cupsGetDests2
</a></li>
323 <li><a href=
"#cupsGetFd" title=
"Get a file from the server.">cupsGetFd
</a></li>
324 <li><a href=
"#cupsGetFile" title=
"Get a file from the server.">cupsGetFile
</a></li>
325 <li><a href=
"#cupsGetJobs" title=
"Get the jobs from the default server.">cupsGetJobs
</a></li>
326 <li><a href=
"#cupsGetJobs2" title=
"Get the jobs from the specified server.">cupsGetJobs2
</a></li>
327 <li><a href=
"#cupsGetNamedDest" title=
"Get options for the named destination.">cupsGetNamedDest
</a></li>
328 <li><a href=
"#cupsGetOption" title=
"Get an option value.">cupsGetOption
</a></li>
329 <li><a href=
"#cupsGetPPD" title=
"Get the PPD file for a printer on the default server.">cupsGetPPD
</a></li>
330 <li><a href=
"#cupsGetPPD2" title=
"Get the PPD file for a printer from the specified server.">cupsGetPPD2
</a></li>
331 <li><a href=
"#cupsGetPPD3" title=
"Get the PPD file for a printer on the specified
332 server if it has changed.">cupsGetPPD3
</a></li>
333 <li><a href=
"#cupsGetPassword" title=
"Get a password from the user.">cupsGetPassword
</a></li>
334 <li><a href=
"#cupsGetPrinters" title=
"Get a list of printers from the default server.">cupsGetPrinters
</a></li>
335 <li><a href=
"#cupsGetServerPPD" title=
"Get an available PPD file from the server.">cupsGetServerPPD
</a></li>
336 <li><a href=
"#cupsLangDefault" title=
"Return the default language.">cupsLangDefault
</a></li>
337 <li><a href=
"#cupsLangEncoding" title=
"Return the character encoding (us-ascii, etc.)
338 for the given language.">cupsLangEncoding
</a></li>
339 <li><a href=
"#cupsLangFlush" title=
"Flush all language data out of the cache.">cupsLangFlush
</a></li>
340 <li><a href=
"#cupsLangFree" title=
"Free language data.">cupsLangFree
</a></li>
341 <li><a href=
"#cupsLangGet" title=
"Get a language.">cupsLangGet
</a></li>
342 <li><a href=
"#cupsLastError" title=
"Return the last IPP status code.">cupsLastError
</a></li>
343 <li><a href=
"#cupsLastErrorString" title=
"Return the last IPP status-message.">cupsLastErrorString
</a></li>
344 <li><a href=
"#cupsNotifySubject" title=
"Return the subject for the given notification message.">cupsNotifySubject
</a></li>
345 <li><a href=
"#cupsNotifyText" title=
"Return the text for the given notification message.">cupsNotifyText
</a></li>
346 <li><a href=
"#cupsParseOptions" title=
"Parse options from a command-line argument.">cupsParseOptions
</a></li>
347 <li><a href=
"#cupsPrintFile" title=
"Print a file to a printer or class on the default server.">cupsPrintFile
</a></li>
348 <li><a href=
"#cupsPrintFile2" title=
"Print a file to a printer or class on the specified
349 server.">cupsPrintFile2
</a></li>
350 <li><a href=
"#cupsPrintFiles" title=
"Print one or more files to a printer or class on the
351 default server.">cupsPrintFiles
</a></li>
352 <li><a href=
"#cupsPrintFiles2" title=
"Print one or more files to a printer or class on the
353 specified server.">cupsPrintFiles2
</a></li>
354 <li><a href=
"#cupsPutFd" title=
"Put a file on the server.">cupsPutFd
</a></li>
355 <li><a href=
"#cupsPutFile" title=
"Put a file on the server.">cupsPutFile
</a></li>
356 <li><a href=
"#cupsRemoveDest" title=
"Remove a destination from the destination list.">cupsRemoveDest
</a></li>
357 <li><a href=
"#cupsRemoveOption" title=
"Remove an option from an option array.">cupsRemoveOption
</a></li>
358 <li><a href=
"#cupsServer" title=
"Return the hostname/address of the default server.">cupsServer
</a></li>
359 <li><a href=
"#cupsSetDefaultDest" title=
"Set the default destination.">cupsSetDefaultDest
</a></li>
360 <li><a href=
"#cupsSetDests" title=
"Save the list of destinations for the default server.">cupsSetDests
</a></li>
361 <li><a href=
"#cupsSetDests2" title=
"Save the list of destinations for the specified server.">cupsSetDests2
</a></li>
362 <li><a href=
"#cupsSetEncryption" title=
"Set the encryption preference.">cupsSetEncryption
</a></li>
363 <li><a href=
"#cupsSetPasswordCB" title=
"Set the password callback for CUPS.">cupsSetPasswordCB
</a></li>
364 <li><a href=
"#cupsSetServer" title=
"Set the default server name.">cupsSetServer
</a></li>
365 <li><a href=
"#cupsSetUser" title=
"Set the default user name.">cupsSetUser
</a></li>
366 <li><a href=
"#cupsStartDocument" title=
"Add a document to a job created with cupsCreateJob().">cupsStartDocument
</a></li>
367 <li><a href=
"#cupsTempFd" title=
"Creates a temporary file.">cupsTempFd
</a></li>
368 <li><a href=
"#cupsTempFile" title=
"Generates a temporary filename.">cupsTempFile
</a></li>
369 <li><a href=
"#cupsTempFile2" title=
"Creates a temporary CUPS file.">cupsTempFile2
</a></li>
370 <li><a href=
"#cupsUser" title=
"Return the current user's name.">cupsUser
</a></li>
372 <li><a href=
"#TYPES">Data Types
</a><ul class=
"code">
373 <li><a href=
"#cups_dest_t" title=
"Destination">cups_dest_t
</a></li>
374 <li><a href=
"#cups_job_t" title=
"Job">cups_job_t
</a></li>
375 <li><a href=
"#cups_option_t" title=
"Printer Options">cups_option_t
</a></li>
376 <li><a href=
"#cups_password_cb_t" title=
"Password callback">cups_password_cb_t
</a></li>
377 <li><a href=
"#cups_ptype_t" title=
"Printer type/capability bits">cups_ptype_t
</a></li>
379 <li><a href=
"#STRUCTURES">Structures
</a><ul class=
"code">
380 <li><a href=
"#cups_dest_s" title=
"Destination">cups_dest_s
</a></li>
381 <li><a href=
"#cups_job_s" title=
"Job">cups_job_s
</a></li>
382 <li><a href=
"#cups_option_s" title=
"Printer Options">cups_option_s
</a></li>
384 <li><a href=
"#ENUMERATIONS">Constants
</a><ul class=
"code">
385 <li><a href=
"#cups_ptype_e" title=
"Printer type/capability bit constants">cups_ptype_e
</a></li>
389 "$Id: api-cups.shtml 7337 2008-02-22 04:44:04Z mike $"
391 CUPS API introduction for the Common UNIX Printing System (CUPS).
393 Copyright 2007-2008 by Apple Inc.
394 Copyright 1997-2006 by Easy Software Products, all rights reserved.
396 These coded instructions, statements, and computer programs are the
397 property of Apple Inc. and are protected by Federal copyright
398 law. Distribution and use rights are outlined in the file "LICENSE.txt"
399 which should have been included with this file. If this file is
400 file is missing or damaged, see the license at "http://www.cups.org/".
403 <h2 class='title'
><a name='OVERVIEW'
>Overview
</a></h2>
405 <p>The CUPS API provides the convenience functions needed to support
406 applications, filters, printer drivers, and backends that need to interface
407 with the CUPS scheduler.
</p>
409 <h3><a name='CLIENTS_AND_SERVERS'
>Clients and Servers
</a></h3>
411 <p>CUPS is based on the Internet Printing Protocol (
"IPP"), which allows
412 clients (applications) to communicate with a server (the scheduler) to get a
413 list of printers, send print jobs, and so forth. You identify which server
414 you want to communicate with using a pointer to the opaque structure
415 <code>http_t
</code>. All of the examples in this document use the
416 <code>CUPS_HTTP_DEFAULT
</code> constant, referring to the default connection
417 to the scheduler. The
<a href='api-httpipp.html' target='_top'
>HTTP and IPP
418 APIs
</a> document provides more information on server connections.
</p>
420 <h3><a name='PRINTERS_AND_CLASSES'
>Printers and Classes
</a></h3>
422 <p>Printers and classes (collections of printers) are accessed through
423 the
<a href=
"#cups_dest_t"><code>cups_dest_t
</code></a> structure which
424 includes the name (
<code>name
</code>), instance (
<code>instance
</code> -
425 a way of selecting certain saved options/settings), and the options and
426 attributes associated with that destination (
<code>num_options
</code> and
427 <code>options
</code>). Destinations are created using the
428 <a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> function and freed
429 using the
<a href='#cupsFreeDests'
><code>cupsFreeDests
</code></a> function.
430 The
<a href='#cupsGetDest'
><code>cupsGetDest
</code></a> function finds a
431 specific destination for printing:
</p>
433 <pre class='example'
>
434 #include
<cups/cups.h
>
436 <a href='#cups_dest_t'
>cups_dest_t
</a> *dests;
437 int num_dests =
<a href='#cupsGetDests'
>cupsGetDests
</a>(
&dests);
438 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest =
<a href='#cupsGetDest'
>cupsGetDest
</a>(
"name", NULL, num_dests, dests);
440 /* do something wiith dest */
442 <a href='#cupsFreeDests'
>cupsFreeDests
</a>(num_dests, dests);
445 <p>Passing
<code>NULL
</code> to
446 <a href='#cupsGetDest'
><code>cupsGetDest
</code></a> for the destination name
447 will return the default destination. Similarly, passing a
<code>NULL
</code>
448 instance will return the default instance for that destination.
</p>
450 <div class='table'
><table summary='Table
1: Printer Attributes' width='
80%'
>
451 <caption>Table
1:
<a name='TABLE1'
>Printer Attributes
</a></caption>
454 <th>Attribute Name
</th>
460 <td>"auth-info-required"</td>
461 <td>The type of authentication required for printing to this
462 destination:
"none",
"username,password",
"domain,username,password",
463 or
"negotiate" (Kerberos)
</td>
466 <td>"printer-info"</td>
467 <td>The human-readable description of the destination such as
"My
471 <td>"printer-is-accepting-jobs"</td>
472 <td>"1" if the destination is accepting new jobs,
"0" if not.
</td>
475 <td>"printer-is-shared"</td>
476 <td>"1" if the destination is being shared with other computers,
"0" if
480 <td>"printer-location"</td>
481 <td>The human-readable location of the destination such as
"Lab 4".
</td>
484 <td>"printer-make-and-model"</td>
485 <td>The human-readable make and model of the destination such as
"HP
486 LaserJet 4000 Series".
</td>
489 <td>"printer-state"</td>
490 <td>"3" if the destination is idle,
"4" if the destination is printing
491 a job, and
"5" if the destination is stopped.
</td>
494 <td>"printer-state-change-time"</td>
495 <td>The UNIX time when the destination entered the current state.
</td>
498 <td>"printer-state-reasons"</td>
499 <td>Additional comma-delimited state keywords for the destination
500 such as
"media-tray-empty-error" and
"toner-low-warning".
</td>
503 <td>"printer-type"</td>
504 <td>The
<a href='#cups_printer_t'
><code>cups_printer_t
</code></a>
505 value associated with the destination.
</td>
510 <h3><a name='OPTIONS'
>Options
</a></h3>
512 <p>Options are stored in arrays of
513 <a href='#cups_option_t'
><code>cups_option_t
</code></a> structures. Each
514 option has a name (
<code>name
</code>) and value (
<code>value
</code>)
515 associated with it. The
<a href='#cups_dest_t'
><code>cups_dest_t
</code></a>
516 <code>num_options
</code> and
<code>options
</code> members contain the
517 default options for a particular destination, along with several informational
518 attributes about the destination as shown in
<a href='#TABLE1'
>Table
1</a>.
519 The
<a href='#cupsGetOption'
><code>cupsGetOption
</code></a> function gets
520 the value for the named option. For example, the following code lists the
521 available destinations and their human-readable descriptions:
</p>
523 <pre class='example'
>
524 #include
<cups/cups.h
>
526 <a href='#cups_dest_t'
>cups_dest_t
</a> *dests;
527 int num_dests =
<a href='#cupsGetDests'
>cupsGetDests
</a>(
&dests);
528 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
532 for (i = num_dests, dest = dests; i
> 0; i --, dest ++)
533 if (dest-
>instance == NULL)
535 value =
<a href='#cupsGetOption'
>cupsGetOption
</a>(
"printer-info", dest-
>num_options, dest-
>options);
536 printf(
"%s (%s)\n", dest-
>name, value ? value :
"no description");
539 <a href='#cupsFreeDests'
>cupsFreeDests
</a>(num_dests, dests);
542 <p>You can create your own option arrays using the
543 <a href='#cupsAddOption'
><code>cupsAddOption
</code></a> function, which
544 adds a single named option to an array:
</p>
546 <pre class='example'
>
547 #include
<cups/cups.h
>
550 <a href='#cups_option_t'
>cups_option_t
</a> *options = NULL;
552 /* The returned num_options value is updated as needed */
553 num_options =
<a href='#cupsAddOption'
>cupsAddOption
</a>(
"first",
"value", num_options,
&options);
555 /* This adds a second option value */
556 num_options =
<a href='#cupsAddOption'
>cupsAddOption
</a>(
"second",
"value", num_options,
&options);
558 /* This replaces the first option we added */
559 num_options =
<a href='#cupsAddOption'
>cupsAddOption
</a>(
"first",
"new value", num_options,
&options);
562 <p>Use a
<code>for
</code> loop to copy the options from a destination:
</p>
564 <pre class='example'
>
565 #include
<cups/cups.h
>
569 <a href='#cups_option_t'
>cups_option_t
</a> *options = NULL;
570 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
572 for (i =
0; i < dest-
>num_options; i ++)
573 num_options =
<a href='#cupsAddOption'
>cupsAddOption
</a>(dest-
>options[i].name, dest-
>options[i].value,
574 num_options,
&options);
577 <p>Use the
<a href='#cupsFreeOptions'
><code>cupsFreeOptions
</code></a>
578 function to free the options array when you are done using it:
</p>
580 <pre class='example'
>
581 <a href='#cupsFreeOptions'
>cupsFreeOptions
</a>(num_options, options);
584 <h3><a name='PRINT_JOBS'
>Print Jobs
</a></h3>
586 <p>Print jobs are identified by a locally-unique job ID number from
1 to
587 2<sup>31</sup>-
1 and have options and one or more files for printing to a
588 single destination. The
<a href='#cupsPrintFile'
><code>cupsPrintFile
</code></a>
589 function creates a new job with one file. The following code prints the CUPS
592 <pre class='example'
>
593 #include
<cups/cups.h
>
595 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
597 <a href='#cups_option_t'
>cups_option_t
</a> *options;
600 /* Print a single file */
601 job_id =
<a href='#cupsPrintFile'
>cupsPrintFile
</a>(dest-
>name,
"/usr/share/cups/data/testprint.ps",
602 "Test Print", num_options, options);
605 <p>The
<a href='#cupsPrintFiles'
><code>cupsPrintFiles
</code></a> function
606 creates a job with multiple files. The files are provided in a
607 <code>char *
</code> array:
</p>
609 <pre class='example'
>
610 #include
<cups/cups.h
>
612 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
614 <a href='#cups_option_t'
>cups_option_t
</a> *options;
616 char *files[
3] = {
"file1.pdf",
"file2.pdf",
"file3.pdf" };
618 /* Print three files */
619 job_id =
<a href='#cupsPrintFiles'
>cupsPrintFiles
</a>(dest-
>name,
3, files,
"Test Print", num_options, options);
622 <p>Finally, the
<a href='#cupsCreateJob'
><code>cupsCreateJob
</code></a>
623 function creates a new job with no files in it. Files are added using the
624 <a href='#cupsStartDocument'
><code>cupsStartDocument
</code></a>,
625 <a href='api-httpipp.html#cupsWriteRequestData'
><code>cupsWriteRequestData
</code></a>,
626 and
<a href='#cupsFinishDocument'
><code>cupsFinishDocument
</code></a> functions.
627 The following example creates a job with
10 text files for printing:
</p>
629 <pre class='example'
>
630 #include
<cups/cups.h
>
632 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
634 <a href='#cups_option_t'
>cups_option_t
</a> *options;
640 job_id =
<a href='#cupsCreateJob'
>cupsCreateJob
</a>(CUPS_HTTP_DEFAULT, dest-
>name,
"10 Text Files",
641 num_options, options);
643 /* If the job is created, add
10 files */
646 for (i =
1; i
<=
10; i ++)
648 snprintf(buffer, sizeof(buffer),
"file%d.txt", i);
650 <a href='#cupsStartDocument'
>cupsStartDocument
</a>(CUPS_HTTP_DEFAULT, dest-
>name, job_id, buffer,
651 CUPS_FORMAT_TEXT, i ==
10);
653 snprintf(buffer, sizeof(buffer),
661 /* cupsWriteRequestData can be called as many times as needed */
662 <a href='#cupsWriteRequestData'
>cupsWriteRequestData
</a>(CUPS_HTTP_DEFAULT, buffer, strlen(buffer));
664 <a href='#cupsFinishDocument'
>cupsFinishDocument
</a>(CUPS_HTTP_DEFAULT, dest-
>name);
669 <p>Once you have created a job, you can monitor its status using the
670 <a href='#cupsGetJobs'
><code>cupsGetJobs
</code></a> function, which returns
671 an array of
<a href='#cups_job_t'
><code>cups_job_t
</code></a> structures.
672 Each contains the job ID (
<code>id
</code>), destination name
673 (
<code>dest
</code>), title (
<code>title
</code>), and other information
674 associated with the job. The job array is freed using the
675 <a href='#cupsFreeJobs'
><code>cupsFreeJobs
</code></a> function. The following
676 example monitors a specific job ID, showing the current job state once every
677 5 seconds until the job is completed:
</p>
679 <pre class='example'
>
680 #include
<cups/cups.h
>
682 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
685 <a href='#cups_job_t'
>cups_job_t
</a> *jobs;
687 ipp_jstate_t job_state = IPP_JOB_PENDING;
689 while (job_state
< IPP_JOB_STOPPED)
691 /* Get my jobs (
1) with any state (-
1) */
692 num_jobs =
<a href='#cupsGetJobs'
>cupsGetJobs
</a>(
&jobs, dest-
>name,
1, -
1);
694 /* Loop to find my job */
695 job_state = IPP_JOB_COMPLETED;
697 for (i =
0; i
< num_jobs; i ++)
698 if (jobs[i].id == job_id)
700 job_state = jobs[i].state;
704 /* Free the job array */
705 <a href='#cupsFreeJobs'
>cupsFreeJobs
</a>(num_jobs, jobs);
707 /* Show the current state */
710 case IPP_JOB_PENDING :
711 printf(
"Job %d is pending.\n", job_id);
714 printf(
"Job %d is held.\n", job_id);
716 case IPP_JOB_PROCESSING :
717 printf(
"Job %d is processing.\n", job_id);
719 case IPP_JOB_STOPPED :
720 printf(
"Job %d is stopped.\n", job_id);
722 case IPP_JOB_CANCELED :
723 printf(
"Job %d is canceled.\n", job_id);
725 case IPP_JOB_ABORTED :
726 printf(
"Job %d is aborted.\n", job_id);
728 case IPP_JOB_COMPLETED :
729 printf(
"Job %d is completed.\n", job_id);
733 /* Sleep if the job is not finished */
734 if (job_state
< IPP_JOB_STOPPED)
739 <p>To cancel a job, use the
740 <a href='#cupsCancelJob'
><code>cupsCancelJob
</code></a> function with the
743 <pre class='example'
>
744 #include
<cups/cups.h
>
746 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
749 <a href='#cupsCancelJob'
>cupsCancelJob
</a>(dest-
>name, job_id);
752 <h3><a name='ERROR_HANDLING'
>Error Handling
</a></h3>
754 <p>If any of the CUPS API printing functions returns an error, the reason for
755 that error can be found by calling the
756 <a href='#cupsLastError'
><code>cupsLastError
</code></a> and
757 <a href='#cupsLastErrorString'
><code>cupsLastErrorString
</code></a> functions.
758 <a href='#cupsLastError'
><code>cupsLastError
</code></a> returns the last IPP
760 (
<a href='api-httpipp.html#ipp_status_t'
><code>ipp_status_t
</code></a>)
761 that was encountered, while
762 <a href='#cupsLastErrorString'
><code>cupsLastErrorString
</code></a> returns
763 a (localized) human-readable string that can be shown to the user. For example,
764 if any of the job creation functions returns a job ID of
0, you can use
765 <a href='#cupsLastErrorString'
><code>cupsLastErrorString
</code></a> to show
766 the reason why the job could not be created:
</p>
768 <pre class='example'
>
769 #include
<cups/cups.h
>
774 puts(cupsLastErrorString());
777 <h3><a name='PASSWORDS_AND_AUTHENTICATION'
>Passwords and Authentication
</a></h3>
779 <p>CUPS supports authentication of any request, including submission of print
780 jobs. The default mechanism for getting the username and password is to use the
781 login user and a password from the console.
</p>
783 <p>To support other types of applications, in particular Graphical User
784 Interfaces (
"GUIs"), the CUPS API provides functions to set the default
785 username and to register a callback function that returns a password string.
</p>
787 <p>The
<a href=
"#cupsSetPasswordCB"><code>cupsSetPasswordCB
</code></a>
788 function is used to set a password callback in your program. Only one
789 function can be used at any time.
</p>
791 <p>The
<a href=
"#cupsSetUser"><code>cupsSetUser
</code></a> function sets the
792 current username for authentication. This function can be called by your
793 password callback function to change the current username as needed.
</p>
795 <p>The following example shows a simple password callback that gets a
796 username and password from the user:
</p>
798 <pre class='example'
>
799 #include
<cups/cups.h
>
802 my_password_cb(const char *prompt)
809 /* Get a username from the user */
810 printf(
"Username: ");
811 if (fgets(user, sizeof(user), stdin) == NULL)
814 /* Strip the newline from the string and set the user */
815 user[strlen(user) -
1] = '\
0';
817 <a href='#cupsSetUser'
>cupsSetUser
</a>(user);
819 /* Use getpass() to ask for the password... */
820 return (getpass(
"Password: "));
823 <a href='#cupsSetPasswordCB'
>cupsSetPasswordCB
</a>(my_password_cb);
826 <p>Similarly, a GUI could display the prompt string in a window with input
827 fields for the username and password. The username should default to the
828 string returned by the
<a href=
"#cupsUser"><code>cupsUser
</code></a>
830 <h2 class=
"title"><a name=
"FUNCTIONS">Functions
</a></h2>
831 <h3 class=
"function"><a name=
"cupsAddDest">cupsAddDest
</a></h3>
832 <p class=
"description">Add a destination to the list of destinations.
</p>
834 int cupsAddDest (
<br>
835 const char *name,
<br>
836 const char *instance,
<br>
837 int num_dests,
<br>
838 <a href=
"#cups_dest_t">cups_dest_t
</a> **dests
<br>
840 <h4 class=
"parameters">Parameters
</h4>
843 <dd class=
"description">Destination name
</dd>
845 <dd class=
"description">Instance name or
<code>NULL
</code> for none/primary
</dd>
847 <dd class=
"description">Number of destinations
</dd>
849 <dd class=
"description">Destinations
</dd>
851 <h4 class=
"returnvalue">Return Value
</h4>
852 <p class=
"description">New number of destinations
</p>
853 <h4 class=
"discussion">Discussion
</h4>
854 <p class=
"discussion">This function cannot be used to add a new class or printer queue,
855 it only adds a new container of saved options for the named
856 destination or instance.
<br>
858 If the named destination already exists, the destination list is
859 returned unchanged. Adding a new instance of a destination creates
860 a copy of that destination's options.
<br>
862 Use the
<a href=
"#cupsSaveDests"><code>cupsSaveDests
</code></a> function to save the updated list of
863 destinations to the user's lpoptions file.
</p>
864 <h3 class=
"function"><a name=
"cupsAddOption">cupsAddOption
</a></h3>
865 <p class=
"description">Add an option to an option array.
</p>
867 int cupsAddOption (
<br>
868 const char *name,
<br>
869 const char *value,
<br>
870 int num_options,
<br>
871 <a href=
"#cups_option_t">cups_option_t
</a> **options
<br>
873 <h4 class=
"parameters">Parameters
</h4>
876 <dd class=
"description">Name of option
</dd>
878 <dd class=
"description">Value of option
</dd>
880 <dd class=
"description">Number of options
</dd>
882 <dd class=
"description">Pointer to options
</dd>
884 <h4 class=
"returnvalue">Return Value
</h4>
885 <p class=
"description">Number of options
</p>
886 <h4 class=
"discussion">Discussion
</h4>
887 <p class=
"discussion">New option arrays can be initialized simply by passing
0 for the
888 "num_options
" parameter.
</p>
889 <h3 class=
"function"><a name=
"cupsCancelJob">cupsCancelJob
</a></h3>
890 <p class=
"description">Cancel a print job on the default server.
</p>
892 int cupsCancelJob (
<br>
893 const char *name,
<br>
894 int job_id
<br>
896 <h4 class=
"parameters">Parameters
</h4>
899 <dd class=
"description">Name of printer or class
</dd>
901 <dd class=
"description">Job ID,
<code>CUPS_JOBID_CURRENT
</code> for the current job, or
<code>CUPS_JOBID_ALL
</code> for all jobs
</dd>
903 <h4 class=
"returnvalue">Return Value
</h4>
904 <p class=
"description">1 on success,
0 on failure
</p>
905 <h4 class=
"discussion">Discussion
</h4>
906 <p class=
"discussion">Pass
<code>CUPS_JOBID_ALL
</code> to cancel all jobs or
<code>CUPS_JOBID_CURRENT
</code>
907 to cancel the current job on the named destination.
<br>
909 Use the
<a href=
"#cupsLastError"><code>cupsLastError
</code></a> and
<a href=
"#cupsLastErrorString"><code>cupsLastErrorString
</code></a> functions to get
910 the cause of any failure.
</p>
911 <h3 class=
"function"><span class=
"info"> CUPS
1.4 </span><a name=
"cupsCancelJob2">cupsCancelJob2
</a></h3>
912 <p class=
"description">Cancel or purge a print job.
</p>
914 ipp_status_t cupsCancelJob2 (
<br>
915 http_t *http,
<br>
916 const char *name,
<br>
917 int job_id,
<br>
918 int purge
<br>
920 <h4 class=
"parameters">Parameters
</h4>
923 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
925 <dd class=
"description">Name of printer or class
</dd>
927 <dd class=
"description">Job ID,
<code>CUPS_JOBID_CURRENT
</code> for the current job, or
<code>CUPS_JOBID_ALL
</code> for all jobs
</dd>
929 <dd class=
"description">1 to purge,
0 to cancel
</dd>
931 <h4 class=
"returnvalue">Return Value
</h4>
932 <p class=
"description">IPP status
</p>
933 <h4 class=
"discussion">Discussion
</h4>
934 <p class=
"discussion">Canceled jobs remain in the job history while purged jobs are removed
935 from the job history.
<br>
937 Pass
<code>CUPS_JOBID_ALL
</code> to cancel all jobs or
<code>CUPS_JOBID_CURRENT
</code>
938 to cancel the current job on the named destination.
<br>
940 Use the
<a href=
"#cupsLastError"><code>cupsLastError
</code></a> and
<a href=
"#cupsLastErrorString"><code>cupsLastErrorString
</code></a> functions to get
941 the cause of any failure.
944 <h3 class=
"function"><span class=
"info"> CUPS
1.4 </span><a name=
"cupsCreateJob">cupsCreateJob
</a></h3>
945 <p class=
"description">Create an empty job for streaming.
</p>
947 int cupsCreateJob (
<br>
948 http_t *http,
<br>
949 const char *name,
<br>
950 const char *title,
<br>
951 int num_options,
<br>
952 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
954 <h4 class=
"parameters">Parameters
</h4>
957 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
959 <dd class=
"description">Destination name
</dd>
961 <dd class=
"description">Title of job
</dd>
963 <dd class=
"description">Number of options
</dd>
965 <dd class=
"description">Options
</dd>
967 <h4 class=
"returnvalue">Return Value
</h4>
968 <p class=
"description">Job ID or
0 on error
</p>
969 <h4 class=
"discussion">Discussion
</h4>
970 <p class=
"discussion">Use this function when you want to stream print data using the
971 <a href=
"#cupsStartDocument"><code>cupsStartDocument
</code></a>,
<a href=
"#cupsWriteRequestData"><code>cupsWriteRequestData
</code></a>, and
972 <a href=
"#cupsFinishDocument"><code>cupsFinishDocument
</code></a> functions. If you have one or more files to
973 print, use the
<a href=
"#cupsPrintFile2"><code>cupsPrintFile2
</code></a> or
<a href=
"#cupsPrintFiles2"><code>cupsPrintFiles2
</code></a> function
977 <h3 class=
"function"><a name=
"cupsEncryption">cupsEncryption
</a></h3>
978 <p class=
"description">Get the default encryption settings.
</p>
980 http_encryption_t cupsEncryption (void);
</p>
981 <h4 class=
"returnvalue">Return Value
</h4>
982 <p class=
"description">Encryption settings
</p>
983 <h4 class=
"discussion">Discussion
</h4>
984 <p class=
"discussion">The default encryption setting comes from the CUPS_ENCRYPTION
985 environment variable, then the ~/.cups/client.conf file, and finally the
986 /etc/cups/client.conf file. If not set, the default is
987 <code>HTTP_ENCRYPT_IF_REQUESTED
</code>.
</p>
988 <h3 class=
"function"><span class=
"info"> CUPS
1.4 </span><a name=
"cupsFinishDocument">cupsFinishDocument
</a></h3>
989 <p class=
"description">Finish sending a document.
</p>
991 ipp_status_t cupsFinishDocument (
<br>
992 http_t *http,
<br>
993 const char *name
<br>
995 <h4 class=
"parameters">Parameters
</h4>
998 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1000 <dd class=
"description">Destination name
</dd>
1002 <h4 class=
"returnvalue">Return Value
</h4>
1003 <p class=
"description">Status of document submission
</p>
1004 <h4 class=
"discussion">Discussion
</h4>
1005 <p class=
"discussion">The document must have been started using
<a href=
"#cupsStartDocument"><code>cupsStartDocument
</code></a>.
1008 <h3 class=
"function"><a name=
"cupsFreeDests">cupsFreeDests
</a></h3>
1009 <p class=
"description">Free the memory used by the list of destinations.
</p>
1011 void cupsFreeDests (
<br>
1012 int num_dests,
<br>
1013 <a href=
"#cups_dest_t">cups_dest_t
</a> *dests
<br>
1015 <h4 class=
"parameters">Parameters
</h4>
1018 <dd class=
"description">Number of destinations
</dd>
1020 <dd class=
"description">Destinations
</dd>
1022 <h3 class=
"function"><a name=
"cupsFreeJobs">cupsFreeJobs
</a></h3>
1023 <p class=
"description">Free memory used by job data.
</p>
1025 void cupsFreeJobs (
<br>
1026 int num_jobs,
<br>
1027 <a href=
"#cups_job_t">cups_job_t
</a> *jobs
<br>
1029 <h4 class=
"parameters">Parameters
</h4>
1032 <dd class=
"description">Number of jobs
</dd>
1034 <dd class=
"description">Jobs
</dd>
1036 <h3 class=
"function"><a name=
"cupsFreeOptions">cupsFreeOptions
</a></h3>
1037 <p class=
"description">Free all memory used by options.
</p>
1039 void cupsFreeOptions (
<br>
1040 int num_options,
<br>
1041 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1043 <h4 class=
"parameters">Parameters
</h4>
1045 <dt>num_options
</dt>
1046 <dd class=
"description">Number of options
</dd>
1048 <dd class=
"description">Pointer to options
</dd>
1050 <h3 class=
"function"><span class=
"info"> DEPRECATED
</span><a name=
"cupsGetClasses">cupsGetClasses
</a></h3>
1051 <p class=
"description">Get a list of printer classes from the default server.
</p>
1053 int cupsGetClasses (
<br>
1054 char ***classes
<br>
1056 <h4 class=
"parameters">Parameters
</h4>
1059 <dd class=
"description">Classes
</dd>
1061 <h4 class=
"returnvalue">Return Value
</h4>
1062 <p class=
"description">Number of classes
</p>
1063 <h4 class=
"discussion">Discussion
</h4>
1064 <p class=
"discussion">This function is deprecated - use
<a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> instead.
1067 <h3 class=
"function"><a name=
"cupsGetDefault">cupsGetDefault
</a></h3>
1068 <p class=
"description">Get the default printer or class for the default server.
</p>
1070 const char *cupsGetDefault (void);
</p>
1071 <h4 class=
"returnvalue">Return Value
</h4>
1072 <p class=
"description">Default printer or
<code>NULL
</code></p>
1073 <h4 class=
"discussion">Discussion
</h4>
1074 <p class=
"discussion">This function returns the default printer or class as defined by
1075 the LPDEST or PRINTER environment variables. If these environment
1076 variables are not set, the server default destination is returned.
1077 Applications should use the
<a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> and
<a href=
"#cupsGetDest"><code>cupsGetDest
</code></a>
1078 functions to get the user-defined default printer, as this function does
1079 not support the lpoptions-defined default printer.
</p>
1080 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21 </span><a name=
"cupsGetDefault2">cupsGetDefault2
</a></h3>
1081 <p class=
"description">Get the default printer or class for the specified server.
</p>
1083 const char *cupsGetDefault2 (
<br>
1084 http_t *http
<br>
1086 <h4 class=
"parameters">Parameters
</h4>
1089 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1091 <h4 class=
"returnvalue">Return Value
</h4>
1092 <p class=
"description">Default printer or
<code>NULL
</code></p>
1093 <h4 class=
"discussion">Discussion
</h4>
1094 <p class=
"discussion">This function returns the default printer or class as defined by
1095 the LPDEST or PRINTER environment variables. If these environment
1096 variables are not set, the server default destination is returned.
1097 Applications should use the
<a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> and
<a href=
"#cupsGetDest"><code>cupsGetDest
</code></a>
1098 functions to get the user-defined default printer, as this function does
1099 not support the lpoptions-defined default printer.
1102 <h3 class=
"function"><a name=
"cupsGetDest">cupsGetDest
</a></h3>
1103 <p class=
"description">Get the named destination from the list.
</p>
1105 <a href=
"#cups_dest_t">cups_dest_t
</a> *cupsGetDest (
<br>
1106 const char *name,
<br>
1107 const char *instance,
<br>
1108 int num_dests,
<br>
1109 <a href=
"#cups_dest_t">cups_dest_t
</a> *dests
<br>
1111 <h4 class=
"parameters">Parameters
</h4>
1114 <dd class=
"description">Destination name or
<code>NULL
</code> for the default destination
</dd>
1116 <dd class=
"description">Instance name or
<code>NULL
</code></dd>
1118 <dd class=
"description">Number of destinations
</dd>
1120 <dd class=
"description">Destinations
</dd>
1122 <h4 class=
"returnvalue">Return Value
</h4>
1123 <p class=
"description">Destination pointer or
<code>NULL
</code></p>
1124 <h4 class=
"discussion">Discussion
</h4>
1125 <p class=
"discussion">Use the
<a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> or
<a href=
"#cupsGetDests2"><code>cupsGetDests2
</code></a> functions to get a
1126 list of supported destinations for the current user.
</p>
1127 <h3 class=
"function"><a name=
"cupsGetDests">cupsGetDests
</a></h3>
1128 <p class=
"description">Get the list of destinations from the default server.
</p>
1130 int cupsGetDests (
<br>
1131 <a href=
"#cups_dest_t">cups_dest_t
</a> **dests
<br>
1133 <h4 class=
"parameters">Parameters
</h4>
1136 <dd class=
"description">Destinations
</dd>
1138 <h4 class=
"returnvalue">Return Value
</h4>
1139 <p class=
"description">Number of destinations
</p>
1140 <h4 class=
"discussion">Discussion
</h4>
1141 <p class=
"discussion">Starting with CUPS
1.2, the returned list of destinations include the
1142 printer-info, printer-is-accepting-jobs, printer-is-shared,
1143 printer-make-and-model, printer-state, printer-state-change-time,
1144 printer-state-reasons, and printer-type attributes as options.
<br>
1146 Use the
<a href=
"#cupsFreeDests"><code>cupsFreeDests
</code></a> function to free the destination list and
1147 the
<a href=
"#cupsGetDest"><code>cupsGetDest
</code></a> function to find a particular destination.
</p>
1148 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21 </span><a name=
"cupsGetDests2">cupsGetDests2
</a></h3>
1149 <p class=
"description">Get the list of destinations from the specified server.
</p>
1151 int cupsGetDests2 (
<br>
1152 http_t *http,
<br>
1153 <a href=
"#cups_dest_t">cups_dest_t
</a> **dests
<br>
1155 <h4 class=
"parameters">Parameters
</h4>
1158 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1160 <dd class=
"description">Destinations
</dd>
1162 <h4 class=
"returnvalue">Return Value
</h4>
1163 <p class=
"description">Number of destinations
</p>
1164 <h4 class=
"discussion">Discussion
</h4>
1165 <p class=
"discussion">Starting with CUPS
1.2, the returned list of destinations include the
1166 printer-info, printer-is-accepting-jobs, printer-is-shared,
1167 printer-make-and-model, printer-state, printer-state-change-time,
1168 printer-state-reasons, and printer-type attributes as options.
<br>
1170 Use the
<a href=
"#cupsFreeDests"><code>cupsFreeDests
</code></a> function to free the destination list and
1171 the
<a href=
"#cupsGetDest"><code>cupsGetDest
</code></a> function to find a particular destination.
1174 <h3 class=
"function"><span class=
"info"> CUPS
1.1.20 </span><a name=
"cupsGetFd">cupsGetFd
</a></h3>
1175 <p class=
"description">Get a file from the server.
</p>
1177 http_status_t cupsGetFd (
<br>
1178 http_t *http,
<br>
1179 const char *resource,
<br>
1180 int fd
<br>
1182 <h4 class=
"parameters">Parameters
</h4>
1185 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1187 <dd class=
"description">Resource name
</dd>
1189 <dd class=
"description">File descriptor
</dd>
1191 <h4 class=
"returnvalue">Return Value
</h4>
1192 <p class=
"description">HTTP status
</p>
1193 <h4 class=
"discussion">Discussion
</h4>
1194 <p class=
"discussion">This function returns
<code>HTTP_OK
</code> when the file is successfully retrieved.
1197 <h3 class=
"function"><span class=
"info"> CUPS
1.1.20 </span><a name=
"cupsGetFile">cupsGetFile
</a></h3>
1198 <p class=
"description">Get a file from the server.
</p>
1200 http_status_t cupsGetFile (
<br>
1201 http_t *http,
<br>
1202 const char *resource,
<br>
1203 const char *filename
<br>
1205 <h4 class=
"parameters">Parameters
</h4>
1208 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1210 <dd class=
"description">Resource name
</dd>
1212 <dd class=
"description">Filename
</dd>
1214 <h4 class=
"returnvalue">Return Value
</h4>
1215 <p class=
"description">HTTP status
</p>
1216 <h4 class=
"discussion">Discussion
</h4>
1217 <p class=
"discussion">This function returns
<code>HTTP_OK
</code> when the file is successfully retrieved.
1220 <h3 class=
"function"><a name=
"cupsGetJobs">cupsGetJobs
</a></h3>
1221 <p class=
"description">Get the jobs from the default server.
</p>
1223 int cupsGetJobs (
<br>
1224 <a href=
"#cups_job_t">cups_job_t
</a> **jobs,
<br>
1225 const char *name,
<br>
1226 int myjobs,
<br>
1227 int whichjobs
<br>
1229 <h4 class=
"parameters">Parameters
</h4>
1232 <dd class=
"description">Job data
</dd>
1234 <dd class=
"description"><code>NULL
</code> = all destinations, otherwise show jobs for named destination
</dd>
1236 <dd class=
"description">0 = all users,
1 = mine
</dd>
1238 <dd class=
"description"><code>CUPS_WHICHJOBS_ALL
</code>,
<code>CUPS_WHICHJOBS_ACTIVE
</code>, or
<code>CUPS_WHICHJOBS_COMPLETED
</code></dd>
1240 <h4 class=
"returnvalue">Return Value
</h4>
1241 <p class=
"description">Number of jobs
</p>
1242 <h4 class=
"discussion">Discussion
</h4>
1243 <p class=
"discussion">A
"whichjobs
" value of
<code>CUPS_WHICHJOBS_ALL
</code> returns all jobs regardless
1244 of state, while
<code>CUPS_WHICHJOBS_ACTIVE
</code> returns jobs that are
1245 pending, processing, or held and
<code>CUPS_WHICHJOBS_COMPLETED
</code> returns
1246 jobs that are stopped, canceled, aborted, or completed.
</p>
1247 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21 </span><a name=
"cupsGetJobs2">cupsGetJobs2
</a></h3>
1248 <p class=
"description">Get the jobs from the specified server.
</p>
1250 int cupsGetJobs2 (
<br>
1251 http_t *http,
<br>
1252 <a href=
"#cups_job_t">cups_job_t
</a> **jobs,
<br>
1253 const char *name,
<br>
1254 int myjobs,
<br>
1255 int whichjobs
<br>
1257 <h4 class=
"parameters">Parameters
</h4>
1260 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1262 <dd class=
"description">Job data
</dd>
1264 <dd class=
"description"><code>NULL
</code> = all destinations, otherwise show jobs for named destination
</dd>
1266 <dd class=
"description">0 = all users,
1 = mine
</dd>
1268 <dd class=
"description"><code>CUPS_WHICHJOBS_ALL
</code>,
<code>CUPS_WHICHJOBS_ACTIVE
</code>, or
<code>CUPS_WHICHJOBS_COMPLETED
</code></dd>
1270 <h4 class=
"returnvalue">Return Value
</h4>
1271 <p class=
"description">Number of jobs
</p>
1272 <h4 class=
"discussion">Discussion
</h4>
1273 <p class=
"discussion">A
"whichjobs
" value of
<code>CUPS_WHICHJOBS_ALL
</code> returns all jobs regardless
1274 of state, while
<code>CUPS_WHICHJOBS_ACTIVE
</code> returns jobs that are
1275 pending, processing, or held and
<code>CUPS_WHICHJOBS_COMPLETED
</code> returns
1276 jobs that are stopped, canceled, aborted, or completed.
1279 <h3 class=
"function"><span class=
"info"> CUPS
1.4 </span><a name=
"cupsGetNamedDest">cupsGetNamedDest
</a></h3>
1280 <p class=
"description">Get options for the named destination.
</p>
1282 <a href=
"#cups_dest_t">cups_dest_t
</a> *cupsGetNamedDest (
<br>
1283 http_t *http,
<br>
1284 const char *name,
<br>
1285 const char *instance
<br>
1287 <h4 class=
"parameters">Parameters
</h4>
1290 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1292 <dd class=
"description">Destination name or
<code>NULL
</code> for the default destination
</dd>
1294 <dd class=
"description">Instance name or
<code>NULL
</code></dd>
1296 <h4 class=
"returnvalue">Return Value
</h4>
1297 <p class=
"description">Destination or
<code>NULL
</code></p>
1298 <h4 class=
"discussion">Discussion
</h4>
1299 <p class=
"discussion">This function is optimized for retrieving a single destination and should
1300 be used instead of
<a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> and
<a href=
"#cupsGetDest"><code>cupsGetDest
</code></a> when you either
1301 know the name of the destination or want to print to the default destination.
1302 If
<code>NULL
</code> is returned, the destination does not exist or there is no
1303 default destination.
<br>
1305 If
"http
" is
<code>CUPS_HTTP_DEFAULT
</code>, the connection to the default print
1306 server will be used.
<br>
1308 If
"name
" is
<code>NULL
</code>, the default printer for the current user will be
1311 The returned destination must be freed using
<a href=
"#cupsFreeDests"><code>cupsFreeDests
</code></a> with a
1312 "num_dests
" value of
1.
1315 <h3 class=
"function"><a name=
"cupsGetOption">cupsGetOption
</a></h3>
1316 <p class=
"description">Get an option value.
</p>
1318 const char *cupsGetOption (
<br>
1319 const char *name,
<br>
1320 int num_options,
<br>
1321 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1323 <h4 class=
"parameters">Parameters
</h4>
1326 <dd class=
"description">Name of option
</dd>
1327 <dt>num_options
</dt>
1328 <dd class=
"description">Number of options
</dd>
1330 <dd class=
"description">Options
</dd>
1332 <h4 class=
"returnvalue">Return Value
</h4>
1333 <p class=
"description">Option value or
<code>NULL
</code></p>
1334 <h3 class=
"function"><a name=
"cupsGetPPD">cupsGetPPD
</a></h3>
1335 <p class=
"description">Get the PPD file for a printer on the default server.
</p>
1337 const char *cupsGetPPD (
<br>
1338 const char *name
<br>
1340 <h4 class=
"parameters">Parameters
</h4>
1343 <dd class=
"description">Destination name
</dd>
1345 <h4 class=
"returnvalue">Return Value
</h4>
1346 <p class=
"description">Filename for PPD file
</p>
1347 <h4 class=
"discussion">Discussion
</h4>
1348 <p class=
"discussion">For classes,
<code>cupsGetPPD
</code> returns the PPD file for the first printer
1351 The returned filename is stored in a static buffer and is overwritten with
1352 each call to
<code>cupsGetPPD
</code> or
<a href=
"#cupsGetPPD2"><code>cupsGetPPD2
</code></a>.
</p>
1353 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21 </span><a name=
"cupsGetPPD2">cupsGetPPD2
</a></h3>
1354 <p class=
"description">Get the PPD file for a printer from the specified server.
</p>
1356 const char *cupsGetPPD2 (
<br>
1357 http_t *http,
<br>
1358 const char *name
<br>
1360 <h4 class=
"parameters">Parameters
</h4>
1363 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1365 <dd class=
"description">Destination name
</dd>
1367 <h4 class=
"returnvalue">Return Value
</h4>
1368 <p class=
"description">Filename for PPD file
</p>
1369 <h4 class=
"discussion">Discussion
</h4>
1370 <p class=
"discussion">For classes,
<code>cupsGetPPD2
</code> returns the PPD file for the first printer
1373 The returned filename is stored in a static buffer and is overwritten with
1374 each call to
<a href=
"#cupsGetPPD"><code>cupsGetPPD
</code></a> or
<code>cupsGetPPD2
</code>.
1377 <h3 class=
"function"><span class=
"info"> CUPS
1.4 </span><a name=
"cupsGetPPD3">cupsGetPPD3
</a></h3>
1378 <p class=
"description">Get the PPD file for a printer on the specified
1379 server if it has changed.
</p>
1381 http_status_t cupsGetPPD3 (
<br>
1382 http_t *http,
<br>
1383 const char *name,
<br>
1384 time_t *modtime,
<br>
1385 char *buffer,
<br>
1386 size_t bufsize
<br>
1388 <h4 class=
"parameters">Parameters
</h4>
1391 <dd class=
"description">HTTP connection or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1393 <dd class=
"description">Destination name
</dd>
1395 <dd class=
"description">Modification time
</dd>
1397 <dd class=
"description">Filename buffer
</dd>
1399 <dd class=
"description">Size of filename buffer
</dd>
1401 <h4 class=
"returnvalue">Return Value
</h4>
1402 <p class=
"description">HTTP status
</p>
1403 <h4 class=
"discussion">Discussion
</h4>
1404 <p class=
"discussion">The
"modtime
" parameter contains the modification time of any
1405 locally-cached content and is updated with the time from the PPD file on
1408 The
"buffer
" parameter contains the local PPD filename. If it contains
1409 the empty string, a new temporary file is created, otherwise the existing
1410 file will be overwritten as needed.
<br>
1412 On success,
<code>HTTP_OK
</code> is returned for a new PPD file and
1413 <code>HTTP_NOT_MODIFIED
</code> if the existing PPD file is up-to-date. Any other
1414 status is an error.
<br>
1416 For classes,
<code>cupsGetPPD3
</code> returns the PPD file for the first printer
1420 <h3 class=
"function"><a name=
"cupsGetPassword">cupsGetPassword
</a></h3>
1421 <p class=
"description">Get a password from the user.
</p>
1423 const char *cupsGetPassword (
<br>
1424 const char *prompt
<br>
1426 <h4 class=
"parameters">Parameters
</h4>
1429 <dd class=
"description">Prompt string
</dd>
1431 <h4 class=
"returnvalue">Return Value
</h4>
1432 <p class=
"description">Password
</p>
1433 <h4 class=
"discussion">Discussion
</h4>
1434 <p class=
"discussion">Uses the current password callback function. Returns
<code>NULL
</code> if the
1435 user does not provide a password.
</p>
1436 <h3 class=
"function"><span class=
"info"> DEPRECATED
</span><a name=
"cupsGetPrinters">cupsGetPrinters
</a></h3>
1437 <p class=
"description">Get a list of printers from the default server.
</p>
1439 int cupsGetPrinters (
<br>
1440 char ***printers
<br>
1442 <h4 class=
"parameters">Parameters
</h4>
1445 <dd class=
"description">Printers
</dd>
1447 <h4 class=
"returnvalue">Return Value
</h4>
1448 <p class=
"description">Number of printers
</p>
1449 <h4 class=
"discussion">Discussion
</h4>
1450 <p class=
"discussion">This function is deprecated - use
<a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> instead.
1453 <h3 class=
"function"><span class=
"info"> CUPS
1.3 </span><a name=
"cupsGetServerPPD">cupsGetServerPPD
</a></h3>
1454 <p class=
"description">Get an available PPD file from the server.
</p>
1456 char *cupsGetServerPPD (
<br>
1457 http_t *http,
<br>
1458 const char *name
<br>
1460 <h4 class=
"parameters">Parameters
</h4>
1463 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1465 <dd class=
"description">Name of PPD file (
"ppd-name
")
</dd>
1467 <h4 class=
"returnvalue">Return Value
</h4>
1468 <p class=
"description">Name of PPD file or
<code>NULL
</code> on error
</p>
1469 <h4 class=
"discussion">Discussion
</h4>
1470 <p class=
"discussion">This function returns the named PPD file from the server. The
1471 list of available PPDs is provided by the IPP
<code>CUPS_GET_PPDS
</code>
1474 You must remove (unlink) the PPD file when you are finished with
1475 it. The PPD filename is stored in a static location that will be
1476 overwritten on the next call to
<a href=
"#cupsGetPPD"><code>cupsGetPPD
</code></a>,
<a href=
"#cupsGetPPD2"><code>cupsGetPPD2
</code></a>,
1477 or
<a href=
"#cupsGetServerPPD"><code>cupsGetServerPPD
</code></a>.
1480 <h3 class=
"function"><a name=
"cupsLangDefault">cupsLangDefault
</a></h3>
1481 <p class=
"description">Return the default language.
</p>
1483 cups_lang_t *cupsLangDefault (void);
</p>
1484 <h4 class=
"returnvalue">Return Value
</h4>
1485 <p class=
"description">Language data
</p>
1486 <h3 class=
"function"><a name=
"cupsLangEncoding">cupsLangEncoding
</a></h3>
1487 <p class=
"description">Return the character encoding (us-ascii, etc.)
1488 for the given language.
</p>
1490 const char *cupsLangEncoding (
<br>
1491 cups_lang_t *lang
<br>
1493 <h4 class=
"parameters">Parameters
</h4>
1496 <dd class=
"description">Language data
</dd>
1498 <h4 class=
"returnvalue">Return Value
</h4>
1499 <p class=
"description">Character encoding
</p>
1500 <h3 class=
"function"><a name=
"cupsLangFlush">cupsLangFlush
</a></h3>
1501 <p class=
"description">Flush all language data out of the cache.
</p>
1503 void cupsLangFlush (void);
</p>
1504 <h3 class=
"function"><a name=
"cupsLangFree">cupsLangFree
</a></h3>
1505 <p class=
"description">Free language data.
</p>
1507 void cupsLangFree (
<br>
1508 cups_lang_t *lang
<br>
1510 <h4 class=
"parameters">Parameters
</h4>
1513 <dd class=
"description">Language to free
</dd>
1515 <h4 class=
"discussion">Discussion
</h4>
1516 <p class=
"discussion">This does not actually free anything; use
<a href=
"#cupsLangFlush"><code>cupsLangFlush
</code></a> for that.
</p>
1517 <h3 class=
"function"><a name=
"cupsLangGet">cupsLangGet
</a></h3>
1518 <p class=
"description">Get a language.
</p>
1520 cups_lang_t *cupsLangGet (
<br>
1521 const char *language
<br>
1523 <h4 class=
"parameters">Parameters
</h4>
1526 <dd class=
"description">Language or locale
</dd>
1528 <h4 class=
"returnvalue">Return Value
</h4>
1529 <p class=
"description">Language data
</p>
1530 <h3 class=
"function"><a name=
"cupsLastError">cupsLastError
</a></h3>
1531 <p class=
"description">Return the last IPP status code.
</p>
1533 ipp_status_t cupsLastError (void);
</p>
1534 <h4 class=
"returnvalue">Return Value
</h4>
1535 <p class=
"description">IPP status code from last request
</p>
1536 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsLastErrorString">cupsLastErrorString
</a></h3>
1537 <p class=
"description">Return the last IPP status-message.
</p>
1539 const char *cupsLastErrorString (void);
</p>
1540 <h4 class=
"returnvalue">Return Value
</h4>
1541 <p class=
"description">status-message text from last request
</p>
1542 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsNotifySubject">cupsNotifySubject
</a></h3>
1543 <p class=
"description">Return the subject for the given notification message.
</p>
1545 char *cupsNotifySubject (
<br>
1546 cups_lang_t *lang,
<br>
1547 ipp_t *event
<br>
1549 <h4 class=
"parameters">Parameters
</h4>
1552 <dd class=
"description">Language data
</dd>
1554 <dd class=
"description">Event data
</dd>
1556 <h4 class=
"returnvalue">Return Value
</h4>
1557 <p class=
"description">Subject string or
<code>NULL
</code></p>
1558 <h4 class=
"discussion">Discussion
</h4>
1559 <p class=
"discussion">The returned string must be freed by the caller using
<code>free
</code>.
1562 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsNotifyText">cupsNotifyText
</a></h3>
1563 <p class=
"description">Return the text for the given notification message.
</p>
1565 char *cupsNotifyText (
<br>
1566 cups_lang_t *lang,
<br>
1567 ipp_t *event
<br>
1569 <h4 class=
"parameters">Parameters
</h4>
1572 <dd class=
"description">Language data
</dd>
1574 <dd class=
"description">Event data
</dd>
1576 <h4 class=
"returnvalue">Return Value
</h4>
1577 <p class=
"description">Message text or
<code>NULL
</code></p>
1578 <h4 class=
"discussion">Discussion
</h4>
1579 <p class=
"discussion">The returned string must be freed by the caller using
<code>free
</code>.
1582 <h3 class=
"function"><a name=
"cupsParseOptions">cupsParseOptions
</a></h3>
1583 <p class=
"description">Parse options from a command-line argument.
</p>
1585 int cupsParseOptions (
<br>
1586 const char *arg,
<br>
1587 int num_options,
<br>
1588 <a href=
"#cups_option_t">cups_option_t
</a> **options
<br>
1590 <h4 class=
"parameters">Parameters
</h4>
1593 <dd class=
"description">Argument to parse
</dd>
1594 <dt>num_options
</dt>
1595 <dd class=
"description">Number of options
</dd>
1597 <dd class=
"description">Options found
</dd>
1599 <h4 class=
"returnvalue">Return Value
</h4>
1600 <p class=
"description">Number of options found
</p>
1601 <h4 class=
"discussion">Discussion
</h4>
1602 <p class=
"discussion">This function converts space-delimited name/value pairs according
1603 to the PAPI text option ABNF specification. Collection values
1604 (
"name={a=... b=... c=...}
") are stored with the curley brackets
1605 intact - use
<code>cupsParseOptions
</code> on the value to extract the
1606 collection attributes.
</p>
1607 <h3 class=
"function"><a name=
"cupsPrintFile">cupsPrintFile
</a></h3>
1608 <p class=
"description">Print a file to a printer or class on the default server.
</p>
1610 int cupsPrintFile (
<br>
1611 const char *name,
<br>
1612 const char *filename,
<br>
1613 const char *title,
<br>
1614 int num_options,
<br>
1615 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1617 <h4 class=
"parameters">Parameters
</h4>
1620 <dd class=
"description">Destination name
</dd>
1622 <dd class=
"description">File to print
</dd>
1624 <dd class=
"description">Title of job
</dd>
1625 <dt>num_options
</dt>
1626 <dd class=
"description">Number of options
</dd>
1628 <dd class=
"description">Options
</dd>
1630 <h4 class=
"returnvalue">Return Value
</h4>
1631 <p class=
"description">Job ID or
0 on error
</p>
1632 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21 </span><a name=
"cupsPrintFile2">cupsPrintFile2
</a></h3>
1633 <p class=
"description">Print a file to a printer or class on the specified
1636 int cupsPrintFile2 (
<br>
1637 http_t *http,
<br>
1638 const char *name,
<br>
1639 const char *filename,
<br>
1640 const char *title,
<br>
1641 int num_options,
<br>
1642 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1644 <h4 class=
"parameters">Parameters
</h4>
1647 <dd class=
"description">Connection to server
</dd>
1649 <dd class=
"description">Destination name
</dd>
1651 <dd class=
"description">File to print
</dd>
1653 <dd class=
"description">Title of job
</dd>
1654 <dt>num_options
</dt>
1655 <dd class=
"description">Number of options
</dd>
1657 <dd class=
"description">Options
</dd>
1659 <h4 class=
"returnvalue">Return Value
</h4>
1660 <p class=
"description">Job ID or
0 on error
</p>
1661 <h3 class=
"function"><a name=
"cupsPrintFiles">cupsPrintFiles
</a></h3>
1662 <p class=
"description">Print one or more files to a printer or class on the
1665 int cupsPrintFiles (
<br>
1666 const char *name,
<br>
1667 int num_files,
<br>
1668 const char **files,
<br>
1669 const char *title,
<br>
1670 int num_options,
<br>
1671 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1673 <h4 class=
"parameters">Parameters
</h4>
1676 <dd class=
"description">Destination name
</dd>
1678 <dd class=
"description">Number of files
</dd>
1680 <dd class=
"description">File(s) to print
</dd>
1682 <dd class=
"description">Title of job
</dd>
1683 <dt>num_options
</dt>
1684 <dd class=
"description">Number of options
</dd>
1686 <dd class=
"description">Options
</dd>
1688 <h4 class=
"returnvalue">Return Value
</h4>
1689 <p class=
"description">Job ID or
0 on error
</p>
1690 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21 </span><a name=
"cupsPrintFiles2">cupsPrintFiles2
</a></h3>
1691 <p class=
"description">Print one or more files to a printer or class on the
1692 specified server.
</p>
1694 int cupsPrintFiles2 (
<br>
1695 http_t *http,
<br>
1696 const char *name,
<br>
1697 int num_files,
<br>
1698 const char **files,
<br>
1699 const char *title,
<br>
1700 int num_options,
<br>
1701 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1703 <h4 class=
"parameters">Parameters
</h4>
1706 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1708 <dd class=
"description">Destination name
</dd>
1710 <dd class=
"description">Number of files
</dd>
1712 <dd class=
"description">File(s) to print
</dd>
1714 <dd class=
"description">Title of job
</dd>
1715 <dt>num_options
</dt>
1716 <dd class=
"description">Number of options
</dd>
1718 <dd class=
"description">Options
</dd>
1720 <h4 class=
"returnvalue">Return Value
</h4>
1721 <p class=
"description">Job ID or
0 on error
</p>
1722 <h3 class=
"function"><span class=
"info"> CUPS
1.1.20 </span><a name=
"cupsPutFd">cupsPutFd
</a></h3>
1723 <p class=
"description">Put a file on the server.
</p>
1725 http_status_t cupsPutFd (
<br>
1726 http_t *http,
<br>
1727 const char *resource,
<br>
1728 int fd
<br>
1730 <h4 class=
"parameters">Parameters
</h4>
1733 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1735 <dd class=
"description">Resource name
</dd>
1737 <dd class=
"description">File descriptor
</dd>
1739 <h4 class=
"returnvalue">Return Value
</h4>
1740 <p class=
"description">HTTP status
</p>
1741 <h4 class=
"discussion">Discussion
</h4>
1742 <p class=
"discussion">This function returns
<code>HTTP_CREATED
</code> when the file is stored
1746 <h3 class=
"function"><span class=
"info"> CUPS
1.1.20 </span><a name=
"cupsPutFile">cupsPutFile
</a></h3>
1747 <p class=
"description">Put a file on the server.
</p>
1749 http_status_t cupsPutFile (
<br>
1750 http_t *http,
<br>
1751 const char *resource,
<br>
1752 const char *filename
<br>
1754 <h4 class=
"parameters">Parameters
</h4>
1757 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1759 <dd class=
"description">Resource name
</dd>
1761 <dd class=
"description">Filename
</dd>
1763 <h4 class=
"returnvalue">Return Value
</h4>
1764 <p class=
"description">HTTP status
</p>
1765 <h4 class=
"discussion">Discussion
</h4>
1766 <p class=
"discussion">This function returns
<code>HTTP_CREATED
</code> when the file is stored
1770 <h3 class=
"function"><span class=
"info"> CUPS
1.3 </span><a name=
"cupsRemoveDest">cupsRemoveDest
</a></h3>
1771 <p class=
"description">Remove a destination from the destination list.
</p>
1773 int cupsRemoveDest (
<br>
1774 const char *name,
<br>
1775 const char *instance,
<br>
1776 int num_dests,
<br>
1777 <a href=
"#cups_dest_t">cups_dest_t
</a> **dests
<br>
1779 <h4 class=
"parameters">Parameters
</h4>
1782 <dd class=
"description">Destination name
</dd>
1784 <dd class=
"description">Instance name or
<code>NULL
</code></dd>
1786 <dd class=
"description">Number of destinations
</dd>
1788 <dd class=
"description">Destinations
</dd>
1790 <h4 class=
"returnvalue">Return Value
</h4>
1791 <p class=
"description">New number of destinations
</p>
1792 <h4 class=
"discussion">Discussion
</h4>
1793 <p class=
"discussion">Removing a destination/instance does not delete the class or printer
1794 queue, merely the lpoptions for that destination/instance. Use the
1795 <a href=
"#cupsSetDests"><code>cupsSetDests
</code></a> or
<a href=
"#cupsSetDests2"><code>cupsSetDests2
</code></a> functions to save the new
1796 options for the user.
1799 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsRemoveOption">cupsRemoveOption
</a></h3>
1800 <p class=
"description">Remove an option from an option array.
</p>
1802 int cupsRemoveOption (
<br>
1803 const char *name,
<br>
1804 int num_options,
<br>
1805 <a href=
"#cups_option_t">cups_option_t
</a> **options
<br>
1807 <h4 class=
"parameters">Parameters
</h4>
1810 <dd class=
"description">Option name
</dd>
1811 <dt>num_options
</dt>
1812 <dd class=
"description">Current number of options
</dd>
1814 <dd class=
"description">Options
</dd>
1816 <h4 class=
"returnvalue">Return Value
</h4>
1817 <p class=
"description">New number of options
</p>
1818 <h3 class=
"function"><a name=
"cupsServer">cupsServer
</a></h3>
1819 <p class=
"description">Return the hostname/address of the default server.
</p>
1821 const char *cupsServer (void);
</p>
1822 <h4 class=
"returnvalue">Return Value
</h4>
1823 <p class=
"description">Server name
</p>
1824 <h4 class=
"discussion">Discussion
</h4>
1825 <p class=
"discussion">The returned value can be a fully-qualified hostname, a numeric
1826 IPv4 or IPv6 address, or a domain socket pathname.
</p>
1827 <h3 class=
"function"><span class=
"info"> CUPS
1.3 </span><a name=
"cupsSetDefaultDest">cupsSetDefaultDest
</a></h3>
1828 <p class=
"description">Set the default destination.
</p>
1830 void cupsSetDefaultDest (
<br>
1831 const char *name,
<br>
1832 const char *instance,
<br>
1833 int num_dests,
<br>
1834 <a href=
"#cups_dest_t">cups_dest_t
</a> *dests
<br>
1836 <h4 class=
"parameters">Parameters
</h4>
1839 <dd class=
"description">Destination name
</dd>
1841 <dd class=
"description">Instance name or
<code>NULL
</code></dd>
1843 <dd class=
"description">Number of destinations
</dd>
1845 <dd class=
"description">Destinations
</dd>
1847 <h3 class=
"function"><a name=
"cupsSetDests">cupsSetDests
</a></h3>
1848 <p class=
"description">Save the list of destinations for the default server.
</p>
1850 void cupsSetDests (
<br>
1851 int num_dests,
<br>
1852 <a href=
"#cups_dest_t">cups_dest_t
</a> *dests
<br>
1854 <h4 class=
"parameters">Parameters
</h4>
1857 <dd class=
"description">Number of destinations
</dd>
1859 <dd class=
"description">Destinations
</dd>
1861 <h4 class=
"discussion">Discussion
</h4>
1862 <p class=
"discussion">This function saves the destinations to /etc/cups/lpoptions when run
1863 as root and ~/.cups/lpoptions when run as a normal user.
</p>
1864 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21 </span><a name=
"cupsSetDests2">cupsSetDests2
</a></h3>
1865 <p class=
"description">Save the list of destinations for the specified server.
</p>
1867 int cupsSetDests2 (
<br>
1868 http_t *http,
<br>
1869 int num_dests,
<br>
1870 <a href=
"#cups_dest_t">cups_dest_t
</a> *dests
<br>
1872 <h4 class=
"parameters">Parameters
</h4>
1875 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1877 <dd class=
"description">Number of destinations
</dd>
1879 <dd class=
"description">Destinations
</dd>
1881 <h4 class=
"returnvalue">Return Value
</h4>
1882 <p class=
"description">0 on success, -
1 on error
</p>
1883 <h4 class=
"discussion">Discussion
</h4>
1884 <p class=
"discussion">This function saves the destinations to /etc/cups/lpoptions when run
1885 as root and ~/.cups/lpoptions when run as a normal user.
1888 <h3 class=
"function"><a name=
"cupsSetEncryption">cupsSetEncryption
</a></h3>
1889 <p class=
"description">Set the encryption preference.
</p>
1891 void cupsSetEncryption (
<br>
1892 http_encryption_t e
<br>
1894 <h4 class=
"parameters">Parameters
</h4>
1897 <dd class=
"description">New encryption preference
</dd>
1899 <h3 class=
"function"><a name=
"cupsSetPasswordCB">cupsSetPasswordCB
</a></h3>
1900 <p class=
"description">Set the password callback for CUPS.
</p>
1902 void cupsSetPasswordCB (
<br>
1903 <a href=
"#cups_password_cb_t">cups_password_cb_t
</a> cb
<br>
1905 <h4 class=
"parameters">Parameters
</h4>
1908 <dd class=
"description">Callback function
</dd>
1910 <h4 class=
"discussion">Discussion
</h4>
1911 <p class=
"discussion">Pass
<code>NULL
</code> to restore the default (console) password callback.
</p>
1912 <h3 class=
"function"><a name=
"cupsSetServer">cupsSetServer
</a></h3>
1913 <p class=
"description">Set the default server name.
</p>
1915 void cupsSetServer (
<br>
1916 const char *server
<br>
1918 <h4 class=
"parameters">Parameters
</h4>
1921 <dd class=
"description">Server name
</dd>
1923 <h4 class=
"discussion">Discussion
</h4>
1924 <p class=
"discussion">The
"server
" string can be a fully-qualified hostname, a numeric
1925 IPv4 or IPv6 address, or a domain socket pathname. Pass
<code>NULL
</code> to
1926 restore the default server name.
</p>
1927 <h3 class=
"function"><a name=
"cupsSetUser">cupsSetUser
</a></h3>
1928 <p class=
"description">Set the default user name.
</p>
1930 void cupsSetUser (
<br>
1931 const char *user
<br>
1933 <h4 class=
"parameters">Parameters
</h4>
1936 <dd class=
"description">User name
</dd>
1938 <h4 class=
"discussion">Discussion
</h4>
1939 <p class=
"discussion">Pass
<code>NULL
</code> to restore the default user name.
</p>
1940 <h3 class=
"function"><span class=
"info"> CUPS
1.4 </span><a name=
"cupsStartDocument">cupsStartDocument
</a></h3>
1941 <p class=
"description">Add a document to a job created with cupsCreateJob().
</p>
1943 http_status_t cupsStartDocument (
<br>
1944 http_t *http,
<br>
1945 const char *name,
<br>
1946 int job_id,
<br>
1947 const char *docname,
<br>
1948 const char *format,
<br>
1949 int last_document
<br>
1951 <h4 class=
"parameters">Parameters
</h4>
1954 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1956 <dd class=
"description">Destination name
</dd>
1958 <dd class=
"description">Job ID from
<a href=
"#cupsCreateJob"><code>cupsCreateJob
</code></a></dd>
1960 <dd class=
"description">Name of document
</dd>
1962 <dd class=
"description">MIME type or
<code>CUPS_FORMAT_foo
</code></dd>
1963 <dt>last_document
</dt>
1964 <dd class=
"description">1 for last document in job,
0 otherwise
</dd>
1966 <h4 class=
"returnvalue">Return Value
</h4>
1967 <p class=
"description">HTTP status of request
</p>
1968 <h4 class=
"discussion">Discussion
</h4>
1969 <p class=
"discussion">Use
<a href=
"#cupsWriteRequestData"><code>cupsWriteRequestData
</code></a> to write data for the document and
1970 <a href=
"#cupsFinishDocument"><code>cupsFinishDocument
</code></a> to finish the document and get the submission status.
<br>
1972 The MIME type constants
<code>CUPS_FORMAT_AUTO
</code>,
<code>CUPS_FORMAT_PDF
</code>,
1973 <code>CUPS_FORMAT_POSTSCRIPT
</code>,
<code>CUPS_FORMAT_RAW
</code>, and
1974 <code>CUPS_FORMAT_TEXT
</code> are provided for the
"format
" argument, although
1975 any supported MIME type string can be supplied.
1978 <h3 class=
"function"><a name=
"cupsTempFd">cupsTempFd
</a></h3>
1979 <p class=
"description">Creates a temporary file.
</p>
1981 int cupsTempFd (
<br>
1982 char *filename,
<br>
1983 int len
<br>
1985 <h4 class=
"parameters">Parameters
</h4>
1988 <dd class=
"description">Pointer to buffer
</dd>
1990 <dd class=
"description">Size of buffer
</dd>
1992 <h4 class=
"returnvalue">Return Value
</h4>
1993 <p class=
"description">New file descriptor or -
1 on error
</p>
1994 <h4 class=
"discussion">Discussion
</h4>
1995 <p class=
"discussion">The temporary filename is returned in the filename buffer.
1996 The temporary file is opened for reading and writing.
</p>
1997 <h3 class=
"function"><span class=
"info"> DEPRECATED
</span><a name=
"cupsTempFile">cupsTempFile
</a></h3>
1998 <p class=
"description">Generates a temporary filename.
</p>
2000 char *cupsTempFile (
<br>
2001 char *filename,
<br>
2002 int len
<br>
2004 <h4 class=
"parameters">Parameters
</h4>
2007 <dd class=
"description">Pointer to buffer
</dd>
2009 <dd class=
"description">Size of buffer
</dd>
2011 <h4 class=
"returnvalue">Return Value
</h4>
2012 <p class=
"description">Filename or
<code>NULL
</code> on error
</p>
2013 <h4 class=
"discussion">Discussion
</h4>
2014 <p class=
"discussion">The temporary filename is returned in the filename buffer.
2015 This function is deprecated - use
<a href=
"#cupsTempFd"><code>cupsTempFd
</code></a> or
2016 <a href=
"#cupsTempFile2"><code>cupsTempFile2
</code></a> instead.
2019 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsTempFile2">cupsTempFile2
</a></h3>
2020 <p class=
"description">Creates a temporary CUPS file.
</p>
2022 cups_file_t *cupsTempFile2 (
<br>
2023 char *filename,
<br>
2024 int len
<br>
2026 <h4 class=
"parameters">Parameters
</h4>
2029 <dd class=
"description">Pointer to buffer
</dd>
2031 <dd class=
"description">Size of buffer
</dd>
2033 <h4 class=
"returnvalue">Return Value
</h4>
2034 <p class=
"description">CUPS file or
<code>NULL
</code> on error
</p>
2035 <h4 class=
"discussion">Discussion
</h4>
2036 <p class=
"discussion">The temporary filename is returned in the filename buffer.
2037 The temporary file is opened for writing.
2040 <h3 class=
"function"><a name=
"cupsUser">cupsUser
</a></h3>
2041 <p class=
"description">Return the current user's name.
</p>
2043 const char *cupsUser (void);
</p>
2044 <h4 class=
"returnvalue">Return Value
</h4>
2045 <p class=
"description">User name
</p>
2046 <h2 class=
"title"><a name=
"TYPES">Data Types
</a></h2>
2047 <h3 class=
"typedef"><a name=
"cups_dest_t">cups_dest_t
</a></h3>
2048 <p class=
"description">Destination
</p>
2050 typedef struct
<a href=
"#cups_dest_s">cups_dest_s
</a> cups_dest_t;
2052 <h3 class=
"typedef"><a name=
"cups_job_t">cups_job_t
</a></h3>
2053 <p class=
"description">Job
</p>
2055 typedef struct
<a href=
"#cups_job_s">cups_job_s
</a> cups_job_t;
2057 <h3 class=
"typedef"><a name=
"cups_option_t">cups_option_t
</a></h3>
2058 <p class=
"description">Printer Options
</p>
2060 typedef struct
<a href=
"#cups_option_s">cups_option_s
</a> cups_option_t;
2062 <h3 class=
"typedef"><a name=
"cups_password_cb_t">cups_password_cb_t
</a></h3>
2063 <p class=
"description">Password callback
</p>
2065 typedef const char *(*cups_password_cb_t)(const char *);
2067 <h3 class=
"typedef"><a name=
"cups_ptype_t">cups_ptype_t
</a></h3>
2068 <p class=
"description">Printer type/capability bits
</p>
2070 typedef unsigned cups_ptype_t;
2072 <h2 class=
"title"><a name=
"STRUCTURES">Structures
</a></h2>
2073 <h3 class=
"struct"><a name=
"cups_dest_s">cups_dest_s
</a></h3>
2074 <p class=
"description">Destination
</p>
2075 <p class=
"code">struct cups_dest_s {
<br>
2076 char *name, *instance;
<br>
2077 int is_default;
<br>
2078 int num_options;
<br>
2079 <a href=
"#cups_option_t">cups_option_t
</a> *options;
<br>
2081 <h4 class=
"members">Members
</h4>
2084 <dd class=
"description">Local instance name or NULL
</dd>
2085 <dt>is_default
</dt>
2086 <dd class=
"description">Is this printer the default?
</dd>
2087 <dt>num_options
</dt>
2088 <dd class=
"description">Number of options
</dd>
2090 <dd class=
"description">Options
</dd>
2092 <h3 class=
"struct"><a name=
"cups_job_s">cups_job_s
</a></h3>
2093 <p class=
"description">Job
</p>
2094 <p class=
"code">struct cups_job_s {
<br>
2095 time_t completed_time;
<br>
2096 time_t creation_time;
<br>
2097 char *dest;
<br>
2098 char *format;
<br>
2099 int id;
<br>
2100 int priority;
<br>
2101 time_t processing_time;
<br>
2102 int size;
<br>
2103 ipp_jstate_t state;
<br>
2104 char *title;
<br>
2105 char *user;
<br>
2107 <h4 class=
"members">Members
</h4>
2109 <dt>completed_time
</dt>
2110 <dd class=
"description">Time the job was completed
</dd>
2111 <dt>creation_time
</dt>
2112 <dd class=
"description">Time the job was created
</dd>
2114 <dd class=
"description">Printer or class name
</dd>
2116 <dd class=
"description">Document format
</dd>
2118 <dd class=
"description">The job ID
</dd>
2120 <dd class=
"description">Priority (
1-
100)
</dd>
2121 <dt>processing_time
</dt>
2122 <dd class=
"description">Time the job was processed
</dd>
2124 <dd class=
"description">Size in kilobytes
</dd>
2126 <dd class=
"description">Job state
</dd>
2128 <dd class=
"description">Title/job name
</dd>
2130 <dd class=
"description">User the submitted the job
</dd>
2132 <h3 class=
"struct"><a name=
"cups_option_s">cups_option_s
</a></h3>
2133 <p class=
"description">Printer Options
</p>
2134 <p class=
"code">struct cups_option_s {
<br>
2135 char *name;
<br>
2136 char *value;
<br>
2138 <h4 class=
"members">Members
</h4>
2141 <dd class=
"description">Name of option
</dd>
2143 <dd class=
"description">Value of option
</dd>
2145 <h2 class=
"title"><a name=
"ENUMERATIONS">Constants
</a></h2>
2146 <h3 class=
"enumeration"><a name=
"cups_ptype_e">cups_ptype_e
</a></h3>
2147 <p class=
"description">Printer type/capability bit constants
</p>
2148 <h4 class=
"constants">Constants
</h4>
2150 <dt>CUPS_PRINTER_AUTHENTICATED
<span class=
"info"> CUPS
1.2 </span></dt>
2151 <dd class=
"description">Printer requires authentication
</dd>
2152 <dt>CUPS_PRINTER_BIND
</dt>
2153 <dd class=
"description">Can bind output
</dd>
2154 <dt>CUPS_PRINTER_BW
</dt>
2155 <dd class=
"description">Can do B
&W printing
</dd>
2156 <dt>CUPS_PRINTER_CLASS
</dt>
2157 <dd class=
"description">Printer class
</dd>
2158 <dt>CUPS_PRINTER_COLLATE
</dt>
2159 <dd class=
"description">Can collage copies
</dd>
2160 <dt>CUPS_PRINTER_COLOR
</dt>
2161 <dd class=
"description">Can do color printing
</dd>
2162 <dt>CUPS_PRINTER_COMMANDS
<span class=
"info"> CUPS
1.2 </span></dt>
2163 <dd class=
"description">Printer supports maintenance commands
</dd>
2164 <dt>CUPS_PRINTER_COPIES
</dt>
2165 <dd class=
"description">Can do copies
</dd>
2166 <dt>CUPS_PRINTER_COVER
</dt>
2167 <dd class=
"description">Can cover output
</dd>
2168 <dt>CUPS_PRINTER_DEFAULT
</dt>
2169 <dd class=
"description">Default printer on network
</dd>
2170 <dt>CUPS_PRINTER_DELETE
<span class=
"info"> CUPS
1.2 </span></dt>
2171 <dd class=
"description">Delete printer
</dd>
2172 <dt>CUPS_PRINTER_DISCOVERED
<span class=
"info"> CUPS
1.3 </span></dt>
2173 <dd class=
"description">Printer was automatically discovered and added
</dd>
2174 <dt>CUPS_PRINTER_DUPLEX
</dt>
2175 <dd class=
"description">Can do duplexing
</dd>
2176 <dt>CUPS_PRINTER_FAX
</dt>
2177 <dd class=
"description">Fax queue
</dd>
2178 <dt>CUPS_PRINTER_IMPLICIT
</dt>
2179 <dd class=
"description">Implicit class
</dd>
2180 <dt>CUPS_PRINTER_LARGE
</dt>
2181 <dd class=
"description">Can do D/E/A1/A0
</dd>
2182 <dt>CUPS_PRINTER_LOCAL
</dt>
2183 <dd class=
"description">Local printer or class
</dd>
2184 <dt>CUPS_PRINTER_MEDIUM
</dt>
2185 <dd class=
"description">Can do Tabloid/B/C/A3/A2
</dd>
2186 <dt>CUPS_PRINTER_NOT_SHARED
<span class=
"info"> CUPS
1.2 </span></dt>
2187 <dd class=
"description">Printer is not shared
</dd>
2188 <dt>CUPS_PRINTER_PUNCH
</dt>
2189 <dd class=
"description">Can punch output
</dd>
2190 <dt>CUPS_PRINTER_REJECTING
</dt>
2191 <dd class=
"description">Printer is rejecting jobs
</dd>
2192 <dt>CUPS_PRINTER_REMOTE
</dt>
2193 <dd class=
"description">Remote printer or class
</dd>
2194 <dt>CUPS_PRINTER_SMALL
</dt>
2195 <dd class=
"description">Can do Letter/Legal/A4
</dd>
2196 <dt>CUPS_PRINTER_SORT
</dt>
2197 <dd class=
"description">Can sort output
</dd>
2198 <dt>CUPS_PRINTER_STAPLE
</dt>
2199 <dd class=
"description">Can staple output
</dd>
2200 <dt>CUPS_PRINTER_VARIABLE
</dt>
2201 <dd class=
"description">Can do variable sizes
</dd>