]> git.ipfire.org Git - thirdparty/cups.git/blame - doc/help/api-filter.html
Remove all of the Subversion keywords from various source files.
[thirdparty/cups.git] / doc / help / api-filter.html
CommitLineData
745129be 1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
ef416fc2 2<html>
3<!-- SECTION: Programming -->
4<head>
0268488e
MS
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">
dd3fdd2c 8 <meta name="creator" content="Mini-XML v2.7">
5a738aea
MS
9<style type="text/css"><!--
10BODY {
11 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
12}
13
14H1, H2, H3, H4, H5, H6, P, TD, TH {
15 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
16}
17
18KBD {
19 font-family: monaco, courier, monospace;
20 font-weight: bold;
21}
22
23PRE {
24 font-family: monaco, courier, monospace;
25}
26
27PRE.command {
10d09e33 28 border: dotted thin #7f7f7f;
5a738aea 29 margin-left: 36pt;
10d09e33 30 padding: 10px;
5a738aea
MS
31}
32
f11a948a
MS
33P.compact {
34 margin: 0;
35}
36
e4572d57
MS
37P.example {
38 font-style: italic;
39 margin-left: 36pt;
40}
ca6b43fc 41
240214ef
MS
42DL.man DD {
43 margin-left: 5em;
44}
45
46DL.man DT {
47 margin-left: 0;
48}
49
50PRE.man {
51 margin: 0;
52}
53
5a738aea
MS
54PRE.example {
55 background: #eeeeee;
56 border: dotted thin #999999;
57 margin-left: 36pt;
178cb736 58 padding: 10pt;
5a738aea
MS
59}
60
61PRE.command EM, PRE.example EM {
62 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
63}
64
65P.command {
66 font-family: monaco, courier, monospace;
67 margin-left: 36pt;
68}
69
70P.formula {
71 font-style: italic;
72 margin-left: 36pt;
73}
74
75BLOCKQUOTE {
178cb736 76 background: #eeeeee;
5a738aea
MS
77 border: solid thin #999999;
78 padding: 10pt;
79}
80
e4572d57
MS
81A IMG {
82 border: none;
83}
84
85A:link:hover IMG {
86 background: #f0f0f0;
87 border-radius: 10px;
88 -moz-border-radius: 10px;
89}
90
5a738aea 91A:link, A:visited {
ca6b43fc 92 font-weight: inherit;
5a738aea 93 text-decoration: none;
5a738aea
MS
94}
95
96A:link:hover, A:visited:hover, A:active {
97 text-decoration: underline;
5a738aea
MS
98}
99
100SUB, SUP {
101 font-size: 50%;
102}
103
e4572d57
MS
104TR.data, TD.data, TR.data TD {
105 margin-top: 10pt;
106 padding: 5pt;
107 border-bottom: solid 1pt #999999;
108}
109
110TR.data TH {
111 border-bottom: solid 1pt #999999;
112 padding-top: 10pt;
113 padding-left: 5pt;
114 text-align: left;
115}
116
5a738aea
MS
117DIV.table TABLE {
118 border: solid thin #999999;
119 border-collapse: collapse;
120 border-spacing: 0;
121 margin-left: auto;
122 margin-right: auto;
123}
124
125DIV.table CAPTION {
126 caption-side: top;
127 font-size: 120%;
128 font-style: italic;
129 font-weight: bold;
130 margin-left: auto;
131 margin-right: auto;
132}
133
134DIV.table TABLE TD {
135 border: solid thin #cccccc;
136 padding-top: 5pt;
137}
138
139DIV.table TABLE TH {
140 background: #cccccc;
141 border: none;
142 border-bottom: solid thin #999999;
143}
144
145DIV.figure TABLE {
146 margin-left: auto;
147 margin-right: auto;
148}
149
150DIV.figure CAPTION {
151 caption-side: bottom;
152 font-size: 120%;
153 font-style: italic;
154 font-weight: bold;
155 margin-left: auto;
156 margin-right: auto;
157}
158
159TH.label {
5a738aea
MS
160 text-align: right;
161 vertical-align: top;
162}
163
e4572d57
MS
164TH.sublabel {
165 text-align: right;
166 font-weight: normal;
167}
168
5a738aea
MS
169HR {
170 border: solid thin;
171}
172
173SPAN.info {
e4572d57
MS
174 background: black;
175 border: thin solid black;
176 color: white;
5a738aea
MS
177 font-size: 80%;
178 font-style: italic;
179 font-weight: bold;
180 white-space: nowrap;
181}
182
183H2 SPAN.info, H3 SPAN.info, H4 SPAN.info {
184 float: right;
185 font-size: 100%;
186}
187
178cb736
MS
188H1.title {
189}
190
5a738aea
MS
191H2.title, H3.title {
192 border-bottom: solid 2pt #000000;
193}
194
e4572d57
MS
195DIV.indent, TABLE.indent {
196 margin-top: 2em;
197 margin-left: auto;
198 margin-right: auto;
199 width: 90%;
200}
201
202TABLE.indent {
203 border-collapse: collapse;
204}
205
206TABLE.indent TD, TABLE.indent TH {
207 padding: 0;
208}
209
210TABLE.list {
211 border-collapse: collapse;
212 margin-left: auto;
213 margin-right: auto;
214 width: 90%;
215}
216
217TABLE.list TH {
218 background: white;
219 border-bottom: solid thin #cccccc;
220 color: #444444;
221 padding-top: 10pt;
222 padding-left: 5pt;
223 text-align: left;
224 vertical-align: bottom;
225 white-space: nowrap;
226}
227
228TABLE.list TH A {
229 color: #4444cc;
230}
231
232TABLE.list TD {
233 border-bottom: solid thin #eeeeee;
234 padding-top: 5pt;
235 padding-left: 5pt;
236}
237
238TABLE.list TR:nth-child(even) {
239 background: #f8f8f8;
240}
241
242TABLE.list TR:nth-child(odd) {
243 background: #f4f4f4;
244}
245
5a738aea
MS
246DT {
247 margin-left: 36pt;
248 margin-top: 12pt;
249}
250
251DD {
252 margin-left: 54pt;
253}
254
255DL.category DT {
256 font-weight: bold;
257}
258
259P.summary {
260 margin-left: 36pt;
261 font-family: monaco, courier, monospace;
262}
263
5a738aea
MS
264DIV.summary TABLE {
265 border: solid thin #999999;
266 border-collapse: collapse;
267 border-spacing: 0;
268 margin: 10px;
269}
270
271DIV.summary TABLE TD, DIV.summary TABLE TH {
272 border: solid thin #999999;
273 padding: 5px;
274 text-align: left;
275 vertical-align: top;
276}
277
278DIV.summary TABLE THEAD TH {
279 background: #eeeeee;
280}
281
282/* API documentation styles... */
283div.body h1 {
284 margin: 0;
285}
286div.body h2 {
287 margin-top: 1.5em;
288}
289div.body h3, div.body h4, div.body h5 {
290 margin-bottom: 0.5em;
291 margin-top: 1.5em;
292}
293.class, .enumeration, .function, .struct, .typedef, .union {
294 border-bottom: solid thin #999999;
295 margin-bottom: 0;
296 margin-top: 2em;
297}
298.description {
299 margin-top: 0.5em;
300}
301code, p.code, pre, ul.code li {
302 font-family: monaco, courier, monospace;
303 font-size: 90%;
304}
305ul.code, ul.contents, ul.subcontents {
306 list-style-type: none;
307 margin: 0;
308 padding-left: 0;
309}
310ul.code li {
311 margin: 0;
312}
313ul.contents > li {
314 margin-top: 1em;
315}
316ul.contents li ul.code, ul.contents li ul.subcontents {
317 padding-left: 2em;
318}
319div.body dl {
320 margin-left: 0;
321 margin-top: 0;
322}
323div.body dt {
324 font-style: italic;
325 margin-left: 0;
326 margin-top: 0;
327}
328div.body dd {
329 margin-bottom: 0.5em;
330}
331
332/* This is just for the HTML files generated with the framedhelp target */
333div.contents {
334 background: #e8e8e8;
335 border: solid thin black;
336 padding: 10px;
337}
338div.contents h1 {
339 font-size: 110%;
340}
341div.contents h2 {
342 font-size: 100%;
343}
344div.contents ul.contents {
345 font-size: 80%;
346}
ac884b6a
MS
347div.contents ul.subcontents li {
348 margin-left: 1em;
349 text-indent: -1em;
350}
5a738aea 351--></style>
ef416fc2 352</head>
353<body>
5a738aea 354<div class='body'>
ef416fc2 355<!--
321d8d57 356 Filter and backend programming header for CUPS.
ef416fc2 357
ca6b43fc 358 Copyright 2008-2014 by Apple Inc.
ef416fc2 359
360 These coded instructions, statements, and computer programs are the
bc44d920 361 property of Apple Inc. and are protected by Federal copyright
362 law. Distribution and use rights are outlined in the file "LICENSE.txt"
363 which should have been included with this file. If this file is
364 file is missing or damaged, see the license at "http://www.cups.org/".
ef416fc2 365-->
366
178cb736
MS
367<h1 class='title'>Filter and Backend Programming</h1>
368
5a738aea
MS
369<div class='summary'><table summary='General Information'>
370<thead>
371<tr>
ac884b6a 372 <th>Headers</th>
5a738aea 373 <th>cups/backend.h<br>
79e1d494 374 cups/sidechannel.h</th>
5a738aea
MS
375</tr>
376</thead>
377<tbody>
378<tr>
379 <th>Library</th>
380 <td>-lcups</td>
381</tr>
382<tr>
383 <th>See Also</th>
384 <td>Programming: <a href='api-overview.html' target='_top'>Introduction to CUPS Programming</a><br>
385 Programming: <a href='api-cups.html' target='_top'>CUPS API</a><br>
386 Programming: <a href='api-ppd.html' target='_top'>PPD API</a><br>
79e1d494 387 Programming: <a href='api-raster.html' target='_top'>Raster API</a><br>
b0f6947b
MS
388 Programming: <a href='postscript-driver.html' target='_top'>Developing PostScript Printer Drivers</a><br>
389 Programming: <a href='raster-driver.html' target='_top'>Developing Raster Printer Drivers</a><br>
10d09e33 390 Specifications: <a href='spec-design.html' target='_top'>CUPS Design Description</a></td>
5a738aea
MS
391</tr>
392</tbody>
393</table></div>
394<h2 class="title">Contents</h2>
395<ul class="contents">
5a738aea 396<li><a href="#OVERVIEW">Overview</a><ul class="subcontents">
0268488e 397 <li><a href="#SECURITY">Security Considerations</a></li>
88f9aafc 398 <li><a href="#SIGNALS">Canceled Jobs and Signal Handling</a></li>
f228370c 399 <li><a href="#PERMISSIONS">File Permissions</a></li>
0268488e
MS
400 <li><a href="#TEMPFILES">Temporary Files</a></li>
401 <li><a href="#COPIES">Copy Generation</a></li>
402 <li><a href="#EXITCODES">Exit Codes</a></li>
403 <li><a href="#ENVIRONMENT">Environment Variables</a></li>
404 <li><a href="#MESSAGES">Communicating with the Scheduler</a></li>
405 <li><a href="#COMMUNICATING_BACKEND">Communicating with the Backend</a></li>
406 <li><a href="#COMMUNICATING_FILTER">Communicating with Filters</a></li>
407 <li><a href="#SNMP">Doing SNMP Queries with Network Printers</a></li>
5a738aea 408</ul></li>
82d1ebb9 409<li><a href="#SANDBOXING">Sandboxing on OS X</a></li>
5a738aea 410<li><a href="#FUNCTIONS">Functions</a><ul class="code">
0268488e
MS
411 <li><a href="#cupsBackChannelRead" title="Read data from the backchannel.">cupsBackChannelRead</a></li>
412 <li><a href="#cupsBackChannelWrite" title="Write data to the backchannel.">cupsBackChannelWrite</a></li>
413 <li><a href="#cupsBackendDeviceURI" title="Get the device URI for a backend.">cupsBackendDeviceURI</a></li>
414 <li><a href="#cupsBackendReport" title="Write a device line from a backend.">cupsBackendReport</a></li>
415 <li><a href="#cupsSideChannelDoRequest" title="Send a side-channel command to a backend and wait for a response.">cupsSideChannelDoRequest</a></li>
416 <li><a href="#cupsSideChannelRead" title="Read a side-channel message.">cupsSideChannelRead</a></li>
417 <li><a href="#cupsSideChannelSNMPGet" title="Query a SNMP OID's value.">cupsSideChannelSNMPGet</a></li>
418 <li><a href="#cupsSideChannelSNMPWalk" title="Query multiple SNMP OID values.">cupsSideChannelSNMPWalk</a></li>
419 <li><a href="#cupsSideChannelWrite" title="Write a side-channel message.">cupsSideChannelWrite</a></li>
8b450588 420</ul></li>
5a738aea
MS
421<li><a href="#TYPES">Data Types</a><ul class="code">
422 <li><a href="#cups_backend_t" title="Backend exit codes">cups_backend_t</a></li>
423 <li><a href="#cups_sc_bidi_t" title="Bidirectional capabilities">cups_sc_bidi_t</a></li>
424 <li><a href="#cups_sc_command_t" title="Request command codes">cups_sc_command_t</a></li>
82f97232 425 <li><a href="#cups_sc_connected_t" title="Connectivity values">cups_sc_connected_t</a></li>
5a738aea
MS
426 <li><a href="#cups_sc_state_t" title="Printer state bits">cups_sc_state_t</a></li>
427 <li><a href="#cups_sc_status_t" title="Response status codes">cups_sc_status_t</a></li>
20fbc903 428 <li><a href="#cups_sc_walk_func_t" title="SNMP walk callback">cups_sc_walk_func_t</a></li>
5a738aea
MS
429</ul></li>
430<li><a href="#ENUMERATIONS">Constants</a><ul class="code">
431 <li><a href="#cups_backend_e" title="Backend exit codes">cups_backend_e</a></li>
79e1d494 432 <li><a href="#cups_sc_bidi_e" title="Bidirectional capability values">cups_sc_bidi_e</a></li>
5a738aea 433 <li><a href="#cups_sc_command_e" title="Request command codes">cups_sc_command_e</a></li>
82f97232 434 <li><a href="#cups_sc_connected_e" title="Connectivity values">cups_sc_connected_e</a></li>
5a738aea
MS
435 <li><a href="#cups_sc_state_e" title="Printer state bits">cups_sc_state_e</a></li>
436 <li><a href="#cups_sc_status_e" title="Response status codes">cups_sc_status_e</a></li>
437</ul></li>
0268488e 438</ul>
5a738aea 439<!--
22c9029b 440 Filter and backend programming introduction for CUPS.
ef416fc2 441
82d1ebb9 442 Copyright 2007-2014 by Apple Inc.
5a738aea 443 Copyright 1997-2006 by Easy Software Products, all rights reserved.
ef416fc2 444
5a738aea
MS
445 These coded instructions, statements, and computer programs are the
446 property of Apple Inc. and are protected by Federal copyright
447 law. Distribution and use rights are outlined in the file "LICENSE.txt"
448 which should have been included with this file. If this file is
449 file is missing or damaged, see the license at "http://www.cups.org/".
450-->
f7deaa1a 451
5a738aea 452<h2 class='title'><a name="OVERVIEW">Overview</a></h2>
ef416fc2 453
79e1d494
MS
454<p>Filters (which include printer drivers and port monitors) and backends
455are used to convert job files to a printable format and send that data to the
456printer itself. All of these programs use a common interface for processing
457print jobs and communicating status information to the scheduler. Each is run
458with a standard set of command-line arguments:<p>
ef416fc2 459
5a738aea 460<dl class="code">
f7deaa1a 461
5a738aea
MS
462 <dt>argv[1]</dt>
463 <dd>The job ID</dd>
ef416fc2 464
5a738aea
MS
465 <dt>argv[2]</dt>
466 <dd>The user printing the job</dd>
f7deaa1a 467
5a738aea
MS
468 <dt>argv[3]</dt>
469 <dd>The job name/title</dd>
f7deaa1a 470
5a738aea
MS
471 <dt>argv[4]</dt>
472 <dd>The number of copies to print</dd>
f7deaa1a 473
5a738aea
MS
474 <dt>argv[5]</dt>
475 <dd>The options that were provided when the job was submitted</dd>
f7deaa1a 476
5a738aea 477 <dt>argv[6]</dt>
79e1d494 478 <dd>The file to print (first program only)</dd>
5a738aea 479</dl>
f7deaa1a 480
5a738aea
MS
481<p>The scheduler runs one or more of these programs to print any given job. The
482first filter reads from the print file and writes to the standard output, while
483the remaining filters read from the standard input and write to the standard
484output. The backend is the last filter in the chain and writes to the
485device.</p>
f7deaa1a 486
178cb736
MS
487<p>Filters are always run as a non-privileged user, typically "lp", with no
488connection to the user's desktop. Backends are run either as a non-privileged
489user or as root if the file permissions do not allow user or group execution.
490The <a href="#PERMISSIONS">file permissions</a> section talks about this in
491more detail.</p>
492
ac884b6a
MS
493<h3><a name="SECURITY">Security Considerations</a></h3>
494
495<p>It is always important to use security programming practices. Filters and
eac3a0a0 496most backends are run as a non-privileged user, so the major security
ac884b6a
MS
497consideration is resource utilization - filters should not depend on unlimited
498amounts of CPU, memory, or disk space, and should protect against conditions
499that could lead to excess usage of any resource like infinite loops and
500unbounded recursion. In addition, filters must <em>never</em> allow the user to
501specify an arbitrary file path to a separator page, template, or other file
502used by the filter since that can lead to an unauthorized disclosure of
503information. <em>Always</em> treat input as suspect and validate it!</p>
504
4d301e69 505<p>If you are developing a backend that runs as root, make sure to check for
ac884b6a
MS
506potential buffer overflows, integer under/overflow conditions, and file
507accesses since these can lead to privilege escalations. When writing files,
508always validate the file path and <em>never</em> allow a user to determine
509where to store a file.</p>
510
511<blockquote><b>Note:</b>
512
513<p><em>Never</em> write files to a user's home directory. Aside from the
514security implications, CUPS is a network print service and as such the network
515user may not be the same as the local user and/or there may not be a local home
516directory to write to.</p>
517
518<p>In addition, some operating systems provide additional security mechanisms
178cb736 519that further limit file system access, even for backends running as root. On
82d1ebb9 520OS X, for example, no backend may write to a user's home directory. See the <a href="#SANDBOXING">Sandboxing on OS X</a> section for more information.</p>
ac884b6a
MS
521</blockquote>
522
f228370c 523<h3><a name="SIGNALS">Canceled Jobs and Signal Handling</a></h3>
22c9029b
MS
524
525<p>The scheduler sends <code>SIGTERM</code> when a printing job is canceled or
526held. Filters, backends, and port monitors <em>must</em> catch
527<code>SIGTERM</code> and perform any cleanup necessary to produce a valid output
528file or return the printer to a known good state. The recommended behavior is to
88f9aafc
MS
529end the output on the current page, preferably on the current line or object
530being printed.</p>
22c9029b 531
88f9aafc 532<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>
eac3a0a0
MS
533
534<pre class="example">
535#include &lt;signal.h&gt;>
536
537...
538
539int
540main(int argc, char *argv[])
541{
542 signal(SIGPIPE, SIG_IGN);
543
544 ...
545}
546</pre>
547
178cb736
MS
548<h3><a name="PERMISSIONS">File Permissions</a></h3>
549
550<p>For security reasons, CUPS will only run filters and backends that are owned
4d301e69
MS
551by root and do not have world or group write permissions. The recommended
552permissions for filters and backends are 0555 - read and execute but no write.
553Backends that must run as root should use permissions of 0500 - read and execute
554by root, no access for other users. Write permissions can be enabled for the
555root user only.</p>
178cb736
MS
556
557<p>To avoid a warning message, the directory containing your filter(s) must also
4d301e69
MS
558be owned by root and have world and group write disabled - permissions of 0755
559or 0555 are strongly encouraged.</p>
178cb736 560
ac884b6a
MS
561<h3><a name="TEMPFILES">Temporary Files</a></h3>
562
563<p>Temporary files should be created in the directory specified by the
564"TMPDIR" environment variable. The
565<a href="#cupsTempFile2"><code>cupsTempFile2</code></a> function can be
566used to safely create temporary files in this directory.</p>
567
568<h3><a name="COPIES">Copy Generation</a></h3>
569
570<p>The <code>argv[4]</code> argument specifies the number of copies to produce
571of the input file. In general, you should only generate copies if the
572<em>filename</em> argument is supplied. The only exception to this are
573filters that produce device-independent PostScript output, since the PostScript
574filter <var>pstops</var> is responsible for generating copies of PostScript
575files.</p>
576
5a738aea 577<h3><a name="EXITCODES">Exit Codes</a></h3>
f7deaa1a 578
5a738aea
MS
579<p>Filters must exit with status 0 when they successfully generate print data
580or 1 when they encounter an error. Backends can return any of the
581<a href="#cups_backend_t"><code>cups_backend_t</code></a> constants.</p>
f7deaa1a 582
5a738aea 583<h3><a name="ENVIRONMENT">Environment Variables</a></h3>
f7deaa1a 584
79e1d494
MS
585<p>The following environment variables are defined by the printing system
586when running print filters and backends:</p>
f7deaa1a 587
5a738aea 588<dl class="code">
f7deaa1a 589
acb056cb 590 <dt>APPLE_LANGUAGE</dt>
5a738aea 591 <dd>The Apple language identifier associated with the job
f3c17241 592 (OS X only).</dd>
f7deaa1a 593
5a738aea
MS
594 <dt>CHARSET</dt>
595 <dd>The job character set, typically "utf-8".</dd>
f7deaa1a 596
5a738aea
MS
597 <dt>CLASS</dt>
598 <dd>When a job is submitted to a printer class, contains the name of
599 the destination printer class. Otherwise this environment
600 variable will not be set.</dd>
f7deaa1a 601
5a738aea
MS
602 <dt>CONTENT_TYPE</dt>
603 <dd>The MIME type associated with the file (e.g.
604 application/postscript).</dd>
f7deaa1a 605
5a738aea 606 <dt>CUPS_CACHEDIR</dt>
79e1d494
MS
607 <dd>The directory where cache files can be stored. Cache files can be
608 used to retain information between jobs or files in a job.</dd>
f7deaa1a 609
5a738aea 610 <dt>CUPS_DATADIR</dt>
79e1d494 611 <dd>The directory where (read-only) CUPS data files can be found.</dd>
f7deaa1a 612
758a062f
MS
613 <dt>CUPS_FILETYPE</dt>
614 <dd>The type of file being printed: "job-sheet" for a banner page and
615 "document" for a regular print file.</dd>
616
5a738aea
MS
617 <dt>CUPS_SERVERROOT</dt>
618 <dd>The root directory of the server.</dd>
f7deaa1a 619
5a738aea
MS
620 <dt>DEVICE_URI</dt>
621 <dd>The device-uri associated with the printer.</dd>
f7deaa1a 622
5a738aea
MS
623 <dt>FINAL_CONTENT_TYPE</dt>
624 <dd>The MIME type associated with the printer (e.g.
625 application/vnd.cups-postscript).</dd>
f7deaa1a 626
5a738aea
MS
627 <dt>LANG</dt>
628 <dd>The language locale associated with the job.</dd>
f7deaa1a 629
5a738aea
MS
630 <dt>PPD</dt>
631 <dd>The full pathname of the PostScript Printer Description (PPD)
632 file for this printer.</dd>
f7deaa1a 633
5a738aea 634 <dt>PRINTER</dt>
79e1d494 635 <dd>The queue name of the class or printer.</dd>
f7deaa1a 636
5a738aea
MS
637 <dt>RIP_CACHE</dt>
638 <dd>The recommended amount of memory to use for Raster Image
639 Processors (RIPs).</dd>
f7deaa1a 640
79e1d494
MS
641 <dt>TMPDIR</dt>
642 <dd>The directory where temporary files should be created.</dd>
643
5a738aea 644</dl>
f7deaa1a 645
5a738aea 646<h3><a name="MESSAGES">Communicating with the Scheduler</a></h3>
f7deaa1a 647
79e1d494
MS
648<p>Filters and backends communicate with the scheduler by writing messages
649to the standard error file. The scheduler reads messages from all filters in
650a job and processes the message based on its prefix. For example, the following
651code sets the current printer state message to "Printing page 5":</p>
f7deaa1a 652
5a738aea
MS
653<pre class="example">
654int page = 5;
f7deaa1a 655
5a738aea 656fprintf(stderr, "INFO: Printing page %d\n", page);
f7deaa1a 657</pre>
658
5a738aea
MS
659<p>Each message is a single line of text starting with one of the following
660prefix strings:</p>
661
662<dl class="code">
663
664 <dt>ALERT: message</dt>
665 <dd>Sets the printer-state-message attribute and adds the specified
666 message to the current error log file using the "alert" log level.</dd>
667
668 <dt>ATTR: attribute=value [attribute=value]</dt>
669 <dd>Sets the named printer or job attribute(s). Typically this is used
88f9aafc
MS
670 to set the <code>marker-colors</code>, <code>marker-high-levels</code>,
671 <code>marker-levels</code>, <code>marker-low-levels</code>,
75bd9771
MS
672 <code>marker-message</code>, <code>marker-names</code>,
673 <code>marker-types</code>, <code>printer-alert</code>, and
674 <code>printer-alert-description</code> printer attributes. Standard
675 <code>marker-types</code> values are listed in <a href='#TABLE1'>Table
ca6b43fc 676 1</a>. String values need special handling - see <a href="#ATTR_STRINGS">Reporting Attribute String Values</a> below.</dd>
5a738aea
MS
677
678 <dt>CRIT: message</dt>
679 <dd>Sets the printer-state-message attribute and adds the specified
680 message to the current error log file using the "critical" log
681 level.</dd>
682
683 <dt>DEBUG: message</dt>
684 <dd>Sets the printer-state-message attribute and adds the specified
685 message to the current error log file using the "debug" log level.</dd>
686
687 <dt>DEBUG2: message</dt>
688 <dd>Sets the printer-state-message attribute and adds the specified
689 message to the current error log file using the "debug2" log level.</dd>
690
691 <dt>EMERG: message</dt>
692 <dd>Sets the printer-state-message attribute and adds the specified
693 message to the current error log file using the "emergency" log
694 level.</dd>
695
696 <dt>ERROR: message</dt>
697 <dd>Sets the printer-state-message attribute and adds the specified
79e1d494
MS
698 message to the current error log file using the "error" log level.
699 Use "ERROR:" messages for non-persistent processing errors.</dd>
5a738aea
MS
700
701 <dt>INFO: message</dt>
702 <dd>Sets the printer-state-message attribute. If the current log level
703 is set to "debug2", also adds the specified message to the current error
704 log file using the "info" log level.</dd>
705
706 <dt>NOTICE: message</dt>
707 <dd>Sets the printer-state-message attribute and adds the specified
708 message to the current error log file using the "notice" log level.</dd>
709
710 <dt>PAGE: page-number #-copies</dt>
711 <dt>PAGE: total #-pages</dt>
712 <dd>Adds an entry to the current page log file. The first form adds
713 #-copies to the job-media-sheets-completed attribute. The second
714 form sets the job-media-sheets-completed attribute to #-pages.</dd>
715
20fbc903
MS
716 <dt>PPD: keyword=value [keyword=value ...]</dt>
717 <dd>Changes or adds keywords to the printer's PPD file. Typically
718 this is used to update installable options or default media settings
719 based on the printer configuration.</dd>
720
5a738aea
MS
721 <dt>STATE: + printer-state-reason [printer-state-reason ...]</dt>
722 <dt>STATE: - printer-state-reason [printer-state-reason ...]</dt>
88f9aafc
MS
723 <dd>Sets or clears printer-state-reason keywords for the current queue.
724 Typically this is used to indicate persistent media, ink, toner, and
725 configuration conditions or errors on a printer.
79e1d494 726 <a href='#TABLE2'>Table 2</a> lists the standard state keywords -
88f9aafc
MS
727 use vendor-prefixed ("com.example.foo") keywords for custom states. See
728 <a href="#MANAGING_STATE">Managing Printer State in a Filter</a> for more
729 information.
5a738aea
MS
730
731 <dt>WARNING: message</dt>
732 <dd>Sets the printer-state-message attribute and adds the specified
733 message to the current error log file using the "warning" log
734 level.</dd>
735
736</dl>
737
738<p>Messages without one of these prefixes are treated as if they began with
739the "DEBUG:" prefix string.</p>
740
79e1d494
MS
741<div class='table'><table width='80%' summary='Table 1: Standard marker-types Values'>
742<caption>Table 1: <a name='TABLE1'>Standard marker-types Values</a></caption>
743<thead>
744<tr>
745 <th>marker-type</th>
746 <th>Description</th>
747</tr>
748</thead>
749<tbody>
750<tr>
751 <td>developer</td>
752 <td>Developer unit</td>
753</tr>
754<tr>
755 <td>fuser</td>
756 <td>Fuser unit</td>
757</tr>
758<tr>
ca6b43fc 759 <td>fuser-cleaning-pad</td>
79e1d494
MS
760 <td>Fuser cleaning pad</td>
761</tr>
762<tr>
ca6b43fc 763 <td>fuser-oil</td>
79e1d494
MS
764 <td>Fuser oil</td>
765</tr>
766<tr>
767 <td>ink</td>
768 <td>Ink supply</td>
769</tr>
770<tr>
771 <td>opc</td>
772 <td>Photo conductor</td>
773</tr>
774<tr>
ca6b43fc 775 <td>solid-wax</td>
79e1d494
MS
776 <td>Wax supply</td>
777</tr>
778<tr>
779 <td>staples</td>
780 <td>Staple supply</td>
781</tr>
782<tr>
783 <td>toner</td>
784 <td>Toner supply</td>
785</tr>
786<tr>
ca6b43fc 787 <td>transfer-unit</td>
79e1d494
MS
788 <td>Transfer unit</td>
789</tr>
790<tr>
ca6b43fc 791 <td>waste-ink</td>
79e1d494
MS
792 <td>Waste ink tank</td>
793</tr>
794<tr>
ca6b43fc 795 <td>waste-toner</td>
79e1d494
MS
796 <td>Waste toner tank</td>
797</tr>
798<tr>
ca6b43fc 799 <td>waste-wax</td>
79e1d494
MS
800 <td>Waste wax tank</td>
801</tr>
802</tbody>
803</table></div>
804
805<br>
806
807<div class='table'><table width='80%' summary='Table 2: Standard State Keywords'>
808<caption>Table 2: <a name='TABLE2'>Standard State Keywords</a></caption>
809<thead>
810<tr>
811 <th>Keyword</th>
812 <th>Description</th>
813</tr>
814</thead>
815<tbody>
816<tr>
817 <td>connecting-to-device</td>
88f9aafc 818 <td>Connecting to printer but not printing yet.</td>
79e1d494
MS
819</tr>
820<tr>
821 <td>cover-open</td>
88f9aafc 822 <td>The printer's cover is open.</td>
79e1d494
MS
823</tr>
824<tr>
825 <td>input-tray-missing</td>
88f9aafc 826 <td>The paper tray is missing.</td>
79e1d494
MS
827</tr>
828<tr>
829 <td>marker-supply-empty</td>
88f9aafc 830 <td>The printer is out of ink.</td>
79e1d494
MS
831</tr>
832<tr>
833 <td>marker-supply-low</td>
88f9aafc 834 <td>The printer is almost out of ink.</td>
79e1d494
MS
835</tr>
836<tr>
837 <td>marker-waste-almost-full</td>
88f9aafc 838 <td>The printer's waste bin is almost full.</td>
79e1d494
MS
839</tr>
840<tr>
841 <td>marker-waste-full</td>
88f9aafc 842 <td>The printer's waste bin is full.</td>
79e1d494
MS
843</tr>
844<tr>
845 <td>media-empty</td>
88f9aafc 846 <td>The paper tray (any paper tray) is empty.</td>
79e1d494
MS
847</tr>
848<tr>
849 <td>media-jam</td>
88f9aafc 850 <td>There is a paper jam.</td>
79e1d494
MS
851</tr>
852<tr>
853 <td>media-low</td>
88f9aafc
MS
854 <td>The paper tray (any paper tray) is almost empty.</td>
855</tr>
856<tr>
857 <td>media-needed</td>
858 <td>The paper tray needs to be filled (for a job that is printing).</td>
79e1d494
MS
859</tr>
860<tr>
861 <td>paused</td>
88f9aafc 862 <td>Stop the printer.</td>
79e1d494
MS
863</tr>
864<tr>
865 <td>timed-out</td>
88f9aafc 866 <td>Unable to connect to printer.</td>
79e1d494
MS
867</tr>
868<tr>
869 <td>toner-empty</td>
88f9aafc 870 <td>The printer is out of toner.</td>
79e1d494
MS
871</tr>
872<tr>
873 <td>toner-low</td>
88f9aafc
MS
874 <td>The printer is low on toner.</td>
875</tr>
876</tbody>
877</table></div>
878
ca6b43fc
MS
879
880<h4><a name="ATTR_STRINGS">Reporting Attribute String Values</a></h4>
881
882<p>When reporting string values using "ATTR:" messages, a filter or backend must take special care to appropriately quote those values. The scheduler uses the CUPS option parsing code for attributes, so the general syntax is:</p>
883
884<pre class="example">
885name=simple
886name=simple,simple,...
887name='complex value'
888name="complex value"
889name='"complex value"','"complex value"',...
890</pre>
891
892<p>Simple values are strings that do not contain spaces, quotes, backslashes, or the comma and can be placed verbatim in the "ATTR:" message, for example:</p>
893
894<pre class="example">
895int levels[4] = { 40, 50, 60, 70 }; /* CMYK */
896
897fputs("ATTR: marker-colors=#00FFFF,#FF00FF,#FFFF00,#000000\n", stderr);
898fputs("ATTR: marker-high-levels=100,100,100,100\n", stderr);
899fprintf(stderr, "ATTR: marker-levels=%d,%d,%d,%d\n", levels[0], levels[1],
900 levels[2], levels[3], levels[4]);
901fputs("ATTR: marker-low-levels=5,5,5,5\n", stderr);
902fputs("ATTR: marker-types=toner,toner,toner,toner\n", stderr);
903</pre>
904
905<p>Complex values that contains spaces, quotes, backslashes, or the comma must be quoted. For a single value a single set of quotes is sufficient:</p>
906
907<pre class="example">
908fputs("ATTR: marker-message='Levels shown are approximate.'\n", stderr);
909</pre>
910
911<p>When multiple values are reported, each value must be enclosed by a set of single and double quotes:</p>
912
913<pre class="example">
914fputs("ATTR: marker-names='\"Cyan Toner\"','\"Magenta Toner\"',"
915 "'\"Yellow Toner\"','\"Black Toner\"'\n", stderr);
916</pre>
917
918<p>The IPP backend includes a <var>quote_string</var> function that may be used to properly quote a complex value in an "ATTR:" message:</p>
919
920<pre class="example">
921static const char * /* O - Quoted string */
922quote_string(const char *s, /* I - String */
923 char *q, /* I - Quoted string buffer */
924 size_t qsize) /* I - Size of quoted string buffer */
925{
926 char *qptr, /* Pointer into string buffer */
927 *qend; /* End of string buffer */
928
929
930 qptr = q;
931 qend = q + qsize - 5;
932
933 if (qend &lt; q)
934 {
935 *q = '\0';
936 return (q);
937 }
938
939 *qptr++ = '\'';
940 *qptr++ = '\"';
941
942 while (*s && qptr &lt; qend)
943 {
944 if (*s == '\\' || *s == '\"' || *s == '\'')
945 {
946 if (qptr &lt; (qend - 4))
947 {
948 *qptr++ = '\\';
949 *qptr++ = '\\';
950 *qptr++ = '\\';
951 }
952 else
953 break;
954 }
955
956 *qptr++ = *s++;
957 }
958
959 *qptr++ = '\"';
960 *qptr++ = '\'';
961 *qptr = '\0';
962
963 return (q);
964}
965</pre>
966
967
88f9aafc
MS
968<h4><a name="MANAGING_STATE">Managing Printer State in a Filter</a></h4>
969
970<p>Filters are responsible for managing the state keywords they set using
971"STATE:" messages. Typically you will update <em>all</em> of the keywords that
972are used by the filter at startup, for example:</p>
973
974<pre class="example">
975if (foo_condition != 0)
976 fputs("STATE: +com.example.foo\n", stderr);
977else
978 fputs("STATE: -com.example.foo\n", stderr);
979
980if (bar_condition != 0)
981 fputs("STATE: +com.example.bar\n", stderr);
982else
983 fputs("STATE: -com.example.bar\n", stderr);
984</pre>
985
986<p>Then as conditions change, your filter sends "STATE: +keyword" or "STATE:
987-keyword" messages as necessary to set or clear the corresponding keyword,
988respectively.</p>
989
990<p>State keywords are often used to notify the user of issues that span across
991jobs, for example "media-empty-warning" that indicates one or more paper trays
992are empty. These keywords should not be cleared unless the corresponding issue
993no longer exists.</p>
994
995<p>Filters should clear job-related keywords on startup and exit so that they
996do not remain set between jobs. For example, "connecting-to-device" is a job
997sub-state and not an issue that applies when a job is not printing.</p>
998
999<blockquote><b>Note:</b>
1000
1001<p>"STATE:" messages often provide visible alerts to the user. For example,
f3c17241 1002on OS X setting a printer-state-reason value with an "-error" or
88f9aafc
MS
1003"-warning" suffix will cause the printer's dock item to bounce if the
1004corresponding reason is localized with a cupsIPPReason keyword in the
1005printer's PPD file.</p>
1006
1007<p>When providing a vendor-prefixed keyword, <em>always</em> provide the
1008corresponding standard keyword (if any) to allow clients to respond to the
1009condition correctly. For example, if you provide a vendor-prefixed keyword
1010for a low cyan ink condition ("com.example.cyan-ink-low") you must also set the
1011"marker-supply-low-warning" keyword. In such cases you should also refrain
1012from localizing the vendor-prefixed keyword in the PPD file - otherwise both
1013the generic and vendor-specific keyword will be shown in the user
1014interface.</p>
1015
7374e9e5 1016</blockquote>
88f9aafc
MS
1017
1018<h4><a name="REPORTING_SUPPLIES">Reporting Supply Levels</a></h4>
1019
1020<p>CUPS tracks several "marker-*" attributes for ink/toner supply level
1021reporting. These attributes allow applications to display the current supply
1022levels for a printer without printer-specific software. <a href="#TABLE3">Table 3</a> lists the marker attributes and what they represent.</p>
1023
1024<p>Filters set marker attributes by sending "ATTR:" messages to stderr. For
1025example, a filter supporting an inkjet printer with black and tri-color ink
1026cartridges would use the following to initialize the supply attributes:</p>
1027
1028<pre class="example">
1029fputs("ATTR: marker-colors=#000000,#00FFFF#FF00FF#FFFF00\n", stderr);
1030fputs("ATTR: marker-low-levels=5,10\n", stderr);
1031fputs("ATTR: marker-names=Black,Tri-Color\n", stderr);
1032fputs("ATTR: marker-types=ink,ink\n", stderr);
1033</pre>
1034
1035<p>Then periodically the filter queries the printer for its current supply
1036levels and updates them with a separate "ATTR:" message:</p>
1037
1038<pre class="example">
1039int black_level, tri_level;
1040...
1041fprintf(stderr, "ATTR: marker-levels=%d,%d\n", black_level, tri_level);
1042</pre>
1043
1044<div class='table'><table width='80%' summary='Table 3: Supply Level Attributes'>
1045<caption>Table 3: <a name='TABLE3'>Supply Level Attributes</a></caption>
1046<thead>
1047<tr>
1048 <th>Attribute</th>
1049 <th>Description</th>
1050</tr>
1051</thead>
1052<tbody>
1053<tr>
1054 <td>marker-colors</td>
1055 <td>A list of comma-separated colors; each color is either "none" or one or
1056 more hex-encoded sRGB colors of the form "#RRGGBB".</td>
1057</tr>
1058<tr>
1059 <td>marker-high-levels</td>
1060 <td>A list of comma-separated "almost full" level values from 0 to 100; a
1061 value of 100 should be used for supplies that are consumed/emptied like ink
1062 cartridges.</td>
1063</tr>
1064<tr>
1065 <td>marker-levels</td>
1066 <td>A list of comma-separated level values for each supply. A value of -1
1067 indicates the level is unavailable, -2 indicates unknown, and -3 indicates
1068 the level is unknown but has not yet reached capacity. Values from 0 to 100
1069 indicate the corresponding percentage.</td>
1070</tr>
1071<tr>
1072 <td>marker-low-levels</td>
1073 <td>A list of comma-separated "almost empty" level values from 0 to 100; a
1074 value of 0 should be used for supplies that are filled like waste ink
1075 tanks.</td>
1076</tr>
1077<tr>
1078 <td>marker-message</td>
1079 <td>A human-readable supply status message for the user like "12 pages of
1080 ink remaining."</td>
1081</tr>
1082<tr>
1083 <td>marker-names</td>
1084 <td>A list of comma-separated supply names like "Cyan Ink", "Fuser",
1085 etc.</td>
1086</tr>
1087<tr>
1088 <td>marker-types</td>
1089 <td>A list of comma-separated supply types; the types are listed in
1090 <a href="#TABLE1">Table 1</a>.</td>
79e1d494
MS
1091</tr>
1092</tbody>
1093</table></div>
1094
20fbc903 1095<h3><a name="COMMUNICATING_BACKEND">Communicating with the Backend</a></h3>
5a738aea
MS
1096
1097<p>Filters can communicate with the backend via the
1098<a href="#cupsBackChannelRead"><code>cupsBackChannelRead</code></a> and
1099<a href="#cupsSideChannelDoRequest"><code>cupsSideChannelDoRequest</code></a>
22c9029b 1100functions. The
5a738aea
MS
1101<a href="#cupsBackChannelRead"><code>cupsBackChannelRead</code></a> function
1102reads data that has been sent back from the device and is typically used to
1103obtain status and configuration information. For example, the following code
1104polls the backend for back-channel data:</p>
1105
1106<pre class="example">
1107#include &lt;cups/cups.h&gt;
1108
1109char buffer[8192];
1110ssize_t bytes;
1111
1112/* Use a timeout of 0.0 seconds to poll for back-channel data */
1113bytes = cupsBackChannelRead(buffer, sizeof(buffer), 0.0);
1114</pre>
f7deaa1a 1115
79e1d494
MS
1116<p>Filters can also use <code>select()</code> or <code>poll()</code> on the
1117back-channel file descriptor (3 or <code>CUPS_BC_FD</code>) to read data only
1118when it is available.</p>
1119
1120<p>The
5a738aea
MS
1121<a href="#cupsSideChannelDoRequest"><code>cupsSideChannelDoRequest</code></a>
1122function allows you to get out-of-band status information and do synchronization
1123with the device. For example, the following code gets the current IEEE-1284
1124device ID string from the backend:</p>
1125
1126<pre class="example">
f7deaa1a 1127#include &lt;cups/sidechannel.h&gt;
1128
1129char data[2049];
1130int datalen;
5a738aea 1131<a href="#cups_sc_status_t">cups_sc_status_t</a> status;
f7deaa1a 1132
79e1d494
MS
1133/* Tell cupsSideChannelDoRequest() how big our buffer is, less 1 byte for
1134 nul-termination... */
f7deaa1a 1135datalen = sizeof(data) - 1;
1136
1137/* Get the IEEE-1284 device ID, waiting for up to 1 second */
5a738aea 1138status = <a href="#cupsSideChannelDoRequest">cupsSideChannelDoRequest</a>(CUPS_SC_CMD_GET_DEVICE_ID, data, &amp;datalen, 1.0);
f7deaa1a 1139
1140/* Use the returned value if OK was returned and the length is non-zero */
7374e9e5 1141if (status == CUPS_SC_STATUS_OK &amp;&amp; datalen > 0)
f7deaa1a 1142 data[datalen] = '\0';
1143else
1144 data[0] = '\0';
1145</pre>
1146
88f9aafc
MS
1147<h4><a name="DRAIN_OUTPUT">Forcing All Output to a Printer</a></h4>
1148
1149<p>The
1150<a href="#cupsSideChannelDoRequest"><code>cupsSideChannelDoRequest</code></a>
1151function allows you to tell the backend to send all pending data to the printer.
1152This is most often needed when sending query commands to the printer. For example:</p>
1153
1154<pre class="example">
1155#include &lt;cups/cups.h&gt;
1156#include &lt;cups/sidechannel.h&gt;
1157
1158char data[1024];
1159int datalen = sizeof(data);
1160<a href="#cups_sc_status_t">cups_sc_status_t</a> status;
1161
1162/* Flush pending output to stdout */
1163fflush(stdout);
1164
1165/* Drain output to backend, waiting for up to 30 seconds */
1166status = <a href="#cupsSideChannelDoRequest">cupsSideChannelDoRequest</a>(CUPS_SC_CMD_DRAIN_OUTPUT, data, &amp;datalen, 30.0);
1167
1168/* Read the response if the output was sent */
1169if (status == CUPS_SC_STATUS_OK)
1170{
1171 ssize_t bytes;
1172
1173 /* Wait up to 10.0 seconds for back-channel data */
1174 bytes = cupsBackChannelRead(data, sizeof(data), 10.0);
1175 /* do something with the data from the printer */
1176}
1177</pre>
1178
20fbc903
MS
1179<h3><a name="COMMUNICATING_FILTER">Communicating with Filters</a></h3>
1180
5a738aea
MS
1181<p>Backends communicate with filters using the reciprocal functions
1182<a href="#cupsBackChannelWrite"><code>cupsBackChannelWrite</code></a>,
1183<a href="#cupsSideChannelRead"><code>cupsSideChannelRead</code></a>, and
1184<a href="#cupsSideChannelWrite"><code>cupsSideChannelWrite</code></a>. We
1185recommend writing back-channel data using a timeout of 1.0 seconds:</p>
f7deaa1a 1186
5a738aea
MS
1187<pre class="example">
1188#include &lt;cups/cups.h&gt;
f7deaa1a 1189
5a738aea
MS
1190char buffer[8192];
1191ssize_t bytes;
f7deaa1a 1192
79e1d494
MS
1193/* Obtain data from printer/device */
1194...
1195
5a738aea
MS
1196/* Use a timeout of 1.0 seconds to give filters a chance to read */
1197cupsBackChannelWrite(buffer, bytes, 1.0);
f7deaa1a 1198</pre>
1199
5a738aea
MS
1200<p>The <a href="#cupsSideChannelRead"><code>cupsSideChannelRead</code></a>
1201function reads a side-channel command from a filter, driver, or port monitor.
1202Backends can either poll for commands using a <code>timeout</code> of 0.0, wait
1203indefinitely for commands using a <code>timeout</code> of -1.0 (probably in a
1204separate thread for that purpose), or use <code>select</code> or
1205<code>poll</code> on the <code>CUPS_SC_FD</code> file descriptor (4) to handle
20fbc903 1206input and output on several file descriptors at the same time.</p>
5a738aea
MS
1207
1208<p>Once a command is processed, the backend uses the
1209<a href="#cupsSideChannelWrite"><code>cupsSideChannelWrite</code></a> function
1210to send its response. For example, the following code shows how to poll for a
1211side-channel command and respond to it:</p>
1212
1213<pre class="example">
f7deaa1a 1214#include &lt;cups/sidechannel.h&gt;
1215
5a738aea
MS
1216<a href="#cups_sc_command_t">cups_sc_command_t</a> command;
1217<a href="#cups_sc_status_t">cups_sc_status_t</a> status;
20fbc903
MS
1218char data[2048];
1219int datalen = sizeof(data);
f7deaa1a 1220
1221/* Poll for a command... */
20fbc903 1222if (!<a href="#cupsSideChannelRead">cupsSideChannelRead</a>(&amp;command, &amp;status, data, &amp;datalen, 0.0))
f7deaa1a 1223{
f7deaa1a 1224 switch (command)
1225 {
20fbc903 1226 /* handle supported commands, fill data/datalen/status with values as needed */
f7deaa1a 1227
1228 default :
1229 status = CUPS_SC_STATUS_NOT_IMPLEMENTED;
1230 datalen = 0;
1231 break;
1232 }
1233
1234 /* Send a response... */
5a738aea 1235 <a href="#cupsSideChannelWrite">cupsSideChannelWrite</a>(command, status, data, datalen, 1.0);
f7deaa1a 1236}
1237</pre>
ac884b6a
MS
1238
1239<h3><a name="SNMP">Doing SNMP Queries with Network Printers</a></h3>
1240
1241<p>The Simple Network Management Protocol (SNMP) allows you to get the current
1242status, page counter, and supply levels from most network printers. Every
1243piece of information is associated with an Object Identifier (OID), and
1244every printer has a <em>community</em> name associated with it. OIDs can be
1245queried directly or by "walking" over a range of OIDs with a common prefix.</p>
1246
20fbc903
MS
1247<p>The two CUPS SNMP functions provide a simple API for querying network
1248printers through the side-channel interface. Each accepts a string containing
1249an OID like ".1.3.6.1.2.1.43.10.2.1.4.1.1" (the standard page counter OID)
1250along with a timeout for the query.</p>
ac884b6a 1251
20fbc903
MS
1252<p>The <a href="#cupsSideChannelSNMPGet"><code>cupsSideChannelSNMPGet</code></a>
1253function queries a single OID and returns the value as a string in a buffer
1254you supply:</p>
ac884b6a
MS
1255
1256<pre class="example">
20fbc903 1257#include &lt;cups/sidechannel.h&gt;
ac884b6a 1258
20fbc903
MS
1259char data[512];
1260int datalen = sizeof(data);
ac884b6a 1261
20fbc903
MS
1262if (<a href="#cupsSideChannelSNMPGet">cupsSideChannelSNMPGet</a>(".1.3.6.1.2.1.43.10.2.1.4.1.1", data, &amp;datalen, 5.0)
1263 == CUPS_SC_STATUS_OK)
ac884b6a
MS
1264{
1265 /* Do something with the value */
20fbc903 1266 printf("Page counter is: %s\n", data);
ac884b6a
MS
1267}
1268</pre>
1269
20fbc903
MS
1270<p>The
1271<a href="#cupsSideChannelSNMPWalk"><code>cupsSideChannelSNMPWalk</code></a>
1272function allows you to query a whole group of OIDs, calling a function of your
1273choice for each OID that is found:</p>
ac884b6a
MS
1274
1275<pre class="example">
20fbc903 1276#include &lt;cups/sidechannel.h&gt;
ac884b6a
MS
1277
1278void
20fbc903 1279my_callback(const char *oid, const char *data, int datalen, void *context)
ac884b6a
MS
1280{
1281 /* Do something with the value */
20fbc903 1282 printf("%s=%s\n", oid, data);
ac884b6a
MS
1283}
1284
20fbc903
MS
1285...
1286
ac884b6a
MS
1287void *my_data;
1288
20fbc903 1289<a href="#cupsSideChannelSNMPWalk">cupsSNMPSideChannelWalk</a>(".1.3.6.1.2.1.43", 5.0, my_callback, my_data);
ac884b6a 1290</pre>
82d1ebb9
MS
1291
1292<h2><a name="SANDBOXING">Sandboxing on OS X</a></h2>
1293
1294<p>Starting with OS X 10.6, filters and backends are run inside a security "sandbox" which further limits (beyond the normal UNIX user/group permissions) what a filter or backend can do. This helps to both secure the printing system from malicious software and enforce the functional separation of components in the CUPS filter chain. What follows is a list of actions that are explicitly allowed for all filters and backends:</p>
1295
1296<ol>
1297
1298 <li>Reading of files: pursuant to normal UNIX file permissions, filters and backends can read files for the current job from the <var>/private/var/spool/cups</var> directory and other files on mounted filesystems <em>except</em> for user home directories under <var>/Users</var>.</li>
1299
1300 <li>Writing of files: pursuant to normal UNIX file permissions, filters and backends can read/write files to the cache directory specified by the <code>CUPS_CACHEDIR</code> environment variable, to the state directory specified by the <code>CUPS_STATEDIR</code> environment variable, to the temporary directory specified by the <code>TMPDIR</code> environment variable, and under the <var>/private/var/db</var>, <var>/private/var/folders</var>, <var>/private/var/lib</var>, <var>/private/var/mysql</var>, <var>/private/var/run</var>, <var>/private/var/spool</var> (except <var>/private/var/spool/cups</var>), <var>/Library/Application&nbsp;Support</var>, <var>/Library/Caches</var>, <var>/Library/Logs</var>, <var>/Library/Preferences</var>, <var>/Library/WebServer</var>, and <var>/Users/Shared</var> directories.</li>
1301
1302 <li>Execution of programs: pursuant to normal UNIX file permissions, filters and backends can execute any program not located under the <var>/Users</var> directory. Child processes inherit the sandbox and are subject to the same restrictions as the parent.</li>
1303
1304 <li>Bluetooth and USB: backends can access Bluetooth and USB printers through IOKit. <em>Filters cannot access Bluetooth and USB printers directly.</em></li>
1305
abcaca57 1306 <li>Network: filters and backends can access UNIX domain sockets under the <var>/private/tmp</var>, <var>/private/var/run</var>, and <var>/private/var/tmp</var> directories. Backends can also create IPv4 and IPv6 TCP (outgoing) and UDP (incoming and outgoing) socket, and bind to local source ports. <em>Filters cannot directly create IPv4 and IPv6 TCP or UDP sockets.</em></li>
82d1ebb9
MS
1307
1308 <li>Notifications: filters and backends can send notifications via the Darwin <code>notify_post()</code> API.</li>
1309
1310</ol>
1311
1312<blockquote><b>Note:</b> The sandbox profile used in CUPS 2.0 still allows some actions that are not listed above - these privileges will be removed over time until the profile matches the list above.</blockquote>
20fbc903 1313<h2 class="title"><a name="FUNCTIONS">Functions</a></h2>
f3c17241 1314<h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsBackChannelRead">cupsBackChannelRead</a></h3>
5a738aea
MS
1315<p class="description">Read data from the backchannel.</p>
1316<p class="code">
1317ssize_t cupsBackChannelRead (<br>
1318&nbsp;&nbsp;&nbsp;&nbsp;char *buffer,<br>
1319&nbsp;&nbsp;&nbsp;&nbsp;size_t bytes,<br>
1320&nbsp;&nbsp;&nbsp;&nbsp;double timeout<br>
1321);</p>
1322<h4 class="parameters">Parameters</h4>
1323<dl>
1324<dt>buffer</dt>
79e1d494 1325<dd class="description">Buffer to read into</dd>
5a738aea
MS
1326<dt>bytes</dt>
1327<dd class="description">Bytes to read</dd>
1328<dt>timeout</dt>
79e1d494 1329<dd class="description">Timeout in seconds, typically 0.0 to poll</dd>
5a738aea
MS
1330</dl>
1331<h4 class="returnvalue">Return Value</h4>
1332<p class="description">Bytes read or -1 on error</p>
1333<h4 class="discussion">Discussion</h4>
79e1d494
MS
1334<p class="discussion">Reads up to &quot;bytes&quot; bytes from the backchannel/backend. The &quot;timeout&quot;
1335parameter controls how many seconds to wait for the data - use 0.0 to
1336return immediately if there is no data, -1.0 to wait for data indefinitely.
ef416fc2 1337
5a738aea 1338</p>
f3c17241 1339<h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsBackChannelWrite">cupsBackChannelWrite</a></h3>
5a738aea
MS
1340<p class="description">Write data to the backchannel.</p>
1341<p class="code">
1342ssize_t cupsBackChannelWrite (<br>
1343&nbsp;&nbsp;&nbsp;&nbsp;const char *buffer,<br>
1344&nbsp;&nbsp;&nbsp;&nbsp;size_t bytes,<br>
1345&nbsp;&nbsp;&nbsp;&nbsp;double timeout<br>
1346);</p>
1347<h4 class="parameters">Parameters</h4>
1348<dl>
1349<dt>buffer</dt>
1350<dd class="description">Buffer to write</dd>
1351<dt>bytes</dt>
1352<dd class="description">Bytes to write</dd>
1353<dt>timeout</dt>
79e1d494 1354<dd class="description">Timeout in seconds, typically 1.0</dd>
5a738aea
MS
1355</dl>
1356<h4 class="returnvalue">Return Value</h4>
1357<p class="description">Bytes written or -1 on error</p>
1358<h4 class="discussion">Discussion</h4>
79e1d494 1359<p class="discussion">Writes &quot;bytes&quot; bytes to the backchannel/filter. The &quot;timeout&quot; parameter
ef416fc2 1360controls how many seconds to wait for the data to be written - use
13610.0 to return immediately if the data cannot be written, -1.0 to wait
1362indefinitely.
1363
ac884b6a 1364</p>
f3c17241 1365<h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsBackendDeviceURI">cupsBackendDeviceURI</a></h3>
ac884b6a
MS
1366<p class="description">Get the device URI for a backend.</p>
1367<p class="code">
1368const char *cupsBackendDeviceURI (<br>
1369&nbsp;&nbsp;&nbsp;&nbsp;char **argv<br>
1370);</p>
1371<h4 class="parameters">Parameters</h4>
1372<dl>
1373<dt>argv</dt>
1374<dd class="description">Command-line arguments</dd>
1375</dl>
1376<h4 class="returnvalue">Return Value</h4>
1377<p class="description">Device URI or <code>NULL</code></p>
1378<h4 class="discussion">Discussion</h4>
1379<p class="discussion">The &quot;argv&quot; argument is the argv argument passed to main(). This
1380function returns the device URI passed in the DEVICE_URI environment
1381variable or the device URI passed in argv[0], whichever is found
426c6a59
MS
1382first.
1383
1384</p>
f3c17241 1385<h3 class="function"><span class="info">&nbsp;CUPS 1.4/OS X 10.6&nbsp;</span><a name="cupsBackendReport">cupsBackendReport</a></h3>
06d4e77b
MS
1386<p class="description">Write a device line from a backend.</p>
1387<p class="code">
1388void cupsBackendReport (<br>
1389&nbsp;&nbsp;&nbsp;&nbsp;const char *device_scheme,<br>
1390&nbsp;&nbsp;&nbsp;&nbsp;const char *device_uri,<br>
1391&nbsp;&nbsp;&nbsp;&nbsp;const char *device_make_and_model,<br>
1392&nbsp;&nbsp;&nbsp;&nbsp;const char *device_info,<br>
1393&nbsp;&nbsp;&nbsp;&nbsp;const char *device_id,<br>
1394&nbsp;&nbsp;&nbsp;&nbsp;const char *device_location<br>
1395);</p>
1396<h4 class="parameters">Parameters</h4>
1397<dl>
1398<dt>device_scheme</dt>
1399<dd class="description">device-scheme string</dd>
1400<dt>device_uri</dt>
1401<dd class="description">device-uri string</dd>
1402<dt>device_make_and_model</dt>
1403<dd class="description">device-make-and-model string or <code>NULL</code></dd>
1404<dt>device_info</dt>
1405<dd class="description">device-info string or <code>NULL</code></dd>
1406<dt>device_id</dt>
1407<dd class="description">device-id string or <code>NULL</code></dd>
1408<dt>device_location</dt>
1409<dd class="description">device-location string or <code>NULL</code></dd>
1410</dl>
1411<h4 class="discussion">Discussion</h4>
1412<p class="discussion">This function writes a single device line to stdout for a backend.
1413It handles quoting of special characters in the device-make-and-model,
426c6a59
MS
1414device-info, device-id, and device-location strings.
1415
1416</p>
f3c17241 1417<h3 class="function"><span class="info">&nbsp;CUPS 1.3/OS X 10.5&nbsp;</span><a name="cupsSideChannelDoRequest">cupsSideChannelDoRequest</a></h3>
5a738aea
MS
1418<p class="description">Send a side-channel command to a backend and wait for a response.</p>
1419<p class="code">
1420<a href="#cups_sc_status_t">cups_sc_status_t</a> cupsSideChannelDoRequest (<br>
1421&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_sc_command_t">cups_sc_command_t</a> command,<br>
1422&nbsp;&nbsp;&nbsp;&nbsp;char *data,<br>
1423&nbsp;&nbsp;&nbsp;&nbsp;int *datalen,<br>
1424&nbsp;&nbsp;&nbsp;&nbsp;double timeout<br>
1425);</p>
1426<h4 class="parameters">Parameters</h4>
1427<dl>
1428<dt>command</dt>
1429<dd class="description">Command to send</dd>
1430<dt>data</dt>
1431<dd class="description">Response data buffer pointer</dd>
1432<dt>datalen</dt>
1433<dd class="description">Size of data buffer on entry, number of bytes in buffer on return</dd>
1434<dt>timeout</dt>
1435<dd class="description">Timeout in seconds</dd>
1436</dl>
1437<h4 class="returnvalue">Return Value</h4>
1438<p class="description">Status of command</p>
1439<h4 class="discussion">Discussion</h4>
1440<p class="discussion">This function is normally only called by filters, drivers, or port
f7deaa1a 1441monitors in order to communicate with the backend used by the current
1442printer. Programs must be prepared to handle timeout or &quot;not
1443implemented&quot; status codes, which indicate that the backend or device
5a738aea
MS
1444do not support the specified side-channel command.<br>
1445<br>
1446The &quot;datalen&quot; parameter must be initialized to the size of the buffer
f7deaa1a 1447pointed to by the &quot;data&quot; parameter. cupsSideChannelDoRequest() will
1448update the value to contain the number of data bytes in the buffer.
1449
5a738aea 1450</p>
f3c17241 1451<h3 class="function"><span class="info">&nbsp;CUPS 1.3/OS X 10.5&nbsp;</span><a name="cupsSideChannelRead">cupsSideChannelRead</a></h3>
5a738aea
MS
1452<p class="description">Read a side-channel message.</p>
1453<p class="code">
1454int cupsSideChannelRead (<br>
1455&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_sc_command_t">cups_sc_command_t</a> *command,<br>
1456&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_sc_status_t">cups_sc_status_t</a> *status,<br>
1457&nbsp;&nbsp;&nbsp;&nbsp;char *data,<br>
1458&nbsp;&nbsp;&nbsp;&nbsp;int *datalen,<br>
1459&nbsp;&nbsp;&nbsp;&nbsp;double timeout<br>
1460);</p>
1461<h4 class="parameters">Parameters</h4>
1462<dl>
1463<dt>command</dt>
1464<dd class="description">Command code</dd>
1465<dt>status</dt>
1466<dd class="description">Status code</dd>
1467<dt>data</dt>
1468<dd class="description">Data buffer pointer</dd>
1469<dt>datalen</dt>
1470<dd class="description">Size of data buffer on entry, number of bytes in buffer on return</dd>
1471<dt>timeout</dt>
1472<dd class="description">Timeout in seconds</dd>
1473</dl>
1474<h4 class="returnvalue">Return Value</h4>
1475<p class="description">0 on success, -1 on error</p>
1476<h4 class="discussion">Discussion</h4>
1477<p class="discussion">This function is normally only called by backend programs to read
f7deaa1a 1478commands from a filter, driver, or port monitor program. The
1479caller must be prepared to handle incomplete or invalid messages
5a738aea
MS
1480and return the corresponding status codes.<br>
1481<br>
1482The &quot;datalen&quot; parameter must be initialized to the size of the buffer
f7deaa1a 1483pointed to by the &quot;data&quot; parameter. cupsSideChannelDoRequest() will
1484update the value to contain the number of data bytes in the buffer.
1485
20fbc903 1486</p>
f3c17241 1487<h3 class="function"><span class="info">&nbsp;CUPS 1.4/OS X 10.6&nbsp;</span><a name="cupsSideChannelSNMPGet">cupsSideChannelSNMPGet</a></h3>
20fbc903
MS
1488<p class="description">Query a SNMP OID's value.</p>
1489<p class="code">
1490<a href="#cups_sc_status_t">cups_sc_status_t</a> cupsSideChannelSNMPGet (<br>
1491&nbsp;&nbsp;&nbsp;&nbsp;const char *oid,<br>
1492&nbsp;&nbsp;&nbsp;&nbsp;char *data,<br>
1493&nbsp;&nbsp;&nbsp;&nbsp;int *datalen,<br>
1494&nbsp;&nbsp;&nbsp;&nbsp;double timeout<br>
1495);</p>
1496<h4 class="parameters">Parameters</h4>
1497<dl>
1498<dt>oid</dt>
1499<dd class="description">OID to query</dd>
1500<dt>data</dt>
1501<dd class="description">Buffer for OID value</dd>
1502<dt>datalen</dt>
1503<dd class="description">Size of OID buffer on entry, size of value on return</dd>
1504<dt>timeout</dt>
1505<dd class="description">Timeout in seconds</dd>
1506</dl>
1507<h4 class="returnvalue">Return Value</h4>
1508<p class="description">Query status</p>
1509<h4 class="discussion">Discussion</h4>
1510<p class="discussion">This function asks the backend to do a SNMP OID query on behalf of the
1511filter, port monitor, or backend using the default community name.<br>
1512<br>
1513&quot;oid&quot; contains a numeric OID consisting of integers separated by periods,
1514for example &quot;.1.3.6.1.2.1.43&quot;. Symbolic names from SNMP MIBs are not
1515supported and must be converted to their numeric forms.<br>
1516<br>
1517On input, &quot;data&quot; and &quot;datalen&quot; provide the location and size of the
1518buffer to hold the OID value as a string. HEX-String (binary) values are
1519converted to hexadecimal strings representing the binary data, while
1520NULL-Value and unknown OID types are returned as the empty string.
1521The returned &quot;datalen&quot; does not include the trailing nul.
1522
1523<code>CUPS_SC_STATUS_NOT_IMPLEMENTED</code> is returned by backends that do not
1524support SNMP queries. <code>CUPS_SC_STATUS_NO_RESPONSE</code> is returned when
1525the printer does not respond to the SNMP query.
1526
1527</p>
f3c17241 1528<h3 class="function"><span class="info">&nbsp;CUPS 1.4/OS X 10.6&nbsp;</span><a name="cupsSideChannelSNMPWalk">cupsSideChannelSNMPWalk</a></h3>
20fbc903
MS
1529<p class="description">Query multiple SNMP OID values.</p>
1530<p class="code">
1531<a href="#cups_sc_status_t">cups_sc_status_t</a> cupsSideChannelSNMPWalk (<br>
1532&nbsp;&nbsp;&nbsp;&nbsp;const char *oid,<br>
1533&nbsp;&nbsp;&nbsp;&nbsp;double timeout,<br>
1534&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_sc_walk_func_t">cups_sc_walk_func_t</a> cb,<br>
1535&nbsp;&nbsp;&nbsp;&nbsp;void *context<br>
1536);</p>
1537<h4 class="parameters">Parameters</h4>
1538<dl>
1539<dt>oid</dt>
1540<dd class="description">First numeric OID to query</dd>
1541<dt>timeout</dt>
1542<dd class="description">Timeout for each query in seconds</dd>
1543<dt>cb</dt>
1544<dd class="description">Function to call with each value</dd>
1545<dt>context</dt>
1546<dd class="description">Application-defined pointer to send to callback</dd>
1547</dl>
1548<h4 class="returnvalue">Return Value</h4>
1549<p class="description">Status of first query of <code>CUPS_SC_STATUS_OK</code> on success</p>
1550<h4 class="discussion">Discussion</h4>
1551<p class="discussion">This function asks the backend to do multiple SNMP OID queries on behalf
1552of the filter, port monitor, or backend using the default community name.
1553All OIDs under the &quot;parent&quot; OID are queried and the results are sent to
1554the callback function you provide.<br>
1555<br>
1556&quot;oid&quot; contains a numeric OID consisting of integers separated by periods,
1557for example &quot;.1.3.6.1.2.1.43&quot;. Symbolic names from SNMP MIBs are not
1558supported and must be converted to their numeric forms.<br>
1559<br>
1560&quot;timeout&quot; specifies the timeout for each OID query. The total amount of
1561time will depend on the number of OID values found and the time required
1562for each query.<br>
1563<br>
1564&quot;cb&quot; provides a function to call for every value that is found. &quot;context&quot;
1565is an application-defined pointer that is sent to the callback function
1566along with the OID and current data. The data passed to the callback is the
1567same as returned by <a href="#cupsSideChannelSNMPGet"><code>cupsSideChannelSNMPGet</code></a>.
1568
1569<code>CUPS_SC_STATUS_NOT_IMPLEMENTED</code> is returned by backends that do not
1570support SNMP queries. <code>CUPS_SC_STATUS_NO_RESPONSE</code> is returned when
1571the printer does not respond to the first SNMP query.
1572
5a738aea 1573</p>
f3c17241 1574<h3 class="function"><span class="info">&nbsp;CUPS 1.3/OS X 10.5&nbsp;</span><a name="cupsSideChannelWrite">cupsSideChannelWrite</a></h3>
5a738aea
MS
1575<p class="description">Write a side-channel message.</p>
1576<p class="code">
1577int cupsSideChannelWrite (<br>
1578&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_sc_command_t">cups_sc_command_t</a> command,<br>
1579&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_sc_status_t">cups_sc_status_t</a> status,<br>
1580&nbsp;&nbsp;&nbsp;&nbsp;const char *data,<br>
1581&nbsp;&nbsp;&nbsp;&nbsp;int datalen,<br>
1582&nbsp;&nbsp;&nbsp;&nbsp;double timeout<br>
1583);</p>
1584<h4 class="parameters">Parameters</h4>
1585<dl>
1586<dt>command</dt>
1587<dd class="description">Command code</dd>
1588<dt>status</dt>
1589<dd class="description">Status code</dd>
1590<dt>data</dt>
1591<dd class="description">Data buffer pointer</dd>
1592<dt>datalen</dt>
1593<dd class="description">Number of bytes of data</dd>
1594<dt>timeout</dt>
1595<dd class="description">Timeout in seconds</dd>
1596</dl>
1597<h4 class="returnvalue">Return Value</h4>
1598<p class="description">0 on success, -1 on error</p>
1599<h4 class="discussion">Discussion</h4>
1600<p class="discussion">This function is normally only called by backend programs to send
f7deaa1a 1601responses to a filter, driver, or port monitor program.
1602
5a738aea
MS
1603</p>
1604<h2 class="title"><a name="TYPES">Data Types</a></h2>
1605<h3 class="typedef"><a name="cups_backend_t">cups_backend_t</a></h3>
1606<p class="description">Backend exit codes</p>
1607<p class="code">
1608typedef enum <a href="#cups_backend_e">cups_backend_e</a> cups_backend_t;
1609</p>
1610<h3 class="typedef"><a name="cups_sc_bidi_t">cups_sc_bidi_t</a></h3>
1611<p class="description">Bidirectional capabilities</p>
1612<p class="code">
1613typedef enum <a href="#cups_sc_bidi_e">cups_sc_bidi_e</a> cups_sc_bidi_t;
1614</p>
1615<h3 class="typedef"><a name="cups_sc_command_t">cups_sc_command_t</a></h3>
1616<p class="description">Request command codes</p>
1617<p class="code">
1618typedef enum <a href="#cups_sc_command_e">cups_sc_command_e</a> cups_sc_command_t;
1619</p>
82f97232
MS
1620<h3 class="typedef"><a name="cups_sc_connected_t">cups_sc_connected_t</a></h3>
1621<p class="description">Connectivity values</p>
1622<p class="code">
1623typedef enum <a href="#cups_sc_connected_e">cups_sc_connected_e</a> cups_sc_connected_t;
1624</p>
5a738aea
MS
1625<h3 class="typedef"><a name="cups_sc_state_t">cups_sc_state_t</a></h3>
1626<p class="description">Printer state bits</p>
1627<p class="code">
1628typedef enum <a href="#cups_sc_state_e">cups_sc_state_e</a> cups_sc_state_t;
1629</p>
1630<h3 class="typedef"><a name="cups_sc_status_t">cups_sc_status_t</a></h3>
1631<p class="description">Response status codes</p>
1632<p class="code">
1633typedef enum <a href="#cups_sc_status_e">cups_sc_status_e</a> cups_sc_status_t;
1634</p>
20fbc903
MS
1635<h3 class="typedef"><a name="cups_sc_walk_func_t">cups_sc_walk_func_t</a></h3>
1636<p class="description">SNMP walk callback</p>
1637<p class="code">
1638typedef void (*cups_sc_walk_func_t)(const char *oid, const char *data, int datalen, void *context);
1639</p>
5a738aea
MS
1640<h2 class="title"><a name="ENUMERATIONS">Constants</a></h2>
1641<h3 class="enumeration"><a name="cups_backend_e">cups_backend_e</a></h3>
1642<p class="description">Backend exit codes</p>
1643<h4 class="constants">Constants</h4>
1644<dl>
1645<dt>CUPS_BACKEND_AUTH_REQUIRED </dt>
1646<dd class="description">Job failed, authentication required</dd>
1647<dt>CUPS_BACKEND_CANCEL </dt>
1648<dd class="description">Job failed, cancel job</dd>
1649<dt>CUPS_BACKEND_FAILED </dt>
1650<dd class="description">Job failed, use error-policy</dd>
1651<dt>CUPS_BACKEND_HOLD </dt>
1652<dd class="description">Job failed, hold job</dd>
1653<dt>CUPS_BACKEND_OK </dt>
1654<dd class="description">Job completed successfully</dd>
22c9029b
MS
1655<dt>CUPS_BACKEND_RETRY </dt>
1656<dd class="description">Job failed, retry this job later</dd>
1657<dt>CUPS_BACKEND_RETRY_CURRENT </dt>
1658<dd class="description">Job failed, retry this job immediately</dd>
5a738aea
MS
1659<dt>CUPS_BACKEND_STOP </dt>
1660<dd class="description">Job failed, stop queue</dd>
1661</dl>
1662<h3 class="enumeration"><a name="cups_sc_bidi_e">cups_sc_bidi_e</a></h3>
79e1d494 1663<p class="description">Bidirectional capability values</p>
5a738aea
MS
1664<h4 class="constants">Constants</h4>
1665<dl>
1666<dt>CUPS_SC_BIDI_NOT_SUPPORTED </dt>
1667<dd class="description">Bidirectional I/O is not supported</dd>
1668<dt>CUPS_SC_BIDI_SUPPORTED </dt>
1669<dd class="description">Bidirectional I/O is supported</dd>
1670</dl>
1671<h3 class="enumeration"><a name="cups_sc_command_e">cups_sc_command_e</a></h3>
1672<p class="description">Request command codes</p>
1673<h4 class="constants">Constants</h4>
1674<dl>
1675<dt>CUPS_SC_CMD_DRAIN_OUTPUT </dt>
1676<dd class="description">Drain all pending output</dd>
1677<dt>CUPS_SC_CMD_GET_BIDI </dt>
1678<dd class="description">Return bidirectional capabilities</dd>
f3c17241 1679<dt>CUPS_SC_CMD_GET_CONNECTED <span class="info">&nbsp;CUPS 1.5/OS X 10.7&nbsp;</span></dt>
82f97232 1680<dd class="description">Return whether the backend is &quot;connected&quot; to the printer </dd>
5a738aea
MS
1681<dt>CUPS_SC_CMD_GET_DEVICE_ID </dt>
1682<dd class="description">Return the IEEE-1284 device ID</dd>
1683<dt>CUPS_SC_CMD_GET_STATE </dt>
1684<dd class="description">Return the device state</dd>
f3c17241 1685<dt>CUPS_SC_CMD_SNMP_GET <span class="info">&nbsp;CUPS 1.4/OS X 10.6&nbsp;</span></dt>
20fbc903 1686<dd class="description">Query an SNMP OID </dd>
f3c17241 1687<dt>CUPS_SC_CMD_SNMP_GET_NEXT <span class="info">&nbsp;CUPS 1.4/OS X 10.6&nbsp;</span></dt>
20fbc903 1688<dd class="description">Query the next SNMP OID </dd>
5a738aea
MS
1689<dt>CUPS_SC_CMD_SOFT_RESET </dt>
1690<dd class="description">Do a soft reset</dd>
1691</dl>
82f97232
MS
1692<h3 class="enumeration"><a name="cups_sc_connected_e">cups_sc_connected_e</a></h3>
1693<p class="description">Connectivity values</p>
1694<h4 class="constants">Constants</h4>
1695<dl>
1696<dt>CUPS_SC_CONNECTED </dt>
1697<dd class="description">Backend is &quot;connected&quot; to printer</dd>
1698<dt>CUPS_SC_NOT_CONNECTED </dt>
1699<dd class="description">Backend is not &quot;connected&quot; to printer</dd>
1700</dl>
5a738aea
MS
1701<h3 class="enumeration"><a name="cups_sc_state_e">cups_sc_state_e</a></h3>
1702<p class="description">Printer state bits</p>
1703<h4 class="constants">Constants</h4>
1704<dl>
1705<dt>CUPS_SC_STATE_BUSY </dt>
1706<dd class="description">Device is busy</dd>
1707<dt>CUPS_SC_STATE_ERROR </dt>
1708<dd class="description">Other error condition</dd>
1709<dt>CUPS_SC_STATE_MARKER_EMPTY </dt>
1710<dd class="description">Toner/ink out condition</dd>
1711<dt>CUPS_SC_STATE_MARKER_LOW </dt>
1712<dd class="description">Toner/ink low condition</dd>
1713<dt>CUPS_SC_STATE_MEDIA_EMPTY </dt>
1714<dd class="description">Paper out condition</dd>
1715<dt>CUPS_SC_STATE_MEDIA_LOW </dt>
1716<dd class="description">Paper low condition</dd>
1717<dt>CUPS_SC_STATE_OFFLINE </dt>
79e1d494 1718<dd class="description">Device is offline</dd>
5a738aea 1719<dt>CUPS_SC_STATE_ONLINE </dt>
79e1d494 1720<dd class="description">Device is online</dd>
5a738aea
MS
1721</dl>
1722<h3 class="enumeration"><a name="cups_sc_status_e">cups_sc_status_e</a></h3>
1723<p class="description">Response status codes</p>
1724<h4 class="constants">Constants</h4>
1725<dl>
1726<dt>CUPS_SC_STATUS_BAD_MESSAGE </dt>
1727<dd class="description">The command/response message was invalid</dd>
1728<dt>CUPS_SC_STATUS_IO_ERROR </dt>
1729<dd class="description">An I/O error occurred</dd>
1730<dt>CUPS_SC_STATUS_NONE </dt>
1731<dd class="description">No status</dd>
1732<dt>CUPS_SC_STATUS_NOT_IMPLEMENTED </dt>
1733<dd class="description">Command not implemented</dd>
1734<dt>CUPS_SC_STATUS_NO_RESPONSE </dt>
1735<dd class="description">The device did not respond</dd>
1736<dt>CUPS_SC_STATUS_OK </dt>
1737<dd class="description">Operation succeeded</dd>
1738<dt>CUPS_SC_STATUS_TIMEOUT </dt>
1739<dd class="description">The backend did not respond</dd>
1740<dt>CUPS_SC_STATUS_TOO_BIG </dt>
1741<dd class="description">Response too big</dd>
1742</dl>
1743</div>
ef416fc2 1744</body>
1745</html>