Written by Urs-Jakob Rüetschi
as part of the pracc project.
Printer Accounting Files (or pracc files for short) record printing credits and debits. Usually, there is one pracc file per user that is subjected to printer accounting. one pracc file for each user with printer accounting enabled. Printer accounting with pracc files works like that:
There is a number of command line tools to manipulate pracc files and there is a C language API for using pracc files in your own software. Direct manipulation of pracc files is not recommended.
Pracc files live in /var/print/pracc/, are owned by root, have a special group pracc, and permissions 660. Therefore, pracc files cannot be modified by users other than through tools with appropriate rights. Such tools must make sure that users do not tamper with pracc files.
/var/print/pracc/ 2770 root:pracc /var/print/pracc/user 660 root:pracc /var/print/pracc.log 660 root:pracc
The location of pracc files and the special group for pracc files can be determined at compile-time in the pracc.h header file.
Line by line, each terminated with LF (ASCII 10). Lines must not be longer than MAXLINE, defined in the pracc.h header file.
The first line in a pracc file is the header line:
#pracc-v2-offset-username [comments]
The #pracc-v2 part identifies the file as a version 2 pracc file; offset is either zero or a byte offset into the pracc file, pointing to the most recent reset line (to speed up account summation, currently unused); and username tells whose pracc file this is (useful for tools that get a pracc file on standard input). Optional comments may follow.
All lines start with a special character that identifies the line type. What follows depends on the line type but usually includes a timestamp and a user name, telling when the entry was created and by whom.
All other lines should be ignored.
The timestamp is an at (@) sign followed by 16 hexadecimal digits; for example:
@4000000042cda28c
The hex digits represent a 64-bit integer that counts the number of seconds that elapsed since the beginning of 1970 plus 4611686018427387914 (which is 10+2^62 or 400000000000000a hex). This is based on the current real time standard, Temps Atomic International, or TAI. The example timestamp above refers to 2005-07-07 21:45:38 TAI. See http://cr.yp.to/time.html for more information on TAI.
An initial pracc file is created:
#pracc-v2-0-wimmer Waldemar Immerfroh $9 @4000000042cda28c root minimum balance =500 @4000000042cda28c root initial credit
After user wimmer has printed three jobs:
#pracc-v2-0-wimmer Waldemar Immerfroh $9 @4000000042cda28c root minimum balance =500 @4000000042cda28c root initial credit -10 @4000000042ce54a7 wimmer printer walze pages 1 job myfile.ps -50 @4000000042ce6403 wimmer printer walze pages 5 job report.ps -20 @4000000042ce9522 wimmer printer walze pages 2 job other.doc
User wimmer got more credit:
#pracc-v2-0-wimmer Waldemar Immerfroh $9 @4000000042cda28c root minimum balance =500 @4000000042cda28c root initial credit -10 @4000000042ce54a7 wimmer printer walze pages 1 job myfile.ps -50 @4000000042ce6403 wimmer printer walze pages 5 job report.ps -20 @4000000042ce9522 wimmer printer walze pages 2 job other.doc +500 @4000000042cf0665 root an early Xmas present ;-)
Use a tool to check the current balance:
# pracc-sum wimmer acct wimmer balance 920 limit 9 ok
After printing many more jobs, user wimmer runs out of credits:
# pracc-sum wimmer acct wimmer balance -20 limit 9 bad
User wimmer buys new credits. Then the purging operation is performed. The resulting pracc file looks like this:
#pracc-v2-0-wimmer Waldemar Immerfroh $9 @4000000042cda28c root minimum balance =500 @4000000042cda28c root initial credit =30 @4000000043341ac2 root balance +1000 @4000000043341ac2 root new credits bought
The sequence of debits and credits was accumulated and the resulting balance written to the new pracc file in place of the individual debit and credit lines. All comment lines were preserved. Finally, the credit software appended a credit line according to the amount of credits bought.
V1 pracc files had group ownership lp so that LPRng could directly append a debit line.
The limit line in pracc files is new with v2.
Timestamp format changed with v2.
Note that most pracc tools work with both versions because they only evaluate the first field on every line and ignore unknown line types.