Specifications

4-2
Guide to Printers and Printing
Printer Backend Overview for Programming
The base operating system printer backend receives and processes print requests from a
spooler, usually the qdaemon command. The printer backend is a standard feature of the
base operating system. It is implemented by the piobe command
The printer backend supports all of the printers installed in the Object Data Manager (ODM)
Predefined database. You can customize the printer backend to assist in the administration
of the printing subsystem. For more information, see Printing Administration on page 2-1.
You can also modify the printer backend to add unsupported printers and National
Language Support (NLS) code page translation tables.
Adding a printer to the printer backend involves adding a printer colon file for that printer. In
many cases, the printer colon file of a similar printer can be duplicated with little
modification. If modification of an existing printer colon file is not sufficient, you can write a
print formatter. If the modifications exceed the scope of the print formatter, you may need to
write a new printer backend.
See the following sections for more information:
Adding a Printer Using the Printer Colon File on page 4-53 provides a procedure for
duplicating a printer colon file.
Printer Colon File Escape Sequences on page 4-14 provides information useful in
modifying a printer colon file.
Understanding Backend Routines in libqb on page 4-34 and Understanding the
Interaction between qdaemon and the Backend on page 4-29 can assist you in writing a
new printer backend.
The procedure for translating NLS code points in the print file to code points for the printers
varies depending upon whether the code sets are single–byte or multibyte. For more
information, see:
Printer Code Page Translation Tables on page 4-37
Printer Code Page Translation for Multibyte Code Sets on page 4-39
Third–party vendors may want to customize the printer backend for special purposes.
Printer Backend Data Flow
The primary purpose of a backend is to send characters to a device, usually a printer. The
printer backend is invoked once for every file or group of files to be printed, with the name of
each file passed to the backend as a parameter. The backend opens the file, reads it, and
sends it to the device. The recommended method for a backend to operate is to write to its
standard output, with the qdaemon process opening the device onto the correct file
descriptor. This requires setting the file field in the qconfig file.
The name of the file to be printed can be a direct or relative path name. The user ID and
group ID of the backend are those of the process that invoked the enq command.
When a backend is invoked, it has access to the users environment. To access the user’s
environment, the backend may invoke the getenv subroutine. For example, to access the
users directory, getenv(PWD) returns a pointer to the directory name. The backend can
use this to read from or write to this directory.
If the backend writes to its standard output, the qdaemon opens the device in root–user
mode. If the backend needs to open the device itself, it must have the correct permissions
to open the device. Because the backend runs under the permissions of the user sending
the print job, you may need to change the protections on the device or install the backend
set–user–ID or set–group–ID.