• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE HTML>
2<html>
3<!-- SECTION: Man Pages -->
4<head>
5	<link rel="stylesheet" type="text/css" href="../cups-printable.css">
6	<title>backend(7)</title>
7</head>
8<body>
9<h1 class="title">backend(7)</h1>
10<h2 class="title"><a name="NAME">Name</a></h2>
11backend - cups backend transmission interfaces
12<h2 class="title"><a name="SYNOPSIS">Synopsis</a></h2>
13<b>backend</b>
14<br>
15<b>backend</b>
16<i>job</i>
17<i>user</i>
18<i>title</i>
19<i>num-copies</i>
20<i>options</i>
21[
22<i>filename</i>
23]
24<pre class="man">
25<b>#include &lt;cups/cups.h></b>
26
27<b>const char *cupsBackendDeviceURI</b>(<b>char **</b><i>argv</i>);
28
29<b>void cupsBackendReport</b>(<b>const char *</b><i>device_scheme</i>,
30                       <b>const char *</b><i>device_uri</i>,
31                       <b>const char *</b><i>device_make_and_model</i>,
32                       <b>const char *</b><i>device_info</i>,
33                       <b>const char *</b><i>device_id</i>,
34                       <b>const char *</b><i>device_location</i>);
35
36<b>ssize_t cupsBackChannelWrite</b>(<b>const char *</b><i>buffer</i>,
37                             <b>size_t </b><i>bytes</i>, <b>double </b><i>timeout</i>);
38
39<b>int cupsSideChannelRead</b>(<b>cups_sc_command_t *</b><i>command</i>,
40                        <b>cups_sc_status_t *</b><i>status</i>, <b>char *</b><i>data</i>,
41                        <b>int *</b><i>datalen</i>, <b>double </b><i>timeout</i>);
42
43<b>int cupsSideChannelWrite</b>(<b>cups_sc_command_t </b><i>command</i>,
44                         <b>cups_sc_status_t </b><i>status</i>, <b>const char *</b><i>data</i>,
45                         <b>int </b><i>datalen</i>, <b>double </b><i>timeout</i>);
46</pre>
47<h2 class="title"><a name="DESCRIPTION">Description</a></h2>
48Backends are a special type of
49<a href="man-filter.html?TOPIC=Man+Pages"><b>filter</b>(7)</a>
50which is used to send print data to and discover different devices on the system.
51<p>Like filters, backends must be capable of reading from a filename on the command-line or from the standard input, copying the standard input to a temporary file as required by the physical interface.
52<p>The command name (<i>argv[0]</i>) is set to the device URI of the destination printer.
53Authentication information in
54<i>argv[0]</i>
55is removed, so backend developers are urged to use the
56<b>DEVICE_URI</b>
57environment variable whenever authentication information is required. The
58<b>cupsBackendDeviceURI</b>()
59function may be used to retrieve the correct device URI.
60<p>Back-channel data from the device should be relayed to the job filters using the <i>cupsBackChannelWrite</i> function.
61<p>Backends are responsible for reading side-channel requests using the
62<b>cupsSideChannelRead</b>()
63function and responding with the
64<b>cupsSideChannelWrite</b>()
65function. The
66<b>CUPS_SC_FD</b>
67constant defines the file descriptor that should be monitored for incoming requests.
68<h3><a name="DEVICE_DISCOVERY">Device Discovery</a></h3>
69When run with no arguments, the backend should list the devices and schemes it supports or is advertising to the standard output.
70The output consists of zero or more lines consisting of any of the following forms:
71<pre class="man">
72    device-class scheme "Unknown" "device-info"
73    device-class device-uri "device-make-and-model" "device-info"
74    device-class device-uri "device-make-and-model" "device-info" "device-id"
75    device-class device-uri "device-make-and-model" "device-info" "device-id" "device-location"
76</pre>
77<p>The
78<b>cupsBackendReport</b>()
79function can be used to generate these lines and handle any necessary escaping of characters in the various strings.
80<p>The
81<i>device-class</i>
82field is one of the following values:
83<dl class="man">
84<dt><b>direct</b>
85<dd style="margin-left: 5.0em">The device-uri refers to a specific direct-access device with no options, such as a parallel, USB, or SCSI device.
86<dt><b>file</b>
87<dd style="margin-left: 5.0em">The device-uri refers to a file on disk.
88<dt><b>network</b>
89<dd style="margin-left: 5.0em">The device-uri refers to a networked device and conforms to the general form for
90network URIs.
91<dt><b>serial</b>
92<dd style="margin-left: 5.0em">The device-uri refers to a serial device with configurable baud rate and other options.
93If the device-uri contains a baud value, it represents the maximum baud rate supported by the device.
94</dl>
95<p>The
96<i>scheme</i>
97field provides the URI scheme that is supported by the backend.
98Backends should use this form only when the backend supports any URI using that scheme.
99The
100<i>device-uri</i>
101field specifies the full URI to use when communicating with the device.
102<p>The
103<i>device-make-and-model</i>
104field specifies the make and model of the device, e.g. "Example Foojet 2000".
105If the make and model is not known, you must report "Unknown".
106<p>The
107<i>device-info</i>
108field specifies additional information about the device.
109Typically this includes the make and model along with the port number or network address, e.g. "Example Foojet 2000 USB #1".
110<p>The optional
111<i>device-id</i>
112field specifies the IEEE-1284 device ID string for the device, which is used to select a matching driver.
113<p>The optional
114<i>device-location</i>
115field specifies the physical location of the device, which is often used to pre-populate the printer-location attribute when adding a printer.
116<h3><a name="PERMISSIONS">Permissions</a></h3>
117Backends without world read and execute permissions are run as the root user.
118Otherwise, the backend is run using an unprivileged user account, typically "lp".
119<h2 class="title"><a name="EXIT_STATUS">Exit Status</a></h2>
120The following exit codes are defined for backends:
121<dl class="man">
122<dt><b>CUPS_BACKEND_OK</b>
123<dd style="margin-left: 5.0em">The print file was successfully transmitted to the device or remote server.
124<dt><b>CUPS_BACKEND_FAILED</b>
125<dd style="margin-left: 5.0em"><br>
126The print file was not successfully transmitted to the device or remote server.
127The scheduler will respond to this by canceling the job, retrying the job, or stopping the queue depending on the state of the
128<i>printer-error-policy</i>
129attribute.
130<dt><b>CUPS_BACKEND_AUTH_REQUIRED</b>
131<dd style="margin-left: 5.0em">The print file was not successfully transmitted because valid authentication information is required.
132The scheduler will respond to this by holding the job and adding the 'cups-held-for-authentication' keyword to the "job-reasons" Job Description attribute.
133<dt><b>CUPS_BACKEND_HOLD</b>
134<dd style="margin-left: 5.0em">The print file was not successfully transmitted because it cannot be printed at this time.
135The scheduler will respond to this by holding the job.
136<dt><b>CUPS_BACKEND_STOP</b>
137<dd style="margin-left: 5.0em">The print file was not successfully transmitted because it cannot be printed at this time.
138The scheduler will respond to this by stopping the queue.
139<dt><b>CUPS_BACKEND_CANCEL</b>
140<dd style="margin-left: 5.0em">The print file was not successfully transmitted because one or more attributes are not supported or the job was canceled at the printer.
141The scheduler will respond to this by canceling the job.
142<dt><b>CUPS_BACKEND_RETRY</b>
143<dd style="margin-left: 5.0em">The print file was not successfully transmitted because of a temporary issue.
144The scheduler will retry the job at a future time - other jobs may print before this one.
145<dt><b>CUPS_BACKEND_RETRY_CURRENT</b>
146<dd style="margin-left: 5.0em">The print file was not successfully transmitted because of a temporary issue.
147The scheduler will retry the job immediately without allowing intervening jobs.
148</dl>
149<p>All other exit code values are reserved.
150<h2 class="title"><a name="ENVIRONMENT">Environment</a></h2>
151In addition to the environment variables listed in
152<a href="man-cups.html?TOPIC=Man+Pages"><b>cups</b>(1)</a>
153and
154<a href="man-filter.html?TOPIC=Man+Pages"><b>filter</b>(7),</a>
155CUPS backends can expect the following environment variable:
156<dl class="man">
157<dt><b>DEVICE_URI</b>
158<dd style="margin-left: 5.0em">The device URI associated with the printer.
159</dl>
160<h2 class="title"><a name="FILES">Files</a></h2>
161<i>/etc/cups/cups-files.conf</i>
162<h2 class="title"><a name="NOTES">Notes</a></h2>
163CUPS backends are not generally designed to be run directly by the user.
164Aside from the device URI issue (
165<i>argv[0]</i>
166and
167<b>DEVICE_URI</b>
168environment variable contain the device URI), CUPS backends also expect specific environment variables and file descriptors, and typically run in a user session that (on macOS) has additional restrictions that affect how it runs.
169Backends can also be installed with restricted permissions (0500 or 0700) that tell the scheduler to run them as the "root" user instead of an unprivileged user (typically "lp") on the system.
170<p>Unless you are a developer and know what you are doing, please do not run backends directly.
171Instead, use the
172<a href="man-lp.html?TOPIC=Man+Pages"><b>lp</b>(1)</a>
173or
174<a href="man-lpr.html?TOPIC=Man+Pages"><b>lpr</b>(1)</a>
175programs to send print jobs or
176<a href="man-lpinfo.html?TOPIC=Man+Pages"><b>lpinfo</b>(8)</a>
177to query for available printers using the backend.
178The one exception is the SNMP backend - see
179<a href="man-cups-snmp.html?TOPIC=Man+Pages"><b>cups-snmp</b>(8)</a>
180for more information.
181<h2 class="title"><a name="NOTES">Notes</a></h2>
182CUPS printer drivers and backends are deprecated and will no longer be supported in a future feature release of CUPS.
183Printers that do not support IPP can be supported using applications such as
184<a href="man-ippeveprinter.html?TOPIC=Man+Pages"><b>ippeveprinter</b>(1).</a>
185<h2 class="title"><a name="SEE_ALSO">See Also</a></h2>
186<i>cups</i>(1),
187<i>cups-files.conf</i>(5),
188<i>cups-snmp</i>(8),
189<i>cupsd</i>(8),
190<i>filter</i>(7),
191<i>lp</i>(1),
192<i>lpinfo</i>(8),
193<i>lpr</i>(1),
194<br>
195CUPS Online Help (<a href="http://localhost:631/help">http://localhost:631/help</a>)
196<h2 class="title"><a name="COPYRIGHT">Copyright</a></h2>
197Copyright &copy; 2020-2024 by OpenPrinting.
198
199</body>
200</html>
201