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