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