When the spooler queue backend is piobe, the formatter filter is normally the next-to-last process in the pipeline of filters processing the print job. The formatter filter is composed of two pieces of code.
A formatter filter provides the capability of either formatting the input print file or passing it through unmodified, based on an input parameter. Even if the formatter passes the input file unmodified, it still sends printer commands to initialize the printer before the input file is printed and restores the printer after printing is complete.
The formatter filter is made up of two components:
The first is the device-independent formatter driver, pioformat. The second is a device-dependent formatter, of which there are less than 20. Code is device-independent when its execution is in no way dependent upon specific hardware, such as a certain physical printer. Similarly, code is device-dependent when its execution is dependent upon specific hardware, again such as a certain printer. In the AIX spooler's formatter filter, it is the device-dependent formatter that contains code designed to handle all of the properties of a particular physical printer or class of printers, including supported data stream, escape sequences, and control codes unique to that printer or printer class.
The device-independent pioformat is called a formatter driver because that it precisely what it does. When pioformat is set into execution, it expects several arguments. One of these arguments is the full path name to a device-dependent formatter. At runtime, pioformat dynamically loads, links, and drives the device-dependent formatter. The Formatter Filter figure depicts this relationship.
The pioformat command expects to be able to call, if necessary, five subroutines; pioformat by itself does not contain these subroutines. The subroutines exist in the device-dependent formatter and are supplied to pioformat at runtime when the loading and linking of the device-dependent formatter by pioformat occurs.
The formatter driver is invoked by a pipeline and is passed the name of a formatter to be driven. The formatter driver dynamically loads and links the formatter and calls the formatter's setup function which indicates whether data formatting or data pass-through is requested. After the formatter's setup function performs the necessary functions, it returns to the formatter driver. The formatter driver calls the initialize function. The initialize function outputs a string of printer commands to initialize the printer and returns to the formatter driver.
The formatter driver either calls the passthru function once or calls the lineout function for each line in the print file based on the return code from the setup function. If the lineout function is called, the formatter driver performs all vertical spacing, including line spacing, vertical tabs, form feeds, and top and bottom margins. Line spacing and vertical tabs are performed by the lineout function. Other vertical spacing functions are performed automatically.
When processing is complete, the formatter driver calls the restore function. The restore function outputs a string of printer commands to restore the printer to its default state, defined by the database attribute values.
For more information about how the print formatter interacts with the printer formatter subroutines, refer to the example of a print formatter.