🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac
Article #18026

PS on UNIX Filter (Part 1/3)

#18026
From: H. Moskovitz
Date: Tue, 11 Aug 1987 22:05
253 lines
10271 bytes
Many people have asked me for the filters that I received to allow me to
send my PS code from my Mac to a LW on a UNIX system. Here it is (in 3
chunks; sorry but the prep files are large).

----------------CUT HERE------------------------

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	README
#	macfilter.csh
#	macfilter.ksh
#	ps8.c
# This archive created: Tue Aug 11 18:01:36 1987
# By:	H. Moskovitz (The Second Door on the Right)
export PATH; PATH=/bin:$PATH
echo shar: extracting "'README'" '(1106 characters)'
if test -f 'README'
then
	echo shar: will not over-write existing file "'README'"
else
cat << \SHAR_EOF > 'README'
After having unpacked the files, compile the program 'ps8.c'. I used
	cc -O -o ps8 ps8.c
This program  converts non-printing characters into hex equivalents that
PS understands but that UNIX lp won't strip out. This is needed if using
lp since it would corrupt the laser prep.

I have included two versions of macfilter; one for 'csh' and one for
'sh/ksh'. The csh version requires stdin so you must cat the input file
and pipe it through macfilter and redirect the output. The ksh version
(which runs under sh as well) will take an input filename or stdin if one
is not supplied.

The input file is a file that was captured on the Mac via the cmd-F
sequence (from the print dialog) and was downloaded. Macfilter looks at
this file and determines which version of the laser prep it needs and
prepends that to the file, writes the modified file to stdout. The laser
prep files are the four files called laser-prep-??.pro

__________________________________
"Remember Jim, if you or any of your I.M. force should be captured, the
secretary will disavow any knowledge of you...
Good luck Jim"

"Thanks Alex."
SHAR_EOF
fi # end of overwriting check
echo shar: extracting "'macfilter.csh'" '(2985 characters)'
if test -f 'macfilter.csh'
then
	echo shar: will not over-write existing file "'macfilter.csh'"
else
cat << \SHAR_EOF > 'macfilter.csh'
#!/bin/csh -f
#	macfilter
#  Filter for Macintosh-generated PostScript code.
#  By Ron Hitchens & Brian Powell
#	hitchens@sally.utexas.edu	brian@sally.utexas.edu
#	hitchens@ut-sally.UUCP		brian@ut-sally.UUCP
#  Modified 8/8/87 By Howard Moskovitz (ihnp4!mtunj!howard)
#	Added elseif for finder 5.5 (Adobe-2.0)
#
#   This filter prepends the necessary LaserPrep file to the Mac file, then
# sends it through a filter to escape 8-bit characters (otherwise lost by the
# UNIX printer driver.)  This version supports the Macintosh LaserWriter driver
# versions 1.1 (LaserPrep version 12), 3.1 (LaserPrep version 40), and 3.3
# (LaserPrep version 49).
#   The difference between the three versions is deduced by looking at the
# first line of the input to this script.  The first line from the 1.1 driver
# consists entirely of "md begin".  The first line from the 3.1 driver consists
# of "%!PS-Adobe-1.0".  The first line from the 3.3 driver consists of
# "%!PS-Adobe-1.2".  This script fgreps for "Adobe-1.2" in the first line and
# if found, prepends the version 49 prep.  Then it fgreps for "Adobe-1.0" and
# if found, prepends the version 40 prep.  Otherwise, it prepends the
# version 12 prep.
#   NOTE:  Other versions of the LaserWriter driver (most notably version 3.0)
# produce output that is not easily distinguishable from output from Laser-
# Writer driver 3.1.  For this reason, this filter cannot provide warnings
# about incorrect input.  In general, the different versions are incompatible,
# and correct output from anything other than PostScript from the Macintosh
# LaserWriter drivers 1.1, 3.1 and 3.3 cannot be expected.


set prepdir=/j3/howard/xfer/LW	# dir where the prep files live
set BIN=/j3/howard/xfer/LW

cat > /tmp/mac$$			# save stdin so we can look at it

# search the first line of stdin for "Adobe-1.2" and "Adobe-1.0".  The
# variable stat1 is true if "Adobe-1.2" isn't found, and the variable stat2
# is true if "Adobe-1.0" isn't found.

head -1 /tmp/mac$$ | fgrep -s Adobe-1.2 >& /dev/null
set stat1=$status
head -1 /tmp/mac$$ | fgrep -s Adobe-1.0 >& /dev/null
set stat2=$status
head -1 /tmp/mac$$ | fgrep -s Adobe-2.0 >& /dev/null
set stat3=$status

if ( ! $stat1 ) then
	set prep=laser-prep-49.pro	# found "Adobe-1.2"; use version 49
else if ( ! $stat2 ) then
	set prep=laser-prep-40.pro	# found "Adobe-1.0"; use version 40
else if ( ! $stat3 ) then
	set prep=laser-prep-65.pro	# found "Adobe-2.0"; use version 65
else
	set prep=laser-prep-12.pro	# not found; assume version 12
endif

# Concatenate the prep and the Mac job.  The combined Postscript is then
# piped thru a filter to escape any chars with the high bit set (Apple
# dropped the ball on that one).  The final result goes down our stdout
# which is usually being piped into the printer driver (psif or pscomm)

cat $prepdir/$prep /tmp/mac$$ | $BIN/ps8

set result=$status		# save the result for our exit code

rm -f /tmp/mac$$		# make sure rm runs silently

exit $result			# that all
SHAR_EOF
chmod +x 'macfilter.csh'
fi # end of overwriting check
echo shar: extracting "'macfilter.ksh'" '(2987 characters)'
if test -f 'macfilter.ksh'
then
	echo shar: will not over-write existing file "'macfilter.ksh'"
else
cat << \SHAR_EOF > 'macfilter.ksh'
#!/bin/ksh
#	macfilter
#  Filter for Macintosh-generated PostScript code.
#  By Ron Hitchens & Brian Powell
#	hitchens@sally.utexas.edu	brian@sally.utexas.edu
#	hitchens@ut-sally.UUCP		brian@ut-sally.UUCP
#	Modified 8/8/87 By Howard Moskovitz, howard@mtunj.ATT.UUCP
#		Converted from csh to ksh.
#		Added case for finder 5.5 (Adobe-2.0)
#
#   This filter prepends the necessary LaserPrep file to the Mac file, then
# sends it through a filter to escape 8-bit characters (otherwise lost by the
# UNIX printer driver.)  This version supports the Macintosh LaserWriter driver
# versions 1.1 (LaserPrep version 12), 3.1 (LaserPrep version 40), and 3.3
# (LaserPrep version 49).
#   The difference between the three versions is deduced by looking at the
# first line of the input to this script.  The first line from the 1.1 driver
# consists entirely of "md begin".  The first line from the 3.1 driver consists
# of "%!PS-Adobe-1.0".  The first line from the 3.3 driver consists of
# "%!PS-Adobe-1.2".  This script fgreps for "Adobe-1.2" in the first line and
# if found, prepends the version 49 prep.  Then it fgreps for "Adobe-1.0" and
# if found, prepends the version 40 prep.  Otherwise, it prepends the
# version 12 prep.
#   NOTE:  Other versions of the LaserWriter driver (most notably version 3.0)
# produce output that is not easily distinguishable from output from Laser-
# Writer driver 3.1.  For this reason, this filter cannot provide warnings
# about incorrect input.  In general, the different versions are incompatible,
# and correct output from anything other than PostScript from the Macintosh
# LaserWriter drivers 1.1, 3.1 and 3.3 cannot be expected.


prepdir=/j3/howard/xfer/LW	# dir where the prep files live
BIN=/j3/howard/xfer/LW

if [ $# -eq 0 -o ! -r $1 ]
then	cat > /tmp/mac$$			# save stdin so we can look at it
	FILE=/tmp/mac$$
else	FILE=$1
fi

# search the first line of stdin for "Adobe-1.2" and "Adobe-1.0".  The
# variable stat1 is true if "Adobe-1.2" isn't found, and the variable stat2
# is true if "Adobe-1.0" isn't found.

head -1 $FILE | fgrep Adobe-1.2 >& /dev/null
stat1=$?
head -1 $FILE | fgrep Adobe-1.0 >& /dev/null
stat2=$?
head -1 $FILE | fgrep Adobe-2.0 >& /dev/null
stat3=$?

if [ $stat1 -eq 0 ]
then prep=laser-prep-49.pro	# found "Adobe-1.2"; use version 49
elif [ $stat2 -eq 0 ]
then prep=laser-prep-40.pro	# found "Adobe-1.0"; use version 40
elif [ $stat3 -eq 0 ]
then prep=laser-prep-65.pro	# found "Adobe-2.0"; use version 65
else prep=laser-prep-12.pro	# not found; assume version 12
fi

# Concatenate the prep and the Mac job.  The combined Postscript is then
# piped thru a filter to escape any chars with the high bit set (Apple
# dropped the ball on that one).  The final result goes down our stdout
# which is usually being piped into the printer driver (psif or pscomm)

cat $prepdir/$prep $FILE | $BIN/ps8

result=$?		# save the result for our exit code

rm -f /tmp/mac$$		# make sure rm runs silently

exit $result			# that all
SHAR_EOF
chmod +x 'macfilter.ksh'
fi # end of overwriting check
echo shar: extracting "'ps8.c'" '(742 characters)'
if test -f 'ps8.c'
then
	echo shar: will not over-write existing file "'ps8.c'"
else
cat << \SHAR_EOF > 'ps8.c'

/*
 * ps8       -  Convert non-ascii characters to octal excapes for the 
 *		LaserWriter printer.  This usually only happens with Postscript
 *		files generated by the Macintosh, it isn't supposed to do that
 *		but sometimes it does.  This little guy makes it all better
 *		again.
 *		Author: Brian Powell, brian@ut-sally
 */

/* ps8 - formerly called macfilter, but we wanted to use that name for the
 *	 filter called from psmac which prepends the LaserPrep.  Macfilter then
 *	 calls ps8.
 */

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

main()
{
	register char c;

	while ((c = getchar()) != EOF) {
		if (!isascii(c))
			printf("\\%03o", ((int)c) & 0377);
		else
			putchar(c);
	}
	exit (0);	/* set explicit exit code for the spooler */
}
SHAR_EOF
fi # end of overwriting check
#	End of shell archive
exit 0
-- 
-----------------------------------------------------------
		Howard Moskovitz
	AT&T Bell Labs @ Liberty Corner, NJ
		ihnp4!io!howrds.
Technical Details
Message-ID: <31@mtunj.ATT.COM>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!rutgers!mtune!mtunj!howard

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!rutgers!mtune!mtunj!howard
From: howard@mtunj.ATT.COM (H. Moskovitz)
Newsgroups: comp.sys.mac
Subject: PS on UNIX Filter (Part 1/3)
Message-ID: <31@mtunj.ATT.COM>
Date: Tue, 11-Aug-87 18:05:40 EDT
Article-I.D.: mtunj.31
Posted: Tue Aug 11 18:05:40 1987
Date-Received: Thu, 13-Aug-87 06:27:11 EDT
Organization: The Second Door on the Right
Lines: 253
Keywords: download Postscript