18.2. Accounting File

Accouting information is usually stored in the file specified by the :af= option. If the option has the format host%port, then a TCP/IP connection is opened to the specified port on the indicated host, and accounting information is written and read from the connection, otherwise the value is treated like a file relative to the spool queue directory. The port that the connection originates from will be in the range set by the configuration or printcap originate_port option.

Accounting information can be written to the accounting file by the print spooler, :of filter, or job file filter. The filters are responsible for making a connection to the specified host and port or opening the accouting file. The following is a simple example of accounting information written to the accounting file.

    jobstart '-Hh4.private' '-nroot' '-Pps' '-kcfA938h4.private' \
    '-b1093' '-tNov  5 19:39:25'
    start '-p12942' '-kcfA938h4.private' '-nroot' '-hh4.private' '-Pps' \
    '-c0' '-Fo' '-tSun Nov  5 19:39:25 1995'
    filestart '-p12944' '-kcfA938h4.private' '-nroot' '-hh4.private' '-Pps' \
    '-c0' '-Ff' '-tSun Nov  5 19:39:27 1995'
    fileend '-p12944' '-kcfA938h4.private' '-nroot' '-hh4.private' '-Pps' \
    '-b3' '-c0' '-Ff' '-tSun Nov  5 19:39:58 1995'
    end '-p12942' '-kcfA938h4.private' '-nroot' '-hh4.private' '-Pps' \
    '-b2' '-c0' '-Fo' '-tSun Nov  5 19:39:59 1995'
    jobend '-Hh4.private' '-nroot' '-Pps' '-kcfA938h4.private' \
    '-b1093' '-tNov  5 19:39:59'


The jobstart lines is added by the lpd server, and are specified by the :as printcap option. The start line is added by the :of filter. This filter usually queries the printer and gets printer dependent accounting information such as the pagecounter value. The :of filter is then suspended and the job is processed by the various format dependent filters. These produce the filestart and fileend lines. These filters can also query the printer and get printer dependent accouting information. The end line is added by the :of filter when it terminates. The :of filter may query the printer again at this point and get the final pagecounter value for the job and determine the number of pages. The :ae option specifies the output to be put into the accouting file at the end of the job.

The accounting file must exist and will not be created by the lpd server. The accounting file should be periodically truncated.

The :as=... and :ae=... options specify the format of the information that the lpd server writes to the accouting file. These values are expanded using the same methods as for the filter options. For example:

    :as=jobstart $H $n $P $k $b $t
      jobstart '-Hh4.private' '-nroot' '-Pps' '-kcfA938h4.private' \
        '-b1093' '-tNov  5 19:39:25'
    :ae=jobend $H $n $P $k $b $t
      jobend '-Hh4.private' '-nroot' '-Pps' '-kcfA938h4.private' \
        '-b1093' '-tNov  5 19:39:59'


If the options have the form :as=|/path ..., then the specified program is run, and is responsible for putting the server level accounting information into the accouting file.

If the format of the :af option is :af=host%port and the :achk option is set, then the lpd server will open the connection to the host, send the :as string, and then wait for a single line of text from the remote server. If nothing is read or the first word on the return line is accept, then the job will be printed. If the value is hold, remove, or abort, the job will be held, removed, or aborted. Any other value will cause the job to be deleted.

At the end of the job the :ae string will be sent to the server. No response is expected.

If the format of the :as option is :as=| ... , then the value is assumed to be a filter program. It is invoked using the usual procedures for filters, with its STDIN set to the accounting file and its output is read by the lpd server. If the filter exits with a 0 exit code, the filter output is read and interpreted as that returned from a network connection. If the exit code is JHOLD, JREMOVE, or JABORT, the job is held, removed, or aborted. Any other exit code will cause the job to be removed.