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