Advanced Programming in the
UNIX Environment

by W. Richard Stevens
Addison-Wesley Professional Computing Series
0-201-56317-7 * Hardcover * 768 pages * ©1992
[Buy this book]

Chapter 17. Communicating with a PostScript Printer

Introduction * PostScript Communication Dynamics * Printer Spooling * Source Code * Summary

Example Relevant Functions
17.1 printer/lprps.h
Header file: all internal interfaces of lprps.
See below
17.2 printer/vars.c
lprps global variable declarations
17.3 printer/main.c
main program: process options, send file
to the printer, do accounting, send errors
from PS interpreter back to user
log_open (Stevens' lib),
log_msg (Stevens' lib),
log_sys (Stevens' lib),
tty_open, get_status, get_page,
send_file, do_acct,
getopt, atexit, exit
17.4 printer/acct.c
Write number of printed pages, hostname
and username into accounting file
log_sys (Stevens' lib),
fopen, fprintf, fclose
17.5 printer/tty.c
Terminal functions:
set_block, set_nonblock, block_write,
tty_flush, tty_open
log_sys (Stevens' lib),
fcntl write open,
tcgetattr, tcsetattr,
cfsetispeed, cfsetospeed,
17.6 printer/interrupt.c
Interrupt signal handling:
sig_int, handle_intr, set_intr, clear_intr
log_sys (Stevens' lib),
signal, exit,
set_alrm, clear_alrm,
tty_flush, block_write,
proc_upto_eof, get_page, do_acct, signal_intr
17.7 printer/alarm.c
Timeouts handling:
sig_alrm, handle_alrm, set_alrm, clear_alrm
log_ret (Stevens' lib),
log_sys (Stevens' lib),
alarm, sleep, exit,
signal_intr, signal
17.8 printer/getstatus.c
Check status of printer before sending job
set_alrm, clear_alrm,
tty_flush, block_write,
init_input, proc_some_input,
sleep, exit
17.9 printer/pagecount.c
Fetch the printer's page count by sending the
appropriate PostScript program to the printer
set_alrm, clear_alrm,
tty_flush, block_write,
init_input, proc_some_input,
17.10 printer/sendfile.c
Send a file to the printer.
Called by main, to copy stdin to printer
init_input, set_intr,
getchar, out_char,
17.11 printer/mail.c
send any output that is not a status message
from the PS interpreter, by mail to user
log_sys (Stevens' lib),
fputs, putc, fprintf,
fopen, fclose,
sprintf, system, unlink
17.12 printer/output.c
Implements out_char which outputs a single
char to the printer but without blocking, and
while dealing with input from the printer.
Called in a tight loop by send_file
select, read, write,
log_sys (Stevens' lib),
set_nonblock, handle_intr,
17.13 printer/input.c
Read and process all input from the printer
init_input, proc_upto_eof, proc_some_input,
log_sys (Stevens' lib),
select, read,
set_nonblock, handle_intr,
handle_alrm, mail_char,
msg_init, msg_char,
17.14 printer/message.c
Process messages returned from the printer
(at the low level).
msg_init, msg_char, proc_msg,
log_msg (Stevens' lib),
isspace, strchr, strcmp,
sscanf, exit,
mail_line, clear_intr,
tty_flush, block_write,
proc_upto_eof get_page, do_acct

[Buy this book]