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