]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - doc/help/api-filter.html
Merge changes from CUPS 1.5svn-r8849.
[thirdparty/cups.git] / doc / help / api-filter.html
index 582871ec623108f5b75e7f445eeaa38e41950721..568aa07b87700cba77d9b20b7faf56b49aa3a059 100644 (file)
@@ -1,10 +1,10 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 <html>
 <!-- SECTION: Programming -->
 <head>
 <title>Filter and Backend Programming</title>
 <meta name="keywords" content="Programming">
-<meta name="creator" content="Mini-XML v2.5">
+<meta name="creator" content="Mini-XML v2.6">
 <style type="text/css"><!--
 BODY {
   font-family: lucida grande, geneva, helvetica, arial, sans-serif;
@@ -27,11 +27,20 @@ PRE.command {
   margin-left: 36pt;
 }
 
+P.compact {
+  margin: 0;
+}
+
+P.example {
+  font-style: italic;
+  margin-left: 36pt;
+}
+  
 PRE.example {
   background: #eeeeee;
   border: dotted thin #999999;
   margin-left: 36pt;
-  padding: 10px;
+  padding: 10pt;
 }
 
 PRE.command EM, PRE.example EM {
@@ -49,11 +58,21 @@ P.formula {
 }
 
 BLOCKQUOTE {
-  background: #cccccc;
+  background: #eeeeee;
   border: solid thin #999999;
   padding: 10pt;
 }
 
+A IMG {
+  border: none;
+}
+
+A:link:hover IMG {
+  background: #f0f0f0;
+  border-radius: 10px;
+  -moz-border-radius: 10px;
+}
+
 A:link, A:visited {
   font-weight: normal;
   text-decoration: none;
@@ -67,6 +86,19 @@ SUB, SUP {
   font-size: 50%;
 }
 
+TR.data, TD.data, TR.data TD {
+  margin-top: 10pt;
+  padding: 5pt;
+  border-bottom: solid 1pt #999999;
+}
+
+TR.data TH {
+  border-bottom: solid 1pt #999999;
+  padding-top: 10pt;
+  padding-left: 5pt;
+  text-align: left;
+}
+
 DIV.table TABLE {
   border: solid thin #999999;
   border-collapse: collapse;
@@ -110,19 +142,23 @@ DIV.figure CAPTION {
 }
 
 TH.label {
-  padding-top: 5pt;
   text-align: right;
   vertical-align: top;
 }
 
+TH.sublabel {
+  text-align: right;
+  font-weight: normal;
+}
+
 HR {
   border: solid thin;
 }
 
 SPAN.info {
-  background: #000000;
-  border: thin solid #000000;
-  color: #ffffff;
+  background: black;
+  border: thin solid black;
+  color: white;
   font-size: 80%;
   font-style: italic;
   font-weight: bold;
@@ -134,10 +170,64 @@ H2 SPAN.info, H3 SPAN.info, H4 SPAN.info {
   font-size: 100%;
 }
 
+H1.title {
+}
+
 H2.title, H3.title {
   border-bottom: solid 2pt #000000;
 }
 
+DIV.indent, TABLE.indent {
+  margin-top: 2em;
+  margin-left: auto;
+  margin-right: auto;
+  width: 90%;
+}
+
+TABLE.indent {
+  border-collapse: collapse;
+}
+
+TABLE.indent TD, TABLE.indent TH {
+  padding: 0;
+}
+
+TABLE.list {
+  border-collapse: collapse;
+  margin-left: auto;
+  margin-right: auto;
+  width: 90%;
+}
+
+TABLE.list TH {
+  background: white;
+  border-bottom: solid thin #cccccc;
+  color: #444444;
+  padding-top: 10pt;
+  padding-left: 5pt;
+  text-align: left;
+  vertical-align: bottom;
+  white-space: nowrap;
+}
+
+TABLE.list TH A {
+  color: #4444cc;
+}
+
+TABLE.list TD {
+  border-bottom: solid thin #eeeeee;
+  padding-top: 5pt;
+  padding-left: 5pt;
+}
+
+TABLE.list TR:nth-child(even) {
+  background: #f8f8f8;
+}
+
+TABLE.list TR:nth-child(odd) {
+  background: #f4f4f4;
+}
+
 DT {
   margin-left: 36pt;
   margin-top: 12pt;
@@ -156,11 +246,6 @@ P.summary {
   font-family: monaco, courier, monospace;
 }
 
-SPAN.message {
-  font-style: italic;
-  font-size: smaller;
-}
-
 DIV.summary TABLE {
   border: solid thin #999999;
   border-collapse: collapse;
@@ -253,12 +338,12 @@ div.contents ul.subcontents li {
 <body>
 <div class='body'>
 <!--
-  "$Id: api-filter.header 7616 2008-05-28 00:34:13Z mike $"
+  "$Id$"
 
   Filter and backend programming header for the Common UNIX Printing System
   (CUPS).
 
-  Copyright 2008 by Apple Inc.
+  Copyright 2008-2009 by Apple Inc.
 
   These coded instructions, statements, and computer programs are the
   property of Apple Inc. and are protected by Federal copyright
@@ -267,7 +352,7 @@ div.contents ul.subcontents li {
   file is missing or damaged, see the license at "http://www.cups.org/".
 -->
 
-<h1 class="title">Filter and Backend Programming</h1>
+<h1 class='title'>Filter and Backend Programming</h1>
 
 <div class='summary'><table summary='General Information'>
 <thead>
@@ -288,15 +373,18 @@ div.contents ul.subcontents li {
        Programming: <a href='api-cups.html' target='_top'>CUPS API</a><br>
        Programming: <a href='api-ppd.html' target='_top'>PPD API</a><br>
        Programming: <a href='api-raster.html' target='_top'>Raster API</a><br>
+       Programming: <a href='postscript-driver.html' target='_top'>Developing PostScript Printer Drivers</a><br>
+       Programming: <a href='raster-driver.html' target='_top'>Developing Raster Printer Drivers</a><br>
        Specifications: <a href='spec-design' target='_top'>CUPS Design Description</a></td>
 </tr>
 </tbody>
 </table></div>
 <h2 class="title">Contents</h2>
 <ul class="contents">
-</li>
+<ul class="subcontents">
 <li><a href="#OVERVIEW">Overview</a><ul class="subcontents">
 <li><a href="#SECURITY">Security Considerations</a></li>
+<li><a href="#PERMISSIONS">File Permissions</a></li>
 <li><a href="#TEMPFILES">Temporary Files</a></li>
 <li><a href="#COPIES">Copy Generation</a></li>
 <li><a href="#EXITCODES">Exit Codes</a></li>
@@ -316,7 +404,7 @@ div.contents ul.subcontents li {
 <li><a href="#cupsSideChannelSNMPGet" title="Query a SNMP OID's value.">cupsSideChannelSNMPGet</a></li>
 <li><a href="#cupsSideChannelSNMPWalk" title="Query multiple SNMP OID values.">cupsSideChannelSNMPWalk</a></li>
 <li><a href="#cupsSideChannelWrite" title="Write a side-channel message.">cupsSideChannelWrite</a></li>
-</ul>
+</ul></li>
 <li><a href="#TYPES">Data Types</a><ul class="code">
        <li><a href="#cups_backend_t" title="Backend exit codes">cups_backend_t</a></li>
        <li><a href="#cups_sc_bidi_t" title="Bidirectional capabilities">cups_sc_bidi_t</a></li>
@@ -332,14 +420,13 @@ div.contents ul.subcontents li {
        <li><a href="#cups_sc_state_e" title="Printer state bits">cups_sc_state_e</a></li>
        <li><a href="#cups_sc_status_e" title="Response status codes">cups_sc_status_e</a></li>
 </ul></li>
-</ul>
 <!--
-  "$Id: api-filter.shtml 7677 2008-06-19 23:22:19Z mike $"
+  "$Id$"
 
   Filter and backend programming introduction for the Common UNIX Printing
   System (CUPS).
 
-  Copyright 2007-2008 by Apple Inc.
+  Copyright 2007-2009 by Apple Inc.
   Copyright 1997-2006 by Easy Software Products, all rights reserved.
 
   These coded instructions, statements, and computer programs are the
@@ -384,6 +471,12 @@ the remaining filters read from the standard input and write to the standard
 output. The backend is the last filter in the chain and writes to the
 device.</p>
 
+<p>Filters are always run as a non-privileged user, typically "lp", with no
+connection to the user's desktop. Backends are run either as a non-privileged
+user or as root if the file permissions do not allow user or group execution.
+The <a href="#PERMISSIONS">file permissions</a> section talks about this in
+more detail.</p>
+
 <h3><a name="SECURITY">Security Considerations</a></h3>
 
 <p>It is always important to use security programming practices. Filters and
@@ -410,10 +503,23 @@ user may not be the same as the local user and/or there may not be a local home
 directory to write to.</p>
 
 <p>In addition, some operating systems provide additional security mechanisms
-that further limit file system access, even for backends running as root.  On
+that further limit file system access, even for backends running as root. On
 Mac OS X, for example, no backend may write to a user's home directory.</p>
 </blockquote>
 
+<h3><a name="PERMISSIONS">File Permissions</a></h3>
+
+<p>For security reasons, CUPS will only run filters and backends that are owned
+by root and do not have world or group write permissions. The recommended
+permissions for filters and backends are 0555 - read and execute but no write.
+Backends that must run as root should use permissions of 0500 - read and execute
+by root, no access for other users. Write permissions can be enabled for the
+root user only.</p>
+
+<p>To avoid a warning message, the directory containing your filter(s) must also
+be owned by root and have world and group write disabled - permissions of 0755
+or 0555 are strongly encouraged.</p>
+
 <h3><a name="TEMPFILES">Temporary Files</a></h3>
 
 <p>Temporary files should be created in the directory specified by the
@@ -443,7 +549,7 @@ when running print filters and backends:</p>
 
 <dl class="code">
 
-       <dt>APPLE_LANGUAGES</dt>
+       <dt>APPLE_LANGUAGE</dt>
        <dd>The Apple language identifier associated with the job
        (Mac OS X only).</dd>
 
@@ -466,6 +572,10 @@ when running print filters and backends:</p>
        <dt>CUPS_DATADIR</dt>
        <dd>The directory where (read-only) CUPS data files can be found.</dd>
 
+       <dt>CUPS_FILETYPE</dt>
+       <dd>The type of file being printed: "job-sheet" for a banner page and
+       "document" for a regular print file.</dd>
+
        <dt>CUPS_SERVERROOT</dt>
        <dd>The root directory of the server.</dd>
 
@@ -576,7 +686,16 @@ prefix strings:</p>
        current queue. Typically this is used to indicate persistent media,
        ink, toner, and configuration conditions or errors on a printer.
        <a href='#TABLE2'>Table 2</a> lists the standard state keywords -
-       use vendor-prefixed ("com.acme.foo") keywords for custom states.</dd>
+       use vendor-prefixed ("com.acme.foo") keywords for custom states.
+
+       <blockquote><b>Note:</b>
+
+       <p>"STATE:" messages often provide visible alerts to the user. For example, on
+       Mac OS X setting a printer-state-reason value with an "-error" or "-warning"
+       suffix will cause the printer's dock item to bounce if the corresponding reason
+       is localized with a cupsIPPReason keyword in the printer's PPD file.</p>
+
+       </blockquote></dd>
 
        <dt>WARNING: message</dt>
        <dd>Sets the printer-state-message attribute and adds the specified
@@ -588,7 +707,6 @@ prefix strings:</p>
 <p>Messages without one of these prefixes are treated as if they began with
 the "DEBUG:" prefix string.</p>
 
-
 <div class='table'><table width='80%' summary='Table 1: Standard marker-types Values'>
 <caption>Table 1: <a name='TABLE1'>Standard marker-types Values</a></caption>
 <thead>
@@ -888,7 +1006,7 @@ void *my_data;
 <a href="#cupsSideChannelSNMPWalk">cupsSNMPSideChannelWalk</a>(".1.3.6.1.2.1.43", 5.0, my_callback, my_data);
 </pre>
 <h2 class="title"><a name="FUNCTIONS">Functions</a></h2>
-<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsBackChannelRead">cupsBackChannelRead</a></h3>
+<h3 class="function"><span class="info">&nbsp;CUPS 1.2/Mac OS X 10.5&nbsp;</span><a name="cupsBackChannelRead">cupsBackChannelRead</a></h3>
 <p class="description">Read data from the backchannel.</p>
 <p class="code">
 ssize_t cupsBackChannelRead (<br>
@@ -913,7 +1031,7 @@ parameter controls how many seconds to wait for the data - use 0.0 to
 return immediately if there is no data, -1.0 to wait for data indefinitely.
 
 </p>
-<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsBackChannelWrite">cupsBackChannelWrite</a></h3>
+<h3 class="function"><span class="info">&nbsp;CUPS 1.2/Mac OS X 10.5&nbsp;</span><a name="cupsBackChannelWrite">cupsBackChannelWrite</a></h3>
 <p class="description">Write data to the backchannel.</p>
 <p class="code">
 ssize_t cupsBackChannelWrite (<br>
@@ -939,7 +1057,7 @@ controls how many seconds to wait for the data to be written - use
 indefinitely.
 
 </p>
-<h3 class="function"><a name="cupsBackendDeviceURI">cupsBackendDeviceURI</a></h3>
+<h3 class="function"><span class="info">&nbsp;CUPS 1.2/Mac OS X 10.5&nbsp;</span><a name="cupsBackendDeviceURI">cupsBackendDeviceURI</a></h3>
 <p class="description">Get the device URI for a backend.</p>
 <p class="code">
 const char *cupsBackendDeviceURI (<br>
@@ -956,8 +1074,10 @@ const char *cupsBackendDeviceURI (<br>
 <p class="discussion">The &quot;argv&quot; argument is the argv argument passed to main(). This
 function returns the device URI passed in the DEVICE_URI environment
 variable or the device URI passed in argv[0], whichever is found
-first.</p>
-<h3 class="function"><a name="cupsBackendReport">cupsBackendReport</a></h3>
+first.
+
+</p>
+<h3 class="function"><span class="info">&nbsp;CUPS 1.4/Mac OS X 10.6&nbsp;</span><a name="cupsBackendReport">cupsBackendReport</a></h3>
 <p class="description">Write a device line from a backend.</p>
 <p class="code">
 void cupsBackendReport (<br>
@@ -986,8 +1106,10 @@ void cupsBackendReport (<br>
 <h4 class="discussion">Discussion</h4>
 <p class="discussion">This function writes a single device line to stdout for a backend.
 It handles quoting of special characters in the device-make-and-model,
-device-info, device-id, and device-location strings.</p>
-<h3 class="function"><span class="info">&nbsp;CUPS 1.3&nbsp;</span><a name="cupsSideChannelDoRequest">cupsSideChannelDoRequest</a></h3>
+device-info, device-id, and device-location strings.
+
+</p>
+<h3 class="function"><span class="info">&nbsp;CUPS 1.3/Mac OS X 10.5&nbsp;</span><a name="cupsSideChannelDoRequest">cupsSideChannelDoRequest</a></h3>
 <p class="description">Send a side-channel command to a backend and wait for a response.</p>
 <p class="code">
 <a href="#cups_sc_status_t">cups_sc_status_t</a> cupsSideChannelDoRequest (<br>
@@ -1021,7 +1143,7 @@ pointed to by the &quot;data&quot; parameter.  cupsSideChannelDoRequest() will
 update the value to contain the number of data bytes in the buffer.
 
 </p>
-<h3 class="function"><span class="info">&nbsp;CUPS 1.3&nbsp;</span><a name="cupsSideChannelRead">cupsSideChannelRead</a></h3>
+<h3 class="function"><span class="info">&nbsp;CUPS 1.3/Mac OS X 10.5&nbsp;</span><a name="cupsSideChannelRead">cupsSideChannelRead</a></h3>
 <p class="description">Read a side-channel message.</p>
 <p class="code">
 int cupsSideChannelRead (<br>
@@ -1057,7 +1179,7 @@ pointed to by the &quot;data&quot; parameter.  cupsSideChannelDoRequest() will
 update the value to contain the number of data bytes in the buffer.
 
 </p>
-<h3 class="function"><span class="info">&nbsp;CUPS 1.4&nbsp;</span><a name="cupsSideChannelSNMPGet">cupsSideChannelSNMPGet</a></h3>
+<h3 class="function"><span class="info">&nbsp;CUPS 1.4/Mac OS X 10.6&nbsp;</span><a name="cupsSideChannelSNMPGet">cupsSideChannelSNMPGet</a></h3>
 <p class="description">Query a SNMP OID's value.</p>
 <p class="code">
 <a href="#cups_sc_status_t">cups_sc_status_t</a> cupsSideChannelSNMPGet (<br>
@@ -1098,7 +1220,7 @@ support SNMP queries.  <code>CUPS_SC_STATUS_NO_RESPONSE</code> is returned when
 the printer does not respond to the SNMP query.
 
 </p>
-<h3 class="function"><span class="info">&nbsp;CUPS 1.4&nbsp;</span><a name="cupsSideChannelSNMPWalk">cupsSideChannelSNMPWalk</a></h3>
+<h3 class="function"><span class="info">&nbsp;CUPS 1.4/Mac OS X 10.6&nbsp;</span><a name="cupsSideChannelSNMPWalk">cupsSideChannelSNMPWalk</a></h3>
 <p class="description">Query multiple SNMP OID values.</p>
 <p class="code">
 <a href="#cups_sc_status_t">cups_sc_status_t</a> cupsSideChannelSNMPWalk (<br>
@@ -1144,7 +1266,7 @@ support SNMP queries.  <code>CUPS_SC_STATUS_NO_RESPONSE</code> is returned when
 the printer does not respond to the first SNMP query.
 
 </p>
-<h3 class="function"><span class="info">&nbsp;CUPS 1.3&nbsp;</span><a name="cupsSideChannelWrite">cupsSideChannelWrite</a></h3>
+<h3 class="function"><span class="info">&nbsp;CUPS 1.3/Mac OS X 10.5&nbsp;</span><a name="cupsSideChannelWrite">cupsSideChannelWrite</a></h3>
 <p class="description">Write a side-channel message.</p>
 <p class="code">
 int cupsSideChannelWrite (<br>
@@ -1244,9 +1366,9 @@ typedef void (*cups_sc_walk_func_t)(const char *oid, const char *data, int datal
 <dd class="description">Return the IEEE-1284 device ID</dd>
 <dt>CUPS_SC_CMD_GET_STATE </dt>
 <dd class="description">Return the device state</dd>
-<dt>CUPS_SC_CMD_SNMP_GET <span class="info">&nbsp;CUPS 1.4&nbsp;</span></dt>
+<dt>CUPS_SC_CMD_SNMP_GET <span class="info">&nbsp;CUPS 1.4/Mac OS X 10.6&nbsp;</span></dt>
 <dd class="description">Query an SNMP OID </dd>
-<dt>CUPS_SC_CMD_SNMP_GET_NEXT <span class="info">&nbsp;CUPS 1.4&nbsp;</span></dt>
+<dt>CUPS_SC_CMD_SNMP_GET_NEXT <span class="info">&nbsp;CUPS 1.4/Mac OS X 10.6&nbsp;</span></dt>
 <dd class="description">Query the next SNMP OID </dd>
 <dt>CUPS_SC_CMD_SOFT_RESET </dt>
 <dd class="description">Do a soft reset</dd>