]> git.ipfire.org Git - thirdparty/cups.git/blame - doc/help/api-filter.html
Merge changes from CUPS 1.4svn-r7851.
[thirdparty/cups.git] / doc / help / api-filter.html
CommitLineData
ef416fc2 1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
2<html>
3<!-- SECTION: Programming -->
4<head>
5a738aea
MS
5<title>Filter and Backend Programming</title>
6<meta name="keywords" content="Programming">
7<meta name="creator" content="Mini-XML v2.5">
8<style type="text/css"><!--
9BODY {
10 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
11}
12
13H1, H2, H3, H4, H5, H6, P, TD, TH {
14 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
15}
16
17KBD {
18 font-family: monaco, courier, monospace;
19 font-weight: bold;
20}
21
22PRE {
23 font-family: monaco, courier, monospace;
24}
25
26PRE.command {
27 margin-left: 36pt;
28}
29
30PRE.example {
31 background: #eeeeee;
32 border: dotted thin #999999;
33 margin-left: 36pt;
34 padding: 10px;
35}
36
37PRE.command EM, PRE.example EM {
38 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
39}
40
41P.command {
42 font-family: monaco, courier, monospace;
43 margin-left: 36pt;
44}
45
46P.formula {
47 font-style: italic;
48 margin-left: 36pt;
49}
50
51BLOCKQUOTE {
52 background: #cccccc;
53 border: solid thin #999999;
54 padding: 10pt;
55}
56
57A:link, A:visited {
568fa3fa 58 font-weight: normal;
5a738aea 59 text-decoration: none;
5a738aea
MS
60}
61
62A:link:hover, A:visited:hover, A:active {
63 text-decoration: underline;
5a738aea
MS
64}
65
66SUB, SUP {
67 font-size: 50%;
68}
69
70DIV.table TABLE {
71 border: solid thin #999999;
72 border-collapse: collapse;
73 border-spacing: 0;
74 margin-left: auto;
75 margin-right: auto;
76}
77
78DIV.table CAPTION {
79 caption-side: top;
80 font-size: 120%;
81 font-style: italic;
82 font-weight: bold;
83 margin-left: auto;
84 margin-right: auto;
85}
86
87DIV.table TABLE TD {
88 border: solid thin #cccccc;
89 padding-top: 5pt;
90}
91
92DIV.table TABLE TH {
93 background: #cccccc;
94 border: none;
95 border-bottom: solid thin #999999;
96}
97
98DIV.figure TABLE {
99 margin-left: auto;
100 margin-right: auto;
101}
102
103DIV.figure CAPTION {
104 caption-side: bottom;
105 font-size: 120%;
106 font-style: italic;
107 font-weight: bold;
108 margin-left: auto;
109 margin-right: auto;
110}
111
112TH.label {
113 padding-top: 5pt;
114 text-align: right;
115 vertical-align: top;
116}
117
118HR {
119 border: solid thin;
120}
121
122SPAN.info {
123 background: #000000;
124 border: thin solid #000000;
125 color: #ffffff;
126 font-size: 80%;
127 font-style: italic;
128 font-weight: bold;
129 white-space: nowrap;
130}
131
132H2 SPAN.info, H3 SPAN.info, H4 SPAN.info {
133 float: right;
134 font-size: 100%;
135}
136
137H2.title, H3.title {
138 border-bottom: solid 2pt #000000;
139}
140
141DT {
142 margin-left: 36pt;
143 margin-top: 12pt;
144}
145
146DD {
147 margin-left: 54pt;
148}
149
150DL.category DT {
151 font-weight: bold;
152}
153
154P.summary {
155 margin-left: 36pt;
156 font-family: monaco, courier, monospace;
157}
158
159SPAN.message {
160 font-style: italic;
161 font-size: smaller;
162}
163
164DIV.summary TABLE {
165 border: solid thin #999999;
166 border-collapse: collapse;
167 border-spacing: 0;
168 margin: 10px;
169}
170
171DIV.summary TABLE TD, DIV.summary TABLE TH {
172 border: solid thin #999999;
173 padding: 5px;
174 text-align: left;
175 vertical-align: top;
176}
177
178DIV.summary TABLE THEAD TH {
179 background: #eeeeee;
180}
181
182/* API documentation styles... */
183div.body h1 {
184 margin: 0;
185}
186div.body h2 {
187 margin-top: 1.5em;
188}
189div.body h3, div.body h4, div.body h5 {
190 margin-bottom: 0.5em;
191 margin-top: 1.5em;
192}
193.class, .enumeration, .function, .struct, .typedef, .union {
194 border-bottom: solid thin #999999;
195 margin-bottom: 0;
196 margin-top: 2em;
197}
198.description {
199 margin-top: 0.5em;
200}
201code, p.code, pre, ul.code li {
202 font-family: monaco, courier, monospace;
203 font-size: 90%;
204}
205ul.code, ul.contents, ul.subcontents {
206 list-style-type: none;
207 margin: 0;
208 padding-left: 0;
209}
210ul.code li {
211 margin: 0;
212}
213ul.contents > li {
214 margin-top: 1em;
215}
216ul.contents li ul.code, ul.contents li ul.subcontents {
217 padding-left: 2em;
218}
219div.body dl {
220 margin-left: 0;
221 margin-top: 0;
222}
223div.body dt {
224 font-style: italic;
225 margin-left: 0;
226 margin-top: 0;
227}
228div.body dd {
229 margin-bottom: 0.5em;
230}
231
232/* This is just for the HTML files generated with the framedhelp target */
233div.contents {
234 background: #e8e8e8;
235 border: solid thin black;
236 padding: 10px;
237}
238div.contents h1 {
239 font-size: 110%;
240}
241div.contents h2 {
242 font-size: 100%;
243}
244div.contents ul.contents {
245 font-size: 80%;
246}
ac884b6a
MS
247div.contents ul.subcontents li {
248 margin-left: 1em;
249 text-indent: -1em;
250}
5a738aea 251--></style>
ef416fc2 252</head>
253<body>
5a738aea 254<div class='body'>
ef416fc2 255<!--
75bd9771 256 "$Id: api-filter.header 7616 2008-05-28 00:34:13Z mike $"
ef416fc2 257
5a738aea
MS
258 Filter and backend programming header for the Common UNIX Printing System
259 (CUPS).
ef416fc2 260
5a738aea 261 Copyright 2008 by Apple Inc.
ef416fc2 262
263 These coded instructions, statements, and computer programs are the
bc44d920 264 property of Apple Inc. and are protected by Federal copyright
265 law. Distribution and use rights are outlined in the file "LICENSE.txt"
266 which should have been included with this file. If this file is
267 file is missing or damaged, see the license at "http://www.cups.org/".
ef416fc2 268-->
269
5a738aea 270<h1 class="title">Filter and Backend Programming</h1>
ef416fc2 271
5a738aea
MS
272<div class='summary'><table summary='General Information'>
273<thead>
274<tr>
ac884b6a 275 <th>Headers</th>
5a738aea 276 <th>cups/backend.h<br>
79e1d494 277 cups/sidechannel.h</th>
5a738aea
MS
278</tr>
279</thead>
280<tbody>
281<tr>
282 <th>Library</th>
283 <td>-lcups</td>
284</tr>
285<tr>
286 <th>See Also</th>
287 <td>Programming: <a href='api-overview.html' target='_top'>Introduction to CUPS Programming</a><br>
288 Programming: <a href='api-cups.html' target='_top'>CUPS API</a><br>
289 Programming: <a href='api-ppd.html' target='_top'>PPD API</a><br>
79e1d494
MS
290 Programming: <a href='api-raster.html' target='_top'>Raster API</a><br>
291 Specifications: <a href='spec-design' target='_top'>CUPS Design Description</a></td>
5a738aea
MS
292</tr>
293</tbody>
294</table></div>
295<h2 class="title">Contents</h2>
296<ul class="contents">
297</li>
298<li><a href="#OVERVIEW">Overview</a><ul class="subcontents">
ac884b6a
MS
299<li><a href="#SECURITY">Security Considerations</a></li>
300<li><a href="#TEMPFILES">Temporary Files</a></li>
301<li><a href="#COPIES">Copy Generation</a></li>
5a738aea
MS
302<li><a href="#EXITCODES">Exit Codes</a></li>
303<li><a href="#ENVIRONMENT">Environment Variables</a></li>
304<li><a href="#MESSAGES">Communicating with the Scheduler</a></li>
20fbc903
MS
305<li><a href="#COMMUNICATING_BACKEND">Communicating with the Backend</a></li>
306<li><a href="#COMMUNICATING_FILTER">Communicating with Filters</a></li>
ac884b6a 307<li><a href="#SNMP">Doing SNMP Queries with Network Printers</a></li>
5a738aea
MS
308</ul></li>
309<li><a href="#FUNCTIONS">Functions</a><ul class="code">
310<li><a href="#cupsBackChannelRead" title="Read data from the backchannel.">cupsBackChannelRead</a></li>
311<li><a href="#cupsBackChannelWrite" title="Write data to the backchannel.">cupsBackChannelWrite</a></li>
ac884b6a 312<li><a href="#cupsBackendDeviceURI" title="Get the device URI for a backend.">cupsBackendDeviceURI</a></li>
5a738aea
MS
313<li><a href="#cupsSideChannelDoRequest" title="Send a side-channel command to a backend and wait for a response.">cupsSideChannelDoRequest</a></li>
314<li><a href="#cupsSideChannelRead" title="Read a side-channel message.">cupsSideChannelRead</a></li>
20fbc903
MS
315<li><a href="#cupsSideChannelSNMPGet" title="Query a SNMP OID's value.">cupsSideChannelSNMPGet</a></li>
316<li><a href="#cupsSideChannelSNMPWalk" title="Query multiple SNMP OID values.">cupsSideChannelSNMPWalk</a></li>
5a738aea
MS
317<li><a href="#cupsSideChannelWrite" title="Write a side-channel message.">cupsSideChannelWrite</a></li>
318</ul>
319<li><a href="#TYPES">Data Types</a><ul class="code">
320 <li><a href="#cups_backend_t" title="Backend exit codes">cups_backend_t</a></li>
321 <li><a href="#cups_sc_bidi_t" title="Bidirectional capabilities">cups_sc_bidi_t</a></li>
322 <li><a href="#cups_sc_command_t" title="Request command codes">cups_sc_command_t</a></li>
323 <li><a href="#cups_sc_state_t" title="Printer state bits">cups_sc_state_t</a></li>
324 <li><a href="#cups_sc_status_t" title="Response status codes">cups_sc_status_t</a></li>
20fbc903 325 <li><a href="#cups_sc_walk_func_t" title="SNMP walk callback">cups_sc_walk_func_t</a></li>
5a738aea
MS
326</ul></li>
327<li><a href="#ENUMERATIONS">Constants</a><ul class="code">
328 <li><a href="#cups_backend_e" title="Backend exit codes">cups_backend_e</a></li>
79e1d494 329 <li><a href="#cups_sc_bidi_e" title="Bidirectional capability values">cups_sc_bidi_e</a></li>
5a738aea
MS
330 <li><a href="#cups_sc_command_e" title="Request command codes">cups_sc_command_e</a></li>
331 <li><a href="#cups_sc_state_e" title="Printer state bits">cups_sc_state_e</a></li>
332 <li><a href="#cups_sc_status_e" title="Response status codes">cups_sc_status_e</a></li>
333</ul></li>
334</ul>
335<!--
75bd9771 336 "$Id: api-filter.shtml 7677 2008-06-19 23:22:19Z mike $"
ef416fc2 337
5a738aea
MS
338 Filter and backend programming introduction for the Common UNIX Printing
339 System (CUPS).
ef416fc2 340
5a738aea
MS
341 Copyright 2007-2008 by Apple Inc.
342 Copyright 1997-2006 by Easy Software Products, all rights reserved.
ef416fc2 343
5a738aea
MS
344 These coded instructions, statements, and computer programs are the
345 property of Apple Inc. and are protected by Federal copyright
346 law. Distribution and use rights are outlined in the file "LICENSE.txt"
347 which should have been included with this file. If this file is
348 file is missing or damaged, see the license at "http://www.cups.org/".
349-->
f7deaa1a 350
5a738aea 351<h2 class='title'><a name="OVERVIEW">Overview</a></h2>
ef416fc2 352
79e1d494
MS
353<p>Filters (which include printer drivers and port monitors) and backends
354are used to convert job files to a printable format and send that data to the
355printer itself. All of these programs use a common interface for processing
356print jobs and communicating status information to the scheduler. Each is run
357with a standard set of command-line arguments:<p>
ef416fc2 358
5a738aea 359<dl class="code">
f7deaa1a 360
5a738aea
MS
361 <dt>argv[1]</dt>
362 <dd>The job ID</dd>
ef416fc2 363
5a738aea
MS
364 <dt>argv[2]</dt>
365 <dd>The user printing the job</dd>
f7deaa1a 366
5a738aea
MS
367 <dt>argv[3]</dt>
368 <dd>The job name/title</dd>
f7deaa1a 369
5a738aea
MS
370 <dt>argv[4]</dt>
371 <dd>The number of copies to print</dd>
f7deaa1a 372
5a738aea
MS
373 <dt>argv[5]</dt>
374 <dd>The options that were provided when the job was submitted</dd>
f7deaa1a 375
5a738aea 376 <dt>argv[6]</dt>
79e1d494 377 <dd>The file to print (first program only)</dd>
5a738aea 378</dl>
f7deaa1a 379
5a738aea
MS
380<p>The scheduler runs one or more of these programs to print any given job. The
381first filter reads from the print file and writes to the standard output, while
382the remaining filters read from the standard input and write to the standard
383output. The backend is the last filter in the chain and writes to the
384device.</p>
f7deaa1a 385
ac884b6a
MS
386<h3><a name="SECURITY">Security Considerations</a></h3>
387
388<p>It is always important to use security programming practices. Filters and
389most backends are run as a non-priviledged user, so the major security
390consideration is resource utilization - filters should not depend on unlimited
391amounts of CPU, memory, or disk space, and should protect against conditions
392that could lead to excess usage of any resource like infinite loops and
393unbounded recursion. In addition, filters must <em>never</em> allow the user to
394specify an arbitrary file path to a separator page, template, or other file
395used by the filter since that can lead to an unauthorized disclosure of
396information. <em>Always</em> treat input as suspect and validate it!</p>
397
398<p>If you are developing a backend that runs as root, make sure to check for
399potential buffer overflows, integer under/overflow conditions, and file
400accesses since these can lead to privilege escalations. When writing files,
401always validate the file path and <em>never</em> allow a user to determine
402where to store a file.</p>
403
404<blockquote><b>Note:</b>
405
406<p><em>Never</em> write files to a user's home directory. Aside from the
407security implications, CUPS is a network print service and as such the network
408user may not be the same as the local user and/or there may not be a local home
409directory to write to.</p>
410
411<p>In addition, some operating systems provide additional security mechanisms
412that further limit file system access, even for backends running as root. On
413Mac OS X, for example, no backend may write to a user's home directory.</p>
414</blockquote>
415
416<h3><a name="TEMPFILES">Temporary Files</a></h3>
417
418<p>Temporary files should be created in the directory specified by the
419"TMPDIR" environment variable. The
420<a href="#cupsTempFile2"><code>cupsTempFile2</code></a> function can be
421used to safely create temporary files in this directory.</p>
422
423<h3><a name="COPIES">Copy Generation</a></h3>
424
425<p>The <code>argv[4]</code> argument specifies the number of copies to produce
426of the input file. In general, you should only generate copies if the
427<em>filename</em> argument is supplied. The only exception to this are
428filters that produce device-independent PostScript output, since the PostScript
429filter <var>pstops</var> is responsible for generating copies of PostScript
430files.</p>
431
5a738aea 432<h3><a name="EXITCODES">Exit Codes</a></h3>
f7deaa1a 433
5a738aea
MS
434<p>Filters must exit with status 0 when they successfully generate print data
435or 1 when they encounter an error. Backends can return any of the
436<a href="#cups_backend_t"><code>cups_backend_t</code></a> constants.</p>
f7deaa1a 437
5a738aea 438<h3><a name="ENVIRONMENT">Environment Variables</a></h3>
f7deaa1a 439
79e1d494
MS
440<p>The following environment variables are defined by the printing system
441when running print filters and backends:</p>
f7deaa1a 442
5a738aea 443<dl class="code">
f7deaa1a 444
5a738aea
MS
445 <dt>APPLE_LANGUAGES</dt>
446 <dd>The Apple language identifier associated with the job
447 (Mac OS X only).</dd>
f7deaa1a 448
5a738aea
MS
449 <dt>CHARSET</dt>
450 <dd>The job character set, typically "utf-8".</dd>
f7deaa1a 451
5a738aea
MS
452 <dt>CLASS</dt>
453 <dd>When a job is submitted to a printer class, contains the name of
454 the destination printer class. Otherwise this environment
455 variable will not be set.</dd>
f7deaa1a 456
5a738aea
MS
457 <dt>CONTENT_TYPE</dt>
458 <dd>The MIME type associated with the file (e.g.
459 application/postscript).</dd>
f7deaa1a 460
5a738aea 461 <dt>CUPS_CACHEDIR</dt>
79e1d494
MS
462 <dd>The directory where cache files can be stored. Cache files can be
463 used to retain information between jobs or files in a job.</dd>
f7deaa1a 464
5a738aea 465 <dt>CUPS_DATADIR</dt>
79e1d494 466 <dd>The directory where (read-only) CUPS data files can be found.</dd>
f7deaa1a 467
5a738aea
MS
468 <dt>CUPS_SERVERROOT</dt>
469 <dd>The root directory of the server.</dd>
f7deaa1a 470
5a738aea
MS
471 <dt>DEVICE_URI</dt>
472 <dd>The device-uri associated with the printer.</dd>
f7deaa1a 473
5a738aea
MS
474 <dt>FINAL_CONTENT_TYPE</dt>
475 <dd>The MIME type associated with the printer (e.g.
476 application/vnd.cups-postscript).</dd>
f7deaa1a 477
5a738aea
MS
478 <dt>LANG</dt>
479 <dd>The language locale associated with the job.</dd>
f7deaa1a 480
5a738aea
MS
481 <dt>PPD</dt>
482 <dd>The full pathname of the PostScript Printer Description (PPD)
483 file for this printer.</dd>
f7deaa1a 484
5a738aea 485 <dt>PRINTER</dt>
79e1d494 486 <dd>The queue name of the class or printer.</dd>
f7deaa1a 487
5a738aea
MS
488 <dt>RIP_CACHE</dt>
489 <dd>The recommended amount of memory to use for Raster Image
490 Processors (RIPs).</dd>
f7deaa1a 491
79e1d494
MS
492 <dt>TMPDIR</dt>
493 <dd>The directory where temporary files should be created.</dd>
494
5a738aea 495</dl>
f7deaa1a 496
5a738aea 497<h3><a name="MESSAGES">Communicating with the Scheduler</a></h3>
f7deaa1a 498
79e1d494
MS
499<p>Filters and backends communicate with the scheduler by writing messages
500to the standard error file. The scheduler reads messages from all filters in
501a job and processes the message based on its prefix. For example, the following
502code sets the current printer state message to "Printing page 5":</p>
f7deaa1a 503
5a738aea
MS
504<pre class="example">
505int page = 5;
f7deaa1a 506
5a738aea 507fprintf(stderr, "INFO: Printing page %d\n", page);
f7deaa1a 508</pre>
509
5a738aea
MS
510<p>Each message is a single line of text starting with one of the following
511prefix strings:</p>
512
513<dl class="code">
514
515 <dt>ALERT: message</dt>
516 <dd>Sets the printer-state-message attribute and adds the specified
517 message to the current error log file using the "alert" log level.</dd>
518
519 <dt>ATTR: attribute=value [attribute=value]</dt>
520 <dd>Sets the named printer or job attribute(s). Typically this is used
521 to set the <code>marker-colors</code>, <code>marker-levels</code>,
75bd9771
MS
522 <code>marker-message</code>, <code>marker-names</code>,
523 <code>marker-types</code>, <code>printer-alert</code>, and
524 <code>printer-alert-description</code> printer attributes. Standard
525 <code>marker-types</code> values are listed in <a href='#TABLE1'>Table
526 1</a>.</dd>
5a738aea
MS
527
528 <dt>CRIT: message</dt>
529 <dd>Sets the printer-state-message attribute and adds the specified
530 message to the current error log file using the "critical" log
531 level.</dd>
532
533 <dt>DEBUG: message</dt>
534 <dd>Sets the printer-state-message attribute and adds the specified
535 message to the current error log file using the "debug" log level.</dd>
536
537 <dt>DEBUG2: message</dt>
538 <dd>Sets the printer-state-message attribute and adds the specified
539 message to the current error log file using the "debug2" log level.</dd>
540
541 <dt>EMERG: message</dt>
542 <dd>Sets the printer-state-message attribute and adds the specified
543 message to the current error log file using the "emergency" log
544 level.</dd>
545
546 <dt>ERROR: message</dt>
547 <dd>Sets the printer-state-message attribute and adds the specified
79e1d494
MS
548 message to the current error log file using the "error" log level.
549 Use "ERROR:" messages for non-persistent processing errors.</dd>
5a738aea
MS
550
551 <dt>INFO: message</dt>
552 <dd>Sets the printer-state-message attribute. If the current log level
553 is set to "debug2", also adds the specified message to the current error
554 log file using the "info" log level.</dd>
555
556 <dt>NOTICE: message</dt>
557 <dd>Sets the printer-state-message attribute and adds the specified
558 message to the current error log file using the "notice" log level.</dd>
559
560 <dt>PAGE: page-number #-copies</dt>
561 <dt>PAGE: total #-pages</dt>
562 <dd>Adds an entry to the current page log file. The first form adds
563 #-copies to the job-media-sheets-completed attribute. The second
564 form sets the job-media-sheets-completed attribute to #-pages.</dd>
565
20fbc903
MS
566 <dt>PPD: keyword=value [keyword=value ...]</dt>
567 <dd>Changes or adds keywords to the printer's PPD file. Typically
568 this is used to update installable options or default media settings
569 based on the printer configuration.</dd>
570
5a738aea
MS
571 <dt>STATE: printer-state-reason [printer-state-reason ...]</dt>
572 <dt>STATE: + printer-state-reason [printer-state-reason ...]</dt>
573 <dt>STATE: - printer-state-reason [printer-state-reason ...]</dt>
574 <dd>Sets, adds, or removes printer-state-reason keywords to the
79e1d494
MS
575 current queue. Typically this is used to indicate persistent media,
576 ink, toner, and configuration conditions or errors on a printer.
577 <a href='#TABLE2'>Table 2</a> lists the standard state keywords -
578 use vendor-prefixed ("com.acme.foo") keywords for custom states.</dd>
5a738aea
MS
579
580 <dt>WARNING: message</dt>
581 <dd>Sets the printer-state-message attribute and adds the specified
582 message to the current error log file using the "warning" log
583 level.</dd>
584
585</dl>
586
587<p>Messages without one of these prefixes are treated as if they began with
588the "DEBUG:" prefix string.</p>
589
79e1d494
MS
590
591<div class='table'><table width='80%' summary='Table 1: Standard marker-types Values'>
592<caption>Table 1: <a name='TABLE1'>Standard marker-types Values</a></caption>
593<thead>
594<tr>
595 <th>marker-type</th>
596 <th>Description</th>
597</tr>
598</thead>
599<tbody>
600<tr>
601 <td>developer</td>
602 <td>Developer unit</td>
603</tr>
604<tr>
605 <td>fuser</td>
606 <td>Fuser unit</td>
607</tr>
608<tr>
609 <td>fuserCleaningPad</td>
610 <td>Fuser cleaning pad</td>
611</tr>
612<tr>
613 <td>fuserOil</td>
614 <td>Fuser oil</td>
615</tr>
616<tr>
617 <td>ink</td>
618 <td>Ink supply</td>
619</tr>
620<tr>
621 <td>opc</td>
622 <td>Photo conductor</td>
623</tr>
624<tr>
625 <td>solidWax</td>
626 <td>Wax supply</td>
627</tr>
628<tr>
629 <td>staples</td>
630 <td>Staple supply</td>
631</tr>
632<tr>
633 <td>toner</td>
634 <td>Toner supply</td>
635</tr>
636<tr>
637 <td>transferUnit</td>
638 <td>Transfer unit</td>
639</tr>
640<tr>
641 <td>wasteInk</td>
642 <td>Waste ink tank</td>
643</tr>
644<tr>
645 <td>wasteToner</td>
646 <td>Waste toner tank</td>
647</tr>
648<tr>
649 <td>wasteWax</td>
650 <td>Waste wax tank</td>
651</tr>
652</tbody>
653</table></div>
654
655<br>
656
657<div class='table'><table width='80%' summary='Table 2: Standard State Keywords'>
658<caption>Table 2: <a name='TABLE2'>Standard State Keywords</a></caption>
659<thead>
660<tr>
661 <th>Keyword</th>
662 <th>Description</th>
663</tr>
664</thead>
665<tbody>
666<tr>
667 <td>connecting-to-device</td>
668 <td>Connecting to printer but not printing yet</td>
669</tr>
670<tr>
671 <td>cover-open</td>
672 <td>A cover is open on the printer</td>
673</tr>
674<tr>
675 <td>input-tray-missing</td>
676 <td>An input tray is missing from the printer</td>
677</tr>
678<tr>
679 <td>marker-supply-empty</td>
680 <td>Out of ink</td>
681</tr>
682<tr>
683 <td>marker-supply-low</td>
684 <td>Low on ink</td>
685</tr>
686<tr>
687 <td>marker-waste-almost-full</td>
688 <td>Waste tank almost full</td>
689</tr>
690<tr>
691 <td>marker-waste-full</td>
692 <td>Waste tank full</td>
693</tr>
694<tr>
695 <td>media-empty</td>
696 <td>Out of media</td>
697</tr>
698<tr>
699 <td>media-jam</td>
700 <td>Media is jammed in the printer</td>
701</tr>
702<tr>
703 <td>media-low</td>
704 <td>Low on media</td>
705</tr>
706<tr>
707 <td>paused</td>
708 <td>Stop the printer</td>
709</tr>
710<tr>
711 <td>timed-out</td>
712 <td>Unable to connect to printer</td>
713</tr>
714<tr>
715 <td>toner-empty</td>
716 <td>Out of toner</td>
717</tr>
718<tr>
719 <td>toner-low</td>
720 <td>Low on toner</td>
721</tr>
722</tbody>
723</table></div>
724
20fbc903 725<h3><a name="COMMUNICATING_BACKEND">Communicating with the Backend</a></h3>
5a738aea
MS
726
727<p>Filters can communicate with the backend via the
728<a href="#cupsBackChannelRead"><code>cupsBackChannelRead</code></a> and
729<a href="#cupsSideChannelDoRequest"><code>cupsSideChannelDoRequest</code></a>
730functions. The
731<a href="#cupsBackChannelRead"><code>cupsBackChannelRead</code></a> function
732reads data that has been sent back from the device and is typically used to
733obtain status and configuration information. For example, the following code
734polls the backend for back-channel data:</p>
735
736<pre class="example">
737#include &lt;cups/cups.h&gt;
738
739char buffer[8192];
740ssize_t bytes;
741
742/* Use a timeout of 0.0 seconds to poll for back-channel data */
743bytes = cupsBackChannelRead(buffer, sizeof(buffer), 0.0);
744</pre>
f7deaa1a 745
79e1d494
MS
746<p>Filters can also use <code>select()</code> or <code>poll()</code> on the
747back-channel file descriptor (3 or <code>CUPS_BC_FD</code>) to read data only
748when it is available.</p>
749
750<p>The
5a738aea
MS
751<a href="#cupsSideChannelDoRequest"><code>cupsSideChannelDoRequest</code></a>
752function allows you to get out-of-band status information and do synchronization
753with the device. For example, the following code gets the current IEEE-1284
754device ID string from the backend:</p>
755
756<pre class="example">
f7deaa1a 757#include &lt;cups/sidechannel.h&gt;
758
759char data[2049];
760int datalen;
5a738aea 761<a href="#cups_sc_status_t">cups_sc_status_t</a> status;
f7deaa1a 762
79e1d494
MS
763/* Tell cupsSideChannelDoRequest() how big our buffer is, less 1 byte for
764 nul-termination... */
f7deaa1a 765datalen = sizeof(data) - 1;
766
767/* Get the IEEE-1284 device ID, waiting for up to 1 second */
5a738aea 768status = <a href="#cupsSideChannelDoRequest">cupsSideChannelDoRequest</a>(CUPS_SC_CMD_GET_DEVICE_ID, data, &amp;datalen, 1.0);
f7deaa1a 769
770/* Use the returned value if OK was returned and the length is non-zero */
771if (status == CUPS_SC_STATUS_OK && datalen > 0)
772 data[datalen] = '\0';
773else
774 data[0] = '\0';
775</pre>
776
20fbc903
MS
777<h3><a name="COMMUNICATING_FILTER">Communicating with Filters</a></h3>
778
5a738aea
MS
779<p>Backends communicate with filters using the reciprocal functions
780<a href="#cupsBackChannelWrite"><code>cupsBackChannelWrite</code></a>,
781<a href="#cupsSideChannelRead"><code>cupsSideChannelRead</code></a>, and
782<a href="#cupsSideChannelWrite"><code>cupsSideChannelWrite</code></a>. We
783recommend writing back-channel data using a timeout of 1.0 seconds:</p>
f7deaa1a 784
5a738aea
MS
785<pre class="example">
786#include &lt;cups/cups.h&gt;
f7deaa1a 787
5a738aea
MS
788char buffer[8192];
789ssize_t bytes;
f7deaa1a 790
79e1d494
MS
791/* Obtain data from printer/device */
792...
793
5a738aea
MS
794/* Use a timeout of 1.0 seconds to give filters a chance to read */
795cupsBackChannelWrite(buffer, bytes, 1.0);
f7deaa1a 796</pre>
797
5a738aea
MS
798<p>The <a href="#cupsSideChannelRead"><code>cupsSideChannelRead</code></a>
799function reads a side-channel command from a filter, driver, or port monitor.
800Backends can either poll for commands using a <code>timeout</code> of 0.0, wait
801indefinitely for commands using a <code>timeout</code> of -1.0 (probably in a
802separate thread for that purpose), or use <code>select</code> or
803<code>poll</code> on the <code>CUPS_SC_FD</code> file descriptor (4) to handle
20fbc903 804input and output on several file descriptors at the same time.</p>
5a738aea
MS
805
806<p>Once a command is processed, the backend uses the
807<a href="#cupsSideChannelWrite"><code>cupsSideChannelWrite</code></a> function
808to send its response. For example, the following code shows how to poll for a
809side-channel command and respond to it:</p>
810
811<pre class="example">
f7deaa1a 812#include &lt;cups/sidechannel.h&gt;
813
5a738aea
MS
814<a href="#cups_sc_command_t">cups_sc_command_t</a> command;
815<a href="#cups_sc_status_t">cups_sc_status_t</a> status;
20fbc903
MS
816char data[2048];
817int datalen = sizeof(data);
f7deaa1a 818
819/* Poll for a command... */
20fbc903 820if (!<a href="#cupsSideChannelRead">cupsSideChannelRead</a>(&amp;command, &amp;status, data, &amp;datalen, 0.0))
f7deaa1a 821{
f7deaa1a 822 switch (command)
823 {
20fbc903 824 /* handle supported commands, fill data/datalen/status with values as needed */
f7deaa1a 825
826 default :
827 status = CUPS_SC_STATUS_NOT_IMPLEMENTED;
828 datalen = 0;
829 break;
830 }
831
832 /* Send a response... */
5a738aea 833 <a href="#cupsSideChannelWrite">cupsSideChannelWrite</a>(command, status, data, datalen, 1.0);
f7deaa1a 834}
835</pre>
ac884b6a
MS
836
837<h3><a name="SNMP">Doing SNMP Queries with Network Printers</a></h3>
838
839<p>The Simple Network Management Protocol (SNMP) allows you to get the current
840status, page counter, and supply levels from most network printers. Every
841piece of information is associated with an Object Identifier (OID), and
842every printer has a <em>community</em> name associated with it. OIDs can be
843queried directly or by "walking" over a range of OIDs with a common prefix.</p>
844
20fbc903
MS
845<p>The two CUPS SNMP functions provide a simple API for querying network
846printers through the side-channel interface. Each accepts a string containing
847an OID like ".1.3.6.1.2.1.43.10.2.1.4.1.1" (the standard page counter OID)
848along with a timeout for the query.</p>
ac884b6a 849
20fbc903
MS
850<p>The <a href="#cupsSideChannelSNMPGet"><code>cupsSideChannelSNMPGet</code></a>
851function queries a single OID and returns the value as a string in a buffer
852you supply:</p>
ac884b6a
MS
853
854<pre class="example">
20fbc903 855#include &lt;cups/sidechannel.h&gt;
ac884b6a 856
20fbc903
MS
857char data[512];
858int datalen = sizeof(data);
ac884b6a 859
20fbc903
MS
860if (<a href="#cupsSideChannelSNMPGet">cupsSideChannelSNMPGet</a>(".1.3.6.1.2.1.43.10.2.1.4.1.1", data, &amp;datalen, 5.0)
861 == CUPS_SC_STATUS_OK)
ac884b6a
MS
862{
863 /* Do something with the value */
20fbc903 864 printf("Page counter is: %s\n", data);
ac884b6a
MS
865}
866</pre>
867
20fbc903
MS
868<p>The
869<a href="#cupsSideChannelSNMPWalk"><code>cupsSideChannelSNMPWalk</code></a>
870function allows you to query a whole group of OIDs, calling a function of your
871choice for each OID that is found:</p>
ac884b6a
MS
872
873<pre class="example">
20fbc903 874#include &lt;cups/sidechannel.h&gt;
ac884b6a
MS
875
876void
20fbc903 877my_callback(const char *oid, const char *data, int datalen, void *context)
ac884b6a
MS
878{
879 /* Do something with the value */
20fbc903 880 printf("%s=%s\n", oid, data);
ac884b6a
MS
881}
882
20fbc903
MS
883...
884
ac884b6a
MS
885void *my_data;
886
20fbc903 887<a href="#cupsSideChannelSNMPWalk">cupsSNMPSideChannelWalk</a>(".1.3.6.1.2.1.43", 5.0, my_callback, my_data);
ac884b6a 888</pre>
20fbc903 889<h2 class="title"><a name="FUNCTIONS">Functions</a></h2>
5a738aea
MS
890<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsBackChannelRead">cupsBackChannelRead</a></h3>
891<p class="description">Read data from the backchannel.</p>
892<p class="code">
893ssize_t cupsBackChannelRead (<br>
894&nbsp;&nbsp;&nbsp;&nbsp;char *buffer,<br>
895&nbsp;&nbsp;&nbsp;&nbsp;size_t bytes,<br>
896&nbsp;&nbsp;&nbsp;&nbsp;double timeout<br>
897);</p>
898<h4 class="parameters">Parameters</h4>
899<dl>
900<dt>buffer</dt>
79e1d494 901<dd class="description">Buffer to read into</dd>
5a738aea
MS
902<dt>bytes</dt>
903<dd class="description">Bytes to read</dd>
904<dt>timeout</dt>
79e1d494 905<dd class="description">Timeout in seconds, typically 0.0 to poll</dd>
5a738aea
MS
906</dl>
907<h4 class="returnvalue">Return Value</h4>
908<p class="description">Bytes read or -1 on error</p>
909<h4 class="discussion">Discussion</h4>
79e1d494
MS
910<p class="discussion">Reads up to &quot;bytes&quot; bytes from the backchannel/backend. The &quot;timeout&quot;
911parameter controls how many seconds to wait for the data - use 0.0 to
912return immediately if there is no data, -1.0 to wait for data indefinitely.
ef416fc2 913
5a738aea
MS
914</p>
915<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsBackChannelWrite">cupsBackChannelWrite</a></h3>
916<p class="description">Write data to the backchannel.</p>
917<p class="code">
918ssize_t cupsBackChannelWrite (<br>
919&nbsp;&nbsp;&nbsp;&nbsp;const char *buffer,<br>
920&nbsp;&nbsp;&nbsp;&nbsp;size_t bytes,<br>
921&nbsp;&nbsp;&nbsp;&nbsp;double timeout<br>
922);</p>
923<h4 class="parameters">Parameters</h4>
924<dl>
925<dt>buffer</dt>
926<dd class="description">Buffer to write</dd>
927<dt>bytes</dt>
928<dd class="description">Bytes to write</dd>
929<dt>timeout</dt>
79e1d494 930<dd class="description">Timeout in seconds, typically 1.0</dd>
5a738aea
MS
931</dl>
932<h4 class="returnvalue">Return Value</h4>
933<p class="description">Bytes written or -1 on error</p>
934<h4 class="discussion">Discussion</h4>
79e1d494 935<p class="discussion">Writes &quot;bytes&quot; bytes to the backchannel/filter. The &quot;timeout&quot; parameter
ef416fc2 936controls how many seconds to wait for the data to be written - use
9370.0 to return immediately if the data cannot be written, -1.0 to wait
938indefinitely.
939
ac884b6a
MS
940</p>
941<h3 class="function"><a name="cupsBackendDeviceURI">cupsBackendDeviceURI</a></h3>
942<p class="description">Get the device URI for a backend.</p>
943<p class="code">
944const char *cupsBackendDeviceURI (<br>
945&nbsp;&nbsp;&nbsp;&nbsp;char **argv<br>
946);</p>
947<h4 class="parameters">Parameters</h4>
948<dl>
949<dt>argv</dt>
950<dd class="description">Command-line arguments</dd>
951</dl>
952<h4 class="returnvalue">Return Value</h4>
953<p class="description">Device URI or <code>NULL</code></p>
954<h4 class="discussion">Discussion</h4>
955<p class="discussion">The &quot;argv&quot; argument is the argv argument passed to main(). This
956function returns the device URI passed in the DEVICE_URI environment
957variable or the device URI passed in argv[0], whichever is found
958first.</p>
5a738aea
MS
959<h3 class="function"><span class="info">&nbsp;CUPS 1.3&nbsp;</span><a name="cupsSideChannelDoRequest">cupsSideChannelDoRequest</a></h3>
960<p class="description">Send a side-channel command to a backend and wait for a response.</p>
961<p class="code">
962<a href="#cups_sc_status_t">cups_sc_status_t</a> cupsSideChannelDoRequest (<br>
963&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_sc_command_t">cups_sc_command_t</a> command,<br>
964&nbsp;&nbsp;&nbsp;&nbsp;char *data,<br>
965&nbsp;&nbsp;&nbsp;&nbsp;int *datalen,<br>
966&nbsp;&nbsp;&nbsp;&nbsp;double timeout<br>
967);</p>
968<h4 class="parameters">Parameters</h4>
969<dl>
970<dt>command</dt>
971<dd class="description">Command to send</dd>
972<dt>data</dt>
973<dd class="description">Response data buffer pointer</dd>
974<dt>datalen</dt>
975<dd class="description">Size of data buffer on entry, number of bytes in buffer on return</dd>
976<dt>timeout</dt>
977<dd class="description">Timeout in seconds</dd>
978</dl>
979<h4 class="returnvalue">Return Value</h4>
980<p class="description">Status of command</p>
981<h4 class="discussion">Discussion</h4>
982<p class="discussion">This function is normally only called by filters, drivers, or port
f7deaa1a 983monitors in order to communicate with the backend used by the current
984printer. Programs must be prepared to handle timeout or &quot;not
985implemented&quot; status codes, which indicate that the backend or device
5a738aea
MS
986do not support the specified side-channel command.<br>
987<br>
988The &quot;datalen&quot; parameter must be initialized to the size of the buffer
f7deaa1a 989pointed to by the &quot;data&quot; parameter. cupsSideChannelDoRequest() will
990update the value to contain the number of data bytes in the buffer.
991
5a738aea
MS
992</p>
993<h3 class="function"><span class="info">&nbsp;CUPS 1.3&nbsp;</span><a name="cupsSideChannelRead">cupsSideChannelRead</a></h3>
994<p class="description">Read a side-channel message.</p>
995<p class="code">
996int cupsSideChannelRead (<br>
997&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_sc_command_t">cups_sc_command_t</a> *command,<br>
998&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_sc_status_t">cups_sc_status_t</a> *status,<br>
999&nbsp;&nbsp;&nbsp;&nbsp;char *data,<br>
1000&nbsp;&nbsp;&nbsp;&nbsp;int *datalen,<br>
1001&nbsp;&nbsp;&nbsp;&nbsp;double timeout<br>
1002);</p>
1003<h4 class="parameters">Parameters</h4>
1004<dl>
1005<dt>command</dt>
1006<dd class="description">Command code</dd>
1007<dt>status</dt>
1008<dd class="description">Status code</dd>
1009<dt>data</dt>
1010<dd class="description">Data buffer pointer</dd>
1011<dt>datalen</dt>
1012<dd class="description">Size of data buffer on entry, number of bytes in buffer on return</dd>
1013<dt>timeout</dt>
1014<dd class="description">Timeout in seconds</dd>
1015</dl>
1016<h4 class="returnvalue">Return Value</h4>
1017<p class="description">0 on success, -1 on error</p>
1018<h4 class="discussion">Discussion</h4>
1019<p class="discussion">This function is normally only called by backend programs to read
f7deaa1a 1020commands from a filter, driver, or port monitor program. The
1021caller must be prepared to handle incomplete or invalid messages
5a738aea
MS
1022and return the corresponding status codes.<br>
1023<br>
1024The &quot;datalen&quot; parameter must be initialized to the size of the buffer
f7deaa1a 1025pointed to by the &quot;data&quot; parameter. cupsSideChannelDoRequest() will
1026update the value to contain the number of data bytes in the buffer.
1027
20fbc903
MS
1028</p>
1029<h3 class="function"><span class="info">&nbsp;CUPS 1.4&nbsp;</span><a name="cupsSideChannelSNMPGet">cupsSideChannelSNMPGet</a></h3>
1030<p class="description">Query a SNMP OID's value.</p>
1031<p class="code">
1032<a href="#cups_sc_status_t">cups_sc_status_t</a> cupsSideChannelSNMPGet (<br>
1033&nbsp;&nbsp;&nbsp;&nbsp;const char *oid,<br>
1034&nbsp;&nbsp;&nbsp;&nbsp;char *data,<br>
1035&nbsp;&nbsp;&nbsp;&nbsp;int *datalen,<br>
1036&nbsp;&nbsp;&nbsp;&nbsp;double timeout<br>
1037);</p>
1038<h4 class="parameters">Parameters</h4>
1039<dl>
1040<dt>oid</dt>
1041<dd class="description">OID to query</dd>
1042<dt>data</dt>
1043<dd class="description">Buffer for OID value</dd>
1044<dt>datalen</dt>
1045<dd class="description">Size of OID buffer on entry, size of value on return</dd>
1046<dt>timeout</dt>
1047<dd class="description">Timeout in seconds</dd>
1048</dl>
1049<h4 class="returnvalue">Return Value</h4>
1050<p class="description">Query status</p>
1051<h4 class="discussion">Discussion</h4>
1052<p class="discussion">This function asks the backend to do a SNMP OID query on behalf of the
1053filter, port monitor, or backend using the default community name.<br>
1054<br>
1055&quot;oid&quot; contains a numeric OID consisting of integers separated by periods,
1056for example &quot;.1.3.6.1.2.1.43&quot;. Symbolic names from SNMP MIBs are not
1057supported and must be converted to their numeric forms.<br>
1058<br>
1059On input, &quot;data&quot; and &quot;datalen&quot; provide the location and size of the
1060buffer to hold the OID value as a string. HEX-String (binary) values are
1061converted to hexadecimal strings representing the binary data, while
1062NULL-Value and unknown OID types are returned as the empty string.
1063The returned &quot;datalen&quot; does not include the trailing nul.
1064
1065<code>CUPS_SC_STATUS_NOT_IMPLEMENTED</code> is returned by backends that do not
1066support SNMP queries. <code>CUPS_SC_STATUS_NO_RESPONSE</code> is returned when
1067the printer does not respond to the SNMP query.
1068
1069</p>
1070<h3 class="function"><span class="info">&nbsp;CUPS 1.4&nbsp;</span><a name="cupsSideChannelSNMPWalk">cupsSideChannelSNMPWalk</a></h3>
1071<p class="description">Query multiple SNMP OID values.</p>
1072<p class="code">
1073<a href="#cups_sc_status_t">cups_sc_status_t</a> cupsSideChannelSNMPWalk (<br>
1074&nbsp;&nbsp;&nbsp;&nbsp;const char *oid,<br>
1075&nbsp;&nbsp;&nbsp;&nbsp;double timeout,<br>
1076&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_sc_walk_func_t">cups_sc_walk_func_t</a> cb,<br>
1077&nbsp;&nbsp;&nbsp;&nbsp;void *context<br>
1078);</p>
1079<h4 class="parameters">Parameters</h4>
1080<dl>
1081<dt>oid</dt>
1082<dd class="description">First numeric OID to query</dd>
1083<dt>timeout</dt>
1084<dd class="description">Timeout for each query in seconds</dd>
1085<dt>cb</dt>
1086<dd class="description">Function to call with each value</dd>
1087<dt>context</dt>
1088<dd class="description">Application-defined pointer to send to callback</dd>
1089</dl>
1090<h4 class="returnvalue">Return Value</h4>
1091<p class="description">Status of first query of <code>CUPS_SC_STATUS_OK</code> on success</p>
1092<h4 class="discussion">Discussion</h4>
1093<p class="discussion">This function asks the backend to do multiple SNMP OID queries on behalf
1094of the filter, port monitor, or backend using the default community name.
1095All OIDs under the &quot;parent&quot; OID are queried and the results are sent to
1096the callback function you provide.<br>
1097<br>
1098&quot;oid&quot; contains a numeric OID consisting of integers separated by periods,
1099for example &quot;.1.3.6.1.2.1.43&quot;. Symbolic names from SNMP MIBs are not
1100supported and must be converted to their numeric forms.<br>
1101<br>
1102&quot;timeout&quot; specifies the timeout for each OID query. The total amount of
1103time will depend on the number of OID values found and the time required
1104for each query.<br>
1105<br>
1106&quot;cb&quot; provides a function to call for every value that is found. &quot;context&quot;
1107is an application-defined pointer that is sent to the callback function
1108along with the OID and current data. The data passed to the callback is the
1109same as returned by <a href="#cupsSideChannelSNMPGet"><code>cupsSideChannelSNMPGet</code></a>.
1110
1111<code>CUPS_SC_STATUS_NOT_IMPLEMENTED</code> is returned by backends that do not
1112support SNMP queries. <code>CUPS_SC_STATUS_NO_RESPONSE</code> is returned when
1113the printer does not respond to the first SNMP query.
1114
5a738aea
MS
1115</p>
1116<h3 class="function"><span class="info">&nbsp;CUPS 1.3&nbsp;</span><a name="cupsSideChannelWrite">cupsSideChannelWrite</a></h3>
1117<p class="description">Write a side-channel message.</p>
1118<p class="code">
1119int cupsSideChannelWrite (<br>
1120&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_sc_command_t">cups_sc_command_t</a> command,<br>
1121&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_sc_status_t">cups_sc_status_t</a> status,<br>
1122&nbsp;&nbsp;&nbsp;&nbsp;const char *data,<br>
1123&nbsp;&nbsp;&nbsp;&nbsp;int datalen,<br>
1124&nbsp;&nbsp;&nbsp;&nbsp;double timeout<br>
1125);</p>
1126<h4 class="parameters">Parameters</h4>
1127<dl>
1128<dt>command</dt>
1129<dd class="description">Command code</dd>
1130<dt>status</dt>
1131<dd class="description">Status code</dd>
1132<dt>data</dt>
1133<dd class="description">Data buffer pointer</dd>
1134<dt>datalen</dt>
1135<dd class="description">Number of bytes of data</dd>
1136<dt>timeout</dt>
1137<dd class="description">Timeout in seconds</dd>
1138</dl>
1139<h4 class="returnvalue">Return Value</h4>
1140<p class="description">0 on success, -1 on error</p>
1141<h4 class="discussion">Discussion</h4>
1142<p class="discussion">This function is normally only called by backend programs to send
f7deaa1a 1143responses to a filter, driver, or port monitor program.
1144
5a738aea
MS
1145</p>
1146<h2 class="title"><a name="TYPES">Data Types</a></h2>
1147<h3 class="typedef"><a name="cups_backend_t">cups_backend_t</a></h3>
1148<p class="description">Backend exit codes</p>
1149<p class="code">
1150typedef enum <a href="#cups_backend_e">cups_backend_e</a> cups_backend_t;
1151</p>
1152<h3 class="typedef"><a name="cups_sc_bidi_t">cups_sc_bidi_t</a></h3>
1153<p class="description">Bidirectional capabilities</p>
1154<p class="code">
1155typedef enum <a href="#cups_sc_bidi_e">cups_sc_bidi_e</a> cups_sc_bidi_t;
1156</p>
1157<h3 class="typedef"><a name="cups_sc_command_t">cups_sc_command_t</a></h3>
1158<p class="description">Request command codes</p>
1159<p class="code">
1160typedef enum <a href="#cups_sc_command_e">cups_sc_command_e</a> cups_sc_command_t;
1161</p>
1162<h3 class="typedef"><a name="cups_sc_state_t">cups_sc_state_t</a></h3>
1163<p class="description">Printer state bits</p>
1164<p class="code">
1165typedef enum <a href="#cups_sc_state_e">cups_sc_state_e</a> cups_sc_state_t;
1166</p>
1167<h3 class="typedef"><a name="cups_sc_status_t">cups_sc_status_t</a></h3>
1168<p class="description">Response status codes</p>
1169<p class="code">
1170typedef enum <a href="#cups_sc_status_e">cups_sc_status_e</a> cups_sc_status_t;
1171</p>
20fbc903
MS
1172<h3 class="typedef"><a name="cups_sc_walk_func_t">cups_sc_walk_func_t</a></h3>
1173<p class="description">SNMP walk callback</p>
1174<p class="code">
1175typedef void (*cups_sc_walk_func_t)(const char *oid, const char *data, int datalen, void *context);
1176</p>
5a738aea
MS
1177<h2 class="title"><a name="ENUMERATIONS">Constants</a></h2>
1178<h3 class="enumeration"><a name="cups_backend_e">cups_backend_e</a></h3>
1179<p class="description">Backend exit codes</p>
1180<h4 class="constants">Constants</h4>
1181<dl>
1182<dt>CUPS_BACKEND_AUTH_REQUIRED </dt>
1183<dd class="description">Job failed, authentication required</dd>
1184<dt>CUPS_BACKEND_CANCEL </dt>
1185<dd class="description">Job failed, cancel job</dd>
1186<dt>CUPS_BACKEND_FAILED </dt>
1187<dd class="description">Job failed, use error-policy</dd>
1188<dt>CUPS_BACKEND_HOLD </dt>
1189<dd class="description">Job failed, hold job</dd>
1190<dt>CUPS_BACKEND_OK </dt>
1191<dd class="description">Job completed successfully</dd>
1192<dt>CUPS_BACKEND_STOP </dt>
1193<dd class="description">Job failed, stop queue</dd>
1194</dl>
1195<h3 class="enumeration"><a name="cups_sc_bidi_e">cups_sc_bidi_e</a></h3>
79e1d494 1196<p class="description">Bidirectional capability values</p>
5a738aea
MS
1197<h4 class="constants">Constants</h4>
1198<dl>
1199<dt>CUPS_SC_BIDI_NOT_SUPPORTED </dt>
1200<dd class="description">Bidirectional I/O is not supported</dd>
1201<dt>CUPS_SC_BIDI_SUPPORTED </dt>
1202<dd class="description">Bidirectional I/O is supported</dd>
1203</dl>
1204<h3 class="enumeration"><a name="cups_sc_command_e">cups_sc_command_e</a></h3>
1205<p class="description">Request command codes</p>
1206<h4 class="constants">Constants</h4>
1207<dl>
1208<dt>CUPS_SC_CMD_DRAIN_OUTPUT </dt>
1209<dd class="description">Drain all pending output</dd>
1210<dt>CUPS_SC_CMD_GET_BIDI </dt>
1211<dd class="description">Return bidirectional capabilities</dd>
1212<dt>CUPS_SC_CMD_GET_DEVICE_ID </dt>
1213<dd class="description">Return the IEEE-1284 device ID</dd>
1214<dt>CUPS_SC_CMD_GET_STATE </dt>
1215<dd class="description">Return the device state</dd>
20fbc903
MS
1216<dt>CUPS_SC_CMD_SNMP_GET <span class="info">&nbsp;CUPS 1.4&nbsp;</span></dt>
1217<dd class="description">Query an SNMP OID </dd>
1218<dt>CUPS_SC_CMD_SNMP_GET_NEXT <span class="info">&nbsp;CUPS 1.4&nbsp;</span></dt>
1219<dd class="description">Query the next SNMP OID </dd>
5a738aea
MS
1220<dt>CUPS_SC_CMD_SOFT_RESET </dt>
1221<dd class="description">Do a soft reset</dd>
1222</dl>
1223<h3 class="enumeration"><a name="cups_sc_state_e">cups_sc_state_e</a></h3>
1224<p class="description">Printer state bits</p>
1225<h4 class="constants">Constants</h4>
1226<dl>
1227<dt>CUPS_SC_STATE_BUSY </dt>
1228<dd class="description">Device is busy</dd>
1229<dt>CUPS_SC_STATE_ERROR </dt>
1230<dd class="description">Other error condition</dd>
1231<dt>CUPS_SC_STATE_MARKER_EMPTY </dt>
1232<dd class="description">Toner/ink out condition</dd>
1233<dt>CUPS_SC_STATE_MARKER_LOW </dt>
1234<dd class="description">Toner/ink low condition</dd>
1235<dt>CUPS_SC_STATE_MEDIA_EMPTY </dt>
1236<dd class="description">Paper out condition</dd>
1237<dt>CUPS_SC_STATE_MEDIA_LOW </dt>
1238<dd class="description">Paper low condition</dd>
1239<dt>CUPS_SC_STATE_OFFLINE </dt>
79e1d494 1240<dd class="description">Device is offline</dd>
5a738aea 1241<dt>CUPS_SC_STATE_ONLINE </dt>
79e1d494 1242<dd class="description">Device is online</dd>
5a738aea
MS
1243</dl>
1244<h3 class="enumeration"><a name="cups_sc_status_e">cups_sc_status_e</a></h3>
1245<p class="description">Response status codes</p>
1246<h4 class="constants">Constants</h4>
1247<dl>
1248<dt>CUPS_SC_STATUS_BAD_MESSAGE </dt>
1249<dd class="description">The command/response message was invalid</dd>
1250<dt>CUPS_SC_STATUS_IO_ERROR </dt>
1251<dd class="description">An I/O error occurred</dd>
1252<dt>CUPS_SC_STATUS_NONE </dt>
1253<dd class="description">No status</dd>
1254<dt>CUPS_SC_STATUS_NOT_IMPLEMENTED </dt>
1255<dd class="description">Command not implemented</dd>
1256<dt>CUPS_SC_STATUS_NO_RESPONSE </dt>
1257<dd class="description">The device did not respond</dd>
1258<dt>CUPS_SC_STATUS_OK </dt>
1259<dd class="description">Operation succeeded</dd>
1260<dt>CUPS_SC_STATUS_TIMEOUT </dt>
1261<dd class="description">The backend did not respond</dd>
1262<dt>CUPS_SC_STATUS_TOO_BIG </dt>
1263<dd class="description">Response too big</dd>
1264</dl>
1265</div>
ef416fc2 1266</body>
1267</html>