home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume7 / lj.lp < prev    next >
Encoding:
Text File  |  1989-08-05  |  8.1 KB  |  295 lines

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