home *** CD-ROM | disk | FTP | other *** search
- From decwrl!ucbvax!tut.cis.ohio-state.edu!unmvax!ncar!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!allbery Sun Apr 9 16:08:47 PDT 1989
- Article 852 of comp.sources.misc:
- Path: decwrl!ucbvax!tut.cis.ohio-state.edu!unmvax!ncar!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!allbery
- From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
- Newsgroups: comp.sources.misc
- Subject: v06i083: plot2ps -- convert plot(5) data to PostScript
- Message-ID: <52333@uunet.UU.NET>
- Date: 8 Apr 89 19:45:14 GMT
- Sender: allbery@uunet.UU.NET
- Reply-To: seindal@diku.dk (Rene' Seindal)
- Lines: 1223
- Approved: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
-
- Posting-number: Volume 6, Issue 83
- Submitted-by: seindal@diku.dk (Rene' Seindal)
- Archive-name: plot2ps
-
-
- This is a program to convert plot(5) data to PostScript.
-
- This package includes a general purpose plot library which outputs PostScript.
-
- Now we have this splendid GNU GENERAL PUBLIC LICENSE, I have made this program
- subject to it. That means, as usual, you're free to copy, modify and
- redistribute this program, but not to disallow others to do so.
-
- Is it really necessary to put 20 lines of copyright message in each file, and
- send out a 9Kb file with everything subjected to the GNU license? Seems a bit
- excessive to me.
-
- ------------------------------------------------------------------------
- #!/bin/sh
- # shar: Shell Archiver (v1.22)
- #
- # Run the following text with /bin/sh to create:
- # COPYING
- # Makefile
- # README
- # arc.c
- # bytesex.h
- # circle.c
- # closepl.c
- # cont.c
- # defs.h
- # dot.c
- # erase.c
- # label.c
- # line.c
- # linemod.c
- # move.c
- # openpl.c
- # output.c
- # plot2ps.1
- # plot2ps.c
- # point.c
- # space.c
- #
- echo "x - extracting COPYING (Text)"
- sed 's/^X//' << 'SHAR_EOF' > COPYING &&
- X
- X GNU GENERAL PUBLIC LICENSE
- X Version 1, February 1989
- X
- X Copyright (C) 1989 Free Software Foundation, Inc.
- X 675 Mass Ave, Cambridge, MA 02139, USA
- X Everyone is permitted to copy and distribute verbatim copies
- X of this license document, but changing it is not allowed.
- X
- X Preamble
- X
- X The license agreements of most software companies try to keep users
- Xat the mercy of those companies. By contrast, our General Public
- XLicense is intended to guarantee your freedom to share and change free
- Xsoftware--to make sure the software is free for all its users. The
- XGeneral Public License applies to the Free Software Foundation's
- Xsoftware and to any other program whose authors commit to using it.
- XYou can use it for your programs, too.
- X
- X When we speak of free software, we are referring to freedom, not
- Xprice. Specifically, the General Public License is designed to make
- Xsure that you have the freedom to give away or sell copies of free
- Xsoftware, that you receive source code or can get it if you want it,
- Xthat you can change the software or use pieces of it in new free
- Xprograms; and that you know you can do these things.
- X
- X To protect your rights, we need to make restrictions that forbid
- Xanyone to deny you these rights or to ask you to surrender the rights.
- XThese restrictions translate to certain responsibilities for you if you
- Xdistribute copies of the software, or if you modify it.
- X
- X For example, if you distribute copies of a such a program, whether
- Xgratis or for a fee, you must give the recipients all the rights that
- Xyou have. You must make sure that they, too, receive or can get the
- Xsource code. And you must tell them their rights.
- X
- X We protect your rights with two steps: (1) copyright the software, and
- X(2) offer you this license which gives you legal permission to copy,
- Xdistribute and/or modify the software.
- X
- X Also, for each author's protection and ours, we want to make certain
- Xthat everyone understands that there is no warranty for this free
- Xsoftware. If the software is modified by someone else and passed on, we
- Xwant its recipients to know that what they have is not the original, so
- Xthat any problems introduced by others will not reflect on the original
- Xauthors' reputations.
- X
- X The precise terms and conditions for copying, distribution and
- Xmodification follow.
- X
- X GNU GENERAL PUBLIC LICENSE
- X TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
- X
- X 0. This License Agreement applies to any program or other work which
- Xcontains a notice placed by the copyright holder saying it may be
- Xdistributed under the terms of this General Public License. The
- X"Program", below, refers to any such program or work, and a "work based
- Xon the Program" means either the Program or any work containing the
- XProgram or a portion of it, either verbatim or with modifications. Each
- Xlicensee is addressed as "you".
- X
- X 1. You may copy and distribute verbatim copies of the Program's source
- Xcode as you receive it, in any medium, provided that you conspicuously and
- Xappropriately publish on each copy an appropriate copyright notice and
- Xdisclaimer of warranty; keep intact all the notices that refer to this
- XGeneral Public License and to the absence of any warranty; and give any
- Xother recipients of the Program a copy of this General Public License
- Xalong with the Program. You may charge a fee for the physical act of
- Xtransferring a copy.
- X
- X 2. You may modify your copy or copies of the Program or any portion of
- Xit, and copy and distribute such modifications under the terms of Paragraph
- X1 above, provided that you also do the following:
- X
- X a) cause the modified files to carry prominent notices stating that
- X you changed the files and the date of any change; and
- X
- X b) cause the whole of any work that you distribute or publish, that
- X in whole or in part contains the Program or any part thereof, either
- X with or without modifications, to be licensed at no charge to all
- X third parties under the terms of this General Public License (except
- X that you may choose to grant warranty protection to some or all
- X third parties, at your option).
- X
- X c) If the modified program normally reads commands interactively when
- X run, you must cause it, when started running for such interactive use
- X in the simplest and most usual way, to print or display an
- X announcement including an appropriate copyright notice and a notice
- X that there is no warranty (or else, saying that you provide a
- X warranty) and that users may redistribute the program under these
- X conditions, and telling the user how to view a copy of this General
- X Public License.
- X
- X d) You may charge a fee for the physical act of transferring a
- X copy, and you may at your option offer warranty protection in
- X exchange for a fee.
- X
- XMere aggregation of another independent work with the Program (or its
- Xderivative) on a volume of a storage or distribution medium does not bring
- Xthe other work under the scope of these terms.
- X
- X 3. You may copy and distribute the Program (or a portion or derivative of
- Xit, under Paragraph 2) in object code or executable form under the terms of
- XParagraphs 1 and 2 above provided that you also do one of the following:
- X
- X a) accompany it with the complete corresponding machine-readable
- X source code, which must be distributed under the terms of
- X Paragraphs 1 and 2 above; or,
- X
- X b) accompany it with a written offer, valid for at least three
- X years, to give any third party free (except for a nominal charge
- X for the cost of distribution) a complete machine-readable copy of the
- X corresponding source code, to be distributed under the terms of
- X Paragraphs 1 and 2 above; or,
- X
- X c) accompany it with the information you received as to where the
- X corresponding source code may be obtained. (This alternative is
- X allowed only for noncommercial distribution and only if you
- X received the program in object code or executable form alone.)
- X
- XSource code for a work means the preferred form of the work for making
- Xmodifications to it. For an executable file, complete source code means
- Xall the source code for all modules it contains; but, as a special
- Xexception, it need not include source code for modules which are standard
- Xlibraries that accompany the operating system on which the executable
- Xfile runs, or for standard header files or definitions files that
- Xaccompany that operating system.
- X
- X 4. You may not copy, modify, sublicense, distribute or transfer the
- XProgram except as expressly provided under this General Public License.
- XAny attempt otherwise to copy, modify, sublicense, distribute or transfer
- Xthe Program is void, and will automatically terminate your rights to use
- Xthe Program under this License. However, parties who have received
- Xcopies, or rights to use copies, from you under this General Public
- XLicense will not have their licenses terminated so long as such parties
- Xremain in full compliance.
- X
- X 5. By copying, distributing or modifying the Program (or any work based
- Xon the Program) you indicate your acceptance of this license to do so,
- Xand all its terms and conditions.
- X
- X 6. Each time you redistribute the Program (or any work based on the
- XProgram), the recipient automatically receives a license from the original
- Xlicensor to copy, distribute or modify the Program subject to these
- Xterms and conditions. You may not impose any further restrictions on the
- Xrecipients' exercise of the rights granted herein.
- X
- X 7. The Free Software Foundation may publish revised and/or new versions
- Xof the General Public License from time to time. Such new versions will
- Xbe similar in spirit to the present version, but may differ in detail to
- Xaddress new problems or concerns.
- X
- XEach version is given a distinguishing version number. If the Program
- Xspecifies a version number of the license which applies to it and "any
- Xlater version", you have the option of following the terms and conditions
- Xeither of that version or of any later version published by the Free
- XSoftware Foundation. If the Program does not specify a version number of
- Xthe license, you may choose any version ever published by the Free Software
- XFoundation.
- X
- X 8. If you wish to incorporate parts of the Program into other free
- Xprograms whose distribution conditions are different, write to the author
- Xto ask for permission. For software which is copyrighted by the Free
- XSoftware Foundation, write to the Free Software Foundation; we sometimes
- Xmake exceptions for this. Our decision will be guided by the two goals
- Xof preserving the free status of all derivatives of our free software and
- Xof promoting the sharing and reuse of software generally.
- X
- X NO WARRANTY
- X
- X 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
- XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
- XOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
- XPROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
- XOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- XMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
- XTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
- XPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
- XREPAIR OR CORRECTION.
- X
- X 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
- XWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
- XREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
- XINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
- XOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
- XTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
- XYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
- XPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
- XPOSSIBILITY OF SUCH DAMAGES.
- X
- SHAR_EOF
- chmod 0644 COPYING || echo "restore of COPYING fails"
- echo "x - extracting Makefile (Text)"
- sed 's/^X//' << 'SHAR_EOF' > Makefile &&
- XINCL =
- XCOPTS = -O
- XCFLAGS = $(COPTS) $(CEXT) $(INCL)
- XCC = cc
- XDEPEND = $(CC) -MM $(INCL)
- XLOADLIBES = -lm
- XINSTALL = install
- X
- XALL = plot2ps libPS.a
- X
- XLIBSRCS = arc.c circle.c closepl.c cont.c erase.c label.c line.c \
- X linemod.c move.c openpl.c output.c point.c space.c dot.c
- XLIBOBJS = arc.o circle.o closepl.o cont.o erase.o label.o line.o \
- X linemod.o move.o openpl.o output.o point.o space.o dot.o
- XLIBHDRS = defs.h
- X
- XSRCS = plot2ps.c
- XOBJS = plot2ps.o
- X
- XBINDIR = /usr/local/bin
- XMANDIR = /usr/man/man1
- XLIBDIR = /usr/lib
- X
- Xall: $(ALL)
- X
- Xinstall: $(ALL)
- X $(INSTALL) -c -s -m 755 plot2ps $(BINDIR)
- X $(INSTALL) -c libPS.a $(LIBDIR)
- X ranlib -t $(LIBDIR)/libPS.a
- X @echo Installation done.
- X
- XlibPS.a: $(LIBOBJS)
- X ar cru $@ $?
- X ranlib $@
- X
- Xplot2ps: plot2ps.o libPS.a
- X $(CC) $(CFLAGS) $(LDFLAGS) -o $@ plot2ps.o libPS.a $(LOADLIBES)
- X
- Xtags: $(SRCS) $(HDRS) $(LIBSRCS) $(LIBHDRS)
- X etags $(SRCS) $(HDRS) $(LIBSRCS) $(LIBHDRS)
- X
- Xid:
- X mkid $(SRCS) $(HRDS) $(LIBSRCS) $(LIBHDRS)
- X
- Xclean:
- X rm -f $(ALL) $(OBJS) $(LIBOBJS) *~ '#*' core a.out
- X
- Xdepend: ${SRCS} $(LIBSRCS)
- X for i in $(SRCS) $(LIBSRCS); do $(DEPEND) $$i >> makedep; done
- X echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
- X echo '$$r makedep' >>eddep
- X echo 'w' >>eddep
- X cp Makefile Makefile.bak
- X ed - Makefile < eddep
- X rm eddep makedep
- X echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
- X echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
- X echo '# see make depend above' >> Makefile
- X
- X# DO NOT DELETE THIS LINE
- X
- Xplot2ps.o: plot2ps.c
- Xplot2ps.o: /usr/include/stdio.h
- Xplot2ps.o: ./bytesex.h
- Xarc.o: arc.c
- Xarc.o: ./defs.h
- Xarc.o: /usr/include/stdio.h
- Xcircle.o: circle.c
- Xcircle.o: ./defs.h
- Xcircle.o: /usr/include/stdio.h
- Xclosepl.o: closepl.c
- Xclosepl.o: ./defs.h
- Xclosepl.o: /usr/include/stdio.h
- Xcont.o: cont.c
- Xcont.o: ./defs.h
- Xcont.o: /usr/include/stdio.h
- Xerase.o: erase.c
- Xerase.o: ./defs.h
- Xerase.o: /usr/include/stdio.h
- Xlabel.o: label.c
- Xlabel.o: ./defs.h
- Xlabel.o: /usr/include/stdio.h
- Xline.o: line.c
- Xline.o: ./defs.h
- Xline.o: /usr/include/stdio.h
- Xlinemod.o: linemod.c
- Xlinemod.o: ./defs.h
- Xlinemod.o: /usr/include/stdio.h
- Xmove.o: move.c
- Xmove.o: ./defs.h
- Xmove.o: /usr/include/stdio.h
- Xopenpl.o: openpl.c
- Xopenpl.o: ./defs.h
- Xopenpl.o: /usr/include/stdio.h
- Xoutput.o: output.c
- Xoutput.o: ./defs.h
- Xoutput.o: /usr/include/stdio.h
- Xpoint.o: point.c
- Xpoint.o: ./defs.h
- Xpoint.o: /usr/include/stdio.h
- Xspace.o: space.c
- Xspace.o: ./defs.h
- Xspace.o: /usr/include/stdio.h
- Xdot.o: dot.c
- Xdot.o: ./defs.h
- Xdot.o: /usr/include/stdio.h
- X# DEPENDENCIES MUST END AT END OF FILE
- X# IF YOU PUT STUFF HERE IT WILL GO AWAY
- X# see make depend above
- SHAR_EOF
- chmod 0644 Makefile || echo "restore of Makefile fails"
- echo "x - extracting README (Text)"
- sed 's/^X//' << 'SHAR_EOF' > README &&
- XThis is a program to convert plot(5) data to PostScript.
- X
- XThis package includes a general purpose plot library which outputs PostScript.
- X
- XYou should edit bytesex.h to reflect the byteorder of your machine, since the
- Xplot format is not portable across architectures. The only place BIG_ENDIAN
- Xis used in in getsi() in plot2ps.c.
- X
- XNow we have this splendid GNU GENERAL PUBLIC LICENSE, I have made this program
- Xsubject to it. That means, as usual, you're free to copy, modify and
- Xredistribute this program, but not to disallow others to do so.
- SHAR_EOF
- chmod 0644 README || echo "restore of README fails"
- echo "x - extracting arc.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > arc.c &&
- X/*
- X This file is part of plot2ps.
- X
- X Copyright (C) 1989 Rene' Seindal
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- X My current address is: seindal@diku.dk
- X*/
- X
- X#include "defs.h"
- X
- X#define PI ((double)3.14159265358979323844)
- X#define radtodeg(x) ((double)(x)*180.0/PI)
- X
- Xarc(x, y, x0, y0, x1, y1)
- X{
- X double theta0, theta1, rad;
- X int rx0, ry0, rx1, ry1;
- X
- X rx0 = x0 - x;
- X ry0 = y0 - y;
- X rx1 = x1 - x;
- X ry1 = y1 - y;
- X
- X rad = hypot( X(x0) - X(x), Y(y0) - Y(y) );
- X theta0 = (rx0 == 0) ? 180.0 : radtodeg( atan2((double)ry0, (double)rx0) );
- X theta1 = (rx1 == 0) ? 180.0 : radtodeg( atan2((double)ry1, (double)rx1) );
- X
- X clear();
- X printf( "%g %g %g %g %g arc\n", X(x), Y(y), rad, theta0, theta1 );
- X DIRTYPATH;
- X}
- SHAR_EOF
- chmod 0644 arc.c || echo "restore of arc.c fails"
- echo "x - extracting bytesex.h (Text)"
- sed 's/^X//' << 'SHAR_EOF' > bytesex.h &&
- X/*
- X This file is part of plot2ps.
- X
- X Copyright (C) 1989 Rene' Seindal
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- X My current address is: seindal@diku.dk
- X*/
- X
- X/*
- X * Define BIG_ENDIAN as appropriate for your machine
- X */
- X
- X#ifdef vax
- X#define BIG_ENDIAN
- X#endif
- X
- X#if defined(sparc) || defined(mc68000)
- X#undef BIG_ENDIAN
- X#endif
- SHAR_EOF
- chmod 0644 bytesex.h || echo "restore of bytesex.h fails"
- echo "x - extracting circle.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > circle.c &&
- X/*
- X This file is part of plot2ps.
- X
- X Copyright (C) 1989 Rene' Seindal
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- X My current address is: seindal@diku.dk
- X*/
- X
- X#include "defs.h"
- X
- Xcircle(x, y, r)
- X{
- X clear(); /* new path to avoid funny lines */
- X shipout( "%g %g %g 0 360 arc\n", X(x), Y(y), xscale * (double)r );
- X DIRTYPATH;
- X}
- SHAR_EOF
- chmod 0644 circle.c || echo "restore of circle.c fails"
- echo "x - extracting closepl.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > closepl.c &&
- X/*
- X This file is part of plot2ps.
- X
- X Copyright (C) 1989 Rene' Seindal
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- X My current address is: seindal@diku.dk
- X*/
- X
- X#include "defs.h"
- X
- X
- Xclosepl()
- X{
- X if ( !(state & CLEANPAGE) )
- X printf( "stroke showpage\n" );
- X fflush( stdout );
- X restpathlen = 0;
- X state = INVALID;
- X}
- SHAR_EOF
- chmod 0644 closepl.c || echo "restore of closepl.c fails"
- echo "x - extracting cont.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > cont.c &&
- X/*
- X This file is part of plot2ps.
- X
- X Copyright (C) 1989 Rene' Seindal
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- X My current address is: seindal@diku.dk
- X*/
- X
- X#include "defs.h"
- X
- X
- Xcont( x, y )
- X{
- X shipout( "%g %g lineto\n", X(x), Y(y) );
- X}
- SHAR_EOF
- chmod 0644 cont.c || echo "restore of cont.c fails"
- echo "x - extracting defs.h (Text)"
- sed 's/^X//' << 'SHAR_EOF' > defs.h &&
- X/*
- X This file is part of plot2ps.
- X
- X Copyright (C) 1989 Rene' Seindal
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- X My current address is: seindal@diku.dk
- X*/
- X
- X#include <stdio.h>
- X
- X/* CONSTANTS */
- X
- X#define XMAX 572 /* physical pagesizes in points */
- X#define YMAX 579 /* (should be 818) */
- X
- X#define XMIN 18 /* lower left x coordiate (ALW) */
- X#define YMIN 25 /* lower left y coordiate (ALW) */
- X
- X#define XRANGE 4096 /* default logical coor (values 0..XRANGE-1) */
- X#define YRANGE 4096 /* values 0..YRANGE-1 */
- X
- X#define FONT "Helvetica"
- X#define PTSIZE 12 /* pointsize for text (in points) */
- X#define LINEWIDTH 0.1 /* width of lines (in points) */
- X#define POINTDIAM 0.5 /* diameter of points (in points!) */
- X#define MAXPATHLENGTH 1024 /* no path generated will contain */
- X /* more segments than MAXPATHLENGTH */
- X
- X/* COORDINATES AND SCALING */
- X
- Xextern double xscale;
- Xextern double yscale;
- Xextern double xoffset;
- Xextern double yoffset;
- X
- X#define X(x) (xscale * ((double)(x)) + xoffset)
- X#define Y(y) (yscale * ((double)(y)) + yoffset)
- X
- X/* POSTSCRIPT OUTPUT */
- X
- X#define INVALID 0x01 /* plot not initialised or closed */
- X#define CLEANPAGE 0x02 /* page is blank */
- X#define CLEANPATH 0x04 /* current path is empty */
- X
- X#define DIRTYPAGE state &= ~CLEANPAGE
- X#define DIRTYPATH state &= ~(CLEANPAGE | CLEANPATH)
- X
- Xextern int state; /* state of the page */
- Xextern int restpathlen; /* length of current path */
- SHAR_EOF
- chmod 0644 defs.h || echo "restore of defs.h fails"
- echo "x - extracting dot.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > dot.c &&
- X/*
- X This file is part of plot2ps.
- X
- X Copyright (C) 1989 Rene' Seindal
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- X My current address is: seindal@diku.dk
- X*/
- X
- X#include "defs.h"
- X
- Xdot()
- X{
- X}
- SHAR_EOF
- chmod 0644 dot.c || echo "restore of dot.c fails"
- echo "x - extracting erase.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > erase.c &&
- X/*
- X This file is part of plot2ps.
- X
- X Copyright (C) 1989 Rene' Seindal
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- X My current address is: seindal@diku.dk
- X*/
- X
- X#include "defs.h"
- X
- X
- Xerase()
- X{
- X if ( state & CLEANPAGE )
- X return;
- X if ( !(state & CLEANPATH) )
- X printf( "stroke " );
- X printf( "showpage newpath\n");
- X everypage();
- X state = CLEANPAGE | CLEANPATH;
- X restpathlen = MAXPATHLENGTH;
- X}
- SHAR_EOF
- chmod 0644 erase.c || echo "restore of erase.c fails"
- echo "x - extracting label.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > label.c &&
- X/*
- X This file is part of plot2ps.
- X
- X Copyright (C) 1989 Rene' Seindal
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- X My current address is: seindal@diku.dk
- X*/
- X
- X#include "defs.h"
- X
- Xlabel(s)
- X char *s;
- X{
- X char t[1024];
- X register char *u = t;
- X
- X do {
- X if ( *s == '(' || *s == ')' || *s == '\\' )
- X *u++ = '\\';
- X if ( *s == '\0' || *s == '\n' )
- X break;
- X if ( u - t >= 1024 )
- X break;
- X } while ( *u++ = *s++ );
- X *u = '\0';
- X
- X printf( "(%s) show\n", t );
- X DIRTYPATH;
- X}
- X
- SHAR_EOF
- chmod 0644 label.c || echo "restore of label.c fails"
- echo "x - extracting line.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > line.c &&
- X/*
- X This file is part of plot2ps.
- X
- X Copyright (C) 1989 Rene' Seindal
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- X My current address is: seindal@diku.dk
- X*/
- X
- X#include "defs.h"
- X
- X
- Xline( x0, y0, x1, y1 )
- X{
- X shipout( "%g %g moveto ", X(x0), Y(y0) );
- X shipout( "%g %g lineto\n", X(x1), Y(y1) );
- X}
- SHAR_EOF
- chmod 0644 line.c || echo "restore of line.c fails"
- echo "x - extracting linemod.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > linemod.c &&
- X/*
- X This file is part of plot2ps.
- X
- X Copyright (C) 1989 Rene' Seindal
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- X My current address is: seindal@diku.dk
- X*/
- X
- X#include "defs.h"
- X
- Xstruct linemod {
- X char *name;
- X char *pat;
- X} linemods[] = {
- X { "solid", "[] 0" },
- X { "dotted", "[1 2] 0" },
- X { "longdashed", "[9 2] 0" },
- X { "shortdashed", "[4.5 2] 0" },
- X { "dotdashed" , "[9 2 1 2] 0" },
- X { 0 , 0 },
- X};
- X
- Xlinemod(s)
- X char *s;
- X{
- X struct linemod *lm;
- X
- X for ( lm = linemods; lm->name && strcmp( lm->name, s ); lm++ )
- X ;
- X if ( lm->name == 0 )
- X lm = linemods;
- X
- X clear();
- X printf( "%s setdash\n", lm->pat );
- X}
- X
- SHAR_EOF
- chmod 0644 linemod.c || echo "restore of linemod.c fails"
- echo "x - extracting move.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > move.c &&
- X/*
- X This file is part of plot2ps.
- X
- X Copyright (C) 1989 Rene' Seindal
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- X My current address is: seindal@diku.dk
- X*/
- X
- X#include "defs.h"
- X
- Xmove( x, y )
- X{
- X shipout( "%g %g moveto\n", X(x), Y(y) );
- X}
- SHAR_EOF
- chmod 0644 move.c || echo "restore of move.c fails"
- echo "x - extracting openpl.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > openpl.c &&
- X/*
- X This file is part of plot2ps.
- X
- X Copyright (C) 1989 Rene' Seindal
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- X My current address is: seindal@diku.dk
- X*/
- X
- X#include "defs.h"
- X
- Xdouble xscale = (double)(XMAX - XMIN) / (double)XRANGE;
- Xdouble yscale = (double)(YMAX - YMIN) / (double)YRANGE;
- Xdouble xoffset = (double)XMIN;
- Xdouble yoffset = (double)XMAX;
- X
- Xint state = INVALID; /* state of the page */
- Xint restpathlen; /* length of current path */
- X
- Xopenpl ()
- X{
- X printf( "/%s findfont %g scalefont setfont\n", FONT, (double)PTSIZE );
- X everypage();
- X restpathlen = MAXPATHLENGTH;
- X state = CLEANPAGE | CLEANPATH;
- X}
- SHAR_EOF
- chmod 0644 openpl.c || echo "restore of openpl.c fails"
- echo "x - extracting output.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > output.c &&
- X/*
- X This file is part of plot2ps.
- X
- X Copyright (C) 1989 Rene' Seindal
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- X My current address is: seindal@diku.dk
- X*/
- X
- X#include "defs.h"
- X
- Xeverypage()
- X{
- X printf( "%g setlinewidth newpath\n", (double)LINEWIDTH );
- X}
- X
- X
- Xvoid shipout( fmt, arg1, arg2, arg3, arg4 )
- X char *fmt;
- X double arg1, arg2, arg3, arg4;
- X{
- X if ( --restpathlen == 0 ) {
- X restpathlen = MAXPATHLENGTH;
- X printf( "currentpoint stroke newpath moveto\n" );
- X }
- X printf( fmt, arg1, arg2, arg3, arg4 );
- X
- X DIRTYPATH;
- X}
- X
- Xclear()
- X{
- X if ( state & CLEANPATH )
- X return;
- X printf( "stroke newpath\n" );
- X state |= CLEANPATH;
- X restpathlen = MAXPATHLENGTH;
- X}
- SHAR_EOF
- chmod 0644 output.c || echo "restore of output.c fails"
- echo "x - extracting plot2ps.1 (Text)"
- sed 's/^X//' << 'SHAR_EOF' > plot2ps.1 &&
- X.\" Rene' Seindal (seindal@skinfaxe.diku.dk) Tue Mar 28 06:10:24 1989
- X.TH PLOT2PS 1 "Mar 28 1989"
- X.SH NAME
- Xplot2ps \- convert plot(5) data to PostScript
- X.SH SYNOPSIS
- X.B plot2ps
- X.SH DESCRIPTION
- X.I Plot2ps
- Xconverts
- X.IR plot "(5)"
- Xdata from standard input to PostScript on standard output.
- X.SH SEE ALSO
- Xplot(1), plot(5)
- X.SH AUTHOR
- XRen\'e Seindal, DIKU, U. of Copenhagen.
- X
- SHAR_EOF
- chmod 0644 plot2ps.1 || echo "restore of plot2ps.1 fails"
- echo "x - extracting plot2ps.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > plot2ps.c &&
- X/*
- X plot2ps --- convert Unix plot(5) data to PostScript
- X
- X Copyright (C) 1989 Rene' Seindal
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- X My current address is: seindal@diku.dk
- X*/
- X
- X#include <stdio.h>
- X
- X/* routines for reading plot data */
- Xint getch(); /* get a byte */
- Xint getsi(); /* get a signed short */
- Xchar *getstr(); /* get a string */
- X
- X#include "bytesex.h"
- X
- Xmain(argc,argv)
- X int argc;
- X char **argv;
- X{
- X int cmd;
- X int x, y, x0, y0, x1, y1; /* (x, y) coordinates */
- X int r; /* circle radius */
- X char *l; /* label/linemods */
- X
- X openpl();
- X while ( (cmd = getch()) != EOF ) {
- X switch (cmd) {
- X case 'm':
- X x = getsi();
- X y = getsi();
- X move( x, y );
- X break;
- X case 'n':
- X x = getsi();
- X y = getsi();
- X cont( x, y );
- X break;
- X case 'p':
- X x = getsi();
- X y = getsi();
- X point( x, y );
- X break;
- X case 'l':
- X x = getsi();
- X y = getsi();
- X x0 = getsi();
- X y0 = getsi();
- X line( x, y, x0, y0 );
- X break;
- X case 't':
- X l = getstr();
- X label( l );
- X break;
- X case 'a':
- X x = getsi();
- X y = getsi();
- X x0 = getsi();
- X y0 = getsi();
- X x1 = getsi();
- X y1 = getsi();
- X arc( x,y, x0, y0, x1, y1 );
- X break;
- X case 'c':
- X x = getsi();
- X y = getsi();
- X r = getsi();
- X circle( x, y, r );
- X break;
- X case 'e':
- X erase();
- X break;
- X case 'f':
- X l = getstr();
- X linemod( l );
- X break;
- X case 's':
- X x = getsi();
- X y = getsi();
- X x0 = getsi();
- X y0 = getsi();
- X space( x, y, x0, y0 );
- X break;
- X default:
- X fprintf( stderr, "Undefinde plot command 0%o\n", cmd );
- X }
- X }
- X closepl();
- X}
- X
- X/* getch() reads a single byte from stdin, not reading EOF more than once,
- X * and not returning more than 8 bits.
- X */
- Xint getch()
- X{
- X int ch;
- X static char eof = '\0';
- X
- X if (eof) return EOF;
- X
- X if ( (ch = getchar()) == EOF ) {
- X eof = '\1';
- X return EOF;
- X }
- X return ch&0377;
- X}
- X
- X/* getsi() return a signed short integer, big endian and sign extending.
- X * Returns EOF on end of file.
- X */
- Xint getsi()
- X{
- X int m, n;
- X int val;
- X
- X n = getch();
- X if ( n == EOF )
- X return EOF;
- X
- X m = getch();
- X if ( m == EOF )
- X return EOF;
- X
- X#ifdef BIG_ENDIAN
- X val = ((m << 8) | n);
- X#else
- X val = ((n << 8) | m);
- X#endif
- X if ( val & 0x8000 )
- X val |= ~0x7fff;
- X return val;
- X}
- X
- X/* getstr() reads a string from stdin. The string is terminated by EOF,
- X * newline or '\0'.
- X */
- Xchar *getstr()
- X{
- X char str[1024];
- X char *s = str;
- X int ch;
- X
- X while ( (ch = getch()) != EOF && ch != '\n' && ch != '\0' )
- X *s++ = ch;
- X *s = '\0';
- X
- X return str;
- X}
- X
- X
- SHAR_EOF
- chmod 0644 plot2ps.c || echo "restore of plot2ps.c fails"
- echo "x - extracting point.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > point.c &&
- X/*
- X This file is part of plot2ps.
- X
- X Copyright (C) 1989 Rene' Seindal
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- X My current address is: seindal@diku.dk
- X*/
- X
- X#include "defs.h"
- X
- X
- Xpoint( x, y )
- X{
- X clear();
- X printf( "%g %g %g 0 360 arc closepath fill newpath\n",
- X X(x), Y(y), (double)POINTDIAM );
- X state |= CLEANPATH;
- X DIRTYPAGE;
- X}
- SHAR_EOF
- chmod 0644 point.c || echo "restore of point.c fails"
- echo "x - extracting space.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > space.c &&
- X/*
- X This file is part of plot2ps.
- X
- X Copyright (C) 1989 Rene' Seindal
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- X My current address is: seindal@diku.dk
- X*/
- X
- X#include "defs.h"
- X
- Xspace( x0, y0, x1, y1 )
- X{
- X xscale = (double)(XMAX - XMIN) / (double)(x1 - x0);
- X yscale = (double)(YMAX - YMIN) / (double)(y1 - y0);
- X
- X xoffset = XMIN - xscale * (double)(x0);
- X yoffset = YMIN - yscale * (double)(y0);
- X}
- SHAR_EOF
- chmod 0644 space.c || echo "restore of space.c fails"
- exit 0
-
-
-