home *** CD-ROM | disk | FTP | other *** search
/ ftp.mayn.de / ftp.mayn.de-pub.zip / ftp.mayn.de-pub / apple / apple_unix / Info / DeskWriter.txt < prev    next >
Text File  |  2017-03-06  |  15KB  |  416 lines

  1. This is a copy of a posting on comp.unix.aux about using an HP DeskWriter
  2. under A/UX.
  3.  
  4. -------------------------------------------------------------------------
  5.  
  6. Path: skates.gsfc.nasa.gov!ames!agate!howland.reston.ans.net!noc.near.net!transfer.stratus.com!greer.az.stratus.com!user
  7. From: mp@az.stratus.com (Mike Peters)
  8. Newsgroups: comp.unix.aux
  9. Subject: Re: Problems of a newcomer
  10. Followup-To: comp.unix.aux
  11. Date: 10 Jul 1993 05:17:10 GMT
  12. Organization: Stratus Computer, Inc.
  13. Lines: 392
  14. Distribution: world
  15. Message-ID: <mp-090793222020@greer.az.stratus.com>
  16. References: <YgCvpLi00WB44Q_o9t@andrew.cmu.edu> <1907@jagubox.gsfc.nasa.gov> <mp-090793184650@kohlsranch.az.stratus.com>
  17. NNTP-Posting-Host: greer.az.stratus.com
  18.  
  19. In article <mp-090793184650@kohlsranch.az.stratus.com>,
  20. mp@tucson.az.stratus.com (Mike Peters) wrote:
  21. > I use an HP DeskWriterC on LocalTalk with 3.0 with no problems.  The MacOS
  22. > (whild running A/UX prints to it via SuperLaserSpool (3.1 I think) and I
  23. > can use lpr to spool to it from A/UX (I saw a post a while back that
  24. > supplied all of the required info to make it work under A/UX.  Things like
  25. > the printcap and filter code). I'm not running A/UX right now (shame on me
  26. > }:-( ) but I can repost the info and give credit to the original offer.
  27.  
  28. Well, I ended up bringing up A/UX :-) so here is the info I mentioned. 
  29.  
  30. Jim, perhaps this could be included in the FAQ and the information could be
  31. posted on jagubox?  When I first got A/UX a year or so ago, I struggled for
  32. weeks to get my DeskWriter working and finally gave up after numerous posts
  33. to this group went unanswered.  Finally, I saw Jeff's post recently and can
  34. finally use my printer.
  35.  
  36. Disclaimer:  I said it, not Stratus!
  37. ----------------------------------------------------------------------
  38. Mike Peters                     Unix Mail: mp@az.stratus.com
  39. Consulting Systems Engineer      VOS Mail: Mike_Peters@vos.stratus.com
  40. Stratus Computer, Inc.         Voice Mail: (602) 852-3002
  41. ----------------------------------------------------------------------
  42.  
  43. ~From: jdh@hare.udev.cdc.com (jeff holmbeck)
  44. ~Subject: Re: Printing w/ DeskWriter under A/UX 3.0
  45. Organization: Control Data
  46. ~Date: Sat, 12 Jun 1993 22:47:07 GMT
  47. Message-ID: <C8J5yK.EpK@raistlin.udev.cdc.com>
  48. X-Newsreader: TIN [version 1.1 PL9]
  49. ~References: <C8EuEq.K79@news.claremont.edu>
  50. ~Sender: usenet@raistlin.udev.cdc.com (News poster)
  51. ~Lines: 347
  52.  
  53. Philip Winston (pwinston@jarthur.claremont.edu) wrote:
  54. : Any idea on getting the printer to work with the Chooser/Mac App route or
  55. : the lpr/printcap route??  Thanks for any help.
  56.  
  57. I haven't tried 3.9 yet on A/UX, but 3.1 works fine on the Mac OS side.
  58. I just ran the DeskWriter installer on my personal System Folder.
  59.  
  60. I have been able to get text files on the UNIX side to print on my
  61. DeskWriter.
  62. If you specify the proper name on the "atprint" command, you can send text
  63. to
  64. the DeskWriter and get some output in an ugly monospaced font.  Here
  65. are some rules that I have discovered:
  66.  
  67.         1. You need both a carriage return and line feed after each line.
  68.         2. Backspace works as expected so you can overprint.
  69.         3. Tab does not work.  You have to replace a tab by the appropriate
  70.            number of spaces.
  71.         4. Form Feed works as expected to start a new page.
  72.         5. The maximum line size is 80 character.
  73.         6. The maximum page size appears to be 66 and 1/2 lines.  For best
  74.            results, send a Form Feed after each 66 lines.
  75.  
  76. Does anyone know if there are control sequences change the font, the style,
  77. etc.?
  78.  
  79. Following is what I did to get DeskWriter printing to work from my A/UX
  80. machine.  No guarentees, but I am sure you can adapt it for your
  81. environment.
  82.  
  83. First put an apropriate entry into your /etc/printcap file.  Something
  84. like this will do:
  85.  
  86. # DeskWriter
  87. dw|DeskWriter|deskwriter:\
  88.         :lp=/dev/null:\
  89.         :if=/usr/spool/lpd/DeskWriter/ifilter:\
  90.         :sd=/usr/spool/lpd/DeskWriter:
  91.  
  92. Create your spool directory:
  93.  
  94.         # mkdir /usr/spool/lpd/DeskWriter
  95.         # chown daemon /usr/spool/lpd/DeskWriter
  96.         # chgrp daemon /usr/spool/lpd/DeskWriter
  97.         # chmod 775 /usr/spool/lpd/DeskWriter
  98.  
  99. Use the atlookup command to find the full name of your DeskWriter.  On
  100. my machine, it is "DeskWriter:DeskWriter@*":
  101.  
  102.         # atlookup
  103.         Found 4 entries in zone *
  104.         0000.80.83 DeskWriter:DeskWriter
  105.  
  106. Create your /usr/spool/lpd/DeskWriter/ifilter script.  It should look
  107. something like this.  Be sure to use the name of your printer for the
  108. "Printer" variable:
  109.  
  110. -------- Begin ifilter ---------
  111. #!/bin/sh
  112. Printer=DeskWriter:DeskWriter@*
  113.  
  114. until [ -n "$status" -a -z "$error" ]
  115. do
  116.         status=`atstatus "$Printer"`
  117.         if [ $? -ne 0 ] ; then
  118.                 exit 2
  119.         fi
  120.  
  121.         error=`echo $status | fgrep Error`
  122.         if [ -n "$error" ] ; then
  123.                 echo $error 1>&2
  124.                 echo $error > status
  125.                 sleep 60
  126.         fi
  127. done
  128.  
  129. /usr/local/bin/dfilter -t | atprint "$Printer" 2> /dev/null
  130. -------- End   ifilter ---------
  131.  
  132. In the above example, lines will be indented by 8 spaces and lines of
  133. greater
  134. than 72 characters will be truncated.  This is handy for formatted output
  135. such
  136. as man pages or output from pr(1).  If you want long lines to be wrapped,
  137. remove the "-t" argument from the "dfilter" command.  If you don't want
  138. indentation, specify "-i 0".
  139.  
  140. Compile dfilter and put the binary into /usr/local/bin/dfilter.  The
  141. source of dfilter is:
  142.  
  143. -------- Begin dfilter.c ---------
  144. #include <stdio.h>
  145. #include <sys/types.h>
  146. #include <string.h>
  147.  
  148. extern  int     getopt();
  149. extern  void    *malloc();
  150. extern  void    *realloc();
  151. extern  long    strtol();
  152.  
  153. extern  char    *optarg;
  154. extern  int     optind;
  155.  
  156. #define BS '\010'
  157. #define CR '\015'
  158. #define FF '\014'
  159. #define LF '\n'
  160. #define NL '\n'
  161. #define SP ' '
  162. #define TAB '\011'
  163.  
  164. static  char    *getline();
  165.  
  166. static  int     literal = 0;    /* literal control characters */
  167. static  int     indent = 8;     /* indentation */
  168. static  char    *login = NULL;  /* login name */
  169. static  char    *host = NULL;   /* host name */
  170. static  char    *acct_file = NULL; /* accounting file name */
  171. static  int     pl = 66;        /* page length */
  172. static  int     pw = 80;        /* page width */
  173. static  int     truncate_lines = 0; /* set if long lines are truncated */
  174. static  int     ticount = 0;
  175. static  int     tlcount = 0;
  176. static  int     tocount = 0;
  177. static  int     tpcount = 0;
  178.  
  179. static  char    *eusage =
  180.         "Usage: %s [-c] [-w width] [-l length] [-i indent] [-n login] [-h
  181. host]
  182. [-t] [acct-file]\n";
  183.  
  184. int
  185. main(argc, argv)
  186.         int     argc;
  187.         char    **argv;
  188. {
  189.         char    *line;
  190.         int     len;
  191.         int     lcount;
  192.         int     ccount;
  193.         int     opt;
  194.         int     trunc;
  195.         char    *ptr;
  196.         int     scan;
  197.         int     index;
  198.  
  199.         /* crack optional arguments */
  200.         while ((opt = getopt(argc, argv, "cw:l:i:n:h:t")) != EOF) {
  201.                 switch (opt) {
  202.                 case 'c':       /* literal characters */
  203.                         literal = 1;
  204.                         break;
  205.                 case 'w':       /* page width */
  206.                         pw = (int) strtol(optarg, &ptr, 0);
  207.                         if (ptr[0] != '\0') {
  208.                                 fprintf(stderr, eusage, argv[0]);
  209.                                 exit(1);
  210.                         }
  211.                         break;
  212.                 case 'l':       /* page length */
  213.                         pl = (int) strtol(optarg, &ptr, 0);
  214.                         if (ptr[0] != '\0') {
  215.                                 fprintf(stderr, eusage, argv[0]);
  216.                                 exit(1);
  217.                         }
  218.                         break;
  219.                 case 'i':       /* indent */
  220.                         indent = (int) strtol(optarg, &ptr, 0);
  221.                         if (ptr[0] != '\0') {
  222.                                 fprintf(stderr, eusage, argv[0]);
  223.                                 exit(1);
  224.                         }
  225.                         break;
  226.                 case 'n':       /* login name */
  227.                         login = optarg;
  228.                         break;
  229.                 case 'h':       /* host name */
  230.                         host = optarg;
  231.                         break;
  232.                 case 't':       /* truncate long lines */
  233.                         truncate_lines = 1;
  234.                         break;
  235.                 }
  236.         }
  237.  
  238.         /* get accounting file name */
  239.         if (optind < argc) {
  240.                 acct_file = argv[optind];
  241.                 optind++;
  242.         }
  243.         if (optind != argc) {
  244.  
  245.                 /* too many arguments */
  246.                 fprintf(stderr, eusage, argv[0]);
  247.                 exit(1);
  248.         }
  249.  
  250.         /* initialize with a Carriage Return */
  251.         printf("%c", CR);
  252.         for (index = 0; index < indent; index++) {
  253.                 printf(" ");
  254.         }
  255.  
  256.         /* read each line of standard input */
  257.         lcount = 0;
  258.         while ((line = getline()) != NULL) {
  259.                 len = strlen(line);
  260.                 ticount += len;
  261.                 ccount = 0;
  262.                 trunc = 0;
  263.                 for (scan = 0; scan < len; scan++) {
  264.  
  265.                         /* check each character in the line */
  266.                         switch (line[scan]) {
  267.                         case TAB:
  268.  
  269.                                 /* Tab, print up to eight spaces */
  270.                                 for (index = 8 - (ccount % 8); index > 0;
  271.                                     index--) {
  272.                                         if (!trunc) {
  273.                                                 printf("%c", SP);
  274.                                         }
  275.                                         ccount++;
  276.                                         if (ccount >= (pw - indent)) {
  277.  
  278.                                                 /* no point tabbing beyond
  279.                                                    page width */
  280.                                                 break;
  281.                                         }
  282.                                 }
  283.                                 break;
  284.                         case BS:
  285.  
  286.                                 /* Back Space, decrement */
  287.                                 if (!trunc) {
  288.                                         printf("%c", BS);
  289.                                 }
  290.                                 if (ccount > 0) {
  291.                                         ccount--;
  292.                                 }
  293.                                 break;
  294.                         case NL:
  295.  
  296.                                 /* new line, we will handle it later */
  297.                                 break;
  298.                         default:
  299.  
  300.                                 /* regular character, just print it */
  301.                                 if (!trunc) {
  302.                                         printf("%c", line[scan]);
  303.                                         tocount++;
  304.                                 }
  305.                                 ccount++;
  306.                                 break;
  307.                         }
  308.                         if ((line[scan] == NL) || (ccount >= (pw -
  309. indent))) {
  310.  
  311.                                 /* Carriage Return/Line Feed required */
  312.                                 if (!trunc) {
  313.                                         printf("%c", CR);
  314.                                         lcount++;
  315.                                         if ((lcount % pl) == 0) {
  316.  
  317.                                                 /* end of page,
  318.                                                    force a Form Feed */
  319.                                                 printf("%c", FF);
  320.                                                 tpcount++;
  321.                                                 tocount++;
  322.                                         } else {
  323.  
  324.                                                 /* Line Feed is enough */
  325.                                                 printf("%c", LF);
  326.                                                 tlcount++;
  327.                                                 tocount++;
  328.                                         }
  329.                                         for (index = 0; index < indent;
  330.                                             index++) {
  331.                                                 printf(" ");
  332.                                         }
  333.                                 }
  334.                                 trunc = truncate_lines;
  335.                                 ccount = 0;
  336.                         }
  337.                 }
  338.         }
  339.  
  340.         /* make sure we finish with a Form Feed */
  341.         if ((lcount % pl) != 0) {
  342.                 printf("%c%c", CR, FF);
  343.                 tocount++;
  344.                 tpcount++;
  345.         }
  346.         exit(0);
  347. }
  348.  
  349. static  char    *
  350. getline()
  351. {
  352.         static  char    *line = NULL;
  353.         static  int     size = 0;
  354.         int     pos;
  355.         int     len;
  356.  
  357.         if (line == NULL) {
  358.                 size = 1024;
  359.                 if ((line = (char *) malloc(size)) == NULL) {
  360.                         size = 0;
  361.                         return (NULL);
  362.                 }
  363.         }
  364.         pos = 0;
  365.         while (fgets(&line[pos], 1024, stdin) == &line[pos]) {
  366.                 if (((len = strlen(line)) > 0) && (line[len - 1] == NL)) {
  367.                         pos += len;
  368.                         break;
  369.                 }
  370.                 if ((len + 1024) > size) {
  371.                         size += 1024;
  372.                         if ((line = (char *) realloc((char *) line, size))
  373. ==
  374.                             NULL) {
  375.                                 size = 0;
  376.                                 return (NULL);
  377.                         }
  378.                 }
  379.         }
  380.         if (pos < 1) {
  381.                 return (NULL);
  382.         }
  383.         return (line);
  384. }
  385. -------- End   dfilter.c ---------
  386.  
  387. Some things that are not in dfilter that might be nice to have:
  388.  
  389.         1. lpd accounting
  390.         2. print pages in reverse order
  391.         3. print only odd or even pages
  392.  
  393.  
  394. Kill lpd, restart it, and try printing something, like a man page:
  395.  
  396.         # kill XXXX
  397.         # /usr/lib/lpd
  398.         # man ls | lpr -Pdw
  399.  
  400.  
  401.  
  402. --
  403.  
  404. Jeff Holmbeck                   Control Data Systems, Inc.
  405. Jeff.Holmbeck@cdc.com           ARH215
  406. (612)482-3255                   4201 Lexington Avenue North
  407. fax: (612)482-2791              Arden Hills, MN 55126
  408. -----------------------------------------------------------
  409.  
  410.     Jim Jagielski               |  "Supreme executive power derives from
  411.     jim@jagubox.gsfc.nasa.gov   |   a mandate from the masses, not from
  412.     NASA/GSFC, Code 734.4       |   some farcical aquatic ceremony."
  413.     Greenbelt, MD 20771         |        - Dennis
  414.