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