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