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;
37 border: dotted thin #999999;
42 PRE.command EM, PRE.example EM {
43 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
47 font-family: monaco, courier, monospace;
58 border: solid thin #999999;
69 -moz-border-radius: 10px;
74 text-decoration: none;
77 A:link:hover, A:visited:hover, A:active {
78 text-decoration: underline;
85 TR.data, TD.data, TR.data TD {
88 border-bottom: solid 1pt #999999;
92 border-bottom: solid 1pt #999999;
99 border: solid thin #999999;
100 border-collapse: collapse;
116 border: solid thin #cccccc;
123 border-bottom: solid thin #999999;
132 caption-side: bottom;
156 border: thin solid black;
164 H2 SPAN.info, H3 SPAN.info, H4 SPAN.info {
170 border-bottom: solid 2pt #000000;
173 DIV.indent, TABLE.indent {
181 border-collapse: collapse;
184 TABLE.indent TD, TABLE.indent TH {
189 border-collapse: collapse;
197 border-bottom: solid thin #cccccc;
202 vertical-align: bottom;
211 border-bottom: solid thin #eeeeee;
216 TABLE.list TR:nth-child(even) {
220 TABLE.list TR:nth-child(odd) {
239 font-family: monaco, courier, monospace;
243 border: solid thin #999999;
244 border-collapse: collapse;
249 DIV.summary TABLE TD, DIV.summary TABLE TH {
250 border: solid thin #999999;
256 DIV.summary TABLE THEAD TH {
260 /* API documentation styles... */
267 div.body h3, div.body h4, div.body h5 {
268 margin-bottom: 0.5em;
271 .class, .enumeration, .function, .struct, .typedef, .union {
272 border-bottom: solid thin #999999;
279 code, p.code, pre, ul.code li {
280 font-family: monaco, courier, monospace;
283 ul.code, ul.contents, ul.subcontents {
284 list-style-type: none;
294 ul.contents li ul.code, ul.contents li ul.subcontents {
307 margin-bottom: 0.5em;
310 /* This is just for the HTML files generated with the framedhelp target */
313 border: solid thin black;
322 div.contents ul.contents {
325 div.contents ul.subcontents li {
334 "$Id: api-cups.header 7279 2008-01-31 01:50:44Z mike $"
336 CUPS API header for the Common UNIX Printing System (CUPS).
338 Copyright 2008 by Apple Inc.
340 These coded instructions, statements, and computer programs are the
341 property of Apple Inc. and are protected by Federal copyright
342 law. Distribution and use rights are outlined in the file "LICENSE.txt"
343 which should have been included with this file. If this file is
344 file is missing or damaged, see the license at "http://www.cups.org/".
347 <div class='summary'
><table summary='General Information'
>
361 <td>Programming:
<a href='api-overview.html' target='_top'
>Introduction to CUPS Programming
</a><br>
362 Programming:
<a href='api-array.html' target='_top'
>Array API
</a><br>
363 Programming:
<a href='api-filedir.html' target='_top'
>File and Directory APIs
</a><br>
364 Programming:
<a href='api-filter.html' target='_top'
>Filter and Backend Programming
</a><br>
365 Programming:
<a href='api-httpipp.html' target='_top'
>HTTP and IPP APIs
</a><br>
366 Programming:
<a href='api-ppd.html' target='_top'
>PPD API
</a><br>
367 Programming:
<a href='api-raster.html' target='_top'
>Raster API
</a></td>
371 <h2 class=
"title">Contents
</h2>
372 <ul class=
"contents">
374 <li><a href=
"#OVERVIEW">Overview
</a><ul class=
"subcontents">
375 <li><a href=
"#CLIENTS_AND_SERVERS">Clients and Servers
</a></li>
376 <li><a href=
"#PRINTERS_AND_CLASSES">Printers and Classes
</a></li>
377 <li><a href=
"#OPTIONS">Options
</a></li>
378 <li><a href=
"#PRINT_JOBS">Print Jobs
</a></li>
379 <li><a href=
"#ERROR_HANDLING">Error Handling
</a></li>
380 <li><a href=
"#PASSWORDS_AND_AUTHENTICATION">Passwords and Authentication
</a></li>
382 <li><a href=
"#FUNCTIONS">Functions
</a><ul class=
"code">
383 <li><a href=
"#cupsAddDest" title=
"Add a destination to the list of destinations.">cupsAddDest
</a></li>
384 <li><a href=
"#cupsAddOption" title=
"Add an option to an option array.">cupsAddOption
</a></li>
385 <li><a href=
"#cupsCancelJob" title=
"Cancel a print job on the default server.">cupsCancelJob
</a></li>
386 <li><a href=
"#cupsCancelJob2" title=
"Cancel or purge a print job.">cupsCancelJob2
</a></li>
387 <li><a href=
"#cupsCreateJob" title=
"Create an empty job for streaming.">cupsCreateJob
</a></li>
388 <li><a href=
"#cupsEncryption" title=
"Get the default encryption settings.">cupsEncryption
</a></li>
389 <li><a href=
"#cupsFinishDocument" title=
"Finish sending a document.">cupsFinishDocument
</a></li>
390 <li><a href=
"#cupsFreeDests" title=
"Free the memory used by the list of destinations.">cupsFreeDests
</a></li>
391 <li><a href=
"#cupsFreeJobs" title=
"Free memory used by job data.">cupsFreeJobs
</a></li>
392 <li><a href=
"#cupsFreeOptions" title=
"Free all memory used by options.">cupsFreeOptions
</a></li>
393 <li><a href=
"#cupsGetClasses" title=
"Get a list of printer classes from the default server.">cupsGetClasses
</a></li>
394 <li><a href=
"#cupsGetDefault" title=
"Get the default printer or class for the default server.">cupsGetDefault
</a></li>
395 <li><a href=
"#cupsGetDefault2" title=
"Get the default printer or class for the specified server.">cupsGetDefault2
</a></li>
396 <li><a href=
"#cupsGetDest" title=
"Get the named destination from the list.">cupsGetDest
</a></li>
397 <li><a href=
"#cupsGetDests" title=
"Get the list of destinations from the default server.">cupsGetDests
</a></li>
398 <li><a href=
"#cupsGetDests2" title=
"Get the list of destinations from the specified server.">cupsGetDests2
</a></li>
399 <li><a href=
"#cupsGetJobs" title=
"Get the jobs from the default server.">cupsGetJobs
</a></li>
400 <li><a href=
"#cupsGetJobs2" title=
"Get the jobs from the specified server.">cupsGetJobs2
</a></li>
401 <li><a href=
"#cupsGetNamedDest" title=
"Get options for the named destination.">cupsGetNamedDest
</a></li>
402 <li><a href=
"#cupsGetOption" title=
"Get an option value.">cupsGetOption
</a></li>
403 <li><a href=
"#cupsGetPPD" title=
"Get the PPD file for a printer on the default server.">cupsGetPPD
</a></li>
404 <li><a href=
"#cupsGetPPD2" title=
"Get the PPD file for a printer from the specified server.">cupsGetPPD2
</a></li>
405 <li><a href=
"#cupsGetPPD3" title=
"Get the PPD file for a printer on the specified
406 server if it has changed.">cupsGetPPD3
</a></li>
407 <li><a href=
"#cupsGetPassword" title=
"Get a password from the user.">cupsGetPassword
</a></li>
408 <li><a href=
"#cupsGetPrinters" title=
"Get a list of printers from the default server.">cupsGetPrinters
</a></li>
409 <li><a href=
"#cupsGetServerPPD" title=
"Get an available PPD file from the server.">cupsGetServerPPD
</a></li>
410 <li><a href=
"#cupsLangDefault" title=
"Return the default language.">cupsLangDefault
</a></li>
411 <li><a href=
"#cupsLangEncoding" title=
"Return the character encoding (us-ascii, etc.)
412 for the given language.">cupsLangEncoding
</a></li>
413 <li><a href=
"#cupsLangFlush" title=
"Flush all language data out of the cache.">cupsLangFlush
</a></li>
414 <li><a href=
"#cupsLangFree" title=
"Free language data.">cupsLangFree
</a></li>
415 <li><a href=
"#cupsLangGet" title=
"Get a language.">cupsLangGet
</a></li>
416 <li><a href=
"#cupsLastError" title=
"Return the last IPP status code.">cupsLastError
</a></li>
417 <li><a href=
"#cupsLastErrorString" title=
"Return the last IPP status-message.">cupsLastErrorString
</a></li>
418 <li><a href=
"#cupsNotifySubject" title=
"Return the subject for the given notification message.">cupsNotifySubject
</a></li>
419 <li><a href=
"#cupsNotifyText" title=
"Return the text for the given notification message.">cupsNotifyText
</a></li>
420 <li><a href=
"#cupsParseOptions" title=
"Parse options from a command-line argument.">cupsParseOptions
</a></li>
421 <li><a href=
"#cupsPrintFile" title=
"Print a file to a printer or class on the default server.">cupsPrintFile
</a></li>
422 <li><a href=
"#cupsPrintFile2" title=
"Print a file to a printer or class on the specified
423 server.">cupsPrintFile2
</a></li>
424 <li><a href=
"#cupsPrintFiles" title=
"Print one or more files to a printer or class on the
425 default server.">cupsPrintFiles
</a></li>
426 <li><a href=
"#cupsPrintFiles2" title=
"Print one or more files to a printer or class on the
427 specified server.">cupsPrintFiles2
</a></li>
428 <li><a href=
"#cupsRemoveDest" title=
"Remove a destination from the destination list.">cupsRemoveDest
</a></li>
429 <li><a href=
"#cupsRemoveOption" title=
"Remove an option from an option array.">cupsRemoveOption
</a></li>
430 <li><a href=
"#cupsServer" title=
"Return the hostname/address of the default server.">cupsServer
</a></li>
431 <li><a href=
"#cupsSetDefaultDest" title=
"Set the default destination.">cupsSetDefaultDest
</a></li>
432 <li><a href=
"#cupsSetDests" title=
"Save the list of destinations for the default server.">cupsSetDests
</a></li>
433 <li><a href=
"#cupsSetDests2" title=
"Save the list of destinations for the specified server.">cupsSetDests2
</a></li>
434 <li><a href=
"#cupsSetEncryption" title=
"Set the encryption preference.">cupsSetEncryption
</a></li>
435 <li><a href=
"#cupsSetPasswordCB" title=
"Set the password callback for CUPS.">cupsSetPasswordCB
</a></li>
436 <li><a href=
"#cupsSetServer" title=
"Set the default server name.">cupsSetServer
</a></li>
437 <li><a href=
"#cupsSetUser" title=
"Set the default user name.">cupsSetUser
</a></li>
438 <li><a href=
"#cupsStartDocument" title=
"Add a document to a job created with cupsCreateJob().">cupsStartDocument
</a></li>
439 <li><a href=
"#cupsTempFd" title=
"Creates a temporary file.">cupsTempFd
</a></li>
440 <li><a href=
"#cupsTempFile" title=
"Generates a temporary filename.">cupsTempFile
</a></li>
441 <li><a href=
"#cupsTempFile2" title=
"Creates a temporary CUPS file.">cupsTempFile2
</a></li>
442 <li><a href=
"#cupsUser" title=
"Return the current user's name.">cupsUser
</a></li>
444 <li><a href=
"#TYPES">Data Types
</a><ul class=
"code">
445 <li><a href=
"#cups_dest_t" title=
"Destination">cups_dest_t
</a></li>
446 <li><a href=
"#cups_device_cb_t" title=
"Device callback ">cups_device_cb_t
</a></li>
447 <li><a href=
"#cups_job_t" title=
"Job">cups_job_t
</a></li>
448 <li><a href=
"#cups_option_t" title=
"Printer Options">cups_option_t
</a></li>
449 <li><a href=
"#cups_password_cb_t" title=
"Password callback">cups_password_cb_t
</a></li>
450 <li><a href=
"#cups_ptype_t" title=
"Printer type/capability bits">cups_ptype_t
</a></li>
452 <li><a href=
"#STRUCTURES">Structures
</a><ul class=
"code">
453 <li><a href=
"#cups_dest_s" title=
"Destination">cups_dest_s
</a></li>
454 <li><a href=
"#cups_job_s" title=
"Job">cups_job_s
</a></li>
455 <li><a href=
"#cups_option_s" title=
"Printer Options">cups_option_s
</a></li>
457 <li><a href=
"#ENUMERATIONS">Constants
</a><ul class=
"code">
458 <li><a href=
"#cups_ptype_e" title=
"Printer type/capability bit constants">cups_ptype_e
</a></li>
462 "$Id: api-cups.shtml 7337 2008-02-22 04:44:04Z mike $"
464 CUPS API introduction for the Common UNIX Printing System (CUPS).
466 Copyright 2007-2008 by Apple Inc.
467 Copyright 1997-2006 by Easy Software Products, all rights reserved.
469 These coded instructions, statements, and computer programs are the
470 property of Apple Inc. and are protected by Federal copyright
471 law. Distribution and use rights are outlined in the file "LICENSE.txt"
472 which should have been included with this file. If this file is
473 file is missing or damaged, see the license at "http://www.cups.org/".
476 <h2 class='title'
><a name='OVERVIEW'
>Overview
</a></h2>
478 <p>The CUPS API provides the convenience functions needed to support
479 applications, filters, printer drivers, and backends that need to interface
480 with the CUPS scheduler.
</p>
482 <h3><a name='CLIENTS_AND_SERVERS'
>Clients and Servers
</a></h3>
484 <p>CUPS is based on the Internet Printing Protocol (
"IPP"), which allows
485 clients (applications) to communicate with a server (the scheduler) to get a
486 list of printers, send print jobs, and so forth. You identify which server
487 you want to communicate with using a pointer to the opaque structure
488 <code>http_t
</code>. All of the examples in this document use the
489 <code>CUPS_HTTP_DEFAULT
</code> constant, referring to the default connection
490 to the scheduler. The
<a href='api-httpipp.html' target='_top'
>HTTP and IPP
491 APIs
</a> document provides more information on server connections.
</p>
493 <h3><a name='PRINTERS_AND_CLASSES'
>Printers and Classes
</a></h3>
495 <p>Printers and classes (collections of printers) are accessed through
496 the
<a href=
"#cups_dest_t"><code>cups_dest_t
</code></a> structure which
497 includes the name (
<code>name
</code>), instance (
<code>instance
</code> -
498 a way of selecting certain saved options/settings), and the options and
499 attributes associated with that destination (
<code>num_options
</code> and
500 <code>options
</code>). Destinations are created using the
501 <a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> function and freed
502 using the
<a href='#cupsFreeDests'
><code>cupsFreeDests
</code></a> function.
503 The
<a href='#cupsGetDest'
><code>cupsGetDest
</code></a> function finds a
504 specific destination for printing:
</p>
506 <pre class='example'
>
507 #include
<cups/cups.h
>
509 <a href='#cups_dest_t'
>cups_dest_t
</a> *dests;
510 int num_dests =
<a href='#cupsGetDests'
>cupsGetDests
</a>(
&dests);
511 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest =
<a href='#cupsGetDest'
>cupsGetDest
</a>(
"name", NULL, num_dests, dests);
513 /* do something wiith dest */
515 <a href='#cupsFreeDests'
>cupsFreeDests
</a>(num_dests, dests);
518 <p>Passing
<code>NULL
</code> to
519 <a href='#cupsGetDest'
><code>cupsGetDest
</code></a> for the destination name
520 will return the default destination. Similarly, passing a
<code>NULL
</code>
521 instance will return the default instance for that destination.
</p>
523 <div class='table'
><table summary='Table
1: Printer Attributes' width='
80%'
>
524 <caption>Table
1:
<a name='TABLE1'
>Printer Attributes
</a></caption>
527 <th>Attribute Name
</th>
533 <td>"auth-info-required"</td>
534 <td>The type of authentication required for printing to this
535 destination:
"none",
"username,password",
"domain,username,password",
536 or
"negotiate" (Kerberos)
</td>
539 <td>"printer-info"</td>
540 <td>The human-readable description of the destination such as
"My
544 <td>"printer-is-accepting-jobs"</td>
545 <td>"1" if the destination is accepting new jobs,
"0" if not.
</td>
548 <td>"printer-is-shared"</td>
549 <td>"1" if the destination is being shared with other computers,
"0" if
553 <td>"printer-location"</td>
554 <td>The human-readable location of the destination such as
"Lab 4".
</td>
557 <td>"printer-make-and-model"</td>
558 <td>The human-readable make and model of the destination such as
"HP
559 LaserJet 4000 Series".
</td>
562 <td>"printer-state"</td>
563 <td>"3" if the destination is idle,
"4" if the destination is printing
564 a job, and
"5" if the destination is stopped.
</td>
567 <td>"printer-state-change-time"</td>
568 <td>The UNIX time when the destination entered the current state.
</td>
571 <td>"printer-state-reasons"</td>
572 <td>Additional comma-delimited state keywords for the destination
573 such as
"media-tray-empty-error" and
"toner-low-warning".
</td>
576 <td>"printer-type"</td>
577 <td>The
<a href='#cups_printer_t'
><code>cups_printer_t
</code></a>
578 value associated with the destination.
</td>
583 <h3><a name='OPTIONS'
>Options
</a></h3>
585 <p>Options are stored in arrays of
586 <a href='#cups_option_t'
><code>cups_option_t
</code></a> structures. Each
587 option has a name (
<code>name
</code>) and value (
<code>value
</code>)
588 associated with it. The
<a href='#cups_dest_t'
><code>cups_dest_t
</code></a>
589 <code>num_options
</code> and
<code>options
</code> members contain the
590 default options for a particular destination, along with several informational
591 attributes about the destination as shown in
<a href='#TABLE1'
>Table
1</a>.
592 The
<a href='#cupsGetOption'
><code>cupsGetOption
</code></a> function gets
593 the value for the named option. For example, the following code lists the
594 available destinations and their human-readable descriptions:
</p>
596 <pre class='example'
>
597 #include
<cups/cups.h
>
599 <a href='#cups_dest_t'
>cups_dest_t
</a> *dests;
600 int num_dests =
<a href='#cupsGetDests'
>cupsGetDests
</a>(
&dests);
601 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
605 for (i = num_dests, dest = dests; i
> 0; i --, dest ++)
606 if (dest-
>instance == NULL)
608 value =
<a href='#cupsGetOption'
>cupsGetOption
</a>(
"printer-info", dest-
>num_options, dest-
>options);
609 printf(
"%s (%s)\n", dest-
>name, value ? value :
"no description");
612 <a href='#cupsFreeDests'
>cupsFreeDests
</a>(num_dests, dests);
615 <p>You can create your own option arrays using the
616 <a href='#cupsAddOption'
><code>cupsAddOption
</code></a> function, which
617 adds a single named option to an array:
</p>
619 <pre class='example'
>
620 #include
<cups/cups.h
>
623 <a href='#cups_option_t'
>cups_option_t
</a> *options = NULL;
625 /* The returned num_options value is updated as needed */
626 num_options =
<a href='#cupsAddOption'
>cupsAddOption
</a>(
"first",
"value", num_options,
&options);
628 /* This adds a second option value */
629 num_options =
<a href='#cupsAddOption'
>cupsAddOption
</a>(
"second",
"value", num_options,
&options);
631 /* This replaces the first option we added */
632 num_options =
<a href='#cupsAddOption'
>cupsAddOption
</a>(
"first",
"new value", num_options,
&options);
635 <p>Use a
<code>for
</code> loop to copy the options from a destination:
</p>
637 <pre class='example'
>
638 #include
<cups/cups.h
>
642 <a href='#cups_option_t'
>cups_option_t
</a> *options = NULL;
643 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
645 for (i =
0; i < dest-
>num_options; i ++)
646 num_options =
<a href='#cupsAddOption'
>cupsAddOption
</a>(dest-
>options[i].name, dest-
>options[i].value,
647 num_options,
&options);
650 <p>Use the
<a href='#cupsFreeOptions'
><code>cupsFreeOptions
</code></a>
651 function to free the options array when you are done using it:
</p>
653 <pre class='example'
>
654 <a href='#cupsFreeOptions'
>cupsFreeOptions
</a>(num_options, options);
657 <h3><a name='PRINT_JOBS'
>Print Jobs
</a></h3>
659 <p>Print jobs are identified by a locally-unique job ID number from
1 to
660 2<sup>31</sup>-
1 and have options and one or more files for printing to a
661 single destination. The
<a href='#cupsPrintFile'
><code>cupsPrintFile
</code></a>
662 function creates a new job with one file. The following code prints the CUPS
665 <pre class='example'
>
666 #include
<cups/cups.h
>
668 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
670 <a href='#cups_option_t'
>cups_option_t
</a> *options;
673 /* Print a single file */
674 job_id =
<a href='#cupsPrintFile'
>cupsPrintFile
</a>(dest-
>name,
"/usr/share/cups/data/testprint.ps",
675 "Test Print", num_options, options);
678 <p>The
<a href='#cupsPrintFiles'
><code>cupsPrintFiles
</code></a> function
679 creates a job with multiple files. The files are provided in a
680 <code>char *
</code> array:
</p>
682 <pre class='example'
>
683 #include
<cups/cups.h
>
685 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
687 <a href='#cups_option_t'
>cups_option_t
</a> *options;
689 char *files[
3] = {
"file1.pdf",
"file2.pdf",
"file3.pdf" };
691 /* Print three files */
692 job_id =
<a href='#cupsPrintFiles'
>cupsPrintFiles
</a>(dest-
>name,
3, files,
"Test Print", num_options, options);
695 <p>Finally, the
<a href='#cupsCreateJob'
><code>cupsCreateJob
</code></a>
696 function creates a new job with no files in it. Files are added using the
697 <a href='#cupsStartDocument'
><code>cupsStartDocument
</code></a>,
698 <a href='api-httpipp.html#cupsWriteRequestData'
><code>cupsWriteRequestData
</code></a>,
699 and
<a href='#cupsFinishDocument'
><code>cupsFinishDocument
</code></a> functions.
700 The following example creates a job with
10 text files for printing:
</p>
702 <pre class='example'
>
703 #include
<cups/cups.h
>
705 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
707 <a href='#cups_option_t'
>cups_option_t
</a> *options;
713 job_id =
<a href='#cupsCreateJob'
>cupsCreateJob
</a>(CUPS_HTTP_DEFAULT, dest-
>name,
"10 Text Files",
714 num_options, options);
716 /* If the job is created, add
10 files */
719 for (i =
1; i
<=
10; i ++)
721 snprintf(buffer, sizeof(buffer),
"file%d.txt", i);
723 <a href='#cupsStartDocument'
>cupsStartDocument
</a>(CUPS_HTTP_DEFAULT, dest-
>name, job_id, buffer,
724 CUPS_FORMAT_TEXT, i ==
10);
726 snprintf(buffer, sizeof(buffer),
734 /* cupsWriteRequestData can be called as many times as needed */
735 <a href='#cupsWriteRequestData'
>cupsWriteRequestData
</a>(CUPS_HTTP_DEFAULT, buffer, strlen(buffer));
737 <a href='#cupsFinishDocument'
>cupsFinishDocument
</a>(CUPS_HTTP_DEFAULT, dest-
>name);
742 <p>Once you have created a job, you can monitor its status using the
743 <a href='#cupsGetJobs'
><code>cupsGetJobs
</code></a> function, which returns
744 an array of
<a href='#cups_job_t'
><code>cups_job_t
</code></a> structures.
745 Each contains the job ID (
<code>id
</code>), destination name
746 (
<code>dest
</code>), title (
<code>title
</code>), and other information
747 associated with the job. The job array is freed using the
748 <a href='#cupsFreeJobs'
><code>cupsFreeJobs
</code></a> function. The following
749 example monitors a specific job ID, showing the current job state once every
750 5 seconds until the job is completed:
</p>
752 <pre class='example'
>
753 #include
<cups/cups.h
>
755 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
758 <a href='#cups_job_t'
>cups_job_t
</a> *jobs;
760 ipp_jstate_t job_state = IPP_JOB_PENDING;
762 while (job_state
< IPP_JOB_STOPPED)
764 /* Get my jobs (
1) with any state (-
1) */
765 num_jobs =
<a href='#cupsGetJobs'
>cupsGetJobs
</a>(
&jobs, dest-
>name,
1, -
1);
767 /* Loop to find my job */
768 job_state = IPP_JOB_COMPLETED;
770 for (i =
0; i
< num_jobs; i ++)
771 if (jobs[i].id == job_id)
773 job_state = jobs[i].state;
777 /* Free the job array */
778 <a href='#cupsFreeJobs'
>cupsFreeJobs
</a>(num_jobs, jobs);
780 /* Show the current state */
783 case IPP_JOB_PENDING :
784 printf(
"Job %d is pending.\n", job_id);
787 printf(
"Job %d is held.\n", job_id);
789 case IPP_JOB_PROCESSING :
790 printf(
"Job %d is processing.\n", job_id);
792 case IPP_JOB_STOPPED :
793 printf(
"Job %d is stopped.\n", job_id);
795 case IPP_JOB_CANCELED :
796 printf(
"Job %d is canceled.\n", job_id);
798 case IPP_JOB_ABORTED :
799 printf(
"Job %d is aborted.\n", job_id);
801 case IPP_JOB_COMPLETED :
802 printf(
"Job %d is completed.\n", job_id);
806 /* Sleep if the job is not finished */
807 if (job_state
< IPP_JOB_STOPPED)
812 <p>To cancel a job, use the
813 <a href='#cupsCancelJob'
><code>cupsCancelJob
</code></a> function with the
816 <pre class='example'
>
817 #include
<cups/cups.h
>
819 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
822 <a href='#cupsCancelJob'
>cupsCancelJob
</a>(dest-
>name, job_id);
825 <h3><a name='ERROR_HANDLING'
>Error Handling
</a></h3>
827 <p>If any of the CUPS API printing functions returns an error, the reason for
828 that error can be found by calling the
829 <a href='#cupsLastError'
><code>cupsLastError
</code></a> and
830 <a href='#cupsLastErrorString'
><code>cupsLastErrorString
</code></a> functions.
831 <a href='#cupsLastError'
><code>cupsLastError
</code></a> returns the last IPP
833 (
<a href='api-httpipp.html#ipp_status_t'
><code>ipp_status_t
</code></a>)
834 that was encountered, while
835 <a href='#cupsLastErrorString'
><code>cupsLastErrorString
</code></a> returns
836 a (localized) human-readable string that can be shown to the user. For example,
837 if any of the job creation functions returns a job ID of
0, you can use
838 <a href='#cupsLastErrorString'
><code>cupsLastErrorString
</code></a> to show
839 the reason why the job could not be created:
</p>
841 <pre class='example'
>
842 #include
<cups/cups.h
>
847 puts(cupsLastErrorString());
850 <h3><a name='PASSWORDS_AND_AUTHENTICATION'
>Passwords and Authentication
</a></h3>
852 <p>CUPS supports authentication of any request, including submission of print
853 jobs. The default mechanism for getting the username and password is to use the
854 login user and a password from the console.
</p>
856 <p>To support other types of applications, in particular Graphical User
857 Interfaces (
"GUIs"), the CUPS API provides functions to set the default
858 username and to register a callback function that returns a password string.
</p>
860 <p>The
<a href=
"#cupsSetPasswordCB"><code>cupsSetPasswordCB
</code></a>
861 function is used to set a password callback in your program. Only one
862 function can be used at any time.
</p>
864 <p>The
<a href=
"#cupsSetUser"><code>cupsSetUser
</code></a> function sets the
865 current username for authentication. This function can be called by your
866 password callback function to change the current username as needed.
</p>
868 <p>The following example shows a simple password callback that gets a
869 username and password from the user:
</p>
871 <pre class='example'
>
872 #include
<cups/cups.h
>
875 my_password_cb(const char *prompt)
882 /* Get a username from the user */
883 printf(
"Username: ");
884 if (fgets(user, sizeof(user), stdin) == NULL)
887 /* Strip the newline from the string and set the user */
888 user[strlen(user) -
1] = '\
0';
890 <a href='#cupsSetUser'
>cupsSetUser
</a>(user);
892 /* Use getpass() to ask for the password... */
893 return (getpass(
"Password: "));
896 <a href='#cupsSetPasswordCB'
>cupsSetPasswordCB
</a>(my_password_cb);
899 <p>Similarly, a GUI could display the prompt string in a window with input
900 fields for the username and password. The username should default to the
901 string returned by the
<a href=
"#cupsUser"><code>cupsUser
</code></a>
903 <h2 class=
"title"><a name=
"FUNCTIONS">Functions
</a></h2>
904 <h3 class=
"function"><a name=
"cupsAddDest">cupsAddDest
</a></h3>
905 <p class=
"description">Add a destination to the list of destinations.
</p>
907 int cupsAddDest (
<br>
908 const char *name,
<br>
909 const char *instance,
<br>
910 int num_dests,
<br>
911 <a href=
"#cups_dest_t">cups_dest_t
</a> **dests
<br>
913 <h4 class=
"parameters">Parameters
</h4>
916 <dd class=
"description">Destination name
</dd>
918 <dd class=
"description">Instance name or
<code>NULL
</code> for none/primary
</dd>
920 <dd class=
"description">Number of destinations
</dd>
922 <dd class=
"description">Destinations
</dd>
924 <h4 class=
"returnvalue">Return Value
</h4>
925 <p class=
"description">New number of destinations
</p>
926 <h4 class=
"discussion">Discussion
</h4>
927 <p class=
"discussion">This function cannot be used to add a new class or printer queue,
928 it only adds a new container of saved options for the named
929 destination or instance.
<br>
931 If the named destination already exists, the destination list is
932 returned unchanged. Adding a new instance of a destination creates
933 a copy of that destination's options.
<br>
935 Use the
<a href=
"#cupsSaveDests"><code>cupsSaveDests
</code></a> function to save the updated list of
936 destinations to the user's lpoptions file.
</p>
937 <h3 class=
"function"><a name=
"cupsAddOption">cupsAddOption
</a></h3>
938 <p class=
"description">Add an option to an option array.
</p>
940 int cupsAddOption (
<br>
941 const char *name,
<br>
942 const char *value,
<br>
943 int num_options,
<br>
944 <a href=
"#cups_option_t">cups_option_t
</a> **options
<br>
946 <h4 class=
"parameters">Parameters
</h4>
949 <dd class=
"description">Name of option
</dd>
951 <dd class=
"description">Value of option
</dd>
953 <dd class=
"description">Number of options
</dd>
955 <dd class=
"description">Pointer to options
</dd>
957 <h4 class=
"returnvalue">Return Value
</h4>
958 <p class=
"description">Number of options
</p>
959 <h4 class=
"discussion">Discussion
</h4>
960 <p class=
"discussion">New option arrays can be initialized simply by passing
0 for the
961 "num_options
" parameter.
</p>
962 <h3 class=
"function"><a name=
"cupsCancelJob">cupsCancelJob
</a></h3>
963 <p class=
"description">Cancel a print job on the default server.
</p>
965 int cupsCancelJob (
<br>
966 const char *name,
<br>
967 int job_id
<br>
969 <h4 class=
"parameters">Parameters
</h4>
972 <dd class=
"description">Name of printer or class
</dd>
974 <dd class=
"description">Job ID,
<code>CUPS_JOBID_CURRENT
</code> for the current job, or
<code>CUPS_JOBID_ALL
</code> for all jobs
</dd>
976 <h4 class=
"returnvalue">Return Value
</h4>
977 <p class=
"description">1 on success,
0 on failure
</p>
978 <h4 class=
"discussion">Discussion
</h4>
979 <p class=
"discussion">Pass
<code>CUPS_JOBID_ALL
</code> to cancel all jobs or
<code>CUPS_JOBID_CURRENT
</code>
980 to cancel the current job on the named destination.
<br>
982 Use the
<a href=
"#cupsLastError"><code>cupsLastError
</code></a> and
<a href=
"#cupsLastErrorString"><code>cupsLastErrorString
</code></a> functions to get
983 the cause of any failure.
</p>
984 <h3 class=
"function"><span class=
"info"> CUPS
1.4 </span><a name=
"cupsCancelJob2">cupsCancelJob2
</a></h3>
985 <p class=
"description">Cancel or purge a print job.
</p>
987 ipp_status_t cupsCancelJob2 (
<br>
988 http_t *http,
<br>
989 const char *name,
<br>
990 int job_id,
<br>
991 int purge
<br>
993 <h4 class=
"parameters">Parameters
</h4>
996 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
998 <dd class=
"description">Name of printer or class
</dd>
1000 <dd class=
"description">Job ID,
<code>CUPS_JOBID_CURRENT
</code> for the current job, or
<code>CUPS_JOBID_ALL
</code> for all jobs
</dd>
1002 <dd class=
"description">1 to purge,
0 to cancel
</dd>
1004 <h4 class=
"returnvalue">Return Value
</h4>
1005 <p class=
"description">IPP status
</p>
1006 <h4 class=
"discussion">Discussion
</h4>
1007 <p class=
"discussion">Canceled jobs remain in the job history while purged jobs are removed
1008 from the job history.
<br>
1010 Pass
<code>CUPS_JOBID_ALL
</code> to cancel all jobs or
<code>CUPS_JOBID_CURRENT
</code>
1011 to cancel the current job on the named destination.
<br>
1013 Use the
<a href=
"#cupsLastError"><code>cupsLastError
</code></a> and
<a href=
"#cupsLastErrorString"><code>cupsLastErrorString
</code></a> functions to get
1014 the cause of any failure.
1017 <h3 class=
"function"><span class=
"info"> CUPS
1.4 </span><a name=
"cupsCreateJob">cupsCreateJob
</a></h3>
1018 <p class=
"description">Create an empty job for streaming.
</p>
1020 int cupsCreateJob (
<br>
1021 http_t *http,
<br>
1022 const char *name,
<br>
1023 const char *title,
<br>
1024 int num_options,
<br>
1025 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1027 <h4 class=
"parameters">Parameters
</h4>
1030 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1032 <dd class=
"description">Destination name
</dd>
1034 <dd class=
"description">Title of job
</dd>
1035 <dt>num_options
</dt>
1036 <dd class=
"description">Number of options
</dd>
1038 <dd class=
"description">Options
</dd>
1040 <h4 class=
"returnvalue">Return Value
</h4>
1041 <p class=
"description">Job ID or
0 on error
</p>
1042 <h4 class=
"discussion">Discussion
</h4>
1043 <p class=
"discussion">Use this function when you want to stream print data using the
1044 <a href=
"#cupsStartDocument"><code>cupsStartDocument
</code></a>,
<a href=
"#cupsWriteRequestData"><code>cupsWriteRequestData
</code></a>, and
1045 <a href=
"#cupsFinishDocument"><code>cupsFinishDocument
</code></a> functions. If you have one or more files to
1046 print, use the
<a href=
"#cupsPrintFile2"><code>cupsPrintFile2
</code></a> or
<a href=
"#cupsPrintFiles2"><code>cupsPrintFiles2
</code></a> function
1050 <h3 class=
"function"><a name=
"cupsEncryption">cupsEncryption
</a></h3>
1051 <p class=
"description">Get the default encryption settings.
</p>
1053 http_encryption_t cupsEncryption (void);
</p>
1054 <h4 class=
"returnvalue">Return Value
</h4>
1055 <p class=
"description">Encryption settings
</p>
1056 <h4 class=
"discussion">Discussion
</h4>
1057 <p class=
"discussion">The default encryption setting comes from the CUPS_ENCRYPTION
1058 environment variable, then the ~/.cups/client.conf file, and finally the
1059 /etc/cups/client.conf file. If not set, the default is
1060 <code>HTTP_ENCRYPT_IF_REQUESTED
</code>.
</p>
1061 <h3 class=
"function"><span class=
"info"> CUPS
1.4 </span><a name=
"cupsFinishDocument">cupsFinishDocument
</a></h3>
1062 <p class=
"description">Finish sending a document.
</p>
1064 ipp_status_t cupsFinishDocument (
<br>
1065 http_t *http,
<br>
1066 const char *name
<br>
1068 <h4 class=
"parameters">Parameters
</h4>
1071 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1073 <dd class=
"description">Destination name
</dd>
1075 <h4 class=
"returnvalue">Return Value
</h4>
1076 <p class=
"description">Status of document submission
</p>
1077 <h4 class=
"discussion">Discussion
</h4>
1078 <p class=
"discussion">The document must have been started using
<a href=
"#cupsStartDocument"><code>cupsStartDocument
</code></a>.
1081 <h3 class=
"function"><a name=
"cupsFreeDests">cupsFreeDests
</a></h3>
1082 <p class=
"description">Free the memory used by the list of destinations.
</p>
1084 void cupsFreeDests (
<br>
1085 int num_dests,
<br>
1086 <a href=
"#cups_dest_t">cups_dest_t
</a> *dests
<br>
1088 <h4 class=
"parameters">Parameters
</h4>
1091 <dd class=
"description">Number of destinations
</dd>
1093 <dd class=
"description">Destinations
</dd>
1095 <h3 class=
"function"><a name=
"cupsFreeJobs">cupsFreeJobs
</a></h3>
1096 <p class=
"description">Free memory used by job data.
</p>
1098 void cupsFreeJobs (
<br>
1099 int num_jobs,
<br>
1100 <a href=
"#cups_job_t">cups_job_t
</a> *jobs
<br>
1102 <h4 class=
"parameters">Parameters
</h4>
1105 <dd class=
"description">Number of jobs
</dd>
1107 <dd class=
"description">Jobs
</dd>
1109 <h3 class=
"function"><a name=
"cupsFreeOptions">cupsFreeOptions
</a></h3>
1110 <p class=
"description">Free all memory used by options.
</p>
1112 void cupsFreeOptions (
<br>
1113 int num_options,
<br>
1114 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1116 <h4 class=
"parameters">Parameters
</h4>
1118 <dt>num_options
</dt>
1119 <dd class=
"description">Number of options
</dd>
1121 <dd class=
"description">Pointer to options
</dd>
1123 <h3 class=
"function"><span class=
"info"> DEPRECATED
</span><a name=
"cupsGetClasses">cupsGetClasses
</a></h3>
1124 <p class=
"description">Get a list of printer classes from the default server.
</p>
1126 int cupsGetClasses (
<br>
1127 char ***classes
<br>
1129 <h4 class=
"parameters">Parameters
</h4>
1132 <dd class=
"description">Classes
</dd>
1134 <h4 class=
"returnvalue">Return Value
</h4>
1135 <p class=
"description">Number of classes
</p>
1136 <h4 class=
"discussion">Discussion
</h4>
1137 <p class=
"discussion">This function is deprecated - use
<a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> instead.
1140 <h3 class=
"function"><a name=
"cupsGetDefault">cupsGetDefault
</a></h3>
1141 <p class=
"description">Get the default printer or class for the default server.
</p>
1143 const char *cupsGetDefault (void);
</p>
1144 <h4 class=
"returnvalue">Return Value
</h4>
1145 <p class=
"description">Default printer or
<code>NULL
</code></p>
1146 <h4 class=
"discussion">Discussion
</h4>
1147 <p class=
"discussion">This function returns the default printer or class as defined by
1148 the LPDEST or PRINTER environment variables. If these environment
1149 variables are not set, the server default destination is returned.
1150 Applications should use the
<a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> and
<a href=
"#cupsGetDest"><code>cupsGetDest
</code></a>
1151 functions to get the user-defined default printer, as this function does
1152 not support the lpoptions-defined default printer.
</p>
1153 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21 </span><a name=
"cupsGetDefault2">cupsGetDefault2
</a></h3>
1154 <p class=
"description">Get the default printer or class for the specified server.
</p>
1156 const char *cupsGetDefault2 (
<br>
1157 http_t *http
<br>
1159 <h4 class=
"parameters">Parameters
</h4>
1162 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1164 <h4 class=
"returnvalue">Return Value
</h4>
1165 <p class=
"description">Default printer or
<code>NULL
</code></p>
1166 <h4 class=
"discussion">Discussion
</h4>
1167 <p class=
"discussion">This function returns the default printer or class as defined by
1168 the LPDEST or PRINTER environment variables. If these environment
1169 variables are not set, the server default destination is returned.
1170 Applications should use the
<a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> and
<a href=
"#cupsGetDest"><code>cupsGetDest
</code></a>
1171 functions to get the user-defined default printer, as this function does
1172 not support the lpoptions-defined default printer.
1175 <h3 class=
"function"><a name=
"cupsGetDest">cupsGetDest
</a></h3>
1176 <p class=
"description">Get the named destination from the list.
</p>
1178 <a href=
"#cups_dest_t">cups_dest_t
</a> *cupsGetDest (
<br>
1179 const char *name,
<br>
1180 const char *instance,
<br>
1181 int num_dests,
<br>
1182 <a href=
"#cups_dest_t">cups_dest_t
</a> *dests
<br>
1184 <h4 class=
"parameters">Parameters
</h4>
1187 <dd class=
"description">Destination name or
<code>NULL
</code> for the default destination
</dd>
1189 <dd class=
"description">Instance name or
<code>NULL
</code></dd>
1191 <dd class=
"description">Number of destinations
</dd>
1193 <dd class=
"description">Destinations
</dd>
1195 <h4 class=
"returnvalue">Return Value
</h4>
1196 <p class=
"description">Destination pointer or
<code>NULL
</code></p>
1197 <h4 class=
"discussion">Discussion
</h4>
1198 <p class=
"discussion">Use the
<a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> or
<a href=
"#cupsGetDests2"><code>cupsGetDests2
</code></a> functions to get a
1199 list of supported destinations for the current user.
</p>
1200 <h3 class=
"function"><a name=
"cupsGetDests">cupsGetDests
</a></h3>
1201 <p class=
"description">Get the list of destinations from the default server.
</p>
1203 int cupsGetDests (
<br>
1204 <a href=
"#cups_dest_t">cups_dest_t
</a> **dests
<br>
1206 <h4 class=
"parameters">Parameters
</h4>
1209 <dd class=
"description">Destinations
</dd>
1211 <h4 class=
"returnvalue">Return Value
</h4>
1212 <p class=
"description">Number of destinations
</p>
1213 <h4 class=
"discussion">Discussion
</h4>
1214 <p class=
"discussion">Starting with CUPS
1.2, the returned list of destinations include the
1215 printer-info, printer-is-accepting-jobs, printer-is-shared,
1216 printer-make-and-model, printer-state, printer-state-change-time,
1217 printer-state-reasons, and printer-type attributes as options.
<br>
1219 Use the
<a href=
"#cupsFreeDests"><code>cupsFreeDests
</code></a> function to free the destination list and
1220 the
<a href=
"#cupsGetDest"><code>cupsGetDest
</code></a> function to find a particular destination.
</p>
1221 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21 </span><a name=
"cupsGetDests2">cupsGetDests2
</a></h3>
1222 <p class=
"description">Get the list of destinations from the specified server.
</p>
1224 int cupsGetDests2 (
<br>
1225 http_t *http,
<br>
1226 <a href=
"#cups_dest_t">cups_dest_t
</a> **dests
<br>
1228 <h4 class=
"parameters">Parameters
</h4>
1231 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1233 <dd class=
"description">Destinations
</dd>
1235 <h4 class=
"returnvalue">Return Value
</h4>
1236 <p class=
"description">Number of destinations
</p>
1237 <h4 class=
"discussion">Discussion
</h4>
1238 <p class=
"discussion">Starting with CUPS
1.2, the returned list of destinations include the
1239 printer-info, printer-is-accepting-jobs, printer-is-shared,
1240 printer-make-and-model, printer-state, printer-state-change-time,
1241 printer-state-reasons, and printer-type attributes as options.
<br>
1243 Use the
<a href=
"#cupsFreeDests"><code>cupsFreeDests
</code></a> function to free the destination list and
1244 the
<a href=
"#cupsGetDest"><code>cupsGetDest
</code></a> function to find a particular destination.
1247 <h3 class=
"function"><a name=
"cupsGetJobs">cupsGetJobs
</a></h3>
1248 <p class=
"description">Get the jobs from the default server.
</p>
1250 int cupsGetJobs (
<br>
1251 <a href=
"#cups_job_t">cups_job_t
</a> **jobs,
<br>
1252 const char *name,
<br>
1253 int myjobs,
<br>
1254 int whichjobs
<br>
1256 <h4 class=
"parameters">Parameters
</h4>
1259 <dd class=
"description">Job data
</dd>
1261 <dd class=
"description"><code>NULL
</code> = all destinations, otherwise show jobs for named destination
</dd>
1263 <dd class=
"description">0 = all users,
1 = mine
</dd>
1265 <dd class=
"description"><code>CUPS_WHICHJOBS_ALL
</code>,
<code>CUPS_WHICHJOBS_ACTIVE
</code>, or
<code>CUPS_WHICHJOBS_COMPLETED
</code></dd>
1267 <h4 class=
"returnvalue">Return Value
</h4>
1268 <p class=
"description">Number of jobs
</p>
1269 <h4 class=
"discussion">Discussion
</h4>
1270 <p class=
"discussion">A
"whichjobs
" value of
<code>CUPS_WHICHJOBS_ALL
</code> returns all jobs regardless
1271 of state, while
<code>CUPS_WHICHJOBS_ACTIVE
</code> returns jobs that are
1272 pending, processing, or held and
<code>CUPS_WHICHJOBS_COMPLETED
</code> returns
1273 jobs that are stopped, canceled, aborted, or completed.
</p>
1274 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21 </span><a name=
"cupsGetJobs2">cupsGetJobs2
</a></h3>
1275 <p class=
"description">Get the jobs from the specified server.
</p>
1277 int cupsGetJobs2 (
<br>
1278 http_t *http,
<br>
1279 <a href=
"#cups_job_t">cups_job_t
</a> **jobs,
<br>
1280 const char *name,
<br>
1281 int myjobs,
<br>
1282 int whichjobs
<br>
1284 <h4 class=
"parameters">Parameters
</h4>
1287 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1289 <dd class=
"description">Job data
</dd>
1291 <dd class=
"description"><code>NULL
</code> = all destinations, otherwise show jobs for named destination
</dd>
1293 <dd class=
"description">0 = all users,
1 = mine
</dd>
1295 <dd class=
"description"><code>CUPS_WHICHJOBS_ALL
</code>,
<code>CUPS_WHICHJOBS_ACTIVE
</code>, or
<code>CUPS_WHICHJOBS_COMPLETED
</code></dd>
1297 <h4 class=
"returnvalue">Return Value
</h4>
1298 <p class=
"description">Number of jobs
</p>
1299 <h4 class=
"discussion">Discussion
</h4>
1300 <p class=
"discussion">A
"whichjobs
" value of
<code>CUPS_WHICHJOBS_ALL
</code> returns all jobs regardless
1301 of state, while
<code>CUPS_WHICHJOBS_ACTIVE
</code> returns jobs that are
1302 pending, processing, or held and
<code>CUPS_WHICHJOBS_COMPLETED
</code> returns
1303 jobs that are stopped, canceled, aborted, or completed.
1306 <h3 class=
"function"><span class=
"info"> CUPS
1.4 </span><a name=
"cupsGetNamedDest">cupsGetNamedDest
</a></h3>
1307 <p class=
"description">Get options for the named destination.
</p>
1309 <a href=
"#cups_dest_t">cups_dest_t
</a> *cupsGetNamedDest (
<br>
1310 http_t *http,
<br>
1311 const char *name,
<br>
1312 const char *instance
<br>
1314 <h4 class=
"parameters">Parameters
</h4>
1317 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1319 <dd class=
"description">Destination name or
<code>NULL
</code> for the default destination
</dd>
1321 <dd class=
"description">Instance name or
<code>NULL
</code></dd>
1323 <h4 class=
"returnvalue">Return Value
</h4>
1324 <p class=
"description">Destination or
<code>NULL
</code></p>
1325 <h4 class=
"discussion">Discussion
</h4>
1326 <p class=
"discussion">This function is optimized for retrieving a single destination and should
1327 be used instead of
<a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> and
<a href=
"#cupsGetDest"><code>cupsGetDest
</code></a> when you either
1328 know the name of the destination or want to print to the default destination.
1329 If
<code>NULL
</code> is returned, the destination does not exist or there is no
1330 default destination.
<br>
1332 If
"http
" is
<code>CUPS_HTTP_DEFAULT
</code>, the connection to the default print
1333 server will be used.
<br>
1335 If
"name
" is
<code>NULL
</code>, the default printer for the current user will be
1338 The returned destination must be freed using
<a href=
"#cupsFreeDests"><code>cupsFreeDests
</code></a> with a
1339 "num_dests
" value of
1.
1342 <h3 class=
"function"><a name=
"cupsGetOption">cupsGetOption
</a></h3>
1343 <p class=
"description">Get an option value.
</p>
1345 const char *cupsGetOption (
<br>
1346 const char *name,
<br>
1347 int num_options,
<br>
1348 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1350 <h4 class=
"parameters">Parameters
</h4>
1353 <dd class=
"description">Name of option
</dd>
1354 <dt>num_options
</dt>
1355 <dd class=
"description">Number of options
</dd>
1357 <dd class=
"description">Options
</dd>
1359 <h4 class=
"returnvalue">Return Value
</h4>
1360 <p class=
"description">Option value or
<code>NULL
</code></p>
1361 <h3 class=
"function"><a name=
"cupsGetPPD">cupsGetPPD
</a></h3>
1362 <p class=
"description">Get the PPD file for a printer on the default server.
</p>
1364 const char *cupsGetPPD (
<br>
1365 const char *name
<br>
1367 <h4 class=
"parameters">Parameters
</h4>
1370 <dd class=
"description">Destination name
</dd>
1372 <h4 class=
"returnvalue">Return Value
</h4>
1373 <p class=
"description">Filename for PPD file
</p>
1374 <h4 class=
"discussion">Discussion
</h4>
1375 <p class=
"discussion">For classes,
<code>cupsGetPPD
</code> returns the PPD file for the first printer
1378 The returned filename is stored in a static buffer and is overwritten with
1379 each call to
<code>cupsGetPPD
</code> or
<a href=
"#cupsGetPPD2"><code>cupsGetPPD2
</code></a>.
</p>
1380 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21 </span><a name=
"cupsGetPPD2">cupsGetPPD2
</a></h3>
1381 <p class=
"description">Get the PPD file for a printer from the specified server.
</p>
1383 const char *cupsGetPPD2 (
<br>
1384 http_t *http,
<br>
1385 const char *name
<br>
1387 <h4 class=
"parameters">Parameters
</h4>
1390 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1392 <dd class=
"description">Destination name
</dd>
1394 <h4 class=
"returnvalue">Return Value
</h4>
1395 <p class=
"description">Filename for PPD file
</p>
1396 <h4 class=
"discussion">Discussion
</h4>
1397 <p class=
"discussion">For classes,
<code>cupsGetPPD2
</code> returns the PPD file for the first printer
1400 The returned filename is stored in a static buffer and is overwritten with
1401 each call to
<a href=
"#cupsGetPPD"><code>cupsGetPPD
</code></a> or
<code>cupsGetPPD2
</code>.
1404 <h3 class=
"function"><span class=
"info"> CUPS
1.4 </span><a name=
"cupsGetPPD3">cupsGetPPD3
</a></h3>
1405 <p class=
"description">Get the PPD file for a printer on the specified
1406 server if it has changed.
</p>
1408 http_status_t cupsGetPPD3 (
<br>
1409 http_t *http,
<br>
1410 const char *name,
<br>
1411 time_t *modtime,
<br>
1412 char *buffer,
<br>
1413 size_t bufsize
<br>
1415 <h4 class=
"parameters">Parameters
</h4>
1418 <dd class=
"description">HTTP connection or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1420 <dd class=
"description">Destination name
</dd>
1422 <dd class=
"description">Modification time
</dd>
1424 <dd class=
"description">Filename buffer
</dd>
1426 <dd class=
"description">Size of filename buffer
</dd>
1428 <h4 class=
"returnvalue">Return Value
</h4>
1429 <p class=
"description">HTTP status
</p>
1430 <h4 class=
"discussion">Discussion
</h4>
1431 <p class=
"discussion">The
"modtime
" parameter contains the modification time of any
1432 locally-cached content and is updated with the time from the PPD file on
1435 The
"buffer
" parameter contains the local PPD filename. If it contains
1436 the empty string, a new temporary file is created, otherwise the existing
1437 file will be overwritten as needed.
<br>
1439 On success,
<code>HTTP_OK
</code> is returned for a new PPD file and
1440 <code>HTTP_NOT_MODIFIED
</code> if the existing PPD file is up-to-date. Any other
1441 status is an error.
<br>
1443 For classes,
<code>cupsGetPPD3
</code> returns the PPD file for the first printer
1447 <h3 class=
"function"><a name=
"cupsGetPassword">cupsGetPassword
</a></h3>
1448 <p class=
"description">Get a password from the user.
</p>
1450 const char *cupsGetPassword (
<br>
1451 const char *prompt
<br>
1453 <h4 class=
"parameters">Parameters
</h4>
1456 <dd class=
"description">Prompt string
</dd>
1458 <h4 class=
"returnvalue">Return Value
</h4>
1459 <p class=
"description">Password
</p>
1460 <h4 class=
"discussion">Discussion
</h4>
1461 <p class=
"discussion">Uses the current password callback function. Returns
<code>NULL
</code> if the
1462 user does not provide a password.
</p>
1463 <h3 class=
"function"><span class=
"info"> DEPRECATED
</span><a name=
"cupsGetPrinters">cupsGetPrinters
</a></h3>
1464 <p class=
"description">Get a list of printers from the default server.
</p>
1466 int cupsGetPrinters (
<br>
1467 char ***printers
<br>
1469 <h4 class=
"parameters">Parameters
</h4>
1472 <dd class=
"description">Printers
</dd>
1474 <h4 class=
"returnvalue">Return Value
</h4>
1475 <p class=
"description">Number of printers
</p>
1476 <h4 class=
"discussion">Discussion
</h4>
1477 <p class=
"discussion">This function is deprecated - use
<a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> instead.
1480 <h3 class=
"function"><span class=
"info"> CUPS
1.3 </span><a name=
"cupsGetServerPPD">cupsGetServerPPD
</a></h3>
1481 <p class=
"description">Get an available PPD file from the server.
</p>
1483 char *cupsGetServerPPD (
<br>
1484 http_t *http,
<br>
1485 const char *name
<br>
1487 <h4 class=
"parameters">Parameters
</h4>
1490 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1492 <dd class=
"description">Name of PPD file (
"ppd-name
")
</dd>
1494 <h4 class=
"returnvalue">Return Value
</h4>
1495 <p class=
"description">Name of PPD file or
<code>NULL
</code> on error
</p>
1496 <h4 class=
"discussion">Discussion
</h4>
1497 <p class=
"discussion">This function returns the named PPD file from the server. The
1498 list of available PPDs is provided by the IPP
<code>CUPS_GET_PPDS
</code>
1501 You must remove (unlink) the PPD file when you are finished with
1502 it. The PPD filename is stored in a static location that will be
1503 overwritten on the next call to
<a href=
"#cupsGetPPD"><code>cupsGetPPD
</code></a>,
<a href=
"#cupsGetPPD2"><code>cupsGetPPD2
</code></a>,
1504 or
<a href=
"#cupsGetServerPPD"><code>cupsGetServerPPD
</code></a>.
1507 <h3 class=
"function"><a name=
"cupsLangDefault">cupsLangDefault
</a></h3>
1508 <p class=
"description">Return the default language.
</p>
1510 cups_lang_t *cupsLangDefault (void);
</p>
1511 <h4 class=
"returnvalue">Return Value
</h4>
1512 <p class=
"description">Language data
</p>
1513 <h3 class=
"function"><a name=
"cupsLangEncoding">cupsLangEncoding
</a></h3>
1514 <p class=
"description">Return the character encoding (us-ascii, etc.)
1515 for the given language.
</p>
1517 const char *cupsLangEncoding (
<br>
1518 cups_lang_t *lang
<br>
1520 <h4 class=
"parameters">Parameters
</h4>
1523 <dd class=
"description">Language data
</dd>
1525 <h4 class=
"returnvalue">Return Value
</h4>
1526 <p class=
"description">Character encoding
</p>
1527 <h3 class=
"function"><a name=
"cupsLangFlush">cupsLangFlush
</a></h3>
1528 <p class=
"description">Flush all language data out of the cache.
</p>
1530 void cupsLangFlush (void);
</p>
1531 <h3 class=
"function"><a name=
"cupsLangFree">cupsLangFree
</a></h3>
1532 <p class=
"description">Free language data.
</p>
1534 void cupsLangFree (
<br>
1535 cups_lang_t *lang
<br>
1537 <h4 class=
"parameters">Parameters
</h4>
1540 <dd class=
"description">Language to free
</dd>
1542 <h4 class=
"discussion">Discussion
</h4>
1543 <p class=
"discussion">This does not actually free anything; use
<a href=
"#cupsLangFlush"><code>cupsLangFlush
</code></a> for that.
</p>
1544 <h3 class=
"function"><a name=
"cupsLangGet">cupsLangGet
</a></h3>
1545 <p class=
"description">Get a language.
</p>
1547 cups_lang_t *cupsLangGet (
<br>
1548 const char *language
<br>
1550 <h4 class=
"parameters">Parameters
</h4>
1553 <dd class=
"description">Language or locale
</dd>
1555 <h4 class=
"returnvalue">Return Value
</h4>
1556 <p class=
"description">Language data
</p>
1557 <h3 class=
"function"><a name=
"cupsLastError">cupsLastError
</a></h3>
1558 <p class=
"description">Return the last IPP status code.
</p>
1560 ipp_status_t cupsLastError (void);
</p>
1561 <h4 class=
"returnvalue">Return Value
</h4>
1562 <p class=
"description">IPP status code from last request
</p>
1563 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsLastErrorString">cupsLastErrorString
</a></h3>
1564 <p class=
"description">Return the last IPP status-message.
</p>
1566 const char *cupsLastErrorString (void);
</p>
1567 <h4 class=
"returnvalue">Return Value
</h4>
1568 <p class=
"description">status-message text from last request
</p>
1569 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsNotifySubject">cupsNotifySubject
</a></h3>
1570 <p class=
"description">Return the subject for the given notification message.
</p>
1572 char *cupsNotifySubject (
<br>
1573 cups_lang_t *lang,
<br>
1574 ipp_t *event
<br>
1576 <h4 class=
"parameters">Parameters
</h4>
1579 <dd class=
"description">Language data
</dd>
1581 <dd class=
"description">Event data
</dd>
1583 <h4 class=
"returnvalue">Return Value
</h4>
1584 <p class=
"description">Subject string or
<code>NULL
</code></p>
1585 <h4 class=
"discussion">Discussion
</h4>
1586 <p class=
"discussion">The returned string must be freed by the caller using
<code>free
</code>.
1589 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsNotifyText">cupsNotifyText
</a></h3>
1590 <p class=
"description">Return the text for the given notification message.
</p>
1592 char *cupsNotifyText (
<br>
1593 cups_lang_t *lang,
<br>
1594 ipp_t *event
<br>
1596 <h4 class=
"parameters">Parameters
</h4>
1599 <dd class=
"description">Language data
</dd>
1601 <dd class=
"description">Event data
</dd>
1603 <h4 class=
"returnvalue">Return Value
</h4>
1604 <p class=
"description">Message text or
<code>NULL
</code></p>
1605 <h4 class=
"discussion">Discussion
</h4>
1606 <p class=
"discussion">The returned string must be freed by the caller using
<code>free
</code>.
1609 <h3 class=
"function"><a name=
"cupsParseOptions">cupsParseOptions
</a></h3>
1610 <p class=
"description">Parse options from a command-line argument.
</p>
1612 int cupsParseOptions (
<br>
1613 const char *arg,
<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">Argument to parse
</dd>
1621 <dt>num_options
</dt>
1622 <dd class=
"description">Number of options
</dd>
1624 <dd class=
"description">Options found
</dd>
1626 <h4 class=
"returnvalue">Return Value
</h4>
1627 <p class=
"description">Number of options found
</p>
1628 <h4 class=
"discussion">Discussion
</h4>
1629 <p class=
"discussion">This function converts space-delimited name/value pairs according
1630 to the PAPI text option ABNF specification. Collection values
1631 (
"name={a=... b=... c=...}
") are stored with the curley brackets
1632 intact - use
<code>cupsParseOptions
</code> on the value to extract the
1633 collection attributes.
</p>
1634 <h3 class=
"function"><a name=
"cupsPrintFile">cupsPrintFile
</a></h3>
1635 <p class=
"description">Print a file to a printer or class on the default server.
</p>
1637 int cupsPrintFile (
<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">Destination name
</dd>
1649 <dd class=
"description">File to print
</dd>
1651 <dd class=
"description">Title of job
</dd>
1652 <dt>num_options
</dt>
1653 <dd class=
"description">Number of options
</dd>
1655 <dd class=
"description">Options
</dd>
1657 <h4 class=
"returnvalue">Return Value
</h4>
1658 <p class=
"description">Job ID or
0 on error
</p>
1659 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21 </span><a name=
"cupsPrintFile2">cupsPrintFile2
</a></h3>
1660 <p class=
"description">Print a file to a printer or class on the specified
1663 int cupsPrintFile2 (
<br>
1664 http_t *http,
<br>
1665 const char *name,
<br>
1666 const char *filename,
<br>
1667 const char *title,
<br>
1668 int num_options,
<br>
1669 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1671 <h4 class=
"parameters">Parameters
</h4>
1674 <dd class=
"description">Connection to server
</dd>
1676 <dd class=
"description">Destination name
</dd>
1678 <dd class=
"description">File to print
</dd>
1680 <dd class=
"description">Title of job
</dd>
1681 <dt>num_options
</dt>
1682 <dd class=
"description">Number of options
</dd>
1684 <dd class=
"description">Options
</dd>
1686 <h4 class=
"returnvalue">Return Value
</h4>
1687 <p class=
"description">Job ID or
0 on error
</p>
1688 <h3 class=
"function"><a name=
"cupsPrintFiles">cupsPrintFiles
</a></h3>
1689 <p class=
"description">Print one or more files to a printer or class on the
1692 int cupsPrintFiles (
<br>
1693 const char *name,
<br>
1694 int num_files,
<br>
1695 const char **files,
<br>
1696 const char *title,
<br>
1697 int num_options,
<br>
1698 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1700 <h4 class=
"parameters">Parameters
</h4>
1703 <dd class=
"description">Destination name
</dd>
1705 <dd class=
"description">Number of files
</dd>
1707 <dd class=
"description">File(s) to print
</dd>
1709 <dd class=
"description">Title of job
</dd>
1710 <dt>num_options
</dt>
1711 <dd class=
"description">Number of options
</dd>
1713 <dd class=
"description">Options
</dd>
1715 <h4 class=
"returnvalue">Return Value
</h4>
1716 <p class=
"description">Job ID or
0 on error
</p>
1717 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21 </span><a name=
"cupsPrintFiles2">cupsPrintFiles2
</a></h3>
1718 <p class=
"description">Print one or more files to a printer or class on the
1719 specified server.
</p>
1721 int cupsPrintFiles2 (
<br>
1722 http_t *http,
<br>
1723 const char *name,
<br>
1724 int num_files,
<br>
1725 const char **files,
<br>
1726 const char *title,
<br>
1727 int num_options,
<br>
1728 <a href=
"#cups_option_t">cups_option_t
</a> *options
<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">Destination name
</dd>
1737 <dd class=
"description">Number of files
</dd>
1739 <dd class=
"description">File(s) to print
</dd>
1741 <dd class=
"description">Title of job
</dd>
1742 <dt>num_options
</dt>
1743 <dd class=
"description">Number of options
</dd>
1745 <dd class=
"description">Options
</dd>
1747 <h4 class=
"returnvalue">Return Value
</h4>
1748 <p class=
"description">Job ID or
0 on error
</p>
1749 <h3 class=
"function"><span class=
"info"> CUPS
1.3 </span><a name=
"cupsRemoveDest">cupsRemoveDest
</a></h3>
1750 <p class=
"description">Remove a destination from the destination list.
</p>
1752 int cupsRemoveDest (
<br>
1753 const char *name,
<br>
1754 const char *instance,
<br>
1755 int num_dests,
<br>
1756 <a href=
"#cups_dest_t">cups_dest_t
</a> **dests
<br>
1758 <h4 class=
"parameters">Parameters
</h4>
1761 <dd class=
"description">Destination name
</dd>
1763 <dd class=
"description">Instance name or
<code>NULL
</code></dd>
1765 <dd class=
"description">Number of destinations
</dd>
1767 <dd class=
"description">Destinations
</dd>
1769 <h4 class=
"returnvalue">Return Value
</h4>
1770 <p class=
"description">New number of destinations
</p>
1771 <h4 class=
"discussion">Discussion
</h4>
1772 <p class=
"discussion">Removing a destination/instance does not delete the class or printer
1773 queue, merely the lpoptions for that destination/instance. Use the
1774 <a href=
"#cupsSetDests"><code>cupsSetDests
</code></a> or
<a href=
"#cupsSetDests2"><code>cupsSetDests2
</code></a> functions to save the new
1775 options for the user.
1778 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsRemoveOption">cupsRemoveOption
</a></h3>
1779 <p class=
"description">Remove an option from an option array.
</p>
1781 int cupsRemoveOption (
<br>
1782 const char *name,
<br>
1783 int num_options,
<br>
1784 <a href=
"#cups_option_t">cups_option_t
</a> **options
<br>
1786 <h4 class=
"parameters">Parameters
</h4>
1789 <dd class=
"description">Option name
</dd>
1790 <dt>num_options
</dt>
1791 <dd class=
"description">Current number of options
</dd>
1793 <dd class=
"description">Options
</dd>
1795 <h4 class=
"returnvalue">Return Value
</h4>
1796 <p class=
"description">New number of options
</p>
1797 <h3 class=
"function"><a name=
"cupsServer">cupsServer
</a></h3>
1798 <p class=
"description">Return the hostname/address of the default server.
</p>
1800 const char *cupsServer (void);
</p>
1801 <h4 class=
"returnvalue">Return Value
</h4>
1802 <p class=
"description">Server name
</p>
1803 <h4 class=
"discussion">Discussion
</h4>
1804 <p class=
"discussion">The returned value can be a fully-qualified hostname, a numeric
1805 IPv4 or IPv6 address, or a domain socket pathname.
</p>
1806 <h3 class=
"function"><span class=
"info"> CUPS
1.3 </span><a name=
"cupsSetDefaultDest">cupsSetDefaultDest
</a></h3>
1807 <p class=
"description">Set the default destination.
</p>
1809 void cupsSetDefaultDest (
<br>
1810 const char *name,
<br>
1811 const char *instance,
<br>
1812 int num_dests,
<br>
1813 <a href=
"#cups_dest_t">cups_dest_t
</a> *dests
<br>
1815 <h4 class=
"parameters">Parameters
</h4>
1818 <dd class=
"description">Destination name
</dd>
1820 <dd class=
"description">Instance name or
<code>NULL
</code></dd>
1822 <dd class=
"description">Number of destinations
</dd>
1824 <dd class=
"description">Destinations
</dd>
1826 <h3 class=
"function"><a name=
"cupsSetDests">cupsSetDests
</a></h3>
1827 <p class=
"description">Save the list of destinations for the default server.
</p>
1829 void cupsSetDests (
<br>
1830 int num_dests,
<br>
1831 <a href=
"#cups_dest_t">cups_dest_t
</a> *dests
<br>
1833 <h4 class=
"parameters">Parameters
</h4>
1836 <dd class=
"description">Number of destinations
</dd>
1838 <dd class=
"description">Destinations
</dd>
1840 <h4 class=
"discussion">Discussion
</h4>
1841 <p class=
"discussion">This function saves the destinations to /etc/cups/lpoptions when run
1842 as root and ~/.cups/lpoptions when run as a normal user.
</p>
1843 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21 </span><a name=
"cupsSetDests2">cupsSetDests2
</a></h3>
1844 <p class=
"description">Save the list of destinations for the specified server.
</p>
1846 int cupsSetDests2 (
<br>
1847 http_t *http,
<br>
1848 int num_dests,
<br>
1849 <a href=
"#cups_dest_t">cups_dest_t
</a> *dests
<br>
1851 <h4 class=
"parameters">Parameters
</h4>
1854 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1856 <dd class=
"description">Number of destinations
</dd>
1858 <dd class=
"description">Destinations
</dd>
1860 <h4 class=
"returnvalue">Return Value
</h4>
1861 <p class=
"description">0 on success, -
1 on error
</p>
1862 <h4 class=
"discussion">Discussion
</h4>
1863 <p class=
"discussion">This function saves the destinations to /etc/cups/lpoptions when run
1864 as root and ~/.cups/lpoptions when run as a normal user.
1867 <h3 class=
"function"><a name=
"cupsSetEncryption">cupsSetEncryption
</a></h3>
1868 <p class=
"description">Set the encryption preference.
</p>
1870 void cupsSetEncryption (
<br>
1871 http_encryption_t e
<br>
1873 <h4 class=
"parameters">Parameters
</h4>
1876 <dd class=
"description">New encryption preference
</dd>
1878 <h3 class=
"function"><a name=
"cupsSetPasswordCB">cupsSetPasswordCB
</a></h3>
1879 <p class=
"description">Set the password callback for CUPS.
</p>
1881 void cupsSetPasswordCB (
<br>
1882 <a href=
"#cups_password_cb_t">cups_password_cb_t
</a> cb
<br>
1884 <h4 class=
"parameters">Parameters
</h4>
1887 <dd class=
"description">Callback function
</dd>
1889 <h4 class=
"discussion">Discussion
</h4>
1890 <p class=
"discussion">Pass
<code>NULL
</code> to restore the default (console) password callback.
</p>
1891 <h3 class=
"function"><a name=
"cupsSetServer">cupsSetServer
</a></h3>
1892 <p class=
"description">Set the default server name.
</p>
1894 void cupsSetServer (
<br>
1895 const char *server
<br>
1897 <h4 class=
"parameters">Parameters
</h4>
1900 <dd class=
"description">Server name
</dd>
1902 <h4 class=
"discussion">Discussion
</h4>
1903 <p class=
"discussion">The
"server
" string can be a fully-qualified hostname, a numeric
1904 IPv4 or IPv6 address, or a domain socket pathname. Pass
<code>NULL
</code> to
1905 restore the default server name.
</p>
1906 <h3 class=
"function"><a name=
"cupsSetUser">cupsSetUser
</a></h3>
1907 <p class=
"description">Set the default user name.
</p>
1909 void cupsSetUser (
<br>
1910 const char *user
<br>
1912 <h4 class=
"parameters">Parameters
</h4>
1915 <dd class=
"description">User name
</dd>
1917 <h4 class=
"discussion">Discussion
</h4>
1918 <p class=
"discussion">Pass
<code>NULL
</code> to restore the default user name.
</p>
1919 <h3 class=
"function"><span class=
"info"> CUPS
1.4 </span><a name=
"cupsStartDocument">cupsStartDocument
</a></h3>
1920 <p class=
"description">Add a document to a job created with cupsCreateJob().
</p>
1922 http_status_t cupsStartDocument (
<br>
1923 http_t *http,
<br>
1924 const char *name,
<br>
1925 int job_id,
<br>
1926 const char *docname,
<br>
1927 const char *format,
<br>
1928 int last_document
<br>
1930 <h4 class=
"parameters">Parameters
</h4>
1933 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1935 <dd class=
"description">Destination name
</dd>
1937 <dd class=
"description">Job ID from
<a href=
"#cupsCreateJob"><code>cupsCreateJob
</code></a></dd>
1939 <dd class=
"description">Name of document
</dd>
1941 <dd class=
"description">MIME type or
<code>CUPS_FORMAT_foo
</code></dd>
1942 <dt>last_document
</dt>
1943 <dd class=
"description">1 for last document in job,
0 otherwise
</dd>
1945 <h4 class=
"returnvalue">Return Value
</h4>
1946 <p class=
"description">HTTP status of request
</p>
1947 <h4 class=
"discussion">Discussion
</h4>
1948 <p class=
"discussion">Use
<a href=
"#cupsWriteRequestData"><code>cupsWriteRequestData
</code></a> to write data for the document and
1949 <a href=
"#cupsFinishDocument"><code>cupsFinishDocument
</code></a> to finish the document and get the submission status.
<br>
1951 The MIME type constants
<code>CUPS_FORMAT_AUTO
</code>,
<code>CUPS_FORMAT_PDF
</code>,
1952 <code>CUPS_FORMAT_POSTSCRIPT
</code>,
<code>CUPS_FORMAT_RAW
</code>, and
1953 <code>CUPS_FORMAT_TEXT
</code> are provided for the
"format
" argument, although
1954 any supported MIME type string can be supplied.
1957 <h3 class=
"function"><a name=
"cupsTempFd">cupsTempFd
</a></h3>
1958 <p class=
"description">Creates a temporary file.
</p>
1960 int cupsTempFd (
<br>
1961 char *filename,
<br>
1962 int len
<br>
1964 <h4 class=
"parameters">Parameters
</h4>
1967 <dd class=
"description">Pointer to buffer
</dd>
1969 <dd class=
"description">Size of buffer
</dd>
1971 <h4 class=
"returnvalue">Return Value
</h4>
1972 <p class=
"description">New file descriptor or -
1 on error
</p>
1973 <h4 class=
"discussion">Discussion
</h4>
1974 <p class=
"discussion">The temporary filename is returned in the filename buffer.
1975 The temporary file is opened for reading and writing.
</p>
1976 <h3 class=
"function"><span class=
"info"> DEPRECATED
</span><a name=
"cupsTempFile">cupsTempFile
</a></h3>
1977 <p class=
"description">Generates a temporary filename.
</p>
1979 char *cupsTempFile (
<br>
1980 char *filename,
<br>
1981 int len
<br>
1983 <h4 class=
"parameters">Parameters
</h4>
1986 <dd class=
"description">Pointer to buffer
</dd>
1988 <dd class=
"description">Size of buffer
</dd>
1990 <h4 class=
"returnvalue">Return Value
</h4>
1991 <p class=
"description">Filename or
<code>NULL
</code> on error
</p>
1992 <h4 class=
"discussion">Discussion
</h4>
1993 <p class=
"discussion">The temporary filename is returned in the filename buffer.
1994 This function is deprecated - use
<a href=
"#cupsTempFd"><code>cupsTempFd
</code></a> or
1995 <a href=
"#cupsTempFile2"><code>cupsTempFile2
</code></a> instead.
1998 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsTempFile2">cupsTempFile2
</a></h3>
1999 <p class=
"description">Creates a temporary CUPS file.
</p>
2001 cups_file_t *cupsTempFile2 (
<br>
2002 char *filename,
<br>
2003 int len
<br>
2005 <h4 class=
"parameters">Parameters
</h4>
2008 <dd class=
"description">Pointer to buffer
</dd>
2010 <dd class=
"description">Size of buffer
</dd>
2012 <h4 class=
"returnvalue">Return Value
</h4>
2013 <p class=
"description">CUPS file or
<code>NULL
</code> on error
</p>
2014 <h4 class=
"discussion">Discussion
</h4>
2015 <p class=
"discussion">The temporary filename is returned in the filename buffer.
2016 The temporary file is opened for writing.
2019 <h3 class=
"function"><a name=
"cupsUser">cupsUser
</a></h3>
2020 <p class=
"description">Return the current user's name.
</p>
2022 const char *cupsUser (void);
</p>
2023 <h4 class=
"returnvalue">Return Value
</h4>
2024 <p class=
"description">User name
</p>
2025 <h2 class=
"title"><a name=
"TYPES">Data Types
</a></h2>
2026 <h3 class=
"typedef"><a name=
"cups_dest_t">cups_dest_t
</a></h3>
2027 <p class=
"description">Destination
</p>
2029 typedef struct
<a href=
"#cups_dest_s">cups_dest_s
</a> cups_dest_t;
2031 <h3 class=
"typedef"><span class=
"info"> CUPS
1.4 </span><a name=
"cups_device_cb_t">cups_device_cb_t
</a></h3>
2032 <p class=
"description">Device callback
</p>
2034 typedef 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);
2036 <h3 class=
"typedef"><a name=
"cups_job_t">cups_job_t
</a></h3>
2037 <p class=
"description">Job
</p>
2039 typedef struct
<a href=
"#cups_job_s">cups_job_s
</a> cups_job_t;
2041 <h3 class=
"typedef"><a name=
"cups_option_t">cups_option_t
</a></h3>
2042 <p class=
"description">Printer Options
</p>
2044 typedef struct
<a href=
"#cups_option_s">cups_option_s
</a> cups_option_t;
2046 <h3 class=
"typedef"><a name=
"cups_password_cb_t">cups_password_cb_t
</a></h3>
2047 <p class=
"description">Password callback
</p>
2049 typedef const char *(*cups_password_cb_t)(const char *prompt);
2051 <h3 class=
"typedef"><a name=
"cups_ptype_t">cups_ptype_t
</a></h3>
2052 <p class=
"description">Printer type/capability bits
</p>
2054 typedef unsigned cups_ptype_t;
2056 <h2 class=
"title"><a name=
"STRUCTURES">Structures
</a></h2>
2057 <h3 class=
"struct"><a name=
"cups_dest_s">cups_dest_s
</a></h3>
2058 <p class=
"description">Destination
</p>
2059 <p class=
"code">struct cups_dest_s {
<br>
2060 char *name, *instance;
<br>
2061 int is_default;
<br>
2062 int num_options;
<br>
2063 <a href=
"#cups_option_t">cups_option_t
</a> *options;
<br>
2065 <h4 class=
"members">Members
</h4>
2068 <dd class=
"description">Local instance name or NULL
</dd>
2069 <dt>is_default
</dt>
2070 <dd class=
"description">Is this printer the default?
</dd>
2071 <dt>num_options
</dt>
2072 <dd class=
"description">Number of options
</dd>
2074 <dd class=
"description">Options
</dd>
2076 <h3 class=
"struct"><a name=
"cups_job_s">cups_job_s
</a></h3>
2077 <p class=
"description">Job
</p>
2078 <p class=
"code">struct cups_job_s {
<br>
2079 time_t completed_time;
<br>
2080 time_t creation_time;
<br>
2081 char *dest;
<br>
2082 char *format;
<br>
2083 int id;
<br>
2084 int priority;
<br>
2085 time_t processing_time;
<br>
2086 int size;
<br>
2087 ipp_jstate_t state;
<br>
2088 char *title;
<br>
2089 char *user;
<br>
2091 <h4 class=
"members">Members
</h4>
2093 <dt>completed_time
</dt>
2094 <dd class=
"description">Time the job was completed
</dd>
2095 <dt>creation_time
</dt>
2096 <dd class=
"description">Time the job was created
</dd>
2098 <dd class=
"description">Printer or class name
</dd>
2100 <dd class=
"description">Document format
</dd>
2102 <dd class=
"description">The job ID
</dd>
2104 <dd class=
"description">Priority (
1-
100)
</dd>
2105 <dt>processing_time
</dt>
2106 <dd class=
"description">Time the job was processed
</dd>
2108 <dd class=
"description">Size in kilobytes
</dd>
2110 <dd class=
"description">Job state
</dd>
2112 <dd class=
"description">Title/job name
</dd>
2114 <dd class=
"description">User the submitted the job
</dd>
2116 <h3 class=
"struct"><a name=
"cups_option_s">cups_option_s
</a></h3>
2117 <p class=
"description">Printer Options
</p>
2118 <p class=
"code">struct cups_option_s {
<br>
2119 char *name;
<br>
2120 char *value;
<br>
2122 <h4 class=
"members">Members
</h4>
2125 <dd class=
"description">Name of option
</dd>
2127 <dd class=
"description">Value of option
</dd>
2129 <h2 class=
"title"><a name=
"ENUMERATIONS">Constants
</a></h2>
2130 <h3 class=
"enumeration"><a name=
"cups_ptype_e">cups_ptype_e
</a></h3>
2131 <p class=
"description">Printer type/capability bit constants
</p>
2132 <h4 class=
"constants">Constants
</h4>
2134 <dt>CUPS_PRINTER_AUTHENTICATED
<span class=
"info"> CUPS
1.2 </span></dt>
2135 <dd class=
"description">Printer requires authentication
</dd>
2136 <dt>CUPS_PRINTER_BIND
</dt>
2137 <dd class=
"description">Can bind output
</dd>
2138 <dt>CUPS_PRINTER_BW
</dt>
2139 <dd class=
"description">Can do B
&W printing
</dd>
2140 <dt>CUPS_PRINTER_CLASS
</dt>
2141 <dd class=
"description">Printer class
</dd>
2142 <dt>CUPS_PRINTER_COLLATE
</dt>
2143 <dd class=
"description">Can collage copies
</dd>
2144 <dt>CUPS_PRINTER_COLOR
</dt>
2145 <dd class=
"description">Can do color printing
</dd>
2146 <dt>CUPS_PRINTER_COMMANDS
<span class=
"info"> CUPS
1.2 </span></dt>
2147 <dd class=
"description">Printer supports maintenance commands
</dd>
2148 <dt>CUPS_PRINTER_COPIES
</dt>
2149 <dd class=
"description">Can do copies
</dd>
2150 <dt>CUPS_PRINTER_COVER
</dt>
2151 <dd class=
"description">Can cover output
</dd>
2152 <dt>CUPS_PRINTER_DEFAULT
</dt>
2153 <dd class=
"description">Default printer on network
</dd>
2154 <dt>CUPS_PRINTER_DELETE
<span class=
"info"> CUPS
1.2 </span></dt>
2155 <dd class=
"description">Delete printer
</dd>
2156 <dt>CUPS_PRINTER_DISCOVERED
<span class=
"info"> CUPS
1.3 </span></dt>
2157 <dd class=
"description">Printer was automatically discovered and added
</dd>
2158 <dt>CUPS_PRINTER_DUPLEX
</dt>
2159 <dd class=
"description">Can do duplexing
</dd>
2160 <dt>CUPS_PRINTER_FAX
</dt>
2161 <dd class=
"description">Fax queue
</dd>
2162 <dt>CUPS_PRINTER_IMPLICIT
</dt>
2163 <dd class=
"description">Implicit class
</dd>
2164 <dt>CUPS_PRINTER_LARGE
</dt>
2165 <dd class=
"description">Can do D/E/A1/A0
</dd>
2166 <dt>CUPS_PRINTER_LOCAL
</dt>
2167 <dd class=
"description">Local printer or class
</dd>
2168 <dt>CUPS_PRINTER_MEDIUM
</dt>
2169 <dd class=
"description">Can do Tabloid/B/C/A3/A2
</dd>
2170 <dt>CUPS_PRINTER_NOT_SHARED
<span class=
"info"> CUPS
1.2 </span></dt>
2171 <dd class=
"description">Printer is not shared
</dd>
2172 <dt>CUPS_PRINTER_PUNCH
</dt>
2173 <dd class=
"description">Can punch output
</dd>
2174 <dt>CUPS_PRINTER_REJECTING
</dt>
2175 <dd class=
"description">Printer is rejecting jobs
</dd>
2176 <dt>CUPS_PRINTER_REMOTE
</dt>
2177 <dd class=
"description">Remote printer or class
</dd>
2178 <dt>CUPS_PRINTER_SMALL
</dt>
2179 <dd class=
"description">Can do Letter/Legal/A4
</dd>
2180 <dt>CUPS_PRINTER_SORT
</dt>
2181 <dd class=
"description">Can sort output
</dd>
2182 <dt>CUPS_PRINTER_STAPLE
</dt>
2183 <dd class=
"description">Can staple output
</dd>
2184 <dt>CUPS_PRINTER_VARIABLE
</dt>
2185 <dd class=
"description">Can do variable sizes
</dd>