home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / misc / volume07 / lj.lp < prev    next >
Encoding:
Internet Message Format  |  1991-08-27  |  8.4 KB

  1. From decwrl!sun-barr!cs.utexas.edu!uunet!allbery Sat Aug  5 22:20:35 PDT 1989
  2. Article 1015 of comp.sources.misc:
  3. Path: decwrl!sun-barr!cs.utexas.edu!uunet!allbery
  4. From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  5. Newsgroups: comp.sources.misc
  6. Subject: v07i114: HP LaserJet interface for SysV lp spooling
  7. Message-ID: <62666@uunet.UU.NET>
  8. Date: 6 Aug 89 02:07:46 GMT
  9. Sender: allbery@uunet.UU.NET
  10. Reply-To: davidsen@crdos1.crd.ge.com (Wm E Davidsen Jr)
  11. Organization: GE Corporate R&D Center
  12. Lines: 287
  13. Approved: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  14.  
  15. Posting-number: Volume 7, Issue 114
  16. Submitted-by: davidsen@crdos1.crd.ge.com (Wm E Davidsen Jr)
  17. Archive-name: lj.lp
  18.  
  19. I mentioned that I had a good LJ interface on my system and I got over
  20. 30 requests for a copy. Here it is in all its trivial glory. Contained
  21. here are the interface program, the driver program, and the initializer
  22. file for fonts allowed as options. Since the init files contain escape
  23. sequences and line which don't end in newline, I uuencoded them.
  24.  
  25. Note: SunOS users will have to make a directory world writable before
  26. unsharing, due to a bug in the Sun uudecode which makes all files it
  27. creates owned by uucp. I put my personal uudecode in my PATH before the
  28. system version.
  29.  
  30. No man page, no read me... if you don't understand SysV spooling you
  31. need more than I can write.
  32.  
  33. #!/bin/sh
  34. # shar:    Shell Archiver  (v1.24)
  35. #
  36. #    Run the following text with /bin/sh to create:
  37. #      ljet
  38. #      lj.c
  39. #      LJ.102x66
  40. #      LJ.102x66m
  41. #      LJ.102x68m
  42. #      LJ.132x100
  43. #      LJ.132x100m
  44. #      LJ.132x90m
  45. #      LJ.land16
  46. #      LJ.land8
  47. #      LJ.reset
  48. #
  49. echo "x - extracting ljet (Text)"
  50. sed 's/^X//' << 'SHAR_EOF' > ljet &&
  51. X:
  52. X#
  53. X
  54. X# ---------------- start custom area ----------------
  55. X
  56. X# define the directory for the font starter files
  57. X#    note that these are not downloadable fonts, they just
  58. X#    select the fonts which must be in the printer already
  59. XFONTS=/u/local/etc
  60. X
  61. X# set default display program
  62. Xdispprog=/u/local/bin/lj
  63. X
  64. X# nice value for the display program
  65. X#    if you have a parallel port and a large LJ memory you can
  66. X#    get a lot of system load, set this higher as needed.
  67. XNICE=6        # parallel port, 1MB memory
  68. X
  69. X# ---------------- you shouldn't have to go any farther ----------------
  70. X
  71. X# set things from the original arguments
  72. Xprinter=`basename $0`
  73. Xrequest=$1
  74. Xname=$2
  75. Xtitle=$3
  76. Xcopies=$4
  77. Xoptions=$5
  78. Xshift; shift; shift; shift; shift
  79. X
  80. X# If it is necessary to change the baud rate or other stty settings for
  81. X# your serial printer insert a line similar to the following here:
  82. X# stty option ... 0<&1
  83. X
  84. X# reset the printer
  85. Xecho "\033E\c"
  86. X
  87. X# border around the banner
  88. Xx="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  89. X
  90. X# the fifth field of the /etc/passwd file is assigned to the variable user
  91. Xuser=`sed -n "s/^$name:.*:.*:.*:\(.*\):.*:.*$/\1/p" /etc/passwd`
  92. X
  93. X# nhead gets the value of BANNERS or 1 by default
  94. Xnhead=`sed -n 's/^BANNERS=//p' /etc/default/lpd`
  95. X[ "$nhead" -ge 0 -a "$nhead" -le 5 ] || nhead=1
  96. X
  97. X# print the banner $nhead times
  98. Xwhile    [ "$nhead" -gt 0 ]
  99. Xdo
  100. X    echo "$x\n"
  101. X    banner "$name"
  102. X    echo "$x\n"
  103. X    [ "$user" ] && echo "User: $user\n"
  104. X    echo "Request id: $request\n"
  105. X    echo "Printer: $printer\n"
  106. X    date
  107. X    echo
  108. X    [ "$title" ] && banner $title
  109. X    echo "\f\c"
  110. X    nhead=`expr $nhead - 1`
  111. Xdone | /u/local/bin/lj
  112. X
  113. X# process option(s)
  114. Xfor opt in $options
  115. Xdo    case $opt in
  116. X    16)    # 16 pitch
  117. X        cat ${FONTS}/LJ.132x100;;
  118. X    16m)    # 16 pitch with 3/4" margin
  119. X        cat ${FONTS}/LJ.132x100m;;
  120. X    16m8)    # 16 pitch with margin, 8.5 point
  121. X        cat ${FONTS}/LJ.132x90m;;
  122. X    12)    # 12 point/pitch
  123. X        cat ${FONTS}/LJ.102x66;;
  124. X    m|12m)    # 12 pitch with 3/4" margin
  125. X        cat ${FONTS}/LJ.102x66m;;
  126. X    r)    #raw mode
  127. X        dispprog=cat;;
  128. X    l)    # landscape print mode
  129. X        cat ${FONTS}/LJ.land16;;
  130. X    esac
  131. Xdone
  132. X
  133. X# send the file(s) to the standard out $copies times
  134. Xwhile    [ "$copies" -gt 0 ]
  135. Xdo    filenum=1
  136. X    for file
  137. X    do
  138. X        nice -${NICE} $dispprog <$file 2>&1
  139. X        if [ $filenum -lt $# ]
  140. X        then    echo "\f\c"
  141. X            filenum=`expr $filenum + 1`
  142. X        fi
  143. X    done
  144. X    copies=`expr $copies - 1`
  145. X    # form feed if more to come
  146. X    if [ "$copies" -gt 0 ]; then echo "\f\c"; fi
  147. Xdone
  148. X
  149. X# reset the printer - force the last page out
  150. Xecho "\033E\c"
  151. X
  152. Xexit 0
  153. SHAR_EOF
  154. chmod 0755 ljet || echo "restore of ljet fails"
  155. echo "x - extracting lj.c (Text)"
  156. sed 's/^X//' << 'SHAR_EOF' > lj.c &&
  157. X/*****************************************************************
  158. X |  lj - HP Laserjet output filter
  159. X |----------------------------------------------------------------
  160. X |  Author: Bill Davidsen 10-5-86
  161. X |
  162. X |  Adds returns before newlines and expands tabs
  163. X ****************************************************************/
  164. X
  165. X#include <stdio.h>
  166. X
  167. X#define TRUE    1
  168. X#define FALSE    0
  169. X
  170. Xmain ()
  171. X{
  172. X    register int  ch,        /* input character */
  173. X                  column = 0,    /* for tab expansion */
  174. X                  wasret = FALSE; /* flag if last char was RETURN */
  175. X
  176. X    while ((ch = getchar ()) != EOF)
  177. X    { /* check for newline, add return */
  178. X    switch (ch) {
  179. X    case '\n': /* newline */
  180. X        if (!wasret)
  181. X        putchar ('\r');
  182. X    case '\r': /* return */
  183. X        column = 0;
  184. X        wasret = TRUE;
  185. X        break;
  186. X    case '\t': /* tab */
  187. X        while ((column++ & 7) != 7)
  188. X        { /* tab via spaces */
  189. X        putchar (' ');
  190. X        }
  191. X        wasret = FALSE;
  192. X        ch = ' '; /* output as blank */
  193. X        break;
  194. X    default: /* anything else */
  195. X        column++;
  196. X        wasret = FALSE;
  197. X    }
  198. X
  199. X    putchar (ch);
  200. X    }
  201. X}
  202. SHAR_EOF
  203. chmod 0644 lj.c || echo "restore of lj.c fails"
  204. echo "x - extracting LJ.102x66 (Binary)"
  205. sed 's/^X//' << 'SHAR_EOF' > s2_temp_.tmp &&
  206. Xbegin 600 LJ.102x66
  207. X8&T4;*',Q,'8Q,D@;)FPT93<N-#5C-C9&
  208. X`
  209. Xend
  210. SHAR_EOF
  211. echo "uudecoding file LJ.102x66"
  212. uudecode < s2_temp_.tmp && rm -f s2_temp_.tmp &&
  213. chmod 0644 LJ.102x66 || echo "restore of LJ.102x66 fails"
  214. echo "x - extracting LJ.102x66m (Binary)"
  215. sed 's/^X//' << 'SHAR_EOF' > s2_temp_.tmp &&
  216. Xbegin 600 LJ.102x66m
  217. X=&T4;*',Q,'8Q,D@;)FPT93<N,#5C-C9&&R9A.4P`
  218. X`
  219. Xend
  220. SHAR_EOF
  221. echo "uudecoding file LJ.102x66m"
  222. uudecode < s2_temp_.tmp && rm -f s2_temp_.tmp &&
  223. chmod 0644 LJ.102x66m || echo "restore of LJ.102x66m fails"
  224. echo "x - extracting LJ.102x68m (Binary)"
  225. sed 's/^X//' << 'SHAR_EOF' > s2_temp_.tmp &&
  226. Xbegin 600 LJ.102x68m
  227. X=&T4;*',Q,'8Q,D@;)FPT93<N,#5C-CA&&R9A.4P`
  228. X`
  229. Xend
  230. SHAR_EOF
  231. echo "uudecoding file LJ.102x68m"
  232. uudecode < s2_temp_.tmp && rm -f s2_temp_.tmp &&
  233. chmod 0644 LJ.102x68m || echo "restore of LJ.102x68m fails"
  234. echo "x - extracting LJ.132x100 (Binary)"
  235. sed 's/^X//' << 'SHAR_EOF' > s2_temp_.tmp &&
  236. Xbegin 600 LJ.132x100
  237. X9&T4;*',W=C$V+C5(&R9L,F4T+CAC,3(P1@``
  238. X`
  239. Xend
  240. SHAR_EOF
  241. echo "uudecoding file LJ.132x100"
  242. uudecode < s2_temp_.tmp && rm -f s2_temp_.tmp &&
  243. chmod 0644 LJ.132x100 || echo "restore of LJ.132x100 fails"
  244. echo "x - extracting LJ.132x100m (Binary)"
  245. sed 's/^X//' << 'SHAR_EOF' > s2_temp_.tmp &&
  246. Xbegin 600 LJ.132x100m
  247. X?&T4;*',W=C$V+C5(&R9L,F4T+CAC,3(P1ALF83$R3``+
  248. X`
  249. Xend
  250. SHAR_EOF
  251. echo "uudecoding file LJ.132x100m"
  252. uudecode < s2_temp_.tmp && rm -f s2_temp_.tmp &&
  253. chmod 0644 LJ.132x100m || echo "restore of LJ.132x100m fails"
  254. echo "x - extracting LJ.132x90m (Binary)"
  255. sed 's/^X//' << 'SHAR_EOF' > s2_temp_.tmp &&
  256. Xbegin 600 LJ.132x90m
  257. XB&T4;*',X+C5V,38N-4@;)FPR934N,S-C,3(P1ALF83$R3```
  258. X`
  259. Xend
  260. SHAR_EOF
  261. echo "uudecoding file LJ.132x90m"
  262. uudecode < s2_temp_.tmp && rm -f s2_temp_.tmp &&
  263. chmod 0644 LJ.132x90m || echo "restore of LJ.132x90m fails"
  264. echo "x - extracting LJ.land16 (Binary)"
  265. sed 's/^X//' << 'SHAR_EOF' > s2_temp_.tmp &&
  266. Xbegin 600 LJ.land16
  267. XD&T4;)FPQ;S@N,T0;*#A5&RAS,'`Q-BXV:#@N-78P<S!B,%0*
  268. X`
  269. Xend
  270. SHAR_EOF
  271. echo "uudecoding file LJ.land16"
  272. uudecode < s2_temp_.tmp && rm -f s2_temp_.tmp &&
  273. chmod 0644 LJ.land16 || echo "restore of LJ.land16 fails"
  274. echo "x - extracting LJ.land8 (Binary)"
  275. sed 's/^X//' << 'SHAR_EOF' > s2_temp_.tmp &&
  276. Xbegin 600 LJ.land8
  277. X=&T4;)FPQ3QLH.%4;*',P<#$P:#$R=C!S,&(S5`H`
  278. X`
  279. Xend
  280. SHAR_EOF
  281. echo "uudecoding file LJ.land8"
  282. uudecode < s2_temp_.tmp && rm -f s2_temp_.tmp &&
  283. chmod 0644 LJ.land8 || echo "restore of LJ.land8 fails"
  284. echo "x - extracting LJ.reset (Binary)"
  285. sed 's/^X//' << 'SHAR_EOF' > s2_temp_.tmp &&
  286. Xbegin 600 LJ.reset
  287. X"&T6N
  288. X`
  289. Xend
  290. SHAR_EOF
  291. echo "uudecoding file LJ.reset"
  292. uudecode < s2_temp_.tmp && rm -f s2_temp_.tmp &&
  293. chmod 0644 LJ.reset || echo "restore of LJ.reset fails"
  294. exit 0
  295.  
  296. -- 
  297. bill davidsen        (davidsen@crdos1.crd.GE.COM -or- davidsen@crdos1.uucp)
  298.             {uunet | philabs}!crdgw1!crdos1!davidsen
  299. "The world is filled with fools. They blindly follow their so-called
  300. 'reason' in the face of the church and common sense. Any fool can see
  301. that the world is flat!" - anon
  302.  
  303.  
  304.