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