diff options
| author | Asias He <asias.hejun@gmail.com> | 2010-09-25 11:51:56 +0800 |
|---|---|---|
| committer | Asias He <asias.hejun@gmail.com> | 2010-09-25 11:51:56 +0800 |
| commit | fa95a976b7e0e64df0d78a327e1295ee0df262fa (patch) | |
| tree | 014ecbbf973e0560f793727373e046cc09cfa03b /usr/src/cmd/lp | |
| parent | 979c69e6fa55f8c86e98b621bbf3760943d35409 (diff) | |
| download | illumos-joyent-fa95a976b7e0e64df0d78a327e1295ee0df262fa.tar.gz | |
111 clean up legacy postscript filters
Reviewed by: garrett@nexenta.com
Approved by: garrett@nexenta.com
Diffstat (limited to 'usr/src/cmd/lp')
30 files changed, 0 insertions, 7442 deletions
diff --git a/usr/src/cmd/lp/filter/postscript/Makefile b/usr/src/cmd/lp/filter/postscript/Makefile index b60cfaf4b3..a730da0d8f 100644 --- a/usr/src/cmd/lp/filter/postscript/Makefile +++ b/usr/src/cmd/lp/filter/postscript/Makefile @@ -20,7 +20,6 @@ # CDDL HEADER END # # -# ident "%Z%%M% %I% %E% SMI" # # Copyright 1989-2002 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. @@ -36,14 +35,8 @@ COMMON_SUBDIRS = \ dpost \ postio \ postprint \ - posttek \ - postdmd \ - postdaisy \ - postmd \ - postplot \ postscript \ postcomm \ - picpack \ download \ font \ filtdesc diff --git a/usr/src/cmd/lp/filter/postscript/README b/usr/src/cmd/lp/filter/postscript/README index 9d78aab37d..93c5eab345 100644 --- a/usr/src/cmd/lp/filter/postscript/README +++ b/usr/src/cmd/lp/filter/postscript/README @@ -228,33 +228,6 @@ postbgi postbgi -P"/prism true" file >file.ps -postdaisy - Translates Diablo 630 files into PostScript. - - EXAMPLE: - - postdaisy file >file.ps - -postdmd - Translates DMD bitmap files into PostScript. The original program (ie. abm) - was written by Guy Riddle. The Ninth Edition bitfile format is supported, - although unless you use the -u option they will be unpacked and completely - reformatted before being sent to the printer. - - EXAMPLE: - - postdmd file >file.ps - -postmd - A program that can be used to display large matrices as gray scale images - on PostScript printers. May help if you're looking for patterns in large - matrices. Input files are matrix elements, written as a series of floating - point numbers in row major order. Check the man page for more details. - - EXAMPLE: - - postmd file >file.ps - postprint Translates ASCII files into PostScript. @@ -272,32 +245,6 @@ postreverse postprint file | postreverse >file.ps -posttek - Translates tektronix 4014 files into PostScript. Most of the code was - borrowed from the DMD tektronix emulator. The default line width is one - pixel, which gives the good results on 300dpi write-black engines, but one - pixel wide lines hardly show up on write-white engines like the ones used - in the PS-2400 or Dataproducts 2665. The -w option can be used to set a - new line width. The argument is in points, where one point is about 1/72 - of an inch. For a different default change the definition of linewidth - in postscript/posttek.ps. - - EXAMPLE: - - posttek -w.5 file >file.ps - -picpack - A simple picture packing pre-processor that works in combination with the - troff, dpost, and the picture inclusion macros. It's not a replacement - for the original picture inclusion mechanism (in dpost) but may help if - you have an application that needs everything together in a single file - before dpost runs. The original picture inclusion mechanism is still the - preferred approach!! - - EXAMPLE: - - picpack file | troff -mm -Tpost >file.t - buildtables A collection of programs and data files that can be used if you want to have a PostScript printer generate new troff width tables for printer or diff --git a/usr/src/cmd/lp/filter/postscript/filtdesc/Makefile b/usr/src/cmd/lp/filter/postscript/filtdesc/Makefile index 65106d65dc..6c9e6d4c1b 100644 --- a/usr/src/cmd/lp/filter/postscript/filtdesc/Makefile +++ b/usr/src/cmd/lp/filter/postscript/filtdesc/Makefile @@ -20,7 +20,6 @@ # CDDL HEADER END # # -# ident "%Z%%M% %I% %E% SMI" # # Copyright 1989-2002 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. @@ -35,15 +34,10 @@ ROOTETCLPFD= $(ROOTETCLP)/fd FILES= catv.fd \ download.fd \ dpost.fd \ - postdaisy.fd \ - postdmd.fd \ postio.fd \ postior.fd \ - postmd.fd \ - postplot.fd \ postprint.fd \ postreverse.fd \ - posttek.fd \ postpages.fd \ pr.fd diff --git a/usr/src/cmd/lp/filter/postscript/filtdesc/postdaisy.fd b/usr/src/cmd/lp/filter/postscript/filtdesc/postdaisy.fd deleted file mode 100644 index e6f92c5e99..0000000000 --- a/usr/src/cmd/lp/filter/postscript/filtdesc/postdaisy.fd +++ /dev/null @@ -1,38 +0,0 @@ -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -Input types: daisy -Output types: postscript -Printer types: any -Printers: any -Filter type: slow -Command: /usr/lib/lp/postscript/postdaisy -Options: PAGES * = -o* -Options: COPIES * = -c* -Options: MODES group = -n2 -Options: MODES group\=\([2-9]\) = -n\1 -Options: MODES portrait = -pp -Options: MODES landscape = -pl -Options: MODES x\=\(\-*[\.0-9]*\) = -x\1 -Options: MODES y\=\(\-*[\.0-9]*\) = -y\1 -Options: MODES magnify\=\([\.0-9]*\) = -m\1 diff --git a/usr/src/cmd/lp/filter/postscript/filtdesc/postdmd.fd b/usr/src/cmd/lp/filter/postscript/filtdesc/postdmd.fd deleted file mode 100644 index 2435b7d184..0000000000 --- a/usr/src/cmd/lp/filter/postscript/filtdesc/postdmd.fd +++ /dev/null @@ -1,39 +0,0 @@ -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -Input types: dmd -Output types: postscript -Printer types: any -Printers: any -Filter type: slow -Command: /usr/lib/lp/postscript/postdmd -Options: PAGES * = -o* -Options: COPIES * = -c* -Options: LENGTH * = -l* -Options: MODES group = -n2 -Options: MODES group\=\([2-9]\) = -n\1 -Options: MODES portrait = -pp -Options: MODES landscape = -pl -Options: MODES x\=\(\-*[\.0-9]*\) = -x\1 -Options: MODES y\=\(\-*[\.0-9]*\) = -y\1 -Options: MODES magnify\=\([\.0-9]*\) = -m\1 diff --git a/usr/src/cmd/lp/filter/postscript/filtdesc/postmd.fd b/usr/src/cmd/lp/filter/postscript/filtdesc/postmd.fd deleted file mode 100644 index 0149f3a767..0000000000 --- a/usr/src/cmd/lp/filter/postscript/filtdesc/postmd.fd +++ /dev/null @@ -1,41 +0,0 @@ -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -Input types: matrix -Output types: postscript -Printer types: any -Printers: any -Filter type: slow -Command: /usr/lib/lp/postscript/postmd -Options: PAGES * = -o* -Options: COPIES * = -c* -Options: LENGTH * = -l* -Options: MODES group = -n2 -Options: MODES group\=\([2-9]\) = -n\1 -Options: MODES portrait = -pp -Options: MODES landscape = -pl -Options: MODES x\=\(\-*[\.0-9]*\) = -x\1 -Options: MODES y\=\(\-*[\.0-9]*\) = -y\1 -Options: MODES magnify\=\([\.0-9]*\) = -m\1 -Options: MODES dimen\=\([1-9]*x*[1-9]*\) = -d\1 -Options: MODES interval\=\(-*[0-9]*\)/*\(-*[0-9]*\)/*\(-*[0-9]*\) = -i\1\,\2\,\3 diff --git a/usr/src/cmd/lp/filter/postscript/filtdesc/postplot.fd b/usr/src/cmd/lp/filter/postscript/filtdesc/postplot.fd deleted file mode 100644 index 9a6395223f..0000000000 --- a/usr/src/cmd/lp/filter/postscript/filtdesc/postplot.fd +++ /dev/null @@ -1,34 +0,0 @@ -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -Input types: plot -Output types: postscript -Printer types: any -Printers: any -Filter type: slow -Command: /usr/lib/lp/postscript/postplot -Options: PAGES * = -o* -Options: COPIES * = -c* -Options: MODES group = -n2 -Options: MODES portrait = -pp -Options: MODES landscape = -pl diff --git a/usr/src/cmd/lp/filter/postscript/filtdesc/posttek.fd b/usr/src/cmd/lp/filter/postscript/filtdesc/posttek.fd deleted file mode 100644 index c53c203750..0000000000 --- a/usr/src/cmd/lp/filter/postscript/filtdesc/posttek.fd +++ /dev/null @@ -1,39 +0,0 @@ -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.2 */ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -Input types: tek4014 -Output types: postscript -Printer types: any -Printers: any -Filter type: slow -Command: /usr/lib/lp/postscript/posttek -Options: PAGES * = -o* -Options: COPIES * = -c* -Options: LENGTH * = -l* -Options: MODES group = -n2 -Options: MODES group\=\([2-9]\) = -n\1 -Options: MODES portrait = -pp -Options: MODES landscape = -pl -Options: MODES x\=\(\-*[0-9][\.0-9]\) = -x\1 -Options: MODES y\=\(\-*[0-9][\.0-9]\) = -y\1 -Options: MODES magnify\=\([0-9][\.0-9]\) = -m\1 diff --git a/usr/src/cmd/lp/filter/postscript/picpack/Makefile b/usr/src/cmd/lp/filter/postscript/picpack/Makefile deleted file mode 100644 index 7990d1d4ef..0000000000 --- a/usr/src/cmd/lp/filter/postscript/picpack/Makefile +++ /dev/null @@ -1,76 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# ident "%Z%%M% %I% %E% SMI" -# -# Copyright 1989-2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/lp/filter/postscript/picpack/Makefile -# - -include ../../../Makefile.lp - -PROG= picpack - -SRCS= picpack.c - -OBJS = $(SRCS:%.c=%.o) - -COMMONDIR = ../common - -COMMONOBJS = $(COMMONDIR)/glob.o \ - $(COMMONDIR)/misc.o \ - $(COMMONDIR)/tempnam.o - - -ENCODING = 2 -CPPFLAGS = -DDFLTENCODING=$(ENCODING) \ - -I$(COMMONDIR) \ - $(CPPFLAGS.master) - -POFILE = lp_filter_postscript_picpack.po - -.KEEP_STATE: - -all: $(PROG) - -install: all $(ROOTLIBLPPOSTPROG) - -$(PROG): $(OBJS) $(COMMONOBJS) - $(LINK.c) -o $@ $(OBJS) $(COMMONOBJS) $(LDLIBS) - $(POST_PROCESS) - -$(COMMONOBJS): $$(@:%.o=%.c) - cd $(@D); $(MAKE) $(@F) - -clean : - $(RM) $(OBJS) - -strip: - $(STRIP) $(PROG) - -lint: lint_SRCS - -include ../../../../Makefile.targ - -include ../Makefile.msg diff --git a/usr/src/cmd/lp/filter/postscript/picpack/picpack.c b/usr/src/cmd/lp/filter/postscript/picpack/picpack.c deleted file mode 100644 index 0573056b8a..0000000000 --- a/usr/src/cmd/lp/filter/postscript/picpack/picpack.c +++ /dev/null @@ -1,488 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * - * picpack - picture packing pre-processor - * - * A trivial troff pre-processor that copies files to stdout, expanding picture - * requests into an in-line format that's passed transparently through troff and - * handled by dpost. The program is an attempt to address requirements, expressed - * by several organizations, of being able to store a document as a single file - * (usually troff input) that can then be sent through dpost and ultimately to - * a PostScript printer. - * - * The program looks for strings listed in the keys[] array at the start of each - * line. When a picture request (as listed in keys[]) is found the second string - * on the line is taken to be a picture file pathname that's added (in transparent - * mode) to the output file. In addition each in-line picture file is preceeded by - * device control command (again passed through in transparent mode) that looks - * like, - * - * x X InlinePicture filename bytes - * - * where bytes is the size of the picture file (which begins on the next line) - * and filename is the pathname of the picture file. dpost uses both arguments to - * manage in-line pictures (in a big temp file). To handle pictures in diversions - * picpack reads each input file twice. The first pass looks for picture inclusion - * requests and copies each picture file transparently to the output file, while - * second pass just copies the input file to the output file. Things could still - * break, but the two pass method should handle most jobs. - * - * The recognized in-line picture requests are saved in keys[] and by default only - * expand .BP and .PI macro calls. The -k option changes the recognized strings, - * and may be needed if you've built your own picture inclusion macros on top of - * .BP or .PI or decided to list each picture file at the start of your input file - * using a dummy macro. For example you could require every in-line picture be - * named by a dummy macro (say .iP), then the command line, - * - * picpack -k.iP file > file.pack - * - * hits on lines that begin with .iP (rather than .BP or .PI), and the only files - * pulled in would be ones named as the second argument to the new .iP macro. The - * -k option accepts a space or comma separated list of up to 10 different key - * strings. picpack imposes no contraints on key strings, other than not allowing - * spaces or commas. A key string can begin with \" and in that case it would be - * troff comment. - * - * Although the program will help some users, there are obvious disadvantages. - * Perhaps the most important is that troff output files (with in-line pictures - * included) don't fit the device independent language accepted by important post - * processors like proof, and that means you won't be able to reliably preview a - * packed file on your 5620 or whatever. Another potential problem is that picture - * files can be large. Packing everything together in a single file at an early - * stage has a better chance of exceeding your system's ulimit. - * - */ - - -#include <stdio.h> -#include <sys/types.h> -#include <sys/stat.h> - -#include "gen.h" /* general purpose definitions */ -#include "ext.h" /* external variable definitions */ -#include "path.h" /* just for TEMPDIR definition */ - - -char *keys[11] = {".BP", ".PI", NULL}; -int quiet = FALSE; - -FILE *fp_in = stdin; /* input */ -FILE *fp_out = stdout; /* and output files */ - -static void addpicfile(char *); -static void arguments(void); -static void copyfile(int, int); -static FILE *copystdin(void); -static void done(void); -static void do_inline(char *); -static int gotpicfile(char *); -static void newkeys(char *); -static void options(void); -static void picpack(void); - -/*****************************************************************************/ - -int -main(int agc, char *agv[]) -{ - - -/* - * - * A picture packing pre-processor that copies input files to stdout, expanding - * picture requests (as listed in keys[]) to an in-line format that can be passed - * through troff (using transparent mode) and handled later by dpost. - * - */ - - - argc = agc; /* global so everyone can use them */ - argv = agv; - - prog_name = argv[0]; /* just for error messages */ - - options(); /* command line options */ - arguments(); /* translate all the input files */ - done(); /* clean things up */ - - return (x_stat); /* everything probably went OK */ - -} /* End of main */ - - -/*****************************************************************************/ - -static void -options(void) -{ - int ch; /* name returned by getopt() */ - - extern char *optarg; /* option argument set by getopt() */ - extern int optind; - - -/* - * - * Handles the command line options. - * - */ - - - while ( (ch = getopt(argc, argv, "k:qDI")) != EOF ) { - - switch ( ch ) { - - case 'k': /* new expansion key strings */ - newkeys(optarg); - break; - - case 'q': /* disables "missing picture" messages */ - quiet = TRUE; - break; - - case 'D': /* debug flag */ - debug = ON; - break; - - case 'I': /* ignore FATAL errors */ - ignore = ON; - break; - - case '?': /* don't know the option */ - error(FATAL, ""); - break; - - default: - error(FATAL, "missing case for option %c", ch); - break; - - } /* End switch */ - } /* End while */ - - argc -= optind; /* get ready for non-options args */ - argv += optind; - -} /* End of options */ - - -/*****************************************************************************/ - -static void -newkeys(char *list) - /* comma or space separated key strings */ -{ - char *p; /* next key string from *list */ - int i; /* goes in keys[i] */ - int n; /* last key string slot in keys[] */ - -/* - * - * Separates *list into space or comma separated strings and adds each one to the - * keys[] array. The strings in keys[] are used to locate the picture inclusion - * requests that are translated to the in-line format. The keys array must end - * with a NULL pointer and by default only expands .BP and .PI macro calls. - * - */ - - - n = (sizeof(keys) / sizeof(char *)) - 1; - - for ( i = 0, p = strtok(list, " ,"); p != NULL; i++, p = strtok(NULL, " ,") ) - if ( i >= n ) - error(FATAL, "too many key strings"); - else keys[i] = p; - - keys[i] = NULL; - -} /* End of newkeys */ - - -/*****************************************************************************/ - -static void -arguments(void) -{ - -/* - * - * Makes sure all the non-option command line arguments are processed. If we get - * here and there aren't any arguments left, or if '-' is one of the input files - * we process stdin, after copying it to a temporary file. - * - */ - - - if ( argc < 1 ) { - fp_in = copystdin(); - picpack(); - } else - while ( argc > 0 ) { - if ( strcmp(*argv, "-") == 0 ) - fp_in = copystdin(); - else if ( (fp_in = fopen(*argv, "r")) == NULL ) - error(FATAL, "can't open %s", *argv); - picpack(); - fclose(fp_in); - argc--; - argv++; - } /* End while */ - -} /* End of arguments */ - - -/*****************************************************************************/ - -static FILE * -copystdin(void) -{ - char *tfile; /* temporary file name */ - int fd_out; /* and its file descriptor */ - FILE *fp; /* return value - will be new input file */ - - -/* - * - * Copies stdin to a temp file, unlinks the file, and returns the file pointer for - * the new temporary file to the caller. Needed because we read each input file - * twice in an attempt to handle pictures in diversions. - * - */ - - - if ( (tfile = tempnam(TEMPDIR, "post")) == NULL ) - error(FATAL, "can't generate temp file name"); - - if ( (fd_out = creat(tfile, 0660)) == -1 ) - error(FATAL, "can't create %s", tfile); - - copyfile(fileno(stdin), fd_out); - close(fd_out); - - if ( (fp = fopen(tfile, "r")) == NULL ) - error(FATAL, "can't open %s", tfile); - - unlink(tfile); - return(fp); - -} /* End of copystdin */ - - -/*****************************************************************************/ - -static void -copyfile(int fd_in, int fd_out) - /* fd_in - input */ - /* fd_out - and output files */ -{ - char buf[512]; /* internal buffer for reads and writes */ - int count; /* number of bytes put in buf[] */ - -/* - * - * Copies file fd_in to fd_out. Handles the second pass for each input file and - * also used to copy stdin to a temporary file. - * - */ - - - while ( (count = read(fd_in, buf, sizeof(buf))) > 0 ) - if ( write(fd_out, buf, count) != count ) - error(FATAL, "write error"); - -} /* End of copyfile */ - - -/*****************************************************************************/ - -static void -done(void) -{ - -/* - * - * Finished with all the input files so unlink the temporary file that we used - * to record the in-line picture file pathnames. - * - */ - - - if ( temp_file != NULL ) - unlink(temp_file); - -} /* End of done */ - - -/*****************************************************************************/ - -static void -picpack(void) -{ - char line[512]; /* next input line */ - char name[100]; /* picture file names - from BP or PI */ - int i; /* for looking through keys[] */ - -/* - * - * Handles the two passes over the next input file. First pass compares the start - * of each line in *fp_in with the key strings saved in the keys[] array. If a - * match is found do_inline() is called to copy the picture file (the file named - * as the second string in line[]) to stdout, provided the file hasn't previously - * been copied. The second pass goes back to the start of fp_in and copies it all - * to the output file. - * - */ - - - while ( fgets(line, sizeof(line), fp_in) != NULL ) { - for ( i = 0; keys[i] != NULL; i++ ) - if ( strncmp(line, keys[i], strlen(keys[i])) == 0 ) { - if ( sscanf(line, "%*s %s", name) == 1 ) { - strtok(name, "("); - if ( gotpicfile(name) == FALSE ) - do_inline(name); - } /* End if */ - } /* End if */ - } /* End while */ - - fflush(fp_out); /* second pass - copy fp_in to fp_out */ - fseek(fp_in, 0L, 0); - copyfile(fileno(fp_in), fileno(fp_out)); - -} /* End of picpack */ - - -/*****************************************************************************/ - -static void -do_inline(char *name) - /* name of the in-line picture file */ -{ - long size; /* and its size in bytes - from fstat */ - FILE *fp; /* for reading file *name */ - int ch; /* next character from picture file */ - int lastch = '\n'; /* so we know when to put out \! */ - - struct stat sbuf; /* for the picture file size */ - -/* - * - * Copies the picture file *name to the output file in an in-line format that can - * be passed through troff and recovered later by dpost. Transparent mode is used - * so each line starts with \! and all \ characters must be escaped. The in-line - * picture sequence begins with an "x X InlinePicture" device control command that - * names the picture file and gives its size (in bytes). - * - */ - - - if ( (fp = fopen(name, "r")) != NULL ) { - fstat(fileno(fp), &sbuf); - if ( (size = sbuf.st_size) > 0 ) { - fprintf(fp_out, "\\!x X InlinePicture %s %ld\n", name, size); - while ( (ch = getc(fp)) != EOF ) { - if ( lastch == '\n' ) - fprintf(fp_out, "\\!"); - if ( ch == '\\' ) - putc('\\', fp_out); - putc(lastch = ch, fp_out); - } /* End while */ - if ( lastch != '\n' ) - putc('\n', fp_out); - } /* End if */ - fclose(fp); - addpicfile(name); - } else if ( quiet == FALSE ) - error(NON_FATAL, "can't read picture file %s", name); - -} /* End of do_inline */ - - -/*****************************************************************************/ - -static int -gotpicfile(char *name) -{ - char buf[100]; - FILE *fp_pic; - -/* - * - * Checks the list of previously added picture files in *temp_file and returns - * FALSE if it's a new file and TRUE otherwise. Probably should open the temp - * file once for update and leave it open, rather than opening and closing it - * every time. - * - */ - - - if ( temp_file != NULL ) - if ( (fp_pic = fopen(temp_file, "r")) != NULL ) { - while ( fscanf(fp_pic, "%s", buf) != EOF ) - if ( strcmp(buf, name) == 0 ) { - fclose(fp_pic); - return(TRUE); - } /* End if */ - fclose(fp_pic); - } /* End if */ - - return(FALSE); - -} /* End of gotpicfile */ - - -/*****************************************************************************/ - -static void -addpicfile(char *name) -{ - FILE *fp_pic; - -/* - * - * Adds string *name to the list of in-line picture files that's maintained in - * *temp_file. Should undoubtedly open the file once for update and use fseek() - * to move around in the file! - * - */ - - - if ( temp_file == NULL ) - if ( (temp_file = tempnam(TEMPDIR, "picpac")) == NULL ) - return; - - if ( (fp_pic = fopen(temp_file, "a")) != NULL ) { - fprintf(fp_pic, "%s\n", name); - fclose(fp_pic); - } /* End if */ - -} /* End of addpicfile */ diff --git a/usr/src/cmd/lp/filter/postscript/postdaisy/Makefile b/usr/src/cmd/lp/filter/postscript/postdaisy/Makefile deleted file mode 100644 index ec976aaf7e..0000000000 --- a/usr/src/cmd/lp/filter/postscript/postdaisy/Makefile +++ /dev/null @@ -1,77 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# ident "%Z%%M% %I% %E% SMI" -# -# Copyright 1989-2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/lp/filter/postscript/postdaisy/Makefile -# - -include ../../../Makefile.lp - -PROG= postdaisy - -SRCS= postdaisy.c - -OBJS = $(SRCS:%.c=%.o) - -COMMONDIR = ../common - -COMMONOBJS = $(COMMONDIR)/request.o \ - $(COMMONDIR)/glob.o \ - $(COMMONDIR)/misc.o - -TXTS= README - -ENCODING = 2 -CPPFLAGS = -DDFLTENCODING=$(ENCODING) \ - -I. -I$(COMMONDIR) \ - $(CPPFLAGS.master) - -POFILE = lp_filter_postscript_postdaisy.po - -.KEEP_STATE: - -all: $(TXTS) $(PROG) - -install: all $(ROOTLIBLPPOSTPROG) - -$(PROG): $(OBJS) $(COMMONOBJS) - $(LINK.c) -o $@ $(OBJS) $(COMMONOBJS) $(LDLIBS) - $(POST_PROCESS) - -$(COMMONOBJS): $$(@:%.o=%.c) - cd $(@D); $(MAKE) $(@F) - -clean: - $(RM) $(OBJS) - -strip: - $(STRIP) $(PROG) - -lint: lint_SRCS - -include ../../../../Makefile.targ - -include ../Makefile.msg diff --git a/usr/src/cmd/lp/filter/postscript/postdaisy/README b/usr/src/cmd/lp/filter/postscript/postdaisy/README deleted file mode 100644 index 138d9f039a..0000000000 --- a/usr/src/cmd/lp/filter/postscript/postdaisy/README +++ /dev/null @@ -1,26 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -Source code for a simple program that translates Diablo 630 daisy-wheel files -into PostScript. No guarantees are given with this program - quite a bit hasn't -been implemented, and what's done isn't well tested. - diff --git a/usr/src/cmd/lp/filter/postscript/postdaisy/postdaisy.c b/usr/src/cmd/lp/filter/postscript/postdaisy/postdaisy.c deleted file mode 100644 index 14697f2ac2..0000000000 --- a/usr/src/cmd/lp/filter/postscript/postdaisy/postdaisy.c +++ /dev/null @@ -1,1322 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * - * postdaisy - PostScript translator for Diablo 1640 files. - * - * A program that translates Diablo 1640 files into PostScript. Absolutely nothing - * is guaranteed. Quite a few things haven't been implemented, and what's been - * done isn't well tested. Most of the documentation used to write this program - * was taken from the 'Diablo Emulator' section of a recent Imagen manual. - * - * Some of document comments that are generated may not be right. Most of the test - * files I used produced a trailing blank page. I've put a check in formfeed() that - * won't print the last page if it doesn't contain any text, but PAGES comments may - * not be right. The DOCUMENTFONTS comment will also be wrong if auto underline or - * bold printing have been turned on by escape commands. - * - * The brute force approach used to implement horizontal and vertical tabs leaves - * much to be desired, and may not work for very small initial hmi and vmi values. - * At the very least I should have used malloc() to get space for the two tabstop - * arrays after hmi and vmi are known! - * - * Reverse printing mode hasn't been tested at all, but what's here should be - * close even though it's not efficient. - * - * The PostScript prologue is copied from *prologue before any of the input files - * are translated. The program expects that the following PostScript procedures - * are defined in that file: - * - * setup - * - * mark ... setup - - * - * Handles special initialization stuff that depends on how this program - * was called. Expects to find a mark followed by key/value pairs on the - * stack. The def operator is applied to each pair up to the mark, then - * the default state is set up. - * - * pagesetup - * - * page pagesetup - - * - * Does whatever is needed to set things up for the next page. Expects to - * find the current page number on the stack. - * - * t - * - * mark str1 x1 str2 x2 ... strn xn y hmi t mark - * - * Handles all the text on the stack. Characters in the strings are - * printed using hmi as the character advance, and all strings are at - * vertical position y. Each string is begins at the horizontal position - * that preceeds it. - * - * f - * - * font f - - * - * Use font f, where f is the full PostScript font name. Only used when - * we switch to auto underline (Courier-Italic) or bold (Courier-Bold) - * printing. - * - * done - * - * done - * - * Makes sure the last page is printed. Only needed when we're printing - * more than one page on each sheet of paper. - * - * Many default values, like the magnification and orientation, are defined in - * the prologue, which is where they belong. If they're changed (by options), an - * appropriate definition is made after the prologue is added to the output file. - * The -P option passes arbitrary PostScript through to the output file. Among - * other things it can be used to set (or change) values that can't be accessed by - * other options. - * - */ - - -#include <stdio.h> -#include <signal.h> -#include <ctype.h> -#include <fcntl.h> - -#include "comments.h" /* PostScript file structuring comments */ -#include "gen.h" /* general purpose definitions */ -#include "path.h" /* for the prologue */ -#include "ext.h" /* external variable declarations */ -#include "postdaisy.h" /* a few special definitions */ - - -char *optnames = "a:c:f:h:l:m:n:o:p:r:s:v:x:y:A:C:J:L:P:DI"; - -char *prologue = POSTDAISY; /* default PostScript prologue */ -char *formfile = FORMFILE; /* stuff for multiple pages per sheet */ - -int formsperpage = 1; /* page images on each piece of paper */ -int copies = 1; /* and this many copies of each sheet */ - -char htabstops[COLUMNS]; /* horizontal */ -char vtabstops[ROWS]; /* and vertical tabs */ - -int res = RES; /* input file resolution - sort of */ - -int hmi = HMI; /* horizontal motion index - 1/120 inch */ -int vmi = VMI; /* vertical motion index - 1/48 inch */ -int ohmi = HMI; /* original hmi */ -int ovmi = VMI; /* and vmi - for tabs and char size */ - -int hpos = 0; /* current horizontal */ -int vpos = 0; /* and vertical position */ - -int lastx = -1; /* printer's last horizontal */ -int lasty = -1; /* and vertical position */ -int lasthmi = -1; /* hmi for current text strings */ - -int lastc = -1; /* last printed character */ -int prevx = -1; /* at this position */ - -int leftmargin = LEFTMARGIN; /* page margins */ -int rightmargin = RIGHTMARGIN; -int topmargin = TOPMARGIN; -int bottommargin = BOTTOMMARGIN; - -int stringcount = 0; /* number of strings on the stack */ -int stringstart = 1; /* column where current one starts */ -int advance = 1; /* -1 if in backward print mode */ - -int lfiscr = OFF; /* line feed implies carriage return */ -int crislf = OFF; /* carriage return implies line feed */ - -int linespp = 0; /* lines per page if it's positive */ -int markedpage = FALSE; /* helps prevent trailing blank page */ -int page = 0; /* page we're working on */ -int printed = 0; /* printed this many pages */ - -Fontmap fontmap[] = FONTMAP; /* for translating font names */ -char *fontname = "Courier"; /* use this PostScript font */ -int shadowprint = OFF; /* automatic bold printing if ON */ - -FILE *fp_in; /* read from this file */ -FILE *fp_out = stdout; /* and write stuff here */ -FILE *fp_acct = NULL; /* for accounting data */ - -static void account(void); -static void arguments(void); -static void backspace(void); -static void carriage(void); -static void changefont(char *); -static void cleartabs(void); -static void endline(void); -static void endstring(void); -static void escape(void); -static void done(void); -static void formfeed(void); -static void header(void); -static void hgoto(int); -static void hmot(int); -static void htab(void); -static void inittabs(void); -static void init_signals(void); -static void linefeed(void); -static void options(void); -static void oput(int); -static void redirect(int); -static void setup(void); -static void startline(void); -static void text(void); -static void vgoto(int); -static void vmot(int); -static void vtab(void); - -/*****************************************************************************/ - -int -main(int agc, char *agv[]) -{ - -/* - * - * A simple program that translates Diablo 1640 files into PostScript. Nothing is - * guaranteed - the program not well tested and doesn't implement everything. - * - */ - - - argc = agc; /* other routines may want them */ - argv = agv; - - prog_name = argv[0]; /* really just for error messages */ - - init_signals(); /* sets up interrupt handling */ - header(); /* PostScript header comments */ - options(); /* handle the command line options */ - setup(); /* for PostScript */ - arguments(); /* followed by each input file */ - done(); /* print the last page etc. */ - account(); /* job accounting data */ - - return (x_stat); /* not much could be wrong */ - -} /* End of main */ - - -/*****************************************************************************/ - -static void -init_signals(void) -{ - void interrupt(); /* signal handler */ - -/* - * - * Makes sure we handle interrupts. - * - */ - - - if ( signal(SIGINT, interrupt) == SIG_IGN ) { - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - signal(SIGHUP, SIG_IGN); - } else { - signal(SIGHUP, interrupt); - signal(SIGQUIT, interrupt); - } /* End else */ - - signal(SIGTERM, interrupt); - -} /* End of init_signals */ - - -/*****************************************************************************/ - -static void -header(void) -{ - int ch; /* return value from getopt() */ - int old_optind = optind; /* for restoring optind - should be 1 */ - -/* - * - * Scans the option list looking for things, like the prologue file, that we need - * right away but could be changed from the default. Doing things this way is an - * attempt to conform to Adobe's latest file structuring conventions. In particular - * they now say there should be nothing executed in the prologue, and they have - * added two new comments that delimit global initialization calls. Once we know - * where things really are we write out the job header, follow it by the prologue, - * and then add the ENDPROLOG and BEGINSETUP comments. - * - */ - - - while ( (ch = getopt(argc, argv, optnames)) != EOF ) - if ( ch == 'L' ) - prologue = optarg; - else if ( ch == '?' ) - error(FATAL, ""); - - optind = old_optind; /* get ready for option scanning */ - - fprintf(stdout, "%s", CONFORMING); - fprintf(stdout, "%s %s\n", VERSION, PROGRAMVERSION); - fprintf(stdout, "%s %s\n", DOCUMENTFONTS, ATEND); - fprintf(stdout, "%s %s\n", PAGES, ATEND); - fprintf(stdout, "%s", ENDCOMMENTS); - - if ( cat(prologue) == FALSE ) - error(FATAL, "can't read %s", prologue); - - fprintf(stdout, "%s", ENDPROLOG); - fprintf(stdout, "%s", BEGINSETUP); - fprintf(stdout, "mark\n"); - -} /* End of header */ - - -/*****************************************************************************/ - -static void -options(void) -{ - int ch; /* return value from getopt() */ - int n; /* for CR and LF modes */ - -/* - * - * Reads and processes the command line options. Added the -P option so arbitrary - * PostScript code can be passed through. Expect it could be useful for changing - * definitions in the prologue for which options have not been defined. - * - * Although any PostScript font can be used, things will only work for constant - * width fonts. - * - */ - - - while ( (ch = getopt(argc, argv, optnames)) != EOF ) { - - switch ( ch ) { - - case 'a': /* aspect ratio */ - fprintf(stdout, "/aspectratio %s def\n", optarg); - break; - - case 'c': /* copies */ - copies = atoi(optarg); - fprintf(stdout, "/#copies %s store\n", optarg); - break; - - case 'f': /* use this PostScript font */ - fontname = get_font(optarg); - fprintf(stdout, "/font /%s def\n", fontname); - break; - - case 'h': /* default character spacing */ - ohmi = hmi = atoi(optarg) * HSCALE; - fprintf(stdout, "/hmi %s def\n", optarg); - break; - - case 'l': /* lines per page */ - linespp = atoi(optarg); - break; - - case 'm': /* magnification */ - fprintf(stdout, "/magnification %s def\n", optarg); - break; - - case 'n': /* forms per page */ - formsperpage = atoi(optarg); - fprintf(stdout, "%s %s\n", FORMSPERPAGE, optarg); - fprintf(stdout, "/formsperpage %s def\n", optarg); - break; - - case 'o': /* output page list */ - out_list(optarg); - break; - - case 'p': /* landscape or portrait mode */ - if ( *optarg == 'l' ) - fprintf(stdout, "/landscape true def\n"); - else fprintf(stdout, "/landscape false def\n"); - break; - - case 'r': /* set CR and LF modes */ - n = atoi(optarg); - if ( n & 01 ) - lfiscr = ON; - else lfiscr = OFF; - if ( n & 02 ) - crislf = ON; - else crislf = OFF; - break; - - case 's': /* point size */ - fprintf(stdout, "/pointsize %s def\n", optarg); - break; - - case 'v': /* default line spacing */ - ovmi = vmi = atoi(optarg) * VSCALE; - break; - - case 'x': /* shift things horizontally */ - fprintf(stdout, "/xoffset %s def\n", optarg); - break; - - case 'y': /* and vertically on the page */ - fprintf(stdout, "/yoffset %s def\n", optarg); - break; - - case 'A': /* force job accounting */ - case 'J': - if ( (fp_acct = fopen(optarg, "a")) == NULL ) - error(FATAL, "can't open accounting file %s", optarg); - break; - - case 'C': /* copy file straight to output */ - if ( cat(optarg) == FALSE ) - error(FATAL, "can't read %s", optarg); - break; - - case 'L': /* PostScript prologue file */ - prologue = optarg; - break; - - case 'P': /* PostScript pass through */ - fprintf(stdout, "%s\n", optarg); - break; - - case 'R': /* special global or page level request */ - saverequest(optarg); - break; - - case 'D': /* debug flag */ - debug = ON; - break; - - case 'I': /* ignore FATAL errors */ - ignore = ON; - break; - - case '?': /* don't understand the option */ - error(FATAL, ""); - break; - - default: /* don't know what to do for ch */ - error(FATAL, "missing case for option %c\n", ch); - break; - - } /* End switch */ - - } /* End while */ - - argc -= optind; /* get ready for non-option args */ - argv += optind; - -} /* End of options */ - - -/*****************************************************************************/ - - -char * -get_font(char *name) - /* name the user asked for */ -{ - int i; /* for looking through fontmap[] */ - -/* - * - * Called from options() to map a user's font name into a legal PostScript name. - * If the lookup fails *name is returned to the caller. That should let you choose - * any PostScript font, although things will only work well for constant width - * fonts. - * - */ - - - for ( i = 0; fontmap[i].name != NULL; i++ ) - if ( strcmp(name, fontmap[i].name) == 0 ) - return(fontmap[i].val); - - return(name); - -} /* End of get_font */ - - -/*****************************************************************************/ - -static void -setup(void) -{ - -/* - * - * Handles things that must be done after the options are read but before the - * input files are processed. - * - */ - - - writerequest(0, stdout); /* global requests eg. manual feed */ - fprintf(stdout, "setup\n"); - - if ( formsperpage > 1 ) { - if ( cat(formfile) == FALSE ) - error(FATAL, "can't read %s", formfile); - fprintf(stdout, "%d setupforms\n", formsperpage); - } /* End if */ - - fprintf(stdout, "%s", ENDSETUP); - -} /* End of setup */ - - -/*****************************************************************************/ - -static void -arguments(void) -{ - -/* - * - * Makes sure all the non-option command line arguments are processed. If we get - * here and there aren't any arguments left, or if '-' is one of the input files - * we'll process stdin. - * - */ - - - fp_in = stdin; - - if ( argc < 1 ) - text(); - else { /* at least one argument is left */ - while ( argc > 0 ) { - if ( strcmp(*argv, "-") == 0 ) - fp_in = stdin; - else if ( (fp_in = fopen(*argv, "r")) == NULL ) - error(FATAL, "can't open %s", *argv); - text(); - if ( fp_in != stdin ) - fclose(fp_in); - argc--; - argv++; - } /* End while */ - } /* End else */ - -} /* End of arguments */ - - -/*****************************************************************************/ - -static void -done(void) -{ - -/* - * - * Finished with all the input files, so mark the end of the pages, make sure the - * last page is printed, and restore the initial environment. - * - */ - - - fprintf(stdout, "%s", TRAILER); - fprintf(stdout, "done\n"); - fprintf(stdout, "%s %s\n", DOCUMENTFONTS, fontname); - fprintf(stdout, "%s %d\n", PAGES, printed); - -} /* End of done */ - - -/*****************************************************************************/ - -static void -account(void) -{ - -/* - * - * Writes an accounting record to *fp_acct provided it's not NULL. Accounting - * is requested using the -A or -J options. - * - */ - - - if ( fp_acct != NULL ) - fprintf(fp_acct, " print %d\n copies %d\n", printed, copies); - -} /* End of account */ - - -/*****************************************************************************/ - -static void -text(void) -{ - int ch; /* next input character */ - -/* - * - * Translates the next input file into PostScript. The redirect(-1) call forces - * the initial output to go to /dev/null - so the stuff formfeed() does at the - * end of each page doesn't go to stdout. - * - */ - - - redirect(-1); /* get ready for the first page */ - formfeed(); /* force PAGE comment etc. */ - inittabs(); - - while ( (ch = getc(fp_in)) != EOF ) - - switch ( ch ) { - - case '\010': /* backspace */ - backspace(); - break; - - case '\011': /* horizontal tab */ - htab(); - break; - - case '\012': /* new line */ - linefeed(); - break; - - case '\013': /* vertical tab */ - vtab(); - break; - - case '\014': /* form feed */ - formfeed(); - break; - - case '\015': /* carriage return */ - carriage(); - break; - - case '\016': /* extended character set - SO */ - break; - - case '\017': /* extended character set - SI */ - break; - - case '\031': /* next char from supplementary set */ - break; - - case '\033': /* 2 or 3 byte escape sequence */ - escape(); - break; - - default: - if ( isascii(ch) && isprint(ch) ) - oput(ch); - break; - - } /* End switch */ - - formfeed(); /* next file starts on a new page? */ - -} /* End of text */ - - -/*****************************************************************************/ - -static void -inittabs(void) -{ - int i; /* loop index */ - -/* - * - * Initializes the horizontal and vertical tab arrays. The way tabs are handled is - * quite inefficient and may not work for all initial hmi or vmi values. - * - */ - - - for ( i = 0; i < ROWS; i++ ) - htabstops[i] = ((i % 8) == 0) ? ON : OFF; - - for ( i = 0; i < COLUMNS; i++ ) - vtabstops[i] = ((i * ovmi) > BOTTOMMARGIN) ? ON : OFF; - -} /* End of inittabs */ - - -/*****************************************************************************/ - -static void -cleartabs(void) -{ - int i; /* loop index */ - -/* - * - * Clears all horizontal and vertical tab stops. - * - */ - - - for ( i = 0; i < ROWS; i++ ) - htabstops[i] = OFF; - - for ( i = 0; i < COLUMNS; i++ ) - vtabstops[i] = OFF; - -} /* End of cleartabs */ - - -/*****************************************************************************/ - -static void -formfeed(void) -{ - -/* - * - * Called whenever we've finished with the last page and want to get ready for the - * next one. Also used at the beginning and end of each input file, so we have to - * be careful about what's done. I've added a simple test before the showpage that - * should eliminate the extra blank page that was put out at the end of many jobs, - * but the PAGES comments may be wrong. - * - */ - - - if ( fp_out == stdout ) /* count the last page */ - printed++; - - endline(); /* print the last line */ - - fprintf(fp_out, "cleartomark\n"); - if ( feof(fp_in) == 0 || markedpage == TRUE ) - fprintf(fp_out, "showpage\n"); - fprintf(fp_out, "restore\n"); - fprintf(fp_out, "%s %d %d\n", ENDPAGE, page, printed); - - if ( ungetc(getc(fp_in), fp_in) == EOF ) - redirect(-1); - else redirect(++page); - - fprintf(fp_out, "%s %d %d\n", PAGE, page, printed+1); - fprintf(fp_out, "save\n"); - fprintf(fp_out, "mark\n"); - writerequest(printed+1, fp_out); - fprintf(fp_out, "%d pagesetup\n", printed+1); - - vgoto(topmargin); - hgoto(leftmargin); - - markedpage = FALSE; - -} /* End of formfeed */ - - -/*****************************************************************************/ - -static void -linefeed(void) -{ - int line = 0; /* current line - based on ovmi */ - -/* - * - * Adjust our current vertical position. If we've passed the bottom of the page - * or exceeded the number of lines per page, print it and go to the upper left - * corner of the next page. This routine is also called from carriage() if crislf - * is ON. - * - */ - - - vmot(vmi); - - if ( lfiscr == ON ) - hgoto(leftmargin); - - if ( linespp > 0 ) /* it means something so see where we are */ - line = vpos / ovmi + 1; - - if ( vpos > bottommargin || line > linespp ) - formfeed(); - -} /* End of linefeed */ - - -/*****************************************************************************/ - -static void -carriage(void) -{ - -/* - * - * Handles carriage return character. If crislf is ON we'll generate a line feed - * every time we get a carriage return character. - * - */ - - - if ( shadowprint == ON ) /* back to normal mode */ - changefont(fontname); - - advance = 1; - shadowprint = OFF; - - hgoto(leftmargin); - - if ( crislf == ON ) - linefeed(); - -} /* End of carriage */ - - -/*****************************************************************************/ - -static void -htab(void) -{ - int col; /* 'column' we'll be at next */ - int i; /* loop index */ - -/* - * - * Tries to figure out where the next tab stop is. Wasn't positive about this - * one, since hmi can change. I'll assume columns are determined by the original - * value of hmi. That fixes them on the page, which seems to make more sense than - * letting them float all over the place. - * - */ - - - endline(); - - col = hpos/ohmi + 1; - for ( i = col; i < ROWS; i++ ) - if ( htabstops[i] == ON ) { - col = i; - break; - } /* End if */ - - hgoto(col * ohmi); - lastx = hpos; - -} /* End of htab */ - - -/*****************************************************************************/ - -static void -vtab(void) -{ - - - int line; /* line we'll be at next */ - int i; /* loop index */ - - -/* - * - * Looks for the next vertical tab stop in the vtabstops[] array and moves to that - * line. If we don't find a tab we'll just move down one line - shouldn't happen. - * - */ - - - endline(); - - line = vpos/ovmi + 1; - for ( i = line; i < COLUMNS; i++ ) - if ( vtabstops[i] == ON ) { - line = i; - break; - } /* End if */ - - vgoto(line * ovmi); - -} /* End of vtab */ - - -/*****************************************************************************/ - -static void -backspace(void) -{ - -/* - * - * Moves backwards a distance equal to the current value of hmi provided we don't - * go past the left margin. - * - */ - - - endline(); - - if ( hpos - leftmargin >= hmi ) - hmot(-hmi); - else hgoto(leftmargin); /* maybe just ignore the backspace?? */ - - lastx = hpos; - -} /* End of backspace */ - - -/*****************************************************************************/ - -static void -escape(void) -{ - int ch; /* control character */ - -/* - * - * Handles special codes that are expected to follow an escape character. The - * initial escape character is followed by one or two bytes. - * - */ - - - switch ( ch = getc(fp_in) ) { - - case 'T': /* top margin */ - topmargin = vpos; - break; - - case 'L': /* bottom margin */ - bottommargin = vpos; - break; - - case 'C': /* clear top and bottom margins */ - bottommargin = BOTTOMMARGIN; - topmargin = TOPMARGIN; - break; - - case '9': /* left margin */ - leftmargin = hpos; - break; - - case '0': /* right margin */ - rightmargin = hpos; - break; - - case '1': /* set horizontal tab */ - htabstops[hpos/ohmi] = ON; - break; - - case '8': /* clear horizontal tab at hpos */ - htabstops[hpos/ohmi] = OFF; - break; - - case '-': /* set vertical tab */ - vtabstops[vpos/ovmi] = ON; - break; - - case '2': /* clear all tabs */ - cleartabs(); - break; - - case '\014': /* set lines per page */ - linespp = getc(fp_in); - break; - - case '\037': /* set hmi to next byte minus 1 */ - hmi = HSCALE * (getc(fp_in) - 1); - break; - - case 'S': /* reset hmi to default */ - hmi = ohmi; - break; - - case '\011': /* move to column given by next byte */ - hgoto((getc(fp_in)-1) * ohmi); - break; - - case '?': /* do carriage return after line feed */ - lfiscr = ON; - break; - - case '!': /* don't generate carriage return */ - lfiscr = OFF; - break; - - case '5': /* forward print mode */ - advance = 1; - break; - - case '6': /* backward print mode */ - advance = -1; - break; - - case '\036': /* set vmi to next byte minus 1 */ - vmi = VSCALE * (getc(fp_in) - 1); - break; - - case '\013': /* move to line given by next byte */ - vgoto((getc(fp_in)-1) * ovmi); - break; - - case 'U': /* positive half line feed */ - vmot(vmi/2); - break; - - case 'D': /* negative half line feed */ - vmot(-vmi/2); - break; - - case '\012': /* negative line feed */ - vmot(-vmi); - break; - - case '\015': /* clear all margins */ - bottommargin = BOTTOMMARGIN; - topmargin = TOPMARGIN; - leftmargin = BOTTOMMARGIN; - rightmargin = RIGHTMARGIN; - break; - - case 'E': /* auto underscore - use italic font */ - changefont("/Courier-Oblique"); - break; - - case 'R': /* disable auto underscore */ - changefont(fontname); - break; - - case 'O': /* bold/shadow printing */ - case 'W': - changefont("/Courier-Bold"); - shadowprint = ON; - break; - - case '&': /* disable bold printing */ - changefont(fontname); - shadowprint = OFF; - break; - - case '/': /* ignored 2 byte escapes */ - case '\\': - case '<': - case '>': - case '%': - case '=': - case '.': - case '4': - case 'A': - case 'B': - case 'M': - case 'N': - case 'P': - case 'Q': - case 'X': - case '\010': - break; - - case ',': /* ignored 3 byte escapes */ - case '\016': - case '\021': - getc(fp_in); - break; - - case '3': /* graphics mode - should quit! */ - case '7': - case 'G': - case 'V': - case 'Y': - case 'Z': - error(FATAL, "graphics mode is not implemented"); - break; - - default: - error(FATAL, "missing case for escape o%o\n", ch); - break; - - } /* End switch */ - -} /* End of escape */ - - -/*****************************************************************************/ - -static void -vmot(int n) - /* move this far vertically */ -{ - -/* - * - * Move vertically n units from where we are. - * - */ - - - vpos += n; - -} /* End of vmot */ - - -/*****************************************************************************/ - -static void -vgoto(int n) - /* new vertical position */ -{ - -/* - * - * Moves to absolute vertical position n. - * - */ - - - vpos = n; - -} /* End of vgoto */ - - -/*****************************************************************************/ - -static void -hmot(int n) - /* move this horizontally */ -{ - -/* - * - * Moves horizontally n units from our current position. - * - */ - - - hpos += n * advance; - - if ( hpos < leftmargin ) - hpos = leftmargin; - -} /* End of hmot */ - - -/*****************************************************************************/ - -static void -hgoto(int n) - /* go to this horizontal position */ -{ - -/* - * - * Moves to absolute horizontal position n. - * - */ - - - hpos = n; - -} /* End of hgoto */ - - -/*****************************************************************************/ - -static void -changefont(char *name) -{ - -/* - * - * Changes the current font. Used to get in and out of auto underscore and bold - * printing. - * - */ - - - endline(); - fprintf(fp_out, "%s f\n", name); - -} /* End of changefont */ - - -/*****************************************************************************/ - -static void -startline(void) -{ - -/* - * - * Called whenever we want to be certain we're ready to start pushing characters - * into an open string on the stack. If stringcount is positive we've already - * started, so there's nothing to do. The first string starts in column 1. - * - */ - - - if ( stringcount < 1 ) { - putc('(', fp_out); - stringstart = lastx = hpos; - lasty = vpos; - lasthmi = hmi; - lastc = -1; - prevx = -1; - stringcount = 1; - } /* End if */ - -} /* End of startline */ - - -/*****************************************************************************/ - -static void -endline(void) -{ - -/* - * - * Generates a call to the PostScript procedure that processes the text on the - * the stack - provided stringcount is positive. - * - */ - - - if ( stringcount > 0 ) - fprintf(fp_out, ")%d %d %d t\n", stringstart, lasty, lasthmi); - - stringcount = 0; - -} /* End of endline */ - - -/*****************************************************************************/ - -static void -endstring(void) -{ - -/* - * - * Takes the string we've been working on and adds it to the output file. Called - * when we need to adjust our horizontal position before starting a new string. - * Also called from endline() when we're done with the current line. - * - */ - - - if ( stringcount > 0 ) { - fprintf(fp_out, ")%d(", stringstart); - lastx = stringstart = hpos; - stringcount++; - } /* End if */ - -} /* End of endstring */ - - -/*****************************************************************************/ - -static void -oput(int ch) - /* next output character */ -{ - -/* - * - * Responsible for adding all printing characters from the input file to the - * open string on top of the stack. The only other characters that end up in - * that string are the quotes required for special characters. Reverse printing - * mode hasn't been tested but it should be close. hpos and lastx should disagree - * each time (except after startline() does something), and that should force a - * call to endstring() for every character. - * - */ - - - if ( stringcount > 100 ) /* don't put too much on the stack */ - endline(); - - if ( vpos != lasty ) - endline(); - - if ( advance == -1 ) /* for reverse printing - move first */ - hmot(hmi); - - startline(); - - if ( lastc != ch || hpos != prevx ) { - if ( lastx != hpos ) - endstring(); - - if ( ch == '\\' || ch == '(' || ch == ')' ) - putc('\\', fp_out); - putc(ch, fp_out); - - lastc = ch; - prevx = hpos; - lastx += lasthmi; - } /* End if */ - - if ( advance != -1 ) - hmot(hmi); - - markedpage = TRUE; - -} /* End of oput */ - - -/*****************************************************************************/ - -static void -redirect(int pg) - /* next page we're printing */ -{ - static FILE *fp_null = NULL; /* if output is turned off */ - -/* - * - * If we're not supposed to print page pg, fp_out will be directed to /dev/null, - * otherwise output goes to stdout. - * - */ - - - if ( pg >= 0 && in_olist(pg) == ON ) - fp_out = stdout; - else if ( (fp_out = fp_null) == NULL ) - fp_out = fp_null = fopen("/dev/null", "w"); - -} /* End of redirect */ - - -/*****************************************************************************/ - diff --git a/usr/src/cmd/lp/filter/postscript/postdaisy/postdaisy.h b/usr/src/cmd/lp/filter/postscript/postdaisy/postdaisy.h deleted file mode 100644 index 068e1a3a48..0000000000 --- a/usr/src/cmd/lp/filter/postscript/postdaisy/postdaisy.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ - -/* - * - * Definitions used by the PostScript translator for Diablo 1640 files. - * - * Diablo printers have horizontal and vertical resolutions of 120 and 48 dpi. - * We'll use a single resolution of 240 dpi and let the program scale horizontal - * and vertical positions by HSCALE and VSCALE. - * - */ - -#define RES 240 -#define HSCALE 2 -#define VSCALE 5 - -/* - * - * HMI is the default character spacing and VMI is the line spacing. Both values - * are in terms of the 240 dpi resolution. - * - */ - -#define HMI (12 * HSCALE) -#define VMI (8 * VSCALE) - -/* - * - * Paper dimensions don't seem to be all that important. They're just used to - * set the right and bottom margins. Both are given in terms of the 240 dpi - * resolution. - * - */ - -#define LEFTMARGIN 0 -#define RIGHTMARGIN 3168 -#define TOPMARGIN 0 -#define BOTTOMMARGIN 2640 - -/* - * - * ROWS and COLUMNS set the dimensions of the horizontal and vertical tab arrays. - * The way I've implemented both kinds of tabs leaves something to be desired, but - * it was simple and should be good enough for now. If arrays are going to be used - * to mark tab stops I probably should use malloc() to get enough space once the - * initial hmi and vmi are know. - * - */ - -#define ROWS 400 -#define COLUMNS 200 - -/* - * - * An array of type Fontmap helps convert font names requested by users into - * legitimate PostScript names. The array is initialized using FONTMAP, which must - * end with an entry that has NULL defined as its name field. - * - */ - -typedef struct { - - char *name; /* user's font name */ - char *val; /* corresponding PostScript name */ - -} Fontmap; - -#define FONTMAP \ - \ - { \ - "R", "Courier", \ - "I", "Courier-Oblique", \ - "B", "Courier-Bold", \ - "CO", "Courier", \ - "CI", "Courier-Oblique", \ - "CB", "Courier-Bold", \ - "CW", "Courier", \ - "PO", "Courier", \ - "courier", "Courier", \ - "cour", "Courier", \ - "co", "Courier", \ - NULL, NULL \ - } - -/* - * - * Some of the non-integer functions in postdaisy.c. - * - */ - -char *get_font(); - diff --git a/usr/src/cmd/lp/filter/postscript/postdmd/Makefile b/usr/src/cmd/lp/filter/postscript/postdmd/Makefile deleted file mode 100644 index 73feac6c6e..0000000000 --- a/usr/src/cmd/lp/filter/postscript/postdmd/Makefile +++ /dev/null @@ -1,77 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# ident "%Z%%M% %I% %E% SMI" -# -# Copyright 1989-2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/lp/filter/postscript/postdmd/Makefile -# - -include ../../../Makefile.lp - -PROG= postdmd - -SRCS= postdmd.c - -OBJS = $(SRCS:%.c=%.o) - -COMMONDIR = ../common - -COMMONOBJS = $(COMMONDIR)/request.o \ - $(COMMONDIR)/glob.o \ - $(COMMONDIR)/misc.o - -TXTS= README - -ENCODING = 2 -CPPFLAGS = -DDFLTENCODING=$(ENCODING) \ - -I. -I$(COMMONDIR) \ - $(CPPFLAGS.master) - -POFILE = lp_filter_postscript_postdmd.po - -.KEEP_STATE: - -all: $(TXTS) $(PROG) - -install: all $(ROOTLIBLPPOSTPROG) - -$(PROG): $(OBJS) $(COMMONOBJS) - $(LINK.c) -o $@ $(OBJS) $(COMMONOBJS) $(LDLIBS) - $(POST_PROCESS) - -$(COMMONOBJS): $$(@:%.o=%.c) - cd $(@D); $(MAKE) $(@F) - -clean: - $(RM) $(OBJS) - -strip: - $(STRIP) $(PROG) - -lint: lint_SRCS - -include ../../../../Makefile.targ - -include ../Makefile.msg diff --git a/usr/src/cmd/lp/filter/postscript/postdmd/README b/usr/src/cmd/lp/filter/postscript/postdmd/README deleted file mode 100644 index fab5758f22..0000000000 --- a/usr/src/cmd/lp/filter/postscript/postdmd/README +++ /dev/null @@ -1,53 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -Source code for a program that translates DMD bitmaps (as produced by dmdps) or -files written in the Ninth Edition bitfile(9.5) format into PostScript. Much of -the code came from abm, which was written by Guy Riddle. - -By default 6 byte patterns are used, but any number can be selected with the -b -option. 6 byte patterns are a tradeoff that achieves a good (but not necessarily -optimal) performance across the wide variety of currently available PostScript -printers. Decreasing the pattern size often helps some on printers with fast -processors (eg. PS-810s) while increasing the pattern size speeds things up on -older printers (eg. PS-800s). In the limited number of tests I ran -b10 worked -best on PS800s and -b4 gave the best performance on PS-810s. If you want a -different default pattern size change the initialization of bytespp (near line -117 in postdmd.c) before you compile the program. - -Bitmaps are unpacked, a scanline at a time, and re-encoded in a format that looks -like, - - bytes patterns count - -where bytes and count are decimal integers and patterns is a series of hex digits. -Bytes is the number of bytes represented by the hex pattern, while count is the -number of additional times the pattern should be repeated. For example, - - 2 FFFF 4 - 5 FFFFFFFFFF 1 - 10 FFFFFFFFFFFFFFFFFFFF 0 - -all represent 10 consecutive bytes of ones. Scanlines are terminated by a 0 on -a line by itself. The new encoding wastes some space, but is relatively easy to -unpack when the bitmap finally gets to the printer. - diff --git a/usr/src/cmd/lp/filter/postscript/postdmd/postdmd.c b/usr/src/cmd/lp/filter/postscript/postdmd/postdmd.c deleted file mode 100644 index 70bd95ab4b..0000000000 --- a/usr/src/cmd/lp/filter/postscript/postdmd/postdmd.c +++ /dev/null @@ -1,784 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * - * postdmd - PostScript translator for DMD bitmap files. - * - * A simple program that can be used to print DMD bitmaps on PostScript printers. - * Much of the code was borrowed from abm, which was written by Guy Riddle. - * - * Although the program supports two different input bitmap formats, by far the - * most important is the Eighth (and Ninth) Edition bitfile format. A bitmap in - * the bitfile format begins with a 10 byte header with the first two bytes set to - * zero. The next 8 bytes set the x and y coordinates of the bitmap's origin and - * corner (ie. the upper left and lower right corners). The compressed raster data - * follows the header and consists of control bytes followed an appropriate number - * of data bytes. Control bytes (ie. n) less than 127 means read the next 2*n bytes - * of raster data directly from the input file, while if n is larger than 128 we - * read two bytes from the input file and replicate the bytes n-128 times. After - * each scan line is recovered it's exclusive-or'd with the preceeding line to - * generate the real raster data. - * - * After each raster line is recovered postdmd encodes it in a slightly different - * format that's designed to be unpacked by a PostScript procedure that's defined - * in the prologue. By default no exclusive-or'ing is done and packing of pattern - * data can be based on any number of bytes rather than just the next two bytes. - * By default 6 byte patterns are used, but any number can be selected with the -b - * option. A non-positive argument (eg. -b0) disables all pattern encoding. Larger - * patterns increase the size of the output file, but reduce the work load that's - * forced on the PostScript interpreter. The default choices I've made (ie. 6 byte - * patterns and no exclusive-or'ing) do a decent balancing job across currently - * available PostScript printers. Larger patterns (eg. -b16) increase the output - * file size, but may be appropriate if you're running at a high baud rate (eg. - * 19.2KB), while smaller patter size (eg. -b4) may help if you've got a printer - * with a fast processor (eg. a PS-810). - * - * The encoding produced by the program (and decoded on the printer) looks like, - * - * bytes patterns count - * - * where bytes and count are decimal integers and patterns is a hex string. Bytes - * is the number of bytes represented by the hex patterns and count is the number - * of additional times the patterns should be repeated. For example, - * - * 2 FFFF 4 - * 5 FFFFFFFFFF 1 - * 10 FFFFFFFFFFFFFFFFFFFF 0 - * - * all represent 10 consecutive bytes of ones. Scanlines are terminated by a 0 on - * a line by itself. - * - * The PostScript prologue is copied from *prologue before any of the input files - * are translated. The program expects that the following PostScript procedures - * are defined in that file: - * - * setup - * - * mark ... setup - - * - * Handles special initialization stuff that depends on how this program - * was called. Expects to find a mark followed by key/value pairs on the - * stack. The def operator is applied to each pair up to the mark, then - * the default state is set up. - * - * pagesetup - * - * page pagesetup - - * - * Does whatever is needed to set things up for the next page. Expects - * to find the current page number on the stack. - * - * bitmap - * - * v8format flip scanlength scanlines bitmap - - * - * Prints the bitmap that's read from standard input. The bitmap consists - * of scanlines lines, each of which includes scanlength pixels. If - * v8format is true the picture is assumed to be an Eighth Edition bitmap, - * and the exclusive-or'ing will be done on the printer. - * - * done - * - * done - * - * Makes sure the last page is printed. Only needed when we're printing - * more than one page on each sheet of paper. - * - * Many default values, like the magnification and orientation, are defined in - * the prologue, which is where they belong. If they're changed (by options), an - * appropriate definition is made after the prologue is added to the output file. - * The -P option passes arbitrary PostScript through to the output file. Among - * other things it can be used to set (or change) values that can't be accessed by - * other options. - * - */ - - -#include <stdio.h> -#include <signal.h> -#include <ctype.h> -#include <fcntl.h> - -#include "comments.h" /* PostScript file structuring comments */ -#include "gen.h" /* general purpose definitions */ -#include "path.h" /* for the prologue */ -#include "ext.h" /* external variable declarations */ - - -char *optnames = "a:b:c:fm:n:o:p:ux:y:A:C:J:L:P:DI"; - -char *prologue = POSTDMD; /* default PostScript prologue */ -char *formfile = FORMFILE; /* stuff for multiple pages per sheet */ - -int bbox[2] = {0, 0}; /* upper right coordinates only */ - -int formsperpage = 1; /* page images on each piece of paper */ -int copies = 1; /* and this many copies of each sheet */ - -int bytespp = 6; /* bytes per pattern - on output */ -int flip = FALSE; /* ones complement the bitmap */ -int v8undo = TRUE; /* xor'ing done on host if TRUE */ -int v8format = FALSE; /* for Eighth Edition bitmaps */ - -int page = 0; /* last page we worked on */ -int printed = 0; /* and the number of pages printed */ - -int patterns; /* 16 bit patterns per scan line */ -int scanlines; /* lines in the bitmap */ -int patcount = 0; /* should be patterns * scanlines */ - -char *raster = NULL; /* next raster line */ -char *prevrast = NULL; /* and the previous one - v8format */ -char *rptr; /* next free byte in raster */ -char *eptr; /* one past the last byte in raster */ - -FILE *fp_in = NULL; /* read from this file */ -FILE *fp_out = stdout; /* and write stuff here */ -FILE *fp_acct = NULL; /* for accounting data */ - -static void account(void); -static void addrast(int); -static void arguments(void); -static void bitmap(FILE *); -static int dimensions(void); -static void done(void); -static int getint(void); -static void header(void); -static void init_signals(void); -static void options(void); -static int patncmp(char *, int); -static void putrast(void); -static void redirect(int); -static void setup(void); - -/*****************************************************************************/ - -int -main(int agc, char *agv[]) -{ - -/* - * - * A simple program that translates DMD bitmap files into PostScript. There can - * be more than one bitmap per file, but none can be split across input files. - * Each bitmap goes on a page by itself. - * - */ - - - argc = agc; /* other routines may want them */ - argv = agv; - - prog_name = argv[0]; /* really just for error messages */ - - init_signals(); /* sets up interrupt handling */ - header(); /* PostScript header comments */ - options(); /* handle the command line options */ - setup(); /* for PostScript */ - arguments(); /* followed by each input file */ - done(); /* print the last page etc. */ - account(); /* job accounting data */ - - return (x_stat); /* not much could be wrong */ - -} /* End of main */ - - -/*****************************************************************************/ - -static void -init_signals(void) -{ - void interrupt(); /* signal handler */ - -/* - * - * Make sure we handle interrupts. - * - */ - - - if ( signal(SIGINT, interrupt) == SIG_IGN ) { - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - signal(SIGHUP, SIG_IGN); - } else { - signal(SIGHUP, interrupt); - signal(SIGQUIT, interrupt); - } /* End else */ - - signal(SIGTERM, interrupt); - -} /* End of init_signals */ - - -/*****************************************************************************/ - -static void -header(void) -{ - int ch; /* return value from getopt() */ - int old_optind = optind; /* for restoring optind - should be 1 */ - -/* - * - * Scans the option list looking for things, like the prologue file, that we need - * right away but could be changed from the default. Doing things this way is an - * attempt to conform to Adobe's latest file structuring conventions. In particular - * they now say there should be nothing executed in the prologue, and they have - * added two new comments that delimit global initialization calls. Once we know - * where things really are we write out the job header, follow it by the prologue, - * and then add the ENDPROLOG and BEGINSETUP comments. - * - */ - - - while ( (ch = getopt(argc, argv, optnames)) != EOF ) - if ( ch == 'L' ) - prologue = optarg; - else if ( ch == '?' ) - error(FATAL, ""); - - optind = old_optind; /* get ready for option scanning */ - - fprintf(stdout, "%s", CONFORMING); - fprintf(stdout, "%s %s\n", VERSION, PROGRAMVERSION); - fprintf(stdout, "%s %s\n", DOCUMENTFONTS, ATEND); - fprintf(stdout, "%s %s\n", PAGES, ATEND); - fprintf(stdout, "%s", ENDCOMMENTS); - - if ( cat(prologue) == FALSE ) - error(FATAL, "can't read %s", prologue); - - fprintf(stdout, "%s", ENDPROLOG); - fprintf(stdout, "%s", BEGINSETUP); - fprintf(stdout, "mark\n"); - -} /* End of header */ - - -/*****************************************************************************/ - -static void -options(void) -{ - int ch; /* return value from getopt() */ - -/* - * - * Reads and processes the command line options. Added the -P option so arbitrary - * PostScript code can be passed through. Expect it could be useful for changing - * definitions in the prologue for which options have not been defined. - * - */ - - - while ( (ch = getopt(argc, argv, optnames)) != EOF ) { - - switch ( ch ) { - - case 'a': /* aspect ratio */ - fprintf(stdout, "/aspectratio %s def\n", optarg); - break; - - case 'b': /* bytes per pattern */ - bytespp = atoi(optarg); - break; - - case 'c': /* copies */ - copies = atoi(optarg); - fprintf(stdout, "/#copies %s store\n", optarg); - break; - - case 'f': /* ones complement - sort of */ - flip = TRUE; - break; - - case 'm': /* magnification */ - fprintf(stdout, "/magnification %s def\n", optarg); - break; - - case 'n': /* forms per page */ - formsperpage = atoi(optarg); - fprintf(stdout, "%s %s\n", FORMSPERPAGE, optarg); - fprintf(stdout, "/formsperpage %s def\n", optarg); - break; - - case 'o': /* output page list */ - out_list(optarg); - break; - - case 'p': /* landscape or portrait mode */ - if ( *optarg == 'l' ) - fprintf(stdout, "/landscape true def\n"); - else fprintf(stdout, "/landscape false def\n"); - break; - - case 'u': /* don't undo Eighth Edition bitmaps */ - v8undo = FALSE; - break; - - case 'x': /* shift things horizontally */ - fprintf(stdout, "/xoffset %s def\n", optarg); - break; - - case 'y': /* and vertically on the page */ - fprintf(stdout, "/yoffset %s def\n", optarg); - break; - - case 'A': /* force job accounting */ - case 'J': - if ( (fp_acct = fopen(optarg, "a")) == NULL ) - error(FATAL, "can't open accounting file %s", optarg); - break; - - case 'C': /* copy file straight to output */ - if ( cat(optarg) == FALSE ) - error(FATAL, "can't read %s", optarg); - break; - - case 'L': /* PostScript prologue file */ - prologue = optarg; - break; - - case 'P': /* PostScript pass through */ - fprintf(stdout, "%s\n", optarg); - break; - - case 'R': /* special global or page level request */ - saverequest(optarg); - break; - - case 'D': /* debug flag */ - debug = ON; - break; - - case 'I': /* ignore FATAL errors */ - ignore = ON; - break; - - case '?': /* don't understand the option */ - error(FATAL, ""); - break; - - default: /* don't know what to do for ch */ - error(FATAL, "missing case for option %c\n", ch); - break; - - } /* End switch */ - - } /* End while */ - - argc -= optind; /* get ready for non-option args */ - argv += optind; - -} /* End of options */ - - -/*****************************************************************************/ - -static void -setup(void) -{ - - -/* - * - * Handles things that must be done after the options are read but before the - * input files are processed. - * - */ - - - writerequest(0, stdout); /* global requests eg. manual feed */ - fprintf(stdout, "setup\n"); - - if ( formsperpage > 1 ) { /* followed by stuff for multiple pages */ - if ( cat(formfile) == FALSE ) - error(FATAL, "can't read %s", formfile); - fprintf(stdout, "%d setupforms\n", formsperpage); - } /* End if */ - - fprintf(stdout, "%s", ENDSETUP); - -} /* End of setup */ - - -/*****************************************************************************/ - - -static void -arguments(void) -{ - FILE *fp; /* next input file */ - -/* - * - * Makes sure all the non-option command line arguments are processed. If we get - * here and there aren't any arguments left, or if '-' is one of the input files - * we'll process stdin. - * - */ - - - if ( argc < 1 ) - bitmap(stdin); - else { /* at least one argument is left */ - while ( argc > 0 ) { - if ( strcmp(*argv, "-") == 0 ) - fp = stdin; - else if ( (fp = fopen(*argv, "r")) == NULL ) - error(FATAL, "can't open %s", *argv); - bitmap(fp); - if ( fp != stdin ) - fclose(fp); - argc--; - argv++; - } /* End while */ - } /* End else */ - -} /* End of arguments */ - - -/*****************************************************************************/ - -static void -done(void) -{ - -/* - * - * Finished with all the input files, so mark the end of the pages with a TRAILER - * comment, make sure the last page prints, and add things like the PAGES comment - * that can only be determined after all the input files have been read. - * - */ - - - fprintf(stdout, "%s", TRAILER); - fprintf(stdout, "done\n"); - fprintf(stdout, "%s 0 0 %d %d\n", BOUNDINGBOX, (bbox[0]*72+100)/100, (bbox[1]*72+100)/100); - fprintf(stdout, "%s %d\n", PAGES, printed); - -} /* End of done */ - - -/*****************************************************************************/ - -static void -account(void) -{ - -/* - * - * Writes an accounting record to *fp_acct provided it's not NULL. Accounting is - * requested using the -A or -J options. - * - */ - - - if ( fp_acct != NULL ) - fprintf(fp_acct, " print %d\n copies %d\n", printed, copies); - -} /* End of account */ - - -/*****************************************************************************/ - -static void -bitmap(FILE *fp) - /* next input file */ -{ - int count; /* pattern repeats this many times */ - long total; /* expect this many patterns */ - -/* - * - * Reads all the bitmaps from the next input file, translates each one into - * PostScript, and arranges to have one bitmap printed on each page. Multiple - * bitmaps per input file work. - * - */ - - - fp_in = fp; /* everyone reads from this file */ - - while ( dimensions() == TRUE ) { - patcount = 0; - total = scanlines * patterns; - - bbox[0] = MAX(bbox[0], patterns*16); /* for BoundingBox comment */ - bbox[1] = MAX(bbox[1], scanlines); - - redirect(++page); - fprintf(fp_out, "%s %d %d\n", PAGE, page, printed+1); - fprintf(fp_out, "save\n"); - writerequest(printed+1, fp_out); - - fprintf(fp_out, "%s ", (v8format == TRUE && v8undo == FALSE) ? "true" : "false"); - fprintf(fp_out, "%s ", (flip == TRUE) ? "true" : "false"); - fprintf(fp_out, "%d %d bitmap\n", patterns * 16, scanlines); - - while ( patcount != total && (count = getc(fp)) != EOF ) { - addrast(count); - patcount += (count & 0177); - if ( patcount % patterns == 0 ) - putrast(); - } /* End while */ - - if ( debug == ON ) - fprintf(stderr, "patterns = %d, scanlines = %d, patcount = %d\n", patterns, scanlines, patcount); - - if ( total != patcount ) - error(FATAL, "bitmap format error"); - - if ( fp_out == stdout ) printed++; - - fprintf(fp_out, "showpage\n"); - fprintf(fp_out, "restore\n"); - fprintf(fp_out, "%s %d %d\n", ENDPAGE, page, printed); - } /* End while */ - -} /* End of bitmap */ - - -/*****************************************************************************/ - -static int -dimensions(void) -{ - int ox, oy; /* coordinates of the origin */ - int cx, cy; /* and right corner of the bitmap */ - int i; /* loop index */ - -/* - * - * Determines the dimensions and type of the next bitmap. Eighth edition bitmaps - * have a zero in the first 16 bits. If valid dimensions are read TRUE is returned - * to the caller. Changed so the check of whether we're done (by testing scanlines - * or patterns) comes before the malloc(). - * - */ - - - if ( (scanlines = getint()) == 0 ) { - ox = getint(); - oy = getint(); - cx = getint(); - cy = getint(); - scanlines = cy - oy; - patterns = (cx - ox + 15) / 16; - v8format = TRUE; - } else patterns = getint(); - - if ( scanlines <= 0 || patterns <= 0 ) /* done - don't do the malloc() */ - return(FALSE); - - if ( raster != NULL ) free(raster); - if ( prevrast != NULL ) free(prevrast); - - if ( (rptr = raster = (char *) malloc(patterns * 2)) == NULL ) - error(FATAL, "no memory"); - - if ( (prevrast = (char *) malloc(patterns * 2)) == NULL ) - error(FATAL, "no memory"); - - for ( i = 0; i < patterns * 2; i++ ) - *(prevrast+i) = 0377; - - eptr = rptr + patterns * 2; - - return(TRUE); - -} /* End of dimensions */ - - -/*****************************************************************************/ - -static void -addrast(int count) - /* repeat count for next pattern */ -{ - int size; /* number of bytes in next pattern */ - int l, h; /* high and low bytes */ - int i, j; /* loop indices */ - -/* - * - * Reads the input file and adds the appropriate number of bytes to the output - * raster line. If count has bit 7 on, one 16 bit pattern is read and repeated - * count & 0177 times. If bit 7 is off, count is the number of patterns read from - * fp_in - each one repeated once. - * - */ - - - if ( count & 0200 ) { - size = 1; - count &= 0177; - } else { - size = count; - count = 1; - } /* End else */ - - for ( i = size; i > 0; i-- ) { - if ( (l = getc(fp_in)) == EOF || (h = getc(fp_in)) == EOF ) - return; - for ( j = count; j > 0; j-- ) { - *rptr++ = l; - *rptr++ = h; - } /* End for */ - } /* End for */ - -} /* End of addrast */ - - -/*****************************************************************************/ - -static void -putrast(void) -{ - char *p1, *p2; /* starting and ending patterns */ - int n; /* set to bytes per pattern */ - int i; /* loop index */ - -/* - * - * Takes the scanline that's been saved in *raster, encodes it according to the - * value that's been assigned to bytespp, and writes the result to *fp_out. Each - * line in the output bitmap is terminated by a 0 on a line by itself. - * - */ - - - n = (bytespp <= 0) ? 2 * patterns : bytespp; - - if ( v8format == TRUE && v8undo == TRUE ) - for ( i = 0; i < patterns * 2; i++ ) - *(raster+i) = (*(prevrast+i) ^= *(raster+i)); - - for ( p1 = raster, p2 = raster + n; p1 < eptr; p1 = p2 ) - if ( patncmp(p1, n) == TRUE ) { - while ( patncmp(p2, n) == TRUE ) p2 += n; - p2 += n; - fprintf(fp_out, "%d ", n); - for ( i = 0; i < n; i++, p1++ ) - fprintf(fp_out, "%.2X", ((int) *p1) & 0377); - fprintf(fp_out, " %d\n", (p2 - p1) / n); - } else { - while ( p2 < eptr && patncmp(p2, n) == FALSE ) p2 += n; - if ( p2 > eptr ) p2 = eptr; - fprintf(fp_out, "%d ", p2 - p1); - while ( p1 < p2 ) - fprintf(fp_out, "%.2X", ((int) *p1++) & 0377); - fprintf(fp_out, " 0\n"); - } /* End else */ - - fprintf(fp_out, "0\n"); - - rptr = raster; - -} /* End of putrast */ - - -/*****************************************************************************/ - -static int -patncmp(char *p1, int n) - /* p1 - first patterns starts here */ - /* n - and extends this many bytes */ -{ - char *p2; /* address of the second pattern */ - -/* - * - * Compares the two n byte patterns *p1 and *(p1+n). FALSE is returned if they're - * different or extend past the end of the current raster line. - * - */ - - - p2 = p1 + n; - - for ( ; n > 0; n--, p1++, p2++ ) - if ( p2 >= eptr || *p1 != *p2 ) - return(FALSE); - - return(TRUE); - -} /* End of patncmp */ - - -/*****************************************************************************/ - -static int -getint(void) -{ - int h, l; /* high and low bytes */ - -/* - * - * Reads the next two bytes from *fp_in and returns the resulting integer. - * - */ - - - if ( (l = getc(fp_in)) == EOF || (h = getc(fp_in)) == EOF ) - return(-1); - - return((h & 0377) << 8 | (l & 0377)); - -} /* End of getint */ - - -/*****************************************************************************/ - -static void -redirect(int pg) - /* next page we're printing */ -{ - static FILE *fp_null = NULL; /* if output is turned off */ - -/* - * - * If we're not supposed to print page pg, fp_out will be directed to /dev/null, - * otherwise output goes to stdout. - * - */ - - - if ( pg >= 0 && in_olist(pg) == ON ) - fp_out = stdout; - else if ( (fp_out = fp_null) == NULL ) - fp_out = fp_null = fopen("/dev/null", "w"); - -} /* End of redirect */ diff --git a/usr/src/cmd/lp/filter/postscript/postmd/Makefile b/usr/src/cmd/lp/filter/postscript/postmd/Makefile deleted file mode 100644 index 43809fab91..0000000000 --- a/usr/src/cmd/lp/filter/postscript/postmd/Makefile +++ /dev/null @@ -1,79 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# ident "%Z%%M% %I% %E% SMI" -# -# Copyright 1989-2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/lp/filter/postscript/postmd/Makefile -# - -include ../../../Makefile.lp - -PROG= postmd - -SRCS= postmd.c - -OBJS = $(SRCS:%.c=%.o) - -COMMONDIR = ../common - -COMMONOBJS = $(COMMONDIR)/request.o \ - $(COMMONDIR)/glob.o \ - $(COMMONDIR)/misc.o - -TXTS= README - -LDLIBS += -lm - -ENCODING= 2 -CPPFLAGS = -DDFLTENCODING=$(ENCODING) \ - -I. -I$(COMMONDIR) \ - $(CPPFLAGS.master) - -POFILE = lp_filter_postscript_postmd.po - -.KEEP_STATE: - -all: $(TXTS) $(PROG) - -install: all $(ROOTLIBLPPOSTPROG) - -$(PROG): $(OBJS) $(COMMONOBJS) - $(LINK.c) -o $@ $(OBJS) $(LDLIBS) $(COMMONOBJS) - $(POST_PROCESS) - -$(COMMONOBJS): $$(@:%.o=%.c) - cd $(@D); $(MAKE) $(@F) - -clean: - $(RM) $(OBJS) - -strip: - $(STRIP) $(PROG) - -lint: lint_SRCS - -include ../../../../Makefile.targ - -include ../Makefile.msg diff --git a/usr/src/cmd/lp/filter/postscript/postmd/README b/usr/src/cmd/lp/filter/postscript/postmd/README deleted file mode 100644 index 6c2abb3ea6..0000000000 --- a/usr/src/cmd/lp/filter/postscript/postmd/README +++ /dev/null @@ -1,53 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -A program that can be used to display a matrix as a gray scale image on PostScript -printers. May be useful if you have a large matrix and want a simple way to look -for patterns. Although I haven't been anywhere close, I expect a 600x600 matrix -is a very optimistic upper bound on a 300 dpi printer using 5 shades of gray and -8.5x11 inch paper. - -Matrix elements are a series of floating point numbers arranged in the input file -in row major order. By default each matrix is assumed to be square and the number -of rows (and columns) is set to the square root of the number of elements in the -input file. White space, including newlines, is not used to determine the matrix -dimensions. Each matrix element is mapped into an integer in the range 0 to 255 -(254 by default) and PostScript's image operator maps that integer into a gray -scale appropriate for your printer. - -The mapping from floating point matrix elements to integers is controlled by an -interval list and grayscale map. The default interval list is "-1,0,1" which -partitions the real line into 7 regions, while the default grayscale map gets -darker as the regions move from left to right along the real line. The -i option -changes the interval list and the -g option modifies the grayscale mapping. Check -the man page for more details. - -By default 6 byte patterns are used, but any number can be selected with the -b -option. 6 byte patterns are a tradeoff that achieves a good (but not necessarily -optimal) performance across the wide variety of currently available PostScript -printers. Decreasing the pattern size often helps some on printers with fast -processors (eg. PS-810s) while increasing the pattern size speeds things up on -older printers (eg. PS-800s). In the limited number of tests I ran -b10 worked -best on PS800s and -b4 gave the best performance on PS-810s. If you want a -different default pattern size change the initialization of bytespp (near line -175 in postmd.c) before you compile the program. - diff --git a/usr/src/cmd/lp/filter/postscript/postmd/postmd.c b/usr/src/cmd/lp/filter/postscript/postmd/postmd.c deleted file mode 100644 index 15d2262b0d..0000000000 --- a/usr/src/cmd/lp/filter/postscript/postmd/postmd.c +++ /dev/null @@ -1,1232 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * - * postmd - matrix display program for PostScript printers. - * - * A simple program that can be used to display a matrix as a gray scale image on - * a PostScript printer using the image operator. Much of the code was borrowed - * from postdmd, the bitmap display program DMD screen dumps. May help if you have - * a large matix (of floating point numbers) and want a simple way to look for - * patterns. - * - * Matrix elements are a series of floating point numbers arranged in the input - * file in row major order. The actual matrix elements can be preceeded by a simple - * header that sets things like the matrix dimensions, interval list, and possibly - * a window into the matrix that we'll use for display. The dimension statement is - * perhaps the most important. If present it determines the number of rows and - * columns in the matrix. For example, either of the following defines a 50x50 - * matrix, - * - * dimension 50 - * dimension 50x50 - * - * If no dimension statement appears in the input file, the matrix is assumed to - * be square, and the number of rows (and columns) is set to the square root of - * the number of elements in the input file. - * - * Each matrix element is mapped into an integer in the range 0 to 255 (actually - * 254) and PostScript's image operator then maps that number into a gray scale - * appropriate for the particular printer. The mapping from the floating point - * matrix elements to integers is accomplished using an interval list that can be - * set using the -i option. The format of the interval string is, - * - * num1,num2,num3,...,numn - * - * where each num is a floating point number. The list must be given in increasing - * numerical order. A list of n numbers partitions the real line into 2n+1 regions - * given as, - * - * region1 element < num1 - * region2 element = num1 - * region3 element < num2 - * region4 element = num2 - * . - * . - * . - * region2n element = numn - * region2n+1 element > numn - * - * Every number in a region is mapped one integer in the range 0 to 254, and that - * number, when displayed on a printer using the image operator, prints as a square - * filled with a gray shade that reflects the integer that was chosen. 0 maps to - * black and 255 maps to white (which by default will not be used). - * - * The default gray scale gets darker as the region number increases, but can be - * changed by supplying a gray scale list with the -g option or in the optional - * matrix header. The color map is again a comman or space separated list that - * looks like, - * - * color1,color2, ... ,color2n+1 - * - * where color1 applies to region 1 and color2n+1 applies to region2n+1. Each - * number in the list should be an integer between 0 and 255. If less than 2n+1 - * colors are given default assignments will be used for missing regions. - * - * The size of the matrix that we can display reasonably well is a function of the - * number of elements in the interval list, paper size, and printer resolution. - * For example a 300dpi printer using 8.5x11 inch paper gives us an image area of - * about 2400x2400 pixels. An interval list of two numbers generates five separate - * regions and will therefore need that many different shades of gray. Since we're - * not using white we'll need to partion our image area into 4x4 pixel squares, - * and that means a 600x600 matrix is about as big as we can go. In practice that's - * optimistic, but the argument illustrates some of the limitations. - * - * A submatrix can be selected to display by windowing into the matrix. The window - * list can be given using the -w option or can be set in the optional header that - * can preceed each matrix. The list should be a comma or space separated list - * that looks like, - * - * lower-column, lower-row, upper-column, upper-row - * - * where each element in the list must be a positive integer. Rows and columns in - * the input matrix start at 1. The dimension of the displayed window will be from - * lower-column to upper-column and from lower-row to upper-row inclusive. - * - * The encoding produced by the program is essentially identical to what's done - * by postdmd. See the comments at the beginning of that program if you need more - * details. The prologue also shares much of the same code. - * - * The PostScript prologue is copied from *prologue before any of the input files - * are translated. The program expects that the following PostScript procedures - * are defined in that file: - * - * setup - * - * mark ... setup - - * - * Handles special initialization stuff that depends on how this program - * was called. Expects to find a mark followed by key/value pairs on the - * stack. The def operator is applied to each pair up to the mark, then - * the default state is set up. - * - * pagesetup - * - * page pagesetup - - * - * Does whatever is needed to set things up for the next page. Expects - * to find the current page number on the stack. - * - * bitmap - * - * columns rows bitmap - - * - * Prints the image that's read as a hex string from standard input. The - * image consists of rows lines, each of which includes columns elements. - * Eight bits per pixel are used to encode the matrix elements. - * - * labelmatrix - * - * matrixname matrixlimits labelmatrix - - * - * Prints string matrixname just below the lower left corner of the image - * and prints string martixlimits near the lower right corner. Outlines - * the entire image with a (one pixel wide) box and then draws tick marks - * along the top and left sides of the image. One tick mark is printed - * for every ten elements. - * - * legend - * - * n1 ... nN N c1 m1 ... cM mM total regions legend - - * - * Prints the legend as a bar graph below the matrix image. n1 ... nN are - * strings that represent the interval list. c1 m1 ... cm mM are pairs - * that consist of a region's color and the statistics count. Actually - * the c's are trivial procedures that just leave a one character string - * on the stack when they're executed by image - which is the way the - * bar graph is drawn. - * - * done - * - * done - * - * Makes sure the last page is printed. Only needed when we're printing - * more than one page on each sheet of paper. - * - * Many default values, like the magnification and orientation, are defined in - * the prologue, which is where they belong. If they're changed (by options), an - * appropriate definition is made after the prologue is added to the output file. - * The -P option passes arbitrary PostScript through to the output file. Among - * other things it can be used to set (or change) values that can't be accessed by - * other options. - * - */ - - -#include <stdio.h> -#include <signal.h> -#include <ctype.h> -#include <fcntl.h> - -#include "comments.h" /* PostScript file structuring comments */ -#include "gen.h" /* general purpose definitions */ -#include "path.h" /* for the prologue */ -#include "ext.h" /* external variable declarations */ -#include "postmd.h" /* special matrix display definitions */ - - -char *optnames = "a:b:c:d:g:i:m:n:o:p:w:x:y:A:C:J:L:P:R:DI"; - -char *prologue = POSTMD; /* default PostScript prologue */ -char *formfile = FORMFILE; /* stuff for multiple pages per sheet */ -char *temp_dir = TEMPDIR; /* temp directory for copying stdin */ - -int formsperpage = 1; /* page images on each piece of paper */ -int copies = 1; /* and this many copies of each sheet */ -int bytespp = 6; /* bytes per pattern - on output */ - -int dostats = ON; /* permanent statistics flag */ -int nmstat = ON; /* and the one for the next matrix */ - -char *interval = DFLTILIST; /* string representations of the interval */ -char *colormap = NULL; /* color map */ -char *window = NULL; /* and window lists */ -char *matrixname = "pipe.end"; /* name for the next plot */ - -Ilist ilist[128]; /* active interval list and color map */ -int next = 0; /* one past the last element in ilist[] */ -int regions; /* an index assigned to the last region */ -int wlist[4]; /* upper left and lower right corners */ - -int page = 0; /* last page we worked on */ -int printed = 0; /* and the number of pages printed */ - -int dfltrows = 0; /* default rows */ -int dfltcols = 0; /* and columns - changed by -d option */ -int rows; /* real number of rows */ -int columns; /* and columns in the matrix */ -int patcount = 0; /* will be set to columns * rows */ - -double element; /* next matrix element */ - -char *raster = NULL; /* next raster line */ -char *rptr; /* next free byte in raster */ -char *eptr; /* one past the last byte in raster */ - -FILE *fp_in = stdin; /* read from this file */ -FILE *fp_out = stdout; /* and write stuff here */ -FILE *fp_acct = NULL; /* for accounting data */ - -static void account(void); -static void addcolormap(char *); -static void arguments(void); -static void buildilist(char *); -static void copystdin(void); -static void dimensions(void); -static void done(void); -static void getheader(void); -static void header(void); -static void init_signals(void); -static int inrange(void); -static int inwindow(void); -static void labelmatrix(void); -static int mapfloat(double); -static void matrix(void); -static void options(void); -static int patncmp(char *, int); -static void putrow(void); -static void redirect(int); -static char *savestring(char *); -static void setup(void); -static void setwindow(char *); - -/*****************************************************************************/ - -int -main(int agc, char *agv[]) -{ - -/* - * - * Bitmap display program for matrices. Only one matrix is allowed per input file, - * and each one will be displayed on a page by itself. Input files consist of an - * optional header followed by floating point numbers that represent the matrix - * elements - in row major order. - * - */ - - - argc = agc; /* other routines may want them */ - argv = agv; - - prog_name = argv[0]; /* really just for error messages */ - - init_signals(); /* sets up interrupt handling */ - header(); /* PostScript header comments */ - options(); /* handle the command line options */ - setup(); /* for PostScript */ - arguments(); /* followed by each input file */ - done(); /* print the last page etc. */ - account(); /* job accounting data */ - - return (x_stat); /* not much could be wrong */ - -} /* End of main */ - - -/*****************************************************************************/ - -static void -init_signals(void) -{ - void interrupt(); /* signal handler */ - -/* - * - * Make sure we handle interrupts. - * - */ - - - if ( signal(SIGINT, interrupt) == SIG_IGN ) { - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - signal(SIGHUP, SIG_IGN); - } else { - signal(SIGHUP, interrupt); - signal(SIGQUIT, interrupt); - } /* End else */ - - signal(SIGTERM, interrupt); - signal(SIGFPE, interrupt); - -} /* End of init_signals */ - - -/*****************************************************************************/ - -static void -header(void) -{ - int ch; /* return value from getopt() */ - int old_optind = optind; /* for restoring optind - should be 1 */ - -/* - * - * Scans the option list looking for things, like the prologue file, that we need - * right away but could be changed from the default. Doing things this way is an - * attempt to conform to Adobe's latest file structuring conventions. In particular - * they now say there should be nothing executed in the prologue, and they have - * added two new comments that delimit global initialization calls. Once we know - * where things really are we write out the job header, follow it by the prologue, - * and then add the ENDPROLOG and BEGINSETUP comments. - * - */ - - - while ( (ch = getopt(argc, argv, optnames)) != EOF ) - if ( ch == 'L' ) - prologue = optarg; - else if ( ch == '?' ) - error(FATAL, ""); - - optind = old_optind; /* get ready for option scanning */ - - fprintf(stdout, "%s", CONFORMING); - fprintf(stdout, "%s %s\n", VERSION, PROGRAMVERSION); - fprintf(stdout, "%s %s\n", DOCUMENTFONTS, ATEND); - fprintf(stdout, "%s %s\n", PAGES, ATEND); - fprintf(stdout, "%s", ENDCOMMENTS); - - if ( cat(prologue) == FALSE ) - error(FATAL, "can't read %s", prologue); - - fprintf(stdout, "%s", ENDPROLOG); - fprintf(stdout, "%s", BEGINSETUP); - fprintf(stdout, "mark\n"); - -} /* End of header */ - - -/*****************************************************************************/ - -static void -options(void) -{ - int ch; /* return value from getopt() */ - -/* - * - * Reads and processes the command line options. Added the -P option so arbitrary - * PostScript code can be passed through. Expect it could be useful for changing - * definitions in the prologue for which options have not been defined. - * - */ - - - while ( (ch = getopt(argc, argv, optnames)) != EOF ) { - - switch ( ch ) { - - case 'a': /* aspect ratio */ - fprintf(stdout, "/aspectratio %s def\n", optarg); - break; - - case 'b': /* bytes per pattern - on output */ - bytespp = atoi(optarg); - break; - - case 'c': /* copies */ - copies = atoi(optarg); - fprintf(stdout, "/#copies %s store\n", optarg); - break; - - case 'd': /* default matrix dimensions */ - sscanf(optarg, "%dx%d", &dfltrows, &dfltcols); - break; - - case 'g': /* set the colormap (ie. grayscale) */ - colormap = optarg; - break; - - case 'i': /* matrix element interval list */ - interval = optarg; - break; - - case 'm': /* magnification */ - fprintf(stdout, "/magnification %s def\n", optarg); - break; - - case 'n': /* forms per page */ - formsperpage = atoi(optarg); - fprintf(stdout, "%s %s\n", FORMSPERPAGE, optarg); - fprintf(stdout, "/formsperpage %s def\n", optarg); - break; - - case 'o': /* output page list */ - out_list(optarg); - break; - - case 'p': /* landscape or portrait mode */ - if ( *optarg == 'l' ) - fprintf(stdout, "/landscape true def\n"); - else fprintf(stdout, "/landscape false def\n"); - break; - - case 'w': /* set the window */ - window = optarg; - break; - - case 'x': /* shift things horizontally */ - fprintf(stdout, "/xoffset %s def\n", optarg); - break; - - case 'y': /* and vertically on the page */ - fprintf(stdout, "/yoffset %s def\n", optarg); - break; - - case 'A': /* force job accounting */ - case 'J': - if ( (fp_acct = fopen(optarg, "a")) == NULL ) - error(FATAL, "can't open accounting file %s", optarg); - break; - - case 'C': /* copy file straight to output */ - if ( cat(optarg) == FALSE ) - error(FATAL, "can't read %s", optarg); - break; - - case 'L': /* PostScript prologue file */ - prologue = optarg; - break; - - case 'P': /* PostScript pass through */ - fprintf(stdout, "%s\n", optarg); - break; - - case 'R': /* special global or page level request */ - saverequest(optarg); - break; - - case 'D': /* debug flag */ - debug = ON; - break; - - case 'I': /* ignore FATAL errors */ - ignore = ON; - break; - - case '?': /* don't understand the option */ - error(FATAL, ""); - break; - - default: /* don't know what to do for ch */ - error(FATAL, "missing case for option %c\n", ch); - break; - - } /* End switch */ - - } /* End while */ - - argc -= optind; /* get ready for non-option args */ - argv += optind; - -} /* End of options */ - - -/*****************************************************************************/ - -static void -setup(void) -{ - -/* - * - * Handles things that must be done after the options are read but before the - * input files are processed. - * - */ - - - writerequest(0, stdout); /* global requests eg. manual feed */ - fprintf(stdout, "setup\n"); - - if ( formsperpage > 1 ) { - if ( cat(formfile) == FALSE ) - error(FATAL, "can't read %s", formfile); - fprintf(stdout, "%d setupforms\n", formsperpage); - } /* End if */ - - fprintf(stdout, "%s", ENDSETUP); - -} /* End of setup */ - - -/*****************************************************************************/ - -static void -arguments(void) -{ - -/* - * - * Makes sure all the non-option command line arguments are processed. If we get - * here and there aren't any arguments left, or if '-' is one of the input files - * we'll process stdin. - * - */ - - - if ( argc < 1 ) - matrix(); - else { /* at least one argument is left */ - while ( argc > 0 ) { - matrixname = *argv; - if ( strcmp(*argv, "-") == 0 ) { - fp_in = stdin; - matrixname = "pipe.end"; - } else if ( (fp_in = fopen(*argv, "r")) == NULL ) - error(FATAL, "can't open %s", *argv); - matrix(); - if ( fp_in != stdin ) - fclose(fp_in); - argc--; - argv++; - } /* End while */ - } /* End else */ - -} /* End of arguments */ - - -/*****************************************************************************/ - -static void -done(void) -{ - -/* - * - * Finished with all the input files, so mark the end of the pages, make sure the - * last page is printed, and restore the initial environment. - * - */ - - - fprintf(stdout, "%s", TRAILER); - fprintf(stdout, "done\n"); - fprintf(stdout, "%s %d\n", PAGES, printed); - - if ( temp_file != NULL ) - unlink(temp_file); - -} /* End of done */ - - -/*****************************************************************************/ - -static void -account(void) -{ - - -/* - * - * Writes an accounting record to *fp_acct provided it's not NULL. Accounting - * is requested using the -A or -J options. - * - */ - - - if ( fp_acct != NULL ) - fprintf(fp_acct, " print %d\n copies %d\n", printed, copies); - -} /* End of account */ - - -/*****************************************************************************/ - -static void -matrix(void) -{ - - - int count; /* pattern repeats this many times */ - long total; /* expect this many patterns */ - - -/* - * - * Reads a matrix from *fp_in, translates it into a PostScript gray scale image, - * and writes the result on stdout. For now only one matrix is allowed per input - * file. Matrix elements are floating point numbers arranged in row major order - * in the input file. In addition each input file may contain an optional header - * that defines special things like the dimension of the matrix, a window into - * the matrix that will be displayed, and an interval list. - * - * If we're reading from stdin we first make a copy in a temporary file so we can - * can properly position ourselves after we've looked for the header. Originally - * wasn't always making a copy of stdin, but I've added a few things to what's - * accepted in the header and this simplifies the job. An alternative would be - * to always require a header and mark the end of it by some string. Didn't like - * that approach much - may fix things up later. - * - */ - - - if ( fp_in == stdin ) /* make a copy so we can seek etc. */ - copystdin(); - - rows = dfltrows; /* new dimensions for the next matrix */ - columns = dfltcols; - - buildilist(interval); /* build the default ilist[] */ - addcolormap(colormap); /* add the colormap - if not NULL */ - setwindow(window); /* and setup the initial matrix window */ - nmstat = dostats; /* want statistics? */ - getheader(); /* matrix dimensions at the very least */ - dimensions(); /* make sure we have the dimensions etc. */ - - patcount = 0; - total = rows * columns; - - eptr = rptr + (wlist[2] - wlist[0] + 1); - - redirect(++page); - - fprintf(fp_out, "%s %d %d\n", PAGE, page, printed+1); - fprintf(fp_out, "save\n"); - writerequest(printed+1, fp_out); - fprintf(fp_out, "%d %d bitmap\n", wlist[2] - wlist[0] + 1, wlist[3] - wlist[1] + 1); - - while ( patcount != total && fscanf(fp_in, "%f", &element) != EOF ) { - if ( inwindow() ) *rptr++ = mapfloat(element); - if ( ++patcount % columns == 0 ) - if ( inrange() ) - putrow(); - } /* End while */ - - if ( total != patcount ) - error(FATAL, "matrix format error"); - - labelmatrix(); - - if ( fp_out == stdout ) printed++; - - fprintf(fp_out, "showpage\n"); - fprintf(fp_out, "restore\n"); - fprintf(fp_out, "%s %d %d\n", ENDPAGE, page, printed); - -} /* End of matrix */ - - -/*****************************************************************************/ - -static void -copystdin(void) -{ - int fd_out; /* for the temporary file */ - int fd_in; /* for stdin */ - int buf[512]; /* buffer for reads and writes */ - int count; /* number of bytes put in buf */ - -/* - * - * If we're reading the matrix from stdin and the matrix dimension isn't set by - * a dimension statement at the beginning of the file we'll copy stdin to a - * temporary file and reset *fp_in so reads come from the temp file. Simplifies - * reading the header (if present), but is expensive. - * - */ - - - if ( temp_file != NULL ) /* been here already */ - unlink(temp_file); - - if ( (temp_file = tempnam(temp_dir, "post")) == NULL ) - error(FATAL, "can't generate temp file name"); - - if ( (fd_out = creat(temp_file, 0660)) == -1 ) - error(FATAL, "can't create %s", temp_file); - - fd_in = fileno(stdin); - - while ( (count = read(fd_in, buf, sizeof(buf))) > 0 ) - if ( write(fd_out, buf, count) != count ) - error(FATAL, "error writing to %s", temp_file); - - close(fd_out); - - if ( (fp_in = fopen(temp_file, "r")) == NULL ) - error(FATAL, "can't open %s", temp_file); - -} /* End of copystdin */ - - -/*****************************************************************************/ - -static void -getheader(void) -{ - char buf[512]; /* temporary string space */ - char *cmap = NULL; /* remember header colormap list */ - long pos; /* for seeking back to first element */ - -/* - * - * Looks for the optional header information at the beginning of the input file, - * reads it if it's there, and sets *fp_in to be just past the header. That should - * be the beginning of the matrix element list. The recognized header keywords are - * dimension, interval, colormap (or grayscale), window, name, and statistics. All - * are optional, but may be useful in a spooling environment when the user doesn't - * doesn't actually run the translator. - * - * The dimension statement specifies the number of rows and columns. For example - * either of the following two lines define a 50 by 50 element matrix, - * - * dimension 50 - * dimension 50x50 - * - * The first integer is the number of rows and the second, if given, is the number - * of columns. If columns are missing from the dimension statement we assume the - * matrix is square. - * - * interval can be used to redefine the interval list used for mapping floating - * point numbers into integers in the range 0 to 254. The string following the - * interval keyword has the same format as the -i option. For example to set the - * interval list to -1, 0, and 1 you can add the line, - * - * interval -1,0,1 - * - * The numbers are floats given in increasing order, and separated by commas or - * blanks. The last interval list in a header takes precedence. - * - * colormap can be used to redefine the grayscale list. The string following - * the colormap keyword has the same format as the -g option. For example - * - * colormap 0,50,100,150,200,250 - * or grayscale 0,50,100,150,200,250 - * - * The window keyword can be used to select a submatrix. The numbers following - * window are the upper left and lower right matix coordinates. May not be - * implemented yet but shouldn't be difficult. For example - * - * window 10 10 40 40 - * - * selects the submatrix with corners at (10, 10) and (40, 40). The edges of the - * window are included in the display. - * - * The name keyword can be used to define the title of the display. For example, - * - * name Plot Of Matrix 1 - * - * prints the string "Plot Of Matrix 1" at the top of the page. Everything up to - * the next newline is taken as the name string. - * - */ - - - pos = ftell(fp_in); - - while ( fscanf(fp_in, "%s", buf) != EOF ) { - if ( strncmp(buf, "dimension", strlen("dimension")) == 0 ) - fscanf(fp_in, "%dx%d", &rows, &columns); - else if ( strncmp(buf, "window", strlen("window")) == 0 ) { - fgets(buf, sizeof(buf), fp_in); - setwindow(buf); - } else if ( strncmp(buf, "name", strlen("name")) == 0 ) { - fgets(buf, sizeof(buf), fp_in); - matrixname = savestring(buf); - } else if ( strncmp(buf, "colormap", strlen("colormap")) == 0 ) { - fgets(buf, sizeof(buf), fp_in); - cmap = savestring(buf); - } else if ( strncmp(buf, "grayscale", strlen("grayscale")) == 0 ) { - fgets(buf, sizeof(buf), fp_in); - cmap = savestring(buf); - } else if ( strncmp(buf, "interval", strlen("interval")) == 0 ) { - fgets(buf, sizeof(buf), fp_in); - buildilist(buf); - } else if ( strncmp(buf, "statistics", strlen("statistics")) == 0 ) { - fscanf(fp_in, "%s", buf); - if ( strcmp(buf, "on") == 0 || strcmp(buf, "ON") == 0 ) - nmstat = ON; - else - nmstat = OFF; - } else break; - pos = ftell(fp_in); - } /* End while */ - - addcolormap(cmap); /* must happen last */ - fseek(fp_in, pos, 0); /* back to the start of the matrix */ - -} /* End of getheader */ - - -/*****************************************************************************/ - -static void -dimensions(void) -{ - char buf[100]; /* temporary storage for the elements */ - long count = 0; /* number of elements in the matrix */ - long pos; /* matrix elements start here */ - -/* - * - * Need to know the dimensions of the matrix before we can go any farther. If - * rows and columns are still 0 we'll read the entire input file, starting from - * the current position, count the number of elements, take the square root of it, - * and use it as the number of rows and columns. Then we seek back to the start - * of the real matrix, make sure columns is set, and allocate enough memory for - * storing each raster line. After we're certain we've got the number of rows and - * columns we check the window coordinates, and if they're not legitimate they're - * reset to cover the entire matrix. - * - */ - - - - if ( rows == 0 ) { - pos = ftell(fp_in); - while ( fscanf(fp_in, "%s", buf) != EOF ) - count++; - rows = sqrt((double) count); - fseek(fp_in, pos, 0); - } /* End if */ - - if ( columns <= 0 ) columns = rows; - - if ( raster != NULL ) free(raster); - - if ( (rptr = raster = malloc(columns)) == NULL ) - error(FATAL, "no memory"); - - eptr = rptr + columns; - - if ( rows <= 0 || columns <= 0 ) - error(FATAL, "bad matrix dimensions"); - - if ( wlist[0] > wlist[2] || wlist[1] > wlist[3] ) { - wlist[0] = wlist[1] = 1; - wlist[2] = columns; - wlist[3] = rows; - } /* End if */ - -} /* End of dimensions */ - - -/*****************************************************************************/ - -static void -buildilist(char *list) - /* use this as the interval list */ -{ - static char *templist = NULL; /* a working copy of the list */ - char *ptr; /* next number in *templist */ - int i; /* loop index - for checking the list */ - - -/* - * - * Reads string *list and builds up the ilist[] that will be used in the next - * matrix. Since strtok() modifies the string it's parsing we make a copy first. - * The format of the interval list is described in detail in the comments at the - * beginning of this program. Basically consists of a comma or space separated - * list of floating point numbers that must be given in increasing numerical order. - * The list determines how floating point numbers are mapped into integers in the - * range 0 to 254. - * - */ - - - if ( templist != NULL ) /* free the space used by the last list */ - free(templist); - - while ( isascii(*list) && isspace(*list) ) - list++; - - for ( ptr = list, regions = 3; *ptr != '\0'; ptr++ ) { - if ( *ptr == ',' || *ptr == '/' || isspace(*ptr) ) - regions += 2; - while ( isascii(*ptr) && isspace(*ptr) ) ptr++; - } /* End for */ - - next = 0; - templist = savestring(list); - - ptr = strtok(templist, ",/ \t\n"); - while ( ptr != NULL ) { - ilist[next].count = 0; - ilist[next++].color = 254 * (regions - 1 - next) / (regions - 1); - ilist[next].val = atof(ptr); - ilist[next].count = 0; - ilist[next++].color = 254 * (regions - 1 - next) / (regions - 1); - ptr = strtok(NULL, ",/ \t\n"); - } /* End while */ - - ilist[next].count = 0; - ilist[next].color = 254 * (regions - 1 - next) / (regions - 1); - - if ( next == 0 ) /* make sure we have a list */ - error(FATAL, "missing interval list"); - - for ( i = 3; i < next; i += 2 ) /* that's in increasing numerical order */ - if ( ilist[i].val <= ilist[i-2].val ) - error(FATAL, "bad interval list"); - -} /* End of buildilist */ - - -/*****************************************************************************/ - -static void -addcolormap(char *list) - /* use this color map */ -{ - static char *templist = NULL; /* a working copy of the color list */ - char *ptr; /* next color in *templist */ - int i = 0; /* assigned to this region in ilist[] */ - -/* - * - * Assigns the integers in *list to the color field for the regions defined in - * ilist[]. Assumes ilist[] has already been setup. - * - */ - - - if ( list != NULL ) { - if ( templist != NULL ) - free(templist); - templist = savestring(list); - - ptr = strtok(templist, ",/ \t\n"); - while ( ptr != NULL ) { - ilist[i++].color = atoi(ptr) % 256; - ptr = strtok(NULL, ",/ \t\n"); - } /* End while */ - } /* End if */ - -} /* End of addcolormap */ - - -/*****************************************************************************/ - -static void -setwindow(char *list) - /* corners of window into the matrix */ -{ - static char *templist = NULL; /* a working copy of the window list */ - char *ptr; /* next window coordinate in *templist */ - int i = 0; /* assigned to this region in wlist[] */ - -/* - * - * Sets up an optional window into the matrix. - * - */ - - - wlist[0] = wlist[1] = 1; - wlist[2] = wlist[3] = 0; - - if ( list != NULL ) { - if ( templist != NULL ) - free(templist); - templist = savestring(list); - - ptr = strtok(templist, ",/ \t\n"); - while ( ptr != NULL ) { - wlist[i++] = atoi(ptr); - ptr = strtok(NULL, ",/ \t\n"); - } /* End while */ - } /* End if */ - -} /* End of setwindow */ - - -/*****************************************************************************/ - -static int -inwindow(void) -{ - int r; /* row of the patcount element */ - int c; /* column of the patcount element */ - -/* - * - * Checks if the patcount element of the matrix is in the window. - * - */ - - - r = (patcount/columns) + 1; - c = (patcount%columns) + 1; - - return((c >= wlist[0]) && (r >= wlist[1]) && (c <= wlist[2]) && (r <= wlist[3])); - -} /* End of inwindow */ - - -/*****************************************************************************/ - -static int -inrange(void) -{ - -/* - * - * Checks if the current row lies in the window. Used right before we output the - * raster lines. - * - */ - - - return(((patcount/columns) >= wlist[1]) && ((patcount/columns) <= wlist[3])); - - -} /* End of inrange */ - - -/*****************************************************************************/ - -static int -mapfloat(double element) - /* floating point matrix element */ -{ - int i; /* loop index */ - -/* - * - * Maps element into an integer in the range 0 to 255, and returns the result to - * the caller. Mapping is done using the color map that was saved in ilist[]. Also - * updates the count field for the region that contains element - not good! - * - */ - - - for ( i = 1; i < next && ilist[i].val < element; i += 2 ) ; - - if ( i > next || element < ilist[i].val ) - i--; - - ilist[i].count++; - return(ilist[i].color); - -} /* End of mapfloat */ - - -/*****************************************************************************/ - -static void -putrow(void) -{ - char *p1, *p2; /* starting and ending columns */ - int n; /* set to bytes per pattern */ - int i; /* loop index */ - -/* - * - * Takes the scanline that's been saved in *raster, encodes it according to the - * value that's been assigned to bytespp, and writes the result to *fp_out. Each - * line in the output bitmap is terminated by a 0 on a line by itself. - * - */ - - - n = (bytespp <= 0) ? columns : bytespp; - - for ( p1 = raster, p2 = raster + n; p1 < eptr; p1 = p2 ) - if ( patncmp(p1, n) == TRUE ) { - while ( patncmp(p2, n) == TRUE ) p2 += n; - p2 += n; - fprintf(fp_out, "%d ", n); - for ( i = 0; i < n; i++, p1++ ) - fprintf(fp_out, "%.2X", ((int) *p1) & 0377); - fprintf(fp_out, " %d\n", (p2 - p1) / n); - } else { - while ( p2 < eptr && patncmp(p2, n) == FALSE ) p2 += n; - if ( p2 > eptr ) p2 = eptr; - fprintf(fp_out, "%d ", p2 - p1); - while ( p1 < p2 ) - fprintf(fp_out, "%.2X", ((int) *p1++) & 0377); - fprintf(fp_out, " 0\n"); - } /* End else */ - - fprintf(fp_out, "0\n"); - - rptr = raster; - -} /* End of putrow */ - - -/*****************************************************************************/ - -static void -labelmatrix(void) -{ - int total; /* number of elements in the window */ - int i; /* loop index */ - -/* - * - * Responsible for generating the PostScript calls that label the matrix, generate - * the legend, and print the matrix name. - * - */ - - - fprintf(fp_out, "(%s) ((%d, %d) to (%d, %d)) labelmatrix\n", matrixname, - wlist[0], wlist[1], wlist[2], wlist[3]); - - total = (wlist[2] - wlist[0] + 1) * (wlist[3] - wlist[1] + 1); - - if ( nmstat == OFF ) - for ( i = 0; i < regions; i++ ) - ilist[i].count = 0; - - for ( i = 1; i < next; i += 2 ) - fprintf(fp_out, "(%g) ", ilist[i].val); - fprintf(fp_out, "%d ", (regions - 1) / 2); - - for ( i = regions - 1; i >= 0; i-- ) - fprintf(fp_out, "{(\\%.3o)} %d ", ilist[i].color, ilist[i].count); - fprintf(fp_out, "%d %d legend\n", total, regions); - -} /* End of labelmatrix */ - - -/*****************************************************************************/ - -static int -patncmp(char *p1, int n) - /* p1 - first patterns starts here */ - /* n - and extends this many bytes */ -{ - char *p2; /* address of the second pattern */ - -/* - * - * Compares the two n byte patterns *p1 and *(p1+n). FALSE if returned is they're - * different or extend past the end of the current raster line. - * - */ - - - p2 = p1 + n; - - for ( ; n > 0; n--, p1++, p2++ ) - if ( p2 >= eptr || *p1 != *p2 ) - return(FALSE); - - return(TRUE); - -} /* End of patncmp */ - - -/*****************************************************************************/ - -static char * -savestring(char *str) - /* save this string */ -{ - char *ptr = NULL; /* at this address */ - -/* - * - * Copies string *str to a permanent place and returns the address to the caller. - * - */ - - - if ( str != NULL && *str != '\0' ) { - if ( (ptr = malloc(strlen(str) + 1)) == NULL ) - error(FATAL, "no memory available for string %s", str); - strcpy(ptr, str); - } /* End if */ - - return(ptr); - -} /* End of savestring */ - - -/*****************************************************************************/ - -static void -redirect(int pg) - /* next page we're printing */ -{ - static FILE *fp_null = NULL; /* if output is turned off */ - -/* - * - * If we're not supposed to print page pg, fp_out will be directed to /dev/null, - * otherwise output goes to stdout. - * - */ - - - if ( pg >= 0 && in_olist(pg) == ON ) - fp_out = stdout; - else if ( (fp_out = fp_null) == NULL ) - fp_out = fp_null = fopen("/dev/null", "w"); - -} /* End of redirect */ diff --git a/usr/src/cmd/lp/filter/postscript/postmd/postmd.h b/usr/src/cmd/lp/filter/postscript/postmd/postmd.h deleted file mode 100644 index 791c64db31..0000000000 --- a/usr/src/cmd/lp/filter/postscript/postmd/postmd.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -#ifndef _POSTMD_H -#define _POSTMD_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * - * Definitions used by the matrix display program. - * - * An interval list used to map matrix elements into integers in the range 0 to - * 254 representing shades of gray on a PostScript printer. The list can be given - * using the -i option or can be set in the optional header that can preceed each - * matrix. The list should be a comma or space separated list that looks like, - * - * num1,num2, ... ,numn - * - * where each num is a floating point number. The list must be given in increasing - * numerical order. The n numbers in the list partion the real line into 2n+1 - * regions given by, - * - * region1 element < num1 - * region2 element = num1 - * region3 element < num2 - * region4 element = num3 - * . . - * . . - * . . - * region2n element = numn - * region2n+1 element > numn - * - * Every number in a given region is mapped into an integer in the range 0 to 254 - * and that number, when displayed on a PostScript printer using the image operator, - * prints as a square filled with a gray scale that reflects the integer that was - * chosen. 0 maps to black and 255 white (that's why 255 is normally omitted). - * - * The shades of gray chosen by the program are normally generated automatically, - * but can be reassigned using the -g option or by including a grayscale line in - * the optional header. The grayscale list is comma or space separated list of - * integers between 0 and 255 that's used to map individual regions into arbitray - * shade of gray, thus overriding the default choice made in the program. The list - * should look like, - * - * color1,color2, ... ,color2n+1 - * - * where color1 applies to region1 and color2n+1 applies to region2n+1. If less - * than 2n+1 numbers are given the default assignments will be used for the missing - * regions. Each color must be an integer in the range 0 to 255. - * - * The default interval list is given below. The default grayscale maps 254 (almost - * white) into the first region and 0 (black) into the last. - * - */ - -#define DFLTILIST "-1,0,1" - -/* - * - * The active interval list is built from an interval string and stored in an array - * whose elements are of type Ilist. - * - */ - -typedef struct { - - double val; /* only valid in kind is ENDPOINT */ - int color; /* gray scale color */ - long count; /* statistics for each region */ - -} Ilist; - -#ifdef __cplusplus -} -#endif - -#endif /* _POSTMD_H */ diff --git a/usr/src/cmd/lp/filter/postscript/postplot/Makefile b/usr/src/cmd/lp/filter/postscript/postplot/Makefile deleted file mode 100644 index a9585c824b..0000000000 --- a/usr/src/cmd/lp/filter/postscript/postplot/Makefile +++ /dev/null @@ -1,77 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# ident "%Z%%M% %I% %E% SMI" -# -# Copyright 1989-2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/lp/filter/postscript/postplot/Makefile -# - -include ../../../Makefile.lp - -PROG= postplot - -SRCS= postplot.c - -OBJS = $(SRCS:%.c=%.o) - -COMMONDIR = ../common - -COMMONOBJS = $(COMMONDIR)/request.o \ - $(COMMONDIR)/glob.o \ - $(COMMONDIR)/misc.o - -TXTS= README - -ENCODING = 2 -CPPFLAGS = -DDFLTENCODING=$(ENCODING) \ - -I. -I$(COMMONDIR) \ - $(CPPFLAGS.master) - -POFILE = lp_filter_postscript_postplot.po - -.KEEP_STATE: - -all: $(TXTS) $(PROG) - -install: all $(ROOTLIBLPPOSTPROG) - -$(PROG): $(OBJS) $(COMMONOBJS) - $(LINK.c) -o $@ $(OBJS) $(COMMONOBJS) $(LDLIBS) - $(POST_PROCESS) - -$(COMMONOBJS): $$(@:%.o=%.c) - cd $(@D); $(MAKE) $(@F) - -clean: - $(RM) $(OBJS) - -strip: - $(STRIP) $(PROG) - -lint: lint_SRCS - -include ../../../../Makefile.targ - -include ../Makefile.msg diff --git a/usr/src/cmd/lp/filter/postscript/postplot/README b/usr/src/cmd/lp/filter/postscript/postplot/README deleted file mode 100644 index 9d0a5d3222..0000000000 --- a/usr/src/cmd/lp/filter/postscript/postplot/README +++ /dev/null @@ -1,26 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ -A PostScript translator for plot(4) graphics files. Only supporting System V's -version of plot - Ninth Edition Unix systems will probably need a separate -translator. - diff --git a/usr/src/cmd/lp/filter/postscript/postplot/postplot.c b/usr/src/cmd/lp/filter/postscript/postplot/postplot.c deleted file mode 100644 index 93819f1ede..0000000000 --- a/usr/src/cmd/lp/filter/postscript/postplot/postplot.c +++ /dev/null @@ -1,828 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * - * postplot - PostScript translator for Unix (System V) plot files. - * - * Only support (currently) is for the System V version of plot. Ninth Edition - * plot is completely different and probably will need a separate translator. - * If character placement appears to be off a bit try changing the definitions - * of xtextshift and ytextshift in the prologue. Didn't spend much time trying - * to speed things up - there's undoubtedly much that could still be done. - * - * The program expects that the following PostScript procedures are defined in - * the prologue: - * - * setup - * - * mark ... setup - - * - * Handles special initialization stuff that depends on how this program - * was called. Expects to find a mark followed by key/value pairs on the - * stack. The def operator is applied to each pair up to the mark, then - * the default state is set up. - * - * pagesetup - * - * page pagesetup - - * - * Does whatever is needed to set things up for the next page. Expect - * to find the current page number on the stack. - * - * space - * - * height width space - - * - * Defines the height and width of the image space. Called outside page - * level save/restore so the definitions are permanent. Typically called - * once at the beginning of each job. - * - * setupspace - * - * setupspace - * - * Finishes setting up the page coordinate system using the height and - * width definitions made by space (above). Usually called at the start - * of each page. - * - * l - * - * x0 y0 x1 y1 l - - * - * Draws a line from (x0, y0) to (x1, y1). - * - * n - * - * x y n - - * - * Adds the line segment from (hpos, vpos) to (x, y) to the current - * path. - * - * p - * - * x y p - - * - * Marks point (x, y) with a filled circle whose radius varies with - * the linewidth. - * - * c - * - * x y r c - - * - * Draws a circle of radius r centered at (x, y). - * - * a - * - * x y dx1 dy1 dx2 dy2 a - - * - * Draws a counterclockwise arc centered at (x, y) through (x+dx1, y+dy1) - * to (x+dx2, y+dy2). - * - * t - * - * s x y t - - * - * Prints string s starting at (x, y). xtextshift and ytextshift provide - * additional control over the placement of text strings. - * - * f - * - * array f - - * - * Selects the line style (e.g. dotted) according to the pattern in array. - * - * m - * - * x y m - * - * Starts a new path that begins at (x, y) - only used with connected - * lines. - * - * s - * - * s - * - * Strokes the current path - again only used with connected lines. - * - * done - * - * done - * - * Makes sure the last page is printed. Only needed when we're printing - * more than one page on each sheet of paper. - * - * The default line width is zero, which forces lines to be one pixel wide. That - * works well on 'write to black' engines but won't be right for 'write to white' - * engines. The line width can be changed using the -w option, or you can change - * the initialization of linewidth in the prologue. - * - */ - -#include <stdio.h> -#include <signal.h> -#include <ctype.h> -#include <fcntl.h> - -#include "comments.h" /* PostScript file structuring comments */ -#include "gen.h" /* general purpose definitions */ -#include "path.h" /* for the prologue */ -#include "ext.h" /* external variable declarations */ -#include "postplot.h" /* a few special definitions */ - -char *optnames = "a:c:f:m:n:o:p:s:w:x:y:A:C:J:L:P:R:DI"; - -char *prologue = POSTPLOT; /* default PostScript prologue */ -char *formfile = FORMFILE; /* stuff for multiple pages per sheet */ - -int formsperpage = 1; /* page images on each piece of paper */ -int copies = 1; /* and this many copies of each sheet */ - -int hpos; /* current horizontal */ -int vpos; /* and vertical position */ - -Styles styles[] = STYLES; /* recognized line styles */ -int linestyle = 0; /* index into styles[] */ - -Fontmap fontmap[] = FONTMAP; /* for translating font names */ -char *fontname = "Courier"; /* use this PostScript font */ - -int page = 0; /* page we're working on */ -int printed = 0; /* printed this many pages */ - -FILE *fp_in = stdin; /* read from this file */ -FILE *fp_out = stdout; /* and write stuff here */ -FILE *fp_acct = NULL; /* for accounting data */ - -static void account(void); -static void arguments(void); -static void connect(void); -static void done(void); -static void formfeed(void); -static char *get_font(char *); -static int getint(void); -static void getstring(char *); -static void header(void); -static void init_signals(void); -static void options(void); -static void plot(void); -static void redirect(int); -static void setstyle(char *); -static void setup(void); - -/*****************************************************************************/ - -int -main(int agc, char *agv[]) -{ - -/* - * - * Plot to PostScript translator for System V only. - * - */ - - argc = agc; /* other routines may want them */ - argv = agv; - - prog_name = argv[0]; /* really just for error messages */ - - init_signals(); /* sets up interrupt handling */ - header(); /* PostScript header and prologue */ - options(); /* handle the command line options */ - setup(); /* for PostScript */ - arguments(); /* followed by each input file */ - done(); /* print the last page etc. */ - account(); /* job accounting data */ - - return (x_stat); /* not much could be wrong */ - -} /* End of main */ - -/*****************************************************************************/ - -static void -init_signals(void) -{ - void interrupt(); /* signal handler */ - -/* - * - * Makes sure we handle interrupts. - * - */ - - if ( signal(SIGINT, interrupt) == SIG_IGN ) { - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - signal(SIGHUP, SIG_IGN); - } else { - signal(SIGHUP, interrupt); - signal(SIGQUIT, interrupt); - } /* End else */ - - signal(SIGTERM, interrupt); - -} /* End of init_signals */ - -/*****************************************************************************/ - -static void -header(void) -{ - int ch; /* return value from getopt() */ - int old_optind = optind; /* for restoring optind - should be 1 */ - -/* - * - * Scans the option list looking for things, like the prologue file, that we need - * right away but could be changed from the default. Doing things this way is an - * attempt to conform to Adobe's latest file structuring conventions. In particular - * they now say there should be nothing executed in the prologue, and they have - * added two new comments that delimit global initialization calls. Once we know - * where things really are we write out the job header, follow it by the prologue, - * and then add the ENDPROLOG and BEGINSETUP comments. - * - */ - - while ( (ch = getopt(argc, argv, optnames)) != EOF ) - if ( ch == 'L' ) - prologue = optarg; - else if ( ch == '?' ) - error(FATAL, ""); - - optind = old_optind; /* get ready for option scanning */ - - fprintf(stdout, "%s", CONFORMING); - fprintf(stdout, "%s %s\n", VERSION, PROGRAMVERSION); - fprintf(stdout, "%s %s\n", DOCUMENTFONTS, ATEND); - fprintf(stdout, "%s %s\n", PAGES, ATEND); - fprintf(stdout, "%s", ENDCOMMENTS); - - if ( cat(prologue) == FALSE ) - error(FATAL, "can't read %s", prologue); - - fprintf(stdout, "%s", ENDPROLOG); - fprintf(stdout, "%s", BEGINSETUP); - fprintf(stdout, "mark\n"); - -} /* End of header */ - -/*****************************************************************************/ - -static void -options(void) -{ - int ch; /* return value from getopt() */ - -/* - * - * Reads and processes the command line options. Added the -P option so arbitrary - * PostScript code can be passed through. Expect it could be useful for changing - * definitions in the prologue for which options have not been defined. - * - */ - - while ( (ch = getopt(argc, argv, optnames)) != EOF ) { - - switch ( ch ) { - - case 'a': /* aspect ratio */ - fprintf(stdout, "/aspectratio %s def\n", optarg); - break; - - case 'c': /* copies */ - copies = atoi(optarg); - fprintf(stdout, "/#copies %s store\n", optarg); - break; - - case 'f': /* use this PostScript font */ - fontname = get_font(optarg); - fprintf(stdout, "/font /%s def\n", fontname); - break; - - case 'm': /* magnification */ - fprintf(stdout, "/magnification %s def\n", optarg); - break; - - case 'n': /* forms per page */ - formsperpage = atoi(optarg); - fprintf(stdout, "%s %s\n", FORMSPERPAGE, optarg); - fprintf(stdout, "/formsperpage %s def\n", optarg); - break; - - case 'o': /* output page list */ - out_list(optarg); - break; - - case 'p': /* landscape or portrait mode */ - if ( *optarg == 'l' ) - fprintf(stdout, "/landscape true def\n"); - else fprintf(stdout, "/landscape false def\n"); - break; - - case 's': /* point size */ - fprintf(stdout, "/size %s def\n", optarg); - break; - - case 'w': /* line width */ - fprintf(stdout, "/linewidth %s def\n", optarg); - break; - - case 'x': /* shift things horizontally */ - fprintf(stdout, "/xoffset %s def\n", optarg); - break; - - case 'y': /* and vertically on the page */ - fprintf(stdout, "/yoffset %s def\n", optarg); - break; - - case 'A': /* force job accounting */ - case 'J': - if ( (fp_acct = fopen(optarg, "a")) == NULL ) - error(FATAL, "can't open accounting file %s", optarg); - break; - - case 'C': /* copy file straight to output */ - if ( cat(optarg) == FALSE ) - error(FATAL, "can't read %s", optarg); - break; - - case 'L': /* PostScript prologue file */ - prologue = optarg; - break; - - case 'P': /* PostScript pass through */ - fprintf(stdout, "%s\n", optarg); - break; - - case 'R': /* special global or page level request */ - saverequest(optarg); - break; - - case 'D': /* debug flag */ - debug = ON; - break; - - case 'I': /* ignore FATAL errors */ - ignore = ON; - break; - - case '?': /* don't understand the option */ - error(FATAL, ""); - break; - - default: /* don't know what to do for ch */ - error(FATAL, "missing case for option %c\n", ch); - break; - - } /* End switch */ - - } /* End while */ - - argc -= optind; /* get ready for non-option args */ - argv += optind; - -} /* End of options */ - -/*****************************************************************************/ - -static char * -get_font(char *name) - /* name the user asked for */ -{ - int i; /* for looking through fontmap[] */ - -/* - * - * Called from options() to map a user's font name into a legal PostScript name. - * If the lookup fails *name is returned to the caller. That should let you choose - * any PostScript font. - * - */ - - for ( i = 0; fontmap[i].name != NULL; i++ ) - if ( strcmp(name, fontmap[i].name) == 0 ) - return(fontmap[i].val); - - return(name); - -} /* End of get_font */ - -/*****************************************************************************/ - -static void -setup(void) -{ - -/* - * - * Handles things that must be done after the options are read but before the - * input files are processed. - * - */ - - writerequest(0, stdout); /* global requests eg. manual feed */ - fprintf(stdout, "setup\n"); - - if ( formsperpage > 1 ) { - if ( cat(formfile) == FALSE ) - error(FATAL, "can't read %s", formfile); - fprintf(stdout, "%d setupforms\n", formsperpage); - } /* End if */ - - fprintf(stdout, "%s", ENDSETUP); - -} /* End of setup */ - -/*****************************************************************************/ - -static void -arguments(void) -{ - -/* - * - * Makes sure all the non-option command line arguments are processed. If we get - * here and there aren't any arguments left, or if '-' is one of the input files - * we'll translate stdin. - * - */ - - if ( argc < 1 ) - plot(); - else { /* at least one argument is left */ - while ( argc > 0 ) { - if ( strcmp(*argv, "-") == 0 ) - fp_in = stdin; - else if ( (fp_in = fopen(*argv, "r")) == NULL ) - error(FATAL, "can't open %s", *argv); - plot(); - if ( fp_in != stdin ) - fclose(fp_in); - argc--; - argv++; - } /* End while */ - } /* End else */ - -} /* End of arguments */ - -/*****************************************************************************/ - -static void -plot(void) -{ - - int c; - char s[256]; - int x0,y0,x1,y1; - int xc, yc, r; - int dx0, dy0, dx1, dy1; - int n, i, pat[256]; - -/* - * - * Parser - borrowed directly from tplot source. - * - */ - - redirect(-1); - formfeed(); - - while((c=getc(fp_in)) != EOF) { - switch(c) { - case 'm': - hpos = getint(); - vpos = getint(); - break; - - case 'l': - x0 = getint(); - y0 = getint(); - x1 = getint(); - y1 = getint(); - fprintf(fp_out, "%d %d %d %d l\n", x1, y1, x0, y0); - hpos = x1; - vpos = y1; - break; - - case 't': - getstring(s); - if ( *s != '\0' ) - fprintf(fp_out, "(%s) %d %d t\n", s, hpos, vpos); - break; - - case 'e': - formfeed(); - break; - - case 'p': - hpos = getint(); - vpos = getint(); - fprintf(fp_out, "%d %d p\n", hpos, vpos); - break; - - case 'n': - ungetc(c, fp_in); - connect(); - break; - - case 's': - x0 = getint(); - y0 = getint(); - x1 = getint(); - y1 = getint(); - fprintf(fp_out, "cleartomark restore\n"); - fprintf(fp_out, "%d %d space\n", x1-x0, y1-y0); - fprintf(fp_out, "save mark\n"); - fprintf(fp_out, "setupspace\n"); - fprintf(fp_out, "%s f\n", styles[linestyle].val); - break; - - case 'a': - xc = getint(); - yc = getint(); - x0 = getint(); - y0 = getint(); - x1 = getint(); - y1 = getint(); - dx0 = x0 - xc; - dy0 = y0 - yc; - dx1 = x1 - xc; - dy1 = y1 - yc; - if ( (dx0 != 0 || dy0 != 0) && (dx1 != 0 || dy1 != 0) ) - fprintf(fp_out, "%d %d %d %d %d %d a\n", xc, yc, dx0, dy0, dx1, dy1); - break; - - case 'c': - xc = getint(); - yc = getint(); - r = getint(); - fprintf(fp_out, "%d %d %d c\n", xc, yc, r); - break; - - case 'f': - getstring(s); - setstyle(s); - break; - - case 'd': /* undocumented and unimplemented */ - x0 = getint(); - y0 = getint(); - dx0 = getint(); - n = getint(); - for(i=0; i<n; i++)pat[i] = getint(); - /*dot(x0,y0,dx0,n,pat);*/ - break; - - default: - error(FATAL, "unknown command %o\n", c); - - } /* End switch */ - - } /* End while */ - - formfeed(); - -} /* End of plot */ - -/*****************************************************************************/ - -static void -connect(void) -{ - - int c; - int x, y; - int count = 0; /* so the path doesn't get to big */ - -/* - * - * Reads consecutive connect commands from the input file. Can't let the path - * get too big, so it's occasionally stroked. - * - */ - - fprintf(fp_out, "%d %d m\n", hpos, vpos); - - while ( (c = getc(fp_in)) == 'n' ) { - if ( count++ > 100 ) { - fprintf(fp_out, "s\n%d %d m\n", hpos, vpos); - count = 1; - } /* End if */ - x = getint(); - y = getint(); - fprintf(fp_out, "%d %d n\n", x, y); - hpos = x; - vpos = y; - } /* End while */ - - fprintf(fp_out, "s\n"); - ungetc(c, fp_in); - -} /* End of connect */ - -/*****************************************************************************/ - -static void -setstyle(char *str) -{ - int i; - -/* - * - * Selects the line style that matches *str. No match resets the style to solid - * (unless you've changed STYLES in postplot.h). - * - */ - - for ( i = 0; styles[i].name != NULL; i++ ) - if ( strcmp(styles[i].name, str) == 0 ) - break; - - if ( styles[i].val != NULL ) { - linestyle = i; - fprintf(fp_out, "%s f\n", styles[linestyle].val); - } /* End if */ - -} /* End of setstyle */ - -/*****************************************************************************/ - -static int -getint(void) -{ - short a, b; - -/* - * - * Returns the integer stored in the next two bytes. - * - */ - - if((b = getc(fp_in)) == EOF) - return(EOF); - if((a = getc(fp_in)) == EOF) - return(EOF); - - a = a<<8; - return(a|b); - -} /* End of getint */ - -/*****************************************************************************/ - -static void -getstring(char *s) -{ - - int c; - -/* - * - * Reads characters, up to a newline, and stores the quoted string in s. - * - */ - - for( ; (c = getc(fp_in)) != EOF; s++) { - if ( c == '(' || c == ')' || c == '\\' ) - *s++ = '\\'; - if( (*s = c) == '\n' ) - break; - } /* End for */ - - *s = '\0'; - -} /* End of getstring */ - -/*****************************************************************************/ - -static void -done(void) -{ - -/* - * - * Finished with all the input files, so mark the end of the pages with a TRAILER - * comment, make sure the last page prints, and add things like the PAGES comment - * that can only be determined after all the input files have been read. - * - */ - - fprintf(stdout, "%s", TRAILER); - fprintf(stdout, "done\n"); - fprintf(stdout, "%s %s\n", DOCUMENTFONTS, fontname); - fprintf(stdout, "%s %d\n", PAGES, printed); - -} /* End of done */ - -/*****************************************************************************/ - -static void -account(void) -{ - -/* - * - * Writes an accounting record to *fp_acct provided it's not NULL. Accounting is - * requested using the -A or -J options. - * - */ - - if ( fp_acct != NULL ) - fprintf(fp_acct, " print %d\n copies %d\n", printed, copies); - -} /* End of account */ - -/*****************************************************************************/ - -static void -formfeed(void) -{ - -/* - * - * Called whenever we've finished with the last page and want to get ready for the - * next one. Also used at the beginning and end of each input file, so we have to - * be careful about what's done. The first time through (up to the redirect() call) - * output goes to /dev/null. - * - * Adobe now recommends that the showpage operator occur after the page level - * restore so it can be easily redefined to have side-effects in the printer's VM. - * Although it seems reasonable I haven't implemented it, because it makes other - * things, like selectively setting manual feed or choosing an alternate paper - * tray, clumsy - at least on a per page basis. - * - */ - - if ( fp_out == stdout ) /* count the last page */ - printed++; - - fprintf(fp_out, "cleartomark\n"); - fprintf(fp_out, "showpage\n"); - fprintf(fp_out, "restore\n"); - fprintf(fp_out, "%s %d %d\n", ENDPAGE, page, printed); - - if ( ungetc(getc(fp_in), fp_in) == EOF ) - redirect(-1); - else redirect(++page); - - fprintf(fp_out, "%s %d %d\n", PAGE, page, printed+1); - fprintf(fp_out, "save\n"); - fprintf(fp_out, "mark\n"); - writerequest(printed+1, fp_out); - fprintf(fp_out, "%d pagesetup\n", printed+1); - fprintf(fp_out, "setupspace\n"); - fprintf(fp_out, "%s f\n", styles[linestyle].val); - -} /* End of formfeed */ - -/*****************************************************************************/ - -static void -redirect(int pg) - /* next page we're printing */ -{ - static FILE *fp_null = NULL; /* if output is turned off */ - -/* - * - * If we're not supposed to print page pg, fp_out will be directed to /dev/null, - * otherwise output goes to stdout. - * - */ - - if ( pg >= 0 && in_olist(pg) == ON ) - fp_out = stdout; - else if ( (fp_out = fp_null) == NULL ) - fp_out = fp_null = fopen("/dev/null", "w"); - -} /* End of redirect */ diff --git a/usr/src/cmd/lp/filter/postscript/postplot/postplot.h b/usr/src/cmd/lp/filter/postscript/postplot/postplot.h deleted file mode 100644 index a6251d8b70..0000000000 --- a/usr/src/cmd/lp/filter/postscript/postplot/postplot.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -#ifndef _POSTPLOT_H -#define _POSTPLOT_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * - * Definitions used by the PostScript translator for Unix plot files. - * - * Recognized line styles are saved in an array of type Styles that's initialized - * using STYLES. - * - */ - -typedef struct { - - char *name; - char *val; - -} Styles; - -#define STYLES \ - \ - { \ - "solid", "[]", \ - "dotted", "[.5 2]", \ - "dashed", "[4 4]", \ - "dotdashed", "[.5 2 4 2]", \ - "shortdashed", "[4 4]", \ - "longdashed", "[8 8]", \ - NULL, "[]" \ - } - -/* - * - * An array of type Fontmap helps convert font names requested by users into - * legitimate PostScript names. The array is initialized using FONTMAP, which must - * end with an entry that has NULL defined as its name field. The only fonts that - * are guaranteed to work well are the constant width fonts. - * - */ - -typedef struct { - - char *name; /* user's font name */ - char *val; /* corresponding PostScript name */ - -} Fontmap; - -#define FONTMAP \ - \ - { \ - "R", "Courier", \ - "I", "Courier-Oblique", \ - "B", "Courier-Bold", \ - "CO", "Courier", \ - "CI", "Courier-Oblique", \ - "CB", "Courier-Bold", \ - "CW", "Courier", \ - "PO", "Courier", \ - "courier", "Courier", \ - "cour", "Courier", \ - "co", "Courier", \ - NULL, NULL \ - } - -#ifdef __cplusplus -} -#endif - -#endif /* _POSTPLOT_H */ diff --git a/usr/src/cmd/lp/filter/postscript/postscript/Makefile b/usr/src/cmd/lp/filter/postscript/postscript/Makefile index 92fff2d723..89e914697d 100644 --- a/usr/src/cmd/lp/filter/postscript/postscript/Makefile +++ b/usr/src/cmd/lp/filter/postscript/postscript/Makefile @@ -19,7 +19,6 @@ # CDDL HEADER END # # -# ident "%Z%%M% %I% %E% SMI" # # Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. @@ -42,12 +41,7 @@ FILES = \ draw.ps \ fatcourier.ps \ forms.ps \ - postdaisy.ps \ - postdmd.ps \ - postmd.ps \ - postplot.ps \ postprint.ps \ - posttek.ps \ ps.requests \ tsol_banner.ps \ tsol_separator.ps \ diff --git a/usr/src/cmd/lp/filter/postscript/posttek/Makefile b/usr/src/cmd/lp/filter/postscript/posttek/Makefile deleted file mode 100644 index 9123bb7fe7..0000000000 --- a/usr/src/cmd/lp/filter/postscript/posttek/Makefile +++ /dev/null @@ -1,77 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# ident "%Z%%M% %I% %E% SMI" -# -# Copyright 1989-2002 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/lp/filter/postscript/posttek/Makefile -# - -include ../../../Makefile.lp - -PROG= posttek - -SRCS= posttek.c - -OBJS = $(SRCS:%.c=%.o) - -COMMONDIR = ../common - -COMMONOBJS = $(COMMONDIR)/request.o \ - $(COMMONDIR)/glob.o \ - $(COMMONDIR)/misc.o - -TXTS= README - -ENCODING = 2 -CPPFLAGS = -DDFLTENCODING=$(ENCODING) \ - -I. -I$(COMMONDIR) \ - $(CPPFLAGS.master) - -POFILE = lp_filter_postscript_posttek.po - -.KEEP_STATE: - -all: $(TXTS) $(PROG) - -install: all $(ROOTLIBLPPOSTPROG) - -$(PROG): $(OBJS) $(COMMONOBJS) - $(LINK.c) -o $@ $(OBJS) $(COMMONOBJS) $(LDLIBS) - $(POST_PROCESS) - -$(COMMONOBJS): $$(@:%.o=%.c) - cd $(@D); $(MAKE) $(@F) - -clean: - $(RM) $(OBJS) - -strip: - $(STRIP) $(PROG) - -lint: lint_SRCS - -include ../../../../Makefile.targ - -include ../Makefile.msg diff --git a/usr/src/cmd/lp/filter/postscript/posttek/README b/usr/src/cmd/lp/filter/postscript/posttek/README deleted file mode 100644 index a2fd364345..0000000000 --- a/usr/src/cmd/lp/filter/postscript/posttek/README +++ /dev/null @@ -1,35 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -Source code for a program that translates tektronix 4014 files into PostScript. -Much of the code was borrowed from the 5620 tektronix emulator. Defocused mode -should work and code that ties lines to device space coordinates has been added -to ../postscript/posttek.ps. Helps eliminate the variation in line widths that -were often noticeable when a non-zero linewidth was selected (eg. with the -w -option). - -The graphics state line width (variable linewidth in ../postscript/posttek.ps) -has been initialized to 0, which gets you one pixel wide lines. That gives good -results on write-black engines, like the one used in the PS-800, but is lacking -on write-white printers like the PS-2400. Use the -w option or redefine linewidth -in file ../postscript/posttek.ps if you want a different line width. - diff --git a/usr/src/cmd/lp/filter/postscript/posttek/posttek.c b/usr/src/cmd/lp/filter/postscript/posttek/posttek.c deleted file mode 100644 index 5cc35e1dd1..0000000000 --- a/usr/src/cmd/lp/filter/postscript/posttek/posttek.c +++ /dev/null @@ -1,1326 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * - * posttek - PostScript translator for tektronix 4014 files - * - * A program that can be used to translate tektronix 4014 files into PostScript. - * Most of the code was borrowed from the tektronix 4014 emulator that was written - * for DMDs. Things have been cleaned up some, but there's still plently that - * could be done. - * - * The PostScript prologue is copied from *prologue before any of the input files - * are translated. The program expects that the following PostScript procedures - * are defined in that file: - * - * setup - * - * mark ... setup - - * - * Handles special initialization stuff that depends on how the program - * was called. Expects to find a mark followed by key/value pairs on the - * stack. The def operator is applied to each pair up to the mark, then - * the default state is set up. - * - * pagesetup - * - * page pagesetup - - * - * Does whatever is needed to set things up for the next page. Expects - * to find the current page number on the stack. - * - * v - * - * mark dx1 dy1 ... dxn dyn x y v mark - * - * Draws the vector described by the numbers on the stack. The top two - * numbers are the starting point. The rest are relative displacements - * from the preceeding point. Must make sure we don't put too much on - * the stack! - * - * t - * - * x y string t - - * - * Prints the string that's on the top of the stack starting at point - * (x, y). - * - * p - * - * x y p - - * - * Marks the point (x, y) with a circle whose radius varies with the - * current intensity setting. - * - * i - * - * percent focus i - - * - * Changes the size of the circle used to mark individual points to - * percent of maximum for focused mode (focus=1) or defocused mode - * (focus=0). The implementation leaves much to be desired! - * - * l - * - * mark array l mark - * - * Set the line drawing mode according to the description given in array. - * The arrays that describe the different line styles are declared in - * STYLES (file posttek.h). The array really belongs in the prologue! - * - * w - * - * n w - - * - * Adjusts the line width for vector drawing. Used to select normal (n=0) - * or defocused (n=1) mode. - * - * f - * - * size f - - * - * Changes the size of the font that's used to print characters in alpha - * mode. size is the tektronix character width and is used to choose an - * appropriate point size in the current font. - * - * done - * - * done - * - * Makes sure the last page is printed. Only needed when we're printing - * more than one page on each sheet of paper. - * - * The default line width is zero, which forces lines to be one pixel wide. That - * works well on 'write to black' engines but won't be right for 'write to white' - * engines. The line width can be changed using the -w option, or you can change - * the initialization of linewidth in the prologue. - * - * Many default values, like the magnification and orientation, are defined in - * the prologue, which is where they belong. If they're changed (by options), an - * appropriate definition is made after the prologue is added to the output file. - * The -P option passes arbitrary PostScript through to the output file. Among - * other things it can be used to set (or change) values that can't be accessed by - * other options. - * - */ - - -#include <stdio.h> -#include <signal.h> -#include <fcntl.h> - -#include "comments.h" /* PostScript file structuring comments */ -#include "gen.h" /* general purpose definitions */ -#include "path.h" /* for the prologue */ -#include "ext.h" /* external variable definitions */ -#include "posttek.h" /* control codes and other definitions */ - - -char *optnames = "a:c:f:m:n:o:p:w:x:y:A:C:J:L:P:R:DI"; - -char *prologue = POSTTEK; /* default PostScript prologue */ -char *formfile = FORMFILE; /* stuff for multiple pages per sheet */ - -int formsperpage = 1; /* page images on each piece of paper */ -int copies = 1; /* and this many copies of each sheet */ - -int charheight[] = CHARHEIGHT; /* height */ -int charwidth[] = CHARWIDTH; /* and width arrays for tek characters */ -int tekfont = TEKFONT; /* index into charheight[] and charwidth[] */ - -char intensity[] = INTENSITY; /* special point intensity array */ -char *styles[] = STYLES; /* description of line styles */ -int linestyle = 0; /* index into styles[] */ -int linetype = 0; /* 0 for normal, 1 for defocused */ - -int dispmode = ALPHA; /* current tektronix state */ -int points = 0; /* points making up the current vector */ -int characters = 0; /* characters waiting to be printed */ -int pen = UP; /* just for point plotting */ -int margin = 0; /* left edge - ALPHA state */ - -Point cursor; /* should be current cursor position */ - -Fontmap fontmap[] = FONTMAP; /* for translating font names */ -char *fontname = "Courier"; /* use this PostScript font */ - -int page = 0; /* page we're working on */ -int printed = 0; /* printed this many pages */ - -FILE *fp_in; /* read from this file */ -FILE *fp_out = stdout; /* and write stuff here */ -FILE *fp_acct = NULL; /* for accounting data */ - -static void account(void); -static void alpha(void); -static void arguments(void); -static int control(int); -static int esc(void); -static void done(void); -static void draw(void); -static void formfeed(void); -static void gin(void); -static void graph(void); -static void header(void); -static void home(void); -static void incremental(void); -static void init_signals(void); -static void move(int, int); -static int nextchar(void); -static void options(void); -static void point(void); -static void redirect(int); -static void reset(void); -static void setfont(int); -static void setmode(int); -static void setup(void); -static void statemachine(FILE *); -static void text(void); - - -/*****************************************************************************/ - - -int -main(int agc, char *agv[]) -{ - -/* - * - * A simple program that can be used to translate tektronix 4014 files into - * PostScript. Most of the code was taken from the DMD tektronix 4014 emulator, - * although things have been cleaned up some. - * - */ - - argv = agv; /* so everyone can use them */ - argc = agc; - - prog_name = argv[0]; /* just for error messages */ - - init_signals(); /* sets up interrupt handling */ - header(); /* PostScript header comments */ - options(); /* handle the command line options */ - setup(); /* for PostScript */ - arguments(); /* followed by each input file */ - done(); /* print the last page etc. */ - account(); /* job accounting data */ - - return (x_stat); /* nothing could be wrong */ - -} /* End of main */ - - -/*****************************************************************************/ - - -static void -init_signals(void) -{ - void interrupt(); /* signal handler */ - -/* - * - * Make sure we handle interrupts. - * - */ - - - if ( signal(SIGINT, interrupt) == SIG_IGN ) { - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - signal(SIGHUP, SIG_IGN); - } else { - signal(SIGHUP, interrupt); - signal(SIGQUIT, interrupt); - } /* End else */ - - signal(SIGTERM, interrupt); - -} /* End of init_signals */ - - -/*****************************************************************************/ - - -static void -header(void) -{ - int ch; /* return value from getopt() */ - int old_optind = optind; /* for restoring optind - should be 1 */ - -/* - * - * Scans the option list looking for things, like the prologue file, that we need - * right away but could be changed from the default. Doing things this way is an - * attempt to conform to Adobe's latest file structuring conventions. In particular - * they now say there should be nothing executed in the prologue, and they have - * added two new comments that delimit global initialization calls. Once we know - * where things really are we write out the job header, follow it by the prologue, - * and then add the ENDPROLOG and BEGINSETUP comments. - * - */ - - - while ( (ch = getopt(argc, argv, optnames)) != EOF ) - if ( ch == 'L' ) - prologue = optarg; - else if ( ch == '?' ) - error(FATAL, ""); - - optind = old_optind; /* get ready for option scanning */ - - fprintf(stdout, "%s", CONFORMING); - fprintf(stdout, "%s %s\n", VERSION, PROGRAMVERSION); - fprintf(stdout, "%s %s\n", DOCUMENTFONTS, ATEND); - fprintf(stdout, "%s %s\n", PAGES, ATEND); - fprintf(stdout, "%s", ENDCOMMENTS); - - if ( cat(prologue) == FALSE ) - error(FATAL, "can't read %s", prologue); - - fprintf(stdout, "%s", ENDPROLOG); - fprintf(stdout, "%s", BEGINSETUP); - fprintf(stdout, "mark\n"); - -} /* End of header */ - - -/*****************************************************************************/ - - -static void -options(void) -{ - int ch; /* value returned by getopt() */ - -/* - * - * Reads and processes the command line options. Added the -P option so arbitrary - * PostScript code can be passed through. Expect it could be useful for changing - * definitions in the prologue for which options have not been defined. - * - */ - - - while ( (ch = getopt(argc, argv, optnames)) != EOF ) { - - switch ( ch ) { - - case 'a': /* aspect ratio */ - fprintf(stdout, "/aspectratio %s def\n", optarg); - break; - - case 'c': /* copies */ - copies = atoi(optarg); - fprintf(stdout, "/#copies %s store\n", optarg); - break; - - case 'f': /* use this PostScript font */ - fontname = get_font(optarg); - fprintf(stdout, "/font /%s def\n", fontname); - break; - - case 'm': /* magnification */ - fprintf(stdout, "/magnification %s def\n", optarg); - break; - - case 'n': /* forms per page */ - formsperpage = atoi(optarg); - fprintf(stdout, "%s %s\n", FORMSPERPAGE, optarg); - fprintf(stdout, "/formsperpage %s def\n", optarg); - break; - - case 'o': /* output page list */ - out_list(optarg); - break; - - case 'p': /* landscape or portrait mode */ - if ( *optarg == 'l' ) - fprintf(stdout, "/landscape true def\n"); - else fprintf(stdout, "/landscape false def\n"); - break; - - case 'w': /* line width */ - fprintf(stdout, "/linewidth %s def\n", optarg); - break; - - case 'x': /* shift horizontally */ - fprintf(stdout, "/xoffset %s def\n", optarg); - break; - - case 'y': /* and vertically on the page */ - fprintf(stdout, "/yoffset %s def\n", optarg); - break; - - case 'A': /* force job accounting */ - case 'J': - if ( (fp_acct = fopen(optarg, "a")) == NULL ) - error(FATAL, "can't open accounting file %s", optarg); - break; - - case 'C': /* copy file straight to output */ - if ( cat(optarg) == FALSE ) - error(FATAL, "can't read %s", optarg); - break; - - case 'L': /* PostScript prologue file */ - prologue = optarg; - break; - - case 'P': /* PostScript pass through */ - fprintf(stdout, "%s\n", optarg); - break; - - case 'R': /* special global or page level request */ - saverequest(optarg); - break; - - case 'D': /* debug flag */ - debug = ON; - break; - - case 'I': /* ignore FATAL errors */ - ignore = ON; - break; - - case '?': /* don't know the option */ - error(FATAL, ""); - break; - - default: /* don't know what to do for ch */ - error(FATAL, "missing case for option %c", ch); - break; - - } /* End switch */ - - } /* End while */ - - argc -= optind; - argv += optind; - -} /* End of options */ - - -/*****************************************************************************/ - - -char *get_font(name) - - - char *name; /* name the user asked for */ - - -{ - - - int i; /* for looking through fontmap[] */ - - -/* - * - * Called from options() to map a user's font name into a legal PostScript name. - * If the lookup fails *name is returned to the caller. That should let you choose - * any PostScript font. - * - */ - - - for ( i = 0; fontmap[i].name != NULL; i++ ) - if ( strcmp(name, fontmap[i].name) == 0 ) - return(fontmap[i].val); - - return(name); - -} /* End of get_font */ - - -/*****************************************************************************/ - -static void -setup(void) -{ - -/* - * - * Handles things that must be done after the options are read but before the - * input files are processed. - * - */ - - - writerequest(0, stdout); /* global requests eg. manual feed */ - fprintf(stdout, "setup\n"); - - if ( formsperpage > 1 ) { - if ( cat(formfile) == FALSE ) - error(FATAL, "can't read %s", formfile); - fprintf(stdout, "%d setupforms\n", formsperpage); - } /* End if */ - - fprintf(stdout, "%s", ENDSETUP); - -} /* End of setup */ - - -/*****************************************************************************/ - - -static void -arguments(void) -{ - -/* - * - * Makes sure all the non-option command line arguments are processed. If we get - * here and there aren't any arguments left, or if '-' is one of the input files - * we'll process stdin. - * - */ - - - if ( argc < 1 ) - statemachine(fp_in = stdin); - else { /* at least one argument is left */ - while ( argc > 0 ) { - if ( strcmp(*argv, "-") == 0 ) - fp_in = stdin; - else if ( (fp_in = fopen(*argv, "r")) == NULL ) - error(FATAL, "can't open %s", *argv); - statemachine(fp_in); - if ( fp_in != stdin ) - fclose(fp_in); - argc--; - argv++; - } /* End while */ - } /* End else */ - -} /* End of arguments */ - - -/*****************************************************************************/ - - -static void -done(void) -{ - -/* - * - * Finished with all the input files, so mark the end of the pages with a TRAILER - * comment, make sure the last page prints, and add things like the PAGES comment - * that can only be determined after all the input files have been read. - * - */ - - - fprintf(stdout, "%s", TRAILER); - fprintf(stdout, "done\n"); - fprintf(stdout, "%s %s\n", DOCUMENTFONTS, fontname); - fprintf(stdout, "%s %d\n", PAGES, printed); - -} /* End of done */ - - -/*****************************************************************************/ - - -static void -account(void) -{ - -/* - * - * Writes an accounting record to *fp_acct provided it's not NULL. Accounting - * is requested using the -A or -J options. - * - */ - - - if ( fp_acct != NULL ) - fprintf(fp_acct, " print %d\n copies %d\n", printed, copies); - -} /* End of account */ - - -/*****************************************************************************/ - - -static void -statemachine(FILE *fp) - /* used to set fp_in */ -{ - -/* - * - * Controls the translation of the next input file. Tektronix states (dispmode) - * are typically changed in control() and esc(). - * - */ - - - redirect(-1); /* get ready for the first page */ - formfeed(); - dispmode = RESET; - - while ( 1 ) - - switch ( dispmode ) { - - case RESET: - reset(); - break; - - case ALPHA: - alpha(); - break; - - case GIN: - gin(); - break; - - case GRAPH: - graph(); - break; - - case POINT: - case SPECIALPOINT: - point(); - break; - - case INCREMENTAL: - incremental(); - break; - - case EXIT: - formfeed(); - return; - - } /* End switch */ - -} /* End of statemachine */ - - -/*****************************************************************************/ - - -static void -reset(void) -{ - -/* - * - * Called to reset things, typically only at the beginning of each input file. - * - */ - - - tekfont = -1; - home(); - setfont(TEKFONT); - setmode(ALPHA); - -} /* End of reset */ - - -/*****************************************************************************/ - - -static void -alpha(void) -{ - int c; /* next character */ - int x, y; /* cursor will be here when we're done */ - -/* - * - * Takes care of printing characters in the current font. - * - */ - - - if ( (c = nextchar()) == OUTMODED ) - return; - - if ( (c < 040) && ((c = control(c)) <= 0) ) - return; - - x = cursor.x; /* where the cursor is right now */ - y = cursor.y; - - switch ( c ) { - - case DEL: - return; - - case BS: - if ((x -= charwidth[tekfont]) < margin) - x = TEKXMAX - charwidth[tekfont]; - break; - - case NL: - y -= charheight[tekfont]; - break; - - case CR: - x = margin; - break; - - case VT: - if ((y += charheight[tekfont]) >= TEKYMAX) - y = 0; - break; - - case HT: - case ' ': - default: - if ( characters++ == 0 ) - fprintf(fp_out, "%d %d (", cursor.x, cursor.y); - switch ( c ) { - case '(': - case ')': - case '\\': - putc('\\', fp_out); - - default: - putc(c, fp_out); - } /* End switch */ - x += charwidth[tekfont]; - move(x, y); - break; - - } /* End switch */ - - if (x >= TEKXMAX) { - x = margin; - y -= charheight[tekfont]; - } /* End if */ - - if (y < 0) { - y = TEKYMAX - charheight[tekfont]; - x -= margin; - margin = (TEKXMAX/2) - margin; - if ((x += margin) > TEKXMAX) - x -= margin; - } /* End if */ - - if ( y != cursor.y || x != cursor.x ) - text(); - - move(x, y); - -} /* End of alpha */ - - -/*****************************************************************************/ - -static void -graph(void) -{ - int c; /* next character */ - int b; /* for figuring out loy */ - int x, y; /* next point in the vector */ - static int hix, hiy; /* upper */ - static int lox, loy; /* and lower part of the address */ - static int extra; /* for extended addressing */ - -/* - * - * Handles things when we're in GRAPH, POINT, or SPECIALPOINT mode. - * - */ - - if ((c = nextchar()) < 040) { - control(c); - return; - } /* End if */ - - if ((c & 0140) == 040) { /* new hiy */ - hiy = c & 037; - do - if (((c = nextchar()) < 040) && ((c = control(c)) == OUTMODED)) - return; - while (c == 0); - } /* End if */ - - if ((c & 0140) == 0140) { /* new loy */ - b = c & 037; - do - if (((c = nextchar()) < 040) && ((c = control(c)) == OUTMODED)) - return; - while (c == 0); - if ((c & 0140) == 0140) { /* no, it was extra */ - extra = b; - loy = c & 037; - do - if (((c = nextchar()) < 040) && ((c = control(c)) == OUTMODED)) - return; - while (c == 0); - } else loy = b; - } /* End if */ - - if ((c & 0140) == 040) { /* new hix */ - hix = c & 037; - do - if (((c = nextchar()) < 040) && ((c = control(c)) == OUTMODED)) - return; - while (c == 0); - } /* End if */ - - lox = c & 037; /* this should be lox */ - if (extra & 020) - margin = TEKXMAX/2; - - x = (hix<<7) | (lox<<2) | (extra & 03); - y = (hiy<<7) | (loy<<2) | ((extra & 014)>>2); - - if ( points > 100 ) { /* don't put too much on the stack */ - draw(); - points = 1; - } /* End if */ - - if ( points++ ) - fprintf(fp_out, "%d %d\n", cursor.x - x, cursor.y - y); - - move(x, y); /* adjust the cursor */ - -} /* End of graph */ - - -/*****************************************************************************/ - -static void -point(void) -{ - int c; /* next input character */ - -/* - * - * Special point mode permits gray scaling by varying the size of the stored - * point, which is controlled by an intensity character that preceeds each point - * address. - * - */ - - - if ( dispmode == SPECIALPOINT ) { - if ((c = nextchar()) < 040 || c > 0175) { - control(c); - return; - } - - fprintf(fp_out, "%d %d i\n", intensity[c - ' '], c & 0100); - } /* End if */ - - graph(); - draw(); - -} /* End of point */ - - -/*****************************************************************************/ - -static void -incremental(void) -{ - - - int c; /* for the next few characters */ - int x, y; /* cursor position when we're done */ - - -/* - * - * Handles incremental plot mode. It's entered after the RS control code and is - * used to mark points relative to our current position. It's typically followed - * by one or two bytes that set the pen state and are used to increment the - * current position. - * - */ - - - if ( (c = nextchar()) == OUTMODED ) - return; - - if ( (c < 040) && ((c = control(c)) <= 0) ) - return; - - x = cursor.x; /* where we are right now */ - y = cursor.y; - - if ( c & 060 ) - pen = ( c & 040 ) ? UP : DOWN; - - if ( c & 04 ) y++; - if ( c & 010 ) y--; - if ( c & 01 ) x++; - if ( c & 02 ) x--; - - move(x, y); - - if ( pen == DOWN ) { - points = 1; - draw(); - } /* End if */ - -} /* End of incremental */ - - -/*****************************************************************************/ - -static void -gin(void) -{ - -/* - * - * All we really have to do for GIN mode is make sure it's properly ended. - * - */ - - - control(nextchar()); - -} /* End of gin */ - - -/*****************************************************************************/ - -static int -control(int c) - /* check this control character */ -{ - -/* - * - * Checks character c and does special things, like mode changes, that depend - * not only on the character, but also on the current state. If the mode changed - * becuase of c, OUTMODED is returned to the caller. In all other cases the - * return value is c or 0, if c doesn't make sense in the current mode. - * - */ - - - switch ( c ) { - - case BEL: - return(0); - - case BS: - case HT: - case VT: - return(dispmode == ALPHA ? c : 0); - - case CR: - if ( dispmode != ALPHA ) { - setmode(ALPHA); - ungetc(c, fp_in); - return(OUTMODED); - } else return(c); - - case FS: - if ( (dispmode == ALPHA) || (dispmode == GRAPH) ) { - setmode(POINT); - return(OUTMODED); - } /* End if */ - return(0); - - case GS: - if ( (dispmode == ALPHA) || (dispmode == GRAPH) ) { - setmode(GRAPH); - return(OUTMODED); - } /* End if */ - return(0); - - case NL: - ungetc(CR, fp_in); - return(dispmode == ALPHA ? c : 0); - - case RS: - if ( dispmode != GIN ) { - setmode(INCREMENTAL); - return(OUTMODED); - } /* End if */ - return(0); - - case US: - if ( dispmode == ALPHA ) - return(0); - setmode(ALPHA); - return(OUTMODED); - - case ESC: - return(esc()); - - case OUTMODED: - return(c); - - default: - return(c < 040 ? 0 : c); - - } /* End switch */ - -} /* End of control */ - - -/*****************************************************************************/ - - -static int -esc(void) -{ - int c; /* next input character */ - int ignore; /* skip it if nonzero */ - -/* - * - * Handles tektronix escape code. Called from control() whenever an ESC character - * is found in the input file. - * - */ - - - do { - c = nextchar(); - ignore = 0; - switch ( c ) { - - case CAN: - return(0); - - case CR: - ignore = 1; - break; - - case ENQ: - setmode(ALPHA); - return(OUTMODED); - - case ETB: - return(0); - - case FF: - formfeed(); - setmode(ALPHA); - return(OUTMODED); - - case FS: - if ( (dispmode == INCREMENTAL) || ( dispmode == GIN) ) - return(0); - setmode(SPECIALPOINT); - return(OUTMODED); - - case SI: - case SO: - return(0); - - case SUB: - setmode(GIN); - return(OUTMODED); - - case OUTMODED: - return(OUTMODED); - - case '8': - case '9': - case ':': - case ';': - setfont(c - '8'); - return(0); - - default: - if ( c == '?' && dispmode == GRAPH ) - return(DEL); - if ( (c<'`') || (c>'w') ) - break; - c -= '`'; - if ( (c & 010) != linetype ) - fprintf(fp_out, "%d w\n", (linetype = (c & 010))/010); - if ( ((c + 1) & 7) >= 6 ) - break; - if ( (c + 1) & 7 ) - if ( (c & 7) != linestyle ) { - linestyle = c & 7; - setmode(dispmode); - fprintf(fp_out, "%s l\n", styles[linestyle]); - } /* End if */ - return(0); - } /* End switch */ - - } while (ignore); - - return(0); - -} /* End of esc */ - - -/*****************************************************************************/ - - -static void -move(int x, int y) - /* move the cursor here */ -{ - -/* - * - * Moves the cursor to the point (x, y). - * - */ - - - cursor.x = x; - cursor.y = y; - -} /* End of move */ - - -/*****************************************************************************/ - -static void -setmode(int mode) - /* this should be the new mode */ -{ - -/* - * - * Makes sure the current mode is properly ended and then sets dispmode to mode. - * - */ - - - switch ( dispmode ) { - - case ALPHA: - text(); - break; - - case GRAPH: - draw(); - break; - - case INCREMENTAL: - pen = UP; - break; - - } /* End switch */ - - dispmode = mode; - -} /* End of setmode */ - - -/*****************************************************************************/ - -static void -home(void) -{ - -/* - * - * Makes sure the cursor is positioned at the upper left corner of the page. - * - */ - - - margin = 0; - move(0, TEKYMAX); - -} /* End of home */ - - -/*****************************************************************************/ - -static void -setfont(int newfont) - /* use this font next */ -{ - - -/* - * - * Generates the call to the procedure that's responsible for changing the - * tektronix font (really just the size). - * - */ - - - if ( newfont != tekfont ) { - setmode(dispmode); - fprintf(fp_out, "%d f\n", charwidth[newfont]); - } /* End if */ - - tekfont = newfont; - -} /* End of setfont */ - - -/*****************************************************************************/ - -static void -text(void) -{ - -/* - * - * Makes sure any text we've put on the stack is printed. - * - */ - - - if ( dispmode == ALPHA && characters > 0 ) - fprintf(fp_out, ") t\n"); - - characters = 0; - -} /* End of text */ - - -/*****************************************************************************/ - -static void -draw(void) -{ - - -/* - * - * Called whenever we need to draw a vector or plot a point. Nothing will be - * done if points is 0 or if it's 1 and we're in GRAPH mode. - * - */ - - - if ( points > 1 ) /* it's a vector */ - fprintf(fp_out, "%d %d v\n", cursor.x, cursor.y); - else if ( points == 1 && dispmode != GRAPH ) - fprintf(fp_out, "%d %d p\n", cursor.x, cursor.y); - - points = 0; - -} /* End of draw */ - - -/*****************************************************************************/ - -static void -formfeed(void) -{ - -/* - * - * Usually called when we've finished the last page and want to get ready for the - * next one. Also used at the beginning and end of each input file, so we have to - * be careful about exactly what's done. - * - */ - - - setmode(dispmode); /* end any outstanding text or graphics */ - - if ( fp_out == stdout ) /* count the last page */ - printed++; - - fprintf(fp_out, "cleartomark\n"); - fprintf(fp_out, "showpage\n"); - fprintf(fp_out, "restore\n"); - fprintf(fp_out, "%s %d %d\n", ENDPAGE, page, printed); - - if ( ungetc(getc(fp_in), fp_in) == EOF ) - redirect(-1); - else redirect(++page); - - fprintf(fp_out, "%s %d %d\n", PAGE, page, printed+1); - fprintf(fp_out, "save\n"); - fprintf(fp_out, "mark\n"); - writerequest(printed+1, fp_out); - fprintf(fp_out, "%d pagesetup\n", printed+1); - fprintf(fp_out, "%d f\n", charwidth[tekfont]); - fprintf(fp_out, "%s l\n", styles[linestyle]); - - home(); - -} /* End of formfeed */ - - -/*****************************************************************************/ - - -static int -nextchar(void) -{ - int ch; /* next input character */ - -/* - * - * Reads the next character from the current input file and returns it to the - * caller. When we're finished with the file dispmode is set to EXIT and OUTMODED - * is returned to the caller. - * - */ - - - if ( (ch = getc(fp_in)) == EOF ) { - setmode(EXIT); - ch = OUTMODED; - } /* End if */ - - return(ch); - -} /* End of nextchar */ - - -/*****************************************************************************/ - -static void -redirect(int pg) - /* next page we're printing */ -{ - static FILE *fp_null = NULL; /* if output is turned off */ - -/* - * - * If we're not supposed to print page pg, fp_out will be directed to /dev/null, - * otherwise output goes to stdout. - * - */ - - - if ( pg >= 0 && in_olist(pg) == ON ) - fp_out = stdout; - else if ( (fp_out = fp_null) == NULL ) - fp_out = fp_null = fopen("/dev/null", "w"); - -} /* End of redirect */ - - -/*****************************************************************************/ diff --git a/usr/src/cmd/lp/filter/postscript/posttek/posttek.h b/usr/src/cmd/lp/filter/postscript/posttek/posttek.h deleted file mode 100644 index e0d4fd544b..0000000000 --- a/usr/src/cmd/lp/filter/postscript/posttek/posttek.h +++ /dev/null @@ -1,214 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ - -/* - * - * Definitions used by the PostScript translator for tektronix 4014 files. - * - */ - -#define NUL '\000' -#define SOH '\001' -#define STX '\002' -#define ETX '\003' -#define EOT '\004' -#define ENQ '\005' -#define ACK '\006' -#define BEL '\007' -#define BS '\010' -#define HT '\011' -#define NL '\012' -#define VT '\013' -#define FF '\014' -#define CR '\015' -#define SO '\016' -#define SI '\017' -#define DLE '\020' -#define DC1 '\021' -#define DC2 '\022' -#define DC3 '\023' -#define DC4 '\024' -#define NAK '\025' -#define SYN '\026' -#define ETB '\027' -#define CAN '\030' -#define EM '\031' -#define SUB '\032' -#define ESC '\033' -#define FS '\034' -#define GS '\035' -#define RS '\036' -#define US '\037' -#define DEL '\177' - -/* - * - * A few definitions used to classify the different tektronix states. OUTMODED - * is returned by control() and esc(), and typically means the state has changed. - * - */ - -#define OUTMODED -1 -#define ALPHA 0 -#define GIN 1 -#define GRAPH 2 -#define POINT 3 -#define SPECIALPOINT 4 -#define INCREMENTAL 5 -#define RESET 6 -#define EXIT 7 - -/* - * - * The pen state, either UP or DOWN, controls whether vectors are drawn. - * - */ - -#define UP 0 -#define DOWN 1 - -/* - * - * Coordinates of the upper right corner of the screen - almost the real screen - * dimensions. - * - */ - -#define TEKXMAX 4096 -#define TEKYMAX 3120 - -/* - * - * The size of the spot in SPECIALPOINT mode is controlled by a non-linear - * function that has a domain that consists of the integers from 040 to 0175. - * The next definition is used to initialize the special point mode intensity - * array that implements the function. Data came from table F-6 in the tektronix - * 4014 manual. - * - */ - -#define INTENSITY \ - \ - { \ - 14, 16, 17, 19, 20, 22, 23, 25, \ - 28, 31, 34, 38, 41, 44, 47, 50, \ - 56, 62, 69, 75, 81, 88, 94,100, \ - 56, 62, 69, 75, 81, 88, 94,100, \ - 0, 1, 1, 1, 1, 1, 1, 2, \ - 2, 2, 2, 2, 3, 3, 3, 3, \ - 4, 4, 4, 5, 5, 5, 6, 6, \ - 7, 8, 9, 10, 11, 12, 12, 13, \ - 14, 16, 17, 19, 20, 22, 23, 25, \ - 28, 31, 34, 38, 41, 44, 47, 50, \ - 56, 62, 69, 75, 81, 88, 94,100, \ - 56, 62, 69, 75, 81, 88, 94,100, \ - } - -/* - * - * The next two definitions give the height and width of characters in the four - * different sizes available on tektronix terminals. TEKFONT is the default index - * into CHARHEIGHT and CHARWIDTH. - * - */ - -#define CHARHEIGHT {88, 82, 53, 48} -#define CHARWIDTH {56, 51, 34, 31} -#define TEKFONT 2 - -/* - * - * The entries defined in STYLES are passed on to the PostScript operator setdash. - * They're used to implement the different tektronix line styles. Belongs in the - * prologue! - * - */ - -#define STYLES \ - \ - { \ - "[]", \ - "[.5 2]", \ - "[.5 2 4 2]", \ - "[4 4]", \ - "[8 4]", \ - "[]" \ - } - -/* - * - * Variables of type Point are used to keep track of the cursor position. - * - */ - -typedef struct { - - int x; - int y; - -} Point; - -/* - * - * An array of type Fontmap helps convert font names requested by users into - * legitimate PostScript names. The array is initialized using FONTMAP, which must - * end with an entry that has NULL defined as its name field. - * - */ - -typedef struct { - - char *name; /* user's font name */ - char *val; /* corresponding PostScript name */ - -} Fontmap; - -#define FONTMAP \ - \ - { \ - "R", "Courier", \ - "I", "Courier-Oblique", \ - "B", "Courier-Bold", \ - "CO", "Courier", \ - "CI", "Courier-Oblique", \ - "CB", "Courier-Bold", \ - "CW", "Courier", \ - "PO", "Courier", \ - "courier", "Courier", \ - "cour", "Courier", \ - "co", "Courier", \ - NULL, NULL \ - } - -/* - * - * Some of the non-integer valued functions in posttek.c. - * - */ - -char *get_font(); - |
