home *** CD-ROM | disk | FTP | other *** search
- From decwrl!sun-barr!cs.utexas.edu!uunet!allbery Sat Aug 5 22:20:35 PDT 1989
- Article 1015 of comp.sources.misc:
- Path: decwrl!sun-barr!cs.utexas.edu!uunet!allbery
- From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
- Newsgroups: comp.sources.misc
- Subject: v07i114: HP LaserJet interface for SysV lp spooling
- Message-ID: <62666@uunet.UU.NET>
- Date: 6 Aug 89 02:07:46 GMT
- Sender: allbery@uunet.UU.NET
- Reply-To: davidsen@crdos1.crd.ge.com (Wm E Davidsen Jr)
- Organization: GE Corporate R&D Center
- Lines: 287
- Approved: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
-
- Posting-number: Volume 7, Issue 114
- Submitted-by: davidsen@crdos1.crd.ge.com (Wm E Davidsen Jr)
- Archive-name: lj.lp
-
- I mentioned that I had a good LJ interface on my system and I got over
- 30 requests for a copy. Here it is in all its trivial glory. Contained
- here are the interface program, the driver program, and the initializer
- file for fonts allowed as options. Since the init files contain escape
- sequences and line which don't end in newline, I uuencoded them.
-
- Note: SunOS users will have to make a directory world writable before
- unsharing, due to a bug in the Sun uudecode which makes all files it
- creates owned by uucp. I put my personal uudecode in my PATH before the
- system version.
-
- No man page, no read me... if you don't understand SysV spooling you
- need more than I can write.
-
- #!/bin/sh
- # shar: Shell Archiver (v1.24)
- #
- # Run the following text with /bin/sh to create:
- # ljet
- # lj.c
- # LJ.102x66
- # LJ.102x66m
- # LJ.102x68m
- # LJ.132x100
- # LJ.132x100m
- # LJ.132x90m
- # LJ.land16
- # LJ.land8
- # LJ.reset
- #
- echo "x - extracting ljet (Text)"
- sed 's/^X//' << 'SHAR_EOF' > ljet &&
- X:
- X#
- X
- X# ---------------- start custom area ----------------
- X
- X# define the directory for the font starter files
- X# note that these are not downloadable fonts, they just
- X# select the fonts which must be in the printer already
- XFONTS=/u/local/etc
- X
- X# set default display program
- Xdispprog=/u/local/bin/lj
- X
- X# nice value for the display program
- X# if you have a parallel port and a large LJ memory you can
- X# get a lot of system load, set this higher as needed.
- XNICE=6 # parallel port, 1MB memory
- X
- X# ---------------- you shouldn't have to go any farther ----------------
- X
- X# set things from the original arguments
- Xprinter=`basename $0`
- Xrequest=$1
- Xname=$2
- Xtitle=$3
- Xcopies=$4
- Xoptions=$5
- Xshift; shift; shift; shift; shift
- X
- X# If it is necessary to change the baud rate or other stty settings for
- X# your serial printer insert a line similar to the following here:
- X# stty option ... 0<&1
- X
- X# reset the printer
- Xecho "\033E\c"
- X
- X# border around the banner
- Xx="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
- X
- X# the fifth field of the /etc/passwd file is assigned to the variable user
- Xuser=`sed -n "s/^$name:.*:.*:.*:\(.*\):.*:.*$/\1/p" /etc/passwd`
- X
- X# nhead gets the value of BANNERS or 1 by default
- Xnhead=`sed -n 's/^BANNERS=//p' /etc/default/lpd`
- X[ "$nhead" -ge 0 -a "$nhead" -le 5 ] || nhead=1
- X
- X# print the banner $nhead times
- Xwhile [ "$nhead" -gt 0 ]
- Xdo
- X echo "$x\n"
- X banner "$name"
- X echo "$x\n"
- X [ "$user" ] && echo "User: $user\n"
- X echo "Request id: $request\n"
- X echo "Printer: $printer\n"
- X date
- X echo
- X [ "$title" ] && banner $title
- X echo "\f\c"
- X nhead=`expr $nhead - 1`
- Xdone | /u/local/bin/lj
- X
- X# process option(s)
- Xfor opt in $options
- Xdo case $opt in
- X 16) # 16 pitch
- X cat ${FONTS}/LJ.132x100;;
- X 16m) # 16 pitch with 3/4" margin
- X cat ${FONTS}/LJ.132x100m;;
- X 16m8) # 16 pitch with margin, 8.5 point
- X cat ${FONTS}/LJ.132x90m;;
- X 12) # 12 point/pitch
- X cat ${FONTS}/LJ.102x66;;
- X m|12m) # 12 pitch with 3/4" margin
- X cat ${FONTS}/LJ.102x66m;;
- X r) #raw mode
- X dispprog=cat;;
- X l) # landscape print mode
- X cat ${FONTS}/LJ.land16;;
- X esac
- Xdone
- X
- X# send the file(s) to the standard out $copies times
- Xwhile [ "$copies" -gt 0 ]
- Xdo filenum=1
- X for file
- X do
- X nice -${NICE} $dispprog <$file 2>&1
- X if [ $filenum -lt $# ]
- X then echo "\f\c"
- X filenum=`expr $filenum + 1`
- X fi
- X done
- X copies=`expr $copies - 1`
- X # form feed if more to come
- X if [ "$copies" -gt 0 ]; then echo "\f\c"; fi
- Xdone
- X
- X# reset the printer - force the last page out
- Xecho "\033E\c"
- X
- Xexit 0
- SHAR_EOF
- chmod 0755 ljet || echo "restore of ljet fails"
- echo "x - extracting lj.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > lj.c &&
- X/*****************************************************************
- X | lj - HP Laserjet output filter
- X |----------------------------------------------------------------
- X | Author: Bill Davidsen 10-5-86
- X |
- X | Adds returns before newlines and expands tabs
- X ****************************************************************/
- X
- X#include <stdio.h>
- X
- X#define TRUE 1
- X#define FALSE 0
- X
- Xmain ()
- X{
- X register int ch, /* input character */
- X column = 0, /* for tab expansion */
- X wasret = FALSE; /* flag if last char was RETURN */
- X
- X while ((ch = getchar ()) != EOF)
- X { /* check for newline, add return */
- X switch (ch) {
- X case '\n': /* newline */
- X if (!wasret)
- X putchar ('\r');
- X case '\r': /* return */
- X column = 0;
- X wasret = TRUE;
- X break;
- X case '\t': /* tab */
- X while ((column++ & 7) != 7)
- X { /* tab via spaces */
- X putchar (' ');
- X }
- X wasret = FALSE;
- X ch = ' '; /* output as blank */
- X break;
- X default: /* anything else */
- X column++;
- X wasret = FALSE;
- X }
- X
- X putchar (ch);
- X }
- X}
- SHAR_EOF
- chmod 0644 lj.c || echo "restore of lj.c fails"
- echo "x - extracting LJ.102x66 (Binary)"
- sed 's/^X//' << 'SHAR_EOF' > s2_temp_.tmp &&
- Xbegin 600 LJ.102x66
- X8&T4;*',Q,'8Q,D@;)FPT93<N-#5C-C9&
- X`
- Xend
- SHAR_EOF
- echo "uudecoding file LJ.102x66"
- uudecode < s2_temp_.tmp && rm -f s2_temp_.tmp &&
- chmod 0644 LJ.102x66 || echo "restore of LJ.102x66 fails"
- echo "x - extracting LJ.102x66m (Binary)"
- sed 's/^X//' << 'SHAR_EOF' > s2_temp_.tmp &&
- Xbegin 600 LJ.102x66m
- X=&T4;*',Q,'8Q,D@;)FPT93<N,#5C-C9&&R9A.4P`
- X`
- Xend
- SHAR_EOF
- echo "uudecoding file LJ.102x66m"
- uudecode < s2_temp_.tmp && rm -f s2_temp_.tmp &&
- chmod 0644 LJ.102x66m || echo "restore of LJ.102x66m fails"
- echo "x - extracting LJ.102x68m (Binary)"
- sed 's/^X//' << 'SHAR_EOF' > s2_temp_.tmp &&
- Xbegin 600 LJ.102x68m
- X=&T4;*',Q,'8Q,D@;)FPT93<N,#5C-CA&&R9A.4P`
- X`
- Xend
- SHAR_EOF
- echo "uudecoding file LJ.102x68m"
- uudecode < s2_temp_.tmp && rm -f s2_temp_.tmp &&
- chmod 0644 LJ.102x68m || echo "restore of LJ.102x68m fails"
- echo "x - extracting LJ.132x100 (Binary)"
- sed 's/^X//' << 'SHAR_EOF' > s2_temp_.tmp &&
- Xbegin 600 LJ.132x100
- X9&T4;*',W=C$V+C5(&R9L,F4T+CAC,3(P1@``
- X`
- Xend
- SHAR_EOF
- echo "uudecoding file LJ.132x100"
- uudecode < s2_temp_.tmp && rm -f s2_temp_.tmp &&
- chmod 0644 LJ.132x100 || echo "restore of LJ.132x100 fails"
- echo "x - extracting LJ.132x100m (Binary)"
- sed 's/^X//' << 'SHAR_EOF' > s2_temp_.tmp &&
- Xbegin 600 LJ.132x100m
- X?&T4;*',W=C$V+C5(&R9L,F4T+CAC,3(P1ALF83$R3``+
- X`
- Xend
- SHAR_EOF
- echo "uudecoding file LJ.132x100m"
- uudecode < s2_temp_.tmp && rm -f s2_temp_.tmp &&
- chmod 0644 LJ.132x100m || echo "restore of LJ.132x100m fails"
- echo "x - extracting LJ.132x90m (Binary)"
- sed 's/^X//' << 'SHAR_EOF' > s2_temp_.tmp &&
- Xbegin 600 LJ.132x90m
- XB&T4;*',X+C5V,38N-4@;)FPR934N,S-C,3(P1ALF83$R3```
- X`
- Xend
- SHAR_EOF
- echo "uudecoding file LJ.132x90m"
- uudecode < s2_temp_.tmp && rm -f s2_temp_.tmp &&
- chmod 0644 LJ.132x90m || echo "restore of LJ.132x90m fails"
- echo "x - extracting LJ.land16 (Binary)"
- sed 's/^X//' << 'SHAR_EOF' > s2_temp_.tmp &&
- Xbegin 600 LJ.land16
- XD&T4;)FPQ;S@N,T0;*#A5&RAS,'`Q-BXV:#@N-78P<S!B,%0*
- X`
- Xend
- SHAR_EOF
- echo "uudecoding file LJ.land16"
- uudecode < s2_temp_.tmp && rm -f s2_temp_.tmp &&
- chmod 0644 LJ.land16 || echo "restore of LJ.land16 fails"
- echo "x - extracting LJ.land8 (Binary)"
- sed 's/^X//' << 'SHAR_EOF' > s2_temp_.tmp &&
- Xbegin 600 LJ.land8
- X=&T4;)FPQ3QLH.%4;*',P<#$P:#$R=C!S,&(S5`H`
- X`
- Xend
- SHAR_EOF
- echo "uudecoding file LJ.land8"
- uudecode < s2_temp_.tmp && rm -f s2_temp_.tmp &&
- chmod 0644 LJ.land8 || echo "restore of LJ.land8 fails"
- echo "x - extracting LJ.reset (Binary)"
- sed 's/^X//' << 'SHAR_EOF' > s2_temp_.tmp &&
- Xbegin 600 LJ.reset
- X"&T6N
- X`
- Xend
- SHAR_EOF
- echo "uudecoding file LJ.reset"
- uudecode < s2_temp_.tmp && rm -f s2_temp_.tmp &&
- chmod 0644 LJ.reset || echo "restore of LJ.reset fails"
- exit 0
-
- --
- bill davidsen (davidsen@crdos1.crd.GE.COM -or- davidsen@crdos1.uucp)
- {uunet | philabs}!crdgw1!crdos1!davidsen
- "The world is filled with fools. They blindly follow their so-called
- 'reason' in the face of the church and common sense. Any fool can see
- that the world is flat!" - anon
-
-
-