filter(7) | Apple Inc. | filter(7) |
filter - cups file conversion filter interface
filter job user title num-copies options [ filename ]
#include <cups/cups.h> ssize_t cupsBackChannelRead(char *buffer, size_t bytes,
double timeout); cups_sc_status_t cupsSideChannelDoRequest(cups_sc_command_t command,
char *data, int *datalen,
double timeout); #include <cups/ppd.h> const char *cupsGetOption(const char *name, int num_options,
cups_option_t *options); int cupsMarkOptions(ppd_file_t *ppd, int num_options,
cups_option_t *options); int cupsParseOptions(const char *arg, int num_options,
cups_option_t **options); ppd_choice_t *ppdFindMarkedChoice(ppd_file_t *ppd, const char *keyword); void ppdMarkDefaults(ppd_file_t *ppd); ppd_file_t *ppdOpenFile(const char *filename);
The CUPS filter interface provides a standard method for adding support for new document types or printers to CUPS. 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.
Filters 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 file format. All output MUST be sent to the standard output. Filters MUST NOT attempt to communicate directly with the printer, other processes, or other services.
The command name (argv[0]) is set to the name of the destination printer but is also available in the PRINTER environment variable.
Options are passed in argv[5] and are encoded from the corresponding IPP attributes used when the job was submitted. Use the cupsParseOptions() function to load the options into a cups_option_t array and the cupsGetOption() function to get the value of a specific attribute. Be careful to look for common aliases of IPP attributes such as "landscape" for the IPP "orientation-requested" attribute.
Options passed on the command-line typically do not include the default choices the printer's PPD file. Use the ppdMarkDefaults() and cupsMarkOptions() functions in the CUPS library to apply the options to the PPD defaults and map any IPP attributes to the corresponding PPD options. Use ppdFindMarkedChoice() 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 Duplex PPD option:
ppd_file_t *ppd = ppdOpenFile(getenv("PPD"));
cups_option_t *options = NULL;
int num_options = cupsParseOptions(argv[5], 0, &options);
ppdMarkDefaults(ppd);
cupsMarkOptions(ppd, num_options, options);
ppd_choice_t *choice = ppdFindMarkedChoice(ppd, "Duplex");
Raster filters should use option choices set through the raster page header, as those reflect the options in effect for a given page. Options specified on the command-line determine the default values for the entire job, which can be overridden on a per-page basis.
Messages sent to the standard error are generally stored in the printer's "printer-state-message" attribute and the current ErrorLog file. Each line begins with a standard prefix:
The following environment variables are defined by the CUPS server when executing the filter:
While the filter interface is compatible with System V interface scripts, CUPS does not support System V interface scripts.
CUPS filters are not meant to be run directly by the user. Aside from the legacy System V interface issues (argv[0] 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. Unless you are a developer and know what you are doing, please do not run filters directly. Instead, use the cupsfilter(8) program to use the appropriate filters to do the conversions you need.
backend(7), cups(1), cups-files.conf(5),
cupsd(8), cupsfilter(8),
CUPS Online Help (http://localhost:631/help)
Copyright © 2007-2017 by Apple Inc.
CUPS | 19 October 2015 |