allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc) (01/22/89)
Posting-number: Volume 6, Issue 3 Submitted-by: federico@actisb.UUCP (Federico Heinz) Archive-name: yahp2ps/part01 #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 1 (of 6)." # Contents: Makefile README basic.h char.c char.h circle.h global.h # shade.h tick.h yahp2ps.c # Wrapped by federico@actisb on Wed Jan 4 13:34:44 1989 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile'\" else echo shar: Extracting \"'Makefile'\" \(1230 characters\) sed "s/^X//" >'Makefile' <<'END_OF_FILE' XCFLAGS = -O X XDEST = /usr/local X XEXTHDRS = X XHDRS = basic.h \ X char.h \ X circle.h \ X defs.h \ X dispatch.h \ X global.h \ X io.h \ X mchinery.h \ X penctrl.h \ X shade.h \ X tick.h X XLDFLAGS = X XLIBS = X XLINKER = cc X XMAKEFILE = Makefile X XOBJS = basic.o \ X char.o \ X circle.o \ X dispatch.o \ X edge.o \ X global.o \ X yahp2ps.o \ X io.o \ X math.o \ X mchinery.o \ X penctrl.o \ X shade.o \ X tick.o X XPRINT = pr X XPROGRAM = yahp2ps X XSRCS = basic.c \ X char.c \ X circle.c \ X dispatch.c \ X edge.c \ X global.c \ X yahp2ps.c \ X io.c \ X math.c \ X mchinery.c \ X penctrl.c \ X shade.c \ X tick.c X Xall: $(PROGRAM) X X$(PROGRAM): $(OBJS) $(LIBS) X $(LINKER) $(LDFLAGS) $(OBJS) $(LIBS) -o $(PROGRAM) X Xclean:; rm -f $(OBJS) X Xdepend:; mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM) DEST=$(DEST) X Xindex:; ctags -wx $(HDRS) $(SRCS) X Xinstall: $(PROGRAM) X install -s $(PROGRAM) $(DEST) X install yahp2ps.pre /usr/lib X Xprint:; $(PRINT) $(HDRS) $(SRCS) X Xprogram: $(PROGRAM) X Xtags: $(HDRS) $(SRCS); ctags $(HDRS) $(SRCS) X Xupdate: $(DEST)/$(PROGRAM) X X$(DEST)/$(PROGRAM): $(SRCS) $(LIBS) $(HDRS) $(EXTHDRS) X @make -f $(MAKEFILE) DEST=$(DEST) install X### END_OF_FILE if test 1230 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi if test -f 'README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'README'\" else echo shar: Extracting \"'README'\" \(3093 characters\) sed "s/^X//" >'README' <<'END_OF_FILE' XThis directory contains the source code for yahp2ps (you got it: 'Yet XAnother HPGL to PostScript Converter). This program takes an HPGL plot Xfile as input and produces a PostScript language page description as Xoutput. This description produces, when interpreted, a printed page Xthat resembles as closely as possible the result you would have gotten Xby sending the original HPGL plot file to a plotter. X X yahp2ps supports most of the HPGL language, including specialties like Xfilled polygons. You shold have no trouble printing anything that Xdoesn't use the HPGL fonts. One thing I decided not to emulate was the Xbehaviour of the plotter when it gets a request to draw a circle arc of Xn degrees with a step angle of s, and both n and s are prime (or at Xleast mutually prime). I don't know what your plotter does under this Xcircumstances, mine gets stuck in an endless loop until power cycle. X X Most of the program is non-PostScript specific. If you want to Xproduce a HPGL-TO-WHATEVER converter, all you should have to do is Xreplace the 'machine.c' module by something with the same functionality X(Murphy permitting). I have compiled and run it on a 68030 BSD 4.3 Unix Xmachine, but it sould be pretty portable. The only problem I can think Xof (but then, it's been a long time since I last thought) is that I Xassume data of type 'Number' to be at least 32-bit integral (I hate Xfloating point math). X XRestrictions: X X * No text commands are implemented. I will eventually get around to X do this some time, but I haven't had the time. This restriction X also implies that you can't get centered chars at segment endings. X * No color support (I haven't been even near a color PostScript X printer). You may define a thickness and a gray level for each X pen, however. On a related topic, if an area is written over with X one pen, and later with another, the last gray level will prevail. X * Only DIN A4 paper size has been really tested. There are X provisions for the other sizes in the code (there are provisions X for text support too), but I havn't got around to test them. X * No commands requiring responses from the plotter are implemented X (for instance the commands for digitizing). X * The prelude isn't "Adobe conformant". It doesn't do anything X weird anyway, it's just that the field names and such stuff X aren't there. I use the 'setmatrix' PostScript command to allow X distorting and restoring of user space without affecting other X parameters, but this should have no ill effects since it's done X under controlled conditions. X * No documentation (I guess I will eventually resign and decide to X learn how to use [tn]roff). The program's function is quite X obvious, though, so that you shouldn't have problems using it. X If you do, try entering 'yahp2ps -' to get the 'Usage' line. X If that doesn't help, look at 'main' in 'yahp2ps.c', if everything X else fails, contact me. X X Xyahp2ps is free software. See the file COPYING for copying permission. X X Federico Heinz END_OF_FILE if test 3093 -ne `wc -c <'README'`; then echo shar: \"'README'\" unpacked with wrong size! fi # end of 'README' fi if test -f 'basic.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'basic.h'\" else echo shar: Extracting \"'basic.h'\" \(1671 characters\) sed "s/^X//" >'basic.h' <<'END_OF_FILE' X/* X HPGL to PostScript converter X Copyright (C) 1988 (and following) Federico Heinz X Xyahp2ps is distributed in the hope that it will be useful, but WITHOUT ANY XWARRANTY. No author or distributor accepts responsibility to anyone Xfor the consequences of using it or for whether it serves any Xparticular purpose or works at all, unless he says so in writing. XRefer to the Free Software Foundation's General Public License for full details. X XEveryone is granted permission to copy, modify and redistribute yahp2ps, Xbut only under the conditions described in the GNU General Public XLicense. A copy of this license is supposed to have been given to you Xalong with yahp2ps so you can know your rights and responsibilities. It Xshould be in a file named COPYING. Among other things, the copyright Xnotice and this notice must be preserved on all copies. X XIn other words, go ahead and share yahp2ps, but don't try to stop Xanyone else from sharing it farther. Help stamp out software hoarding! X Xyahp2ps is TOTALLY unrelated to GNU or the Free Software Foundation, Xit is only released under the same conditions. X X For bug reports, wishes, etc. send e-mail to X X ...!mcvax!unido!tub!actisb!federico (from Europe) X ...!uunet!pyramid!actisb!federico (from anywhere else) X X For Physical mail: X X Federico Heinz X Beusselstr. 21 X 1000 Berlin 21 X X Tel. (+49 30) 396 77 92 X X*/ X/************************************************************************** X X Definitions for basical movement routines. X X**************************************************************************/ X X X/* Restore the module's default parameters */ X Xextern void basicInit(); X END_OF_FILE if test 1671 -ne `wc -c <'basic.h'`; then echo shar: \"'basic.h'\" unpacked with wrong size! fi # end of 'basic.h' fi if test -f 'char.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'char.c'\" else echo shar: Extracting \"'char.c'\" \(2561 characters\) sed "s/^X//" >'char.c' <<'END_OF_FILE' X/* X HPGL to PostScript converter X Copyright (C) 1988 (and following) Federico Heinz X Xyahp2ps is distributed in the hope that it will be useful, but WITHOUT ANY XWARRANTY. No author or distributor accepts responsibility to anyone Xfor the consequences of using it or for whether it serves any Xparticular purpose or works at all, unless he says so in writing. XRefer to the Free Software Foundation's General Public License for full details. X XEveryone is granted permission to copy, modify and redistribute yahp2ps, Xbut only under the conditions described in the GNU General Public XLicense. A copy of this license is supposed to have been given to you Xalong with yahp2ps so you can know your rights and responsibilities. It Xshould be in a file named COPYING. Among other things, the copyright Xnotice and this notice must be preserved on all copies. X XIn other words, go ahead and share yahp2ps, but don't try to stop Xanyone else from sharing it farther. Help stamp out software hoarding! X Xyahp2ps is TOTALLY unrelated to GNU or the Free Software Foundation, Xit is only released under the same conditions. X X For bug reports, wishes, etc. send e-mail to X X ...!mcvax!unido!tub!actisb!federico (from Europe) X ...!uunet!pyramid!actisb!federico (from anywhere else) X X For Physical mail: X X Federico Heinz X Beusselstr. 21 X 1000 Berlin 21 X X Tel. (+49 30) 396 77 92 X X*/ X/************************************************************************ X X Character drawing stuff. X X************************************************************************/ X X#include "defs.h" X#include "dispatch.h" X X X/* X X Reset this module's default parameters. X X*/ X Xvoid charInit() X X{ } X X XCommandImplementation setAlternateChar() X X{ notImplemented(); } X X XCommandImplementation characterPlot() X X{ notImplemented(); } X X XCommandImplementation setStandardChar() X X{ notImplemented(); } X X XCommandImplementation setAbsoluteDirection() X X{ notImplemented(); } X X X XCommandImplementation setRelativeDirection() X X{ notImplemented(); } X X X XCommandImplementation setLabelTerminator() X X{ notImplemented(); } X X X XCommandImplementation putASCIILabel() X X{ notImplemented(); } X X X XCommandImplementation selectAlternate() X X{ notImplemented(); } X X X XCommandImplementation setAbsoluteCharSize() X X{ notImplemented(); } X X X XCommandImplementation setAbsoluteCharSlant() X X{ notImplemented(); } X X X XCommandImplementation setRelativeCharSize() X X{ notImplemented(); } X X X XCommandImplementation selectStandard() X X{ notImplemented(); } X X X XCommandImplementation userChar() X X{ notImplemented(); } X X X X END_OF_FILE if test 2561 -ne `wc -c <'char.c'`; then echo shar: \"'char.c'\" unpacked with wrong size! fi # end of 'char.c' fi if test -f 'char.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'char.h'\" else echo shar: Extracting \"'char.h'\" \(1657 characters\) sed "s/^X//" >'char.h' <<'END_OF_FILE' X/* X HPGL to PostScript converter X Copyright (C) 1988 (and following) Federico Heinz X Xyahp2ps is distributed in the hope that it will be useful, but WITHOUT ANY XWARRANTY. No author or distributor accepts responsibility to anyone Xfor the consequences of using it or for whether it serves any Xparticular purpose or works at all, unless he says so in writing. XRefer to the Free Software Foundation's General Public License for full details. X XEveryone is granted permission to copy, modify and redistribute yahp2ps, Xbut only under the conditions described in the GNU General Public XLicense. A copy of this license is supposed to have been given to you Xalong with yahp2ps so you can know your rights and responsibilities. It Xshould be in a file named COPYING. Among other things, the copyright Xnotice and this notice must be preserved on all copies. X XIn other words, go ahead and share yahp2ps, but don't try to stop Xanyone else from sharing it farther. Help stamp out software hoarding! X Xyahp2ps is TOTALLY unrelated to GNU or the Free Software Foundation, Xit is only released under the same conditions. X X For bug reports, wishes, etc. send e-mail to X X ...!mcvax!unido!tub!actisb!federico (from Europe) X ...!uunet!pyramid!actisb!federico (from anywhere else) X X For Physical mail: X X Federico Heinz X Beusselstr. 21 X 1000 Berlin 21 X X Tel. (+49 30) 396 77 92 X X*/ X/************************************************************************* X X Definitions for char handling routines. X X************************************************************************/ X X X/* Reset the module's default status */ X Xextern void charInit(); X END_OF_FILE if test 1657 -ne `wc -c <'char.h'`; then echo shar: \"'char.h'\" unpacked with wrong size! fi # end of 'char.h' fi if test -f 'circle.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'circle.h'\" else echo shar: Extracting \"'circle.h'\" \(2381 characters\) sed "s/^X//" >'circle.h' <<'END_OF_FILE' X/* X HPGL to PostScript converter X Copyright (C) 1988 (and following) Federico Heinz X Xyahp2ps is distributed in the hope that it will be useful, but WITHOUT ANY XWARRANTY. No author or distributor accepts responsibility to anyone Xfor the consequences of using it or for whether it serves any Xparticular purpose or works at all, unless he says so in writing. XRefer to the Free Software Foundation's General Public License for full details. X XEveryone is granted permission to copy, modify and redistribute yahp2ps, Xbut only under the conditions described in the GNU General Public XLicense. A copy of this license is supposed to have been given to you Xalong with yahp2ps so you can know your rights and responsibilities. It Xshould be in a file named COPYING. Among other things, the copyright Xnotice and this notice must be preserved on all copies. X XIn other words, go ahead and share yahp2ps, but don't try to stop Xanyone else from sharing it farther. Help stamp out software hoarding! X Xyahp2ps is TOTALLY unrelated to GNU or the Free Software Foundation, Xit is only released under the same conditions. X X For bug reports, wishes, etc. send e-mail to X X ...!mcvax!unido!tub!actisb!federico (from Europe) X ...!uunet!pyramid!actisb!federico (from anywhere else) X X For Physical mail: X X Federico Heinz X Beusselstr. 21 X 1000 Berlin 21 X X Tel. (+49 30) 396 77 92 X X*/ X/************************************************************************** X X Definition of circle/arc support arithmetic X X**************************************************************************/ X X X#define MinimumChordForWedge 40000L /* For wedges only */ X#define MaximumChordAngle 1200000L /* For wedges only */ X#define DefaultChordAngle 50000L X X#define OneSquare 900000L X#define TwoSquares 1800000L X#define ThreeSquares 2700000L X#define FullCircle 3600000L X X X/* Compute an acceptable chord angle */ X Xextern Number correctedChordAngle(); X X X/* Twist the start and the sweep angles so as to make sense. */ X Xextern void fixUpStartAndSweep(); X X X/* Compute the position of a point at polar coordinates from a point */ X Xextern void polarToCartesian(); X X X X/* Compute the angle and hypotenuse that produces these cathetes */ X Xextern void cartesianToPolar(); X X X X/* Get the optional chord angle parameter */ X Xextern void getChordAngle(); END_OF_FILE if test 2381 -ne `wc -c <'circle.h'`; then echo shar: \"'circle.h'\" unpacked with wrong size! fi # end of 'circle.h' fi if test -f 'global.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'global.h'\" else echo shar: Extracting \"'global.h'\" \(1810 characters\) sed "s/^X//" >'global.h' <<'END_OF_FILE' X/* X HPGL to PostScript converter X Copyright (C) 1988 (and following) Federico Heinz X Xyahp2ps is distributed in the hope that it will be useful, but WITHOUT ANY XWARRANTY. No author or distributor accepts responsibility to anyone Xfor the consequences of using it or for whether it serves any Xparticular purpose or works at all, unless he says so in writing. XRefer to the Free Software Foundation's General Public License for full details. X XEveryone is granted permission to copy, modify and redistribute yahp2ps, Xbut only under the conditions described in the GNU General Public XLicense. A copy of this license is supposed to have been given to you Xalong with yahp2ps so you can know your rights and responsibilities. It Xshould be in a file named COPYING. Among other things, the copyright Xnotice and this notice must be preserved on all copies. X XIn other words, go ahead and share yahp2ps, but don't try to stop Xanyone else from sharing it farther. Help stamp out software hoarding! X Xyahp2ps is TOTALLY unrelated to GNU or the Free Software Foundation, Xit is only released under the same conditions. X X For bug reports, wishes, etc. send e-mail to X X ...!mcvax!unido!tub!actisb!federico (from Europe) X ...!uunet!pyramid!actisb!federico (from anywhere else) X X For Physical mail: X X Federico Heinz X Beusselstr. 21 X 1000 Berlin 21 X X Tel. (+49 30) 396 77 92 X X*/ X/************************************************************************* X X Definition of global status routines. X X*************************************************************************/ X X X#define PaperSizeLimit 40000 /* Smaller means A3, bigger means A4 */ X X X/* Restore this module's default status */ X Xextern void globalInit(); X X X/* Restore all modules' default status */ X Xextern void restoreDefaults(); X END_OF_FILE if test 1810 -ne `wc -c <'global.h'`; then echo shar: \"'global.h'\" unpacked with wrong size! fi # end of 'global.h' fi if test -f 'shade.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'shade.h'\" else echo shar: Extracting \"'shade.h'\" \(1842 characters\) sed "s/^X//" >'shade.h' <<'END_OF_FILE' X/* X HPGL to PostScript converter X Copyright (C) 1988 (and following) Federico Heinz X Xyahp2ps is distributed in the hope that it will be useful, but WITHOUT ANY XWARRANTY. No author or distributor accepts responsibility to anyone Xfor the consequences of using it or for whether it serves any Xparticular purpose or works at all, unless he says so in writing. XRefer to the Free Software Foundation's General Public License for full details. X XEveryone is granted permission to copy, modify and redistribute yahp2ps, Xbut only under the conditions described in the GNU General Public XLicense. A copy of this license is supposed to have been given to you Xalong with yahp2ps so you can know your rights and responsibilities. It Xshould be in a file named COPYING. Among other things, the copyright Xnotice and this notice must be preserved on all copies. X XIn other words, go ahead and share yahp2ps, but don't try to stop Xanyone else from sharing it farther. Help stamp out software hoarding! X Xyahp2ps is TOTALLY unrelated to GNU or the Free Software Foundation, Xit is only released under the same conditions. X X For bug reports, wishes, etc. send e-mail to X X ...!mcvax!unido!tub!actisb!federico (from Europe) X ...!uunet!pyramid!actisb!federico (from anywhere else) X X For Physical mail: X X Federico Heinz X Beusselstr. 21 X 1000 Berlin 21 X X Tel. (+49 30) 396 77 92 X X*/ X/********************************************************************** X X Definitions for figure shading. X X**********************************************************************/ X X#define DefaultFillSpacing 1232200L X#define ParallelLines 30000 X X#define DefaultFillType One X X#define DefaultPenWidth 03000L X#define MinPenWidth 01000L X#define MaxPenWidth 50000L X X X/* Restore the module's status to the default. */ X Xextern void shadeInit(); END_OF_FILE if test 1842 -ne `wc -c <'shade.h'`; then echo shar: \"'shade.h'\" unpacked with wrong size! fi # end of 'shade.h' fi if test -f 'tick.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'tick.h'\" else echo shar: Extracting \"'tick.h'\" \(1779 characters\) sed "s/^X//" >'tick.h' <<'END_OF_FILE' X/* X HPGL to PostScript converter X Copyright (C) 1988 (and following) Federico Heinz X Xyahp2ps is distributed in the hope that it will be useful, but WITHOUT ANY XWARRANTY. No author or distributor accepts responsibility to anyone Xfor the consequences of using it or for whether it serves any Xparticular purpose or works at all, unless he says so in writing. XRefer to the Free Software Foundation's General Public License for full details. X XEveryone is granted permission to copy, modify and redistribute yahp2ps, Xbut only under the conditions described in the GNU General Public XLicense. A copy of this license is supposed to have been given to you Xalong with yahp2ps so you can know your rights and responsibilities. It Xshould be in a file named COPYING. Among other things, the copyright Xnotice and this notice must be preserved on all copies. X XIn other words, go ahead and share yahp2ps, but don't try to stop Xanyone else from sharing it farther. Help stamp out software hoarding! X Xyahp2ps is TOTALLY unrelated to GNU or the Free Software Foundation, Xit is only released under the same conditions. X X For bug reports, wishes, etc. send e-mail to X X ...!mcvax!unido!tub!actisb!federico (from Europe) X ...!uunet!pyramid!actisb!federico (from anywhere else) X X For Physical mail: X X Federico Heinz X Beusselstr. 21 X 1000 Berlin 21 X X Tel. (+49 30) 396 77 92 X X*/ X/************************************************************************ X X Interface to Tick drawing module. X X************************************************************************/ X X X#define InitialTick 5000L X X X X/* Adjust the tick parameters to a new environment */ X Xextern void updateTicks(); X X X X/* Reset the tick parameters to the default values */ X Xextern void tickInit(); X END_OF_FILE if test 1779 -ne `wc -c <'tick.h'`; then echo shar: \"'tick.h'\" unpacked with wrong size! fi # end of 'tick.h' fi if test -f 'yahp2ps.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'yahp2ps.c'\" else echo shar: Extracting \"'yahp2ps.c'\" \(2523 characters\) sed "s/^X//" >'yahp2ps.c' <<'END_OF_FILE' X/* X HPGL to PostScript converter X Copyright (C) 1988 (and following) Federico Heinz X Xyahp2ps is distributed in the hope that it will be useful, but WITHOUT ANY XWARRANTY. No author or distributor accepts responsibility to anyone Xfor the consequences of using it or for whether it serves any Xparticular purpose or works at all, unless he says so in writing. XRefer to the Free Software Foundation's General Public License for full details. X XEveryone is granted permission to copy, modify and redistribute yahp2ps, Xbut only under the conditions described in the GNU General Public XLicense. A copy of this license is supposed to have been given to you Xalong with yahp2ps so you can know your rights and responsibilities. It Xshould be in a file named COPYING. Among other things, the copyright Xnotice and this notice must be preserved on all copies. X XIn other words, go ahead and share yahp2ps, but don't try to stop Xanyone else from sharing it farther. Help stamp out software hoarding! X Xyahp2ps is TOTALLY unrelated to GNU or the Free Software Foundation, Xit is only released under the same conditions. X X For bug reports, wishes, etc. send e-mail to X X ...!mcvax!unido!tub!actisb!federico (from Europe) X ...!uunet!pyramid!actisb!federico (from anywhere else) X X For Physical mail: X X Federico Heinz X Beusselstr. 21 X 1000 Berlin 21 X X Tel. (+49 30) 396 77 92 X X*/ X#include <stdio.h> X#include "defs.h" X#include "dispatch.h" X#include "mchinery.h" X XNumber TN; /* Temporary storage for Number math */ X Xmain(argc, argv) X Xint argc; Xchar **argv; X X{ while (--argc) X { argv++; X if (**argv == '-') X switch(*((*argv)+1)) X { case 'l': X if (argc-1) X { getPenSizes(*(++argv)); X argc--; X } X break; X case 'o': X if (argc-1) X { if (!setOutput(*(++argv))) X error("Unable to open target file."); X argc--; X } X break; X case 'p': X if (argc-1) X { if (PreludeFile != NULL) X PreludeFile = *(++argv); X argc--; X } X break; X case 's': X PreludeFile = NULL; X break; X default: X error("Usage: hpgl2ps [-l <linesizes>] [-p <preludefile>] [-s] [-o <outputfile>] inputfile"); X break; X } X else X if (!setInput(*argv)) X error("Unable to open source file."); X } X initializeMachinery(); X penctrlInit(); X restoreDefaults(); X dispatch(); X shutdownMachinery(); X} X END_OF_FILE if test 2523 -ne `wc -c <'yahp2ps.c'`; then echo shar: \"'yahp2ps.c'\" unpacked with wrong size! fi # end of 'yahp2ps.c' fi echo shar: End of archive 1 \(of 6\). cp /dev/null ark1isdone MISSING="" for I in 1 2 3 4 5 6 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 6 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0