1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
3 <!-- SECTION: Programming -->
5 <title>Filter and Backend Programming
</title>
6 <meta name=
"keywords" content=
"Programming">
7 <meta http-equiv=
"Content-Type" content=
"text/html;charset=utf-8">
8 <meta name=
"creator" content=
"Mini-XML v2.7">
9 <style type=
"text/css"><!--
11 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
14 H1, H2, H3, H4, H5, H6, P, TD, TH {
15 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
19 font-family: monaco, courier, monospace;
24 font-family: monaco, courier, monospace;
28 border: dotted thin #7f7f7f;
44 border: dotted thin #999999;
49 PRE.command EM, PRE.example EM {
50 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
54 font-family: monaco, courier, monospace;
65 border: solid thin #999999;
76 -moz-border-radius: 10px;
81 text-decoration: none;
84 A:link:hover, A:visited:hover, A:active {
85 text-decoration: underline;
92 TR.data, TD.data, TR.data TD {
95 border-bottom: solid 1pt #999999;
99 border-bottom: solid 1pt #999999;
106 border: solid thin #999999;
107 border-collapse: collapse;
123 border: solid thin #cccccc;
130 border-bottom: solid thin #999999;
139 caption-side: bottom;
163 border: thin solid black;
171 H2 SPAN.info, H3 SPAN.info, H4 SPAN.info {
180 border-bottom: solid 2pt #000000;
183 DIV.indent, TABLE.indent {
191 border-collapse: collapse;
194 TABLE.indent TD, TABLE.indent TH {
199 border-collapse: collapse;
207 border-bottom: solid thin #cccccc;
212 vertical-align: bottom;
221 border-bottom: solid thin #eeeeee;
226 TABLE.list TR:nth-child(even) {
230 TABLE.list TR:nth-child(odd) {
249 font-family: monaco, courier, monospace;
253 border: solid thin #999999;
254 border-collapse: collapse;
259 DIV.summary TABLE TD, DIV.summary TABLE TH {
260 border: solid thin #999999;
266 DIV.summary TABLE THEAD TH {
270 /* API documentation styles... */
277 div.body h3, div.body h4, div.body h5 {
278 margin-bottom: 0.5em;
281 .class, .enumeration, .function, .struct, .typedef, .union {
282 border-bottom: solid thin #999999;
289 code, p.code, pre, ul.code li {
290 font-family: monaco, courier, monospace;
293 ul.code, ul.contents, ul.subcontents {
294 list-style-type: none;
304 ul.contents li ul.code, ul.contents li ul.subcontents {
317 margin-bottom: 0.5em;
320 /* This is just for the HTML files generated with the framedhelp target */
323 border: solid thin black;
332 div.contents ul.contents {
335 div.contents ul.subcontents li {
344 "$Id: api-filter.header 7616 2008-05-28 00:34:13Z mike $"
346 Filter and backend programming header for CUPS.
348 Copyright 2008-2011 by Apple Inc.
350 These coded instructions, statements, and computer programs are the
351 property of Apple Inc. and are protected by Federal copyright
352 law. Distribution and use rights are outlined in the file "LICENSE.txt"
353 which should have been included with this file. If this file is
354 file is missing or damaged, see the license at "http://www.cups.org/".
357 <h1 class='title'
>Filter and Backend Programming
</h1>
359 <div class='summary'
><table summary='General Information'
>
363 <th>cups/backend.h
<br>
364 cups/sidechannel.h
</th>
374 <td>Programming:
<a href='api-overview.html' target='_top'
>Introduction to CUPS Programming
</a><br>
375 Programming:
<a href='api-cups.html' target='_top'
>CUPS API
</a><br>
376 Programming:
<a href='api-ppd.html' target='_top'
>PPD API
</a><br>
377 Programming:
<a href='api-raster.html' target='_top'
>Raster API
</a><br>
378 Programming:
<a href='postscript-driver.html' target='_top'
>Developing PostScript Printer Drivers
</a><br>
379 Programming:
<a href='raster-driver.html' target='_top'
>Developing Raster Printer Drivers
</a><br>
380 Specifications:
<a href='spec-design.html' target='_top'
>CUPS Design Description
</a></td>
384 <h2 class=
"title">Contents
</h2>
385 <ul class=
"contents">
386 <li><a href=
"#OVERVIEW">Overview
</a><ul class=
"subcontents">
387 <li><a href=
"#SECURITY">Security Considerations
</a></li>
388 <li><a href=
"#SIGNALS">Canceled Jobs and Signal Handling
</a></li>
389 <li><a href=
"#PERMISSIONS">File Permissions
</a></li>
390 <li><a href=
"#TEMPFILES">Temporary Files
</a></li>
391 <li><a href=
"#COPIES">Copy Generation
</a></li>
392 <li><a href=
"#EXITCODES">Exit Codes
</a></li>
393 <li><a href=
"#ENVIRONMENT">Environment Variables
</a></li>
394 <li><a href=
"#MESSAGES">Communicating with the Scheduler
</a></li>
395 <li><a href=
"#COMMUNICATING_BACKEND">Communicating with the Backend
</a></li>
396 <li><a href=
"#COMMUNICATING_FILTER">Communicating with Filters
</a></li>
397 <li><a href=
"#SNMP">Doing SNMP Queries with Network Printers
</a></li>
399 <li><a href=
"#FUNCTIONS">Functions
</a><ul class=
"code">
400 <li><a href=
"#cupsBackChannelRead" title=
"Read data from the backchannel.">cupsBackChannelRead
</a></li>
401 <li><a href=
"#cupsBackChannelWrite" title=
"Write data to the backchannel.">cupsBackChannelWrite
</a></li>
402 <li><a href=
"#cupsBackendDeviceURI" title=
"Get the device URI for a backend.">cupsBackendDeviceURI
</a></li>
403 <li><a href=
"#cupsBackendReport" title=
"Write a device line from a backend.">cupsBackendReport
</a></li>
404 <li><a href=
"#cupsSideChannelDoRequest" title=
"Send a side-channel command to a backend and wait for a response.">cupsSideChannelDoRequest
</a></li>
405 <li><a href=
"#cupsSideChannelRead" title=
"Read a side-channel message.">cupsSideChannelRead
</a></li>
406 <li><a href=
"#cupsSideChannelSNMPGet" title=
"Query a SNMP OID's value.">cupsSideChannelSNMPGet
</a></li>
407 <li><a href=
"#cupsSideChannelSNMPWalk" title=
"Query multiple SNMP OID values.">cupsSideChannelSNMPWalk
</a></li>
408 <li><a href=
"#cupsSideChannelWrite" title=
"Write a side-channel message.">cupsSideChannelWrite
</a></li>
410 <li><a href=
"#TYPES">Data Types
</a><ul class=
"code">
411 <li><a href=
"#cups_backend_t" title=
"Backend exit codes">cups_backend_t
</a></li>
412 <li><a href=
"#cups_sc_bidi_t" title=
"Bidirectional capabilities">cups_sc_bidi_t
</a></li>
413 <li><a href=
"#cups_sc_command_t" title=
"Request command codes">cups_sc_command_t
</a></li>
414 <li><a href=
"#cups_sc_connected_t" title=
"Connectivity values">cups_sc_connected_t
</a></li>
415 <li><a href=
"#cups_sc_state_t" title=
"Printer state bits">cups_sc_state_t
</a></li>
416 <li><a href=
"#cups_sc_status_t" title=
"Response status codes">cups_sc_status_t
</a></li>
417 <li><a href=
"#cups_sc_walk_func_t" title=
"SNMP walk callback">cups_sc_walk_func_t
</a></li>
419 <li><a href=
"#ENUMERATIONS">Constants
</a><ul class=
"code">
420 <li><a href=
"#cups_backend_e" title=
"Backend exit codes">cups_backend_e
</a></li>
421 <li><a href=
"#cups_sc_bidi_e" title=
"Bidirectional capability values">cups_sc_bidi_e
</a></li>
422 <li><a href=
"#cups_sc_command_e" title=
"Request command codes">cups_sc_command_e
</a></li>
423 <li><a href=
"#cups_sc_connected_e" title=
"Connectivity values">cups_sc_connected_e
</a></li>
424 <li><a href=
"#cups_sc_state_e" title=
"Printer state bits">cups_sc_state_e
</a></li>
425 <li><a href=
"#cups_sc_status_e" title=
"Response status codes">cups_sc_status_e
</a></li>
429 "$Id: api-filter.shtml 7677 2008-06-19 23:22:19Z mike $"
431 Filter and backend programming introduction for CUPS.
433 Copyright 2007-2013 by Apple Inc.
434 Copyright 1997-2006 by Easy Software Products, all rights reserved.
436 These coded instructions, statements, and computer programs are the
437 property of Apple Inc. and are protected by Federal copyright
438 law. Distribution and use rights are outlined in the file "LICENSE.txt"
439 which should have been included with this file. If this file is
440 file is missing or damaged, see the license at "http://www.cups.org/".
443 <h2 class='title'
><a name=
"OVERVIEW">Overview
</a></h2>
445 <p>Filters (which include printer drivers and port monitors) and backends
446 are used to convert job files to a printable format and send that data to the
447 printer itself. All of these programs use a common interface for processing
448 print jobs and communicating status information to the scheduler. Each is run
449 with a standard set of command-line arguments:
<p>
457 <dd>The user printing the job
</dd>
460 <dd>The job name/title
</dd>
463 <dd>The number of copies to print
</dd>
466 <dd>The options that were provided when the job was submitted
</dd>
469 <dd>The file to print (first program only)
</dd>
472 <p>The scheduler runs one or more of these programs to print any given job. The
473 first filter reads from the print file and writes to the standard output, while
474 the remaining filters read from the standard input and write to the standard
475 output. The backend is the last filter in the chain and writes to the
478 <p>Filters are always run as a non-privileged user, typically
"lp", with no
479 connection to the user's desktop. Backends are run either as a non-privileged
480 user or as root if the file permissions do not allow user or group execution.
481 The
<a href=
"#PERMISSIONS">file permissions
</a> section talks about this in
484 <h3><a name=
"SECURITY">Security Considerations
</a></h3>
486 <p>It is always important to use security programming practices. Filters and
487 most backends are run as a non-privileged user, so the major security
488 consideration is resource utilization - filters should not depend on unlimited
489 amounts of CPU, memory, or disk space, and should protect against conditions
490 that could lead to excess usage of any resource like infinite loops and
491 unbounded recursion. In addition, filters must
<em>never
</em> allow the user to
492 specify an arbitrary file path to a separator page, template, or other file
493 used by the filter since that can lead to an unauthorized disclosure of
494 information.
<em>Always
</em> treat input as suspect and validate it!
</p>
496 <p>If you are developing a backend that runs as root, make sure to check for
497 potential buffer overflows, integer under/overflow conditions, and file
498 accesses since these can lead to privilege escalations. When writing files,
499 always validate the file path and
<em>never
</em> allow a user to determine
500 where to store a file.
</p>
502 <blockquote><b>Note:
</b>
504 <p><em>Never
</em> write files to a user's home directory. Aside from the
505 security implications, CUPS is a network print service and as such the network
506 user may not be the same as the local user and/or there may not be a local home
507 directory to write to.
</p>
509 <p>In addition, some operating systems provide additional security mechanisms
510 that further limit file system access, even for backends running as root. On
511 OS X, for example, no backend may write to a user's home directory.
</p>
514 <h3><a name=
"SIGNALS">Canceled Jobs and Signal Handling
</a></h3>
516 <p>The scheduler sends
<code>SIGTERM
</code> when a printing job is canceled or
517 held. Filters, backends, and port monitors
<em>must
</em> catch
518 <code>SIGTERM
</code> and perform any cleanup necessary to produce a valid output
519 file or return the printer to a known good state. The recommended behavior is to
520 end the output on the current page, preferably on the current line or object
523 <p>Filters and backends may also receive
<code>SIGPIPE
</code> when an upstream or downstream filter/backend exits with a non-zero status. Developers should generally ignore
<code>SIGPIPE
</code> at the beginning of
<code>main()
</code> with the following function call:
</p>
525 <pre class=
"example">
526 #include
<signal.h
>>
531 main(int argc, char *argv[])
533 signal(SIGPIPE, SIG_IGN);
539 <h3><a name=
"PERMISSIONS">File Permissions
</a></h3>
541 <p>For security reasons, CUPS will only run filters and backends that are owned
542 by root and do not have world or group write permissions. The recommended
543 permissions for filters and backends are
0555 - read and execute but no write.
544 Backends that must run as root should use permissions of
0500 - read and execute
545 by root, no access for other users. Write permissions can be enabled for the
548 <p>To avoid a warning message, the directory containing your filter(s) must also
549 be owned by root and have world and group write disabled - permissions of
0755
550 or
0555 are strongly encouraged.
</p>
552 <h3><a name=
"TEMPFILES">Temporary Files
</a></h3>
554 <p>Temporary files should be created in the directory specified by the
555 "TMPDIR" environment variable. The
556 <a href=
"#cupsTempFile2"><code>cupsTempFile2
</code></a> function can be
557 used to safely create temporary files in this directory.
</p>
559 <h3><a name=
"COPIES">Copy Generation
</a></h3>
561 <p>The
<code>argv[
4]
</code> argument specifies the number of copies to produce
562 of the input file. In general, you should only generate copies if the
563 <em>filename
</em> argument is supplied. The only exception to this are
564 filters that produce device-independent PostScript output, since the PostScript
565 filter
<var>pstops
</var> is responsible for generating copies of PostScript
568 <h3><a name=
"EXITCODES">Exit Codes
</a></h3>
570 <p>Filters must exit with status
0 when they successfully generate print data
571 or
1 when they encounter an error. Backends can return any of the
572 <a href=
"#cups_backend_t"><code>cups_backend_t
</code></a> constants.
</p>
574 <h3><a name=
"ENVIRONMENT">Environment Variables
</a></h3>
576 <p>The following environment variables are defined by the printing system
577 when running print filters and backends:
</p>
581 <dt>APPLE_LANGUAGE
</dt>
582 <dd>The Apple language identifier associated with the job
586 <dd>The job character set, typically
"utf-8".
</dd>
589 <dd>When a job is submitted to a printer class, contains the name of
590 the destination printer class. Otherwise this environment
591 variable will not be set.
</dd>
593 <dt>CONTENT_TYPE
</dt>
594 <dd>The MIME type associated with the file (e.g.
595 application/postscript).
</dd>
597 <dt>CUPS_CACHEDIR
</dt>
598 <dd>The directory where cache files can be stored. Cache files can be
599 used to retain information between jobs or files in a job.
</dd>
601 <dt>CUPS_DATADIR
</dt>
602 <dd>The directory where (read-only) CUPS data files can be found.
</dd>
604 <dt>CUPS_FILETYPE
</dt>
605 <dd>The type of file being printed:
"job-sheet" for a banner page and
606 "document" for a regular print file.
</dd>
608 <dt>CUPS_SERVERROOT
</dt>
609 <dd>The root directory of the server.
</dd>
612 <dd>The device-uri associated with the printer.
</dd>
614 <dt>FINAL_CONTENT_TYPE
</dt>
615 <dd>The MIME type associated with the printer (e.g.
616 application/vnd.cups-postscript).
</dd>
619 <dd>The language locale associated with the job.
</dd>
622 <dd>The full pathname of the PostScript Printer Description (PPD)
623 file for this printer.
</dd>
626 <dd>The queue name of the class or printer.
</dd>
629 <dd>The recommended amount of memory to use for Raster Image
630 Processors (RIPs).
</dd>
633 <dd>The directory where temporary files should be created.
</dd>
637 <h3><a name=
"MESSAGES">Communicating with the Scheduler
</a></h3>
639 <p>Filters and backends communicate with the scheduler by writing messages
640 to the standard error file. The scheduler reads messages from all filters in
641 a job and processes the message based on its prefix. For example, the following
642 code sets the current printer state message to
"Printing page 5":
</p>
644 <pre class=
"example">
647 fprintf(stderr,
"INFO: Printing page %d\n", page);
650 <p>Each message is a single line of text starting with one of the following
655 <dt>ALERT: message
</dt>
656 <dd>Sets the printer-state-message attribute and adds the specified
657 message to the current error log file using the
"alert" log level.
</dd>
659 <dt>ATTR: attribute=value [attribute=value]
</dt>
660 <dd>Sets the named printer or job attribute(s). Typically this is used
661 to set the
<code>marker-colors
</code>,
<code>marker-high-levels
</code>,
662 <code>marker-levels
</code>,
<code>marker-low-levels
</code>,
663 <code>marker-message
</code>,
<code>marker-names
</code>,
664 <code>marker-types
</code>,
<code>printer-alert
</code>, and
665 <code>printer-alert-description
</code> printer attributes. Standard
666 <code>marker-types
</code> values are listed in
<a href='#TABLE1'
>Table
669 <dt>CRIT: message
</dt>
670 <dd>Sets the printer-state-message attribute and adds the specified
671 message to the current error log file using the
"critical" log
674 <dt>DEBUG: message
</dt>
675 <dd>Sets the printer-state-message attribute and adds the specified
676 message to the current error log file using the
"debug" log level.
</dd>
678 <dt>DEBUG2: message
</dt>
679 <dd>Sets the printer-state-message attribute and adds the specified
680 message to the current error log file using the
"debug2" log level.
</dd>
682 <dt>EMERG: message
</dt>
683 <dd>Sets the printer-state-message attribute and adds the specified
684 message to the current error log file using the
"emergency" log
687 <dt>ERROR: message
</dt>
688 <dd>Sets the printer-state-message attribute and adds the specified
689 message to the current error log file using the
"error" log level.
690 Use
"ERROR:" messages for non-persistent processing errors.
</dd>
692 <dt>INFO: message
</dt>
693 <dd>Sets the printer-state-message attribute. If the current log level
694 is set to
"debug2", also adds the specified message to the current error
695 log file using the
"info" log level.
</dd>
697 <dt>NOTICE: message
</dt>
698 <dd>Sets the printer-state-message attribute and adds the specified
699 message to the current error log file using the
"notice" log level.
</dd>
701 <dt>PAGE: page-number #-copies
</dt>
702 <dt>PAGE: total #-pages
</dt>
703 <dd>Adds an entry to the current page log file. The first form adds
704 #-copies to the job-media-sheets-completed attribute. The second
705 form sets the job-media-sheets-completed attribute to #-pages.
</dd>
707 <dt>PPD: keyword=value [keyword=value ...]
</dt>
708 <dd>Changes or adds keywords to the printer's PPD file. Typically
709 this is used to update installable options or default media settings
710 based on the printer configuration.
</dd>
712 <dt>STATE: + printer-state-reason [printer-state-reason ...]
</dt>
713 <dt>STATE: - printer-state-reason [printer-state-reason ...]
</dt>
714 <dd>Sets or clears printer-state-reason keywords for the current queue.
715 Typically this is used to indicate persistent media, ink, toner, and
716 configuration conditions or errors on a printer.
717 <a href='#TABLE2'
>Table
2</a> lists the standard state keywords -
718 use vendor-prefixed (
"com.example.foo") keywords for custom states. See
719 <a href=
"#MANAGING_STATE">Managing Printer State in a Filter
</a> for more
722 <dt>WARNING: message
</dt>
723 <dd>Sets the printer-state-message attribute and adds the specified
724 message to the current error log file using the
"warning" log
729 <p>Messages without one of these prefixes are treated as if they began with
730 the
"DEBUG:" prefix string.
</p>
732 <div class='table'
><table width='
80%' summary='Table
1: Standard marker-types Values'
>
733 <caption>Table
1:
<a name='TABLE1'
>Standard marker-types Values
</a></caption>
743 <td>Developer unit
</td>
750 <td>fuserCleaningPad
</td>
751 <td>Fuser cleaning pad
</td>
763 <td>Photo conductor
</td>
771 <td>Staple supply
</td>
775 <td>Toner supply
</td>
778 <td>transferUnit
</td>
779 <td>Transfer unit
</td>
783 <td>Waste ink tank
</td>
787 <td>Waste toner tank
</td>
791 <td>Waste wax tank
</td>
798 <div class='table'
><table width='
80%' summary='Table
2: Standard State Keywords'
>
799 <caption>Table
2:
<a name='TABLE2'
>Standard State Keywords
</a></caption>
808 <td>connecting-to-device
</td>
809 <td>Connecting to printer but not printing yet.
</td>
813 <td>The printer's cover is open.
</td>
816 <td>input-tray-missing
</td>
817 <td>The paper tray is missing.
</td>
820 <td>marker-supply-empty
</td>
821 <td>The printer is out of ink.
</td>
824 <td>marker-supply-low
</td>
825 <td>The printer is almost out of ink.
</td>
828 <td>marker-waste-almost-full
</td>
829 <td>The printer's waste bin is almost full.
</td>
832 <td>marker-waste-full
</td>
833 <td>The printer's waste bin is full.
</td>
837 <td>The paper tray (any paper tray) is empty.
</td>
841 <td>There is a paper jam.
</td>
845 <td>The paper tray (any paper tray) is almost empty.
</td>
848 <td>media-needed
</td>
849 <td>The paper tray needs to be filled (for a job that is printing).
</td>
853 <td>Stop the printer.
</td>
857 <td>Unable to connect to printer.
</td>
861 <td>The printer is out of toner.
</td>
865 <td>The printer is low on toner.
</td>
870 <h4><a name=
"MANAGING_STATE">Managing Printer State in a Filter
</a></h4>
872 <p>Filters are responsible for managing the state keywords they set using
873 "STATE:" messages. Typically you will update
<em>all
</em> of the keywords that
874 are used by the filter at startup, for example:
</p>
876 <pre class=
"example">
877 if (foo_condition !=
0)
878 fputs(
"STATE: +com.example.foo\n", stderr);
880 fputs(
"STATE: -com.example.foo\n", stderr);
882 if (bar_condition !=
0)
883 fputs(
"STATE: +com.example.bar\n", stderr);
885 fputs(
"STATE: -com.example.bar\n", stderr);
888 <p>Then as conditions change, your filter sends
"STATE: +keyword" or
"STATE:
889 -keyword" messages as necessary to set or clear the corresponding keyword,
892 <p>State keywords are often used to notify the user of issues that span across
893 jobs, for example
"media-empty-warning" that indicates one or more paper trays
894 are empty. These keywords should not be cleared unless the corresponding issue
895 no longer exists.
</p>
897 <p>Filters should clear job-related keywords on startup and exit so that they
898 do not remain set between jobs. For example,
"connecting-to-device" is a job
899 sub-state and not an issue that applies when a job is not printing.
</p>
901 <blockquote><b>Note:
</b>
903 <p>"STATE:" messages often provide visible alerts to the user. For example,
904 on OS X setting a printer-state-reason value with an
"-error" or
905 "-warning" suffix will cause the printer's dock item to bounce if the
906 corresponding reason is localized with a cupsIPPReason keyword in the
907 printer's PPD file.
</p>
909 <p>When providing a vendor-prefixed keyword,
<em>always
</em> provide the
910 corresponding standard keyword (if any) to allow clients to respond to the
911 condition correctly. For example, if you provide a vendor-prefixed keyword
912 for a low cyan ink condition (
"com.example.cyan-ink-low") you must also set the
913 "marker-supply-low-warning" keyword. In such cases you should also refrain
914 from localizing the vendor-prefixed keyword in the PPD file - otherwise both
915 the generic and vendor-specific keyword will be shown in the user
920 <h4><a name=
"REPORTING_SUPPLIES">Reporting Supply Levels
</a></h4>
922 <p>CUPS tracks several
"marker-*" attributes for ink/toner supply level
923 reporting. These attributes allow applications to display the current supply
924 levels for a printer without printer-specific software.
<a href=
"#TABLE3">Table
3</a> lists the marker attributes and what they represent.
</p>
926 <p>Filters set marker attributes by sending
"ATTR:" messages to stderr. For
927 example, a filter supporting an inkjet printer with black and tri-color ink
928 cartridges would use the following to initialize the supply attributes:
</p>
930 <pre class=
"example">
931 fputs(
"ATTR: marker-colors=#000000,#00FFFF#FF00FF#FFFF00\n", stderr);
932 fputs(
"ATTR: marker-low-levels=5,10\n", stderr);
933 fputs(
"ATTR: marker-names=Black,Tri-Color\n", stderr);
934 fputs(
"ATTR: marker-types=ink,ink\n", stderr);
937 <p>Then periodically the filter queries the printer for its current supply
938 levels and updates them with a separate
"ATTR:" message:
</p>
940 <pre class=
"example">
941 int black_level, tri_level;
943 fprintf(stderr,
"ATTR: marker-levels=%d,%d\n", black_level, tri_level);
946 <div class='table'
><table width='
80%' summary='Table
3: Supply Level Attributes'
>
947 <caption>Table
3:
<a name='TABLE3'
>Supply Level Attributes
</a></caption>
956 <td>marker-colors
</td>
957 <td>A list of comma-separated colors; each color is either
"none" or one or
958 more hex-encoded sRGB colors of the form
"#RRGGBB".
</td>
961 <td>marker-high-levels
</td>
962 <td>A list of comma-separated
"almost full" level values from
0 to
100; a
963 value of
100 should be used for supplies that are consumed/emptied like ink
967 <td>marker-levels
</td>
968 <td>A list of comma-separated level values for each supply. A value of -
1
969 indicates the level is unavailable, -
2 indicates unknown, and -
3 indicates
970 the level is unknown but has not yet reached capacity. Values from
0 to
100
971 indicate the corresponding percentage.
</td>
974 <td>marker-low-levels
</td>
975 <td>A list of comma-separated
"almost empty" level values from
0 to
100; a
976 value of
0 should be used for supplies that are filled like waste ink
980 <td>marker-message
</td>
981 <td>A human-readable supply status message for the user like
"12 pages of
985 <td>marker-names
</td>
986 <td>A list of comma-separated supply names like
"Cyan Ink",
"Fuser",
990 <td>marker-types
</td>
991 <td>A list of comma-separated supply types; the types are listed in
992 <a href=
"#TABLE1">Table
1</a>.
</td>
997 <h3><a name=
"COMMUNICATING_BACKEND">Communicating with the Backend
</a></h3>
999 <p>Filters can communicate with the backend via the
1000 <a href=
"#cupsBackChannelRead"><code>cupsBackChannelRead
</code></a> and
1001 <a href=
"#cupsSideChannelDoRequest"><code>cupsSideChannelDoRequest
</code></a>
1003 <a href=
"#cupsBackChannelRead"><code>cupsBackChannelRead
</code></a> function
1004 reads data that has been sent back from the device and is typically used to
1005 obtain status and configuration information. For example, the following code
1006 polls the backend for back-channel data:
</p>
1008 <pre class=
"example">
1009 #include
<cups/cups.h
>
1014 /* Use a timeout of
0.0 seconds to poll for back-channel data */
1015 bytes = cupsBackChannelRead(buffer, sizeof(buffer),
0.0);
1018 <p>Filters can also use
<code>select()
</code> or
<code>poll()
</code> on the
1019 back-channel file descriptor (
3 or
<code>CUPS_BC_FD
</code>) to read data only
1020 when it is available.
</p>
1023 <a href=
"#cupsSideChannelDoRequest"><code>cupsSideChannelDoRequest
</code></a>
1024 function allows you to get out-of-band status information and do synchronization
1025 with the device. For example, the following code gets the current IEEE-
1284
1026 device ID string from the backend:
</p>
1028 <pre class=
"example">
1029 #include
<cups/sidechannel.h
>
1033 <a href=
"#cups_sc_status_t">cups_sc_status_t
</a> status;
1035 /* Tell cupsSideChannelDoRequest() how big our buffer is, less
1 byte for
1036 nul-termination... */
1037 datalen = sizeof(data) -
1;
1039 /* Get the IEEE-
1284 device ID, waiting for up to
1 second */
1040 status =
<a href=
"#cupsSideChannelDoRequest">cupsSideChannelDoRequest
</a>(CUPS_SC_CMD_GET_DEVICE_ID, data,
&datalen,
1.0);
1042 /* Use the returned value if OK was returned and the length is non-zero */
1043 if (status == CUPS_SC_STATUS_OK
&& datalen
> 0)
1044 data[datalen] = '\
0';
1049 <h4><a name=
"DRAIN_OUTPUT">Forcing All Output to a Printer
</a></h4>
1052 <a href=
"#cupsSideChannelDoRequest"><code>cupsSideChannelDoRequest
</code></a>
1053 function allows you to tell the backend to send all pending data to the printer.
1054 This is most often needed when sending query commands to the printer. For example:
</p>
1056 <pre class=
"example">
1057 #include
<cups/cups.h
>
1058 #include
<cups/sidechannel.h
>
1061 int datalen = sizeof(data);
1062 <a href=
"#cups_sc_status_t">cups_sc_status_t
</a> status;
1064 /* Flush pending output to stdout */
1067 /* Drain output to backend, waiting for up to
30 seconds */
1068 status =
<a href=
"#cupsSideChannelDoRequest">cupsSideChannelDoRequest
</a>(CUPS_SC_CMD_DRAIN_OUTPUT, data,
&datalen,
30.0);
1070 /* Read the response if the output was sent */
1071 if (status == CUPS_SC_STATUS_OK)
1075 /* Wait up to
10.0 seconds for back-channel data */
1076 bytes = cupsBackChannelRead(data, sizeof(data),
10.0);
1077 /* do something with the data from the printer */
1081 <h3><a name=
"COMMUNICATING_FILTER">Communicating with Filters
</a></h3>
1083 <p>Backends communicate with filters using the reciprocal functions
1084 <a href=
"#cupsBackChannelWrite"><code>cupsBackChannelWrite
</code></a>,
1085 <a href=
"#cupsSideChannelRead"><code>cupsSideChannelRead
</code></a>, and
1086 <a href=
"#cupsSideChannelWrite"><code>cupsSideChannelWrite
</code></a>. We
1087 recommend writing back-channel data using a timeout of
1.0 seconds:
</p>
1089 <pre class=
"example">
1090 #include
<cups/cups.h
>
1095 /* Obtain data from printer/device */
1098 /* Use a timeout of
1.0 seconds to give filters a chance to read */
1099 cupsBackChannelWrite(buffer, bytes,
1.0);
1102 <p>The
<a href=
"#cupsSideChannelRead"><code>cupsSideChannelRead
</code></a>
1103 function reads a side-channel command from a filter, driver, or port monitor.
1104 Backends can either poll for commands using a
<code>timeout
</code> of
0.0, wait
1105 indefinitely for commands using a
<code>timeout
</code> of -
1.0 (probably in a
1106 separate thread for that purpose), or use
<code>select
</code> or
1107 <code>poll
</code> on the
<code>CUPS_SC_FD
</code> file descriptor (
4) to handle
1108 input and output on several file descriptors at the same time.
</p>
1110 <p>Once a command is processed, the backend uses the
1111 <a href=
"#cupsSideChannelWrite"><code>cupsSideChannelWrite
</code></a> function
1112 to send its response. For example, the following code shows how to poll for a
1113 side-channel command and respond to it:
</p>
1115 <pre class=
"example">
1116 #include
<cups/sidechannel.h
>
1118 <a href=
"#cups_sc_command_t">cups_sc_command_t
</a> command;
1119 <a href=
"#cups_sc_status_t">cups_sc_status_t
</a> status;
1121 int datalen = sizeof(data);
1123 /* Poll for a command... */
1124 if (!
<a href=
"#cupsSideChannelRead">cupsSideChannelRead
</a>(
&command,
&status, data,
&datalen,
0.0))
1128 /* handle supported commands, fill data/datalen/status with values as needed */
1131 status = CUPS_SC_STATUS_NOT_IMPLEMENTED;
1136 /* Send a response... */
1137 <a href=
"#cupsSideChannelWrite">cupsSideChannelWrite
</a>(command, status, data, datalen,
1.0);
1141 <h3><a name=
"SNMP">Doing SNMP Queries with Network Printers
</a></h3>
1143 <p>The Simple Network Management Protocol (SNMP) allows you to get the current
1144 status, page counter, and supply levels from most network printers. Every
1145 piece of information is associated with an Object Identifier (OID), and
1146 every printer has a
<em>community
</em> name associated with it. OIDs can be
1147 queried directly or by
"walking" over a range of OIDs with a common prefix.
</p>
1149 <p>The two CUPS SNMP functions provide a simple API for querying network
1150 printers through the side-channel interface. Each accepts a string containing
1151 an OID like
".1.3.6.1.2.1.43.10.2.1.4.1.1" (the standard page counter OID)
1152 along with a timeout for the query.
</p>
1154 <p>The
<a href=
"#cupsSideChannelSNMPGet"><code>cupsSideChannelSNMPGet
</code></a>
1155 function queries a single OID and returns the value as a string in a buffer
1158 <pre class=
"example">
1159 #include
<cups/sidechannel.h
>
1162 int datalen = sizeof(data);
1164 if (
<a href=
"#cupsSideChannelSNMPGet">cupsSideChannelSNMPGet
</a>(
".1.3.6.1.2.1.43.10.2.1.4.1.1", data,
&datalen,
5.0)
1165 == CUPS_SC_STATUS_OK)
1167 /* Do something with the value */
1168 printf(
"Page counter is: %s\n", data);
1173 <a href=
"#cupsSideChannelSNMPWalk"><code>cupsSideChannelSNMPWalk
</code></a>
1174 function allows you to query a whole group of OIDs, calling a function of your
1175 choice for each OID that is found:
</p>
1177 <pre class=
"example">
1178 #include
<cups/sidechannel.h
>
1181 my_callback(const char *oid, const char *data, int datalen, void *context)
1183 /* Do something with the value */
1184 printf(
"%s=%s\n", oid, data);
1191 <a href=
"#cupsSideChannelSNMPWalk">cupsSNMPSideChannelWalk
</a>(
".1.3.6.1.2.1.43",
5.0, my_callback, my_data);
1193 <h2 class=
"title"><a name=
"FUNCTIONS">Functions
</a></h2>
1194 <h3 class=
"function"><span class=
"info"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsBackChannelRead">cupsBackChannelRead
</a></h3>
1195 <p class=
"description">Read data from the backchannel.
</p>
1197 ssize_t cupsBackChannelRead (
<br>
1198 char *buffer,
<br>
1199 size_t bytes,
<br>
1200 double timeout
<br>
1202 <h4 class=
"parameters">Parameters
</h4>
1205 <dd class=
"description">Buffer to read into
</dd>
1207 <dd class=
"description">Bytes to read
</dd>
1209 <dd class=
"description">Timeout in seconds, typically
0.0 to poll
</dd>
1211 <h4 class=
"returnvalue">Return Value
</h4>
1212 <p class=
"description">Bytes read or -
1 on error
</p>
1213 <h4 class=
"discussion">Discussion
</h4>
1214 <p class=
"discussion">Reads up to
"bytes
" bytes from the backchannel/backend. The
"timeout
"
1215 parameter controls how many seconds to wait for the data - use
0.0 to
1216 return immediately if there is no data, -
1.0 to wait for data indefinitely.
1219 <h3 class=
"function"><span class=
"info"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsBackChannelWrite">cupsBackChannelWrite
</a></h3>
1220 <p class=
"description">Write data to the backchannel.
</p>
1222 ssize_t cupsBackChannelWrite (
<br>
1223 const char *buffer,
<br>
1224 size_t bytes,
<br>
1225 double timeout
<br>
1227 <h4 class=
"parameters">Parameters
</h4>
1230 <dd class=
"description">Buffer to write
</dd>
1232 <dd class=
"description">Bytes to write
</dd>
1234 <dd class=
"description">Timeout in seconds, typically
1.0</dd>
1236 <h4 class=
"returnvalue">Return Value
</h4>
1237 <p class=
"description">Bytes written or -
1 on error
</p>
1238 <h4 class=
"discussion">Discussion
</h4>
1239 <p class=
"discussion">Writes
"bytes
" bytes to the backchannel/filter. The
"timeout
" parameter
1240 controls how many seconds to wait for the data to be written - use
1241 0.0 to return immediately if the data cannot be written, -
1.0 to wait
1245 <h3 class=
"function"><span class=
"info"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsBackendDeviceURI">cupsBackendDeviceURI
</a></h3>
1246 <p class=
"description">Get the device URI for a backend.
</p>
1248 const char *cupsBackendDeviceURI (
<br>
1249 char **argv
<br>
1251 <h4 class=
"parameters">Parameters
</h4>
1254 <dd class=
"description">Command-line arguments
</dd>
1256 <h4 class=
"returnvalue">Return Value
</h4>
1257 <p class=
"description">Device URI or
<code>NULL
</code></p>
1258 <h4 class=
"discussion">Discussion
</h4>
1259 <p class=
"discussion">The
"argv
" argument is the argv argument passed to main(). This
1260 function returns the device URI passed in the DEVICE_URI environment
1261 variable or the device URI passed in argv[
0], whichever is found
1265 <h3 class=
"function"><span class=
"info"> CUPS
1.4/OS X
10.6 </span><a name=
"cupsBackendReport">cupsBackendReport
</a></h3>
1266 <p class=
"description">Write a device line from a backend.
</p>
1268 void cupsBackendReport (
<br>
1269 const char *device_scheme,
<br>
1270 const char *device_uri,
<br>
1271 const char *device_make_and_model,
<br>
1272 const char *device_info,
<br>
1273 const char *device_id,
<br>
1274 const char *device_location
<br>
1276 <h4 class=
"parameters">Parameters
</h4>
1278 <dt>device_scheme
</dt>
1279 <dd class=
"description">device-scheme string
</dd>
1281 <dd class=
"description">device-uri string
</dd>
1282 <dt>device_make_and_model
</dt>
1283 <dd class=
"description">device-make-and-model string or
<code>NULL
</code></dd>
1284 <dt>device_info
</dt>
1285 <dd class=
"description">device-info string or
<code>NULL
</code></dd>
1287 <dd class=
"description">device-id string or
<code>NULL
</code></dd>
1288 <dt>device_location
</dt>
1289 <dd class=
"description">device-location string or
<code>NULL
</code></dd>
1291 <h4 class=
"discussion">Discussion
</h4>
1292 <p class=
"discussion">This function writes a single device line to stdout for a backend.
1293 It handles quoting of special characters in the device-make-and-model,
1294 device-info, device-id, and device-location strings.
1297 <h3 class=
"function"><span class=
"info"> CUPS
1.3/OS X
10.5 </span><a name=
"cupsSideChannelDoRequest">cupsSideChannelDoRequest
</a></h3>
1298 <p class=
"description">Send a side-channel command to a backend and wait for a response.
</p>
1300 <a href=
"#cups_sc_status_t">cups_sc_status_t
</a> cupsSideChannelDoRequest (
<br>
1301 <a href=
"#cups_sc_command_t">cups_sc_command_t
</a> command,
<br>
1302 char *data,
<br>
1303 int *datalen,
<br>
1304 double timeout
<br>
1306 <h4 class=
"parameters">Parameters
</h4>
1309 <dd class=
"description">Command to send
</dd>
1311 <dd class=
"description">Response data buffer pointer
</dd>
1313 <dd class=
"description">Size of data buffer on entry, number of bytes in buffer on return
</dd>
1315 <dd class=
"description">Timeout in seconds
</dd>
1317 <h4 class=
"returnvalue">Return Value
</h4>
1318 <p class=
"description">Status of command
</p>
1319 <h4 class=
"discussion">Discussion
</h4>
1320 <p class=
"discussion">This function is normally only called by filters, drivers, or port
1321 monitors in order to communicate with the backend used by the current
1322 printer. Programs must be prepared to handle timeout or
"not
1323 implemented
" status codes, which indicate that the backend or device
1324 do not support the specified side-channel command.
<br>
1326 The
"datalen
" parameter must be initialized to the size of the buffer
1327 pointed to by the
"data
" parameter. cupsSideChannelDoRequest() will
1328 update the value to contain the number of data bytes in the buffer.
1331 <h3 class=
"function"><span class=
"info"> CUPS
1.3/OS X
10.5 </span><a name=
"cupsSideChannelRead">cupsSideChannelRead
</a></h3>
1332 <p class=
"description">Read a side-channel message.
</p>
1334 int cupsSideChannelRead (
<br>
1335 <a href=
"#cups_sc_command_t">cups_sc_command_t
</a> *command,
<br>
1336 <a href=
"#cups_sc_status_t">cups_sc_status_t
</a> *status,
<br>
1337 char *data,
<br>
1338 int *datalen,
<br>
1339 double timeout
<br>
1341 <h4 class=
"parameters">Parameters
</h4>
1344 <dd class=
"description">Command code
</dd>
1346 <dd class=
"description">Status code
</dd>
1348 <dd class=
"description">Data buffer pointer
</dd>
1350 <dd class=
"description">Size of data buffer on entry, number of bytes in buffer on return
</dd>
1352 <dd class=
"description">Timeout in seconds
</dd>
1354 <h4 class=
"returnvalue">Return Value
</h4>
1355 <p class=
"description">0 on success, -
1 on error
</p>
1356 <h4 class=
"discussion">Discussion
</h4>
1357 <p class=
"discussion">This function is normally only called by backend programs to read
1358 commands from a filter, driver, or port monitor program. The
1359 caller must be prepared to handle incomplete or invalid messages
1360 and return the corresponding status codes.
<br>
1362 The
"datalen
" parameter must be initialized to the size of the buffer
1363 pointed to by the
"data
" parameter. cupsSideChannelDoRequest() will
1364 update the value to contain the number of data bytes in the buffer.
1367 <h3 class=
"function"><span class=
"info"> CUPS
1.4/OS X
10.6 </span><a name=
"cupsSideChannelSNMPGet">cupsSideChannelSNMPGet
</a></h3>
1368 <p class=
"description">Query a SNMP OID's value.
</p>
1370 <a href=
"#cups_sc_status_t">cups_sc_status_t
</a> cupsSideChannelSNMPGet (
<br>
1371 const char *oid,
<br>
1372 char *data,
<br>
1373 int *datalen,
<br>
1374 double timeout
<br>
1376 <h4 class=
"parameters">Parameters
</h4>
1379 <dd class=
"description">OID to query
</dd>
1381 <dd class=
"description">Buffer for OID value
</dd>
1383 <dd class=
"description">Size of OID buffer on entry, size of value on return
</dd>
1385 <dd class=
"description">Timeout in seconds
</dd>
1387 <h4 class=
"returnvalue">Return Value
</h4>
1388 <p class=
"description">Query status
</p>
1389 <h4 class=
"discussion">Discussion
</h4>
1390 <p class=
"discussion">This function asks the backend to do a SNMP OID query on behalf of the
1391 filter, port monitor, or backend using the default community name.
<br>
1393 "oid
" contains a numeric OID consisting of integers separated by periods,
1394 for example
".1.3.6.1.2.1.43". Symbolic names from SNMP MIBs are not
1395 supported and must be converted to their numeric forms.
<br>
1397 On input,
"data
" and
"datalen
" provide the location and size of the
1398 buffer to hold the OID value as a string. HEX-String (binary) values are
1399 converted to hexadecimal strings representing the binary data, while
1400 NULL-Value and unknown OID types are returned as the empty string.
1401 The returned
"datalen
" does not include the trailing nul.
1403 <code>CUPS_SC_STATUS_NOT_IMPLEMENTED
</code> is returned by backends that do not
1404 support SNMP queries.
<code>CUPS_SC_STATUS_NO_RESPONSE
</code> is returned when
1405 the printer does not respond to the SNMP query.
1408 <h3 class=
"function"><span class=
"info"> CUPS
1.4/OS X
10.6 </span><a name=
"cupsSideChannelSNMPWalk">cupsSideChannelSNMPWalk
</a></h3>
1409 <p class=
"description">Query multiple SNMP OID values.
</p>
1411 <a href=
"#cups_sc_status_t">cups_sc_status_t
</a> cupsSideChannelSNMPWalk (
<br>
1412 const char *oid,
<br>
1413 double timeout,
<br>
1414 <a href=
"#cups_sc_walk_func_t">cups_sc_walk_func_t
</a> cb,
<br>
1415 void *context
<br>
1417 <h4 class=
"parameters">Parameters
</h4>
1420 <dd class=
"description">First numeric OID to query
</dd>
1422 <dd class=
"description">Timeout for each query in seconds
</dd>
1424 <dd class=
"description">Function to call with each value
</dd>
1426 <dd class=
"description">Application-defined pointer to send to callback
</dd>
1428 <h4 class=
"returnvalue">Return Value
</h4>
1429 <p class=
"description">Status of first query of
<code>CUPS_SC_STATUS_OK
</code> on success
</p>
1430 <h4 class=
"discussion">Discussion
</h4>
1431 <p class=
"discussion">This function asks the backend to do multiple SNMP OID queries on behalf
1432 of the filter, port monitor, or backend using the default community name.
1433 All OIDs under the
"parent
" OID are queried and the results are sent to
1434 the callback function you provide.
<br>
1436 "oid
" contains a numeric OID consisting of integers separated by periods,
1437 for example
".1.3.6.1.2.1.43". Symbolic names from SNMP MIBs are not
1438 supported and must be converted to their numeric forms.
<br>
1440 "timeout
" specifies the timeout for each OID query. The total amount of
1441 time will depend on the number of OID values found and the time required
1444 "cb
" provides a function to call for every value that is found.
"context
"
1445 is an application-defined pointer that is sent to the callback function
1446 along with the OID and current data. The data passed to the callback is the
1447 same as returned by
<a href=
"#cupsSideChannelSNMPGet"><code>cupsSideChannelSNMPGet
</code></a>.
1449 <code>CUPS_SC_STATUS_NOT_IMPLEMENTED
</code> is returned by backends that do not
1450 support SNMP queries.
<code>CUPS_SC_STATUS_NO_RESPONSE
</code> is returned when
1451 the printer does not respond to the first SNMP query.
1454 <h3 class=
"function"><span class=
"info"> CUPS
1.3/OS X
10.5 </span><a name=
"cupsSideChannelWrite">cupsSideChannelWrite
</a></h3>
1455 <p class=
"description">Write a side-channel message.
</p>
1457 int cupsSideChannelWrite (
<br>
1458 <a href=
"#cups_sc_command_t">cups_sc_command_t
</a> command,
<br>
1459 <a href=
"#cups_sc_status_t">cups_sc_status_t
</a> status,
<br>
1460 const char *data,
<br>
1461 int datalen,
<br>
1462 double timeout
<br>
1464 <h4 class=
"parameters">Parameters
</h4>
1467 <dd class=
"description">Command code
</dd>
1469 <dd class=
"description">Status code
</dd>
1471 <dd class=
"description">Data buffer pointer
</dd>
1473 <dd class=
"description">Number of bytes of data
</dd>
1475 <dd class=
"description">Timeout in seconds
</dd>
1477 <h4 class=
"returnvalue">Return Value
</h4>
1478 <p class=
"description">0 on success, -
1 on error
</p>
1479 <h4 class=
"discussion">Discussion
</h4>
1480 <p class=
"discussion">This function is normally only called by backend programs to send
1481 responses to a filter, driver, or port monitor program.
1484 <h2 class=
"title"><a name=
"TYPES">Data Types
</a></h2>
1485 <h3 class=
"typedef"><a name=
"cups_backend_t">cups_backend_t
</a></h3>
1486 <p class=
"description">Backend exit codes
</p>
1488 typedef enum
<a href=
"#cups_backend_e">cups_backend_e
</a> cups_backend_t;
1490 <h3 class=
"typedef"><a name=
"cups_sc_bidi_t">cups_sc_bidi_t
</a></h3>
1491 <p class=
"description">Bidirectional capabilities
</p>
1493 typedef enum
<a href=
"#cups_sc_bidi_e">cups_sc_bidi_e
</a> cups_sc_bidi_t;
1495 <h3 class=
"typedef"><a name=
"cups_sc_command_t">cups_sc_command_t
</a></h3>
1496 <p class=
"description">Request command codes
</p>
1498 typedef enum
<a href=
"#cups_sc_command_e">cups_sc_command_e
</a> cups_sc_command_t;
1500 <h3 class=
"typedef"><a name=
"cups_sc_connected_t">cups_sc_connected_t
</a></h3>
1501 <p class=
"description">Connectivity values
</p>
1503 typedef enum
<a href=
"#cups_sc_connected_e">cups_sc_connected_e
</a> cups_sc_connected_t;
1505 <h3 class=
"typedef"><a name=
"cups_sc_state_t">cups_sc_state_t
</a></h3>
1506 <p class=
"description">Printer state bits
</p>
1508 typedef enum
<a href=
"#cups_sc_state_e">cups_sc_state_e
</a> cups_sc_state_t;
1510 <h3 class=
"typedef"><a name=
"cups_sc_status_t">cups_sc_status_t
</a></h3>
1511 <p class=
"description">Response status codes
</p>
1513 typedef enum
<a href=
"#cups_sc_status_e">cups_sc_status_e
</a> cups_sc_status_t;
1515 <h3 class=
"typedef"><a name=
"cups_sc_walk_func_t">cups_sc_walk_func_t
</a></h3>
1516 <p class=
"description">SNMP walk callback
</p>
1518 typedef void (*cups_sc_walk_func_t)(const char *oid, const char *data, int datalen, void *context);
1520 <h2 class=
"title"><a name=
"ENUMERATIONS">Constants
</a></h2>
1521 <h3 class=
"enumeration"><a name=
"cups_backend_e">cups_backend_e
</a></h3>
1522 <p class=
"description">Backend exit codes
</p>
1523 <h4 class=
"constants">Constants
</h4>
1525 <dt>CUPS_BACKEND_AUTH_REQUIRED
</dt>
1526 <dd class=
"description">Job failed, authentication required
</dd>
1527 <dt>CUPS_BACKEND_CANCEL
</dt>
1528 <dd class=
"description">Job failed, cancel job
</dd>
1529 <dt>CUPS_BACKEND_FAILED
</dt>
1530 <dd class=
"description">Job failed, use error-policy
</dd>
1531 <dt>CUPS_BACKEND_HOLD
</dt>
1532 <dd class=
"description">Job failed, hold job
</dd>
1533 <dt>CUPS_BACKEND_OK
</dt>
1534 <dd class=
"description">Job completed successfully
</dd>
1535 <dt>CUPS_BACKEND_RETRY
</dt>
1536 <dd class=
"description">Job failed, retry this job later
</dd>
1537 <dt>CUPS_BACKEND_RETRY_CURRENT
</dt>
1538 <dd class=
"description">Job failed, retry this job immediately
</dd>
1539 <dt>CUPS_BACKEND_STOP
</dt>
1540 <dd class=
"description">Job failed, stop queue
</dd>
1542 <h3 class=
"enumeration"><a name=
"cups_sc_bidi_e">cups_sc_bidi_e
</a></h3>
1543 <p class=
"description">Bidirectional capability values
</p>
1544 <h4 class=
"constants">Constants
</h4>
1546 <dt>CUPS_SC_BIDI_NOT_SUPPORTED
</dt>
1547 <dd class=
"description">Bidirectional I/O is not supported
</dd>
1548 <dt>CUPS_SC_BIDI_SUPPORTED
</dt>
1549 <dd class=
"description">Bidirectional I/O is supported
</dd>
1551 <h3 class=
"enumeration"><a name=
"cups_sc_command_e">cups_sc_command_e
</a></h3>
1552 <p class=
"description">Request command codes
</p>
1553 <h4 class=
"constants">Constants
</h4>
1555 <dt>CUPS_SC_CMD_DRAIN_OUTPUT
</dt>
1556 <dd class=
"description">Drain all pending output
</dd>
1557 <dt>CUPS_SC_CMD_GET_BIDI
</dt>
1558 <dd class=
"description">Return bidirectional capabilities
</dd>
1559 <dt>CUPS_SC_CMD_GET_CONNECTED
<span class=
"info"> CUPS
1.5/OS X
10.7 </span></dt>
1560 <dd class=
"description">Return whether the backend is
"connected
" to the printer
</dd>
1561 <dt>CUPS_SC_CMD_GET_DEVICE_ID
</dt>
1562 <dd class=
"description">Return the IEEE-
1284 device ID
</dd>
1563 <dt>CUPS_SC_CMD_GET_STATE
</dt>
1564 <dd class=
"description">Return the device state
</dd>
1565 <dt>CUPS_SC_CMD_SNMP_GET
<span class=
"info"> CUPS
1.4/OS X
10.6 </span></dt>
1566 <dd class=
"description">Query an SNMP OID
</dd>
1567 <dt>CUPS_SC_CMD_SNMP_GET_NEXT
<span class=
"info"> CUPS
1.4/OS X
10.6 </span></dt>
1568 <dd class=
"description">Query the next SNMP OID
</dd>
1569 <dt>CUPS_SC_CMD_SOFT_RESET
</dt>
1570 <dd class=
"description">Do a soft reset
</dd>
1572 <h3 class=
"enumeration"><a name=
"cups_sc_connected_e">cups_sc_connected_e
</a></h3>
1573 <p class=
"description">Connectivity values
</p>
1574 <h4 class=
"constants">Constants
</h4>
1576 <dt>CUPS_SC_CONNECTED
</dt>
1577 <dd class=
"description">Backend is
"connected
" to printer
</dd>
1578 <dt>CUPS_SC_NOT_CONNECTED
</dt>
1579 <dd class=
"description">Backend is not
"connected
" to printer
</dd>
1581 <h3 class=
"enumeration"><a name=
"cups_sc_state_e">cups_sc_state_e
</a></h3>
1582 <p class=
"description">Printer state bits
</p>
1583 <h4 class=
"constants">Constants
</h4>
1585 <dt>CUPS_SC_STATE_BUSY
</dt>
1586 <dd class=
"description">Device is busy
</dd>
1587 <dt>CUPS_SC_STATE_ERROR
</dt>
1588 <dd class=
"description">Other error condition
</dd>
1589 <dt>CUPS_SC_STATE_MARKER_EMPTY
</dt>
1590 <dd class=
"description">Toner/ink out condition
</dd>
1591 <dt>CUPS_SC_STATE_MARKER_LOW
</dt>
1592 <dd class=
"description">Toner/ink low condition
</dd>
1593 <dt>CUPS_SC_STATE_MEDIA_EMPTY
</dt>
1594 <dd class=
"description">Paper out condition
</dd>
1595 <dt>CUPS_SC_STATE_MEDIA_LOW
</dt>
1596 <dd class=
"description">Paper low condition
</dd>
1597 <dt>CUPS_SC_STATE_OFFLINE
</dt>
1598 <dd class=
"description">Device is offline
</dd>
1599 <dt>CUPS_SC_STATE_ONLINE
</dt>
1600 <dd class=
"description">Device is online
</dd>
1602 <h3 class=
"enumeration"><a name=
"cups_sc_status_e">cups_sc_status_e
</a></h3>
1603 <p class=
"description">Response status codes
</p>
1604 <h4 class=
"constants">Constants
</h4>
1606 <dt>CUPS_SC_STATUS_BAD_MESSAGE
</dt>
1607 <dd class=
"description">The command/response message was invalid
</dd>
1608 <dt>CUPS_SC_STATUS_IO_ERROR
</dt>
1609 <dd class=
"description">An I/O error occurred
</dd>
1610 <dt>CUPS_SC_STATUS_NONE
</dt>
1611 <dd class=
"description">No status
</dd>
1612 <dt>CUPS_SC_STATUS_NOT_IMPLEMENTED
</dt>
1613 <dd class=
"description">Command not implemented
</dd>
1614 <dt>CUPS_SC_STATUS_NO_RESPONSE
</dt>
1615 <dd class=
"description">The device did not respond
</dd>
1616 <dt>CUPS_SC_STATUS_OK
</dt>
1617 <dd class=
"description">Operation succeeded
</dd>
1618 <dt>CUPS_SC_STATUS_TIMEOUT
</dt>
1619 <dd class=
"description">The backend did not respond
</dd>
1620 <dt>CUPS_SC_STATUS_TOO_BIG
</dt>
1621 <dd class=
"description">Response too big
</dd>