home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-04-04 | 37.0 KB | 1,341 lines |
- 29-Mar-89 23:07:47-GMT,37871;000000000001
- Return-Path: <edmoy@violet.berkeley.edu>
- Received: from violet.berkeley.edu by sumex-aim.stanford.edu (4.0/inc-1.0)
- id AA12117; Wed, 29 Mar 89 15:07:47 PST
- Received: by violet.berkeley.edu (5.61/1.30)
- id AA11046; Wed, 29 Mar 89 15:05:45 PST
- Date: Wed, 29 Mar 89 15:05:45 PST
- From: edmoy@violet.berkeley.edu
- Message-Id: <8903292305.AA11046@violet.berkeley.edu>
- To: info-mac@sumex-aim.stanford.edu
- Subject: New version of macps & prepfix
-
- Here is version 2.1 of macps & prepfix, to replace the current version.
-
- Macps is a Unix program that takes an uploaded PostScript file created
- on a Macintosh (by typing Command-F at the LaserWriter dialog box) and
- includes an appropriately modified LaserPrep file so that the result
- can be sent to a PostScript printer from Unix. Since the Apple
- LaserPrep files are copyrighted, I've included a program, prepfix, that
- reads version 4.0 and up LaserPrep files, and edits them so that they
- are compatible with Unix, and are even electronically mailable.
-
- CHANGES IN VERSION 2.1
-
- Version 2.1 of prepfix uses a safer method for turning on bit-smoothing
- for non-Apple printers. This should get around some of the problems
- people have been having with specialized macros in the LaserPreps that
- are Apple printer specific. The -l and -p options in version 1.1 have
- been replaced with the single -l option, and the limit on the number
- of printers you can specify has been removed.
-
- Also, prepfix removes some other various macros that cause
- unpredictable problems, and a problem with Apple LaserWriter II/NTs
- (but not other Apple printers).
-
- Version 2.1 macps has several new options. The -c option allow you to
- specify the number of copies to generate (overriding any multiple copy
- option that was specified on the Macintosh). The -d option allows an
- alternate directory to look for the macps.config file. Finally, the -r
- (raw) option suppresses the conversion of 8-bit binary into ASCII, and
- is useful for some graphics programs that manipulate gray-scale images,
- and produce 8-bit binary PostScript output.
-
- Macps will even work with a NeXT laser printer, but (at least the 0.8
- version of the operating system) will not do bit smoothing. Beware,
- though, that if you print Macintosh patterns at 400 dpi, they will
- look funny.
-
- Edward Moy Principal Programmer - Macintosh & Unix
- Workstation Support Services Workstation Software Support Group
- University of California
- Berkeley, CA 94720
-
- edmoy@violet.Berkeley.EDU
- ucbvax!violet!edmoy
- -------- cut ---------------------- cut -------------------- cut ------------
- #! /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
- # Installation
- # Makefile
- # macaux.c
- # macps.c
- # prepfix.c
- # str.h
- # ucbwhich.c
- # ucbwhich.h
- # macps.config
- # macps.1
- # prepfix.1
- # macps.shar - archive created: Wed Mar 29 13:54:22 PST 1989
- if test -f ReadMe
- then
- echo shar: will not overwrite existing file "'ReadMe'"
- else
- echo 'x - ReadMe'
- cat << \RAZZLE!DAZZLE > ReadMe
- COPYRIGHT NOTICE (SCCSid = "@(#)ReadMe 2.1 3/29/89")
-
- Copyright (c) 1988, The Regents of the University of California.
- Edward Moy, Workstation Software Support Group, Workstation Support
- Serices, Information Systems and Technology.
-
- Permission is granted to any individual or institution to use, copy, or
- redistribute this software so long as it is not sold for profit,
- provided that this notice and the original copyright notices are
- retained. The University of California makes no representations about
- the suitability of this software for any purpose. It is provided "as
- is" without express or implied warranty.
-
- WHAT IS MACPS?
-
- Macps is a Unix program that takes an uploaded PostScript file created
- on a Macintosh (by typing Command-F at the LaserWriter dialog box; see
- macps.1 for more details) and includes an appropriately modified
- LaserPrep file so that the result can be sent to a PostScript printer
- >From Unix. The LaserPrep file contains macros used by the PostScript
- generator on the Macintosh.
-
- WHY IS MACPS NEEDED?
-
- This is how Mac printing works. When a Mac talks to a LaserWriter, it
- asks if the LaserWriter has had a LaserPrep file downloaded to it. A
- LaserWriter that is first powered up, has no such LaserPrep file, and
- so the Mac downloads it and makes the LaserPrep file resident in
- memory. Then the actual print file is sent to the LaserWriter.
- Subsequent print requests need not download the LaserPrep file, unless
- it is a different version.
-
- Since a LaserWriter connected to a Unix system usually does things
- other than Mac printing, it is unwise to make LaserPrep files resident
- in memory so that other PostScript jobs have less memory to work with.
- What prepfix does is to modify a LaserPrep file so that, among other
- things, it does not make itself resident in memory. Thus, the
- LaserPrep file must be downloaded for each Mac print job. This is the
- function of macps, to automatically append the appropriate LaserPrep
- file.
-
- WHICH VERSION OF THE LASERPREP WILL BE USED?
-
- Macps interprets the %%IncludeProcSet directive found in the PostScript
- generated by LaserWriter driver 4.0 and greater. It takes the ProcSet
- id and looks it up in a file "macps.config", to get the pathname of the
- prep file, and thus macps can convert PostScript generated by different
- versions of the LaserWriter driver.
-
- HOW ARE THE LASERPREP FILES GENERATED?
-
- Since the Apple LaserPrep files are copyrighted, I've included a
- program, prepfix, that reads version 4.0 and up LaserPrep files, and
- edits them so that they are compatible with Unix, and are even
- electronically mailable (See prepfix.1 for more details).
-
- WHERE IS THE MACPS.CONFIG FILE LOCATED?
-
- Macps has some special code that is able to figure out from which
- directory it was called from. It will then look in a "lib" subdiretory
- for the macps.config file.
-
- WHAT ABOUT BIT-SMOOTHING ON NON-LASERWRITER PRINTERS?
-
- For PostScript printers using Motorola 680x0 processors and Adobe
- PostScript firmware other than LaserWriters, there is an option that
- will allow these printers to do bit-smoothing, just like LaserWriters.
-
- CHANGES IN VERSION 2.1
-
- Version 2.1 of prepfix uses a safer method for turning on bit-smoothing
- for non-Apple printers. This should get around some of the problems
- people have been having with specialized macros in the LaserPreps that
- are Apple printer specific. The -l and -p options in version 1.1 have
- been replaced with the single -l option, and the limit on the number
- of printers you can specify has been removed.
-
- Also, prepfix removes some other various macros that cause
- unpredictable problems, and a problem with Apple LaserWriter II/NTs
- (but not other Apple printers).
-
- Version 2.1 macps has several new options. The -c option allow you to
- specify the number of copies to generate (overriding any multiple copy
- option that was specified on the Macintosh). The -d option allows an
- alternate directory to look for the macps.config file. Finally, the -r
- (raw) option suppresses the conversion of 8-bit binary into ASCII, and
- is useful for some graphics programs that manipulate gray-scale images,
- and produce 8-bit binary PostScript output.
-
- Macps will even work with a NeXT laser printer, but (at least the 0.8
- version of the operating system) will not do bit smoothing. Beware,
- though, that if you print Macintosh patterns at 400 dpi, they will
- look funny.
- RAZZLE!DAZZLE
- fi # End ReadMe
- if test -f Installation
- then
- echo shar: will not overwrite existing file "'Installation'"
- else
- echo 'x - Installation'
- cat << \RAZZLE!DAZZLE > Installation
- Installation Instructions (SCCSid = "@(#)Installation 2.1 3/29/89")
-
- 1) Look at the Makefile. There are two CFLAGS options that you can
- use. Setting SYSV should allow macps and prepfix to compile on System
- V machines (I've only tried it under A/UX). Setting CONFIGDIR will
- cause macps to look for macps.config in that directory. The options
- will look something like:
-
- CFLAGS = -O -DSYSV -DCONFIGDIR=\"/usr/new/lib\"
-
- 2) Type "make". If all goes well, macps and prepfix will be created.
-
- 3) To create the unprocessed LaserPrep file on the Mac, as well as
- creating the raw PostScript files that you want to print, make sure
- that either you're not running MultiFinder, or if you are, go to the
- Chooser under the Apple menu, click on the LaserWriter icon and then
- turn off Background Printing.
-
- 4) For each version of LaserPrep on the Mac that you want to include,
- install that version in the System Folder. Then, open an empty
- document in some simple application (one that doesn't have its
- own ProcSet to download). Choose Print from the File menu and the
- LaserWriter print dialog will appear. Click on the OK button and
- IMMEDIATELY press and hold Command-K. When a dialog box appears
- telling you that it is creating a PostScript file, you can release
- Command-K. The unprocessed LaserPrep file will usually be found in one
- of three places, in the System Folder, in the same folder as the
- application or at the top level of the disk.
-
- 5) Upload the PostScript file(s) to Unix, using some file transfer
- program like MacTerminal, Versaterm, Red Ryder, MacKermit or NCSA
- Telnet (if your file transfer program feels left out, feel free to add
- it to your list).
-
- 6) Run prepfix on each unprocessed file, diverting the standard output
- to an appropriataly named file (like LaserPrep5.2). If you want to
- allow bit smoothing on a non-Apple PostScript printer, specify the -l
- option to prepfix (you can specify as many printer names as you want,
- each with a separate -l flag). If you aren't sure the your printer can
- do smoothing, you can try it and see if it works (if it doesn't, you
- can always re-run prepfix on the unprocessed file(s), leaving off the
- printer that doesn't work). If you don't know the product name for you
- printer, you can use the following PostScript code to print it:
-
- %!
- /in {72 mul} def
- /Courier findfont 18 scalefont setfont
- 1 in 8 in moveto
- statusdict /product get show
- showpage
-
- 7) Put the modified LaserPrep file(s) in some directory and modify the
- macps.config file to point to these LaserPrep files. Then put the
- macps.config file in a "lib" subdirectory to where you install macps
- (or in the directory CONFIGDIR if you used that option).
-
- 8) Now when you want to print something, do the same thing as in step 4
- above with the LaserWriter print dialog, except press and hold
- Command-F (this cause LaserPrep not to be included in the PostScript
- file).
-
- 9) Upload the PostScript file and run macps on it, sending the output
- to your printer, as in:
-
- % macps psfile | lpr
- RAZZLE!DAZZLE
- fi # End Installation
- if test -f Makefile
- then
- echo shar: will not overwrite existing file "'Makefile'"
- else
- echo 'x - Makefile'
- cat << \RAZZLE!DAZZLE > Makefile
- # Copyright (c) 1988, The Regents of the University of California.
- # Edward Moy, Workstation Software Support Group, Workstation Support Serices,
- # Information Systems and Technology.
- #
- # Permission is granted to any individual or institution to use, copy,
- # or redistribute this software so long as it is not sold for profit,
- # provided that this notice and the original copyright notices are
- # retained. The University of California makes no representations about the
- # suitability of this software for any purpose. It is provided "as is"
- # without express or implied warranty.
- #
- # SCCSid = "@(#)Makefile 2.1 3/29/89"
- #
- # For System V, include -DSYSV in CFLAGS below.
- # To specify a fixed path for macps.config, include -DCONFIGDIR=\"path\"
- # in CFLAGS below (path is the full pathname of the directory).
- #
- CFLAGS = -O
- MACPS = macps.o macaux.o ucbwhich.o
- PREPFIX = prepfix.o macaux.o
-
- all : macps prepfix
-
- macps : $(MACPS)
- cc -o macps $(CFLAGS) $(MACPS)
-
- prepfix : $(PREPFIX)
- cc -o prepfix $(CFLAGS) $(PREPFIX)
-
- clean :
- /bin/rm -f *.o macps prepfix
- RAZZLE!DAZZLE
- fi # End Makefile
- if test -f macaux.c
- then
- echo shar: will not overwrite existing file "'macaux.c'"
- else
- echo 'x - macaux.c'
- cat << \RAZZLE!DAZZLE > macaux.c
- /*
- * Copyright (c) 1988, The Regents of the University of California.
- * Edward Moy, Workstation Software Support Group, Workstation Support Serices,
- * Information Systems and Technology.
- *
- * Permission is granted to any individual or institution to use, copy,
- * or redistribute this software so long as it is not sold for profit,
- * provided that this notice and the original copyright notices are
- * retained. The University of California makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- */
-
- #ifndef lint
- static char *SCCSid = "@(#)macaux.c 2.1 3/29/89";
- #endif lint
-
- #include <ctype.h>
- #include <stdio.h>
- #include "str.h"
-
- #define FALSE 0
- #define TRUE 1
-
- extern char *myname;
- int rawmode = FALSE;
-
- STR *
- STRalloc()
- {
- register STR *str;
- char *malloc();
-
- if((str = (STR *)malloc(sizeof(STR))) == NULL ||
- (str->bufptr = (unsigned char *)malloc(STRSIZE)) == NULL) {
- fprintf(stderr, "%s: STRalloc: Out of memory\n", myname);
- exit(1);
- }
- str->curendptr = str->bufptr;
- str->realendptr = str->bufptr + STRSIZE;
- return(str);
- }
-
- STRfree(str)
- STR *str;
- {
- free((char *)str->bufptr);
- free((char *)str);
- }
-
- STRexpand(str)
- register STR *str;
- {
- register int curend, realend;
- char *realloc();
-
- curend = str->curendptr - str->bufptr;
- realend = (str->realendptr - str->bufptr) + STRSIZEDELTA;
- if((str->bufptr = (unsigned char *)realloc((char *)str->bufptr,
- realend)) == NULL) {
- fprintf(stderr, "%s: STRexpand: Out of memory\n", myname);
- exit(1);
- }
- str->curendptr = str->bufptr + curend;
- str->realendptr = str->bufptr + realend;
- }
-
- STRgets(str, fp)
- register STR *str;
- register FILE *fp;
- {
- register int c;
-
- str->curendptr = str->bufptr;
- for( ; ; ) {
- if((c = getc(fp)) == EOF)
- return(str->curendptr > str->bufptr);
- if(str->curendptr >= str->realendptr)
- STRexpand(str);
- *str->curendptr++ = c;
- if(c == '\n' || c == '\r')
- return(TRUE);
- }
- }
-
- STRputsptr(str, cp, fp)
- register STR *str;
- register unsigned char *cp;
- register FILE *fp;
- {
- if(rawmode) {
- for( ; cp < str->curendptr ; cp++)
- putc(*cp, fp);
- return;
- }
- for( ; cp < str->curendptr ; cp++) {
- if(!isascii(*cp))
- fprintf(fp, "\\%03o", *cp);
- else if(isprint(*cp))
- putc(*cp, fp);
- else {
- switch(*cp) {
- case '\n':
- case '\r':
- putc('\n', fp);
- continue;
- case '\t':
- putc('\t', fp);
- continue;
- default:
- fprintf(fp, "\\%03o", *str);
- continue;
- }
- }
- }
- }
-
- STRcompareptr(str, cp, sp)
- register STR *str;
- register unsigned char *cp, *sp;
- {
- register int comp;
-
- for( ; ; ) {
- if(*sp == 0)
- return(cp >= str->curendptr ? 0 : 1);
- if(cp >= str->curendptr)
- return(-1);
- if(*sp == '\n') {
- if(*cp != '\n' && *cp != '\r')
- return((int)*cp - (int)*sp);
- } else if((comp = (int)*cp - (int)*sp) != 0)
- return(comp);
- cp++;
- sp++;
- }
- }
-
- STRheadcmpptr(str, cp, sp)
- register STR *str;
- register unsigned char *cp, *sp;
- {
- register int comp;
-
- for( ; ; ) {
- if(*sp == 0)
- return(0);
- if(cp >= str->curendptr)
- return(-1);
- if(*sp == '\n') {
- if(*cp != '\n' && *cp != '\r')
- return((int)*cp - (int)*sp);
- } else if((comp = (int)*cp - (int)*sp) != 0)
- return(comp);
- cp++;
- sp++;
- }
- }
-
- unsigned char *
- STRmatch(str, sp)
- register STR *str;
- register unsigned char *sp;
- {
- register unsigned char *mp, *last;
- register int firstchar;
-
- firstchar = *sp;
- last = str->curendptr - strlen(sp);
- mp = str->bufptr;
- while(mp <= last) {
- if(*mp == firstchar && STRheadcmpptr(str, mp, sp) == 0)
- return(mp);
- mp++;
- }
- return(NULL);
- }
- RAZZLE!DAZZLE
- fi # End macaux.c
- if test -f macps.c
- then
- echo shar: will not overwrite existing file "'macps.c'"
- else
- echo 'x - macps.c'
- cat << \RAZZLE!DAZZLE > macps.c
- /*
- * Copyright (c) 1988, The Regents of the University of California.
- * Edward Moy, Workstation Software Support Group, Workstation Support Serices,
- * Information Systems and Technology.
- *
- * Permission is granted to any individual or institution to use, copy,
- * or redistribute this software so long as it is not sold for profit,
- * provided that this notice and the original copyright notices are
- * retained. The University of California makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- */
-
- #ifndef lint
- static char *SCCSid = "@(#)macps.c 2.1 3/29/89";
- #endif lint
-
- #include <ctype.h>
- #include <stdio.h>
- #ifdef SYSV
- #include <string.h>
- #else SYSV
- #include <strings.h>
- #endif SYSV
- #include <sys/types.h>
- #include <sys/file.h>
- #include "str.h"
- #include "ucbwhich.h"
-
- #define CONFIG "macps.config"
- #ifdef SYSV
- #define index strchr
- #define rindex strrchr
- #endif SYSV
-
- char *finale = "macps restore\n";
- char intro[] = "\
- %%! *** Created by macps: %s\
- /macps save def\n\
- ";
- char *myname;
- int ncopies = 0;
- #ifdef CONFIGDIR
- char ucblib[UCBMAXPATHLEN] = CONFIGDIR;
- #else CONFIGDIR
- int ucbalternate;
- char ucbpath[UCBMAXPATHLEN];
- char ucblib[UCBMAXPATHLEN];
- #endif CONFIGDIR
-
- main(argc, argv)
- int argc;
- char **argv;
- {
- register STR* str;
- register char *cp, *pp;
- register FILE *fp;
- register int i, fd;
- char line[BUFSIZ];
- char path[UCBMAXPATHLEN];
- long ltime;
- char *ctime();
-
- #ifndef CONFIGDIR
- ucbwhich(*argv);
- #endif CONFIGDIR
- if(myname = rindex(*argv, '/'))
- myname++;
- else
- myname = *argv;
- cp = NULL;
- for(argc--, argv++ ; argc > 0 && **argv == '-' ; argc--, argv++) {
- switch((*argv)[1]) {
- case 'c': /* multiple copies */
- if((*argv)[2])
- ncopies = atoi(&(*argv[2]));
- else {
- if(argc < 2)
- Usage(); /* never returns */
- argc--;
- ncopies = atoi(*++argv);
- }
- if(ncopies <= 0)
- Usage(); /* never returns */
- break;
- case 'd': /* alternate directory for config file */
- if((*argv)[2])
- cp = &(*argv[2]);
- else {
- if(argc < 2)
- Usage(); /* never returns */
- argc--;
- cp = *++argv;
- }
- strcpy(ucblib, cp);
- break;
- case 'r': /* raw mode */
- rawmode++;
- break;
- default:
- Usage(); /* never returns */
- }
- }
- if(argc > 1)
- Usage(); /* never returns */
- if(argc == 1 && freopen(*argv, "r", stdin) == NULL) {
- fprintf(stderr, "%s: can't open %s\n", myname, *argv);
- exit(1);
- }
- str = STRalloc();
- if(!STRgets(str, stdin)) {
- fprintf(stderr, "%s: Null input\n", myname);
- exit(1);
- }
- strcat(ucblib, "/");
- strcpy(path, ucblib);
- strcat(path, CONFIG);
- if((fp = fopen(path, "r")) == NULL) {
- fprintf(stderr, "%s: Can't open %s\n", myname, path);
- exit(1);
- }
- time(<ime);
- printf(intro, ctime(<ime));
- do {
- if(ncopies != 0 && STRheadcompare(str, "userdict /#copies ")
- == 0)
- continue;
- if(STRcompare(str, "%%EOF\n") == 0) {
- if(finale) {
- fputs(finale, stdout);
- finale = NULL;
- }
- STRputs(str, stdout);
- continue;
- }
- if(STRheadcompare(str, "%%IncludeProcSet:") == 0) {
- for(cp = (char *)&str->bufptr[17] ; ; cp++) {
- if(!*cp) {
- fprintf(stderr,
- "%s: Syntax error on IncludeProcSet line\n",
- myname);
- exit(1);
- }
- if(!isascii(*cp) || !isspace(*cp))
- break;
- }
- pp = (char *)str->curendptr;
- while(--pp >= cp) {
- if(!isascii(*pp) || !isspace(*pp))
- break;
- *pp = 0;
- }
- str->curendptr = (unsigned char *)(pp + 1);
- fseek(fp, 0L, 0);
- for( ; ; ) {
- if(!fgets(line, BUFSIZ, fp)) {
- fprintf(stderr,
- "%s: Unknown IncludeProcSet %s\n",
- myname, cp);
- exit(1);
- }
- if(*line == '#')
- continue;
- if(pp = index(line, '\n')) {
- if(pp == line)
- continue;
- *pp = 0;
- }
- if(!(pp = index(line, '\t'))) {
- fprintf(stderr,
- "%s: Syntax error in macps.config\n",
- myname);
- exit(1);
- }
- *pp++ = 0;
- if(STRcompareptr(str, cp, line) == 0)
- break;
- }
- if(*pp == '/')
- strcpy(path, pp);
- else {
- strcpy(path, ucblib);
- strcat(path, pp);
- }
- fflush(stdout);
- if((fd = open(path, O_RDONLY, 0)) < 0) {
- fprintf(stderr, "%s: Can't open %s\n", myname,
- path);
- exit(1);
- }
- while((i = read(fd, line, BUFSIZ)) > 0)
- write(1, line, i);
- close(fd);
- continue;
- }
- STRputs(str, stdout);
- if(ncopies > 1 && isascii(*str->bufptr) &&
- isdigit(*str->bufptr)) {
- cp = (char *)str->bufptr;
- while(cp < (char *)str->curendptr && isascii(*cp)
- && isdigit(*cp))
- cp++;
- if((char *)str->curendptr - cp == 4 &&
- STRcompareptr(str, cp, " mf\n") == 0) {
- printf("userdict /#copies %d put\n", ncopies);
- ncopies = -1;
- }
- }
- } while(STRgets(str, stdin));
- if(finale)
- fputs(finale, stdout);
- exit(0);
- }
-
- Usage()
- {
- fputs("Usage: macps [-c #] [-d directory] [-r] [file]\n", stderr);
- exit(1);
- }
- RAZZLE!DAZZLE
- fi # End macps.c
- if test -f prepfix.c
- then
- echo shar: will not overwrite existing file "'prepfix.c'"
- else
- echo 'x - prepfix.c'
- cat << \RAZZLE!DAZZLE > prepfix.c
- /*
- * Copyright (c) 1988, The Regents of the University of California.
- * Edward Moy, Workstation Software Support Group, Workstation Support Serices,
- * Information Systems and Technology.
- *
- * Permission is granted to any individual or institution to use, copy,
- * or redistribute this software so long as it is not sold for profit,
- * provided that this notice and the original copyright notices are
- * retained. The University of California makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- */
-
- #ifndef lint
- static char *SCCSid = "@(#)prepfix.c 2.1 3/29/89";
- #endif lint
-
- #include <ctype.h>
- #include <stdio.h>
- #ifdef SYSV
- #include <string.h>
- #else SYSV
- #include <strings.h>
- #endif SYSV
- #include "str.h"
-
- #define CLEARTOMARK 12
- #define EEXECLEN 80
- #define EXTRA (NZEROLINE * ZEROLINE + CLEARTOMARK)
- #define LINELEN 256
- #define NPRODUCTS 32
- #define NZEROLINE 7
- #define ZEROLINE 65
- #ifdef SYSV
- #define index strchr
- #define rindex strrchr
- #endif SYSV
-
- char exstr[] = "\
- %ck userdict/%s known not and{currentfile eexec}{%d{currentfile read\n\
- pop pop}repeat}ifelse\n\
- ";
- char *match();
- char *myname;
- int maxproducts = NPRODUCTS;
- int nproducts = 0;
- char Ok[] = "\
- /Ok{ok dup not{save /Pd statusdict /product get def false 0 1 ProdArr length\n\
- 1 sub{Pd exch ProdArr exch get anchorsearch exch pop{pop pop true exit}if}for\n\
- exch restore}if}bind def\n\
- ";
- char ProdArr0[] = "/ProdArr [\n";
- char ProdArr1[] = "] def\n";
- char **products;
- char tempname[] = "/tmp/prepfixXXXXXX";
-
- main(argc, argv)
- int argc;
- char **argv;
- {
- register STR *str;
- register FILE *tp;
- register int i;
- register unsigned char *lp;
- char buf[BUFSIZ];
- char *malloc(), *realloc();
-
- if(myname = rindex(*argv, '/'))
- myname++;
- else
- myname = *argv;
- for(argc--, argv++ ; argc > 0 && **argv == '-' ; argc--, argv++) {
- switch((*argv)[1]) {
- case 'h':
- usage();
- case 'l':
- if(nproducts <= 0 && (products =
- (char **)malloc(maxproducts*sizeof(char *))) == NULL) {
- fprintf(stderr,
- "%s: Out of memory creating products array\n",
- myname);
- exit(1);
- } else if(nproducts >= maxproducts - 1 && (products =
- (char **)realloc(products, (maxproducts += NPRODUCTS)
- * sizeof(char *))) == NULL) {
- fprintf(stderr,
- "%s: Out of memory expanding products array\n",
- myname);
- exit(1);
- }
- if((*argv)[2])
- products[nproducts++] = &(*argv)[2];
- else {
- if(argc < 2) {
- fprintf(stderr,
- "%s: No argument for -l\n", myname);
- exit(1);
- }
- argc--;
- argv++;
- products[nproducts++] = *argv;
- }
- break;
- }
- }
- if(argc > 1)
- usage();
- if(argc > 0 && freopen(*argv, "r", stdin) == NULL) {
- fprintf(stderr, "%s: Can't open %s\n", myname, *argv);
- exit(1);
- }
- mktemp(tempname);
- if((tp = fopen(tempname, "w+")) == NULL) {
- fprintf(stderr, "%s: Can't create temp file %s\n",
- myname, tempname);
- exit(1);
- }
- unlink(tempname);
- str = STRalloc();
- if(!STRgets(str, stdin)) {
- fprintf(stderr, "%s: Null input\n", myname);
- exit(1);
- }
- for( ; ; ) {
- if(STRheadcompare(str, "% \251") == 0) {
- fputs("% ", tp);
- str->bufptr[0] = '(';
- str->bufptr[1] = 'C';
- str->bufptr[2] = ')';
- } else if(STRheadcompare(str, "%%BeginProcSet:") == 0) {
- STRputs(str, stdout);
- fseek(tp, 0L, 0);
- while((i = fread(buf, 1, BUFSIZ, tp)) > 0)
- fwrite(buf, 1, i, stdout);
- fclose(tp);
- break;
- }
- STRputs(str, tp);
- if(!STRgets(str, stdin)) {
- fprintf(stderr, "%s: No BeginProcSet\n", myname);
- exit(1);
- }
- }
- while(STRgets(str, stdin)) {
- if(nproducts > 0 && STRheadcompare(str, "/ok{") == 0) {
- STRputs(str, stdout);
- fputs(ProdArr0, stdout);
- for(i = 0 ; i < nproducts ; i++)
- printf("(%s)\n", products[i]);
- fputs(ProdArr1, stdout);
- fputs(Ok, stdout);
- continue;
- } else if(STRmatch(str, "setdefaulttimeouts")
- || STRmatch(str, "setsccinteractive"))
- continue;
- else if(STRmatch(str, "eexec")) {
- if(STRmatch(str, "/stretch")) {
- eexec("stretch", str);
- continue;
- } else if(STRmatch(str, "/smooth4")) {
- eexec("smooth4", str);
- continue;
- }
- } else if(STRmatch(str, "(LaserWriter II NT)")) {
- STRgets(str, stdin); /* skip next line */
- while(STRgets(str, stdin) && isxdigit(*str->bufptr))
- {}
- } else if(lp = STRmatch(str, "scaleby96{ppr")) {
- STRputsptr(str, lp, stdout);
- continue;
- } else if(STRheadcompare(str, "%%EndProcSet") == 0) {
- STRputs(str, stdout);
- break;
- }
- STRputs(str, stdout);
- }
- exit(0);
- }
-
- eexec(name, str)
- char *name;
- register STR *str;
- {
- register int len;
- register unsigned char *bp;
-
- if(!STRgets(str, stdin)) {
- fprintf(stderr, "%s: EOF during reading eexec\n", myname);
- exit(1);
- }
- bp = str->bufptr;
- len = (str->curendptr - bp) - 1;
- printf(exstr, nproducts > 0 ? 'O' : 'o', name, len + (len / EEXECLEN)
- + (len % EEXECLEN ? 1 : 0) + EXTRA);
- while(len >= 80) {
- fwrite(bp, 80, 1, stdout);
- putchar('\n');
- bp += 80;
- len -= 80;
- }
- if(len > 0) {
- fwrite(bp, len, 1, stdout);
- putchar('\n');
- }
- for( ; ; ) {
- if(!STRgets(str, stdin)) {
- fprintf(stderr, "%s: EOF reached before cleartomark\n",
- myname);
- exit(1);
- }
- if(STRheadcompare(str, "cleartomark") == 0) {
- STRputs(str, stdout);
- return;
- }
- STRputs(str, stdout);
- }
- }
-
- usage()
- {
- fprintf(stderr,
- "Usage: %s [-l product_name1 [-l product_name2]...] [file]\n",
- myname);
- fprintf(stderr, " %s -help\n", myname);
- exit(1);
- }
- RAZZLE!DAZZLE
- fi # End prepfix.c
- if test -f str.h
- then
- echo shar: will not overwrite existing file "'str.h'"
- else
- echo 'x - str.h'
- cat << \RAZZLE!DAZZLE > str.h
- /*
- * Copyright (c) 1988, The Regents of the University of California.
- * Edward Moy, Workstation Software Support Group, Workstation Support Serices,
- * Information Systems and Technology.
- *
- * Permission is granted to any individual or institution to use, copy,
- * or redistribute this software so long as it is not sold for profit,
- * provided that this notice and the original copyright notices are
- * retained. The University of California makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- */
-
- /*
- * SCCSid = "@(#)str.h 2.1 3/29/89"
- */
-
- #define STRSIZEDELTA 1024
- #define STRSIZE 1024
-
- #define STRcompare(str,fp) STRcompareptr((str), (str)->bufptr, (fp))
- #define STRheadcompare(str,fp) STRheadcmpptr((str), (str)->bufptr, (fp))
- #define STRputs(str,fp) STRputsptr((str), (str)->bufptr, (fp))
-
- typedef struct {
- unsigned char *bufptr;
- unsigned char *curendptr;
- unsigned char *realendptr;
- } STR;
-
- extern int rawmode;
-
- STR *STRalloc();
- int STRcompareptr();
- int STRfree();
- int STRgets();
- int STRheadcmpptr();
- unsigned char *STRmatch();
- int STRputsptr();
- RAZZLE!DAZZLE
- fi # End str.h
- if test -f ucbwhich.c
- then
- echo shar: will not overwrite existing file "'ucbwhich.c'"
- else
- echo 'x - ucbwhich.c'
- cat << \RAZZLE!DAZZLE > ucbwhich.c
- /*
- * Copyright (c) 1988, The Regents of the University of California.
- * Edward Moy, Workstation Software Support Group, Workstation Support Serices,
- * Information Systems and Technology.
- *
- * Permission is granted to any individual or institution to use, copy,
- * or redistribute this software so long as it is not sold for profit,
- * provided that this notice and the original copyright notices are
- * retained. The University of California makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- */
-
- #ifndef CONFIGDIR
- #ifndef lint
- static char *SCCSid = "@(#)ucbwhich.c 2.1 3/29/89";
- #endif lint
-
- #include <stdio.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include "ucbwhich.h"
-
- #define F_OK 0 /* does file exist */
- #define X_OK 1 /* is it executable by caller */
- #define W_OK 2 /* writable by caller */
- #define R_OK 4 /* readable by caller */
-
- #define LIBLEN 4
- #ifdef SYSV
- #define index strchr
- #define rindex strrchr
- #endif SYSV
-
- static char lib[] = "/lib";
-
- char ucblib[UCBMAXPATHLEN];
- int ucbalternate = 0;
- char ucbpath[UCBMAXPATHLEN];
-
- ucbwhich(str)
- char *str;
- {
- register char *dir, *name, *cp, *tp;
- register int len;
- char dirbuf[UCBMAXPATHLEN], namebuf[UCBMAXPATHLEN];
- struct stat sbuf;
- char *index(), *rindex(), *getwd(), *getenv();
-
- strcpy(name = namebuf, str);
- if(*name == '/') /* absolute pathname */
- *(rindex(dir = name, '/')) = 0 ; /* remove tail */
- else {
- if(cp = index(name, '/')) { /* relative pathname */
- if((dir = getwd(dirbuf)) == NULL)
- return(0);
- /* if any errors occurs assume standard version */
- *cp++ = 0;
- for( ; ; ) {
- if(*name != 0) { /* multiple slashes */
- if(strcmp(name, "..") == 0) {
- /* parent directory */
- if((tp = rindex(dir, '/')) ==
- NULL)
- return(0);
- if(tp == dir)
- tp++;
- /* root directory */
- *tp = 0;
- /* remove last component */
- } else if(strcmp(name, ".") != 0) {
- /* subdirectory */
- strcat(dir, "/");
- strcat(dir, name);
- }
- }
- name = cp;
- if((cp = index(name, '/')) == NULL) break;
- /* ignore last component */
- *cp++ = 0;
- }
- } else { /* look through $PATH variable */
- if((tp = getenv("PATH")) == NULL)
- return(0);
- for(name = namebuf ; ; ) {
- if(*tp == 0)
- return(0);
- else if(*tp == ':')
- tp++;
- if((cp = index(tp, ':')) == NULL)
- cp = tp + strlen(tp);
- /* positioned on null */
- for(dir = dirbuf ; tp < cp ; )
- *dir++ = *tp++;
- *dir = 0;
- strcpy(name, dir = dirbuf);
- strcat(name, "/");
- strcat(name, str);
- if(stat(name, &sbuf) < 0 || (sbuf.st_mode &
- S_IFMT) != S_IFREG)
- continue;
- if(access(name, X_OK) == 0) {
- if(strcmp(dir, ".") == 0 &&
- (dir = getwd(dirbuf)) == NULL)
- return(0);
- break;
- }
- }
- }
- }
- strcpy(ucbpath, dir);
- strcpy(ucblib, dir);
- if((len = strlen(dir)) < LIBLEN || strcmp(&dir[len - LIBLEN], lib)
- != 0)
- strcat(ucblib, lib);
- else
- ucbpath[len - LIBLEN] = 0;
- ucbalternate = (strcmp(ucbpath, UCBSTANDARD) != 0);
- #ifdef EBUG
- fprintf(stderr, "ucbwhich: alt=%d path=%s lib=%s\n", ucbalternate,
- ucbpath, ucblib);
- #endif EBUG
- return(ucbalternate);
- }
- #endif CONFIGDIR
- RAZZLE!DAZZLE
- fi # End ucbwhich.c
- if test -f ucbwhich.h
- then
- echo shar: will not overwrite existing file "'ucbwhich.h'"
- else
- echo 'x - ucbwhich.h'
- cat << \RAZZLE!DAZZLE > ucbwhich.h
- /*
- * Copyright (c) 1988, The Regents of the University of California.
- * Edward Moy, Workstation Software Support Group, Workstation Support Serices,
- * Information Systems and Technology.
- *
- * Permission is granted to any individual or institution to use, copy,
- * or redistribute this software so long as it is not sold for profit,
- * provided that this notice and the original copyright notices are
- * retained. The University of California makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- */
-
- /*
- * SCCSid = "@(#)ucbwhich.h 2.1 3/29/89"
- */
-
- #define UCBMAXPATHLEN 128
- #define UCBSTANDARD "/usr/ucb"
-
- extern char ucblib[];
- extern int ucbalternate;
- extern char ucbpath[];
- RAZZLE!DAZZLE
- fi # End ucbwhich.h
- if test -f macps.config
- then
- echo shar: will not overwrite existing file "'macps.config'"
- else
- echo 'x - macps.config'
- cat << \RAZZLE!DAZZLE > macps.config
- # This is the config file read by macps.
- # SCCSid = "@(#)macps.config 2.1 3/29/89"
- #
- # Each line is composed of the %%IncludeProcSet id, a tab and the file
- # containing the ProcSet. If the file doesn't begin with a slash, the
- # the name is taken to be relative to the directory in which this config file
- # resides.
-
- "(AppleDict md)" 65 0 ProcSets/LaserPrep4.0
- "(AppleDict md)" 66 ProcSets/LaserPrep5.0
- "(AppleDict md)" 67 0 ProcSets/LaserPrep5.1
- "(AppleDict md)" 68 0 ProcSets/LaserPrep5.2
- RAZZLE!DAZZLE
- fi # End macps.config
- if test -f macps.1
- then
- echo shar: will not overwrite existing file "'macps.1'"
- else
- echo 'x - macps.1'
- cat << \RAZZLE!DAZZLE > macps.1
- .\" SCCSid = "@(#)macps.1 2.1 3/29/89"
- .TH MACPS 1 "29 March 1989"
- .UC 4
- .SH NAME
- macps \- print Macintosh-created PostScript file on Unix
- .SH SYNOPSIS
- .B macps
- [
- \-c copies
- ]
- [
- \-d directory
- ]
- [
- \-r
- ]
- [
- file
- ]
- .SH DESCRIPTION
- .I Macps
- takes the command-line file (or the standard input if no filename is given),
- and prepends the appropriate Macintosh LaserPrep file (e.g., those generated
- by
- .IR prepfix (1)).
- The standard output can then be directed to a PostScript printer, via
- .IR lpr (1),
- for example.
- .PP
- The input PostScript file is generated on a Macintosh by typing (and holding)
- Command-F immediately after clicking the OK button of the LaserWriter printer
- dialog box.
- Another dialog will appear, confirming that a file named ``PostScript'' is
- being created (the Command-F keys can be released now).
- .PP
- Depending on the application, the created PostScript file can be found in the
- System Folder, the application folder or the top level of the disk.
- This file can then be uploaded via some file transfer program, such as
- MacTerminal/VersaTerm and
- .IR macget (1)
- or MacKermit/Red Ryder and
- .IR kermit (1).
- .PP
- Normally, you would specify the number of copies in the LaserWriter
- print dialog box on the Macintosh.
- However, you can override that after uploading the PostScript file by
- specifying the
- .B \-c
- option, followed by the number of copies.
- .PP
- The file
- .B macps.config
- specifies the mapping between the internal LaserPrep name and the actual
- file it resides in.
- This file is normally located in the lib subdirectory from which
- .I macps
- was called from.
- The
- .B \-d
- option allow you to specify an alternate directory in which the
- .B macps.config
- file can be found.
- .PP
- Most Macintosh applications produce normal ASCII PostScript files.
- However, some graphics programs that manipulate gray-scale images will
- produce PostScript files that contain 8-bit binary data.
- Since
- .I macps
- normally converts this binary data, these PostScript file will not work
- properly.
- The
- .B \-r
- (raw) option suppresses this binary conversion.
- (Note: Depending on how the printer is physically connected, it may not be
- able to handle 8-bit binary data properly, and results may be disappointing.)
- .SH FILES
- .TP "\w'lib/macps.config 'u"
- lib/macps.config
- maps ProcSet ids to LaserPrep filenames
- .SH "SEE ALSO"
- lpr(1), macget(1), kermit(1), prepfix(1)
- .SH BUGS
- .I Macps
- only works with version 4.0 and up of the Macintosh LaserPrep files.
- Because of the way bit smoothing is implimented by the LaserWriter driver,
- some PostScript printers other than the Apple LaserWriters may not be able to
- bit smooth.
- RAZZLE!DAZZLE
- fi # End macps.1
- if test -f prepfix.1
- then
- echo shar: will not overwrite existing file "'prepfix.1'"
- else
- echo 'x - prepfix.1'
- cat << \RAZZLE!DAZZLE > prepfix.1
- .\" SCCSid = "@(#)prepfix.1 2.1 3/29/89"
- .TH PREPFIX 1 "29 March 1989"
- .UC 4
- .SH NAME
- prepfix \- converts Apple LaserPrep files to form useable on Unix
- .SH SYNOPSIS
- .B prepfix
- [
- \-l
- printer_name1
- [
- \-l
- printer_name2
- ]...
- ]
- [
- file
- ]
- .SH DESCRIPTION
- .I Prepfix
- takes the command-line LaserPrep file (or the standard input if no filename is
- given), and converts it into a form that is useable on Unix with the
- .IR macps (1),
- and is even electronically mailable.
- .PP
- To use
- .IR prepfix ,
- create the input LaserPrep file on a Macintosh by opening an empty
- document in some application, selecting
- .B Print
- >From the
- .B File
- menu and then typing (and holding) Command-K immediately after clicking the
- .B OK
- button in the LaserWriter print dialog box.
- Another dialog will appear, confirming that a file named ``PostScript'' is
- being created (the Command-K keys can be released now).
- .PP
- Depending on the application, the created PostScript file can be found in the
- System Folder, the application folder or the top level of the disk.
- This file can then be uploaded via some file transfer program, such as
- MacTerminal/VersaTerm and
- .IR macget (1)
- or MacKermit/Red Ryder and
- .IR kermit (1).
- .PP
- Normally, only Apple LaserWriters can take advantage of the bit smoothing
- feature of the LaserPrep file.
- However, other PostScript laser printer using the Motorola 680x0 processor
- and the Adobe PostScript firmware can be made to do bit smoothing by
- specifying for each printer the
- .B \-l
- option and the printer's name, as returned by the PostScript
- .B product
- command in
- .B statusdict
- (remember to quote the printer name if it contains blanks).
- The resulting LaserPrep file will be modified so that for LaserWriters and for
- printers specified in the
- .B \-l
- option, bit smoothing will be allowed (smoothing must still be selected in the
- Print Dialog box when saving the PostScript to disk).
- More than one printer name can be specified using additional
- .B \-l
- and printer name pairs.
- .SH "SEE ALSO"
- macps(1), macget(1), kermit(1)
- .SH BUGS
- .I Prepfix
- only works with version 4.0 and up of the Macintosh LaserPrep files.
- RAZZLE!DAZZLE
- fi # End prepfix.1
- echo '***** End of' macps.shar '*****'
- exit
-
-