1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
3 <!-- SECTION: Programming -->
5 <title>CUPS API
</title>
6 <meta name=
"keywords" content=
"Programming">
7 <meta name=
"creator" content=
"Mini-XML v2.6">
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 8087 2008-10-27 21:37:05Z 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">
373 <ul class=
"subcontents">
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=
"#cupsAdminCreateWindowsPPD" title=
"Create the Windows PPD file for a printer.">cupsAdminCreateWindowsPPD
</a></li>
386 <li><a href=
"#cupsAdminExportSamba" title=
"Export a printer to Samba.">cupsAdminExportSamba
</a></li>
387 <li><a href=
"#cupsAdminGetServerSettings" title=
"Get settings from the server.">cupsAdminGetServerSettings
</a></li>
388 <li><a href=
"#cupsAdminSetServerSettings" title=
"Set settings on the server.">cupsAdminSetServerSettings
</a></li>
389 <li><a href=
"#cupsCancelJob" title=
"Cancel a print job on the default server.">cupsCancelJob
</a></li>
390 <li><a href=
"#cupsCancelJob2" title=
"Cancel or purge a print job.">cupsCancelJob2
</a></li>
391 <li><a href=
"#cupsCreateJob" title=
"Create an empty job for streaming.">cupsCreateJob
</a></li>
392 <li><a href=
"#cupsEncryption" title=
"Get the default encryption settings.">cupsEncryption
</a></li>
393 <li><a href=
"#cupsFinishDocument" title=
"Finish sending a document.">cupsFinishDocument
</a></li>
394 <li><a href=
"#cupsFreeDests" title=
"Free the memory used by the list of destinations.">cupsFreeDests
</a></li>
395 <li><a href=
"#cupsFreeJobs" title=
"Free memory used by job data.">cupsFreeJobs
</a></li>
396 <li><a href=
"#cupsFreeOptions" title=
"Free all memory used by options.">cupsFreeOptions
</a></li>
397 <li><a href=
"#cupsGetClasses" title=
"Get a list of printer classes from the default server.">cupsGetClasses
</a></li>
398 <li><a href=
"#cupsGetDefault" title=
"Get the default printer or class for the default server.">cupsGetDefault
</a></li>
399 <li><a href=
"#cupsGetDefault2" title=
"Get the default printer or class for the specified server.">cupsGetDefault2
</a></li>
400 <li><a href=
"#cupsGetDest" title=
"Get the named destination from the list.">cupsGetDest
</a></li>
401 <li><a href=
"#cupsGetDests" title=
"Get the list of destinations from the default server.">cupsGetDests
</a></li>
402 <li><a href=
"#cupsGetDests2" title=
"Get the list of destinations from the specified server.">cupsGetDests2
</a></li>
403 <li><a href=
"#cupsGetJobs" title=
"Get the jobs from the default server.">cupsGetJobs
</a></li>
404 <li><a href=
"#cupsGetJobs2" title=
"Get the jobs from the specified server.">cupsGetJobs2
</a></li>
405 <li><a href=
"#cupsGetNamedDest" title=
"Get options for the named destination.">cupsGetNamedDest
</a></li>
406 <li><a href=
"#cupsGetOption" title=
"Get an option value.">cupsGetOption
</a></li>
407 <li><a href=
"#cupsGetPPD" title=
"Get the PPD file for a printer on the default server.">cupsGetPPD
</a></li>
408 <li><a href=
"#cupsGetPPD2" title=
"Get the PPD file for a printer from the specified server.">cupsGetPPD2
</a></li>
409 <li><a href=
"#cupsGetPPD3" title=
"Get the PPD file for a printer on the specified
410 server if it has changed.">cupsGetPPD3
</a></li>
411 <li><a href=
"#cupsGetPassword" title=
"Get a password from the user.">cupsGetPassword
</a></li>
412 <li><a href=
"#cupsGetPrinters" title=
"Get a list of printers from the default server.">cupsGetPrinters
</a></li>
413 <li><a href=
"#cupsGetServerPPD" title=
"Get an available PPD file from the server.">cupsGetServerPPD
</a></li>
414 <li><a href=
"#cupsLangDefault" title=
"Return the default language.">cupsLangDefault
</a></li>
415 <li><a href=
"#cupsLangEncoding" title=
"Return the character encoding (us-ascii, etc.)
416 for the given language.">cupsLangEncoding
</a></li>
417 <li><a href=
"#cupsLangFlush" title=
"Flush all language data out of the cache.">cupsLangFlush
</a></li>
418 <li><a href=
"#cupsLangFree" title=
"Free language data.">cupsLangFree
</a></li>
419 <li><a href=
"#cupsLangGet" title=
"Get a language.">cupsLangGet
</a></li>
420 <li><a href=
"#cupsLastError" title=
"Return the last IPP status code.">cupsLastError
</a></li>
421 <li><a href=
"#cupsLastErrorString" title=
"Return the last IPP status-message.">cupsLastErrorString
</a></li>
422 <li><a href=
"#cupsNotifySubject" title=
"Return the subject for the given notification message.">cupsNotifySubject
</a></li>
423 <li><a href=
"#cupsNotifyText" title=
"Return the text for the given notification message.">cupsNotifyText
</a></li>
424 <li><a href=
"#cupsParseOptions" title=
"Parse options from a command-line argument.">cupsParseOptions
</a></li>
425 <li><a href=
"#cupsPrintFile" title=
"Print a file to a printer or class on the default server.">cupsPrintFile
</a></li>
426 <li><a href=
"#cupsPrintFile2" title=
"Print a file to a printer or class on the specified
427 server.">cupsPrintFile2
</a></li>
428 <li><a href=
"#cupsPrintFiles" title=
"Print one or more files to a printer or class on the
429 default server.">cupsPrintFiles
</a></li>
430 <li><a href=
"#cupsPrintFiles2" title=
"Print one or more files to a printer or class on the
431 specified server.">cupsPrintFiles2
</a></li>
432 <li><a href=
"#cupsRemoveDest" title=
"Remove a destination from the destination list.">cupsRemoveDest
</a></li>
433 <li><a href=
"#cupsRemoveOption" title=
"Remove an option from an option array.">cupsRemoveOption
</a></li>
434 <li><a href=
"#cupsServer" title=
"Return the hostname/address of the default server.">cupsServer
</a></li>
435 <li><a href=
"#cupsSetDefaultDest" title=
"Set the default destination.">cupsSetDefaultDest
</a></li>
436 <li><a href=
"#cupsSetDests" title=
"Save the list of destinations for the default server.">cupsSetDests
</a></li>
437 <li><a href=
"#cupsSetDests2" title=
"Save the list of destinations for the specified server.">cupsSetDests2
</a></li>
438 <li><a href=
"#cupsSetEncryption" title=
"Set the encryption preference.">cupsSetEncryption
</a></li>
439 <li><a href=
"#cupsSetPasswordCB" title=
"Set the password callback for CUPS.">cupsSetPasswordCB
</a></li>
440 <li><a href=
"#cupsSetServer" title=
"Set the default server name.">cupsSetServer
</a></li>
441 <li><a href=
"#cupsSetUser" title=
"Set the default user name.">cupsSetUser
</a></li>
442 <li><a href=
"#cupsStartDocument" title=
"Add a document to a job created with cupsCreateJob().">cupsStartDocument
</a></li>
443 <li><a href=
"#cupsTempFd" title=
"Creates a temporary file.">cupsTempFd
</a></li>
444 <li><a href=
"#cupsTempFile" title=
"Generates a temporary filename.">cupsTempFile
</a></li>
445 <li><a href=
"#cupsTempFile2" title=
"Creates a temporary CUPS file.">cupsTempFile2
</a></li>
446 <li><a href=
"#cupsUser" title=
"Return the current user's name.">cupsUser
</a></li>
448 <li><a href=
"#TYPES">Data Types
</a><ul class=
"code">
449 <li><a href=
"#cups_dest_t" title=
"Destination">cups_dest_t
</a></li>
450 <li><a href=
"#cups_device_cb_t" title=
"Device callback ">cups_device_cb_t
</a></li>
451 <li><a href=
"#cups_job_t" title=
"Job">cups_job_t
</a></li>
452 <li><a href=
"#cups_option_t" title=
"Printer Options">cups_option_t
</a></li>
453 <li><a href=
"#cups_password_cb_t" title=
"Password callback">cups_password_cb_t
</a></li>
454 <li><a href=
"#cups_ptype_t" title=
"Printer type/capability bits">cups_ptype_t
</a></li>
456 <li><a href=
"#STRUCTURES">Structures
</a><ul class=
"code">
457 <li><a href=
"#cups_dest_s" title=
"Destination">cups_dest_s
</a></li>
458 <li><a href=
"#cups_job_s" title=
"Job">cups_job_s
</a></li>
459 <li><a href=
"#cups_option_s" title=
"Printer Options">cups_option_s
</a></li>
461 <li><a href=
"#ENUMERATIONS">Constants
</a><ul class=
"code">
462 <li><a href=
"#cups_ptype_e" title=
"Printer type/capability bit constants">cups_ptype_e
</a></li>
465 "$Id: api-cups.shtml 7337 2008-02-22 04:44:04Z mike $"
467 CUPS API introduction for the Common UNIX Printing System (CUPS).
469 Copyright 2007-2008 by Apple Inc.
470 Copyright 1997-2006 by Easy Software Products, all rights reserved.
472 These coded instructions, statements, and computer programs are the
473 property of Apple Inc. and are protected by Federal copyright
474 law. Distribution and use rights are outlined in the file "LICENSE.txt"
475 which should have been included with this file. If this file is
476 file is missing or damaged, see the license at "http://www.cups.org/".
479 <h2 class='title'
><a name='OVERVIEW'
>Overview
</a></h2>
481 <p>The CUPS API provides the convenience functions needed to support
482 applications, filters, printer drivers, and backends that need to interface
483 with the CUPS scheduler.
</p>
485 <h3><a name='CLIENTS_AND_SERVERS'
>Clients and Servers
</a></h3>
487 <p>CUPS is based on the Internet Printing Protocol (
"IPP"), which allows
488 clients (applications) to communicate with a server (the scheduler) to get a
489 list of printers, send print jobs, and so forth. You identify which server
490 you want to communicate with using a pointer to the opaque structure
491 <code>http_t
</code>. All of the examples in this document use the
492 <code>CUPS_HTTP_DEFAULT
</code> constant, referring to the default connection
493 to the scheduler. The
<a href='api-httpipp.html' target='_top'
>HTTP and IPP
494 APIs
</a> document provides more information on server connections.
</p>
496 <h3><a name='PRINTERS_AND_CLASSES'
>Printers and Classes
</a></h3>
498 <p>Printers and classes (collections of printers) are accessed through
499 the
<a href=
"#cups_dest_t"><code>cups_dest_t
</code></a> structure which
500 includes the name (
<code>name
</code>), instance (
<code>instance
</code> -
501 a way of selecting certain saved options/settings), and the options and
502 attributes associated with that destination (
<code>num_options
</code> and
503 <code>options
</code>). Destinations are created using the
504 <a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> function and freed
505 using the
<a href='#cupsFreeDests'
><code>cupsFreeDests
</code></a> function.
506 The
<a href='#cupsGetDest'
><code>cupsGetDest
</code></a> function finds a
507 specific destination for printing:
</p>
509 <pre class='example'
>
510 #include
<cups/cups.h
>
512 <a href='#cups_dest_t'
>cups_dest_t
</a> *dests;
513 int num_dests =
<a href='#cupsGetDests'
>cupsGetDests
</a>(
&dests);
514 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest =
<a href='#cupsGetDest'
>cupsGetDest
</a>(
"name", NULL, num_dests, dests);
516 /* do something wiith dest */
518 <a href='#cupsFreeDests'
>cupsFreeDests
</a>(num_dests, dests);
521 <p>Passing
<code>NULL
</code> to
522 <a href='#cupsGetDest'
><code>cupsGetDest
</code></a> for the destination name
523 will return the default destination. Similarly, passing a
<code>NULL
</code>
524 instance will return the default instance for that destination.
</p>
526 <div class='table'
><table summary='Table
1: Printer Attributes' width='
80%'
>
527 <caption>Table
1:
<a name='TABLE1'
>Printer Attributes
</a></caption>
530 <th>Attribute Name
</th>
536 <td>"auth-info-required"</td>
537 <td>The type of authentication required for printing to this
538 destination:
"none",
"username,password",
"domain,username,password",
539 or
"negotiate" (Kerberos)
</td>
542 <td>"printer-info"</td>
543 <td>The human-readable description of the destination such as
"My
547 <td>"printer-is-accepting-jobs"</td>
548 <td>"1" if the destination is accepting new jobs,
"0" if not.
</td>
551 <td>"printer-is-shared"</td>
552 <td>"1" if the destination is being shared with other computers,
"0" if
556 <td>"printer-location"</td>
557 <td>The human-readable location of the destination such as
"Lab 4".
</td>
560 <td>"printer-make-and-model"</td>
561 <td>The human-readable make and model of the destination such as
"HP
562 LaserJet 4000 Series".
</td>
565 <td>"printer-state"</td>
566 <td>"3" if the destination is idle,
"4" if the destination is printing
567 a job, and
"5" if the destination is stopped.
</td>
570 <td>"printer-state-change-time"</td>
571 <td>The UNIX time when the destination entered the current state.
</td>
574 <td>"printer-state-reasons"</td>
575 <td>Additional comma-delimited state keywords for the destination
576 such as
"media-tray-empty-error" and
"toner-low-warning".
</td>
579 <td>"printer-type"</td>
580 <td>The
<a href='#cups_printer_t'
><code>cups_printer_t
</code></a>
581 value associated with the destination.
</td>
586 <h3><a name='OPTIONS'
>Options
</a></h3>
588 <p>Options are stored in arrays of
589 <a href='#cups_option_t'
><code>cups_option_t
</code></a> structures. Each
590 option has a name (
<code>name
</code>) and value (
<code>value
</code>)
591 associated with it. The
<a href='#cups_dest_t'
><code>cups_dest_t
</code></a>
592 <code>num_options
</code> and
<code>options
</code> members contain the
593 default options for a particular destination, along with several informational
594 attributes about the destination as shown in
<a href='#TABLE1'
>Table
1</a>.
595 The
<a href='#cupsGetOption'
><code>cupsGetOption
</code></a> function gets
596 the value for the named option. For example, the following code lists the
597 available destinations and their human-readable descriptions:
</p>
599 <pre class='example'
>
600 #include
<cups/cups.h
>
602 <a href='#cups_dest_t'
>cups_dest_t
</a> *dests;
603 int num_dests =
<a href='#cupsGetDests'
>cupsGetDests
</a>(
&dests);
604 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
608 for (i = num_dests, dest = dests; i
> 0; i --, dest ++)
609 if (dest-
>instance == NULL)
611 value =
<a href='#cupsGetOption'
>cupsGetOption
</a>(
"printer-info", dest-
>num_options, dest-
>options);
612 printf(
"%s (%s)\n", dest-
>name, value ? value :
"no description");
615 <a href='#cupsFreeDests'
>cupsFreeDests
</a>(num_dests, dests);
618 <p>You can create your own option arrays using the
619 <a href='#cupsAddOption'
><code>cupsAddOption
</code></a> function, which
620 adds a single named option to an array:
</p>
622 <pre class='example'
>
623 #include
<cups/cups.h
>
626 <a href='#cups_option_t'
>cups_option_t
</a> *options = NULL;
628 /* The returned num_options value is updated as needed */
629 num_options =
<a href='#cupsAddOption'
>cupsAddOption
</a>(
"first",
"value", num_options,
&options);
631 /* This adds a second option value */
632 num_options =
<a href='#cupsAddOption'
>cupsAddOption
</a>(
"second",
"value", num_options,
&options);
634 /* This replaces the first option we added */
635 num_options =
<a href='#cupsAddOption'
>cupsAddOption
</a>(
"first",
"new value", num_options,
&options);
638 <p>Use a
<code>for
</code> loop to copy the options from a destination:
</p>
640 <pre class='example'
>
641 #include
<cups/cups.h
>
645 <a href='#cups_option_t'
>cups_option_t
</a> *options = NULL;
646 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
648 for (i =
0; i < dest-
>num_options; i ++)
649 num_options =
<a href='#cupsAddOption'
>cupsAddOption
</a>(dest-
>options[i].name, dest-
>options[i].value,
650 num_options,
&options);
653 <p>Use the
<a href='#cupsFreeOptions'
><code>cupsFreeOptions
</code></a>
654 function to free the options array when you are done using it:
</p>
656 <pre class='example'
>
657 <a href='#cupsFreeOptions'
>cupsFreeOptions
</a>(num_options, options);
660 <h3><a name='PRINT_JOBS'
>Print Jobs
</a></h3>
662 <p>Print jobs are identified by a locally-unique job ID number from
1 to
663 2<sup>31</sup>-
1 and have options and one or more files for printing to a
664 single destination. The
<a href='#cupsPrintFile'
><code>cupsPrintFile
</code></a>
665 function creates a new job with one file. The following code prints the CUPS
668 <pre class='example'
>
669 #include
<cups/cups.h
>
671 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
673 <a href='#cups_option_t'
>cups_option_t
</a> *options;
676 /* Print a single file */
677 job_id =
<a href='#cupsPrintFile'
>cupsPrintFile
</a>(dest-
>name,
"/usr/share/cups/data/testprint.ps",
678 "Test Print", num_options, options);
681 <p>The
<a href='#cupsPrintFiles'
><code>cupsPrintFiles
</code></a> function
682 creates a job with multiple files. The files are provided in a
683 <code>char *
</code> array:
</p>
685 <pre class='example'
>
686 #include
<cups/cups.h
>
688 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
690 <a href='#cups_option_t'
>cups_option_t
</a> *options;
692 char *files[
3] = {
"file1.pdf",
"file2.pdf",
"file3.pdf" };
694 /* Print three files */
695 job_id =
<a href='#cupsPrintFiles'
>cupsPrintFiles
</a>(dest-
>name,
3, files,
"Test Print", num_options, options);
698 <p>Finally, the
<a href='#cupsCreateJob'
><code>cupsCreateJob
</code></a>
699 function creates a new job with no files in it. Files are added using the
700 <a href='#cupsStartDocument'
><code>cupsStartDocument
</code></a>,
701 <a href='api-httpipp.html#cupsWriteRequestData'
><code>cupsWriteRequestData
</code></a>,
702 and
<a href='#cupsFinishDocument'
><code>cupsFinishDocument
</code></a> functions.
703 The following example creates a job with
10 text files for printing:
</p>
705 <pre class='example'
>
706 #include
<cups/cups.h
>
708 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
710 <a href='#cups_option_t'
>cups_option_t
</a> *options;
716 job_id =
<a href='#cupsCreateJob'
>cupsCreateJob
</a>(CUPS_HTTP_DEFAULT, dest-
>name,
"10 Text Files",
717 num_options, options);
719 /* If the job is created, add
10 files */
722 for (i =
1; i
<=
10; i ++)
724 snprintf(buffer, sizeof(buffer),
"file%d.txt", i);
726 <a href='#cupsStartDocument'
>cupsStartDocument
</a>(CUPS_HTTP_DEFAULT, dest-
>name, job_id, buffer,
727 CUPS_FORMAT_TEXT, i ==
10);
729 snprintf(buffer, sizeof(buffer),
737 /* cupsWriteRequestData can be called as many times as needed */
738 <a href='#cupsWriteRequestData'
>cupsWriteRequestData
</a>(CUPS_HTTP_DEFAULT, buffer, strlen(buffer));
740 <a href='#cupsFinishDocument'
>cupsFinishDocument
</a>(CUPS_HTTP_DEFAULT, dest-
>name);
745 <p>Once you have created a job, you can monitor its status using the
746 <a href='#cupsGetJobs'
><code>cupsGetJobs
</code></a> function, which returns
747 an array of
<a href='#cups_job_t'
><code>cups_job_t
</code></a> structures.
748 Each contains the job ID (
<code>id
</code>), destination name
749 (
<code>dest
</code>), title (
<code>title
</code>), and other information
750 associated with the job. The job array is freed using the
751 <a href='#cupsFreeJobs'
><code>cupsFreeJobs
</code></a> function. The following
752 example monitors a specific job ID, showing the current job state once every
753 5 seconds until the job is completed:
</p>
755 <pre class='example'
>
756 #include
<cups/cups.h
>
758 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
761 <a href='#cups_job_t'
>cups_job_t
</a> *jobs;
763 ipp_jstate_t job_state = IPP_JOB_PENDING;
765 while (job_state
< IPP_JOB_STOPPED)
767 /* Get my jobs (
1) with any state (-
1) */
768 num_jobs =
<a href='#cupsGetJobs'
>cupsGetJobs
</a>(
&jobs, dest-
>name,
1, -
1);
770 /* Loop to find my job */
771 job_state = IPP_JOB_COMPLETED;
773 for (i =
0; i
< num_jobs; i ++)
774 if (jobs[i].id == job_id)
776 job_state = jobs[i].state;
780 /* Free the job array */
781 <a href='#cupsFreeJobs'
>cupsFreeJobs
</a>(num_jobs, jobs);
783 /* Show the current state */
786 case IPP_JOB_PENDING :
787 printf(
"Job %d is pending.\n", job_id);
790 printf(
"Job %d is held.\n", job_id);
792 case IPP_JOB_PROCESSING :
793 printf(
"Job %d is processing.\n", job_id);
795 case IPP_JOB_STOPPED :
796 printf(
"Job %d is stopped.\n", job_id);
798 case IPP_JOB_CANCELED :
799 printf(
"Job %d is canceled.\n", job_id);
801 case IPP_JOB_ABORTED :
802 printf(
"Job %d is aborted.\n", job_id);
804 case IPP_JOB_COMPLETED :
805 printf(
"Job %d is completed.\n", job_id);
809 /* Sleep if the job is not finished */
810 if (job_state
< IPP_JOB_STOPPED)
815 <p>To cancel a job, use the
816 <a href='#cupsCancelJob'
><code>cupsCancelJob
</code></a> function with the
819 <pre class='example'
>
820 #include
<cups/cups.h
>
822 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
825 <a href='#cupsCancelJob'
>cupsCancelJob
</a>(dest-
>name, job_id);
828 <h3><a name='ERROR_HANDLING'
>Error Handling
</a></h3>
830 <p>If any of the CUPS API printing functions returns an error, the reason for
831 that error can be found by calling the
832 <a href='#cupsLastError'
><code>cupsLastError
</code></a> and
833 <a href='#cupsLastErrorString'
><code>cupsLastErrorString
</code></a> functions.
834 <a href='#cupsLastError'
><code>cupsLastError
</code></a> returns the last IPP
836 (
<a href='api-httpipp.html#ipp_status_t'
><code>ipp_status_t
</code></a>)
837 that was encountered, while
838 <a href='#cupsLastErrorString'
><code>cupsLastErrorString
</code></a> returns
839 a (localized) human-readable string that can be shown to the user. For example,
840 if any of the job creation functions returns a job ID of
0, you can use
841 <a href='#cupsLastErrorString'
><code>cupsLastErrorString
</code></a> to show
842 the reason why the job could not be created:
</p>
844 <pre class='example'
>
845 #include
<cups/cups.h
>
850 puts(cupsLastErrorString());
853 <h3><a name='PASSWORDS_AND_AUTHENTICATION'
>Passwords and Authentication
</a></h3>
855 <p>CUPS supports authentication of any request, including submission of print
856 jobs. The default mechanism for getting the username and password is to use the
857 login user and a password from the console.
</p>
859 <p>To support other types of applications, in particular Graphical User
860 Interfaces (
"GUIs"), the CUPS API provides functions to set the default
861 username and to register a callback function that returns a password string.
</p>
863 <p>The
<a href=
"#cupsSetPasswordCB"><code>cupsSetPasswordCB
</code></a>
864 function is used to set a password callback in your program. Only one
865 function can be used at any time.
</p>
867 <p>The
<a href=
"#cupsSetUser"><code>cupsSetUser
</code></a> function sets the
868 current username for authentication. This function can be called by your
869 password callback function to change the current username as needed.
</p>
871 <p>The following example shows a simple password callback that gets a
872 username and password from the user:
</p>
874 <pre class='example'
>
875 #include
<cups/cups.h
>
878 my_password_cb(const char *prompt)
885 /* Get a username from the user */
886 printf(
"Username: ");
887 if (fgets(user, sizeof(user), stdin) == NULL)
890 /* Strip the newline from the string and set the user */
891 user[strlen(user) -
1] = '\
0';
893 <a href='#cupsSetUser'
>cupsSetUser
</a>(user);
895 /* Use getpass() to ask for the password... */
896 return (getpass(
"Password: "));
899 <a href='#cupsSetPasswordCB'
>cupsSetPasswordCB
</a>(my_password_cb);
902 <p>Similarly, a GUI could display the prompt string in a window with input
903 fields for the username and password. The username should default to the
904 string returned by the
<a href=
"#cupsUser"><code>cupsUser
</code></a>
906 <h2 class=
"title"><a name=
"FUNCTIONS">Functions
</a></h2>
907 <h3 class=
"function"><a name=
"cupsAddDest">cupsAddDest
</a></h3>
908 <p class=
"description">Add a destination to the list of destinations.
</p>
910 int cupsAddDest (
<br>
911 const char *name,
<br>
912 const char *instance,
<br>
913 int num_dests,
<br>
914 <a href=
"#cups_dest_t">cups_dest_t
</a> **dests
<br>
916 <h4 class=
"parameters">Parameters
</h4>
919 <dd class=
"description">Destination name
</dd>
921 <dd class=
"description">Instance name or
<code>NULL
</code> for none/primary
</dd>
923 <dd class=
"description">Number of destinations
</dd>
925 <dd class=
"description">Destinations
</dd>
927 <h4 class=
"returnvalue">Return Value
</h4>
928 <p class=
"description">New number of destinations
</p>
929 <h4 class=
"discussion">Discussion
</h4>
930 <p class=
"discussion">This function cannot be used to add a new class or printer queue,
931 it only adds a new container of saved options for the named
932 destination or instance.
<br>
934 If the named destination already exists, the destination list is
935 returned unchanged. Adding a new instance of a destination creates
936 a copy of that destination's options.
<br>
938 Use the
<a href=
"#cupsSaveDests"><code>cupsSaveDests
</code></a> function to save the updated list of
939 destinations to the user's lpoptions file.
</p>
940 <h3 class=
"function"><a name=
"cupsAddOption">cupsAddOption
</a></h3>
941 <p class=
"description">Add an option to an option array.
</p>
943 int cupsAddOption (
<br>
944 const char *name,
<br>
945 const char *value,
<br>
946 int num_options,
<br>
947 <a href=
"#cups_option_t">cups_option_t
</a> **options
<br>
949 <h4 class=
"parameters">Parameters
</h4>
952 <dd class=
"description">Name of option
</dd>
954 <dd class=
"description">Value of option
</dd>
956 <dd class=
"description">Number of options
</dd>
958 <dd class=
"description">Pointer to options
</dd>
960 <h4 class=
"returnvalue">Return Value
</h4>
961 <p class=
"description">Number of options
</p>
962 <h4 class=
"discussion">Discussion
</h4>
963 <p class=
"discussion">New option arrays can be initialized simply by passing
0 for the
964 "num_options
" parameter.
</p>
965 <h3 class=
"function"><span class=
"info"> CUPS
1.2/Mac OS X
10.5 </span><a name=
"cupsAdminCreateWindowsPPD">cupsAdminCreateWindowsPPD
</a></h3>
966 <p class=
"description">Create the Windows PPD file for a printer.
</p>
968 char *cupsAdminCreateWindowsPPD (
<br>
969 http_t *http,
<br>
970 const char *dest,
<br>
971 char *buffer,
<br>
972 int bufsize
<br>
974 <h4 class=
"parameters">Parameters
</h4>
977 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
979 <dd class=
"description">Printer or class
</dd>
981 <dd class=
"description">Filename buffer
</dd>
983 <dd class=
"description">Size of filename buffer
</dd>
985 <h4 class=
"returnvalue">Return Value
</h4>
986 <p class=
"description">PPD file or NULL
</p>
987 <h3 class=
"function"><span class=
"info"> CUPS
1.2/Mac OS X
10.5 </span><a name=
"cupsAdminExportSamba">cupsAdminExportSamba
</a></h3>
988 <p class=
"description">Export a printer to Samba.
</p>
990 int cupsAdminExportSamba (
<br>
991 const char *dest,
<br>
992 const char *ppd,
<br>
993 const char *samba_server,
<br>
994 const char *samba_user,
<br>
995 const char *samba_password,
<br>
996 FILE *logfile
<br>
998 <h4 class=
"parameters">Parameters
</h4>
1001 <dd class=
"description">Destination to export
</dd>
1003 <dd class=
"description">PPD file
</dd>
1004 <dt>samba_server
</dt>
1005 <dd class=
"description">Samba server
</dd>
1007 <dd class=
"description">Samba username
</dd>
1008 <dt>samba_password
</dt>
1009 <dd class=
"description">Samba password
</dd>
1011 <dd class=
"description">Log file, if any
</dd>
1013 <h4 class=
"returnvalue">Return Value
</h4>
1014 <p class=
"description">1 on success,
0 on failure
</p>
1015 <h3 class=
"function"><span class=
"info"> CUPS
1.3/Mac OS X
10.5 </span><a name=
"cupsAdminGetServerSettings">cupsAdminGetServerSettings
</a></h3>
1016 <p class=
"description">Get settings from the server.
</p>
1018 int cupsAdminGetServerSettings (
<br>
1019 http_t *http,
<br>
1020 int *num_settings,
<br>
1021 <a href=
"#cups_option_t">cups_option_t
</a> **settings
<br>
1023 <h4 class=
"parameters">Parameters
</h4>
1026 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1027 <dt>num_settings
</dt>
1028 <dd class=
"description">Number of settings
</dd>
1030 <dd class=
"description">Settings
</dd>
1032 <h4 class=
"returnvalue">Return Value
</h4>
1033 <p class=
"description">1 on success,
0 on failure
</p>
1034 <h4 class=
"discussion">Discussion
</h4>
1035 <p class=
"discussion">The returned settings should be freed with cupsFreeOptions() when
1036 you are done with them.
1039 <h3 class=
"function"><span class=
"info"> CUPS
1.3/Mac OS X
10.5 </span><a name=
"cupsAdminSetServerSettings">cupsAdminSetServerSettings
</a></h3>
1040 <p class=
"description">Set settings on the server.
</p>
1042 int cupsAdminSetServerSettings (
<br>
1043 http_t *http,
<br>
1044 int num_settings,
<br>
1045 <a href=
"#cups_option_t">cups_option_t
</a> *settings
<br>
1047 <h4 class=
"parameters">Parameters
</h4>
1050 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1051 <dt>num_settings
</dt>
1052 <dd class=
"description">Number of settings
</dd>
1054 <dd class=
"description">Settings
</dd>
1056 <h4 class=
"returnvalue">Return Value
</h4>
1057 <p class=
"description">1 on success,
0 on failure
</p>
1058 <h3 class=
"function"><a name=
"cupsCancelJob">cupsCancelJob
</a></h3>
1059 <p class=
"description">Cancel a print job on the default server.
</p>
1061 int cupsCancelJob (
<br>
1062 const char *name,
<br>
1063 int job_id
<br>
1065 <h4 class=
"parameters">Parameters
</h4>
1068 <dd class=
"description">Name of printer or class
</dd>
1070 <dd class=
"description">Job ID,
<code>CUPS_JOBID_CURRENT
</code> for the current job, or
<code>CUPS_JOBID_ALL
</code> for all jobs
</dd>
1072 <h4 class=
"returnvalue">Return Value
</h4>
1073 <p class=
"description">1 on success,
0 on failure
</p>
1074 <h4 class=
"discussion">Discussion
</h4>
1075 <p class=
"discussion">Pass
<code>CUPS_JOBID_ALL
</code> to cancel all jobs or
<code>CUPS_JOBID_CURRENT
</code>
1076 to cancel the current job on the named destination.
<br>
1078 Use the
<a href=
"#cupsLastError"><code>cupsLastError
</code></a> and
<a href=
"#cupsLastErrorString"><code>cupsLastErrorString
</code></a> functions to get
1079 the cause of any failure.
</p>
1080 <h3 class=
"function"><span class=
"info"> CUPS
1.4 </span><a name=
"cupsCancelJob2">cupsCancelJob2
</a></h3>
1081 <p class=
"description">Cancel or purge a print job.
</p>
1083 ipp_status_t cupsCancelJob2 (
<br>
1084 http_t *http,
<br>
1085 const char *name,
<br>
1086 int job_id,
<br>
1087 int purge
<br>
1089 <h4 class=
"parameters">Parameters
</h4>
1092 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1094 <dd class=
"description">Name of printer or class
</dd>
1096 <dd class=
"description">Job ID,
<code>CUPS_JOBID_CURRENT
</code> for the current job, or
<code>CUPS_JOBID_ALL
</code> for all jobs
</dd>
1098 <dd class=
"description">1 to purge,
0 to cancel
</dd>
1100 <h4 class=
"returnvalue">Return Value
</h4>
1101 <p class=
"description">IPP status
</p>
1102 <h4 class=
"discussion">Discussion
</h4>
1103 <p class=
"discussion">Canceled jobs remain in the job history while purged jobs are removed
1104 from the job history.
<br>
1106 Pass
<code>CUPS_JOBID_ALL
</code> to cancel all jobs or
<code>CUPS_JOBID_CURRENT
</code>
1107 to cancel the current job on the named destination.
<br>
1109 Use the
<a href=
"#cupsLastError"><code>cupsLastError
</code></a> and
<a href=
"#cupsLastErrorString"><code>cupsLastErrorString
</code></a> functions to get
1110 the cause of any failure.
1113 <h3 class=
"function"><span class=
"info"> CUPS
1.4 </span><a name=
"cupsCreateJob">cupsCreateJob
</a></h3>
1114 <p class=
"description">Create an empty job for streaming.
</p>
1116 int cupsCreateJob (
<br>
1117 http_t *http,
<br>
1118 const char *name,
<br>
1119 const char *title,
<br>
1120 int num_options,
<br>
1121 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1123 <h4 class=
"parameters">Parameters
</h4>
1126 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1128 <dd class=
"description">Destination name
</dd>
1130 <dd class=
"description">Title of job
</dd>
1131 <dt>num_options
</dt>
1132 <dd class=
"description">Number of options
</dd>
1134 <dd class=
"description">Options
</dd>
1136 <h4 class=
"returnvalue">Return Value
</h4>
1137 <p class=
"description">Job ID or
0 on error
</p>
1138 <h4 class=
"discussion">Discussion
</h4>
1139 <p class=
"discussion">Use this function when you want to stream print data using the
1140 <a href=
"#cupsStartDocument"><code>cupsStartDocument
</code></a>,
<a href=
"#cupsWriteRequestData"><code>cupsWriteRequestData
</code></a>, and
1141 <a href=
"#cupsFinishDocument"><code>cupsFinishDocument
</code></a> functions. If you have one or more files to
1142 print, use the
<a href=
"#cupsPrintFile2"><code>cupsPrintFile2
</code></a> or
<a href=
"#cupsPrintFiles2"><code>cupsPrintFiles2
</code></a> function
1146 <h3 class=
"function"><a name=
"cupsEncryption">cupsEncryption
</a></h3>
1147 <p class=
"description">Get the default encryption settings.
</p>
1149 http_encryption_t cupsEncryption (void);
</p>
1150 <h4 class=
"returnvalue">Return Value
</h4>
1151 <p class=
"description">Encryption settings
</p>
1152 <h4 class=
"discussion">Discussion
</h4>
1153 <p class=
"discussion">The default encryption setting comes from the CUPS_ENCRYPTION
1154 environment variable, then the ~/.cups/client.conf file, and finally the
1155 /etc/cups/client.conf file. If not set, the default is
1156 <code>HTTP_ENCRYPT_IF_REQUESTED
</code>.
</p>
1157 <h3 class=
"function"><span class=
"info"> CUPS
1.4 </span><a name=
"cupsFinishDocument">cupsFinishDocument
</a></h3>
1158 <p class=
"description">Finish sending a document.
</p>
1160 ipp_status_t cupsFinishDocument (
<br>
1161 http_t *http,
<br>
1162 const char *name
<br>
1164 <h4 class=
"parameters">Parameters
</h4>
1167 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1169 <dd class=
"description">Destination name
</dd>
1171 <h4 class=
"returnvalue">Return Value
</h4>
1172 <p class=
"description">Status of document submission
</p>
1173 <h4 class=
"discussion">Discussion
</h4>
1174 <p class=
"discussion">The document must have been started using
<a href=
"#cupsStartDocument"><code>cupsStartDocument
</code></a>.
1177 <h3 class=
"function"><a name=
"cupsFreeDests">cupsFreeDests
</a></h3>
1178 <p class=
"description">Free the memory used by the list of destinations.
</p>
1180 void cupsFreeDests (
<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">Number of destinations
</dd>
1189 <dd class=
"description">Destinations
</dd>
1191 <h3 class=
"function"><a name=
"cupsFreeJobs">cupsFreeJobs
</a></h3>
1192 <p class=
"description">Free memory used by job data.
</p>
1194 void cupsFreeJobs (
<br>
1195 int num_jobs,
<br>
1196 <a href=
"#cups_job_t">cups_job_t
</a> *jobs
<br>
1198 <h4 class=
"parameters">Parameters
</h4>
1201 <dd class=
"description">Number of jobs
</dd>
1203 <dd class=
"description">Jobs
</dd>
1205 <h3 class=
"function"><a name=
"cupsFreeOptions">cupsFreeOptions
</a></h3>
1206 <p class=
"description">Free all memory used by options.
</p>
1208 void cupsFreeOptions (
<br>
1209 int num_options,
<br>
1210 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1212 <h4 class=
"parameters">Parameters
</h4>
1214 <dt>num_options
</dt>
1215 <dd class=
"description">Number of options
</dd>
1217 <dd class=
"description">Pointer to options
</dd>
1219 <h3 class=
"function"><span class=
"info"> DEPRECATED
</span><a name=
"cupsGetClasses">cupsGetClasses
</a></h3>
1220 <p class=
"description">Get a list of printer classes from the default server.
</p>
1222 int cupsGetClasses (
<br>
1223 char ***classes
<br>
1225 <h4 class=
"parameters">Parameters
</h4>
1228 <dd class=
"description">Classes
</dd>
1230 <h4 class=
"returnvalue">Return Value
</h4>
1231 <p class=
"description">Number of classes
</p>
1232 <h4 class=
"discussion">Discussion
</h4>
1233 <p class=
"discussion">This function is deprecated - use
<a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> instead.
1236 <h3 class=
"function"><a name=
"cupsGetDefault">cupsGetDefault
</a></h3>
1237 <p class=
"description">Get the default printer or class for the default server.
</p>
1239 const char *cupsGetDefault (void);
</p>
1240 <h4 class=
"returnvalue">Return Value
</h4>
1241 <p class=
"description">Default printer or
<code>NULL
</code></p>
1242 <h4 class=
"discussion">Discussion
</h4>
1243 <p class=
"discussion">This function returns the default printer or class as defined by
1244 the LPDEST or PRINTER environment variables. If these environment
1245 variables are not set, the server default destination is returned.
1246 Applications should use the
<a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> and
<a href=
"#cupsGetDest"><code>cupsGetDest
</code></a>
1247 functions to get the user-defined default printer, as this function does
1248 not support the lpoptions-defined default printer.
</p>
1249 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21/Mac OS X
10.4 </span><a name=
"cupsGetDefault2">cupsGetDefault2
</a></h3>
1250 <p class=
"description">Get the default printer or class for the specified server.
</p>
1252 const char *cupsGetDefault2 (
<br>
1253 http_t *http
<br>
1255 <h4 class=
"parameters">Parameters
</h4>
1258 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1260 <h4 class=
"returnvalue">Return Value
</h4>
1261 <p class=
"description">Default printer or
<code>NULL
</code></p>
1262 <h4 class=
"discussion">Discussion
</h4>
1263 <p class=
"discussion">This function returns the default printer or class as defined by
1264 the LPDEST or PRINTER environment variables. If these environment
1265 variables are not set, the server default destination is returned.
1266 Applications should use the
<a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> and
<a href=
"#cupsGetDest"><code>cupsGetDest
</code></a>
1267 functions to get the user-defined default printer, as this function does
1268 not support the lpoptions-defined default printer.
1271 <h3 class=
"function"><a name=
"cupsGetDest">cupsGetDest
</a></h3>
1272 <p class=
"description">Get the named destination from the list.
</p>
1274 <a href=
"#cups_dest_t">cups_dest_t
</a> *cupsGetDest (
<br>
1275 const char *name,
<br>
1276 const char *instance,
<br>
1277 int num_dests,
<br>
1278 <a href=
"#cups_dest_t">cups_dest_t
</a> *dests
<br>
1280 <h4 class=
"parameters">Parameters
</h4>
1283 <dd class=
"description">Destination name or
<code>NULL
</code> for the default destination
</dd>
1285 <dd class=
"description">Instance name or
<code>NULL
</code></dd>
1287 <dd class=
"description">Number of destinations
</dd>
1289 <dd class=
"description">Destinations
</dd>
1291 <h4 class=
"returnvalue">Return Value
</h4>
1292 <p class=
"description">Destination pointer or
<code>NULL
</code></p>
1293 <h4 class=
"discussion">Discussion
</h4>
1294 <p class=
"discussion">Use the
<a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> or
<a href=
"#cupsGetDests2"><code>cupsGetDests2
</code></a> functions to get a
1295 list of supported destinations for the current user.
</p>
1296 <h3 class=
"function"><a name=
"cupsGetDests">cupsGetDests
</a></h3>
1297 <p class=
"description">Get the list of destinations from the default server.
</p>
1299 int cupsGetDests (
<br>
1300 <a href=
"#cups_dest_t">cups_dest_t
</a> **dests
<br>
1302 <h4 class=
"parameters">Parameters
</h4>
1305 <dd class=
"description">Destinations
</dd>
1307 <h4 class=
"returnvalue">Return Value
</h4>
1308 <p class=
"description">Number of destinations
</p>
1309 <h4 class=
"discussion">Discussion
</h4>
1310 <p class=
"discussion">Starting with CUPS
1.2, the returned list of destinations include the
1311 printer-info, printer-is-accepting-jobs, printer-is-shared,
1312 printer-make-and-model, printer-state, printer-state-change-time,
1313 printer-state-reasons, and printer-type attributes as options. CUPS
1.4
1314 adds the marker-change-time, marker-colors, marker-high-levels,
1315 marker-levels, marker-low-levels, marker-message, marker-names,
1316 marker-types, and printer-commands attributes as well.
<br>
1318 Use the
<a href=
"#cupsFreeDests"><code>cupsFreeDests
</code></a> function to free the destination list and
1319 the
<a href=
"#cupsGetDest"><code>cupsGetDest
</code></a> function to find a particular destination.
</p>
1320 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21/Mac OS X
10.4 </span><a name=
"cupsGetDests2">cupsGetDests2
</a></h3>
1321 <p class=
"description">Get the list of destinations from the specified server.
</p>
1323 int cupsGetDests2 (
<br>
1324 http_t *http,
<br>
1325 <a href=
"#cups_dest_t">cups_dest_t
</a> **dests
<br>
1327 <h4 class=
"parameters">Parameters
</h4>
1330 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1332 <dd class=
"description">Destinations
</dd>
1334 <h4 class=
"returnvalue">Return Value
</h4>
1335 <p class=
"description">Number of destinations
</p>
1336 <h4 class=
"discussion">Discussion
</h4>
1337 <p class=
"discussion">Starting with CUPS
1.2, the returned list of destinations include the
1338 printer-info, printer-is-accepting-jobs, printer-is-shared,
1339 printer-make-and-model, printer-state, printer-state-change-time,
1340 printer-state-reasons, and printer-type attributes as options. CUPS
1.4
1341 adds the marker-change-time, marker-colors, marker-high-levels,
1342 marker-levels, marker-low-levels, marker-message, marker-names,
1343 marker-types, and printer-commands attributes as well.
<br>
1345 Use the
<a href=
"#cupsFreeDests"><code>cupsFreeDests
</code></a> function to free the destination list and
1346 the
<a href=
"#cupsGetDest"><code>cupsGetDest
</code></a> function to find a particular destination.
1349 <h3 class=
"function"><a name=
"cupsGetJobs">cupsGetJobs
</a></h3>
1350 <p class=
"description">Get the jobs from the default server.
</p>
1352 int cupsGetJobs (
<br>
1353 <a href=
"#cups_job_t">cups_job_t
</a> **jobs,
<br>
1354 const char *name,
<br>
1355 int myjobs,
<br>
1356 int whichjobs
<br>
1358 <h4 class=
"parameters">Parameters
</h4>
1361 <dd class=
"description">Job data
</dd>
1363 <dd class=
"description"><code>NULL
</code> = all destinations, otherwise show jobs for named destination
</dd>
1365 <dd class=
"description">0 = all users,
1 = mine
</dd>
1367 <dd class=
"description"><code>CUPS_WHICHJOBS_ALL
</code>,
<code>CUPS_WHICHJOBS_ACTIVE
</code>, or
<code>CUPS_WHICHJOBS_COMPLETED
</code></dd>
1369 <h4 class=
"returnvalue">Return Value
</h4>
1370 <p class=
"description">Number of jobs
</p>
1371 <h4 class=
"discussion">Discussion
</h4>
1372 <p class=
"discussion">A
"whichjobs
" value of
<code>CUPS_WHICHJOBS_ALL
</code> returns all jobs regardless
1373 of state, while
<code>CUPS_WHICHJOBS_ACTIVE
</code> returns jobs that are
1374 pending, processing, or held and
<code>CUPS_WHICHJOBS_COMPLETED
</code> returns
1375 jobs that are stopped, canceled, aborted, or completed.
</p>
1376 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21/Mac OS X
10.4 </span><a name=
"cupsGetJobs2">cupsGetJobs2
</a></h3>
1377 <p class=
"description">Get the jobs from the specified server.
</p>
1379 int cupsGetJobs2 (
<br>
1380 http_t *http,
<br>
1381 <a href=
"#cups_job_t">cups_job_t
</a> **jobs,
<br>
1382 const char *name,
<br>
1383 int myjobs,
<br>
1384 int whichjobs
<br>
1386 <h4 class=
"parameters">Parameters
</h4>
1389 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1391 <dd class=
"description">Job data
</dd>
1393 <dd class=
"description"><code>NULL
</code> = all destinations, otherwise show jobs for named destination
</dd>
1395 <dd class=
"description">0 = all users,
1 = mine
</dd>
1397 <dd class=
"description"><code>CUPS_WHICHJOBS_ALL
</code>,
<code>CUPS_WHICHJOBS_ACTIVE
</code>, or
<code>CUPS_WHICHJOBS_COMPLETED
</code></dd>
1399 <h4 class=
"returnvalue">Return Value
</h4>
1400 <p class=
"description">Number of jobs
</p>
1401 <h4 class=
"discussion">Discussion
</h4>
1402 <p class=
"discussion">A
"whichjobs
" value of
<code>CUPS_WHICHJOBS_ALL
</code> returns all jobs regardless
1403 of state, while
<code>CUPS_WHICHJOBS_ACTIVE
</code> returns jobs that are
1404 pending, processing, or held and
<code>CUPS_WHICHJOBS_COMPLETED
</code> returns
1405 jobs that are stopped, canceled, aborted, or completed.
1408 <h3 class=
"function"><span class=
"info"> CUPS
1.4 </span><a name=
"cupsGetNamedDest">cupsGetNamedDest
</a></h3>
1409 <p class=
"description">Get options for the named destination.
</p>
1411 <a href=
"#cups_dest_t">cups_dest_t
</a> *cupsGetNamedDest (
<br>
1412 http_t *http,
<br>
1413 const char *name,
<br>
1414 const char *instance
<br>
1416 <h4 class=
"parameters">Parameters
</h4>
1419 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1421 <dd class=
"description">Destination name or
<code>NULL
</code> for the default destination
</dd>
1423 <dd class=
"description">Instance name or
<code>NULL
</code></dd>
1425 <h4 class=
"returnvalue">Return Value
</h4>
1426 <p class=
"description">Destination or
<code>NULL
</code></p>
1427 <h4 class=
"discussion">Discussion
</h4>
1428 <p class=
"discussion">This function is optimized for retrieving a single destination and should
1429 be used instead of
<a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> and
<a href=
"#cupsGetDest"><code>cupsGetDest
</code></a> when you either
1430 know the name of the destination or want to print to the default destination.
1431 If
<code>NULL
</code> is returned, the destination does not exist or there is no
1432 default destination.
<br>
1434 If
"http
" is
<code>CUPS_HTTP_DEFAULT
</code>, the connection to the default print
1435 server will be used.
<br>
1437 If
"name
" is
<code>NULL
</code>, the default printer for the current user will be
1440 The returned destination must be freed using
<a href=
"#cupsFreeDests"><code>cupsFreeDests
</code></a> with a
1441 "num_dests
" value of
1.
1444 <h3 class=
"function"><a name=
"cupsGetOption">cupsGetOption
</a></h3>
1445 <p class=
"description">Get an option value.
</p>
1447 const char *cupsGetOption (
<br>
1448 const char *name,
<br>
1449 int num_options,
<br>
1450 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1452 <h4 class=
"parameters">Parameters
</h4>
1455 <dd class=
"description">Name of option
</dd>
1456 <dt>num_options
</dt>
1457 <dd class=
"description">Number of options
</dd>
1459 <dd class=
"description">Options
</dd>
1461 <h4 class=
"returnvalue">Return Value
</h4>
1462 <p class=
"description">Option value or
<code>NULL
</code></p>
1463 <h3 class=
"function"><a name=
"cupsGetPPD">cupsGetPPD
</a></h3>
1464 <p class=
"description">Get the PPD file for a printer on the default server.
</p>
1466 const char *cupsGetPPD (
<br>
1467 const char *name
<br>
1469 <h4 class=
"parameters">Parameters
</h4>
1472 <dd class=
"description">Destination name
</dd>
1474 <h4 class=
"returnvalue">Return Value
</h4>
1475 <p class=
"description">Filename for PPD file
</p>
1476 <h4 class=
"discussion">Discussion
</h4>
1477 <p class=
"discussion">For classes,
<code>cupsGetPPD
</code> returns the PPD file for the first printer
1480 The returned filename is stored in a static buffer and is overwritten with
1481 each call to
<code>cupsGetPPD
</code> or
<a href=
"#cupsGetPPD2"><code>cupsGetPPD2
</code></a>.
</p>
1482 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21/Mac OS X
10.4 </span><a name=
"cupsGetPPD2">cupsGetPPD2
</a></h3>
1483 <p class=
"description">Get the PPD file for a printer from the specified server.
</p>
1485 const char *cupsGetPPD2 (
<br>
1486 http_t *http,
<br>
1487 const char *name
<br>
1489 <h4 class=
"parameters">Parameters
</h4>
1492 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1494 <dd class=
"description">Destination name
</dd>
1496 <h4 class=
"returnvalue">Return Value
</h4>
1497 <p class=
"description">Filename for PPD file
</p>
1498 <h4 class=
"discussion">Discussion
</h4>
1499 <p class=
"discussion">For classes,
<code>cupsGetPPD2
</code> returns the PPD file for the first printer
1502 The returned filename is stored in a static buffer and is overwritten with
1503 each call to
<a href=
"#cupsGetPPD"><code>cupsGetPPD
</code></a> or
<code>cupsGetPPD2
</code>.
1506 <h3 class=
"function"><span class=
"info"> CUPS
1.4 </span><a name=
"cupsGetPPD3">cupsGetPPD3
</a></h3>
1507 <p class=
"description">Get the PPD file for a printer on the specified
1508 server if it has changed.
</p>
1510 http_status_t cupsGetPPD3 (
<br>
1511 http_t *http,
<br>
1512 const char *name,
<br>
1513 time_t *modtime,
<br>
1514 char *buffer,
<br>
1515 size_t bufsize
<br>
1517 <h4 class=
"parameters">Parameters
</h4>
1520 <dd class=
"description">HTTP connection or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1522 <dd class=
"description">Destination name
</dd>
1524 <dd class=
"description">Modification time
</dd>
1526 <dd class=
"description">Filename buffer
</dd>
1528 <dd class=
"description">Size of filename buffer
</dd>
1530 <h4 class=
"returnvalue">Return Value
</h4>
1531 <p class=
"description">HTTP status
</p>
1532 <h4 class=
"discussion">Discussion
</h4>
1533 <p class=
"discussion">The
"modtime
" parameter contains the modification time of any
1534 locally-cached content and is updated with the time from the PPD file on
1537 The
"buffer
" parameter contains the local PPD filename. If it contains
1538 the empty string, a new temporary file is created, otherwise the existing
1539 file will be overwritten as needed.
<br>
1541 On success,
<code>HTTP_OK
</code> is returned for a new PPD file and
1542 <code>HTTP_NOT_MODIFIED
</code> if the existing PPD file is up-to-date. Any other
1543 status is an error.
<br>
1545 For classes,
<code>cupsGetPPD3
</code> returns the PPD file for the first printer
1549 <h3 class=
"function"><a name=
"cupsGetPassword">cupsGetPassword
</a></h3>
1550 <p class=
"description">Get a password from the user.
</p>
1552 const char *cupsGetPassword (
<br>
1553 const char *prompt
<br>
1555 <h4 class=
"parameters">Parameters
</h4>
1558 <dd class=
"description">Prompt string
</dd>
1560 <h4 class=
"returnvalue">Return Value
</h4>
1561 <p class=
"description">Password
</p>
1562 <h4 class=
"discussion">Discussion
</h4>
1563 <p class=
"discussion">Uses the current password callback function. Returns
<code>NULL
</code> if the
1564 user does not provide a password.
</p>
1565 <h3 class=
"function"><span class=
"info"> DEPRECATED
</span><a name=
"cupsGetPrinters">cupsGetPrinters
</a></h3>
1566 <p class=
"description">Get a list of printers from the default server.
</p>
1568 int cupsGetPrinters (
<br>
1569 char ***printers
<br>
1571 <h4 class=
"parameters">Parameters
</h4>
1574 <dd class=
"description">Printers
</dd>
1576 <h4 class=
"returnvalue">Return Value
</h4>
1577 <p class=
"description">Number of printers
</p>
1578 <h4 class=
"discussion">Discussion
</h4>
1579 <p class=
"discussion">This function is deprecated - use
<a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> instead.
1582 <h3 class=
"function"><span class=
"info"> CUPS
1.3/Mac OS X
10.5 </span><a name=
"cupsGetServerPPD">cupsGetServerPPD
</a></h3>
1583 <p class=
"description">Get an available PPD file from the server.
</p>
1585 char *cupsGetServerPPD (
<br>
1586 http_t *http,
<br>
1587 const char *name
<br>
1589 <h4 class=
"parameters">Parameters
</h4>
1592 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1594 <dd class=
"description">Name of PPD file (
"ppd-name
")
</dd>
1596 <h4 class=
"returnvalue">Return Value
</h4>
1597 <p class=
"description">Name of PPD file or
<code>NULL
</code> on error
</p>
1598 <h4 class=
"discussion">Discussion
</h4>
1599 <p class=
"discussion">This function returns the named PPD file from the server. The
1600 list of available PPDs is provided by the IPP
<code>CUPS_GET_PPDS
</code>
1603 You must remove (unlink) the PPD file when you are finished with
1604 it. The PPD filename is stored in a static location that will be
1605 overwritten on the next call to
<a href=
"#cupsGetPPD"><code>cupsGetPPD
</code></a>,
<a href=
"#cupsGetPPD2"><code>cupsGetPPD2
</code></a>,
1606 or
<a href=
"#cupsGetServerPPD"><code>cupsGetServerPPD
</code></a>.
1609 <h3 class=
"function"><a name=
"cupsLangDefault">cupsLangDefault
</a></h3>
1610 <p class=
"description">Return the default language.
</p>
1612 cups_lang_t *cupsLangDefault (void);
</p>
1613 <h4 class=
"returnvalue">Return Value
</h4>
1614 <p class=
"description">Language data
</p>
1615 <h3 class=
"function"><a name=
"cupsLangEncoding">cupsLangEncoding
</a></h3>
1616 <p class=
"description">Return the character encoding (us-ascii, etc.)
1617 for the given language.
</p>
1619 const char *cupsLangEncoding (
<br>
1620 cups_lang_t *lang
<br>
1622 <h4 class=
"parameters">Parameters
</h4>
1625 <dd class=
"description">Language data
</dd>
1627 <h4 class=
"returnvalue">Return Value
</h4>
1628 <p class=
"description">Character encoding
</p>
1629 <h3 class=
"function"><a name=
"cupsLangFlush">cupsLangFlush
</a></h3>
1630 <p class=
"description">Flush all language data out of the cache.
</p>
1632 void cupsLangFlush (void);
</p>
1633 <h3 class=
"function"><a name=
"cupsLangFree">cupsLangFree
</a></h3>
1634 <p class=
"description">Free language data.
</p>
1636 void cupsLangFree (
<br>
1637 cups_lang_t *lang
<br>
1639 <h4 class=
"parameters">Parameters
</h4>
1642 <dd class=
"description">Language to free
</dd>
1644 <h4 class=
"discussion">Discussion
</h4>
1645 <p class=
"discussion">This does not actually free anything; use
<a href=
"#cupsLangFlush"><code>cupsLangFlush
</code></a> for that.
</p>
1646 <h3 class=
"function"><a name=
"cupsLangGet">cupsLangGet
</a></h3>
1647 <p class=
"description">Get a language.
</p>
1649 cups_lang_t *cupsLangGet (
<br>
1650 const char *language
<br>
1652 <h4 class=
"parameters">Parameters
</h4>
1655 <dd class=
"description">Language or locale
</dd>
1657 <h4 class=
"returnvalue">Return Value
</h4>
1658 <p class=
"description">Language data
</p>
1659 <h3 class=
"function"><a name=
"cupsLastError">cupsLastError
</a></h3>
1660 <p class=
"description">Return the last IPP status code.
</p>
1662 ipp_status_t cupsLastError (void);
</p>
1663 <h4 class=
"returnvalue">Return Value
</h4>
1664 <p class=
"description">IPP status code from last request
</p>
1665 <h3 class=
"function"><span class=
"info"> CUPS
1.2/Mac OS X
10.5 </span><a name=
"cupsLastErrorString">cupsLastErrorString
</a></h3>
1666 <p class=
"description">Return the last IPP status-message.
</p>
1668 const char *cupsLastErrorString (void);
</p>
1669 <h4 class=
"returnvalue">Return Value
</h4>
1670 <p class=
"description">status-message text from last request
</p>
1671 <h3 class=
"function"><span class=
"info"> CUPS
1.2/Mac OS X
10.5 </span><a name=
"cupsNotifySubject">cupsNotifySubject
</a></h3>
1672 <p class=
"description">Return the subject for the given notification message.
</p>
1674 char *cupsNotifySubject (
<br>
1675 cups_lang_t *lang,
<br>
1676 ipp_t *event
<br>
1678 <h4 class=
"parameters">Parameters
</h4>
1681 <dd class=
"description">Language data
</dd>
1683 <dd class=
"description">Event data
</dd>
1685 <h4 class=
"returnvalue">Return Value
</h4>
1686 <p class=
"description">Subject string or
<code>NULL
</code></p>
1687 <h4 class=
"discussion">Discussion
</h4>
1688 <p class=
"discussion">The returned string must be freed by the caller using
<code>free
</code>.
1691 <h3 class=
"function"><span class=
"info"> CUPS
1.2/Mac OS X
10.5 </span><a name=
"cupsNotifyText">cupsNotifyText
</a></h3>
1692 <p class=
"description">Return the text for the given notification message.
</p>
1694 char *cupsNotifyText (
<br>
1695 cups_lang_t *lang,
<br>
1696 ipp_t *event
<br>
1698 <h4 class=
"parameters">Parameters
</h4>
1701 <dd class=
"description">Language data
</dd>
1703 <dd class=
"description">Event data
</dd>
1705 <h4 class=
"returnvalue">Return Value
</h4>
1706 <p class=
"description">Message text or
<code>NULL
</code></p>
1707 <h4 class=
"discussion">Discussion
</h4>
1708 <p class=
"discussion">The returned string must be freed by the caller using
<code>free
</code>.
1711 <h3 class=
"function"><a name=
"cupsParseOptions">cupsParseOptions
</a></h3>
1712 <p class=
"description">Parse options from a command-line argument.
</p>
1714 int cupsParseOptions (
<br>
1715 const char *arg,
<br>
1716 int num_options,
<br>
1717 <a href=
"#cups_option_t">cups_option_t
</a> **options
<br>
1719 <h4 class=
"parameters">Parameters
</h4>
1722 <dd class=
"description">Argument to parse
</dd>
1723 <dt>num_options
</dt>
1724 <dd class=
"description">Number of options
</dd>
1726 <dd class=
"description">Options found
</dd>
1728 <h4 class=
"returnvalue">Return Value
</h4>
1729 <p class=
"description">Number of options found
</p>
1730 <h4 class=
"discussion">Discussion
</h4>
1731 <p class=
"discussion">This function converts space-delimited name/value pairs according
1732 to the PAPI text option ABNF specification. Collection values
1733 (
"name={a=... b=... c=...}
") are stored with the curley brackets
1734 intact - use
<code>cupsParseOptions
</code> on the value to extract the
1735 collection attributes.
</p>
1736 <h3 class=
"function"><a name=
"cupsPrintFile">cupsPrintFile
</a></h3>
1737 <p class=
"description">Print a file to a printer or class on the default server.
</p>
1739 int cupsPrintFile (
<br>
1740 const char *name,
<br>
1741 const char *filename,
<br>
1742 const char *title,
<br>
1743 int num_options,
<br>
1744 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1746 <h4 class=
"parameters">Parameters
</h4>
1749 <dd class=
"description">Destination name
</dd>
1751 <dd class=
"description">File to print
</dd>
1753 <dd class=
"description">Title of job
</dd>
1754 <dt>num_options
</dt>
1755 <dd class=
"description">Number of options
</dd>
1757 <dd class=
"description">Options
</dd>
1759 <h4 class=
"returnvalue">Return Value
</h4>
1760 <p class=
"description">Job ID or
0 on error
</p>
1761 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21/Mac OS X
10.4 </span><a name=
"cupsPrintFile2">cupsPrintFile2
</a></h3>
1762 <p class=
"description">Print a file to a printer or class on the specified
1765 int cupsPrintFile2 (
<br>
1766 http_t *http,
<br>
1767 const char *name,
<br>
1768 const char *filename,
<br>
1769 const char *title,
<br>
1770 int num_options,
<br>
1771 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1773 <h4 class=
"parameters">Parameters
</h4>
1776 <dd class=
"description">Connection to server
</dd>
1778 <dd class=
"description">Destination name
</dd>
1780 <dd class=
"description">File to print
</dd>
1782 <dd class=
"description">Title of job
</dd>
1783 <dt>num_options
</dt>
1784 <dd class=
"description">Number of options
</dd>
1786 <dd class=
"description">Options
</dd>
1788 <h4 class=
"returnvalue">Return Value
</h4>
1789 <p class=
"description">Job ID or
0 on error
</p>
1790 <h3 class=
"function"><a name=
"cupsPrintFiles">cupsPrintFiles
</a></h3>
1791 <p class=
"description">Print one or more files to a printer or class on the
1794 int cupsPrintFiles (
<br>
1795 const char *name,
<br>
1796 int num_files,
<br>
1797 const char **files,
<br>
1798 const char *title,
<br>
1799 int num_options,
<br>
1800 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1802 <h4 class=
"parameters">Parameters
</h4>
1805 <dd class=
"description">Destination name
</dd>
1807 <dd class=
"description">Number of files
</dd>
1809 <dd class=
"description">File(s) to print
</dd>
1811 <dd class=
"description">Title of job
</dd>
1812 <dt>num_options
</dt>
1813 <dd class=
"description">Number of options
</dd>
1815 <dd class=
"description">Options
</dd>
1817 <h4 class=
"returnvalue">Return Value
</h4>
1818 <p class=
"description">Job ID or
0 on error
</p>
1819 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21/Mac OS X
10.4 </span><a name=
"cupsPrintFiles2">cupsPrintFiles2
</a></h3>
1820 <p class=
"description">Print one or more files to a printer or class on the
1821 specified server.
</p>
1823 int cupsPrintFiles2 (
<br>
1824 http_t *http,
<br>
1825 const char *name,
<br>
1826 int num_files,
<br>
1827 const char **files,
<br>
1828 const char *title,
<br>
1829 int num_options,
<br>
1830 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1832 <h4 class=
"parameters">Parameters
</h4>
1835 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1837 <dd class=
"description">Destination name
</dd>
1839 <dd class=
"description">Number of files
</dd>
1841 <dd class=
"description">File(s) to print
</dd>
1843 <dd class=
"description">Title of job
</dd>
1844 <dt>num_options
</dt>
1845 <dd class=
"description">Number of options
</dd>
1847 <dd class=
"description">Options
</dd>
1849 <h4 class=
"returnvalue">Return Value
</h4>
1850 <p class=
"description">Job ID or
0 on error
</p>
1851 <h3 class=
"function"><span class=
"info"> CUPS
1.3/Mac OS X
10.5 </span><a name=
"cupsRemoveDest">cupsRemoveDest
</a></h3>
1852 <p class=
"description">Remove a destination from the destination list.
</p>
1854 int cupsRemoveDest (
<br>
1855 const char *name,
<br>
1856 const char *instance,
<br>
1857 int num_dests,
<br>
1858 <a href=
"#cups_dest_t">cups_dest_t
</a> **dests
<br>
1860 <h4 class=
"parameters">Parameters
</h4>
1863 <dd class=
"description">Destination name
</dd>
1865 <dd class=
"description">Instance name or
<code>NULL
</code></dd>
1867 <dd class=
"description">Number of destinations
</dd>
1869 <dd class=
"description">Destinations
</dd>
1871 <h4 class=
"returnvalue">Return Value
</h4>
1872 <p class=
"description">New number of destinations
</p>
1873 <h4 class=
"discussion">Discussion
</h4>
1874 <p class=
"discussion">Removing a destination/instance does not delete the class or printer
1875 queue, merely the lpoptions for that destination/instance. Use the
1876 <a href=
"#cupsSetDests"><code>cupsSetDests
</code></a> or
<a href=
"#cupsSetDests2"><code>cupsSetDests2
</code></a> functions to save the new
1877 options for the user.
1880 <h3 class=
"function"><span class=
"info"> CUPS
1.2/Mac OS X
10.5 </span><a name=
"cupsRemoveOption">cupsRemoveOption
</a></h3>
1881 <p class=
"description">Remove an option from an option array.
</p>
1883 int cupsRemoveOption (
<br>
1884 const char *name,
<br>
1885 int num_options,
<br>
1886 <a href=
"#cups_option_t">cups_option_t
</a> **options
<br>
1888 <h4 class=
"parameters">Parameters
</h4>
1891 <dd class=
"description">Option name
</dd>
1892 <dt>num_options
</dt>
1893 <dd class=
"description">Current number of options
</dd>
1895 <dd class=
"description">Options
</dd>
1897 <h4 class=
"returnvalue">Return Value
</h4>
1898 <p class=
"description">New number of options
</p>
1899 <h3 class=
"function"><a name=
"cupsServer">cupsServer
</a></h3>
1900 <p class=
"description">Return the hostname/address of the default server.
</p>
1902 const char *cupsServer (void);
</p>
1903 <h4 class=
"returnvalue">Return Value
</h4>
1904 <p class=
"description">Server name
</p>
1905 <h4 class=
"discussion">Discussion
</h4>
1906 <p class=
"discussion">The returned value can be a fully-qualified hostname, a numeric
1907 IPv4 or IPv6 address, or a domain socket pathname.
</p>
1908 <h3 class=
"function"><span class=
"info"> CUPS
1.3/Mac OS X
10.5 </span><a name=
"cupsSetDefaultDest">cupsSetDefaultDest
</a></h3>
1909 <p class=
"description">Set the default destination.
</p>
1911 void cupsSetDefaultDest (
<br>
1912 const char *name,
<br>
1913 const char *instance,
<br>
1914 int num_dests,
<br>
1915 <a href=
"#cups_dest_t">cups_dest_t
</a> *dests
<br>
1917 <h4 class=
"parameters">Parameters
</h4>
1920 <dd class=
"description">Destination name
</dd>
1922 <dd class=
"description">Instance name or
<code>NULL
</code></dd>
1924 <dd class=
"description">Number of destinations
</dd>
1926 <dd class=
"description">Destinations
</dd>
1928 <h3 class=
"function"><a name=
"cupsSetDests">cupsSetDests
</a></h3>
1929 <p class=
"description">Save the list of destinations for the default server.
</p>
1931 void cupsSetDests (
<br>
1932 int num_dests,
<br>
1933 <a href=
"#cups_dest_t">cups_dest_t
</a> *dests
<br>
1935 <h4 class=
"parameters">Parameters
</h4>
1938 <dd class=
"description">Number of destinations
</dd>
1940 <dd class=
"description">Destinations
</dd>
1942 <h4 class=
"discussion">Discussion
</h4>
1943 <p class=
"discussion">This function saves the destinations to /etc/cups/lpoptions when run
1944 as root and ~/.cups/lpoptions when run as a normal user.
</p>
1945 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21/Mac OS X
10.4 </span><a name=
"cupsSetDests2">cupsSetDests2
</a></h3>
1946 <p class=
"description">Save the list of destinations for the specified server.
</p>
1948 int cupsSetDests2 (
<br>
1949 http_t *http,
<br>
1950 int num_dests,
<br>
1951 <a href=
"#cups_dest_t">cups_dest_t
</a> *dests
<br>
1953 <h4 class=
"parameters">Parameters
</h4>
1956 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1958 <dd class=
"description">Number of destinations
</dd>
1960 <dd class=
"description">Destinations
</dd>
1962 <h4 class=
"returnvalue">Return Value
</h4>
1963 <p class=
"description">0 on success, -
1 on error
</p>
1964 <h4 class=
"discussion">Discussion
</h4>
1965 <p class=
"discussion">This function saves the destinations to /etc/cups/lpoptions when run
1966 as root and ~/.cups/lpoptions when run as a normal user.
1969 <h3 class=
"function"><a name=
"cupsSetEncryption">cupsSetEncryption
</a></h3>
1970 <p class=
"description">Set the encryption preference.
</p>
1972 void cupsSetEncryption (
<br>
1973 http_encryption_t e
<br>
1975 <h4 class=
"parameters">Parameters
</h4>
1978 <dd class=
"description">New encryption preference
</dd>
1980 <h3 class=
"function"><a name=
"cupsSetPasswordCB">cupsSetPasswordCB
</a></h3>
1981 <p class=
"description">Set the password callback for CUPS.
</p>
1983 void cupsSetPasswordCB (
<br>
1984 <a href=
"#cups_password_cb_t">cups_password_cb_t
</a> cb
<br>
1986 <h4 class=
"parameters">Parameters
</h4>
1989 <dd class=
"description">Callback function
</dd>
1991 <h4 class=
"discussion">Discussion
</h4>
1992 <p class=
"discussion">Pass
<code>NULL
</code> to restore the default (console) password callback.
</p>
1993 <h3 class=
"function"><a name=
"cupsSetServer">cupsSetServer
</a></h3>
1994 <p class=
"description">Set the default server name.
</p>
1996 void cupsSetServer (
<br>
1997 const char *server
<br>
1999 <h4 class=
"parameters">Parameters
</h4>
2002 <dd class=
"description">Server name
</dd>
2004 <h4 class=
"discussion">Discussion
</h4>
2005 <p class=
"discussion">The
"server
" string can be a fully-qualified hostname, a numeric
2006 IPv4 or IPv6 address, or a domain socket pathname. Pass
<code>NULL
</code> to
2007 restore the default server name.
</p>
2008 <h3 class=
"function"><a name=
"cupsSetUser">cupsSetUser
</a></h3>
2009 <p class=
"description">Set the default user name.
</p>
2011 void cupsSetUser (
<br>
2012 const char *user
<br>
2014 <h4 class=
"parameters">Parameters
</h4>
2017 <dd class=
"description">User name
</dd>
2019 <h4 class=
"discussion">Discussion
</h4>
2020 <p class=
"discussion">Pass
<code>NULL
</code> to restore the default user name.
</p>
2021 <h3 class=
"function"><span class=
"info"> CUPS
1.4 </span><a name=
"cupsStartDocument">cupsStartDocument
</a></h3>
2022 <p class=
"description">Add a document to a job created with cupsCreateJob().
</p>
2024 http_status_t cupsStartDocument (
<br>
2025 http_t *http,
<br>
2026 const char *name,
<br>
2027 int job_id,
<br>
2028 const char *docname,
<br>
2029 const char *format,
<br>
2030 int last_document
<br>
2032 <h4 class=
"parameters">Parameters
</h4>
2035 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
2037 <dd class=
"description">Destination name
</dd>
2039 <dd class=
"description">Job ID from
<a href=
"#cupsCreateJob"><code>cupsCreateJob
</code></a></dd>
2041 <dd class=
"description">Name of document
</dd>
2043 <dd class=
"description">MIME type or
<code>CUPS_FORMAT_foo
</code></dd>
2044 <dt>last_document
</dt>
2045 <dd class=
"description">1 for last document in job,
0 otherwise
</dd>
2047 <h4 class=
"returnvalue">Return Value
</h4>
2048 <p class=
"description">HTTP status of request
</p>
2049 <h4 class=
"discussion">Discussion
</h4>
2050 <p class=
"discussion">Use
<a href=
"#cupsWriteRequestData"><code>cupsWriteRequestData
</code></a> to write data for the document and
2051 <a href=
"#cupsFinishDocument"><code>cupsFinishDocument
</code></a> to finish the document and get the submission status.
<br>
2053 The MIME type constants
<code>CUPS_FORMAT_AUTO
</code>,
<code>CUPS_FORMAT_PDF
</code>,
2054 <code>CUPS_FORMAT_POSTSCRIPT
</code>,
<code>CUPS_FORMAT_RAW
</code>, and
2055 <code>CUPS_FORMAT_TEXT
</code> are provided for the
"format
" argument, although
2056 any supported MIME type string can be supplied.
2059 <h3 class=
"function"><a name=
"cupsTempFd">cupsTempFd
</a></h3>
2060 <p class=
"description">Creates a temporary file.
</p>
2062 int cupsTempFd (
<br>
2063 char *filename,
<br>
2064 int len
<br>
2066 <h4 class=
"parameters">Parameters
</h4>
2069 <dd class=
"description">Pointer to buffer
</dd>
2071 <dd class=
"description">Size of buffer
</dd>
2073 <h4 class=
"returnvalue">Return Value
</h4>
2074 <p class=
"description">New file descriptor or -
1 on error
</p>
2075 <h4 class=
"discussion">Discussion
</h4>
2076 <p class=
"discussion">The temporary filename is returned in the filename buffer.
2077 The temporary file is opened for reading and writing.
</p>
2078 <h3 class=
"function"><span class=
"info"> DEPRECATED
</span><a name=
"cupsTempFile">cupsTempFile
</a></h3>
2079 <p class=
"description">Generates a temporary filename.
</p>
2081 char *cupsTempFile (
<br>
2082 char *filename,
<br>
2083 int len
<br>
2085 <h4 class=
"parameters">Parameters
</h4>
2088 <dd class=
"description">Pointer to buffer
</dd>
2090 <dd class=
"description">Size of buffer
</dd>
2092 <h4 class=
"returnvalue">Return Value
</h4>
2093 <p class=
"description">Filename or
<code>NULL
</code> on error
</p>
2094 <h4 class=
"discussion">Discussion
</h4>
2095 <p class=
"discussion">The temporary filename is returned in the filename buffer.
2096 This function is deprecated - use
<a href=
"#cupsTempFd"><code>cupsTempFd
</code></a> or
2097 <a href=
"#cupsTempFile2"><code>cupsTempFile2
</code></a> instead.
2100 <h3 class=
"function"><span class=
"info"> CUPS
1.2/Mac OS X
10.5 </span><a name=
"cupsTempFile2">cupsTempFile2
</a></h3>
2101 <p class=
"description">Creates a temporary CUPS file.
</p>
2103 cups_file_t *cupsTempFile2 (
<br>
2104 char *filename,
<br>
2105 int len
<br>
2107 <h4 class=
"parameters">Parameters
</h4>
2110 <dd class=
"description">Pointer to buffer
</dd>
2112 <dd class=
"description">Size of buffer
</dd>
2114 <h4 class=
"returnvalue">Return Value
</h4>
2115 <p class=
"description">CUPS file or
<code>NULL
</code> on error
</p>
2116 <h4 class=
"discussion">Discussion
</h4>
2117 <p class=
"discussion">The temporary filename is returned in the filename buffer.
2118 The temporary file is opened for writing.
2121 <h3 class=
"function"><a name=
"cupsUser">cupsUser
</a></h3>
2122 <p class=
"description">Return the current user's name.
</p>
2124 const char *cupsUser (void);
</p>
2125 <h4 class=
"returnvalue">Return Value
</h4>
2126 <p class=
"description">User name
</p>
2127 <h2 class=
"title"><a name=
"TYPES">Data Types
</a></h2>
2128 <h3 class=
"typedef"><a name=
"cups_dest_t">cups_dest_t
</a></h3>
2129 <p class=
"description">Destination
</p>
2131 typedef struct
<a href=
"#cups_dest_s">cups_dest_s
</a> cups_dest_t;
2133 <h3 class=
"typedef"><span class=
"info"> CUPS
1.4 </span><a name=
"cups_device_cb_t">cups_device_cb_t
</a></h3>
2134 <p class=
"description">Device callback
</p>
2136 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);
2138 <h3 class=
"typedef"><a name=
"cups_job_t">cups_job_t
</a></h3>
2139 <p class=
"description">Job
</p>
2141 typedef struct
<a href=
"#cups_job_s">cups_job_s
</a> cups_job_t;
2143 <h3 class=
"typedef"><a name=
"cups_option_t">cups_option_t
</a></h3>
2144 <p class=
"description">Printer Options
</p>
2146 typedef struct
<a href=
"#cups_option_s">cups_option_s
</a> cups_option_t;
2148 <h3 class=
"typedef"><a name=
"cups_password_cb_t">cups_password_cb_t
</a></h3>
2149 <p class=
"description">Password callback
</p>
2151 typedef const char *(*cups_password_cb_t)(const char *prompt);
2153 <h3 class=
"typedef"><a name=
"cups_ptype_t">cups_ptype_t
</a></h3>
2154 <p class=
"description">Printer type/capability bits
</p>
2156 typedef unsigned cups_ptype_t;
2158 <h2 class=
"title"><a name=
"STRUCTURES">Structures
</a></h2>
2159 <h3 class=
"struct"><a name=
"cups_dest_s">cups_dest_s
</a></h3>
2160 <p class=
"description">Destination
</p>
2161 <p class=
"code">struct cups_dest_s {
<br>
2162 char *name, *instance;
<br>
2163 int is_default;
<br>
2164 int num_options;
<br>
2165 <a href=
"#cups_option_t">cups_option_t
</a> *options;
<br>
2167 <h4 class=
"members">Members
</h4>
2170 <dd class=
"description">Local instance name or NULL
</dd>
2171 <dt>is_default
</dt>
2172 <dd class=
"description">Is this printer the default?
</dd>
2173 <dt>num_options
</dt>
2174 <dd class=
"description">Number of options
</dd>
2176 <dd class=
"description">Options
</dd>
2178 <h3 class=
"struct"><a name=
"cups_job_s">cups_job_s
</a></h3>
2179 <p class=
"description">Job
</p>
2180 <p class=
"code">struct cups_job_s {
<br>
2181 time_t completed_time;
<br>
2182 time_t creation_time;
<br>
2183 char *dest;
<br>
2184 char *format;
<br>
2185 int id;
<br>
2186 int priority;
<br>
2187 time_t processing_time;
<br>
2188 int size;
<br>
2189 ipp_jstate_t state;
<br>
2190 char *title;
<br>
2191 char *user;
<br>
2193 <h4 class=
"members">Members
</h4>
2195 <dt>completed_time
</dt>
2196 <dd class=
"description">Time the job was completed
</dd>
2197 <dt>creation_time
</dt>
2198 <dd class=
"description">Time the job was created
</dd>
2200 <dd class=
"description">Printer or class name
</dd>
2202 <dd class=
"description">Document format
</dd>
2204 <dd class=
"description">The job ID
</dd>
2206 <dd class=
"description">Priority (
1-
100)
</dd>
2207 <dt>processing_time
</dt>
2208 <dd class=
"description">Time the job was processed
</dd>
2210 <dd class=
"description">Size in kilobytes
</dd>
2212 <dd class=
"description">Job state
</dd>
2214 <dd class=
"description">Title/job name
</dd>
2216 <dd class=
"description">User the submitted the job
</dd>
2218 <h3 class=
"struct"><a name=
"cups_option_s">cups_option_s
</a></h3>
2219 <p class=
"description">Printer Options
</p>
2220 <p class=
"code">struct cups_option_s {
<br>
2221 char *name;
<br>
2222 char *value;
<br>
2224 <h4 class=
"members">Members
</h4>
2227 <dd class=
"description">Name of option
</dd>
2229 <dd class=
"description">Value of option
</dd>
2231 <h2 class=
"title"><a name=
"ENUMERATIONS">Constants
</a></h2>
2232 <h3 class=
"enumeration"><a name=
"cups_ptype_e">cups_ptype_e
</a></h3>
2233 <p class=
"description">Printer type/capability bit constants
</p>
2234 <h4 class=
"constants">Constants
</h4>
2236 <dt>CUPS_PRINTER_AUTHENTICATED
<span class=
"info"> CUPS
1.2/Mac OS X
10.5 </span></dt>
2237 <dd class=
"description">Printer requires authentication
</dd>
2238 <dt>CUPS_PRINTER_BIND
</dt>
2239 <dd class=
"description">Can bind output
</dd>
2240 <dt>CUPS_PRINTER_BW
</dt>
2241 <dd class=
"description">Can do B
&W printing
</dd>
2242 <dt>CUPS_PRINTER_CLASS
</dt>
2243 <dd class=
"description">Printer class
</dd>
2244 <dt>CUPS_PRINTER_COLLATE
</dt>
2245 <dd class=
"description">Can collage copies
</dd>
2246 <dt>CUPS_PRINTER_COLOR
</dt>
2247 <dd class=
"description">Can do color printing
</dd>
2248 <dt>CUPS_PRINTER_COMMANDS
<span class=
"info"> CUPS
1.2/Mac OS X
10.5 </span></dt>
2249 <dd class=
"description">Printer supports maintenance commands
</dd>
2250 <dt>CUPS_PRINTER_COPIES
</dt>
2251 <dd class=
"description">Can do copies
</dd>
2252 <dt>CUPS_PRINTER_COVER
</dt>
2253 <dd class=
"description">Can cover output
</dd>
2254 <dt>CUPS_PRINTER_DEFAULT
</dt>
2255 <dd class=
"description">Default printer on network
</dd>
2256 <dt>CUPS_PRINTER_DELETE
<span class=
"info"> CUPS
1.2/Mac OS X
10.5 </span></dt>
2257 <dd class=
"description">Delete printer
</dd>
2258 <dt>CUPS_PRINTER_DISCOVERED
<span class=
"info"> CUPS
1.3/Mac OS X
10.5 </span></dt>
2259 <dd class=
"description">Printer was automatically discovered and added
</dd>
2260 <dt>CUPS_PRINTER_DUPLEX
</dt>
2261 <dd class=
"description">Can do duplexing
</dd>
2262 <dt>CUPS_PRINTER_FAX
</dt>
2263 <dd class=
"description">Fax queue
</dd>
2264 <dt>CUPS_PRINTER_IMPLICIT
</dt>
2265 <dd class=
"description">Implicit class
</dd>
2266 <dt>CUPS_PRINTER_LARGE
</dt>
2267 <dd class=
"description">Can do D/E/A1/A0
</dd>
2268 <dt>CUPS_PRINTER_LOCAL
</dt>
2269 <dd class=
"description">Local printer or class
</dd>
2270 <dt>CUPS_PRINTER_MEDIUM
</dt>
2271 <dd class=
"description">Can do Tabloid/B/C/A3/A2
</dd>
2272 <dt>CUPS_PRINTER_NOT_SHARED
<span class=
"info"> CUPS
1.2/Mac OS X
10.5 </span></dt>
2273 <dd class=
"description">Printer is not shared
</dd>
2274 <dt>CUPS_PRINTER_PUNCH
</dt>
2275 <dd class=
"description">Can punch output
</dd>
2276 <dt>CUPS_PRINTER_REJECTING
</dt>
2277 <dd class=
"description">Printer is rejecting jobs
</dd>
2278 <dt>CUPS_PRINTER_REMOTE
</dt>
2279 <dd class=
"description">Remote printer or class
</dd>
2280 <dt>CUPS_PRINTER_SMALL
</dt>
2281 <dd class=
"description">Can do Letter/Legal/A4
</dd>
2282 <dt>CUPS_PRINTER_SORT
</dt>
2283 <dd class=
"description">Can sort output
</dd>
2284 <dt>CUPS_PRINTER_STAPLE
</dt>
2285 <dd class=
"description">Can staple output
</dd>
2286 <dt>CUPS_PRINTER_VARIABLE
</dt>
2287 <dd class=
"description">Can do variable sizes
</dd>