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;
41 border: dotted thin #999999;
46 PRE.command EM, PRE.example EM {
47 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
51 font-family: monaco, courier, monospace;
62 border: solid thin #999999;
73 -moz-border-radius: 10px;
78 text-decoration: none;
81 A:link:hover, A:visited:hover, A:active {
82 text-decoration: underline;
89 TR.data, TD.data, TR.data TD {
92 border-bottom: solid 1pt #999999;
96 border-bottom: solid 1pt #999999;
103 border: solid thin #999999;
104 border-collapse: collapse;
120 border: solid thin #cccccc;
127 border-bottom: solid thin #999999;
136 caption-side: bottom;
160 border: thin solid black;
168 H2 SPAN.info, H3 SPAN.info, H4 SPAN.info {
177 border-bottom: solid 2pt #000000;
180 DIV.indent, TABLE.indent {
188 border-collapse: collapse;
191 TABLE.indent TD, TABLE.indent TH {
196 border-collapse: collapse;
204 border-bottom: solid thin #cccccc;
209 vertical-align: bottom;
218 border-bottom: solid thin #eeeeee;
223 TABLE.list TR:nth-child(even) {
227 TABLE.list TR:nth-child(odd) {
246 font-family: monaco, courier, monospace;
250 border: solid thin #999999;
251 border-collapse: collapse;
256 DIV.summary TABLE TD, DIV.summary TABLE TH {
257 border: solid thin #999999;
263 DIV.summary TABLE THEAD TH {
267 /* API documentation styles... */
274 div.body h3, div.body h4, div.body h5 {
275 margin-bottom: 0.5em;
278 .class, .enumeration, .function, .struct, .typedef, .union {
279 border-bottom: solid thin #999999;
286 code, p.code, pre, ul.code li {
287 font-family: monaco, courier, monospace;
290 ul.code, ul.contents, ul.subcontents {
291 list-style-type: none;
301 ul.contents li ul.code, ul.contents li ul.subcontents {
314 margin-bottom: 0.5em;
317 /* This is just for the HTML files generated with the framedhelp target */
320 border: solid thin black;
329 div.contents ul.contents {
332 div.contents ul.subcontents li {
341 "$Id: api-cups.header 8627 2009-05-13 21:39:17Z mike $"
343 CUPS API header for the Common UNIX Printing System (CUPS).
345 Copyright 2008-2009 by Apple Inc.
347 These coded instructions, statements, and computer programs are the
348 property of Apple Inc. and are protected by Federal copyright
349 law. Distribution and use rights are outlined in the file "LICENSE.txt"
350 which should have been included with this file. If this file is
351 file is missing or damaged, see the license at "http://www.cups.org/".
354 <h1 class='title'
>CUPS API
</h1>
356 <div class='summary'
><table summary='General Information'
>
370 <td>Programming:
<a href='api-overview.html' target='_top'
>Introduction to CUPS Programming
</a><br>
371 Programming:
<a href='api-array.html' target='_top'
>Array API
</a><br>
372 Programming:
<a href='api-filedir.html' target='_top'
>File and Directory APIs
</a><br>
373 Programming:
<a href='api-filter.html' target='_top'
>Filter and Backend Programming
</a><br>
374 Programming:
<a href='api-httpipp.html' target='_top'
>HTTP and IPP APIs
</a><br>
375 Programming:
<a href='api-ppd.html' target='_top'
>PPD API
</a><br>
376 Programming:
<a href='api-raster.html' target='_top'
>Raster API
</a></td>
380 <h2 class=
"title">Contents
</h2>
381 <ul class=
"contents">
382 <ul class=
"subcontents">
383 <li><a href=
"#OVERVIEW">Overview
</a><ul class=
"subcontents">
384 <li><a href=
"#CLIENTS_AND_SERVERS">Clients and Servers
</a></li>
385 <li><a href=
"#PRINTERS_AND_CLASSES">Printers and Classes
</a></li>
386 <li><a href=
"#OPTIONS">Options
</a></li>
387 <li><a href=
"#PRINT_JOBS">Print Jobs
</a></li>
388 <li><a href=
"#ERROR_HANDLING">Error Handling
</a></li>
389 <li><a href=
"#PASSWORDS_AND_AUTHENTICATION">Passwords and Authentication
</a></li>
391 <li><a href=
"#FUNCTIONS">Functions
</a><ul class=
"code">
392 <li><a href=
"#cupsAddDest" title=
"Add a destination to the list of destinations.">cupsAddDest
</a></li>
393 <li><a href=
"#cupsAddOption" title=
"Add an option to an option array.">cupsAddOption
</a></li>
394 <li><a href=
"#cupsAdminCreateWindowsPPD" title=
"Create the Windows PPD file for a printer.">cupsAdminCreateWindowsPPD
</a></li>
395 <li><a href=
"#cupsAdminExportSamba" title=
"Export a printer to Samba.">cupsAdminExportSamba
</a></li>
396 <li><a href=
"#cupsAdminGetServerSettings" title=
"Get settings from the server.">cupsAdminGetServerSettings
</a></li>
397 <li><a href=
"#cupsAdminSetServerSettings" title=
"Set settings on the server.">cupsAdminSetServerSettings
</a></li>
398 <li><a href=
"#cupsCancelJob" title=
"Cancel a print job on the default server.">cupsCancelJob
</a></li>
399 <li><a href=
"#cupsCancelJob2" title=
"Cancel or purge a print job.">cupsCancelJob2
</a></li>
400 <li><a href=
"#cupsCreateJob" title=
"Create an empty job for streaming.">cupsCreateJob
</a></li>
401 <li><a href=
"#cupsEncryption" title=
"Get the default encryption settings.">cupsEncryption
</a></li>
402 <li><a href=
"#cupsFinishDocument" title=
"Finish sending a document.">cupsFinishDocument
</a></li>
403 <li><a href=
"#cupsFreeDests" title=
"Free the memory used by the list of destinations.">cupsFreeDests
</a></li>
404 <li><a href=
"#cupsFreeJobs" title=
"Free memory used by job data.">cupsFreeJobs
</a></li>
405 <li><a href=
"#cupsFreeOptions" title=
"Free all memory used by options.">cupsFreeOptions
</a></li>
406 <li><a href=
"#cupsGetClasses" title=
"Get a list of printer classes from the default server.">cupsGetClasses
</a></li>
407 <li><a href=
"#cupsGetDefault" title=
"Get the default printer or class for the default server.">cupsGetDefault
</a></li>
408 <li><a href=
"#cupsGetDefault2" title=
"Get the default printer or class for the specified server.">cupsGetDefault2
</a></li>
409 <li><a href=
"#cupsGetDest" title=
"Get the named destination from the list.">cupsGetDest
</a></li>
410 <li><a href=
"#cupsGetDests" title=
"Get the list of destinations from the default server.">cupsGetDests
</a></li>
411 <li><a href=
"#cupsGetDests2" title=
"Get the list of destinations from the specified server.">cupsGetDests2
</a></li>
412 <li><a href=
"#cupsGetJobs" title=
"Get the jobs from the default server.">cupsGetJobs
</a></li>
413 <li><a href=
"#cupsGetJobs2" title=
"Get the jobs from the specified server.">cupsGetJobs2
</a></li>
414 <li><a href=
"#cupsGetNamedDest" title=
"Get options for the named destination.">cupsGetNamedDest
</a></li>
415 <li><a href=
"#cupsGetOption" title=
"Get an option value.">cupsGetOption
</a></li>
416 <li><a href=
"#cupsGetPPD" title=
"Get the PPD file for a printer on the default server.">cupsGetPPD
</a></li>
417 <li><a href=
"#cupsGetPPD2" title=
"Get the PPD file for a printer from the specified server.">cupsGetPPD2
</a></li>
418 <li><a href=
"#cupsGetPPD3" title=
"Get the PPD file for a printer on the specified
419 server if it has changed.">cupsGetPPD3
</a></li>
420 <li><a href=
"#cupsGetPassword" title=
"Get a password from the user.">cupsGetPassword
</a></li>
421 <li><a href=
"#cupsGetPassword2" title=
"Get a password from the user using the advanced
422 callback.">cupsGetPassword2
</a></li>
423 <li><a href=
"#cupsGetPrinters" title=
"Get a list of printers from the default server.">cupsGetPrinters
</a></li>
424 <li><a href=
"#cupsGetServerPPD" title=
"Get an available PPD file from the server.">cupsGetServerPPD
</a></li>
425 <li><a href=
"#cupsLangDefault" title=
"Return the default language.">cupsLangDefault
</a></li>
426 <li><a href=
"#cupsLangEncoding" title=
"Return the character encoding (us-ascii, etc.)
427 for the given language.">cupsLangEncoding
</a></li>
428 <li><a href=
"#cupsLangFlush" title=
"Flush all language data out of the cache.">cupsLangFlush
</a></li>
429 <li><a href=
"#cupsLangFree" title=
"Free language data.">cupsLangFree
</a></li>
430 <li><a href=
"#cupsLangGet" title=
"Get a language.">cupsLangGet
</a></li>
431 <li><a href=
"#cupsLastError" title=
"Return the last IPP status code.">cupsLastError
</a></li>
432 <li><a href=
"#cupsLastErrorString" title=
"Return the last IPP status-message.">cupsLastErrorString
</a></li>
433 <li><a href=
"#cupsNotifySubject" title=
"Return the subject for the given notification message.">cupsNotifySubject
</a></li>
434 <li><a href=
"#cupsNotifyText" title=
"Return the text for the given notification message.">cupsNotifyText
</a></li>
435 <li><a href=
"#cupsParseOptions" title=
"Parse options from a command-line argument.">cupsParseOptions
</a></li>
436 <li><a href=
"#cupsPrintFile" title=
"Print a file to a printer or class on the default server.">cupsPrintFile
</a></li>
437 <li><a href=
"#cupsPrintFile2" title=
"Print a file to a printer or class on the specified
438 server.">cupsPrintFile2
</a></li>
439 <li><a href=
"#cupsPrintFiles" title=
"Print one or more files to a printer or class on the
440 default server.">cupsPrintFiles
</a></li>
441 <li><a href=
"#cupsPrintFiles2" title=
"Print one or more files to a printer or class on the
442 specified server.">cupsPrintFiles2
</a></li>
443 <li><a href=
"#cupsRemoveDest" title=
"Remove a destination from the destination list.">cupsRemoveDest
</a></li>
444 <li><a href=
"#cupsRemoveOption" title=
"Remove an option from an option array.">cupsRemoveOption
</a></li>
445 <li><a href=
"#cupsServer" title=
"Return the hostname/address of the default server.">cupsServer
</a></li>
446 <li><a href=
"#cupsSetDefaultDest" title=
"Set the default destination.">cupsSetDefaultDest
</a></li>
447 <li><a href=
"#cupsSetDests" title=
"Save the list of destinations for the default server.">cupsSetDests
</a></li>
448 <li><a href=
"#cupsSetDests2" title=
"Save the list of destinations for the specified server.">cupsSetDests2
</a></li>
449 <li><a href=
"#cupsSetEncryption" title=
"Set the encryption preference.">cupsSetEncryption
</a></li>
450 <li><a href=
"#cupsSetPasswordCB" title=
"Set the password callback for CUPS.">cupsSetPasswordCB
</a></li>
451 <li><a href=
"#cupsSetPasswordCB2" title=
"Set the advanced password callback for CUPS.">cupsSetPasswordCB2
</a></li>
452 <li><a href=
"#cupsSetServer" title=
"Set the default server name.">cupsSetServer
</a></li>
453 <li><a href=
"#cupsSetUser" title=
"Set the default user name.">cupsSetUser
</a></li>
454 <li><a href=
"#cupsStartDocument" title=
"Add a document to a job created with cupsCreateJob().">cupsStartDocument
</a></li>
455 <li><a href=
"#cupsTempFd" title=
"Creates a temporary file.">cupsTempFd
</a></li>
456 <li><a href=
"#cupsTempFile" title=
"Generates a temporary filename.">cupsTempFile
</a></li>
457 <li><a href=
"#cupsTempFile2" title=
"Creates a temporary CUPS file.">cupsTempFile2
</a></li>
458 <li><a href=
"#cupsUser" title=
"Return the current user's name.">cupsUser
</a></li>
460 <li><a href=
"#TYPES">Data Types
</a><ul class=
"code">
461 <li><a href=
"#cups_dest_t" title=
"Destination">cups_dest_t
</a></li>
462 <li><a href=
"#cups_device_cb_t" title=
"Device callback ">cups_device_cb_t
</a></li>
463 <li><a href=
"#cups_job_t" title=
"Job">cups_job_t
</a></li>
464 <li><a href=
"#cups_option_t" title=
"Printer Options">cups_option_t
</a></li>
465 <li><a href=
"#cups_password_cb2_t" title=
"New password callback ">cups_password_cb2_t
</a></li>
466 <li><a href=
"#cups_password_cb_t" title=
"Password callback">cups_password_cb_t
</a></li>
467 <li><a href=
"#cups_ptype_t" title=
"Printer type/capability bits">cups_ptype_t
</a></li>
469 <li><a href=
"#STRUCTURES">Structures
</a><ul class=
"code">
470 <li><a href=
"#cups_dest_s" title=
"Destination">cups_dest_s
</a></li>
471 <li><a href=
"#cups_job_s" title=
"Job">cups_job_s
</a></li>
472 <li><a href=
"#cups_option_s" title=
"Printer Options">cups_option_s
</a></li>
474 <li><a href=
"#ENUMERATIONS">Constants
</a><ul class=
"code">
475 <li><a href=
"#cups_ptype_e" title=
"Printer type/capability bit constants">cups_ptype_e
</a></li>
478 "$Id: api-cups.shtml 7337 2008-02-22 04:44:04Z mike $"
480 CUPS API introduction for the Common UNIX Printing System (CUPS).
482 Copyright 2007-2008 by Apple Inc.
483 Copyright 1997-2006 by Easy Software Products, all rights reserved.
485 These coded instructions, statements, and computer programs are the
486 property of Apple Inc. and are protected by Federal copyright
487 law. Distribution and use rights are outlined in the file "LICENSE.txt"
488 which should have been included with this file. If this file is
489 file is missing or damaged, see the license at "http://www.cups.org/".
492 <h2 class='title'
><a name='OVERVIEW'
>Overview
</a></h2>
494 <p>The CUPS API provides the convenience functions needed to support
495 applications, filters, printer drivers, and backends that need to interface
496 with the CUPS scheduler.
</p>
498 <h3><a name='CLIENTS_AND_SERVERS'
>Clients and Servers
</a></h3>
500 <p>CUPS is based on the Internet Printing Protocol (
"IPP"), which allows
501 clients (applications) to communicate with a server (the scheduler) to get a
502 list of printers, send print jobs, and so forth. You identify which server
503 you want to communicate with using a pointer to the opaque structure
504 <code>http_t
</code>. All of the examples in this document use the
505 <code>CUPS_HTTP_DEFAULT
</code> constant, referring to the default connection
506 to the scheduler. The
<a href='api-httpipp.html' target='_top'
>HTTP and IPP
507 APIs
</a> document provides more information on server connections.
</p>
509 <h3><a name='PRINTERS_AND_CLASSES'
>Printers and Classes
</a></h3>
511 <p>Printers and classes (collections of printers) are accessed through
512 the
<a href=
"#cups_dest_t"><code>cups_dest_t
</code></a> structure which
513 includes the name (
<code>name
</code>), instance (
<code>instance
</code> -
514 a way of selecting certain saved options/settings), and the options and
515 attributes associated with that destination (
<code>num_options
</code> and
516 <code>options
</code>). Destinations are created using the
517 <a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> function and freed
518 using the
<a href='#cupsFreeDests'
><code>cupsFreeDests
</code></a> function.
519 The
<a href='#cupsGetDest'
><code>cupsGetDest
</code></a> function finds a
520 specific destination for printing:
</p>
522 <pre class='example'
>
523 #include
<cups/cups.h
>
525 <a href='#cups_dest_t'
>cups_dest_t
</a> *dests;
526 int num_dests =
<a href='#cupsGetDests'
>cupsGetDests
</a>(
&dests);
527 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest =
<a href='#cupsGetDest'
>cupsGetDest
</a>(
"name", NULL, num_dests, dests);
529 /* do something wiith dest */
531 <a href='#cupsFreeDests'
>cupsFreeDests
</a>(num_dests, dests);
534 <p>Passing
<code>NULL
</code> to
535 <a href='#cupsGetDest'
><code>cupsGetDest
</code></a> for the destination name
536 will return the default destination. Similarly, passing a
<code>NULL
</code>
537 instance will return the default instance for that destination.
</p>
539 <div class='table'
><table summary='Table
1: Printer Attributes' width='
80%'
>
540 <caption>Table
1:
<a name='TABLE1'
>Printer Attributes
</a></caption>
543 <th>Attribute Name
</th>
549 <td>"auth-info-required"</td>
550 <td>The type of authentication required for printing to this
551 destination:
"none",
"username,password",
"domain,username,password",
552 or
"negotiate" (Kerberos)
</td>
555 <td>"printer-info"</td>
556 <td>The human-readable description of the destination such as
"My
560 <td>"printer-is-accepting-jobs"</td>
561 <td>"1" if the destination is accepting new jobs,
"0" if not.
</td>
564 <td>"printer-is-shared"</td>
565 <td>"1" if the destination is being shared with other computers,
"0" if
569 <td>"printer-location"</td>
570 <td>The human-readable location of the destination such as
"Lab 4".
</td>
573 <td>"printer-make-and-model"</td>
574 <td>The human-readable make and model of the destination such as
"HP
575 LaserJet 4000 Series".
</td>
578 <td>"printer-state"</td>
579 <td>"3" if the destination is idle,
"4" if the destination is printing
580 a job, and
"5" if the destination is stopped.
</td>
583 <td>"printer-state-change-time"</td>
584 <td>The UNIX time when the destination entered the current state.
</td>
587 <td>"printer-state-reasons"</td>
588 <td>Additional comma-delimited state keywords for the destination
589 such as
"media-tray-empty-error" and
"toner-low-warning".
</td>
592 <td>"printer-type"</td>
593 <td>The
<a href='#cups_printer_t'
><code>cups_printer_t
</code></a>
594 value associated with the destination.
</td>
599 <h3><a name='OPTIONS'
>Options
</a></h3>
601 <p>Options are stored in arrays of
602 <a href='#cups_option_t'
><code>cups_option_t
</code></a> structures. Each
603 option has a name (
<code>name
</code>) and value (
<code>value
</code>)
604 associated with it. The
<a href='#cups_dest_t'
><code>cups_dest_t
</code></a>
605 <code>num_options
</code> and
<code>options
</code> members contain the
606 default options for a particular destination, along with several informational
607 attributes about the destination as shown in
<a href='#TABLE1'
>Table
1</a>.
608 The
<a href='#cupsGetOption'
><code>cupsGetOption
</code></a> function gets
609 the value for the named option. For example, the following code lists the
610 available destinations and their human-readable descriptions:
</p>
612 <pre class='example'
>
613 #include
<cups/cups.h
>
615 <a href='#cups_dest_t'
>cups_dest_t
</a> *dests;
616 int num_dests =
<a href='#cupsGetDests'
>cupsGetDests
</a>(
&dests);
617 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
621 for (i = num_dests, dest = dests; i
> 0; i --, dest ++)
622 if (dest-
>instance == NULL)
624 value =
<a href='#cupsGetOption'
>cupsGetOption
</a>(
"printer-info", dest-
>num_options, dest-
>options);
625 printf(
"%s (%s)\n", dest-
>name, value ? value :
"no description");
628 <a href='#cupsFreeDests'
>cupsFreeDests
</a>(num_dests, dests);
631 <p>You can create your own option arrays using the
632 <a href='#cupsAddOption'
><code>cupsAddOption
</code></a> function, which
633 adds a single named option to an array:
</p>
635 <pre class='example'
>
636 #include
<cups/cups.h
>
639 <a href='#cups_option_t'
>cups_option_t
</a> *options = NULL;
641 /* The returned num_options value is updated as needed */
642 num_options =
<a href='#cupsAddOption'
>cupsAddOption
</a>(
"first",
"value", num_options,
&options);
644 /* This adds a second option value */
645 num_options =
<a href='#cupsAddOption'
>cupsAddOption
</a>(
"second",
"value", num_options,
&options);
647 /* This replaces the first option we added */
648 num_options =
<a href='#cupsAddOption'
>cupsAddOption
</a>(
"first",
"new value", num_options,
&options);
651 <p>Use a
<code>for
</code> loop to copy the options from a destination:
</p>
653 <pre class='example'
>
654 #include
<cups/cups.h
>
658 <a href='#cups_option_t'
>cups_option_t
</a> *options = NULL;
659 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
661 for (i =
0; i < dest-
>num_options; i ++)
662 num_options =
<a href='#cupsAddOption'
>cupsAddOption
</a>(dest-
>options[i].name, dest-
>options[i].value,
663 num_options,
&options);
666 <p>Use the
<a href='#cupsFreeOptions'
><code>cupsFreeOptions
</code></a>
667 function to free the options array when you are done using it:
</p>
669 <pre class='example'
>
670 <a href='#cupsFreeOptions'
>cupsFreeOptions
</a>(num_options, options);
673 <h3><a name='PRINT_JOBS'
>Print Jobs
</a></h3>
675 <p>Print jobs are identified by a locally-unique job ID number from
1 to
676 2<sup>31</sup>-
1 and have options and one or more files for printing to a
677 single destination. The
<a href='#cupsPrintFile'
><code>cupsPrintFile
</code></a>
678 function creates a new job with one file. The following code prints the CUPS
681 <pre class='example'
>
682 #include
<cups/cups.h
>
684 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
686 <a href='#cups_option_t'
>cups_option_t
</a> *options;
689 /* Print a single file */
690 job_id =
<a href='#cupsPrintFile'
>cupsPrintFile
</a>(dest-
>name,
"/usr/share/cups/data/testprint.ps",
691 "Test Print", num_options, options);
694 <p>The
<a href='#cupsPrintFiles'
><code>cupsPrintFiles
</code></a> function
695 creates a job with multiple files. The files are provided in a
696 <code>char *
</code> array:
</p>
698 <pre class='example'
>
699 #include
<cups/cups.h
>
701 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
703 <a href='#cups_option_t'
>cups_option_t
</a> *options;
705 char *files[
3] = {
"file1.pdf",
"file2.pdf",
"file3.pdf" };
707 /* Print three files */
708 job_id =
<a href='#cupsPrintFiles'
>cupsPrintFiles
</a>(dest-
>name,
3, files,
"Test Print", num_options, options);
711 <p>Finally, the
<a href='#cupsCreateJob'
><code>cupsCreateJob
</code></a>
712 function creates a new job with no files in it. Files are added using the
713 <a href='#cupsStartDocument'
><code>cupsStartDocument
</code></a>,
714 <a href='api-httpipp.html#cupsWriteRequestData'
><code>cupsWriteRequestData
</code></a>,
715 and
<a href='#cupsFinishDocument'
><code>cupsFinishDocument
</code></a> functions.
716 The following example creates a job with
10 text files for printing:
</p>
718 <pre class='example'
>
719 #include
<cups/cups.h
>
721 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
723 <a href='#cups_option_t'
>cups_option_t
</a> *options;
729 job_id =
<a href='#cupsCreateJob'
>cupsCreateJob
</a>(CUPS_HTTP_DEFAULT, dest-
>name,
"10 Text Files",
730 num_options, options);
732 /* If the job is created, add
10 files */
735 for (i =
1; i
<=
10; i ++)
737 snprintf(buffer, sizeof(buffer),
"file%d.txt", i);
739 <a href='#cupsStartDocument'
>cupsStartDocument
</a>(CUPS_HTTP_DEFAULT, dest-
>name, job_id, buffer,
740 CUPS_FORMAT_TEXT, i ==
10);
742 snprintf(buffer, sizeof(buffer),
750 /* cupsWriteRequestData can be called as many times as needed */
751 <a href='#cupsWriteRequestData'
>cupsWriteRequestData
</a>(CUPS_HTTP_DEFAULT, buffer, strlen(buffer));
753 <a href='#cupsFinishDocument'
>cupsFinishDocument
</a>(CUPS_HTTP_DEFAULT, dest-
>name);
758 <p>Once you have created a job, you can monitor its status using the
759 <a href='#cupsGetJobs'
><code>cupsGetJobs
</code></a> function, which returns
760 an array of
<a href='#cups_job_t'
><code>cups_job_t
</code></a> structures.
761 Each contains the job ID (
<code>id
</code>), destination name
762 (
<code>dest
</code>), title (
<code>title
</code>), and other information
763 associated with the job. The job array is freed using the
764 <a href='#cupsFreeJobs'
><code>cupsFreeJobs
</code></a> function. The following
765 example monitors a specific job ID, showing the current job state once every
766 5 seconds until the job is completed:
</p>
768 <pre class='example'
>
769 #include
<cups/cups.h
>
771 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
774 <a href='#cups_job_t'
>cups_job_t
</a> *jobs;
776 ipp_jstate_t job_state = IPP_JOB_PENDING;
778 while (job_state
< IPP_JOB_STOPPED)
780 /* Get my jobs (
1) with any state (-
1) */
781 num_jobs =
<a href='#cupsGetJobs'
>cupsGetJobs
</a>(
&jobs, dest-
>name,
1, -
1);
783 /* Loop to find my job */
784 job_state = IPP_JOB_COMPLETED;
786 for (i =
0; i
< num_jobs; i ++)
787 if (jobs[i].id == job_id)
789 job_state = jobs[i].state;
793 /* Free the job array */
794 <a href='#cupsFreeJobs'
>cupsFreeJobs
</a>(num_jobs, jobs);
796 /* Show the current state */
799 case IPP_JOB_PENDING :
800 printf(
"Job %d is pending.\n", job_id);
803 printf(
"Job %d is held.\n", job_id);
805 case IPP_JOB_PROCESSING :
806 printf(
"Job %d is processing.\n", job_id);
808 case IPP_JOB_STOPPED :
809 printf(
"Job %d is stopped.\n", job_id);
811 case IPP_JOB_CANCELED :
812 printf(
"Job %d is canceled.\n", job_id);
814 case IPP_JOB_ABORTED :
815 printf(
"Job %d is aborted.\n", job_id);
817 case IPP_JOB_COMPLETED :
818 printf(
"Job %d is completed.\n", job_id);
822 /* Sleep if the job is not finished */
823 if (job_state
< IPP_JOB_STOPPED)
828 <p>To cancel a job, use the
829 <a href='#cupsCancelJob'
><code>cupsCancelJob
</code></a> function with the
832 <pre class='example'
>
833 #include
<cups/cups.h
>
835 <a href='#cups_dest_t'
>cups_dest_t
</a> *dest;
838 <a href='#cupsCancelJob'
>cupsCancelJob
</a>(dest-
>name, job_id);
841 <h3><a name='ERROR_HANDLING'
>Error Handling
</a></h3>
843 <p>If any of the CUPS API printing functions returns an error, the reason for
844 that error can be found by calling the
845 <a href='#cupsLastError'
><code>cupsLastError
</code></a> and
846 <a href='#cupsLastErrorString'
><code>cupsLastErrorString
</code></a> functions.
847 <a href='#cupsLastError'
><code>cupsLastError
</code></a> returns the last IPP
849 (
<a href='api-httpipp.html#ipp_status_t'
><code>ipp_status_t
</code></a>)
850 that was encountered, while
851 <a href='#cupsLastErrorString'
><code>cupsLastErrorString
</code></a> returns
852 a (localized) human-readable string that can be shown to the user. For example,
853 if any of the job creation functions returns a job ID of
0, you can use
854 <a href='#cupsLastErrorString'
><code>cupsLastErrorString
</code></a> to show
855 the reason why the job could not be created:
</p>
857 <pre class='example'
>
858 #include
<cups/cups.h
>
863 puts(cupsLastErrorString());
866 <h3><a name='PASSWORDS_AND_AUTHENTICATION'
>Passwords and Authentication
</a></h3>
868 <p>CUPS supports authentication of any request, including submission of print
869 jobs. The default mechanism for getting the username and password is to use the
870 login user and a password from the console.
</p>
872 <p>To support other types of applications, in particular Graphical User
873 Interfaces (
"GUIs"), the CUPS API provides functions to set the default
874 username and to register a callback function that returns a password string.
</p>
876 <p>The
<a href=
"#cupsSetPasswordCB"><code>cupsSetPasswordCB
</code></a>
877 function is used to set a password callback in your program. Only one
878 function can be used at any time.
</p>
880 <p>The
<a href=
"#cupsSetUser"><code>cupsSetUser
</code></a> function sets the
881 current username for authentication. This function can be called by your
882 password callback function to change the current username as needed.
</p>
884 <p>The following example shows a simple password callback that gets a
885 username and password from the user:
</p>
887 <pre class='example'
>
888 #include
<cups/cups.h
>
891 my_password_cb(const char *prompt)
898 /* Get a username from the user */
899 printf(
"Username: ");
900 if (fgets(user, sizeof(user), stdin) == NULL)
903 /* Strip the newline from the string and set the user */
904 user[strlen(user) -
1] = '\
0';
906 <a href='#cupsSetUser'
>cupsSetUser
</a>(user);
908 /* Use getpass() to ask for the password... */
909 return (getpass(
"Password: "));
912 <a href='#cupsSetPasswordCB'
>cupsSetPasswordCB
</a>(my_password_cb);
915 <p>Similarly, a GUI could display the prompt string in a window with input
916 fields for the username and password. The username should default to the
917 string returned by the
<a href=
"#cupsUser"><code>cupsUser
</code></a>
919 <h2 class=
"title"><a name=
"FUNCTIONS">Functions
</a></h2>
920 <h3 class=
"function"><a name=
"cupsAddDest">cupsAddDest
</a></h3>
921 <p class=
"description">Add a destination to the list of destinations.
</p>
923 int cupsAddDest (
<br>
924 const char *name,
<br>
925 const char *instance,
<br>
926 int num_dests,
<br>
927 <a href=
"#cups_dest_t">cups_dest_t
</a> **dests
<br>
929 <h4 class=
"parameters">Parameters
</h4>
932 <dd class=
"description">Destination name
</dd>
934 <dd class=
"description">Instance name or
<code>NULL
</code> for none/primary
</dd>
936 <dd class=
"description">Number of destinations
</dd>
938 <dd class=
"description">Destinations
</dd>
940 <h4 class=
"returnvalue">Return Value
</h4>
941 <p class=
"description">New number of destinations
</p>
942 <h4 class=
"discussion">Discussion
</h4>
943 <p class=
"discussion">This function cannot be used to add a new class or printer queue,
944 it only adds a new container of saved options for the named
945 destination or instance.
<br>
947 If the named destination already exists, the destination list is
948 returned unchanged. Adding a new instance of a destination creates
949 a copy of that destination's options.
<br>
951 Use the
<a href=
"#cupsSaveDests"><code>cupsSaveDests
</code></a> function to save the updated list of
952 destinations to the user's lpoptions file.
</p>
953 <h3 class=
"function"><a name=
"cupsAddOption">cupsAddOption
</a></h3>
954 <p class=
"description">Add an option to an option array.
</p>
956 int cupsAddOption (
<br>
957 const char *name,
<br>
958 const char *value,
<br>
959 int num_options,
<br>
960 <a href=
"#cups_option_t">cups_option_t
</a> **options
<br>
962 <h4 class=
"parameters">Parameters
</h4>
965 <dd class=
"description">Name of option
</dd>
967 <dd class=
"description">Value of option
</dd>
969 <dd class=
"description">Number of options
</dd>
971 <dd class=
"description">Pointer to options
</dd>
973 <h4 class=
"returnvalue">Return Value
</h4>
974 <p class=
"description">Number of options
</p>
975 <h4 class=
"discussion">Discussion
</h4>
976 <p class=
"discussion">New option arrays can be initialized simply by passing
0 for the
977 "num_options
" parameter.
</p>
978 <h3 class=
"function"><span class=
"info"> CUPS
1.2/Mac OS X
10.5 </span><a name=
"cupsAdminCreateWindowsPPD">cupsAdminCreateWindowsPPD
</a></h3>
979 <p class=
"description">Create the Windows PPD file for a printer.
</p>
981 char *cupsAdminCreateWindowsPPD (
<br>
982 http_t *http,
<br>
983 const char *dest,
<br>
984 char *buffer,
<br>
985 int bufsize
<br>
987 <h4 class=
"parameters">Parameters
</h4>
990 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
992 <dd class=
"description">Printer or class
</dd>
994 <dd class=
"description">Filename buffer
</dd>
996 <dd class=
"description">Size of filename buffer
</dd>
998 <h4 class=
"returnvalue">Return Value
</h4>
999 <p class=
"description">PPD file or NULL
</p>
1000 <h3 class=
"function"><span class=
"info"> CUPS
1.2/Mac OS X
10.5 </span><a name=
"cupsAdminExportSamba">cupsAdminExportSamba
</a></h3>
1001 <p class=
"description">Export a printer to Samba.
</p>
1003 int cupsAdminExportSamba (
<br>
1004 const char *dest,
<br>
1005 const char *ppd,
<br>
1006 const char *samba_server,
<br>
1007 const char *samba_user,
<br>
1008 const char *samba_password,
<br>
1009 FILE *logfile
<br>
1011 <h4 class=
"parameters">Parameters
</h4>
1014 <dd class=
"description">Destination to export
</dd>
1016 <dd class=
"description">PPD file
</dd>
1017 <dt>samba_server
</dt>
1018 <dd class=
"description">Samba server
</dd>
1020 <dd class=
"description">Samba username
</dd>
1021 <dt>samba_password
</dt>
1022 <dd class=
"description">Samba password
</dd>
1024 <dd class=
"description">Log file, if any
</dd>
1026 <h4 class=
"returnvalue">Return Value
</h4>
1027 <p class=
"description">1 on success,
0 on failure
</p>
1028 <h3 class=
"function"><span class=
"info"> CUPS
1.3/Mac OS X
10.5 </span><a name=
"cupsAdminGetServerSettings">cupsAdminGetServerSettings
</a></h3>
1029 <p class=
"description">Get settings from the server.
</p>
1031 int cupsAdminGetServerSettings (
<br>
1032 http_t *http,
<br>
1033 int *num_settings,
<br>
1034 <a href=
"#cups_option_t">cups_option_t
</a> **settings
<br>
1036 <h4 class=
"parameters">Parameters
</h4>
1039 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1040 <dt>num_settings
</dt>
1041 <dd class=
"description">Number of settings
</dd>
1043 <dd class=
"description">Settings
</dd>
1045 <h4 class=
"returnvalue">Return Value
</h4>
1046 <p class=
"description">1 on success,
0 on failure
</p>
1047 <h4 class=
"discussion">Discussion
</h4>
1048 <p class=
"discussion">The returned settings should be freed with cupsFreeOptions() when
1049 you are done with them.
1052 <h3 class=
"function"><span class=
"info"> CUPS
1.3/Mac OS X
10.5 </span><a name=
"cupsAdminSetServerSettings">cupsAdminSetServerSettings
</a></h3>
1053 <p class=
"description">Set settings on the server.
</p>
1055 int cupsAdminSetServerSettings (
<br>
1056 http_t *http,
<br>
1057 int num_settings,
<br>
1058 <a href=
"#cups_option_t">cups_option_t
</a> *settings
<br>
1060 <h4 class=
"parameters">Parameters
</h4>
1063 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1064 <dt>num_settings
</dt>
1065 <dd class=
"description">Number of settings
</dd>
1067 <dd class=
"description">Settings
</dd>
1069 <h4 class=
"returnvalue">Return Value
</h4>
1070 <p class=
"description">1 on success,
0 on failure
</p>
1071 <h3 class=
"function"><a name=
"cupsCancelJob">cupsCancelJob
</a></h3>
1072 <p class=
"description">Cancel a print job on the default server.
</p>
1074 int cupsCancelJob (
<br>
1075 const char *name,
<br>
1076 int job_id
<br>
1078 <h4 class=
"parameters">Parameters
</h4>
1081 <dd class=
"description">Name of printer or class
</dd>
1083 <dd class=
"description">Job ID,
<code>CUPS_JOBID_CURRENT
</code> for the current job, or
<code>CUPS_JOBID_ALL
</code> for all jobs
</dd>
1085 <h4 class=
"returnvalue">Return Value
</h4>
1086 <p class=
"description">1 on success,
0 on failure
</p>
1087 <h4 class=
"discussion">Discussion
</h4>
1088 <p class=
"discussion">Pass
<code>CUPS_JOBID_ALL
</code> to cancel all jobs or
<code>CUPS_JOBID_CURRENT
</code>
1089 to cancel the current job on the named destination.
<br>
1091 Use the
<a href=
"#cupsLastError"><code>cupsLastError
</code></a> and
<a href=
"#cupsLastErrorString"><code>cupsLastErrorString
</code></a> functions to get
1092 the cause of any failure.
</p>
1093 <h3 class=
"function"><span class=
"info"> CUPS
1.4/Mac OS X
10.6 </span><a name=
"cupsCancelJob2">cupsCancelJob2
</a></h3>
1094 <p class=
"description">Cancel or purge a print job.
</p>
1096 ipp_status_t cupsCancelJob2 (
<br>
1097 http_t *http,
<br>
1098 const char *name,
<br>
1099 int job_id,
<br>
1100 int purge
<br>
1102 <h4 class=
"parameters">Parameters
</h4>
1105 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1107 <dd class=
"description">Name of printer or class
</dd>
1109 <dd class=
"description">Job ID,
<code>CUPS_JOBID_CURRENT
</code> for the current job, or
<code>CUPS_JOBID_ALL
</code> for all jobs
</dd>
1111 <dd class=
"description">1 to purge,
0 to cancel
</dd>
1113 <h4 class=
"returnvalue">Return Value
</h4>
1114 <p class=
"description">IPP status
</p>
1115 <h4 class=
"discussion">Discussion
</h4>
1116 <p class=
"discussion">Canceled jobs remain in the job history while purged jobs are removed
1117 from the job history.
<br>
1119 Pass
<code>CUPS_JOBID_ALL
</code> to cancel all jobs or
<code>CUPS_JOBID_CURRENT
</code>
1120 to cancel the current job on the named destination.
<br>
1122 Use the
<a href=
"#cupsLastError"><code>cupsLastError
</code></a> and
<a href=
"#cupsLastErrorString"><code>cupsLastErrorString
</code></a> functions to get
1123 the cause of any failure.
1126 <h3 class=
"function"><span class=
"info"> CUPS
1.4/Mac OS X
10.6 </span><a name=
"cupsCreateJob">cupsCreateJob
</a></h3>
1127 <p class=
"description">Create an empty job for streaming.
</p>
1129 int cupsCreateJob (
<br>
1130 http_t *http,
<br>
1131 const char *name,
<br>
1132 const char *title,
<br>
1133 int num_options,
<br>
1134 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1136 <h4 class=
"parameters">Parameters
</h4>
1139 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1141 <dd class=
"description">Destination name
</dd>
1143 <dd class=
"description">Title of job
</dd>
1144 <dt>num_options
</dt>
1145 <dd class=
"description">Number of options
</dd>
1147 <dd class=
"description">Options
</dd>
1149 <h4 class=
"returnvalue">Return Value
</h4>
1150 <p class=
"description">Job ID or
0 on error
</p>
1151 <h4 class=
"discussion">Discussion
</h4>
1152 <p class=
"discussion">Use this function when you want to stream print data using the
1153 <a href=
"#cupsStartDocument"><code>cupsStartDocument
</code></a>,
<a href=
"#cupsWriteRequestData"><code>cupsWriteRequestData
</code></a>, and
1154 <a href=
"#cupsFinishDocument"><code>cupsFinishDocument
</code></a> functions. If you have one or more files to
1155 print, use the
<a href=
"#cupsPrintFile2"><code>cupsPrintFile2
</code></a> or
<a href=
"#cupsPrintFiles2"><code>cupsPrintFiles2
</code></a> function
1159 <h3 class=
"function"><a name=
"cupsEncryption">cupsEncryption
</a></h3>
1160 <p class=
"description">Get the default encryption settings.
</p>
1162 http_encryption_t cupsEncryption (void);
</p>
1163 <h4 class=
"returnvalue">Return Value
</h4>
1164 <p class=
"description">Encryption settings
</p>
1165 <h4 class=
"discussion">Discussion
</h4>
1166 <p class=
"discussion">The default encryption setting comes from the CUPS_ENCRYPTION
1167 environment variable, then the ~/.cups/client.conf file, and finally the
1168 /etc/cups/client.conf file. If not set, the default is
1169 <code>HTTP_ENCRYPT_IF_REQUESTED
</code>.
</p>
1170 <h3 class=
"function"><span class=
"info"> CUPS
1.4/Mac OS X
10.6 </span><a name=
"cupsFinishDocument">cupsFinishDocument
</a></h3>
1171 <p class=
"description">Finish sending a document.
</p>
1173 ipp_status_t cupsFinishDocument (
<br>
1174 http_t *http,
<br>
1175 const char *name
<br>
1177 <h4 class=
"parameters">Parameters
</h4>
1180 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1182 <dd class=
"description">Destination name
</dd>
1184 <h4 class=
"returnvalue">Return Value
</h4>
1185 <p class=
"description">Status of document submission
</p>
1186 <h4 class=
"discussion">Discussion
</h4>
1187 <p class=
"discussion">The document must have been started using
<a href=
"#cupsStartDocument"><code>cupsStartDocument
</code></a>.
1190 <h3 class=
"function"><a name=
"cupsFreeDests">cupsFreeDests
</a></h3>
1191 <p class=
"description">Free the memory used by the list of destinations.
</p>
1193 void cupsFreeDests (
<br>
1194 int num_dests,
<br>
1195 <a href=
"#cups_dest_t">cups_dest_t
</a> *dests
<br>
1197 <h4 class=
"parameters">Parameters
</h4>
1200 <dd class=
"description">Number of destinations
</dd>
1202 <dd class=
"description">Destinations
</dd>
1204 <h3 class=
"function"><a name=
"cupsFreeJobs">cupsFreeJobs
</a></h3>
1205 <p class=
"description">Free memory used by job data.
</p>
1207 void cupsFreeJobs (
<br>
1208 int num_jobs,
<br>
1209 <a href=
"#cups_job_t">cups_job_t
</a> *jobs
<br>
1211 <h4 class=
"parameters">Parameters
</h4>
1214 <dd class=
"description">Number of jobs
</dd>
1216 <dd class=
"description">Jobs
</dd>
1218 <h3 class=
"function"><a name=
"cupsFreeOptions">cupsFreeOptions
</a></h3>
1219 <p class=
"description">Free all memory used by options.
</p>
1221 void cupsFreeOptions (
<br>
1222 int num_options,
<br>
1223 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1225 <h4 class=
"parameters">Parameters
</h4>
1227 <dt>num_options
</dt>
1228 <dd class=
"description">Number of options
</dd>
1230 <dd class=
"description">Pointer to options
</dd>
1232 <h3 class=
"function"><span class=
"info"> DEPRECATED
</span><a name=
"cupsGetClasses">cupsGetClasses
</a></h3>
1233 <p class=
"description">Get a list of printer classes from the default server.
</p>
1235 int cupsGetClasses (
<br>
1236 char ***classes
<br>
1238 <h4 class=
"parameters">Parameters
</h4>
1241 <dd class=
"description">Classes
</dd>
1243 <h4 class=
"returnvalue">Return Value
</h4>
1244 <p class=
"description">Number of classes
</p>
1245 <h4 class=
"discussion">Discussion
</h4>
1246 <p class=
"discussion">This function is deprecated - use
<a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> instead.
1249 <h3 class=
"function"><a name=
"cupsGetDefault">cupsGetDefault
</a></h3>
1250 <p class=
"description">Get the default printer or class for the default server.
</p>
1252 const char *cupsGetDefault (void);
</p>
1253 <h4 class=
"returnvalue">Return Value
</h4>
1254 <p class=
"description">Default printer or
<code>NULL
</code></p>
1255 <h4 class=
"discussion">Discussion
</h4>
1256 <p class=
"discussion">This function returns the default printer or class as defined by
1257 the LPDEST or PRINTER environment variables. If these environment
1258 variables are not set, the server default destination is returned.
1259 Applications should use the
<a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> and
<a href=
"#cupsGetDest"><code>cupsGetDest
</code></a>
1260 functions to get the user-defined default printer, as this function does
1261 not support the lpoptions-defined default printer.
</p>
1262 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21/Mac OS X
10.4 </span><a name=
"cupsGetDefault2">cupsGetDefault2
</a></h3>
1263 <p class=
"description">Get the default printer or class for the specified server.
</p>
1265 const char *cupsGetDefault2 (
<br>
1266 http_t *http
<br>
1268 <h4 class=
"parameters">Parameters
</h4>
1271 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1273 <h4 class=
"returnvalue">Return Value
</h4>
1274 <p class=
"description">Default printer or
<code>NULL
</code></p>
1275 <h4 class=
"discussion">Discussion
</h4>
1276 <p class=
"discussion">This function returns the default printer or class as defined by
1277 the LPDEST or PRINTER environment variables. If these environment
1278 variables are not set, the server default destination is returned.
1279 Applications should use the
<a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> and
<a href=
"#cupsGetDest"><code>cupsGetDest
</code></a>
1280 functions to get the user-defined default printer, as this function does
1281 not support the lpoptions-defined default printer.
1284 <h3 class=
"function"><a name=
"cupsGetDest">cupsGetDest
</a></h3>
1285 <p class=
"description">Get the named destination from the list.
</p>
1287 <a href=
"#cups_dest_t">cups_dest_t
</a> *cupsGetDest (
<br>
1288 const char *name,
<br>
1289 const char *instance,
<br>
1290 int num_dests,
<br>
1291 <a href=
"#cups_dest_t">cups_dest_t
</a> *dests
<br>
1293 <h4 class=
"parameters">Parameters
</h4>
1296 <dd class=
"description">Destination name or
<code>NULL
</code> for the default destination
</dd>
1298 <dd class=
"description">Instance name or
<code>NULL
</code></dd>
1300 <dd class=
"description">Number of destinations
</dd>
1302 <dd class=
"description">Destinations
</dd>
1304 <h4 class=
"returnvalue">Return Value
</h4>
1305 <p class=
"description">Destination pointer or
<code>NULL
</code></p>
1306 <h4 class=
"discussion">Discussion
</h4>
1307 <p class=
"discussion">Use the
<a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> or
<a href=
"#cupsGetDests2"><code>cupsGetDests2
</code></a> functions to get a
1308 list of supported destinations for the current user.
</p>
1309 <h3 class=
"function"><a name=
"cupsGetDests">cupsGetDests
</a></h3>
1310 <p class=
"description">Get the list of destinations from the default server.
</p>
1312 int cupsGetDests (
<br>
1313 <a href=
"#cups_dest_t">cups_dest_t
</a> **dests
<br>
1315 <h4 class=
"parameters">Parameters
</h4>
1318 <dd class=
"description">Destinations
</dd>
1320 <h4 class=
"returnvalue">Return Value
</h4>
1321 <p class=
"description">Number of destinations
</p>
1322 <h4 class=
"discussion">Discussion
</h4>
1323 <p class=
"discussion">Starting with CUPS
1.2, the returned list of destinations include the
1324 printer-info, printer-is-accepting-jobs, printer-is-shared,
1325 printer-make-and-model, printer-state, printer-state-change-time,
1326 printer-state-reasons, and printer-type attributes as options. CUPS
1.4
1327 adds the marker-change-time, marker-colors, marker-high-levels,
1328 marker-levels, marker-low-levels, marker-message, marker-names,
1329 marker-types, and printer-commands attributes as well.
<br>
1331 Use the
<a href=
"#cupsFreeDests"><code>cupsFreeDests
</code></a> function to free the destination list and
1332 the
<a href=
"#cupsGetDest"><code>cupsGetDest
</code></a> function to find a particular destination.
</p>
1333 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21/Mac OS X
10.4 </span><a name=
"cupsGetDests2">cupsGetDests2
</a></h3>
1334 <p class=
"description">Get the list of destinations from the specified server.
</p>
1336 int cupsGetDests2 (
<br>
1337 http_t *http,
<br>
1338 <a href=
"#cups_dest_t">cups_dest_t
</a> **dests
<br>
1340 <h4 class=
"parameters">Parameters
</h4>
1343 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1345 <dd class=
"description">Destinations
</dd>
1347 <h4 class=
"returnvalue">Return Value
</h4>
1348 <p class=
"description">Number of destinations
</p>
1349 <h4 class=
"discussion">Discussion
</h4>
1350 <p class=
"discussion">Starting with CUPS
1.2, the returned list of destinations include the
1351 printer-info, printer-is-accepting-jobs, printer-is-shared,
1352 printer-make-and-model, printer-state, printer-state-change-time,
1353 printer-state-reasons, and printer-type attributes as options. CUPS
1.4
1354 adds the marker-change-time, marker-colors, marker-high-levels,
1355 marker-levels, marker-low-levels, marker-message, marker-names,
1356 marker-types, and printer-commands attributes as well.
<br>
1358 Use the
<a href=
"#cupsFreeDests"><code>cupsFreeDests
</code></a> function to free the destination list and
1359 the
<a href=
"#cupsGetDest"><code>cupsGetDest
</code></a> function to find a particular destination.
1362 <h3 class=
"function"><a name=
"cupsGetJobs">cupsGetJobs
</a></h3>
1363 <p class=
"description">Get the jobs from the default server.
</p>
1365 int cupsGetJobs (
<br>
1366 <a href=
"#cups_job_t">cups_job_t
</a> **jobs,
<br>
1367 const char *name,
<br>
1368 int myjobs,
<br>
1369 int whichjobs
<br>
1371 <h4 class=
"parameters">Parameters
</h4>
1374 <dd class=
"description">Job data
</dd>
1376 <dd class=
"description"><code>NULL
</code> = all destinations, otherwise show jobs for named destination
</dd>
1378 <dd class=
"description">0 = all users,
1 = mine
</dd>
1380 <dd class=
"description"><code>CUPS_WHICHJOBS_ALL
</code>,
<code>CUPS_WHICHJOBS_ACTIVE
</code>, or
<code>CUPS_WHICHJOBS_COMPLETED
</code></dd>
1382 <h4 class=
"returnvalue">Return Value
</h4>
1383 <p class=
"description">Number of jobs
</p>
1384 <h4 class=
"discussion">Discussion
</h4>
1385 <p class=
"discussion">A
"whichjobs
" value of
<code>CUPS_WHICHJOBS_ALL
</code> returns all jobs regardless
1386 of state, while
<code>CUPS_WHICHJOBS_ACTIVE
</code> returns jobs that are
1387 pending, processing, or held and
<code>CUPS_WHICHJOBS_COMPLETED
</code> returns
1388 jobs that are stopped, canceled, aborted, or completed.
</p>
1389 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21/Mac OS X
10.4 </span><a name=
"cupsGetJobs2">cupsGetJobs2
</a></h3>
1390 <p class=
"description">Get the jobs from the specified server.
</p>
1392 int cupsGetJobs2 (
<br>
1393 http_t *http,
<br>
1394 <a href=
"#cups_job_t">cups_job_t
</a> **jobs,
<br>
1395 const char *name,
<br>
1396 int myjobs,
<br>
1397 int whichjobs
<br>
1399 <h4 class=
"parameters">Parameters
</h4>
1402 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1404 <dd class=
"description">Job data
</dd>
1406 <dd class=
"description"><code>NULL
</code> = all destinations, otherwise show jobs for named destination
</dd>
1408 <dd class=
"description">0 = all users,
1 = mine
</dd>
1410 <dd class=
"description"><code>CUPS_WHICHJOBS_ALL
</code>,
<code>CUPS_WHICHJOBS_ACTIVE
</code>, or
<code>CUPS_WHICHJOBS_COMPLETED
</code></dd>
1412 <h4 class=
"returnvalue">Return Value
</h4>
1413 <p class=
"description">Number of jobs
</p>
1414 <h4 class=
"discussion">Discussion
</h4>
1415 <p class=
"discussion">A
"whichjobs
" value of
<code>CUPS_WHICHJOBS_ALL
</code> returns all jobs regardless
1416 of state, while
<code>CUPS_WHICHJOBS_ACTIVE
</code> returns jobs that are
1417 pending, processing, or held and
<code>CUPS_WHICHJOBS_COMPLETED
</code> returns
1418 jobs that are stopped, canceled, aborted, or completed.
1421 <h3 class=
"function"><span class=
"info"> CUPS
1.4/Mac OS X
10.6 </span><a name=
"cupsGetNamedDest">cupsGetNamedDest
</a></h3>
1422 <p class=
"description">Get options for the named destination.
</p>
1424 <a href=
"#cups_dest_t">cups_dest_t
</a> *cupsGetNamedDest (
<br>
1425 http_t *http,
<br>
1426 const char *name,
<br>
1427 const char *instance
<br>
1429 <h4 class=
"parameters">Parameters
</h4>
1432 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1434 <dd class=
"description">Destination name or
<code>NULL
</code> for the default destination
</dd>
1436 <dd class=
"description">Instance name or
<code>NULL
</code></dd>
1438 <h4 class=
"returnvalue">Return Value
</h4>
1439 <p class=
"description">Destination or
<code>NULL
</code></p>
1440 <h4 class=
"discussion">Discussion
</h4>
1441 <p class=
"discussion">This function is optimized for retrieving a single destination and should
1442 be used instead of
<a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> and
<a href=
"#cupsGetDest"><code>cupsGetDest
</code></a> when you either
1443 know the name of the destination or want to print to the default destination.
1444 If
<code>NULL
</code> is returned, the destination does not exist or there is no
1445 default destination.
<br>
1447 If
"http
" is
<code>CUPS_HTTP_DEFAULT
</code>, the connection to the default print
1448 server will be used.
<br>
1450 If
"name
" is
<code>NULL
</code>, the default printer for the current user will be
1453 The returned destination must be freed using
<a href=
"#cupsFreeDests"><code>cupsFreeDests
</code></a> with a
1454 "num_dests
" value of
1.
1457 <h3 class=
"function"><a name=
"cupsGetOption">cupsGetOption
</a></h3>
1458 <p class=
"description">Get an option value.
</p>
1460 const char *cupsGetOption (
<br>
1461 const char *name,
<br>
1462 int num_options,
<br>
1463 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1465 <h4 class=
"parameters">Parameters
</h4>
1468 <dd class=
"description">Name of option
</dd>
1469 <dt>num_options
</dt>
1470 <dd class=
"description">Number of options
</dd>
1472 <dd class=
"description">Options
</dd>
1474 <h4 class=
"returnvalue">Return Value
</h4>
1475 <p class=
"description">Option value or
<code>NULL
</code></p>
1476 <h3 class=
"function"><a name=
"cupsGetPPD">cupsGetPPD
</a></h3>
1477 <p class=
"description">Get the PPD file for a printer on the default server.
</p>
1479 const char *cupsGetPPD (
<br>
1480 const char *name
<br>
1482 <h4 class=
"parameters">Parameters
</h4>
1485 <dd class=
"description">Destination name
</dd>
1487 <h4 class=
"returnvalue">Return Value
</h4>
1488 <p class=
"description">Filename for PPD file
</p>
1489 <h4 class=
"discussion">Discussion
</h4>
1490 <p class=
"discussion">For classes,
<code>cupsGetPPD
</code> returns the PPD file for the first printer
1493 The returned filename is stored in a static buffer and is overwritten with
1494 each call to
<code>cupsGetPPD
</code> or
<a href=
"#cupsGetPPD2"><code>cupsGetPPD2
</code></a>.
</p>
1495 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21/Mac OS X
10.4 </span><a name=
"cupsGetPPD2">cupsGetPPD2
</a></h3>
1496 <p class=
"description">Get the PPD file for a printer from the specified server.
</p>
1498 const char *cupsGetPPD2 (
<br>
1499 http_t *http,
<br>
1500 const char *name
<br>
1502 <h4 class=
"parameters">Parameters
</h4>
1505 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1507 <dd class=
"description">Destination name
</dd>
1509 <h4 class=
"returnvalue">Return Value
</h4>
1510 <p class=
"description">Filename for PPD file
</p>
1511 <h4 class=
"discussion">Discussion
</h4>
1512 <p class=
"discussion">For classes,
<code>cupsGetPPD2
</code> returns the PPD file for the first printer
1515 The returned filename is stored in a static buffer and is overwritten with
1516 each call to
<a href=
"#cupsGetPPD"><code>cupsGetPPD
</code></a> or
<code>cupsGetPPD2
</code>.
1519 <h3 class=
"function"><span class=
"info"> CUPS
1.4/Mac OS X
10.6 </span><a name=
"cupsGetPPD3">cupsGetPPD3
</a></h3>
1520 <p class=
"description">Get the PPD file for a printer on the specified
1521 server if it has changed.
</p>
1523 http_status_t cupsGetPPD3 (
<br>
1524 http_t *http,
<br>
1525 const char *name,
<br>
1526 time_t *modtime,
<br>
1527 char *buffer,
<br>
1528 size_t bufsize
<br>
1530 <h4 class=
"parameters">Parameters
</h4>
1533 <dd class=
"description">HTTP connection or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1535 <dd class=
"description">Destination name
</dd>
1537 <dd class=
"description">Modification time
</dd>
1539 <dd class=
"description">Filename buffer
</dd>
1541 <dd class=
"description">Size of filename buffer
</dd>
1543 <h4 class=
"returnvalue">Return Value
</h4>
1544 <p class=
"description">HTTP status
</p>
1545 <h4 class=
"discussion">Discussion
</h4>
1546 <p class=
"discussion">The
"modtime
" parameter contains the modification time of any
1547 locally-cached content and is updated with the time from the PPD file on
1550 The
"buffer
" parameter contains the local PPD filename. If it contains
1551 the empty string, a new temporary file is created, otherwise the existing
1552 file will be overwritten as needed.
<br>
1554 On success,
<code>HTTP_OK
</code> is returned for a new PPD file and
1555 <code>HTTP_NOT_MODIFIED
</code> if the existing PPD file is up-to-date. Any other
1556 status is an error.
<br>
1558 For classes,
<code>cupsGetPPD3
</code> returns the PPD file for the first printer
1562 <h3 class=
"function"><a name=
"cupsGetPassword">cupsGetPassword
</a></h3>
1563 <p class=
"description">Get a password from the user.
</p>
1565 const char *cupsGetPassword (
<br>
1566 const char *prompt
<br>
1568 <h4 class=
"parameters">Parameters
</h4>
1571 <dd class=
"description">Prompt string
</dd>
1573 <h4 class=
"returnvalue">Return Value
</h4>
1574 <p class=
"description">Password
</p>
1575 <h4 class=
"discussion">Discussion
</h4>
1576 <p class=
"discussion">Uses the current password callback function. Returns
<code>NULL
</code> if the
1577 user does not provide a password.
</p>
1578 <h3 class=
"function"><span class=
"info"> CUPS
1.4/Mac OS X
10.6 </span><a name=
"cupsGetPassword2">cupsGetPassword2
</a></h3>
1579 <p class=
"description">Get a password from the user using the advanced
1582 const char *cupsGetPassword2 (
<br>
1583 const char *prompt,
<br>
1584 http_t *http,
<br>
1585 const char *method,
<br>
1586 const char *resource
<br>
1588 <h4 class=
"parameters">Parameters
</h4>
1591 <dd class=
"description">Prompt string
</dd>
1593 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1595 <dd class=
"description">Request method (
"GET
",
"POST
",
"PUT
")
</dd>
1597 <dd class=
"description">Resource path
</dd>
1599 <h4 class=
"returnvalue">Return Value
</h4>
1600 <p class=
"description">Password
</p>
1601 <h4 class=
"discussion">Discussion
</h4>
1602 <p class=
"discussion">Uses the current password callback function. Returns
<code>NULL
</code> if the
1603 user does not provide a password.
1606 <h3 class=
"function"><span class=
"info"> DEPRECATED
</span><a name=
"cupsGetPrinters">cupsGetPrinters
</a></h3>
1607 <p class=
"description">Get a list of printers from the default server.
</p>
1609 int cupsGetPrinters (
<br>
1610 char ***printers
<br>
1612 <h4 class=
"parameters">Parameters
</h4>
1615 <dd class=
"description">Printers
</dd>
1617 <h4 class=
"returnvalue">Return Value
</h4>
1618 <p class=
"description">Number of printers
</p>
1619 <h4 class=
"discussion">Discussion
</h4>
1620 <p class=
"discussion">This function is deprecated - use
<a href=
"#cupsGetDests"><code>cupsGetDests
</code></a> instead.
1623 <h3 class=
"function"><span class=
"info"> CUPS
1.3/Mac OS X
10.5 </span><a name=
"cupsGetServerPPD">cupsGetServerPPD
</a></h3>
1624 <p class=
"description">Get an available PPD file from the server.
</p>
1626 char *cupsGetServerPPD (
<br>
1627 http_t *http,
<br>
1628 const char *name
<br>
1630 <h4 class=
"parameters">Parameters
</h4>
1633 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1635 <dd class=
"description">Name of PPD file (
"ppd-name
")
</dd>
1637 <h4 class=
"returnvalue">Return Value
</h4>
1638 <p class=
"description">Name of PPD file or
<code>NULL
</code> on error
</p>
1639 <h4 class=
"discussion">Discussion
</h4>
1640 <p class=
"discussion">This function returns the named PPD file from the server. The
1641 list of available PPDs is provided by the IPP
<code>CUPS_GET_PPDS
</code>
1644 You must remove (unlink) the PPD file when you are finished with
1645 it. The PPD filename is stored in a static location that will be
1646 overwritten on the next call to
<a href=
"#cupsGetPPD"><code>cupsGetPPD
</code></a>,
<a href=
"#cupsGetPPD2"><code>cupsGetPPD2
</code></a>,
1647 or
<a href=
"#cupsGetServerPPD"><code>cupsGetServerPPD
</code></a>.
1650 <h3 class=
"function"><a name=
"cupsLangDefault">cupsLangDefault
</a></h3>
1651 <p class=
"description">Return the default language.
</p>
1653 cups_lang_t *cupsLangDefault (void);
</p>
1654 <h4 class=
"returnvalue">Return Value
</h4>
1655 <p class=
"description">Language data
</p>
1656 <h3 class=
"function"><a name=
"cupsLangEncoding">cupsLangEncoding
</a></h3>
1657 <p class=
"description">Return the character encoding (us-ascii, etc.)
1658 for the given language.
</p>
1660 const char *cupsLangEncoding (
<br>
1661 cups_lang_t *lang
<br>
1663 <h4 class=
"parameters">Parameters
</h4>
1666 <dd class=
"description">Language data
</dd>
1668 <h4 class=
"returnvalue">Return Value
</h4>
1669 <p class=
"description">Character encoding
</p>
1670 <h3 class=
"function"><a name=
"cupsLangFlush">cupsLangFlush
</a></h3>
1671 <p class=
"description">Flush all language data out of the cache.
</p>
1673 void cupsLangFlush (void);
</p>
1674 <h3 class=
"function"><a name=
"cupsLangFree">cupsLangFree
</a></h3>
1675 <p class=
"description">Free language data.
</p>
1677 void cupsLangFree (
<br>
1678 cups_lang_t *lang
<br>
1680 <h4 class=
"parameters">Parameters
</h4>
1683 <dd class=
"description">Language to free
</dd>
1685 <h4 class=
"discussion">Discussion
</h4>
1686 <p class=
"discussion">This does not actually free anything; use
<a href=
"#cupsLangFlush"><code>cupsLangFlush
</code></a> for that.
</p>
1687 <h3 class=
"function"><a name=
"cupsLangGet">cupsLangGet
</a></h3>
1688 <p class=
"description">Get a language.
</p>
1690 cups_lang_t *cupsLangGet (
<br>
1691 const char *language
<br>
1693 <h4 class=
"parameters">Parameters
</h4>
1696 <dd class=
"description">Language or locale
</dd>
1698 <h4 class=
"returnvalue">Return Value
</h4>
1699 <p class=
"description">Language data
</p>
1700 <h3 class=
"function"><a name=
"cupsLastError">cupsLastError
</a></h3>
1701 <p class=
"description">Return the last IPP status code.
</p>
1703 ipp_status_t cupsLastError (void);
</p>
1704 <h4 class=
"returnvalue">Return Value
</h4>
1705 <p class=
"description">IPP status code from last request
</p>
1706 <h3 class=
"function"><span class=
"info"> CUPS
1.2/Mac OS X
10.5 </span><a name=
"cupsLastErrorString">cupsLastErrorString
</a></h3>
1707 <p class=
"description">Return the last IPP status-message.
</p>
1709 const char *cupsLastErrorString (void);
</p>
1710 <h4 class=
"returnvalue">Return Value
</h4>
1711 <p class=
"description">status-message text from last request
</p>
1712 <h3 class=
"function"><span class=
"info"> CUPS
1.2/Mac OS X
10.5 </span><a name=
"cupsNotifySubject">cupsNotifySubject
</a></h3>
1713 <p class=
"description">Return the subject for the given notification message.
</p>
1715 char *cupsNotifySubject (
<br>
1716 cups_lang_t *lang,
<br>
1717 ipp_t *event
<br>
1719 <h4 class=
"parameters">Parameters
</h4>
1722 <dd class=
"description">Language data
</dd>
1724 <dd class=
"description">Event data
</dd>
1726 <h4 class=
"returnvalue">Return Value
</h4>
1727 <p class=
"description">Subject string or
<code>NULL
</code></p>
1728 <h4 class=
"discussion">Discussion
</h4>
1729 <p class=
"discussion">The returned string must be freed by the caller using
<code>free
</code>.
1732 <h3 class=
"function"><span class=
"info"> CUPS
1.2/Mac OS X
10.5 </span><a name=
"cupsNotifyText">cupsNotifyText
</a></h3>
1733 <p class=
"description">Return the text for the given notification message.
</p>
1735 char *cupsNotifyText (
<br>
1736 cups_lang_t *lang,
<br>
1737 ipp_t *event
<br>
1739 <h4 class=
"parameters">Parameters
</h4>
1742 <dd class=
"description">Language data
</dd>
1744 <dd class=
"description">Event data
</dd>
1746 <h4 class=
"returnvalue">Return Value
</h4>
1747 <p class=
"description">Message text or
<code>NULL
</code></p>
1748 <h4 class=
"discussion">Discussion
</h4>
1749 <p class=
"discussion">The returned string must be freed by the caller using
<code>free
</code>.
1752 <h3 class=
"function"><a name=
"cupsParseOptions">cupsParseOptions
</a></h3>
1753 <p class=
"description">Parse options from a command-line argument.
</p>
1755 int cupsParseOptions (
<br>
1756 const char *arg,
<br>
1757 int num_options,
<br>
1758 <a href=
"#cups_option_t">cups_option_t
</a> **options
<br>
1760 <h4 class=
"parameters">Parameters
</h4>
1763 <dd class=
"description">Argument to parse
</dd>
1764 <dt>num_options
</dt>
1765 <dd class=
"description">Number of options
</dd>
1767 <dd class=
"description">Options found
</dd>
1769 <h4 class=
"returnvalue">Return Value
</h4>
1770 <p class=
"description">Number of options found
</p>
1771 <h4 class=
"discussion">Discussion
</h4>
1772 <p class=
"discussion">This function converts space-delimited name/value pairs according
1773 to the PAPI text option ABNF specification. Collection values
1774 (
"name={a=... b=... c=...}
") are stored with the curley brackets
1775 intact - use
<code>cupsParseOptions
</code> on the value to extract the
1776 collection attributes.
</p>
1777 <h3 class=
"function"><a name=
"cupsPrintFile">cupsPrintFile
</a></h3>
1778 <p class=
"description">Print a file to a printer or class on the default server.
</p>
1780 int cupsPrintFile (
<br>
1781 const char *name,
<br>
1782 const char *filename,
<br>
1783 const char *title,
<br>
1784 int num_options,
<br>
1785 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1787 <h4 class=
"parameters">Parameters
</h4>
1790 <dd class=
"description">Destination name
</dd>
1792 <dd class=
"description">File to print
</dd>
1794 <dd class=
"description">Title of job
</dd>
1795 <dt>num_options
</dt>
1796 <dd class=
"description">Number of options
</dd>
1798 <dd class=
"description">Options
</dd>
1800 <h4 class=
"returnvalue">Return Value
</h4>
1801 <p class=
"description">Job ID or
0 on error
</p>
1802 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21/Mac OS X
10.4 </span><a name=
"cupsPrintFile2">cupsPrintFile2
</a></h3>
1803 <p class=
"description">Print a file to a printer or class on the specified
1806 int cupsPrintFile2 (
<br>
1807 http_t *http,
<br>
1808 const char *name,
<br>
1809 const char *filename,
<br>
1810 const char *title,
<br>
1811 int num_options,
<br>
1812 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1814 <h4 class=
"parameters">Parameters
</h4>
1817 <dd class=
"description">Connection to server
</dd>
1819 <dd class=
"description">Destination name
</dd>
1821 <dd class=
"description">File to print
</dd>
1823 <dd class=
"description">Title of job
</dd>
1824 <dt>num_options
</dt>
1825 <dd class=
"description">Number of options
</dd>
1827 <dd class=
"description">Options
</dd>
1829 <h4 class=
"returnvalue">Return Value
</h4>
1830 <p class=
"description">Job ID or
0 on error
</p>
1831 <h3 class=
"function"><a name=
"cupsPrintFiles">cupsPrintFiles
</a></h3>
1832 <p class=
"description">Print one or more files to a printer or class on the
1835 int cupsPrintFiles (
<br>
1836 const char *name,
<br>
1837 int num_files,
<br>
1838 const char **files,
<br>
1839 const char *title,
<br>
1840 int num_options,
<br>
1841 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1843 <h4 class=
"parameters">Parameters
</h4>
1846 <dd class=
"description">Destination name
</dd>
1848 <dd class=
"description">Number of files
</dd>
1850 <dd class=
"description">File(s) to print
</dd>
1852 <dd class=
"description">Title of job
</dd>
1853 <dt>num_options
</dt>
1854 <dd class=
"description">Number of options
</dd>
1856 <dd class=
"description">Options
</dd>
1858 <h4 class=
"returnvalue">Return Value
</h4>
1859 <p class=
"description">Job ID or
0 on error
</p>
1860 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21/Mac OS X
10.4 </span><a name=
"cupsPrintFiles2">cupsPrintFiles2
</a></h3>
1861 <p class=
"description">Print one or more files to a printer or class on the
1862 specified server.
</p>
1864 int cupsPrintFiles2 (
<br>
1865 http_t *http,
<br>
1866 const char *name,
<br>
1867 int num_files,
<br>
1868 const char **files,
<br>
1869 const char *title,
<br>
1870 int num_options,
<br>
1871 <a href=
"#cups_option_t">cups_option_t
</a> *options
<br>
1873 <h4 class=
"parameters">Parameters
</h4>
1876 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1878 <dd class=
"description">Destination name
</dd>
1880 <dd class=
"description">Number of files
</dd>
1882 <dd class=
"description">File(s) to print
</dd>
1884 <dd class=
"description">Title of job
</dd>
1885 <dt>num_options
</dt>
1886 <dd class=
"description">Number of options
</dd>
1888 <dd class=
"description">Options
</dd>
1890 <h4 class=
"returnvalue">Return Value
</h4>
1891 <p class=
"description">Job ID or
0 on error
</p>
1892 <h3 class=
"function"><span class=
"info"> CUPS
1.3/Mac OS X
10.5 </span><a name=
"cupsRemoveDest">cupsRemoveDest
</a></h3>
1893 <p class=
"description">Remove a destination from the destination list.
</p>
1895 int cupsRemoveDest (
<br>
1896 const char *name,
<br>
1897 const char *instance,
<br>
1898 int num_dests,
<br>
1899 <a href=
"#cups_dest_t">cups_dest_t
</a> **dests
<br>
1901 <h4 class=
"parameters">Parameters
</h4>
1904 <dd class=
"description">Destination name
</dd>
1906 <dd class=
"description">Instance name or
<code>NULL
</code></dd>
1908 <dd class=
"description">Number of destinations
</dd>
1910 <dd class=
"description">Destinations
</dd>
1912 <h4 class=
"returnvalue">Return Value
</h4>
1913 <p class=
"description">New number of destinations
</p>
1914 <h4 class=
"discussion">Discussion
</h4>
1915 <p class=
"discussion">Removing a destination/instance does not delete the class or printer
1916 queue, merely the lpoptions for that destination/instance. Use the
1917 <a href=
"#cupsSetDests"><code>cupsSetDests
</code></a> or
<a href=
"#cupsSetDests2"><code>cupsSetDests2
</code></a> functions to save the new
1918 options for the user.
1921 <h3 class=
"function"><span class=
"info"> CUPS
1.2/Mac OS X
10.5 </span><a name=
"cupsRemoveOption">cupsRemoveOption
</a></h3>
1922 <p class=
"description">Remove an option from an option array.
</p>
1924 int cupsRemoveOption (
<br>
1925 const char *name,
<br>
1926 int num_options,
<br>
1927 <a href=
"#cups_option_t">cups_option_t
</a> **options
<br>
1929 <h4 class=
"parameters">Parameters
</h4>
1932 <dd class=
"description">Option name
</dd>
1933 <dt>num_options
</dt>
1934 <dd class=
"description">Current number of options
</dd>
1936 <dd class=
"description">Options
</dd>
1938 <h4 class=
"returnvalue">Return Value
</h4>
1939 <p class=
"description">New number of options
</p>
1940 <h3 class=
"function"><a name=
"cupsServer">cupsServer
</a></h3>
1941 <p class=
"description">Return the hostname/address of the default server.
</p>
1943 const char *cupsServer (void);
</p>
1944 <h4 class=
"returnvalue">Return Value
</h4>
1945 <p class=
"description">Server name
</p>
1946 <h4 class=
"discussion">Discussion
</h4>
1947 <p class=
"discussion">The returned value can be a fully-qualified hostname, a numeric
1948 IPv4 or IPv6 address, or a domain socket pathname.
</p>
1949 <h3 class=
"function"><span class=
"info"> CUPS
1.3/Mac OS X
10.5 </span><a name=
"cupsSetDefaultDest">cupsSetDefaultDest
</a></h3>
1950 <p class=
"description">Set the default destination.
</p>
1952 void cupsSetDefaultDest (
<br>
1953 const char *name,
<br>
1954 const char *instance,
<br>
1955 int num_dests,
<br>
1956 <a href=
"#cups_dest_t">cups_dest_t
</a> *dests
<br>
1958 <h4 class=
"parameters">Parameters
</h4>
1961 <dd class=
"description">Destination name
</dd>
1963 <dd class=
"description">Instance name or
<code>NULL
</code></dd>
1965 <dd class=
"description">Number of destinations
</dd>
1967 <dd class=
"description">Destinations
</dd>
1969 <h3 class=
"function"><a name=
"cupsSetDests">cupsSetDests
</a></h3>
1970 <p class=
"description">Save the list of destinations for the default server.
</p>
1972 void cupsSetDests (
<br>
1973 int num_dests,
<br>
1974 <a href=
"#cups_dest_t">cups_dest_t
</a> *dests
<br>
1976 <h4 class=
"parameters">Parameters
</h4>
1979 <dd class=
"description">Number of destinations
</dd>
1981 <dd class=
"description">Destinations
</dd>
1983 <h4 class=
"discussion">Discussion
</h4>
1984 <p class=
"discussion">This function saves the destinations to /etc/cups/lpoptions when run
1985 as root and ~/.cups/lpoptions when run as a normal user.
</p>
1986 <h3 class=
"function"><span class=
"info"> CUPS
1.1.21/Mac OS X
10.4 </span><a name=
"cupsSetDests2">cupsSetDests2
</a></h3>
1987 <p class=
"description">Save the list of destinations for the specified server.
</p>
1989 int cupsSetDests2 (
<br>
1990 http_t *http,
<br>
1991 int num_dests,
<br>
1992 <a href=
"#cups_dest_t">cups_dest_t
</a> *dests
<br>
1994 <h4 class=
"parameters">Parameters
</h4>
1997 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
1999 <dd class=
"description">Number of destinations
</dd>
2001 <dd class=
"description">Destinations
</dd>
2003 <h4 class=
"returnvalue">Return Value
</h4>
2004 <p class=
"description">0 on success, -
1 on error
</p>
2005 <h4 class=
"discussion">Discussion
</h4>
2006 <p class=
"discussion">This function saves the destinations to /etc/cups/lpoptions when run
2007 as root and ~/.cups/lpoptions when run as a normal user.
2010 <h3 class=
"function"><a name=
"cupsSetEncryption">cupsSetEncryption
</a></h3>
2011 <p class=
"description">Set the encryption preference.
</p>
2013 void cupsSetEncryption (
<br>
2014 http_encryption_t e
<br>
2016 <h4 class=
"parameters">Parameters
</h4>
2019 <dd class=
"description">New encryption preference
</dd>
2021 <h3 class=
"function"><a name=
"cupsSetPasswordCB">cupsSetPasswordCB
</a></h3>
2022 <p class=
"description">Set the password callback for CUPS.
</p>
2024 void cupsSetPasswordCB (
<br>
2025 <a href=
"#cups_password_cb_t">cups_password_cb_t
</a> cb
<br>
2027 <h4 class=
"parameters">Parameters
</h4>
2030 <dd class=
"description">Callback function
</dd>
2032 <h4 class=
"discussion">Discussion
</h4>
2033 <p class=
"discussion">Pass
<code>NULL
</code> to restore the default (console) password callback.
</p>
2034 <h3 class=
"function"><span class=
"info"> CUPS
1.4/Mac OS X
10.6 </span><a name=
"cupsSetPasswordCB2">cupsSetPasswordCB2
</a></h3>
2035 <p class=
"description">Set the advanced password callback for CUPS.
</p>
2037 void cupsSetPasswordCB2 (
<br>
2038 <a href=
"#cups_password_cb2_t">cups_password_cb2_t
</a> cb,
<br>
2039 void *user_data
<br>
2041 <h4 class=
"parameters">Parameters
</h4>
2044 <dd class=
"description">Callback function
</dd>
2046 <dd class=
"description">User data pointer
</dd>
2048 <h4 class=
"discussion">Discussion
</h4>
2049 <p class=
"discussion">Pass
<code>NULL
</code> to restore the default (console) password callback.
2052 <h3 class=
"function"><a name=
"cupsSetServer">cupsSetServer
</a></h3>
2053 <p class=
"description">Set the default server name.
</p>
2055 void cupsSetServer (
<br>
2056 const char *server
<br>
2058 <h4 class=
"parameters">Parameters
</h4>
2061 <dd class=
"description">Server name
</dd>
2063 <h4 class=
"discussion">Discussion
</h4>
2064 <p class=
"discussion">The
"server
" string can be a fully-qualified hostname, a numeric
2065 IPv4 or IPv6 address, or a domain socket pathname. Pass
<code>NULL
</code> to
2066 restore the default server name.
</p>
2067 <h3 class=
"function"><a name=
"cupsSetUser">cupsSetUser
</a></h3>
2068 <p class=
"description">Set the default user name.
</p>
2070 void cupsSetUser (
<br>
2071 const char *user
<br>
2073 <h4 class=
"parameters">Parameters
</h4>
2076 <dd class=
"description">User name
</dd>
2078 <h4 class=
"discussion">Discussion
</h4>
2079 <p class=
"discussion">Pass
<code>NULL
</code> to restore the default user name.
</p>
2080 <h3 class=
"function"><span class=
"info"> CUPS
1.4/Mac OS X
10.6 </span><a name=
"cupsStartDocument">cupsStartDocument
</a></h3>
2081 <p class=
"description">Add a document to a job created with cupsCreateJob().
</p>
2083 http_status_t cupsStartDocument (
<br>
2084 http_t *http,
<br>
2085 const char *name,
<br>
2086 int job_id,
<br>
2087 const char *docname,
<br>
2088 const char *format,
<br>
2089 int last_document
<br>
2091 <h4 class=
"parameters">Parameters
</h4>
2094 <dd class=
"description">Connection to server or
<code>CUPS_HTTP_DEFAULT
</code></dd>
2096 <dd class=
"description">Destination name
</dd>
2098 <dd class=
"description">Job ID from
<a href=
"#cupsCreateJob"><code>cupsCreateJob
</code></a></dd>
2100 <dd class=
"description">Name of document
</dd>
2102 <dd class=
"description">MIME type or
<code>CUPS_FORMAT_foo
</code></dd>
2103 <dt>last_document
</dt>
2104 <dd class=
"description">1 for last document in job,
0 otherwise
</dd>
2106 <h4 class=
"returnvalue">Return Value
</h4>
2107 <p class=
"description">HTTP status of request
</p>
2108 <h4 class=
"discussion">Discussion
</h4>
2109 <p class=
"discussion">Use
<a href=
"#cupsWriteRequestData"><code>cupsWriteRequestData
</code></a> to write data for the document and
2110 <a href=
"#cupsFinishDocument"><code>cupsFinishDocument
</code></a> to finish the document and get the submission status.
<br>
2112 The MIME type constants
<code>CUPS_FORMAT_AUTO
</code>,
<code>CUPS_FORMAT_PDF
</code>,
2113 <code>CUPS_FORMAT_POSTSCRIPT
</code>,
<code>CUPS_FORMAT_RAW
</code>, and
2114 <code>CUPS_FORMAT_TEXT
</code> are provided for the
"format
" argument, although
2115 any supported MIME type string can be supplied.
2118 <h3 class=
"function"><a name=
"cupsTempFd">cupsTempFd
</a></h3>
2119 <p class=
"description">Creates a temporary file.
</p>
2121 int cupsTempFd (
<br>
2122 char *filename,
<br>
2123 int len
<br>
2125 <h4 class=
"parameters">Parameters
</h4>
2128 <dd class=
"description">Pointer to buffer
</dd>
2130 <dd class=
"description">Size of buffer
</dd>
2132 <h4 class=
"returnvalue">Return Value
</h4>
2133 <p class=
"description">New file descriptor or -
1 on error
</p>
2134 <h4 class=
"discussion">Discussion
</h4>
2135 <p class=
"discussion">The temporary filename is returned in the filename buffer.
2136 The temporary file is opened for reading and writing.
</p>
2137 <h3 class=
"function"><span class=
"info"> DEPRECATED
</span><a name=
"cupsTempFile">cupsTempFile
</a></h3>
2138 <p class=
"description">Generates a temporary filename.
</p>
2140 char *cupsTempFile (
<br>
2141 char *filename,
<br>
2142 int len
<br>
2144 <h4 class=
"parameters">Parameters
</h4>
2147 <dd class=
"description">Pointer to buffer
</dd>
2149 <dd class=
"description">Size of buffer
</dd>
2151 <h4 class=
"returnvalue">Return Value
</h4>
2152 <p class=
"description">Filename or
<code>NULL
</code> on error
</p>
2153 <h4 class=
"discussion">Discussion
</h4>
2154 <p class=
"discussion">The temporary filename is returned in the filename buffer.
2155 This function is deprecated - use
<a href=
"#cupsTempFd"><code>cupsTempFd
</code></a> or
2156 <a href=
"#cupsTempFile2"><code>cupsTempFile2
</code></a> instead.
2159 <h3 class=
"function"><span class=
"info"> CUPS
1.2/Mac OS X
10.5 </span><a name=
"cupsTempFile2">cupsTempFile2
</a></h3>
2160 <p class=
"description">Creates a temporary CUPS file.
</p>
2162 cups_file_t *cupsTempFile2 (
<br>
2163 char *filename,
<br>
2164 int len
<br>
2166 <h4 class=
"parameters">Parameters
</h4>
2169 <dd class=
"description">Pointer to buffer
</dd>
2171 <dd class=
"description">Size of buffer
</dd>
2173 <h4 class=
"returnvalue">Return Value
</h4>
2174 <p class=
"description">CUPS file or
<code>NULL
</code> on error
</p>
2175 <h4 class=
"discussion">Discussion
</h4>
2176 <p class=
"discussion">The temporary filename is returned in the filename buffer.
2177 The temporary file is opened for writing.
2180 <h3 class=
"function"><a name=
"cupsUser">cupsUser
</a></h3>
2181 <p class=
"description">Return the current user's name.
</p>
2183 const char *cupsUser (void);
</p>
2184 <h4 class=
"returnvalue">Return Value
</h4>
2185 <p class=
"description">User name
</p>
2186 <h2 class=
"title"><a name=
"TYPES">Data Types
</a></h2>
2187 <h3 class=
"typedef"><a name=
"cups_dest_t">cups_dest_t
</a></h3>
2188 <p class=
"description">Destination
</p>
2190 typedef struct
<a href=
"#cups_dest_s">cups_dest_s
</a> cups_dest_t;
2192 <h3 class=
"typedef"><span class=
"info"> CUPS
1.4/Mac OS X
10.6 </span><a name=
"cups_device_cb_t">cups_device_cb_t
</a></h3>
2193 <p class=
"description">Device callback
</p>
2195 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);
2197 <h3 class=
"typedef"><a name=
"cups_job_t">cups_job_t
</a></h3>
2198 <p class=
"description">Job
</p>
2200 typedef struct
<a href=
"#cups_job_s">cups_job_s
</a> cups_job_t;
2202 <h3 class=
"typedef"><a name=
"cups_option_t">cups_option_t
</a></h3>
2203 <p class=
"description">Printer Options
</p>
2205 typedef struct
<a href=
"#cups_option_s">cups_option_s
</a> cups_option_t;
2207 <h3 class=
"typedef"><span class=
"info"> CUPS
1.4/Mac OS X
10.6 </span><a name=
"cups_password_cb2_t">cups_password_cb2_t
</a></h3>
2208 <p class=
"description">New password callback
</p>
2210 typedef const char *(*cups_password_cb2_t)(const char *prompt, http_t *http, const char *method, const char *resource, void *user_data);
2212 <h3 class=
"typedef"><a name=
"cups_password_cb_t">cups_password_cb_t
</a></h3>
2213 <p class=
"description">Password callback
</p>
2215 typedef const char *(*cups_password_cb_t)(const char *prompt);
2217 <h3 class=
"typedef"><a name=
"cups_ptype_t">cups_ptype_t
</a></h3>
2218 <p class=
"description">Printer type/capability bits
</p>
2220 typedef unsigned cups_ptype_t;
2222 <h2 class=
"title"><a name=
"STRUCTURES">Structures
</a></h2>
2223 <h3 class=
"struct"><a name=
"cups_dest_s">cups_dest_s
</a></h3>
2224 <p class=
"description">Destination
</p>
2225 <p class=
"code">struct cups_dest_s {
<br>
2226 char *name, *instance;
<br>
2227 int is_default;
<br>
2228 int num_options;
<br>
2229 <a href=
"#cups_option_t">cups_option_t
</a> *options;
<br>
2231 <h4 class=
"members">Members
</h4>
2234 <dd class=
"description">Local instance name or NULL
</dd>
2235 <dt>is_default
</dt>
2236 <dd class=
"description">Is this printer the default?
</dd>
2237 <dt>num_options
</dt>
2238 <dd class=
"description">Number of options
</dd>
2240 <dd class=
"description">Options
</dd>
2242 <h3 class=
"struct"><a name=
"cups_job_s">cups_job_s
</a></h3>
2243 <p class=
"description">Job
</p>
2244 <p class=
"code">struct cups_job_s {
<br>
2245 time_t completed_time;
<br>
2246 time_t creation_time;
<br>
2247 char *dest;
<br>
2248 char *format;
<br>
2249 int id;
<br>
2250 int priority;
<br>
2251 time_t processing_time;
<br>
2252 int size;
<br>
2253 ipp_jstate_t state;
<br>
2254 char *title;
<br>
2255 char *user;
<br>
2257 <h4 class=
"members">Members
</h4>
2259 <dt>completed_time
</dt>
2260 <dd class=
"description">Time the job was completed
</dd>
2261 <dt>creation_time
</dt>
2262 <dd class=
"description">Time the job was created
</dd>
2264 <dd class=
"description">Printer or class name
</dd>
2266 <dd class=
"description">Document format
</dd>
2268 <dd class=
"description">The job ID
</dd>
2270 <dd class=
"description">Priority (
1-
100)
</dd>
2271 <dt>processing_time
</dt>
2272 <dd class=
"description">Time the job was processed
</dd>
2274 <dd class=
"description">Size in kilobytes
</dd>
2276 <dd class=
"description">Job state
</dd>
2278 <dd class=
"description">Title/job name
</dd>
2280 <dd class=
"description">User the submitted the job
</dd>
2282 <h3 class=
"struct"><a name=
"cups_option_s">cups_option_s
</a></h3>
2283 <p class=
"description">Printer Options
</p>
2284 <p class=
"code">struct cups_option_s {
<br>
2285 char *name;
<br>
2286 char *value;
<br>
2288 <h4 class=
"members">Members
</h4>
2291 <dd class=
"description">Name of option
</dd>
2293 <dd class=
"description">Value of option
</dd>
2295 <h2 class=
"title"><a name=
"ENUMERATIONS">Constants
</a></h2>
2296 <h3 class=
"enumeration"><a name=
"cups_ptype_e">cups_ptype_e
</a></h3>
2297 <p class=
"description">Printer type/capability bit constants
</p>
2298 <h4 class=
"constants">Constants
</h4>
2300 <dt>CUPS_PRINTER_AUTHENTICATED
<span class=
"info"> CUPS
1.2/Mac OS X
10.5 </span></dt>
2301 <dd class=
"description">Printer requires authentication
</dd>
2302 <dt>CUPS_PRINTER_BIND
</dt>
2303 <dd class=
"description">Can bind output
</dd>
2304 <dt>CUPS_PRINTER_BW
</dt>
2305 <dd class=
"description">Can do B
&W printing
</dd>
2306 <dt>CUPS_PRINTER_CLASS
</dt>
2307 <dd class=
"description">Printer class
</dd>
2308 <dt>CUPS_PRINTER_COLLATE
</dt>
2309 <dd class=
"description">Can collage copies
</dd>
2310 <dt>CUPS_PRINTER_COLOR
</dt>
2311 <dd class=
"description">Can do color printing
</dd>
2312 <dt>CUPS_PRINTER_COMMANDS
<span class=
"info"> CUPS
1.2/Mac OS X
10.5 </span></dt>
2313 <dd class=
"description">Printer supports maintenance commands
</dd>
2314 <dt>CUPS_PRINTER_COPIES
</dt>
2315 <dd class=
"description">Can do copies
</dd>
2316 <dt>CUPS_PRINTER_COVER
</dt>
2317 <dd class=
"description">Can cover output
</dd>
2318 <dt>CUPS_PRINTER_DEFAULT
</dt>
2319 <dd class=
"description">Default printer on network
</dd>
2320 <dt>CUPS_PRINTER_DELETE
<span class=
"info"> CUPS
1.2/Mac OS X
10.5 </span></dt>
2321 <dd class=
"description">Delete printer
</dd>
2322 <dt>CUPS_PRINTER_DISCOVERED
<span class=
"info"> CUPS
1.3/Mac OS X
10.5 </span></dt>
2323 <dd class=
"description">Printer was automatically discovered and added
</dd>
2324 <dt>CUPS_PRINTER_DUPLEX
</dt>
2325 <dd class=
"description">Can do duplexing
</dd>
2326 <dt>CUPS_PRINTER_FAX
</dt>
2327 <dd class=
"description">Fax queue
</dd>
2328 <dt>CUPS_PRINTER_IMPLICIT
</dt>
2329 <dd class=
"description">Implicit class
</dd>
2330 <dt>CUPS_PRINTER_LARGE
</dt>
2331 <dd class=
"description">Can do D/E/A1/A0
</dd>
2332 <dt>CUPS_PRINTER_LOCAL
</dt>
2333 <dd class=
"description">Local printer or class
</dd>
2334 <dt>CUPS_PRINTER_MEDIUM
</dt>
2335 <dd class=
"description">Can do Tabloid/B/C/A3/A2
</dd>
2336 <dt>CUPS_PRINTER_MFP
<span class=
"info"> CUPS
1.4/Mac OS X
10.6 </span></dt>
2337 <dd class=
"description">Printer with scanning capabilities
</dd>
2338 <dt>CUPS_PRINTER_NOT_SHARED
<span class=
"info"> CUPS
1.2/Mac OS X
10.5 </span></dt>
2339 <dd class=
"description">Printer is not shared
</dd>
2340 <dt>CUPS_PRINTER_PUNCH
</dt>
2341 <dd class=
"description">Can punch output
</dd>
2342 <dt>CUPS_PRINTER_REJECTING
</dt>
2343 <dd class=
"description">Printer is rejecting jobs
</dd>
2344 <dt>CUPS_PRINTER_REMOTE
</dt>
2345 <dd class=
"description">Remote printer or class
</dd>
2346 <dt>CUPS_PRINTER_SCANNER
<span class=
"info"> CUPS
1.4/Mac OS X
10.6 </span></dt>
2347 <dd class=
"description">Scanner-only device
</dd>
2348 <dt>CUPS_PRINTER_SMALL
</dt>
2349 <dd class=
"description">Can do Letter/Legal/A4
</dd>
2350 <dt>CUPS_PRINTER_SORT
</dt>
2351 <dd class=
"description">Can sort output
</dd>
2352 <dt>CUPS_PRINTER_STAPLE
</dt>
2353 <dd class=
"description">Can staple output
</dd>
2354 <dt>CUPS_PRINTER_VARIABLE
</dt>
2355 <dd class=
"description">Can do variable sizes
</dd>