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