]> git.ipfire.org Git - thirdparty/cups.git/blob - man/filter.7
Update .gitignore to ignore compressed man pages.
[thirdparty/cups.git] / man / filter.7
1 .\"
2 .\" filter man page for CUPS.
3 .\"
4 .\" Copyright © 2007-2019 by Apple Inc.
5 .\" Copyright © 1997-2007 by Easy Software Products.
6 .\"
7 .\" Licensed under Apache License v2.0. See the file "LICENSE" for more
8 .\" information.
9 .\"
10 .TH filter 7 "CUPS" "26 April 2019" "Apple Inc."
11 .SH NAME
12 filter \- cups file conversion filter interface
13 .SH SYNOPSIS
14 .B filter
15 .I job
16 .I user
17 .I title
18 .I num-copies
19 .I options
20 [
21 .I filename
22 ]
23 .nf
24
25 \fB#include <cups/cups.h>\fR
26
27 \fBssize_t cupsBackChannelRead\fR(\fBchar *\fIbuffer\fR, \fBsize_t \fIbytes\fR,
28 \fBdouble \fItimeout\fR);
29
30 \fBcups_sc_status_t cupsSideChannelDoRequest\fR(\fBcups_sc_command_t \fIcommand\fR,
31 \fBchar *\fIdata\fR, \fBint *\fIdatalen\fR,
32 \fBdouble \fItimeout\fR);
33
34 \fB#include <cups/ppd.h>\fR
35
36 \fBconst char *cupsGetOption\fR(\fBconst char *\fIname\fR, \fBint \fInum_options\fR,
37 \fBcups_option_t *\fIoptions\fR);
38
39 \fBint cupsMarkOptions\fR(\fBppd_file_t *\fIppd\fR, \fBint \fInum_options\fR,
40 \fBcups_option_t *\fIoptions\fR);
41
42 \fBint cupsParseOptions\fR(\fBconst char *\fIarg\fR, \fBint \fInum_options\fR,
43 \fBcups_option_t **\fIoptions\fR);
44
45 \fBppd_choice_t *ppdFindMarkedChoice\fR(\fBppd_file_t *\fIppd\fR, \fBconst char *\fIkeyword\fR);
46
47 \fBvoid ppdMarkDefaults\fR(\fBppd_file_t *\fIppd\fR);
48
49 \fBppd_file_t *ppdOpenFile\fR(\fBconst char *\fIfilename\fR);
50 .fi
51 .SH DESCRIPTION
52 The CUPS filter interface provides a standard method for adding support for new document types or printers to CUPS.
53 Each filter is capable of converting from one or more input formats to another format that can either be printed directly or piped into another filter to get it to a printable format.
54 .LP
55 Filters \fBMUST\fR 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 file format.
56 All output \fBMUST\fR be sent to the standard output.
57 Filters \fBMUST NOT\fR attempt to communicate directly with the printer, other processes, or other services.
58 .LP
59 The command name (\fIargv[0]\fR) is set to the name of the destination printer but is also available in the \fBPRINTER\fI environment variable.
60 .SH OPTIONS
61 Options are passed in \fIargv[5]\fR and are encoded from the corresponding IPP attributes used when the job was submitted. Use the
62 .BR cupsParseOptions ()
63 function to load the options into a \fBcups_option_t\fR array and the
64 .BR cupsGetOption ()
65 function to get the value of a specific attribute.
66 Be careful to look for common aliases of IPP attributes such as "landscape" for the IPP "orientation-requested" attribute.
67 .LP
68 Options passed on the command-line typically do not include the default choices the printer's PPD file. Use the
69 .BR ppdMarkDefaults ()
70 and
71 .BR cupsMarkOptions ()
72 functions in the CUPS library to apply the options to the PPD defaults and map any IPP attributes to the corresponding PPD options.
73 Use
74 .BR ppdFindMarkedChoice ()
75 to get the user-selected choice for a PPD option. For example, a filter might use the following code to determine the current value of the \fBDuplex\fR PPD option:
76 .nf
77
78 ppd_file_t *ppd = ppdOpenFile(getenv("PPD"));
79 cups_option_t *options = NULL;
80 int num_options = cupsParseOptions(argv[5], 0, &options);
81
82 ppdMarkDefaults(ppd);
83 cupsMarkOptions(ppd, num_options, options);
84
85 ppd_choice_t *choice = ppdFindMarkedChoice(ppd, "Duplex");
86 .fi
87 .LP
88 Raster filters should use option choices set through the raster page header, as those reflect the options in effect for a given page.
89 Options specified on the command-line determine the default values for the entire job, which can be overridden on a per-page basis.
90 .SH LOG MESSAGES
91 Messages sent to the standard error are generally stored in the printer's "printer-state-message" attribute and the current \fBErrorLog\fR file.
92 Each line begins with a standard prefix:
93 .TP 5
94 \fBALERT: \fImessage\fR
95 Sets the "printer-state-message" attribute and adds the specified message to the current \fBErrorLog\fR using the "alert" log level.
96 .TP 5
97 \fBATTR: \fIattribute=value \fR[ \fI... attribute=value\fR]
98 Sets the named job or printer attribute(s). The following job attributes can be set: "job-media-progress". The following printer attributes can be set:
99 "auth-info-required", "marker-colors", "marker-high-levels", "marker-levels",
100 "marker-low-levels", "marker-message", "marker-names", "marker-types",
101 "printer-alert", and "printer-alert-description".
102 .TP 5
103 \fBCRIT: \fImessage\fR
104 Sets the "printer-state-message" attribute and adds the specified message to the current \fBErrorLog\fR using the "critical" log level.
105 .TP 5
106 \fBDEBUG: \fImessage\fR
107 Adds the specified message to the current \fBErrorLog\fR using the "debug" log level.
108 \fBDEBUG\fR messages are never stored in the "printer-state-message" attribute.
109 .TP 5
110 \fBDEBUG2: \fImessage\fR
111 .br
112 Adds the specified message to the current \fBErrorLog\fR using the "debug2" log level.
113 \fBDEBUG2\fR messages are never stored in the "printer-state-message" attribute.
114 .TP 5
115 \fBEMERG: \fImessage\fR
116 Sets the "printer-state-message" attribute and adds the specified message to the current \fBErrorLog\fR using the "emergency" log level.
117 .TP 5
118 \fBERROR:\fI message\fR
119 Sets the "printer-state-message" attribute and adds the specified message to the current \fBErrorLog\fR using the "error" log level.
120 .TP 5
121 \fBINFO:\fI message\fR
122 Sets the "printer-state-message" attribute. If the current \fBLogLevel\fR is set to "debug2", also adds the specified message to the current \fBErrorLog\fR using the "info" log level.
123 .TP 5
124 \fBNOTICE:\fI message\fR
125 Sets the "printer-state-message" attribute and adds the specified message to the current \fBErrorLog\fR using the "notice" log level.
126 .TP 5
127 \fBPAGE:\fI page-number #-copies\fR
128 .TP 5
129 \fBPAGE:\fI total #-pages\fR
130 Adds an entry to the current \fBPageLog\fR. The first form adds \fI#-copies\fR to the "job-media-sheets-completed" attribute. The second form sets the "job-media-sheets-completed" attribute to \fI#-pages\fR.
131 .TP 5
132 \fBPPD:\fI Keyword=Value\fR [ \fI... KeywordN=Value\fR ]
133 Sets the named keywords in the printer's PPD file. This is typically used to update default option keywords such as \fBDefaultPageSize\fR and the various installable options in the PPD file.
134 .TP 5
135 \fBSTATE:\fI printer-state-reason \fR[ \fI... printer-state-reason\fR ]
136 .TP 5
137 \fBSTATE: +\fI printer-state-reason \fR[ \fI... printer-state-reason\fR ]
138 .TP 5
139 \fBSTATE: -\fI printer-state-reason \fR[ \fI... printer-state-reason\fR ]
140 Sets, adds, or removes "printer-state-reason" keywords for the current queue. Typically this is used to indicate media, ink, and toner conditions on a printer.
141 .TP 5
142 \fBWARNING:\fI message\fR
143 Sets the "printer-state-message" attribute and adds the specified message to the current \fBErrorLog\fR using the "warning" log level.
144 .SH ENVIRONMENT VARIABLES
145 The following environment variables are defined by the CUPS
146 server when executing the filter:
147 .TP 5
148 .B CHARSET
149 The default text character set, typically "utf-8".
150 .TP 5
151 .B CLASS
152 When a job is submitted to a printer class, contains the name of the destination printer class. Otherwise this environment variable will not be set.
153 .TP 5
154 .B CONTENT_TYPE
155 The MIME media type associated with the submitted job file, for example "application/postscript".
156 .TP 5
157 .B CUPS_CACHEDIR
158 The directory where semi-persistent cache files can be found and stored.
159 .TP 5
160 .B CUPS_DATADIR
161 The directory where data files can be found.
162 .TP 5
163 .B CUPS_FILETYPE
164 The type of file being printed: "job-sheet" for a banner page and "document"
165 for a regular print file.
166 .TP 5
167 .B CUPS_MAX_MESSAGE
168 The maximum size of a message sent to \fIstderr\fR, including any leading prefix and the trailing newline.
169 .TP 5
170 .B CUPS_SERVERROOT
171 The root directory of the server.
172 .TP 5
173 .B FINAL_CONTENT_TYPE
174 The MIME media type associated with the output destined for the printer, for example "application/vnd.cups-postscript".
175 .TP 5
176 .B LANG
177 The default language locale (typically C or en).
178 .TP 5
179 .B PATH
180 The standard execution path for external programs that may be run by the filter.
181 .TP 5
182 .B PPD
183 The full pathname of the PostScript Printer Description (PPD) file for this printer.
184 .TP 5
185 .B PRINTER
186 The name of the printer.
187 .TP 5
188 .B RIP_CACHE
189 The recommended amount of memory to use for Raster Image Processors (RIPs).
190 .TP 5
191 .B SOFTWARE
192 The name and version number of the server (typically CUPS/\fImajor.minor\fR).
193 .TP 5
194 .B TZ
195 The timezone of the server.
196 .TP 5
197 .B USER
198 The user executing the filter, typically "lp" or "root"; consult the \fIcups-files.conf\fR file for the current setting.
199 .SH CONFORMING TO
200 While the filter interface is compatible with System V interface scripts, CUPS does not support System V interface scripts.
201 .SH NOTES
202 CUPS printer drivers and backends are deprecated and will no longer be supported in a future feature release of CUPS.
203 Printers that do not support IPP can be supported using applications such as
204 .BR ippeveprinter (1).
205 .LP
206 CUPS filters are not meant to be run directly by the user.
207 Aside from the legacy System V interface issues (\fIargv[0]\fR is the printer name), CUPS filters 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.
208 Unless you are a developer and know what you are doing, please do not run filters directly.
209 Instead, use the
210 .BR cupsfilter (8)
211 program to use the appropriate filters to do the conversions you need.
212 .SH SEE ALSO
213 .BR backend (7),
214 .BR cups (1),
215 .BR cups-files.conf (5),
216 .BR cupsd (8),
217 .BR cupsfilter (8),
218 .br
219 CUPS Online Help (http://localhost:631/help)
220 .SH COPYRIGHT
221 Copyright \[co] 2007-2019 by Apple Inc.