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