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