Specifications

4-29
Printer, Plotter, and Spooler Subsystem Programming
Understanding the Interaction between qdaemon and the
Backend
The qdaemon and the backend communicate through a status file. Understanding Backend
Routines in libqb on page 4-34 explains the set of library routines that the backend should
use to fulfill these communication requirements. These routines are in the /usr/lib/libqb.a
library.
Using the Status File
When the qdaemon process invokes a backend, it passes the following parameters, in
order:
1. The parameters appearing in the /etc/qconfig file.
2. The flags that the enq command did not recognize, in the order they were given. These
flags will be preceded by the –o option on the command line.
3. The names of one or more files to be printed.
There is a status file for each device and its associated queue. These files are found in the
/var/spool/lpd/stat directory.
The status file provides a means of communication for the qdaemon process and the
backend. The qdaemon passes information such as the date of the file, whether to print
burst pages, and the number of copies to be printed. The backend passes back the charge
for the job it has just finished running. In addition, the backend periodically updates the
number of pages it has printed and what percent of the job is finished. This information is
read by the qchk command.
Note: Backends should never explicitly write into their status file. They should call the
libqb library routines to do this.
The routines are called for the following reason:
The backend is spared the trouble of accessing the status file directly.
The format of the status file can be changed without requiring backends to be rewritten.
Should the format of the status file change, the backend only needs to be re–linked.
To initialize certain data common to the library routines, the backend must call the routine
log_init. For more information see Understanding Backend Routines in libqb on page 4-34.
The call is as follows:
log_init();
This routine should be called to initialize the status file interface. The log_init routine, like all
log_ routines in the library, returns a value of –1 if it fails.
Printing Extra Copies
The enq –N command prints extra copies of a file. For example, to print five copies of a file
filename, enter this command:
enq –N5 filename
The enq command passes the information to the qdaemon process, which puts it into the
status file. Backends should get the information by calling the get_copies ( Understanding
Backend Routines in libqb on page 4-34) routine, which returns the total number of copies
requested.