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