[comp.sources.misc] v09i061: draw, part 01/02

allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc) (12/13/89)

Posting-number: Volume 9, Issue 61
Submitted-by: jta@sah.vtt.fi (Juha Takala)
Archive-name: draw_jt/part01

[This is "dr_lib", a library to produce plots in various formats including
plot(3) and HPGL formats, and "draw", a simple front-end for the library.
See the README for more information.  ++bsa]

#! /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 2)."
# Contents:  License MANIFEST Makefile README dr_lib.h draw.1 getopt.c
#   getopt.l3 kiero.c koe koe.dat makefile.dos vttlogo
# Wrapped by allbery@uunet on Tue Dec 12 21:15:56 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'License' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'License'\"
else
echo shar: Extracting \"'License'\" \(14173 characters\)
sed "s/^X//" >'License' <<'END_OF_FILE'
X
XCopyright (C) 1988, 1989 by Juha Takala, jta@sah.vtt.fi
X
X$Id: License,v 1.1 89/12/08 14:00:46 jta Exp Locker: jta $
X
XI want this program to be free; that's why I say:
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; version 1.
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
XThe GNU General Public License follows (taken directly from GNU Emacs info).
X
X=====================Start of GNU General Public License ================
X
XGNU GENERAL PUBLIC LICENSE
X**************************
X                          Version 1, February 1989
X
X     Copyright (C) 1989 Free Software Foundation, Inc.
X     675 Mass Ave, Cambridge, MA 02139, USA
X
X     Everyone is permitted to copy and distribute verbatim copies
X     of this license document, but changing it is not allowed.
X
X
XPreamble
X========
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                            TERMS AND CONDITIONS
X
X  1. This License Agreement applies to any program or other work which
X     contains a notice placed by the copyright holder saying it may be
X     distributed under the terms of this General Public License.  The
X     "Program", below, refers to any such program or work, and a "work based
X     on the Program" means either the Program or any work containing the
X     Program or a portion of it, either verbatim or with modifications.  Each
X     licensee is addressed as "you".
X
X  2. You may copy and distribute verbatim copies of the Program's source
X     code as you receive it, in any medium, provided that you conspicuously and
X     appropriately publish on each copy an appropriate copyright notice and
X     disclaimer of warranty; keep intact all the notices that refer to this
X     General Public License and to the absence of any warranty; and give any
X     other recipients of the Program a copy of this General Public License
X     along with the Program.  You may charge a fee for the physical act of
X     transferring a copy.
X
X  3. You may modify your copy or copies of the Program or any portion of
X     it, and copy and distribute such modifications under the terms of Paragraph
X     1 above, provided that you also do the following:
X
X        * cause the modified files to carry prominent notices stating that
X          you changed the files and the date of any change; and
X
X        * 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        * 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        * 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
X     Mere aggregation of another independent work with the Program (or its
X     derivative) on a volume of a storage or distribution medium does not bring
X     the other work under the scope of these terms.
X
X  4. You may copy and distribute the Program (or a portion or derivative of
X     it, under Paragraph 2) in object code or executable form under the terms of
X     Paragraphs 1 and 2 above provided that you also do one of the following:
X
X        * 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        * 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        * 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
X     Source code for a work means the preferred form of the work for making
X     modifications to it.  For an executable file, complete source code means
X     all the source code for all modules it contains; but, as a special
X     exception, it need not include source code for modules which are standard
X     libraries that accompany the operating system on which the executable
X     file runs, or for standard header files or definitions files that
X     accompany that operating system.
X
X  5. You may not copy, modify, sublicense, distribute or transfer the
X     Program except as expressly provided under this General Public License.
X     Any attempt otherwise to copy, modify, sublicense, distribute or transfer
X     the Program is void, and will automatically terminate your rights to use
X     the Program under this License.  However, parties who have received
X     copies, or rights to use copies, from you under this General Public
X     License will not have their licenses terminated so long as such parties
X     remain in full compliance.
X
X  6. By copying, distributing or modifying the Program (or any work based
X     on the Program) you indicate your acceptance of this license to do so,
X     and all its terms and conditions.
X
X  7. Each time you redistribute the Program (or any work based on the
X     Program), the recipient automatically receives a license from the original
X     licensor to copy, distribute or modify the Program subject to these
X     terms and conditions.  You may not impose any further restrictions on the
X     recipients' exercise of the rights granted herein.
X
X  8. The Free Software Foundation may publish revised and/or new versions
X     of the General Public License from time to time.  Such new versions will
X     be similar in spirit to the present version, but may differ in detail to
X     address new problems or concerns.
X
X     Each version is given a distinguishing version number.  If the Program
X     specifies a version number of the license which applies to it and "any
X     later version", you have the option of following the terms and conditions
X     either of that version or of any later version published by the Free
X     Software Foundation.  If the Program does not specify a version number of
X     the license, you may choose any version ever published by the Free Software
X     Foundation.
X
X  9. If you wish to incorporate parts of the Program into other free
X     programs whose distribution conditions are different, write to the author
X     to ask for permission.  For software which is copyrighted by the Free
X     Software Foundation, write to the Free Software Foundation; we sometimes
X     make exceptions for this.  Our decision will be guided by the two goals
X     of preserving the free status of all derivatives of our free software and
X     of promoting the sharing and reuse of software generally.
X
X                                   NO WARRANTY
X
X 10. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
X     FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
X     OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
X     PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
X     OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
X     MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
X     TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
X     PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
X     REPAIR OR CORRECTION.
X
X 11. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
X     ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
X     REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
X     INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
X     ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT
X     LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES
X     SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE
X     WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN
X     ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
X
X                        END OF TERMS AND CONDITIONS
X
X
XAppendix: How to Apply These Terms to Your New Programs
X=======================================================
X
X  If you develop a new program, and you want it to be of the greatest
Xpossible use to humanity, the best way to achieve this is to make it
Xfree software which everyone can redistribute and change under these
Xterms.
X
X  To do so, attach the following notices to the program.  It is safest to
Xattach them to the start of each source file to most effectively convey
Xthe exclusion of warranty; and each file should have at least the
X"copyright" line and a pointer to where the full notice is found.
X
X     ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES.
X     Copyright (C) 19YY  NAME OF AUTHOR
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
XAlso add information on how to contact you by electronic and paper mail.
X
XIf the program is interactive, make it output a short notice like this
Xwhen it starts in an interactive mode:
X
X     Gnomovision version 69, Copyright (C) 19YY NAME OF AUTHOR
X     Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
X     This is free software, and you are welcome to redistribute it
X     under certain conditions; type `show c' for details.
X
XThe hypothetical commands `show w' and `show c' should show the
Xappropriate parts of the General Public License.  Of course, the
Xcommands you use may be called something other than `show w' and `show
Xc'; they could even be mouse-clicks or menu items---whatever suits your
Xprogram.
X
XYou should also get your employer (if you work as a programmer) or your
Xschool, if any, to sign a "copyright disclaimer" for the program, if
Xnecessary.  Here a sample; alter the names:
X
X     Yoyodyne, Inc., hereby disclaims all copyright interest in the
X     program `Gnomovision' (a program to direct compilers to make passes
X     at assemblers) written by James Hacker.
X
X     SIGNATURE OF TY COON, 1 April 1989
X     Ty Coon, President of Vice
X
XThat's all there is to it!
X
X====================== End of GNU General Public License ================
END_OF_FILE
if test 14173 -ne `wc -c <'License'`; then
    echo shar: \"'License'\" unpacked with wrong size!
fi
# end of 'License'
fi
if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(561 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X License                    1	
X MANIFEST                   1	
X Makefile                   1	
X README                     1	
X dr_lib.c                   2	
X dr_lib.h                   1	
X draw.1                     1	
X draw.c                     2	
X getopt.c                   1	
X getopt.l3                  1	
X kiero.c                    1	
X koe                        1	
X koe.dat                    1	
X makefile.dos               1	
X vttlogo                    1	
END_OF_FILE
if test 561 -ne `wc -c <'MANIFEST'`; then
    echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(2766 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X#
X#	Makefile for draw
X#	Copyright (C) 1988, 1989 by Juha Takala
X#	jta@sah.vtt.fi
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; version 1.
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# the file "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# Send bug reports and suggestions to:
X#	jta@sah.vtt.fi
X#
X# $Id: Makefile,v 2.7 89/12/11 09:24:39 jta Exp $
X#
X
XSRCS	= dr_lib.h dr_lib.c draw.c
XDOCS	= README draw.1 License
XMAKES	= Makefile makefile.dos
XOTHERS	= koe koe.dat vttlogo kiero.c 
XGETOPTSRC = getopt.c getopt.l3
XKIT	= $(DOCS) $(SRCS) $(MAKES) $(OTHERS) $(GETOPTSRC)
X
X########## BEGINning of configuration section #############
X
XCC = cc
X
X# Choose one.  UNIX (SysV) and MSDOS are tested, BSD should be easy, and VMS
X# has also been done a long time and many versions ago
XOS = -DUNIX
X#OS = -DMSDOS
X#OS = -DVMS
X
X# SYSV shared libraries work in my system!  Take it or leave it.
XLIBSH	= -lc_s
X
X# Choose of these; gcc allows both:
X#DEBUG = -g
XDEBUG = -O
X
X# Do define this if you want *NIX plot(3) interface calls
XPLOT = -DPLOT
X
X# Do define this if you want LIBGL.  It is a library that will handle ega
X# etc.  Look for its docs.  
XGL_LIB = -DGL_LIB
X
X# Where to find gl_plot() funtions.  If you didn't define GL_LIB,
X# you don't need this, either
XLIBGL	= ../gl_plot/gl.a
X
X# Standard *NIX plot(3) library spec.  This might also be -l4014 for
X# direct tek4014 output.  See plot(3).
XLIBPLOT = -lplot
X
X# If you don't have getopt library, use this.  This is the one that has been
X# posted into netland long ago.  I guess MS-DOSsers need this.
X# GETOPT = getopt.o
X
XCI = ci
XCO = co
XSHAR = makekit -s10k
XTAR = gtar -zcf draw.zar
X
X################## END of configuration section ###################
X
XCFLAGS	= $(DEBUG) $(GL_LIB) $(OS) $(PLOT)
X
X# Collection of libraries to give ld
XLIBS	= $(LIBGL) $(LIBPLOT) $(LIBSH) -lm
X
XOBJS	= draw.o dr_lib.o $(GETOPT)
X
Xdraw:	$(OBJS) $(LIBGL)
X	cc $(CFLAGS) -o $@ $(OBJS) $(LIBS)
X
X$(OBJS): dr_lib.h
X
Xdemo:	kiero draw
X#	kiero | ./draw -tplot | tplot -T4014
X# maybe it is better to leave the fun to be done by hand...
X
X# the name is finnish and means 'screwed'
Xkiero:	kiero.c
X	cc -o kiero kiero.c -lm $(LIBSH)
X
Xci:	;		for i in $(KIT); do $(CI) $$i </dev/null; done
Xco:	;		for i in $(KIT); do $(CO) $$i; done
X
Xkit:	$(KIT);		$(SHAR) $(KIT)
Xzar:	$(KIT);		$(TAR) $(KIT)
Xlint:	;		lint $(CFLAGS) $(SRCS)
END_OF_FILE
if test 2766 -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'\" \(3603 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
X$Id: README,v 2.3 89/12/11 09:25:07 jta Exp $
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 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     file "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
XWhat we have here
X*****************
X
Xdr_lib.c :
X----------
X
Xdr_lib.c is a collection of simple device level graphics drawing
Xsubroutines.  dr_lib.c has several output choises: it will produce HPGL
Xdirectly, produce plot(3) code, and use gl_plot(3) library to support EGA,
XCGA, HERCULES, IBM graphics printer, Laserjet, etc.  gl_plot was posted in
Xcomp.sources.unix some time ago, and it is made by umix!m-net!dtlewis!lewis,
Xthe rest is made by me.  There is a compile time scwith (see Makefile) to
Xinclude code generation for gl_plot().  If you want to include gl_plot()
Xcode, make sure your gl_plot() library works in your system.
X
XI once made a quick port of gl_lib to 386 UNIX (Enix), but I have no longer
Xacces to that system.  My current system is Interactive SVr3.2, and it was
Xnot so easy to port gl_lib here.  I also have X now, and that has Tektronix
Xemulation.   That is why I implemented the standard *NIX plot(3) library
Xinterface into dr_lib.c (*NIX has also tplot(1)), so this is my current
Xmethod to get plots onto screen.
X
X
Xdraw.c :
X--------
X
Xdraw.c is intended to be a "front-end" for dr_lib routines.  draw.c makes
Xuse of line and text drawing and pen movement routines to build x-y pictures
Xwith axes, labels, text etc.  Nothing will prevent you from making your own
Xmain program to call directly functions in dr_lib.c, if you like.  Real
X[nt]roff-able man page is also included in this kit (draw.1), hope it is up
Xto date.
X
X
Xkiero.c :
X---------
X
Xkiero.c is a fancy demo program that will produce data into its stdout, to
Xbe processed further by draw.  It will also put enough definitions, so that
Xyou can pipe its stdout directly to draw.
X
X
XCompiling and Installing :
X--------------------------
X
X1) Edit the Makefile to suit your system.  Then say 'make'.  This version of
X   draw is developed under Interactive 386/ix SysV 3.2.  draw was born veery
X   looong time ago started under BSD 4.x, has also been compiled under
X   MosseDos (MSC x), and even VMS.  Porting to these systems should be quite
X   easy, send the diffs to me if there is something special.
X
X2) draw will use enviroment variable DRAWDEV to decide what kind of device
X   it should work for.  Default value is `ega' for gl_plot() subroutine
X   package.  That, again will use GLMODE to choose between EGA, CGA, VGA
X   etc.  I have:
X	DRAWDEV=plot;	export DRAWDEV	# my default is to pipe to tplot(1)
X	GLMODE=256;	export GLMODE	# but specifying -tega, I get it to
X					# my Epson FX-80...
X	PLOTDEV=lp;	export PLOTDEV	# ... which is /dev/lp
X   in my .profile 
X
X
X
XTo do :
X-------
X
X- Real support for X.
X
X- Suggestions ?
X
X
X   I would like to hear a) experiences in porting this package into
X   different systems, b) bugs & new features, so that I can fix and
X   include them in next version, if it ever will be made.
X
X	jta@sah.vtt.fi	voice: +358 0 4566425
X
X	Juha Takala
X	VTT/SAH
X	PL 34
X	02151 Espoo
X	Finland
X
X
END_OF_FILE
if test 3603 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'dr_lib.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'dr_lib.h'\"
else
echo shar: Extracting \"'dr_lib.h'\" \(4029 characters\)
sed "s/^X//" >'dr_lib.h' <<'END_OF_FILE'
X/*
X
XCopyright (C) 1988, 1989 by Juha Takala, jta@sah.vtt.fi
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; version 1.
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     the file "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
X */
X
X
X/* $Id: dr_lib.h,v 2.3 89/12/08 14:00:31 jta Exp Locker: jta $
X *
X * This is header file for a subroutine package that contains
X * device level routines to manipulate graphics devices such as
X *  - hpgl output for hp7475 plotter
X *  - gl_plot(3) calls for EGA or matrix printer output
X *  - plot(3) interface
X *
X * Following routines are provided:
X *
X *
X * void circle()
X *    - draw a small circle at current point
X *
X * void dr_set_pen(n)
X * int n;
X *    - select pen n
X *    - n==0 menas 'put it away'
X *    - n = 1..6 means select pen n
X *    - n<0 or n>6 issues error message and selects pen 1
X *
X * void dr_goto(x,y,linetype,penup,relative)
X * float x, y; int linetype, penup;
X *    - move pen to point (x,y)
X *    - if penup!=0, will draw line of type linetype
X *    - if relative!=0, will move relative to current point
X *
X * void dr_draw_line(x1, y1, x2, y2, linetype)
X * float x1, y1, x2, y2; int linetype;
X *    - draw a line of type linetype from poin (x1,y1) to point (x2,y2)
X *
X * void dr_set_shape(x)
X * float x;
X *    - change text 'fatness'
X * 
X * void dr_set_size(x)
X * float x;
X *    - change text size
X * 
X * void dr_draw_array(x, y, n, linetype)
X * float x[], y[]; int n, linetype;
X *    - points (x[i],y[i]) (i = 0..n-1) will be connected
X *      with line of linetype
X *
X * void dr_put_mark(x, y, mark) 
X * float x, y; char mark;
X *    - put marker mark at point (x,y)
X *
X * void dr_put_text(xpos, ypos, xofs, yofs, dir, size, s)
X * float xpos, ypos, xofs, yofs; char *dir, *size, *s;
X *    - put text s to position (xpos+xofs,ypos+yofs) in direction dir
X *
X * int dr_finish()
X *    - finish plotting, report errors, return number of them
X *
X * void dr_start(xlow, xhigh, ylow, yhigh, dev)
X * float xlow, xhigh, ylow, yhigh; int dev;
X *    - prepare plotting for device dev, establish relative drawing area
X *
X * void dr_xgrid(n)
X * int n;
X *    - draw vertical grid lines
X *
X * void dr_ygrid(n)
X * int n;
X *    - draw horizontal grid lines
X *
X * void dr_area_def(xlow, xincr, xhigh, ylow, yincr, yhigh, no_axes)
X * float xlow, xincr, xhigh, ylow, yincr, yhigh;
X * int no_axes;
X *    - establish user coordinates
X *    - draw x- and y-axis and tick marks (only if no_axes == 0)
X *
X * void dr_errmsg(s)
X * char *s;
X *    - send string s to error log file
X */
X
Xint dr_set_ltype();
Xvoid dr_goto(), dr_draw_line(), dr_draw_array(), dr_put_mark();
Xvoid dr_set_pen(), dr_set_shape(), dr_set_size(), dr_put_text(), dr_set_cset();
Xint dr_finish();
Xvoid dr_start(), dr_area_def();
Xvoid dr_xgrid(), dr_ygrid(), dr_draw_circle();
Xvoid dr_errmsg(), dr_warnmsg();
X
X
X/* The following devices are supported: */
X#define HP7475 1		/* hp 7475 plotter */
X#define SCREEN 2		/* ega == dtlewis's gl_plot */
X#define PLOTLIB 3		/* UNIX plot(3) interface */
X#define FIRSTDEV HP7475
X#define LASTDEV PLOTLIB
X#define INVDEV -1
X#define DEVMASK 0xff
X
X/* the following are paper size coding */
X#define SIZE_A4 0x100
X#define SIZE_A3 0x200
X#define SIZE_A  0x400
X#define SIZE_B  0x800
X#define SIZEMASK 0xff00
X
X#ifdef PLOT
Xextern void openpl();
Xextern void erase();
Xextern void label();
Xextern void line();
Xextern void circle();
Xextern void arc();
Xextern void move();
Xextern void cont();
Xextern void point();
Xextern void linemod();
Xextern void space();
Xextern void closepl();
X#endif
X
X#ifdef MSDOS
X#define M_PI_2 1.5707963268
X#endif
END_OF_FILE
if test 4029 -ne `wc -c <'dr_lib.h'`; then
    echo shar: \"'dr_lib.h'\" unpacked with wrong size!
fi
# end of 'dr_lib.h'
fi
if test -f 'draw.1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'draw.1'\"
else
echo shar: Extracting \"'draw.1'\" \(14856 characters\)
sed "s/^X//" >'draw.1' <<'END_OF_FILE'
X.\" dummy line
X' $Id: draw.1,v 2.4 89/12/11 09:25:12 jta Exp $
X.TH DRAW 1L "" "Graphics utilities"
X.UC 4
X.SH NAME
Xdraw
X\- Yet another line- etc. drawing utility.
X.SH SYNOPSIS
X\fBdraw\fP [\fIoptions\fP] [\fIfiles\fP]
X.SH DESCRIPTION
XThe purpose of \fBdraw\fP is basically to read 
X(\fIx,y\fP)
Xcoordinates from user's data file(s) (or stdin) and produce a
Xpolyline connecting those points on a graphic device.
XCoordinate axes, labels for axes, etc. are made on user's request.
X.PP
XThe good thing about this program is, that it accepts infinite size input;
Xdata is not stored inside program, but procecced immediately.
X
XThe output data should be sent to desired device.
XThe input data stream is organised as lines of text.
XThere are three kinds of input lines:
X.RS 2
X.IP \(bu 3
XEmpty lines containing only white space, and comment lines
Xstarting with `\fB#\fR'.
XAdding or removing these has no effects on output.
X.IP \(bu
XPseudo comment lines (command lines); they look like
X`\fB#$ \fIcommand arguments\fR'.
XThese lines have effects on what is to be output, and thus what
Xthe picture will look like.
X.IP \(bu
XOthers are taken to be data lines.
XData line that does not have
Xtwo floating point numbers (generally) at beginning, is invalid
Xand will be discarded, and error message will be generated.
XRest
Xof the line is not used, so it may contain any text.
X(See also \fB-f\fP)
X.RE
X.PP
XCurrently supported devices are (see \fB-t\fR):
X.RS 2
X.IP \(bu 3
XHP7475 plotter.  Using this you get the HPGL code to stdout.
XUse redirection to lp(1), /dev/tty00 or whatever you like.
X.IP \(bu
XEGA & friends.
XThis is implemented by using \fIgl_plot\fR(3)
Xlibrary calls, and so you can get the picture to whatever device
Xthat library can handle.  The library has been posted in 
Xcomp.sources.unix and is made by D. T. Lewis.  Existence of this device
Xdepends of compile-time option, and may not be present at your
Xsystem, contact the person who did the installation at your site.
X
X.IP \(bu
XStandard *NIX \fIplot\fP(3) output (\fBdraw\fP versions 2.x and later).
XThis produces device independent stuff to stdout, so you may want to filter
Xit futher with \fItplot\fP(1) into suitable form for your graphics
Xdevice. 
X.RE
X.PP
X\fBdraw\f may give some error and warning messages during its run.
XDuring the plotting, the messages are collected into a log file named
X\fIdraw.err\fP 
Xto be viewed after the run, because stdout and stderr might be the same
Xdevice (as in the case of a T-connected plotter).  After the run, the
Xnumber of errors and warnings is reported, if non-zero, or the log-file
Xis removed.
X.PP
XFatal errors cause immediate termination of program.  They are 
Xgenerated by invalid device or range specifications and such.
XNon-fatal errors are generated, when invalid pseudo comments are
Xfound, invalid data lines are found, or data points fall
Xoutside device hard limits.  Warnings are generated, when data
Xpoints fall outside user coordinate ranges.
X.PP
XExit status is 1 if errors were detected, 2 if nothing was done,
Xand 0 otherwise (warnings are possible in this case).
X.SS Controlling the job
X.PP
XYou can change the way of drawing with 
X.B command line options
Xor
X.B pseudo comments
Xor both.
XThere are options to set plotting area on device, axis
Xranges, label texts, name for the picture, etc.
X.PP
XAll command line options must be given before any
Xfilenames, they are parsed by \fIgetopt\fR(3).
X.PP
XMost pseudo comments need arguments.
XTextual arguments contunue till the end of line.
XArguments are separated form the command by
Xat least one whitespace character, and from each other by exactly
Xone `\fB,\fR' (comma).
X.PP
XMost pseudo comments remember the pen position (thinking of plotter
Xoutput), so you can easily put some 
Xexplanatory text into your picture at any moment without
Xmaking a break in the figure to be drawn.
X.PP
XIn the following both the command line options and pseudo comments, that
Xhave same effect, 
Xare described in parallel, because there are both ways available
Xto do most things. 
X.PP
X.B #$absolute
X.I \fR[\fPx_origin,y_origin\fR]\fP
X.br
X.B #$endabsolute
X.RS
XAfter the \fB#$absolute\fP command, following input data pairs, until
Xthe \fB#$endabsolute\fP command, are converted as follows:  each \fIx\fP
Xvalue is added to \fIx_origin\fP, and the resulting number is scaled so
Xthat 0.0 corresponds to \fIxlow\fP and 1.0 corresponds to \fIxhigh\fP
X(see \fB-x\fP and \fB#$xrange\fP).  Similar conversion
Xapplies to \fIy\fP-values.  Default values for \fIx_origin\fP and
X\fIy_origin\fP are 0.0, if they are missing (or invalid, in which case
Xno error is reported!).
X
XThis feature is supposed to be useful with the \fB#$include\fP command,
Xso that some constant data,  eg. logos or such, may be inserted into
Xpictures.  Note, however, that changing the ratio of \fIx\fP and \fIy\fP
Xdirection's relative drawing areas (see \fB-a\fP and \fB#$area\fP) will
Xaffect the shape!
X.RE
X.PP
X.B -a
X.I x1,y1,x2,y2
X.br
X.B #$area
X.I x1,y1,x2,y2
X.RS
XCan be used to specify plotting area on device, when several
Xpictures are to be plotted on one paper sheet.
X.I x1,y1
Xwill specify lower left corner and
X.I x2,y2
Xwill specify upper right corner.  Enough
Xmarginal area is automatically reserved for axis labels and picture
Xname texts.
XDefault is 0,0,1,1 to use whole device area.  Pseudo command may
Xtake effect only if command line option has not been specified,
Xand must be given before device initialization (see \fB#$init\fR) has
Xtaken place, otherwise the default will be used.
X.RE
X.PP
X.B -b
X.br
X.B #$noaxes
X.RS
XDisables the drawing of coordinate axes, labels, name etc.
XOnly
Xthe data points (and commands inside data) will produce somthing
Xvisible on device.
XTo take effect, this must be specified before
Xdevice initialization (see \fB#$init\fR) is done.
X.RE
X.PP
X.B -c
X.I n
X.br
X.B #$cset
X.I n
X.RS
XSpecifies character set \fIn\fP to be used.  Meaning of \fIn\fP
Xis the same as for HP7475.
XPseudo comment can be used many times in the data to mix different
Xcharacter sets.  
XChanging character set does not affect pen's position or up/down status.
XInitial value is 0 for US Ascii character set.
X\fB#$cset\fP will force device initialization.
X\fBNote:\fP all devices are not capable to support this.  In those cases
Xthis command is ignored.
X.RE
X.PP
X.B -d
X.br
X.BR #$date | #$time
X.RS
XAsks \fBdraw\fP to output current date (or date and time) in upper right
Xcorner of the picture.
XGiven \fB-dd\fP or \fB -d -d \fP on command line is equvalent to
X\fB#$time\fP, and  causes also current time to be output.
X.RE
X.PP
X.B #$direction
X.I angle
X.RS
XSpecify \fIangle\fP (radians) to be the direction, where text will be
Xwritten form now on.
XInitial value is 0.0 (left to right, parallel to x-axis).  
XPositive values go counterclockwise.
XWorks in funny way with device \fB-tplot\fP: letters are not re-oriented,
Xbut lines of text run in desired \fIangle\fP.
X.RE
X.PP
X.B -f
X.I n1,n2
X.RS
XChanges the format of input.
XUsually the two first columns are
Xconsidered on each line, and the order is so that first column is
Xvalue for \fIx\fP, and second column is value for \fIy\fP.
XThis option tells \fBdraw\fP that value for \fIx\fP should be taken from
Xcolumn \fIn1\fP, and \fIy\fP should be taken from column \fIn2\fP.
XGiving \fB-f 2\,1\fP effectively reverses the variables.
XPseudo comment version is not available.
X.RE
X.PP
X.B -g
X.I nx,ny
X.br
X.B #$grid
X.I nx,ny
X.RS
XSpecify how grid lines should be drawn.
XIf this option is not
Xgiven, no grid lines are drawn.
X.IR nx " applies to " x- "grid lines (parallel to "
X.IR y- "axis), and " ny " applies to " y- "grid"
Xlines, both should be (small) non-negative integers.
XUsing 1 for either \fIn\fP will produce grid lines at every
X\fIincr\fP positions (see options \fB-x\fP and \fB-y\fP).
XUsing 2 will double the grid line density etc.
XSpecifying 0 for either direction will produce no grid lines for that
Xdirection.
X.RE
X.PP
X.B -h
X.RS
XGives short description of available command line options and
Xexits.
X.RE
X.PP
X.B #$include
X.I file
X.RS
XCauses \fBdraw\fP to take temporarily input from file \fIfile.\fP
XAfter that file is done, input resumes from current file.  Nesting is
Xallowed, ie. included files may include other files.
X.RE
X.PP
X.B #$init
X.RS
XForces internal and device dependant initialization with current
Xvalues.  This is not necessary, 
Xbecause the initializations are done automatically by the time
Xwhen first data point is to be processed.
XInternal initializations include following things:
X.RS 2
X.IP 0) 4
XMemory allocation for raster buffers, mode switching into graphic
Xmode and ioctls to map EGA-memory into user-space, if appropriate.
X.IP 1)
XFix internal translation between user coordinate system and device
Xcoordinate system.
XUser coordinate system is defined by
X.IR xlow,xhigh " and " ylow,yhigh
Xwhich are taken from
X.BR -x " and " -y
Xcommand line options' arguments, or, if they were not given, from
X.BR #$xrange " and " #$yrange
Xpseudo comments' arguments, or if they have not been found (at the
Xmoment), default values are used.
XDevice coordinate system is device dependent.
X.IP 2)
XDraw coordinate axes and units, if allowed.
X.IP 3)
XDraw grid lines if requested.
X.IP 4)
XPrint labels for axes, if specified.
X.IP 5)
XPrint name for the picture, if specified.
X.IP 6)
XPrint current date (and time), if requested.
X.RE
X.PP
XSteps 4).. may be done also at later time, but only if no
Xspecification is available at the time of initialization.
XIn any
Xcase it is checked that each of these step is made at most once.
X.RE
X.PP
X.B -l
X.I n
X.br
X.B #$ltype
X.I n
X.RS
XChoose line type \fIn\fP to be used.  The meaning for \fIn\fP is the
Xsame as in HPGL, but 7 is for continous line (initial value).
X\fB#$ltype\fP will force device initialization.
X\fBNote:\fP all devices are not capable to support this.  In those cases
Xthis command is ignored.
X.PP
X.RE
X.PP
X.B -m
X.I c
X.br
X.B #$mark
X.I c
X.RS
XChoose character \fIc\fP
Xto be used as marker at each data point, no line will be drawn to
Xconnect them.  This is a way to get a "scattergram" of your
Xobservations.  Pseudocomment may also specify no 
Xmarker at all (just say \fB#$mark\fR).
XThat will tell \fBdraw\fP to start drawing continuous lines again, using
Xcurrent line type. 
XMarker may be changed as many times as desired, and the effect is
Ximmediate from next data point on, until next change.
X.RE
X.PP
X.B -n
X.I nametext
X.br
X.B #$name
X.I nametext
X.RS
XCauses \fInametext\fP to be output on top of the picture.
XThe text is centered and character size is twice the default size.
XName may be specified only once, so if command line has specified one,
Xpseudo comment has no effect.
X.RE
X.PP
X.B -p
X.I n
X.br
X.B #$pen
X.I num
X.RS
XChoose pen number \fIn\fP to be used, default is 1.
XHP7475 has room for 6 pens, and EGA has not implemented this yet
X(makes white), but.. "coming real soon now".  \fIplot\fP(3) does not
Xhave any colors.  Pen status (up/down) does not change.
X\fB#$pen\fP will force device initialization.
X.RE
X.PP
X.B #$penup
X.RS
XLift pen up.  Pen will go automatically down after next data point.
XThis makes it possible to draw more than one line into one picture:
XAt the point, where one line should end, just put command
X`\fB#$penup\fR' and continue with the data for next line.
XIt might also be wise to put `\fB#$ltype \fInum\fR' and/or
X`\fB#$pen \fInum\fR' to make some visible difference for those
Xlines.
X.RE
X.PP
X.B -S
X.I factor
X.br
X.B #$shape 
X.I factor
X.RS
XChange character fatness.  \fIfactor\fP
Xshould be a floating point number and not far from 1.0 to get
Xreasonable looking characters.  See also \fB#$size\fR.  Does not work
Xwith device \fB-tplot\fP.  \fBNote:\fP Relative plotting area's ratio in
X\fIx\fP and \fIy\fP directions also affects the character's shape (see
X\fB#$size\fP).
X.RE
X.PP
X.B -s
X.I factor
X.br
X.B #$size
X.I factor
X.RS
XChange character's size.  Actual character dimensions for HP7475
Xare:
X.RS 3
X\fIheight = size*\fR(1.5/100)\fI*yrelarea\fR
X.br
X\fIwidth = size*\fR(0.75/100)\fI*shape_factor*xrelarea,\fR
X.RE
Xwhere \fIxrelarea\fR and \fIyrelarea\fR are calculated from
X\fB-a\fR's or \fB#$area\fR's arguments.  Work in a funny way
Xwith device \fB-tplot\fP:  charater size does not change, but there
Xdistance from each other (in plotted strings) does.
X.RE
X.PP
X.B -t
X.I device
X.RS
XChoose \fIdevice\fP as the target.  Possible \fIdevice\fPs are:
X.BR a4 ", " a3 ", " a " and "
X.B b
Xto specify that size paper for HP7475 plotter and \fBega\fP
Xfor EGA & friends (\fIgl_plot\fR(3) library calls).
XVersions 2.x and later have standard *NIX \fIplot\fP(3) interface
Xavailable with \fIdevice\fP \fBplot\fP.
XIf no device is specified, environment variable \fBDRAWDEV\fP
Xwill be checked, and that value is used.  If no value is found,
X\fBdraw\fP will use a default value (\fBa4\fR).
XRefer \fIgl_plot\fR(3) to find its ways to determine its output devices
X(resolution and such).
X.RE
X.PP
X.B #$text 
X.I x,y,sometext
X.RS
XOutput the text \fIsometext\fP into picture so that it starts at
Xposition \fI(x,y)\fP.  The text is made using current settings of
X.BR #$direction ", " #$size ", "
X.BR #$shape " and " #$cset ". "
XThis is the command to put explanatary text into the picture.
XEach line must be positioned separately.  See also 
X.BR #$alabel " and " #$rlabel .
XThis will force device initialization.
X.RE
X.PP
X.BR #$alabel | #$rlabel
X.I x,y,sometext
X.RS
XOutput the text \fIsometext\fP
Xinto picture so that it starts at position \fIx,y\fR (with
X\fB#$alabel\fR), and at offset \fIx,y\fR from current position
X(with \fB#$rlabel\fR).
XThe text is made using current settings of
X.BR #$direction ", " #$size ", "
X.BR #$shape " and " #$cset ".
X.PP
XAfter the text is made, a solid line is drawn below it, and the
Xline's left end is connected to the point where last data point
Xwas.  There is also made a tiny circle.  The purpose of all this
Xis to provide a way to put labels to individual lines on a picture
Xwith more than one line.
XThese will force device initialization.
X.RE
X.PP
X.B -v
X.RS
XPrints version number on stderr and exits.
X.RE
X.PP
X.BR -x | -y
X.I low,incr,high
X.br
X.BR #$xrange | #$yrange
X.I low,incr,high
X.RS
XDefines user coordinate system to be used.
XAll data points to be
Xdrawn are given using these user coordinates.
X.I low
Xand 
X.I high
Xvalues define the range of observations that will fall in the
Xpicture area.
XThese values are also output below the axis's heads.
X.I incr
Xdefines, how often to output additional numbers below axes.
XIf no
Xuser coordinates are specified,
X.B draw
Xwill use default ranges
X.I -1,1,1
Xfor both directions.
XSee also option \fB-g\fP for grid lines.
X.RE
X.PP
X.BR -X | -Y
X.I axistext
X.br
X.BR #$xlabel | #$ylabel
X.I axistext
X.RS
XSpecify
X.I axistext
Xto be output at the high end of the axis.
XThe text is output in
Xsize of 1.4 times the default size.
XNo axis texts are made by
Xdefault.
X.RE
X.PP
X.SH BUGS
XCertaily.
XTell me when you find.
X.PP
X.SH SEE ALSO
Xplot(3), gl_plot(3), HP7475 Programmers manual.
X.PP
X.SH AUTHOR
XJuha Takala
X.br
Xjta@sah.vtt.fi
END_OF_FILE
if test 14856 -ne `wc -c <'draw.1'`; then
    echo shar: \"'draw.1'\" unpacked with wrong size!
fi
# end of 'draw.1'
fi
if test -f 'getopt.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'getopt.c'\"
else
echo shar: Extracting \"'getopt.c'\" \(2467 characters\)
sed "s/^X//" >'getopt.c' <<'END_OF_FILE'
X/*
X**	@(#)getopt.c	2.2 (smail) 1/26/87
X*/
X
X/*
X * Here's something you've all been waiting for:  the AT&T public domain
X * source for getopt(3).  It is the code which was given out at the 1985
X * UNIFORUM conference in Dallas.  I obtained it by electronic mail
X * directly from AT&T.  The people there assure me that it is indeed
X * in the public domain.
X * 
X * There is no manual page.  That is because the one they gave out at
X * UNIFORUM was slightly different from the current System V Release 2
X * manual page.  The difference apparently involved a note about the
X * famous rules 5 and 6, recommending using white space between an option
X * and its first argument, and not grouping options that have arguments.
X * Getopt itself is currently lenient about both of these things White
X * space is allowed, but not mandatory, and the last option in a group can
X * have an argument.  That particular version of the man page evidently
X * has no official existence, and my source at AT&T did not send a copy.
X * The current SVR2 man page reflects the actual behavor of this getopt.
X * However, I am not about to post a copy of anything licensed by AT&T.
X */
X
X/* #define BSD */
X#ifdef BSD
X#include <strings.h>
X#else
X#define index(x,y) strchr((x),(y))
X#include <string.h>
X#endif
X
X/*LINTLIBRARY*/
X#define NULL	0
X#define EOF	(-1)
X#define ERR(s, c)	if(opterr){\
X	extern int write();\
X	char errbuf[2];\
X	errbuf[0] = c; errbuf[1] = '\n';\
X	(void) write(2, argv[0], (unsigned)strlen(argv[0]));\
X	(void) write(2, s, (unsigned)strlen(s));\
X	(void) write(2, errbuf, 2);}
X
X
Xint	opterr = 1;
Xint	optind = 1;
Xint	optopt;
Xchar	*optarg;
X
Xint
Xgetopt(argc, argv, opts)
Xint	argc;
Xchar	**argv, *opts;
X{
X	static int sp = 1;
X	register int c;
X	register char *cp;
X
X	if(sp == 1)
X		if(optind >= argc ||
X		   argv[optind][0] != '-' || argv[optind][1] == '\0')
X			return(EOF);
X		else if(strcmp(argv[optind], "--") == NULL) {
X			optind++;
X			return(EOF);
X		}
X	optopt = c = argv[optind][sp];
X	if(c == ':' || (cp=index(opts, c)) == NULL) {
X		ERR(": illegal option -- ", c);
X		if(argv[optind][++sp] == '\0') {
X			optind++;
X			sp = 1;
X		}
X		return('?');
X	}
X	if(*++cp == ':') {
X		if(argv[optind][sp+1] != '\0')
X			optarg = &argv[optind++][sp+1];
X		else if(++optind >= argc) {
X			ERR(": option requires an argument -- ", c);
X			sp = 1;
X			return('?');
X		} else
X			optarg = argv[optind++];
X		sp = 1;
X	} else {
X		if(argv[optind][++sp] == '\0') {
X			sp = 1;
X			optind++;
X		}
X		optarg = NULL;
X	}
X	return(c);
X}
END_OF_FILE
if test 2467 -ne `wc -c <'getopt.c'`; then
    echo shar: \"'getopt.c'\" unpacked with wrong size!
fi
# end of 'getopt.c'
fi
if test -f 'getopt.l3' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'getopt.l3'\"
else
echo shar: Extracting \"'getopt.l3'\" \(2755 characters\)
sed "s/^X//" >'getopt.l3' <<'END_OF_FILE'
X.TH GETOPT 3 local
X.DA 25 March 1982
X.SH NAME
Xgetopt \- get option letter from argv
X.SH SYNOPSIS
X.ft B
Xint getopt(argc, argv, optstring)
X.br
Xint argc;
X.br
Xchar **argv;
X.br
Xchar *optstring;
X.sp
Xextern char *optarg;
X.br
Xextern int optind;
X.ft
X.SH DESCRIPTION
X.I Getopt
Xreturns the next option letter in
X.I argv
Xthat matches a letter in
X.IR optstring .
X.I Optstring
Xis a string of recognized option letters;
Xif a letter is followed by a colon, the option is expected to have
Xan argument that may or may not be separated from it by white space.
X.I Optarg
Xis set to point to the start of the option argument on return from
X.IR getopt .
X.PP
X.I Getopt
Xplaces in
X.I optind
Xthe
X.I argv
Xindex of the next argument to be processed.
XBecause
X.I optind
Xis external, it is normally initialized to zero automatically
Xbefore the first call to 
X.IR getopt .
X.PP
XWhen all options have been processed (i.e., up to the first
Xnon-option argument),
X.I getopt
Xreturns
X.BR EOF .
XThe special option
X.B \-\-
Xmay be used to delimit the end of the options;
X.B EOF
Xwill be returned, and
X.B \-\-
Xwill be skipped.
X.SH SEE ALSO
Xgetopt(1)
X.SH DIAGNOSTICS
X.I Getopt
Xprints an error message on
X.I stderr
Xand returns a question mark
X.RB ( ? )
Xwhen it encounters an option letter not included in
X.IR optstring .
X.SH EXAMPLE
XThe following code fragment shows how one might process the arguments
Xfor a command that can take the mutually exclusive options
X.B a
Xand
X.BR b ,
Xand the options
X.B f
Xand
X.BR o ,
Xboth of which require arguments:
X.PP
X.RS
X.nf
Xmain(argc, argv)
Xint argc;
Xchar **argv;
X{
X	int c;
X	extern int optind;
X	extern char *optarg;
X	\&.
X	\&.
X	\&.
X	while ((c = getopt(argc, argv, "abf:o:")) != EOF)
X		switch (c) {
X		case 'a':
X			if (bflg)
X				errflg++;
X			else
X				aflg++;
X			break;
X		case 'b':
X			if (aflg)
X				errflg++;
X			else
X				bproc();
X			break;
X		case 'f':
X			ifile = optarg;
X			break;
X		case 'o':
X			ofile = optarg;
X			break;
X		case '?':
X		default:
X			errflg++;
X			break;
X		}
X	if (errflg) {
X		fprintf(stderr, "Usage: ...");
X		exit(2);
X	}
X	for (; optind < argc; optind++) {
X		\&.
X		\&.
X		\&.
X	}
X	\&.
X	\&.
X	\&.
X}
X.RE
X.PP
XA template similar to this can be found in
X.IR /usr/pub/template.c .
X.SH HISTORY
XWritten by Henry Spencer, working from a Bell Labs manual page.
XBehavior believed identical to the Bell version.
X.SH BUGS
XIt is not obvious how
X`\-'
Xstanding alone should be treated;  this version treats it as
Xa non-option argument, which is not always right.
X.PP
XOption arguments are allowed to begin with `\-';
Xthis is reasonable but reduces the amount of error checking possible.
X.PP
X.I Getopt
Xis quite flexible but the obvious price must be paid:  there is much
Xit could do that it doesn't, like
Xchecking mutually exclusive options, checking type of
Xoption arguments, etc.
END_OF_FILE
if test 2755 -ne `wc -c <'getopt.l3'`; then
    echo shar: \"'getopt.l3'\" unpacked with wrong size!
fi
# end of 'getopt.l3'
fi
if test -f 'kiero.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'kiero.c'\"
else
echo shar: Extracting \"'kiero.c'\" \(1898 characters\)
sed "s/^X//" >'kiero.c' <<'END_OF_FILE'
X/*
X
XCopyright (C) 1988, 1989 by Juha Takala, jta@sah.vtt.fi
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; version 1.
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     the file "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
X */
X
X/* Description:
X * Screwed demo to tie your cpu for a while.  Pipe the output of this
X * program to the "draw" that you just made, and "draw"'s output to the
X * device you like.
X */
X
X#include <math.h>
X#include <stdio.h>
X
Xstatic char *rcsid =
X  "$Id: kiero.c,v 1.3 89/12/08 14:00:54 jta Exp Locker: jta $";
X
Xdouble param[8] = {0.99, -0.7, 3.01, 1.01, 0.1, 15.03, 0.01};
Xstatic char *ttbl[] = {
X    "#$xrange -2,1,2",
X    "#$yrange -2,1,2",
X    "#$noaxes",
X    "#$init",
X    "#$size 2",
X    "#$text -2,1.9,See: Computer Recreations",
X    "#$text -2,1.7,Scientific American, May -88, p.95",
X    "#$size 1.4",
X    "#$text -2,-1.75,Hit your interrupt character to stop.",
X    NULL
X};
X
Xint maxn = 100000;
X
Xmain (argc, argv, envp)
Xint argc;
Xchar *argv[], *envp[];
X{
X    double t, *p;
X    char **cp;
X    int i;
X    
X    if (argc > 1) {
X	maxn = atoi(*(++argv));
X	argc--;
X    }
X    
X    p = param;
X    while (--argc > 0)
X      *(p++) = atof(*(++argv));
X
X    for (cp=ttbl; *cp; cp++)
X      printf ("%s\n", *cp);
X
X    t = 0.0;
X    for (i=0; i<maxn; i++) {
X	printf ("%8.4f %8.4f\n",
X		sin(param[0]*t) + param[1] * cos(param[2]*t),
X		cos(param[3]*t) + param[4] * sin(param[5]*t));
X	t += param[6];
X    }
X}
END_OF_FILE
if test 1898 -ne `wc -c <'kiero.c'`; then
    echo shar: \"'kiero.c'\" unpacked with wrong size!
fi
# end of 'kiero.c'
fi
if test -f 'koe' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'koe'\"
else
echo shar: Extracting \"'koe'\" \(35 characters\)
sed "s/^X//" >'koe' <<'END_OF_FILE'
Xdraw -tplot koe.dat | tplot -T4014
END_OF_FILE
if test 35 -ne `wc -c <'koe'`; then
    echo shar: \"'koe'\" unpacked with wrong size!
fi
chmod +x 'koe'
# end of 'koe'
fi
if test -f 'koe.dat' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'koe.dat'\"
else
echo shar: Extracting \"'koe.dat'\" \(360 characters\)
sed "s/^X//" >'koe.dat' <<'END_OF_FILE'
X# koe.dat   -- test data for draw.c
X# #$area 0,0,0.5,0.5
X#$xrange 0,0.1,1
X#$yrange 0,0.2,1
X# #$grid 2,1
X#$name Name: jyklTqg
X#$xlabel X: jyklTqg
X#$ylabel Y: jyklTqg
X#$date
X0.01	0.52
X0.21	0.63
X0.41	0.41
X#$alabel 0.53,0.77 label for data
X0.61	0.55
X0.81	0.45
X0.99	0.51
X#$include vttlogo
X#$mark X
X0.1	0.24
X0.3	0.37
X0.5	0.22
X0.61	0.55
X0.81	0.45
X0.99	0.51
X#
X# -eof-
END_OF_FILE
if test 360 -ne `wc -c <'koe.dat'`; then
    echo shar: \"'koe.dat'\" unpacked with wrong size!
fi
# end of 'koe.dat'
fi
if test -f 'makefile.dos' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'makefile.dos'\"
else
echo shar: Extracting \"'makefile.dos'\" \(515 characters\)
sed "s/^X//" >'makefile.dos' <<'END_OF_FILE'
X#
X#
X# I don't know about Mosse-dos makes.  This makefile does not work with
X# Microsoft make (?).  Here is a bat file you can use to compile each .c
X# file into .obj, how about link ?
X#        cl -AL -FPa -Zi -c %1.c
X
XSRC	= draw.c hpp.c getopt.c
XOBJS	= draw.obj hpp.obj getopt.obj
X
Xdraw.exe:	$(OBJS)
X	link $(OBJS),,,;
X
Xall:	draw.exe
X
Xkoe:	draw.exe koe.dat
X	draw -dd -x 5,5,15 -y 0,10,30 -g 1,2 koe.dat >koe.pic
X
Xgetopt.obj:	getopt.c
X	cl -c $*.c
X
Xhpp.obj:	hpp.c hpp.h
X	cl -c $*.c
X
Xdraw.obj:	draw.c hpp.h
X	cl -c $*.c
END_OF_FILE
if test 515 -ne `wc -c <'makefile.dos'`; then
    echo shar: \"'makefile.dos'\" unpacked with wrong size!
fi
# end of 'makefile.dos'
fi
if test -f 'vttlogo' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'vttlogo'\"
else
echo shar: Extracting \"'vttlogo'\" \(361 characters\)
sed "s/^X//" >'vttlogo' <<'END_OF_FILE'
X#$penup
X#$absolute 0.2,0.1
X# mutterin kuori
X0.012	0.05
X0.03	0.005
X0.07	0.005
X0.088	0.05
X0.07	0.095
X0.03	0.095
X0.012	0.05
X#$penup
X# V
X0.041	0.090
X0.050	0.055
X0.059	0.090
X#$penup
X# vasemmanpuoleinen T
X0.027	0.045
X0.045	0.045
X#$penup
X0.036	0.045
X0.036	0.010
X#$penup
X# oikeanpuoleinen T
X0.055	0.045
X0.073	0.045
X#$penup
X0.064	0.045
X0.064	0.010
X#$endabsolute
X#$penup
END_OF_FILE
if test 361 -ne `wc -c <'vttlogo'`; then
    echo shar: \"'vttlogo'\" unpacked with wrong size!
fi
# end of 'vttlogo'
fi
echo shar: End of archive 1 \(of 2\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked both 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