<HTML> <HEAD> <META NAME="COPYRIGHT" CONTENT="Copyright 1997-2002, All Rights Reserved"> <META NAME="DOCNUMBER" CONTENT="CUPS-SDD-1.1"> <META NAME="Author" CONTENT="Easy Software Products"> <TITLE>CUPS Software Design Description</TITLE> </HEAD> <BODY> <H1>Scope</H1> <H2>Identification</H2> This software design description document provides general information on the architecture and coding of the Common UNIX Printing System ("CUPS") Version 1.1. <EMBED SRC="system-overview.shtml"> <H2>Document Overview</H2> This software design description document is organized into the following sections: <UL> <LI>1 - Scope <LI>2 - References <LI>3 - Design Overview <LI>A - Glossary </UL> <EMBED SRC="references.shtml"> <H1>Design Overview</H1> CUPS is composed of 9 software sub-systems that operate together to perform common printing tasks: <UL> <LI>Backends <LI>Berkeley Commands <LI>CGI <LI>CUPS Application Programmers Interface <LI>CUPS Imaging Library <LI>Daemons <LI>Filters <LI>Scheduler <LI>System V Commands </UL> <H2>Backends</H2> The backends implement communications over a number of different interfaces. All backends are called with a common set of arguments: <UL> <LI>Device URI - the Uniform Resource Identifier for the output device (e.g. <CODE>parallel:/dev/plp</CODE>, <CODE>ipp://hostname/resource</CODE>). <LI>Job Identifier - the job identifier for this job (integer). <LI>User Name - the user associated with this job (name string). <LI>Title - the title/job-name associated with this job (name string). <LI>Copies - the number of copies required (integer). <LI>Options - the options associated with this job (space separated option strings). <LI>Filename (optional) - the file to print; if this option is not specified, the backend must read the print file from the standard input. </UL> <P>Backends are named using the scheme of the URI, so a URI of "ipp://hostname/resource" would be processed by the "ipp" backend. <H3>ipp</H3> <P>The ipp backend sends the specified job to a network printer or host using the Internet Printing Protocol. The URI is as specified by the <CODE>printer-uri-supported</CODE> attribute from the printer or host. <H3>lpd</H3> <P>The lpd backend sends the specified job to a network printer or host using the Line Printer Daemon protocol. The URI is of the form: <UL><PRE>lpd://hostname/queue </PRE></UL> <H3>parallel</H3> <P>The parallel backend sends the specified job to a local printer connected via the specified parallel port device. The URI is of the form: <UL><PRE>parallel:/dev/file </PRE></UL> <H3>serial</H3> <P>The serial backend sends the specified job to a local printer connected via the specified serial port device. The URI is of the form: <UL><PRE>serial:/dev/file?option[+option+...] </PRE></UL> The options can be any combination of the following: <UL> <LI><CODE>baud=<I>rate</I></CODE> - Sets the baud rate for the device. <LI><CODE>bits=<I>7 or 8</I></CODE> - Sets the number of data bits. <LI><CODE>parity=<I>even</I></CODE> - Sets even parity checking. <LI><CODE>parity=<I>odd</I></CODE> - Sets odd parity checking. <LI><CODE>parity=<I>none</I></CODE> - Turns parity checking off. <LI><CODE>flow=dtrdsr<I></I></CODE> - Turns DTR/DSR (hardware) flow control on. <LI><CODE>flow=hard<I></I></CODE> - Turns RTS/CTS (hardware) flow control on. <LI><CODE>flow=none<I></I></CODE> - Turns flow control off. <LI><CODE>flow=rtscts<I></I></CODE> - Turns RTS/CTS (hardware) flow control on. <LI><CODE>flow=xonxoff<I></I></CODE> - Turns XON/XOFF (software) flow control on. </UL> <H3>socket</H3> <P>The socket backend sends the specified job to a network host using the AppSocket protocol commonly used by Hewlett-Packard and Tektronix printers. The URI is of the form: <UL><PRE>socket://hostname[:port] </PRE></UL> The default port number is 9100. <H3>usb</H3> <P>The usb backend sends the specified job to a local printer connected via the specified usb port device. The URI is of the form: <UL><PRE>usb:/dev/file </PRE></UL> <H2>Berkeley Commands</H2> <P>The Berkeley commands provide a simple command-line interface to CUPS to submit and control print jobs. It is provided for compatibility with existing software that is hardcoded to use the Berkeley commands. <H3>lpc</H3> The lpc command allows users and administrators to check the status and control print queues. The version provided with CUPS supports the following commands: <UL> <LI>quit - Quits the lpc command. <LI>status - Shows the status of printers and jobs in the queue. </UL> <H3>lpq</H3> <P>The lpq command shows the current queue status. <H3>lpr</H3> <P>The lpr command submits a job for printing. The CUPS version of lpr silently ignores the "i", "t", "m", "h", and "s" options. <H3>lprm</H3> <P>The lprm removes one or more print jobs. <H2>CGI</H2> <P>The Common Gateway Interface (CGI) programs provide a web-based status interface to monitor the status of printers, classes, and jobs. Each of the CGIs utilize HTML template files that can be customized to provide alternate appearances. <H3>admin.cgi</H3> <P>The admin CGI provides administration interfaces for printers and classes. The user can add, modify, delete, start, stop, and configure printers and classes using "wizard" interfaces. <H3>classes.cgi</H3> <P>The classes CGI lists the available printer classes and any pending jobs for the class. The user can click on individual classes to limit the display and click on jobs to see the job status. <H3>jobs.cgi</H3> <P>The jobs CGI lists the queued print jobs in order of priority. The list can be limited by printer or job. <H3>printers.cgi</H3> <P>The printers CGI lists the available printer queues and any pending jobs for the printer. The user can click on individual printers to limit the display and click on jobs to see the job status. <H2>CUPS Application Programmers Interface</H2> <P>The CUPS Application Programmers Interface ("API") provides common convenience, HTTP, IPP, language, and PPD functions used by the CUPS software. <H3>Convenience Functions</H3> <P>Convenience functions are provided to submit an IPP request, send a print file, cancel a job, get a list of available printers, get a list of available classes, get the default printer or class, get the default server name, get the local username, and get a password string. <H3>HTTP Functions</H3> <P>The HTTP functions provide functions to connect to HTTP servers, issue requests, read data from a server, and write data to a server. <H3>IPP Functions</H3> <P>The IPP function provide functions to manage IPP request data and attributes, read IPP responses from a server, and write IPP requests to a server. <H3>Language Functions</H3> <P>The language functions provide a standard interface for retrieving common textual messages for a particular locale and determining the correct encoding (e.g. US ASCII, UTF-8, ISO-8859-1, etc.) <H3>PPD Functions</H3> <P>The PostScript Printer Description functions manage PPD files, select options, check for option conflicts, and emit selected options in the correct order. <H2>CUPS Imaging Library</H2> <P>The CUPS imaging library provides colorspace conversion, color management, image management, scaling, image file, and raster functions used by the CUPS raster filters. <H3>Colorspace Conversion Functions</H3> <P>The colorspace conversion functions handle conversion of grayscale and RGB colors to grayscale, RGB, K, CMY, CMYK, and CMYKcm colorspaces. <H3>Color Management Functions</H3> <P>The color management functions handle gamut mapping and density correction. These are integrated with the colorspace conversion functions so that colorspace conversion and color management are processed in a single step. <H3>Image Management Functions</H3> <P>The image management functions manage a tiled image database that is swapped to/from disk as needed. <H3>Scaling Functions</H3> <P>The scaling functions provide image scaling services using nearest-neighbor sampling and bilinear interpolation as appropriate. <H3>Image File Functions</H3> <P>The image file functions handle loading of all image file formats. <H3>Raster Functions</H3> <P>The raster functions manage streams of CUPS raster data (described in the Interface Design Document) used by non-PostScript printer drivers and raster filters. <H2>Daemons</H2> <P>The daemons provide additional network functions for the scheduler. Currently only two daemons are provided with CUPS. <H3>Line Printer Daemon</H3> <P>The line printer daemon provides remote LPD client support and is run by the <CODE>inetd(8)</CODE> daemon as needed. <H3>Polling Daemon</H3> <P>The polling daemon is used to poll a remote server for a list of available printers and provide it to the scheduler for addition. A separate polling daemon is run by the scheduler for every remote system listed for polling in the scheduler configuration file. <H2>Filters</H2> <P>The filters implement file conversion services for CUPS. All filters are called with a common set of arguments: <UL> <LI>Printer name - the name of the destination printer (name string). <LI>Job Identifier - the job identifier for this job (integer). <LI>User Name - the user associated with this job (name string). <LI>Title - the title/job-name associated with this job (name string). <LI>Copies - the number of copies required (integer). <LI>Options - the options associated with this job (space separated option strings). <LI>Filename (optional) - the file to print; if this option is not specified, the filter must read the input file from the standard input. </UL> <P>Filters are added to the MIME conversion data file and implement all necessary conversions from one file type to another. <H3>hpgltops</H3> <P>The hpgltops filter converts HP-GL/2 files into PostScript. <H3>imagetops</H3> <P>The imagetops filter converts image files into PostScript. <H3>imagetoraster</H3> <P>The imagetoraster filter converts image files into CUPS raster data. <H3>pdftops</H3> <P>The pdftops filter converts PDF files into PostScript. <H3>pstops</H3> <P>The pstops filter inserts printer-specific commands from PPD files and performs page filtering as requested by the user. <H3>pstoraster</H3> <P>The pstoraster filter converts PostScript program data into CUPS raster data. <H3>rastertoepson</H3> <P>The rastertoepson filter handles converting CUPS raster data to ESC/P and supports both color and black-and-white printers. <H3>rastertohp</H3> <P>The rastertohp filter handles converting CUPS raster data to HP-PCL and supports both color and black-and-white printers. <H3>texttops</H3> <P>The texttops filter converts text files into PostScript. <H2>Scheduler</H2> <P>The scheduler is a fully-functional HTTP/1.1 and IPP/1.1 server that manages the printers, classes, and jobs in the system. It also handles a simple broadcast-based directory service so that remote print queues and classes can be accessed transparently from the local system. <H3>Authorization</H3> <P>The authorization module is responsible for performing access control and authentication for all HTTP and IPP requests entering the system. <H3>Classes</H3> <P>The classes module is responsible for managing printer classes in the system. Each class is a collection of local and/or remote printers. The classes module also reads and writes the classes configuration file. <H3>Client</H3> <P>The client module is responsible for all HTTP client communications. It handles listening on selected interfaces, accepting connections from prospective clients, processing incoming HTTP requests, and sending HTTP responses to those requests. The client module also is responsible for executing the external CGI programs as needed to support web-based printer, class, and job status monitoring and administration. <P>Once authorized, all IPP requests are sent to the IPP module. <H3>Configuration</H3> <P>The configuration module is responsible for reading the CUPS configuration file and initializing the appropriate data structures and values. The configuration module also stops CUPS services before reading the configuration file and restarts them after the configuration file has been read. <H3>Devices</H3> <P>The devices module is responsible for managing the list of available devices for the CUPS-Get-Devices operation. <H3>Directory Services</H3> <P>The directory services module sends and recieves printer state information over a broadcast socket. Remote printers and classes are automatically added to or removed from the local printer and class lists as needed. <P>The directory services module can only recieve printer state information over a single UDP port, however it can broadcast to multiple addresses and ports as needed. <H3>IPP</H3> <P>The IPP module handles IPP requests and acts accordingly. URI validation is also performed here, as a client can post IPP data to any URI on the server which might sidestep the access control or authentication of the HTTP server. <H3>Jobs</H3> <P>The jobs module manages print jobs, starts filter and backend processes for jobs to be printed, and monitors status messages from those filters and backends. <H3>Logging</H3> <P>The logging module manages the access, error, and page log files that are generated by the scheduler. <H3>Main</H3> <P>The main module is responsible for timing out and dispatching input and output for client connections. It also watches for incoming <CODE>SIGHUP</CODE> and <CODE>SIGCHLD</CODE> signals, reloads the server configuration files as needed, and handles child process errors and exits. <H3>MIME</H3> <P>The Multimedia Internet Mail Exchange module manages a MIME type and conversion database that supports file typing by extension and content and least-cost file filtering from a source to a destination file type. <H3>PPDs</H3> <P>The PPDs module is responsible for managing the list of available PPD files for the CUPS-Get-PPDs operation. <H3>Printers</H3> <P>The printers module is responsible for managing printers and PPD files in the system. The printers module also reads and writes the printers configuration file. <H2>System V Commands</H2> <P>The System V commands provide a robust command-line interface to CUPS to submit and control printers and jobs. <H3>accept</H3> <P>The accept command tells the scheduler to accept new jobs for specific printers. <H3>cancel</H3> <P>The cancel command tells the scheduler to cancel one or more jobs that are queued for printing. <H3>disable</H3> <P>The disable command tells the scheduler to stop printing jobs on the specified printers. <H3>enable</H3> <P>The enable command tells the scheduler to start printing jobs on the specified printers. <H3>lp</H3> <P>The lp command submits submits files for printing. Unlike the standard System V lp command, a single CUPS lp command will generate a separate job ID for each file that is printed. Also, the Solaris "f", "H", "P", "S", and "y" options are silently ignored. <H3>lpadmin</H3> <P>The lpadmin command manages printer queues and classes. The Solaris "A", "F", "I", "M", "P", "Q", "S", "T", "U", "W", "f", "l", "m", "o", "s", "t", and "u" options are not supported, and new options "P" (PPD file) and "E" (enable and accept) are provided to configure CUPS-specific features. <H3>lpinfo</H3> <P>The lpinfo command lists the available PPD files or devices as selected by the user. <H3>lpmove</H3> <P>The lpmove command moves a print job to a new destination. <H3>lpoptions</H3> <P>The lpoptions command manages user-defined printers and options. <H3>lpstat</H3> <P>The lpstat command lists printers, classes, and jobs as requested by the user. <H3>reject</H3> <P>The reject command tells the scheduler not to accept new jobs for specific printers. <EMBED SRC="glossary.shtml"> </BODY> </HTML>