Date: Fri, 3 Jul 92 13:08:55 PDT From: edmoy@violet.berkeley.edu Subject: macps/prepfix v. 2.3 Well, here is the long-overdue System 7 compatible version of macps and prepfix, version 2.3, in shar format. Following are some excerpts from the included ReadMe file. Edward Moy Principal Programmer - Macintosh & Unix Workstation Support Services Workstation Software Support Group University of California Berkeley, CA 94720 -------------------------------------------------------------------------------- WHAT IS MACPS? Macps is a Unix program that takes an uploaded PostScript file created on a Macintosh (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. 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 (mostly) compatible with Unix (See prepfix.1 for more details). CHANGES IN VERSION 2.3 Version 2.3 of prepfix now support LaserPrep 7.x (System 7). Resulting LaserPrep files are slightly smaller, since some extraneous comments have been removed. Version 2.3 of macps works with System 7-generated PostScript files, replacing the included LaserPrep with the modified version. Because of the way this change was made, macps can now work on either a Command-F or Command-K (pre-System 7) PostScript file. Creating a PostScript file under System 7 will cause all fonts used in a document to be downloaded. Downloaded fonts, especially TrueType fonts, tend to make the resulting PostScript file very large. Both the size of the PostScript file and the complexity of a downloadable TrueType font can cause some printers to fail to print, even when the printer already contains the requested fonts. Software like H.M. Ayala's Trimmer CDEV (available from most Macintosh ftp sites and bulletin board systems) can prevents selected fonts (those already resident in the printer) from being downloaded. ----------- 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: # Installation # Makefile # ReadMe # macaux.c # macps.1 # macps.c # macps.config # prepfix.1 # prepfix.c # str.h # ucbwhich.c # ucbwhich.h # macps/prepfix v 2.3 - archive created: Fri Jul 3 12:35:19 PDT 1992 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.3 7/1/92") 1) Look at the Makefile. There are three 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. Setting SAVE will cause macps to enclose the entire print job is a PostScript save/restore context. Normally you don't need SAVE, since most spooling software will automatically do an EOF between print jobs, which effectively does a restore of memory for you, but some spooling software does require the save/restore. Note that defining SAVE will cause printing to fail on a NeXT laser printer, while it is harmless on most other systems. The options will look something like: CFLAGS = -O -DSYSV -DCONFIGDIR=\"/usr/new/lib\" -DSAVE if you defined all the options. 2) Type "make". If all goes well, macps and prepfix will be created. 3) For pre-System 7 systems, 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. (No special setting need to be made under System 7.) 4a) Under a pre-System 7 system, 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. 4b) Under a System 7 system, make sure that the LaserWriter driver is installed 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 PostScript File radio button, and then click on the Save button. When the standard file dialog box appears, specify a name and folder for the PostScript file, and click on the Save button. 5) Upload the PostScript file(s) to Unix, using some file transfer program like MacTerminal, Versaterm, Red Ryder, MacKermit or ftp. 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 for pre-System 7 system, 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, 1992, 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.3 7/1/92" # # 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). # To do save/restore context, include -DSAVE in CFLAGS below. # 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) macps.o : macps.c str.h ucbwhich.h macaux.o : macaux.c str.h prepfix.o : prepfix.c str.h ucbwhich.o : ucbwhich.c ucbwhich.h clean : /bin/rm -f *.o macps prepfix RAZZLE!DAZZLE fi # End Makefile 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.3 7/3/92") Copyright (C) 1988, 1992, 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 (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. Since System 7, the LaserPrep is no longer downloaded to the printer. Some people have had success printing a System 7-generated PostScript file directly, but using macps should make printing more reliable and available to non-Apple PostScript printers. 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 (mostly) compatible with Unix (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.3 Version 2.3 of prepfix now support LaserPrep 7.x (System 7). Resulting LaserPrep files are slightly smaller, since some extraneous comments have been removed. Version 2.3 of macps works with System 7-generated PostScript files, replacing the included LaserPrep with the modified version. Because of the way this change was made, macps can now work on either a Command-F or Command-K (pre-System 7) PostScript file. Creating a PostScript file under System 7 will cause all fonts used in a document to be downloaded. Downloaded fonts, especially TrueType fonts, tend to make the resulting PostScript file very large. Both the size of the PostScript file and the complexity of a downloadable TrueType font can cause some printers to fail to print, even when the printer already contains the requested fonts. Software like H.M. Ayala's Trimmer CDEV (available from most Macintosh ftp sites and bulletin board systems) can prevents selected fonts (those already resident in the printer) from being downloaded. CHANGES IN VERSION 2.2 Version 2.2 of prepfix now supports LaserPrep 6.0. The PostScript save/restore context is now a compile-time option, since it caused printing to fail on a NeXT printer (though it was harmless on most other printers). This save/restore is now more intelligent about clearing the stacks. 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 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, 1992, 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.3 7/1/92"; #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 = (byte *)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 = (byte *)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') { if(str->curendptr >= str->realendptr) STRexpand(str); *str->curendptr = 0; return(TRUE); } } } STRputsptr(str, cp, fp) register STR *str; register byte *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 byte *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 byte *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++; } } byte * STRmatch(str, sp) register STR *str; register byte *sp; { register byte *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.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.3 7/3/92" .TH MACPS 1 "1 July 1992" .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 in one of two ways. On pre-System 7 systems, this PostScript file is created by typing (and holding) Command-F immediately after clicking the OK button of the LaserWriter Print dialog box. Another dialog will appear, confirming that a file named ``PostScript'' is being created (the Command-F keys can be released now). 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. .PP On System 7 systems, the Print dialog box allows the selection of the destination of the output. Clicking on the PostScript File radio button and then clicking the Save button will cause a standard file dialog box to appear, allowing the user to specify the name and location of the resultant PostScript file. .PP The PostScript file can then be uploaded via some file transfer program, such as MacTerminal/VersaTerm and .IR macget (1), MacKermit/Red Ryder and .IR kermit (1) or .IR ftp (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 In a Macintosh PostScript file, the line beginning with ``%%IncludeProcSet:'' is a request to include a LaserPrep with the internal name that follows on the same line as the ``%%IncludeProcSet:'' directive. This internal name corresponds to the name in a LaserPrep file that follows on the same line as the ``%%BeginProcSet:'' directive. .PP To specify where a LaserPrep file with a certain internal name is stored, a file named .B macps.config is used. This file is composed of one of more lines; one for each LaserPrep file. Each line contains the internal name followed a tab character followed by the name of file containing the corresponding LaserPrep. The file name can be either a full pathname or a pathname relative to the directory that .B macps.config resides. .PP The .B macps.config file is normally located in a `lib' subdirectory of the directory .I macps is located. 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 files 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 internal names 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. .PP Because of the way bit smoothing is implemented by the LaserWriter driver, some PostScript printers other than the Apple LaserWriters may not be able to bit smooth. .PP Creating a PostScript file under System 7 will cause all fonts used in a document to be downloaded. Downloaded fonts, especially TrueType fonts, tend to make the resulting PostScript file very large. Both the size of the PostScript file and the complexity of a downloadable TrueType font can cause some printers to fail to print, even when the printer already contains the requested fonts. Software like H.M. Ayala's Trimmer CDEV (available from most Macintosh ftp sites and bulletin board systems) can prevents selected fonts (those already resident in the printer) from being downloaded. RAZZLE!DAZZLE fi # End macps.1 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, 1992, 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.3 7/1/92"; #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 BEGINPROC 1 #define CONFIG "macps.config" #define INCLUDEPROC 0 #define PS_INCLUDED 0x1 #ifdef SYSV #define index strchr #define rindex strrchr #endif SYSV typedef struct procset_str { struct procset_str *next; char *procset; char *path; short flags; } ProcSet; ProcSet *firstprocset; #ifdef SAVE char *finale = "clear countdictstack 2 sub{end}repeat macps restore\n"; char intro[] = "\ %%! *** Created by macps: %s\ /macps save def\n\ "; #else SAVE char intro[] = "\ %%! *** Created by macps: %s\ "; #endif SAVE ProcSet *lastprocset; char *myname; int ncopies = 0; #ifdef CONFIGDIR char ucblib[UCBMAXPATHLEN] = CONFIGDIR; #else CONFIGDIR int ucbalternate; char ucbpath[UCBMAXPATHLEN]; char ucblib[UCBMAXPATHLEN]; #endif CONFIGDIR void copyproc(); ProcSet *findprocset(); void insertproc(); char *newstring(); void newprocset(); void readprocfile(); void Usage(); main(argc, argv) int argc; char **argv; { register STR *str; register char *cp; long ltime; char *ctime(); #ifndef CONFIGDIR ucbwhich(*argv); #endif CONFIGDIR strcat(ucblib, "/"); 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); } readprocfile(); str = STRalloc(); if(!STRgets(str, stdin)) { fprintf(stderr, "%s: Null input\n", myname); exit(1); } time(<ime); printf(intro, ctime(<ime)); do { if(ncopies != 0 && STRheadcompare(str, "userdict /#copies ") == 0) continue; if(STRcompare(str, "%%EOF\n") == 0) { #ifdef SAVE if(finale) { fputs(finale, stdout); finale = NULL; } #endif SAVE STRputs(str, stdout); continue; } if(STRheadcompare(str, "%%IncludeProcSet:") == 0) { insertproc(str, INCLUDEPROC); continue; } if(STRheadcompare(str, "%%BeginProcSet:") == 0) { insertproc(str, BEGINPROC); 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)); #ifdef SAVE if(finale) fputs(finale, stdout); #endif SAVE exit(0); } void insertproc(str, beginproc) register STR *str; int beginproc; { register char *cp, *pp; register int i, n, fd; register ProcSet *ps; char buf[BUFSIZ]; cp = index((char *)str->bufptr, ':') + 1; strcpy(buf, cp); cp = buf; for( ; ; cp++) { if(!*cp) { fprintf(stderr, "%s: Syntax error on IncludeProcSet/BeginProcSet line\n", myname); exit(1); } if(!isascii(*cp) || !isspace(*cp)) break; } pp = cp + strlen(cp); while(--pp >= cp) { if(!isascii(*pp) || !isspace(*pp)) break; *pp = 0; } if((ps = findprocset(cp)) == NULL) { if(beginproc) { STRputs(str, stdout); copyproc(str, stdout); return; } fprintf(stderr, "%s: Unknown IncludeProcSet %s\n", myname, cp); exit(1); } if(ps->flags & PS_INCLUDED) return; ps->flags |= PS_INCLUDED; if(*(ps->path) == '/') strcpy(buf, ps->path); else { strcpy(buf, ucblib); strcat(buf, ps->path); } fflush(stdout); if((fd = open(buf, O_RDONLY, 0)) < 0) { fprintf(stderr, "%s: Can't open %s\n", myname, buf); exit(1); } if(beginproc) copyproc(str, NULL); while((i = read(fd, buf, BUFSIZ)) > 0) { do { if((n = write(1, buf, i)) < 0) { fprintf(stderr, "%s: Write error\n", myname); exit(1); } } while((i -= n) > 0); } close(fd); } void readprocfile() { register FILE *fp; register char *pp; register int linenum; char buf[BUFSIZ]; strcpy(buf, ucblib); strcat(buf, CONFIG); if((fp = fopen(buf, "r")) == NULL) { fprintf(stderr, "%s: Can't open %s\n", myname, buf); exit(1); } linenum = 0; while(fgets(buf, BUFSIZ, fp)) { linenum++; if(*buf == '#') continue; if(pp = index(buf, '\n')) { if(pp == buf) continue; *pp = 0; } if(!(pp = index(buf, '\t'))) { fprintf(stderr, "%s: Syntax error in macps.config, line %d\n", myname, linenum); exit(1); } *pp++ = 0; newprocset(buf, pp); } fclose(fp); } void copyproc(str, fp) register STR *str; register FILE *fp; { for( ; ; ) { if(!STRgets(str, stdin)) { fprintf(stderr, "%s: End of file copying ProcSet\n", myname); exit(1); } if(fp) STRputs(str, fp); if(STRheadcompare(str, "%%EndProcSet") == 0) return; } } void newprocset(procset, path) char *procset, *path; { register ProcSet *ps; char *calloc(); if((ps = (ProcSet *)calloc(1, sizeof(ProcSet))) == NULL) { fprintf(stderr, "%s: Out of memory allocating ProcSet\n", myname); exit(1); } if(firstprocset) { lastprocset->next = ps; lastprocset = ps; } else firstprocset = lastprocset = ps; ps->procset = newstring(procset); ps->path = newstring(path); } ProcSet * findprocset(procset) register char *procset; { register ProcSet *ps; for(ps = firstprocset ; ps ; ps = ps->next) { if(strcmp(procset, ps->procset) == 0) return(ps); } return(NULL); } char * newstring(str) register char *str; { register char *cp; char *malloc(); if((cp = malloc(strlen(str) + 1)) == NULL) { fprintf(stderr, "%s: Out of memory allocating string\n", myname); exit(1); } strcpy(cp, str); return(cp); } void Usage() { fputs("Usage: macps [-c #] [-d directory] [-r] [file]\n", stderr); exit(1); } RAZZLE!DAZZLE fi # End macps.c 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.3 7/1/92" # # 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 "(AppleDict md)" 70 0 ProcSets/LaserPrep6.0 "(AppleDict md)" 71 0 ProcSets/LaserPrep7.0 RAZZLE!DAZZLE fi # End macps.config 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.3 7/1/92" .TH PREPFIX 1 "1 Jul 1992" .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). .PP To use .IR prepfix , create the input LaserPrep file on a Macintosh by opening an empty document in some application, and selecting .B Print from the .B File menu. On a pre-System 7 system, typing (and holding) Command-K immediately after clicking the .B OK button in the LaserWriter print dialog box will cause another dialog to appear, confirming that a file named ``PostScript'' is being created (the Command-K keys can be released now). 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. .PP On a System 7 system, clicking on the .B "PostScript File" radio button and then clicking on the .B Save button will cause a standard file dialog to appear, requesting the name and location to save the PostScript file. .PP This PostScript file can then be uploaded via some file transfer program, such as MacTerminal/VersaTerm and .IR macget (1), MacKermit/Red Ryder and .IR kermit (1) or .IR ftp (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" ftp(1), 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 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, 1992, 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.3 7/1/92"; #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{true}{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}ifelse}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 byte *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] = ')'; STRputs(str, tp); } else if(STRheadcompare(str, "%% \251") == 0) { fputs("%%", tp); str->bufptr[0] = ' '; str->bufptr[1] = '('; str->bufptr[2] = 'C'; str->bufptr[3] = ')'; STRputs(str, tp); } else if(STRheadcompare(str, "%%BeginProcSet:") == 0) { STRputs(str, stdout); rewind(tp); while((i = fread(buf, 1, BUFSIZ, tp)) > 0) fwrite(buf, 1, i, stdout); fclose(tp); break; } else if(STRheadcompare(str, "%{appledict") == 0) STRputs(str, tp); if(!STRgets(str, stdin)) { fprintf(stderr, "%s: No BeginProcSet\n", myname); exit(1); } } while(STRgets(str, stdin)) { if(nproducts > 0 && STRmatch(str, "/ok{")) { 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, " checkload")) { checkload(str); continue; } else if(STRmatch(str, "/stretch") && STRmatch(str, "eexec")) { eexec("stretch", str); continue; } else if(STRmatch(str, "/smooth4") && STRmatch(str, "eexec")) { eexec("smooth4", str); continue; } else if(STRmatch(str, "(LaserWriter II NT)")) { while(STRgets(str, stdin) && STRheadcompare(str, "35de") != 0) { /* ignore line */ } while(STRgets(str, stdin) && isxdigit(*str->bufptr)) { /* ignore line */ } } else if(lp = STRmatch(str, "scaleby96{ppr")) { STRputsptr(str, lp, stdout); continue; } else if(STRmatch(str, "waittimeout")) 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; if(!STRgets(str, stdin)) { fprintf(stderr, "%s: EOF during reading eexec\n", myname); exit(1); } len = (str->curendptr - str->bufptr) - 1; printf(exstr, nproducts > 0 ? 'O' : 'o', name, len + (len / EEXECLEN) + (len % EEXECLEN ? 1 : 0) + EXTRA); spliteexec(str); } checkload(str) register STR *str; { register byte *cp; if(nproducts > 0 && (cp = STRmatch(str, "ok "))) *cp = 'O'; STRputs(str, stdout); if(!STRgets(str, stdin)) { fprintf(stderr, "%s: EOF during reading eexec\n", myname); exit(1); } spliteexec(str); } spliteexec(str) register STR *str; { register int len; register byte *bp; bp = str->bufptr; len = (str->curendptr - bp) - 1; 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); } STRputs(str, stdout); if(STRheadcompare(str, "cleartomark") == 0) return; } } 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, 1992, 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.3 7/1/92" */ #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 unsigned char byte; typedef struct { byte *bufptr; byte *curendptr; byte *realendptr; } STR; extern int rawmode; STR *STRalloc(); int STRcompareptr(); int STRfree(); int STRgets(); int STRheadcmpptr(); byte *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, 1992, 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.3 7/1/92"; #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, 1992, 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.3 7/1/92" */ #define UCBMAXPATHLEN 128 #define UCBSTANDARD "/usr/ucb" extern char ucblib[]; extern int ucbalternate; extern char ucbpath[]; RAZZLE!DAZZLE fi # End ucbwhich.h echo '***** End of' macps/prepfix v 2.3 '*****' exit