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