[mod.mac.sources] Paintps.shar.1

macintosh@felix.UUCP (07/09/86)

     Here is the first of two shar files that contain paintps.  Paintps
is a UNIX program for printing MacPaint pictures on a LaserWriter that is
connected to a UNIX machine.  Also included are programs that allow other
Macintosh output to be printed on the LaserWriter.
     There are two different shar files in order to keep each one
under 32K in size.

Brian H. Powell
		UUCP:	{ihnp4,seismo,ctvax}!ut-sally!brian
		ARPA:	brian@sally.UTEXAS.EDU


# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by sally!brian on Tue Jul  8 16:19:05 CDT 1986
# Contents:  README README.SPOOL paintps.c paintps.1 Makefile maclaser.csh
#	maclaser.1
 
echo x - README
sed 's/^@//' > "README" <<'@//E*O*F README//'

     This shell archive contains a program called paintps which will convert
a MacPaint file (uploaded from a Mac) to PostScript for printing on a
LaserWriter.  It reads a plain MacPaint document as input and produces 
postscript output in the same style as that produced by the 1.1 version
of the Mac LaserWriter driver.  Paintps runs on unix and will automatically
spool its output for printing if no output redirection has been done.
The advantage of paintps is that MacPaint pictures are usually less than
25K, while the resulting PostScript often exceeds 100K.  This obviously
reduces the file transfer time.

     Also included is the version 1.1 laser-prep file, which is needed
by paintps, and a shell script called maclaser, which is called by paintps
to spool its output.  Maclaser is simply a front end to lpr, and depends
on the spooler setup described in the file README.SPOOL.  
     
     This code has been used with 4.2 and 4.3BSD; vaxen, Sun and Sequent
hardware.  We use the TranScript package from Adobe to drive the LaserWriter.
If you're using some other set of PostScript drivers, the spooler hacks
are basically the same, since there are no changes to the drivers themselves.

     Paintps is distantly related to a program called paintimp, originally
written by Dave Johnson at Brown University.  It converted MacPaint pictures
to Impress for printing on Imagens.  Ron Hitchens at the University of
Texas hacked on it a bit and added some features.  When we got a LW,
Brian Powell at UT was inspired to do something similar for PostScript.
The resulting paintps is very different from paintimp, but paintimp did
provide the structure and a few subroutines.  Maclaser and the spooler hacks
were conceived by Ron Hitchens' twisted mind.

     There are several different critters in this distribution.  They 
probably won't all want to live in the same place.  A makefile is included
for paintps, mainly because it was already there.  Use your local customs
for determining where things should go.

     NOTE:  Maclaser can print PostScript generated by any Macintosh program,
not just MacPaint.  (See the man page for maclaser for details.)  For now, you
must use version 1.1 of the LaserWriter driver to generate the PostScript on
the Macintosh.
     You do not have to have the LaserWriter printer driver on the Macintosh
to use paintps.
     When Apple settles down on their Printer Drivers, I will modify this
code to support the latest 3.* LaserWriter driver.  The latest driver I have
seen is version 3.1, and I don't think it will be hard to modify paintps to
produce that driver's new format.
     And by the way, the "Chooser" desk accessory won't install the version 1.1
LaserWriter driver.  To use LaserWriter 1.1 with the new systems, simply install
and use "Choose Printer" (from Finder 4.1 days).  I have noticed no problems
using the old driver with the new ROMS or new system.

-------------------------
Brian Powell	brian@sally.utexas.edu
Ron Hitchens	hitchens@sally.utexas.edu
@//E*O*F README//
chmod u=rw,g=rw,o=r README
 
echo x - README.SPOOL
sed 's/^@//' > "README.SPOOL" <<'@//E*O*F README.SPOOL//'

   Paintps depends on the "Mac environment" being present in the LaserWriter
at the time its Postscript output is processed.  This environment is setup
by the laser-prep prolog file which is prepended by the Mac print drivers
when a Mac prints directly to a LaserWriter.  Since paintps basically
mimics what MacPaint does when it prints a file on a LW, something needs
to be done to provide the Mac environment in the LW with the Unix system.

   The same applies to any "Mac PostScript" file produced on a Mac and
captured with the Command-F sequence and then uploaded to a Unix machine.
The remaining discussion concerns printing Mac files to a LaserWriter
being driven by a Unix (4.2 or 4.3 BSD) spooler and which is primarily
used for general text processing, not for Mac output.  The output of
paintps is considered a "Mac file", even though it's produced on a
Unix system, and is included in the general discussion below.

   The first step is to get the laser-prep prolog file, so that it can be
sent to the LW via the spooler.  The laser-prep file must be modified
for use with the spooler.  There are two reasons why.
	1) The standard laser-prep installs itself permanently, on the
	   assumption that the LW is living in a Mac-only universe.  The
	   amount of memory it consumes is substantial and we aren't
	   willing to give it away to accomodate the occasional Mac
	   job sent via the Unix spooler.  Removing the few lines
	   at the beginning which escape from the server loop is
	   sufficient to prevent permanent residency.
	2) The encrypted smoothing function in the laser-prep is fed
	   as stdin to an eexec command which will read until eof.  Since
	   what we're trying to accomplish is to have the laser-prep only
	   live for the duration of a single job, this presents a problem.
	   Luckily the eexec command will also accept a string argument
	   on the stack, so by placing hex quotes (<>) around the smoothing
	   code and calling eexec after it has been placed on the stack,
	   we get the same effect plus the ability to continue sending
	   PostScript code afterwards.  Hence, we can simply concatenate
	   the modified laser-prep and the Mac PostScript file and send
	   it to the printer, the Mac environment will be there for the
	   job and will be flushed afterwards.
   This will also allow us to support more than one version of the LaserWriter
driver in the future (which we intend to do.)  Since the laser-prep won't be
in the LW RAM, we can prepend any laser-prep without causing a conflict.

   Now, there are a couple of ways to handle a Mac PostScript job via
the Unix spooler.
	1) On the front end of the spooler thru lpr, such as:
		paintps foo.mp > foo.ps
		cat /usr/local/lib/laser-prep.pro foo.ps | lpr -Plw
	   This is the most generic and doesn't require anything special
	   be done on the unix system.  The drawbacks are that a current
	   copy of the laser-prep must be present on every system that might
	   spool a job, that users know where it is, and that they know
	   the proper incantations.  A shell script could be written to
	   hide the above commands, but that still requires multiple
	   copies of the laser-prep file.
	2) In the back end of the spooler, by having a filter automatically
	   prepend the laser-prep to all Mac PostScript jobs.  This is 
	   the most elegant way to handle it, since only one copy of the
	   laser-prep need exist on the system where the printer is, and
	   the details of handling Mac specific files are hidden from
	   the user.  This method requires selecting a "file type" for
	   spooling Mac jobs and specifying the proper handlers on the
	   system where the printer is.  At UT we chose the "Fortran"
	   file type, since it was unused.  Others could be used but
	   there aren't many candidates, especially if you already
	   support ditroff and/or TeX.  We handle spooling of Mac files
	   with a shell script which simply calls lpr and adds the -f
	   file type flag.

   The discussion below assumes the reader is familiar with how the 
Berkeley spooler works and knows how to setup filters.  The person
who does this must have super-user access anyway.  Once again there
are two ways to go about setting up your spooler to handle Mac PostScript
files:
	1) If you're using the standard Transcript setup, use the psmac
	   shell script included.  Put it in /usr/local/lib, or where
	   you keep the rest of your filters, and put its name in the
	   printcap slot for whichever file type you use (the rf field
	   is for the Fortran type, go figure).
	2) If you're using an Imagen-style shell script which is called
	   by several different names, use our psfilter (included) as
	   a guide and include a case for handling Mac files as shown.
	   This approach is kind of odd, and can lead to various problems,
	   but allows more flexibility and enables you to do things
	   like complex pipelines and problem notification.  Psfilter
	   is what we use at UT, you may or may not find it useful.
	   In any case you can ignore the local hacks for dealing
	   with LaserWriters on Bridges (unless you have some, I might
	   be able to help).

   The program macfilter, named in both psmac and psfilter, does nothing
more than convert any non-printable characters in the data stream to 
the octal equivalent.  Apple broke the rules and used non-printable
characters (specifically non-ascii > 128) for certain symbols.  These
don't survice the unix device driver (they lose the high bit) and raw
mode is not possible because the LW needs to use flow control.

   Here is the /etc/printcap we use here at UT:
#
#
# Apple LaserWriter
# sb MUST be specified, psof depends on it.  psof prints job header page.
# rw must be specified, printer talks back to psif

lw-generic|Apple Laserwriter:\
	:rw:br#9600:ff=:tr=^D:sc:sb:\
	:of=/usr/local/lib/psof:\
	:df=/usr/local/lib/psdvi:\
	:nf=/usr/local/lib/psditroff:\
	:tf=/usr/local/lib/pscat:\
	:if=/usr/local/lib/psasc:\
	:cf=/usr/local/lib/psbad:\
	:gf=/usr/local/lib/psbad:\
	:vf=/usr/local/lib/psbad:\
	:rf=/usr/local/lib/psmac:

Lazarus|lw1|lw|lazarus|LW connected to im4u:\
	:lp=/dev/lw:sd=/usr/spool/lw1:\
	:xs#040400:fc#070:fs#00302:\
	:lf=/usr/adm/log-lw1:\
	:af=/usr/adm/lw.acct/lw1:\
	:tc=lw-generic:
-------------------
Ron Hitchens	University of Texas at Austin, Computer Science
hitchens@uo.cs.utexas.edu
hitchens@sally.UUCP
@//E*O*F README.SPOOL//
chmod u=rw,g=rw,o=r README.SPOOL
 
echo x - paintps.c
sed 's/^@//' > "paintps.c" <<'@//E*O*F paintps.c//'
#ifndef lint
static	char sccsid[] = "@(#)paintps.c	1.7 6/11/86 (UT)";
#endif

/*
 * paintps -- Convert MacPaint document to PostScript document 
 * 
 * Brian H. Powell, University of Texas at Austin
 *	brian@sally.UTEXAS.EDU
 *	brian@ut-sally.UUCP
 *	CS.Powell@r20.UTEXAS.EDU
 *
 * This program may be used but not sold without permission.
 *
 * Modification History
 * 	BHP	7/25/85	Created.
 *	BHP	7/31/85	Optimized output routines for execution speed.
 *	BHP	4/22/86	Added -P option, extracted spool command to Makefile.
 *	BHP	6/ 3/86 Fixed bug causing (rare) small white gaps between
 *			bitmaps.
 */

#include <stdio.h>
#include <ctype.h>

#define FALSE 0
#define TRUE  (-1)

#define MACPAINT_HDRSIZE	512
#define MACRASTER_BITWIDTH	576
#define	MACPAINT_BITHEIGHT	720

			/* DEFAULT OPTIONS */
int smooth = TRUE;		/* smoothing enabled */
int copies = 1;			/* one copy of the painting */
char *printername = NULL;	/* default printer */

char hexbuffer[MACPAINT_BITHEIGHT][MACRASTER_BITWIDTH/8];
int blank[MACPAINT_BITHEIGHT + 4];	/* we need the four extra blank */
					/* lines as filler for output */

char usage[] = "paintps [-d] [-#<n>] [-P<printer>] file";

main(ac, av)
char **av;
{
   ac--; av++;
   while (ac && (av[0][0] == '-') && av[0][1]) {
      switch (av[0][1]) {
	 case 'd':			/* "draft" option */
	    smooth = FALSE;
	    break;

	 case '#':			/* number of copies */
	    copies = atoi (&av[0][2]);
	    break;

	 case 'P':			/* printer name */
	    printername = av[0];
	    break;

	 default:
	    goto bad_usage;
      }
      ac--; av++;
   }
   open_output();		/* also starts spooling to the spool cmd. */
   paintfilter(av[0]);
   exit(0);

bad_usage:
   fprintf(stderr, "usage: %s\n", usage);
   exit(1);
}

/* convert from MacPaint to PostScript */

paintfilter(name)
char *name;
{
   register int x, y;
   FILE *fp;
   register int c;
   int blankline;

   fp = fopen(name, "r");		/* open the MacPaint file. */
   if (fp == NULL) {
      perror(name);
      return;
   }

   (void) fseek(fp, (long)MACPAINT_HDRSIZE, 0);	/* skip the MacPaint patterns */

   begin_image();				/* print postscript header */

/*  We skip horizontal whitespace.  "blankline" is used to diagnose this
    for the current line.  The boolean array "blank[y]" shows which lines
    in the entire painting are blank. */

   for (y = 0; y < MACPAINT_BITHEIGHT; y++) {
				/* for each pixel row... */
      blankline = TRUE;
      for (x = 0; x < MACRASTER_BITWIDTH/8; x++) {

         if ((c = getbits(fp)) == EOF) {
            fprintf(stderr, "Unexpected EOF, stopped.\n");
            for ( ; y < MACPAINT_BITHEIGHT; y++)		/* Mark the */
               blank[y] = TRUE;				/* rest of the page */
            blankline = TRUE;		       /* blank, print it and quit. */
            break;

         } else {
            hexbuffer[y][x] = (char) c;	  /* else record the character and */
            if (c)			  /* mark the line as non-blank. */
               blankline = FALSE;
         }
      }
      blank[y] = blankline;
   }
   blank[y++] = TRUE;		/* put four blank lines at end */
   blank[y++] = TRUE;		/* (I think this is needed for smoothing.) */
   blank[y++] = TRUE;
   blank[y] = TRUE;
   dump_buffer(hexbuffer, blank);	/* print the buffer (entire page) */

   end_imag(copies);		/* print the postscript trailer. */
   (void) fclose(fp);		/* close the file. */
}

/* macpaint input routines */

getbits(fp)		/* this routine scarfed from paintimp. */
FILE *fp;
{
/* This routine expands the PackBits encoded MacPaint file,
   delivering one byte per call.
*/

   static int count, rep, chr;
   int c;

   if (rep) {		/* if we are repeating a previous character, */
      rep--;		/* reduce the repeat count and return the char. */
      return chr;
   }
   if (count) {		/* if we are in an unrepeated section, reduce */
      count--;		/* the count and return next char from the file. */
      return getc(fp);
   }
   c = getc(fp);	/* otherwise, get the next repeat count.  */
   if (c & 0x80) {	/* if negative, repeat the next */
      rep = 0x100 - c;	/* byte (2's comp(c)+1) times. */
      chr = getc(fp);		/* the character to repeat */
      return chr;
   }
   else {		/* if repeat count is positive, next "count" bytes */
      count = c;   	/* are unencoded.  */
      return getc(fp);
   }
}

/* PostScript output routines */

open_output()
{
   char lpr [64];
   FILE *popen();

/* if stdout is going to the terminal, call the spool command to spool the
   output, otherwise assume it's being piped somewhere else
   or directed into a file.
*/
   if (isatty (fileno (stdout)))
   {
      (void) sprintf (lpr, "%s %s", SPOOLCMD,
			printername ? printername : "");
		/* include printer name if it was specified.  */

	/* disconnect stdout from the tty and pipe it to lpr */
      (void) fclose (stdout);
      if (popen (lpr, "w") == NULL) {
         fprintf(stderr, "%s failed, giving up.\n", lpr);
         exit(2);
      }
      fprintf(stderr, "Spooling to '%s'.\n", lpr);
   }

}

begin_image()		/* print the postscript header. */
{
   printf("%%!\n");		/* TranScript PostScript flag "%!" */
   printf("md begin\n");	/* standard apple header */
   printf("1320 od\n");
   printf("(; user: )jn\n");
   printf("%%%%EndProlog\n");
   printf("%%%%Page: ? ?\n");
   printf("op\n");
   printf("0 0 moveto\n");
}

/* The reason the following routine isn't called "end_image" is because */
/* of a bug in the Sequent C compiler.  */
end_imag(copies)	/* print the postscript trailer. */
int copies;		/* copies == number of copies to print */
{
   printf("%d page\n", copies - 1);	/* "page" takes # of pages to */
   printf("cp\n");           		/* print minus 1 */
   printf("%%%%Trailer\n");
   printf("end\n");
}

#define OUTBUF_SIZE	28
#define XSCALE		578
#define XLOC		0
#define ROWBYTES	74
#define SRCMODE		1

	/* Modular code purists can close their eyes for the following */
	/* routine.  */
dump_buffer(hexbuffer, blank)
char hexbuffer[MACPAINT_BITHEIGHT][MACRASTER_BITWIDTH/8];
int blank[MACPAINT_BITHEIGHT];
   /* hexbuffer contains the entire unencoded MacPaint file. */
   /* blank is a boolean array for each row.  TRUE means the horizontal
      line is blank. */
{
   int xscale, yscale, xloc, yloc, xactual, yactual;
   char smoothing;
   int i, j;
   int curline, top_of_sect, begin_line, numblanks, lines_used;
   char outstring[MACRASTER_BITWIDTH/4];

   xscale = XSCALE;		/* Postscript parameters describing the */
   xloc = XLOC;			/* size of the image area.  */
   xactual = XSCALE;
   smoothing = smooth ? 'T' : 'F';

/*  The postscript output consists of calls to "dobits" for each group of */
/* non-blank horizontal lines.  Due to LaserWriter memory limitations,    */
/* only about 28 lines at a time can be sent per command.  Also, lines    */
/* adjacent to the current section must be included (presumably for the   */
/* smoothing function to work.)						  */

   curline = 0;
   top_of_sect = TRUE;		/* begin a "dobits" call. */

   while (curline < MACPAINT_BITHEIGHT) {
			/* for the entire picture... */

/*  If a previous section terminated because of white space, skip the */
/* blank lines that precede the next section.  */
      if (top_of_sect)
	 while ((curline < MACPAINT_BITHEIGHT) && blank[curline])
            curline++;

/* check for end of page. */
      if (curline >= MACPAINT_BITHEIGHT)
         break;

      if (top_of_sect) {	/* At top of non-white section, include */
         begin_line = curline - 2;	/* previous two lines; */
         lines_used = 2;
         top_of_sect = FALSE;
      } else {			/* if continuing a non-white section, don't. */
         begin_line = curline;
         lines_used = 0;
      }

      numblanks = 0;		/* compute height of non-white area. */
      for (i = lines_used; i < (OUTBUF_SIZE - 1); i++) {
         if (blank[curline++])
            numblanks++;
         else
            numblanks = 0;   /* reset counter */
         if (numblanks >= 4) {	/* Too much white space: break and print it. */
      				/* The four blanks at the end of the */
				/* page will stop us at the bottom */
            curline--;		/* We want curline to point */
      				/* to the fourth blank line. */
            break;
         }
      }
      if (numblanks > 0)	/* If the bitmap ended in any whitespace, */
	 top_of_sect = TRUE;	/* we skip it the next time around.  */
      curline++;
      yactual = i - 3;		/* Height of current bitmap section. */
      yscale = yactual;		/* Scale it 1 to 1.  */
      yloc = begin_line + 2;

/* print the "dobits" call. */
      printf("%d %d %d %d %d %d %d %c %d dobits\n",
		xscale, yscale, xloc, yloc, ROWBYTES,
		xactual, yactual, smoothing, SRCMODE);
/* print the corresponding horizontal lines. */
      for (i = begin_line; i < curline; i++) {
         if ((i < 0) || blank[i])
			/* if blank, print all zeros. */
            for (j = 0; j< MACRASTER_BITWIDTH/4; j++)
               putchar('0');
         else {
			/* else convert to a hex string and print it. */
            tohex(hexbuffer[i], MACRASTER_BITWIDTH/8,
               outstring);
            printf("%s", outstring);
         }
		/* Put four extra nibbles at the ends of lines.  I think */
		/* are for smoothing.  */
	 if ((i == (-2)) || blank[i+1])	/* Include the first four nibbles of */
            printf("0000\n");		/* the next line.  */
	 else {
	    tohex(hexbuffer[i+1], 2, outstring);
	    printf("%s\n", outstring);
	 }
      }
      if (!top_of_sect)
         curline -= 4;		/* we'll have to overlap the next section */
   }				/* with this one, so back up four lines. */
}

tohex(hexline, size, outstring)   /* convert binary bytes to a hex string. */
char hexline[];
int size;		/* number of bytes to convert. */
char outstring[];
{
   int i, j;
   register char c, c1;

   j = 0;
   for (i = 0 ; i < size ; i++) {
      c = hexline[i];
      c1 = (c >> 4) & 0x0F;
      c1 = (c1 <= 9) ? (c1 + '0') : (c1 - 10 + 'A');
      outstring[j++] = c1;
      c1 = c & 0x0F;
      c1 = (c1 <= 9) ? (c1 + '0') : (c1 - 10 + 'A');
      outstring[j++] = c1;
   }
   outstring[j] = NULL;
}
@//E*O*F paintps.c//
chmod u=rw,g=rw,o=r paintps.c
 
echo x - paintps.1
sed 's/^@//' > "paintps.1" <<'@//E*O*F paintps.1//'
@.TH PAINTPS local "23 April 1986"
@.UC 4
@.SH NAME
paintps - Convert MacPaint document into PostScript
@.SH SYNOPSIS
@.B paintps
file
@.br
@.B paintps
[
@.B \-d
] [
@.BI \-#<n>
] [
@.BI \-P<printer>
] file
@.SH DESCRIPTION
@.I Paintps
translates a MacPaint document, uploaded from a Macintosh via macget (local),
into the PostScript language.  It can also spool output to maclaser (local)
for printing on a LaserWriter or other PostScript device.
@.PP
If the output of paintps hasn't been redirected or piped, then paintps
automatically spools the output to the LaserWriter.
@.PP
Note that the resulting PostScript file requires certain function
definitions that aren't normally present on the LaserWriter.  Therefore,
the output of paintps must eventually be printed using "maclaser" instead of,
for example, "lpr -Plw".
@.PP
The order of command line arguments is not important, except that the options
must precede the filename.  The available command line options are:
@.TP
@.B -d
Specifies Draft Mode.  This turns off the smoothing function for graphics.
This option is of dubious usefulness since the smoothing overhead is small.
@.TP
@.BI -#<n>
Specifies n copies should be printed.
@.TP
@.BI -P<printer>
Specifies the printer to be used as the output device.
@.SH UPLOADING\ MACPAINT\ FILES\ TO\ UNIX
You may use the command
@.PP
% macget -d
@.PP
to upload MacPaint files from the Macintosh to UNIX.  See macget(local)
for more information.
@.SH DIAGNOSTICS
If the LaserWriter produces an error page saying "/md undefined", this
probably means you spooled the output with lpr instead of maclaser.
@.SH AUTHOR
Brian H. Powell, The University of Texas at Austin
@.SH SEE\ ALSO
maclaser(local), macget(local)
@//E*O*F paintps.1//
chmod u=rw,g=rw,o=r paintps.1
 
echo x - Makefile
sed 's/^@//' > "Makefile" <<'@//E*O*F Makefile//'
SRCS= paintps.c
OBJS= paintps.o
COMMANDS= paintps
CFLAGS= -O
BIN= /usr/local
MAN= /usr/man/manl

SPOOLCMD= "maclaser"

all: $(COMMANDS)

paintps: paintps.c
	$(CC) $(CFLAGS) paintps.c -o paintps '-DSPOOLCMD=$(SPOOLCMD)'

install: $(COMMANDS)
	install -s -m 0775 paintps ${DESTDIR}/${BIN}
	install -c -m 0444 paintps.1 ${DESTDIR}/${MAN}

clean:
	rm -f *.o a.out core $(COMMANDS)
@//E*O*F Makefile//
chmod u=rw,g=rw,o=r Makefile
 
echo x - maclaser.csh
sed 's/^@//' > "maclaser.csh" <<'@//E*O*F maclaser.csh//'
#! /bin/csh -f

# A simple script to spool files prepared on a Macintosh for printing on
# the LaserWriter.  It expilictly spools to the lw printer and flags the
# file as "Fortran" type.  This file type is redefined locally to mean
# a mac Postscript file, causing the Apple laser-prep file to be prepended
# to provide the standard Mac environment in the printer when the file
# is processed.
# Files spooled with maclaser should have been created on the Mac with
# the COMMAND-F sequence and the resulting PostScript file uploaded  [RH]
#
#  April 1986	Generalized to handle arbitrary option args and accept
#		multiple file names.  This is now a general filter for
#		calling lpr.  Options and file names can be mixed up in
#		the "wrong" order and they will be given to lpr in the 
#		order it wants them.  The 'always' variable is what makes
#		this a script specific to handling Mac Postscript.
#		Ron Hitchens (hitchens@sally), Brian Powell (brian@sally)
#

set lpr = /usr/ucb/lpr
set lw = -Plw
set always = (-f)		# this means Mac PostScript (local spooler hack)
set flags = ()
set files = ()

top:
	if ($#argv > 0) then
		switch ($argv[1])
		case -P*:		# need to look for this one specifically
			set lw=$argv[1]	# since we've setup a default
			shift argv
			goto top
		case -:			# pretend this means read stdin
			shift argv	# lpr reads stdin if no files names
			goto top	# are given anyway.  Ignore it.
		case -*:
			set flags = ($flags $argv[1])
			shift argv
			goto top
		default:
			set files = ($files $argv[1])
			shift argv
			goto top
		endsw
	endif

exec $lpr $always $lw $flags $files
@//E*O*F maclaser.csh//
chmod u=rwx,g=rwx,o=rx maclaser.csh
 
echo x - maclaser.1
sed 's/^@//' > "maclaser.1" <<'@//E*O*F maclaser.1//'
@.TH MACLASER local "23 April 1986"
@.UC 4
@.SH NAME
maclaser - Spool Macintosh PostScript files to the LaserWriter printers
@.SH SYNOPSIS
@.B maclaser
[
@.BI \-P<printer>
]
file
@.SH DESCRIPTION
@.I Maclaser
is a program which spools Macintosh-generated PostScript files to any of the
LaserWriters.  It defines function definitions that the
Macintosh PostScript file uses.
@.PP
The -P option is used to specify the output device.  If the option is
omitted, the default LaserWriter (-Plw) is used.
@.PP
For MacPaint pictures, PostScript files may be generated using paintps
(local) or using the method described below.
@.PP
For other output, you must (currently) use the procedure described below
to get the Macintosh to create the PostScript file.
@.SH GENERATING\ MACINTOSH\ POSTSCRIPT\ FILES
This section describes how to generate PostScript files on the Macintosh
for uploading and eventual printing.
@.PP
Make sure the LaserWriter printer driver file is installed on your system
disk.  You may use the "Choose Printer" desk accessory to select the
LaserWriter driver instead of the Imagewriter driver.
@.PP
Use the Page Setup menu item to specify whether you want the
LaserWriter to substitute its built-in fonts for the Macintosh fonts,
whether you want smoothing, and so forth.
@.PP
Open the document with the required application and choose the "Print..."
menu item.  In most applications (such as MacWrite) a dialog box will
appear.  Answer the questions and click OK.  After you click OK, hold down
the command key (cloverleaf) and hold down the "f" key.  When a box
appears saying "Creating PostScript File", you may
release the cmd-F keys.  If instead a box appears saying "Looking for
LaserWriter", you did not press cmd-F at the right time.
@.PP
NOTE:  MacPaint is slightly different.  "Print Draft" prints without
smoothing, and "Print Final" prints with smoothing.  Also, no dialog
box appears when you choose "Print ..", so hold down cmd-F right after
you choose one of the print commands.
@.PP
A file called PostScript will appear on your disk.  This file is a text-only
file readable by MacWrite and most other editors and word processors.
This file is often extremely large (> 100K), so you might make sure you
have lots of room on the disk before creating it.
You will not be warned if you run out of space.
@.PP
Now upload the PostScript file to your favorite UNIX machine. For instance,
using MacTerminal connected to a UNIX machine, you can give the UNIX command
@.PP
% macget -u
@.PP
Then choose "Send File" in MacTerminal and select PostScript.  This will
leave a file in your current UNIX directory called PostScript.text.
@.PP
Now you may finally give UNIX the command:
@.PP
% maclaser PostScript.text
@.PP
to print the file on the default LaserWriter.
@.SH WARNINGS
This version of maclaser is intended to work only with PostScript files
created by version 1.1 of the
Macintosh LaserWriter driver and LaserPrep file.  Versions 3.0 and later
of these files will cause strange results.
@.SH FILES
/usr/local/lib/allfonts/postscript/laser-prep.pro
@.SH SEE\ ALSO
paintps(local), macget(local), lpr(1), printers(4L)
@//E*O*F maclaser.1//
chmod u=rw,g=rw,o=r maclaser.1
 
exit 0