]> git.ipfire.org Git - thirdparty/cups.git/blame - man/filter.7
Greatly simplify the man page handling.
[thirdparty/cups.git] / man / filter.7
CommitLineData
ef416fc2 1.\"
bfbd0197 2.\" filter man page for CUPS.
ef416fc2 3.\"
87030afb
MS
4.\" Copyright © 2007-2019 by Apple Inc.
5.\" Copyright © 1997-2007 by Easy Software Products.
ef416fc2 6.\"
87030afb
MS
7.\" Licensed under Apache License v2.0. See the file "LICENSE" for more
8.\" information.
ef416fc2 9.\"
87030afb 10.TH filter 7 "CUPS" "26 April 2019" "Apple Inc."
ef416fc2 11.SH NAME
bd7854cb 12filter \- cups file conversion filter interface
ef416fc2 13.SH SYNOPSIS
14.B filter
bfbd0197
MS
15.I job
16.I user
17.I title
18.I num-copies
19.I options
20[
ef416fc2 21.I filename
22]
bfbd0197
MS
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
ef416fc2 51.SH DESCRIPTION
bfbd0197
MS
52The CUPS filter interface provides a standard method for adding support for new document types or printers to CUPS.
53Each 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.
ef416fc2 54.LP
bfbd0197
MS
55Filters \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.
56All output \fBMUST\fR be sent to the standard output.
57Filters \fBMUST NOT\fR attempt to communicate directly with the printer, other processes, or other services.
ef416fc2 58.LP
bfbd0197 59The command name (\fIargv[0]\fR) is set to the name of the destination printer but is also available in the \fBPRINTER\fI environment variable.
178cb736 60.SH OPTIONS
bfbd0197
MS
61Options 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 ()
63function to load the options into a \fBcups_option_t\fR array and the
64.BR cupsGetOption ()
65function to get the value of a specific attribute.
dd3fdd2c 66Be careful to look for common aliases of IPP attributes such as "landscape" for the IPP "orientation-requested" attribute.
178cb736 67.LP
bfbd0197
MS
68Options passed on the command-line typically do not include the default choices the printer's PPD file. Use the
69.BR ppdMarkDefaults ()
70and
71.BR cupsMarkOptions ()
72functions in the CUPS library to apply the options to the PPD defaults and map any IPP attributes to the corresponding PPD options.
73Use
74.BR ppdFindMarkedChoice ()
75to 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
88Raster filters should use option choices set through the raster page header, as those reflect the options in effect for a given page.
89Options specified on the command-line determine the default values for the entire job, which can be overridden on a per-page basis.
bd7854cb 90.SH LOG MESSAGES
bfbd0197 91Messages sent to the standard error are generally stored in the printer's "printer-state-message" attribute and the current \fBErrorLog\fR file.
bd7854cb 92Each line begins with a standard prefix:
bd7854cb 93.TP 5
bfbd0197
MS
94\fBALERT: \fImessage\fR
95Sets the "printer-state-message" attribute and adds the specified message to the current \fBErrorLog\fR using the "alert" log level.
bd7854cb 96.TP 5
bfbd0197
MS
97\fBATTR: \fIattribute=value \fR[ \fI... attribute=value\fR]
98Sets the named job or printer attribute(s). The following job attributes can be set: "job-media-progress". The following printer attributes can be set:
f3c17241
MS
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".
bd7854cb 102.TP 5
bfbd0197
MS
103\fBCRIT: \fImessage\fR
104Sets the "printer-state-message" attribute and adds the specified message to the current \fBErrorLog\fR using the "critical" log level.
bd7854cb 105.TP 5
bfbd0197
MS
106\fBDEBUG: \fImessage\fR
107Adds 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.
bd7854cb 109.TP 5
bfbd0197 110\fBDEBUG2: \fImessage\fR
bd7854cb 111.br
bfbd0197
MS
112Adds 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.
bd7854cb 114.TP 5
bfbd0197
MS
115\fBEMERG: \fImessage\fR
116Sets the "printer-state-message" attribute and adds the specified message to the current \fBErrorLog\fR using the "emergency" log level.
bd7854cb 117.TP 5
bfbd0197
MS
118\fBERROR:\fI message\fR
119Sets the "printer-state-message" attribute and adds the specified message to the current \fBErrorLog\fR using the "error" log level.
bd7854cb 120.TP 5
bfbd0197
MS
121\fBINFO:\fI message\fR
122Sets 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.
bd7854cb 123.TP 5
bfbd0197
MS
124\fBNOTICE:\fI message\fR
125Sets the "printer-state-message" attribute and adds the specified message to the current \fBErrorLog\fR using the "notice" log level.
bd7854cb 126.TP 5
bfbd0197 127\fBPAGE:\fI page-number #-copies\fR
bd7854cb 128.TP 5
bfbd0197
MS
129\fBPAGE:\fI total #-pages\fR
130Adds 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.
c9fc04c6 131.TP 5
bfbd0197
MS
132\fBPPD:\fI Keyword=Value\fR [ \fI... KeywordN=Value\fR ]
133Sets 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.
bd7854cb 134.TP 5
bfbd0197 135\fBSTATE:\fI printer-state-reason \fR[ \fI... printer-state-reason\fR ]
bd7854cb 136.TP 5
bfbd0197 137\fBSTATE: +\fI printer-state-reason \fR[ \fI... printer-state-reason\fR ]
bd7854cb 138.TP 5
bfbd0197
MS
139\fBSTATE: -\fI printer-state-reason \fR[ \fI... printer-state-reason\fR ]
140Sets, 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.
bd7854cb 141.TP 5
bfbd0197
MS
142\fBWARNING:\fI message\fR
143Sets the "printer-state-message" attribute and adds the specified message to the current \fBErrorLog\fR using the "warning" log level.
ef416fc2 144.SH ENVIRONMENT VARIABLES
bd7854cb 145The following environment variables are defined by the CUPS
80ca4592 146server when executing the filter:
ef416fc2 147.TP 5
bfbd0197
MS
148.B CHARSET
149The default text character set, typically "utf-8".
ef416fc2 150.TP 5
bfbd0197
MS
151.B CLASS
152When a job is submitted to a printer class, contains the name of the destination printer class. Otherwise this environment variable will not be set.
ef416fc2 153.TP 5
bfbd0197
MS
154.B CONTENT_TYPE
155The MIME media type associated with the submitted job file, for example "application/postscript".
0af14961 156.TP 5
bfbd0197
MS
157.B CUPS_CACHEDIR
158The directory where semi-persistent cache files can be found and stored.
ef416fc2 159.TP 5
bfbd0197 160.B CUPS_DATADIR
ef416fc2 161The directory where data files can be found.
0af14961 162.TP 5
bfbd0197 163.B CUPS_FILETYPE
0af14961
MS
164The type of file being printed: "job-sheet" for a banner page and "document"
165for a regular print file.
ef416fc2 166.TP 5
bfbd0197
MS
167.B CUPS_MAX_MESSAGE
168The maximum size of a message sent to \fIstderr\fR, including any leading prefix and the trailing newline.
a29fd7dd 169.TP 5
bfbd0197 170.B CUPS_SERVERROOT
ef416fc2 171The root directory of the server.
172.TP 5
bfbd0197
MS
173.B FINAL_CONTENT_TYPE
174The MIME media type associated with the output destined for the printer, for example "application/vnd.cups-postscript".
ef416fc2 175.TP 5
bfbd0197 176.B LANG
ef416fc2 177The default language locale (typically C or en).
178.TP 5
bfbd0197
MS
179.B PATH
180The standard execution path for external programs that may be run by the filter.
ef416fc2 181.TP 5
bfbd0197
MS
182.B PPD
183The full pathname of the PostScript Printer Description (PPD) file for this printer.
ef416fc2 184.TP 5
bfbd0197 185.B PRINTER
bd7854cb 186The name of the printer.
ef416fc2 187.TP 5
bfbd0197
MS
188.B RIP_CACHE
189The recommended amount of memory to use for Raster Image Processors (RIPs).
ef416fc2 190.TP 5
bfbd0197
MS
191.B SOFTWARE
192The name and version number of the server (typically CUPS/\fImajor.minor\fR).
ef416fc2 193.TP 5
bfbd0197 194.B TZ
ef416fc2 195The timezone of the server.
196.TP 5
bfbd0197
MS
197.B USER
198The user executing the filter, typically "lp" or "root"; consult the \fIcups-files.conf\fR file for the current setting.
199.SH CONFORMING TO
e67e2f9e 200While the filter interface is compatible with System V interface scripts, CUPS does not support System V interface scripts.
bfbd0197 201.SH NOTES
87030afb
MS
202CUPS printer drivers and backends are deprecated and will no longer be supported in a future feature release of CUPS.
203Printers that do not support IPP can be supported using applications such as
204.BR ippeveprinter (1).
205.LP
bfbd0197 206CUPS filters are not meant to be run directly by the user.
8072030b 207Aside 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.
bfbd0197
MS
208Unless you are a developer and know what you are doing, please do not run filters directly.
209Instead, use the
210.BR cupsfilter (8)
211program to use the appropriate filters to do the conversions you need.
ef416fc2 212.SH SEE ALSO
bfbd0197
MS
213.BR backend (7),
214.BR cups (1),
215.BR cups-files.conf (5),
216.BR cupsd (8),
217.BR cupsfilter (8),
bd7854cb 218.br
bfbd0197 219CUPS Online Help (http://localhost:631/help)
ef416fc2 220.SH COPYRIGHT
87030afb 221Copyright \[co] 2007-2019 by Apple Inc.