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