User`s guide
4-3
Printer, Plotter, and Spooler Subsystem Programming
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 user’s environment. To access the user’s
environment, the backend may invoke the getenv subroutine. For example, to access the
user’s 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. Since 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.
By default, stdin, stdout, and stderr are all open to the null device (/dev/null), although it
is possible to override the setting of stdout (and possibly stdin) with the file and
access fields in the qconfig file.