home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / misc / volume06 / plot2ps < prev    next >
Encoding:
Internet Message Format  |  1991-08-27  |  39.6 KB

  1. 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
  2. Article 852 of comp.sources.misc:
  3. Path: decwrl!ucbvax!tut.cis.ohio-state.edu!unmvax!ncar!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!allbery
  4. From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  5. Newsgroups: comp.sources.misc
  6. Subject: v06i083: plot2ps  -- convert plot(5) data to PostScript
  7. Message-ID: <52333@uunet.UU.NET>
  8. Date: 8 Apr 89 19:45:14 GMT
  9. Sender: allbery@uunet.UU.NET
  10. Reply-To: seindal@diku.dk (Rene' Seindal)
  11. Lines: 1223
  12. Approved: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  13.  
  14. Posting-number: Volume 6, Issue 83
  15. Submitted-by: seindal@diku.dk (Rene' Seindal)
  16. Archive-name: plot2ps
  17.  
  18.  
  19. This is a program to convert plot(5) data to PostScript.
  20.  
  21. This package includes a general purpose plot library which outputs PostScript.
  22.  
  23. Now we have this splendid GNU GENERAL PUBLIC LICENSE, I have made this program
  24. subject to it.  That means, as usual, you're free to copy, modify and
  25. redistribute this program, but not to disallow others to do so.  
  26.  
  27. Is it really necessary to put 20 lines of copyright message in each file, and
  28. send out a 9Kb file with everything subjected to the GNU license?  Seems a bit
  29. excessive to me.
  30.  
  31. ------------------------------------------------------------------------
  32. #!/bin/sh
  33. # shar:    Shell Archiver  (v1.22)
  34. #
  35. #    Run the following text with /bin/sh to create:
  36. #      COPYING
  37. #      Makefile
  38. #      README
  39. #      arc.c
  40. #      bytesex.h
  41. #      circle.c
  42. #      closepl.c
  43. #      cont.c
  44. #      defs.h
  45. #      dot.c
  46. #      erase.c
  47. #      label.c
  48. #      line.c
  49. #      linemod.c
  50. #      move.c
  51. #      openpl.c
  52. #      output.c
  53. #      plot2ps.1
  54. #      plot2ps.c
  55. #      point.c
  56. #      space.c
  57. #
  58. echo "x - extracting COPYING (Text)"
  59. sed 's/^X//' << 'SHAR_EOF' > COPYING &&
  60. X
  61. X            GNU GENERAL PUBLIC LICENSE
  62. X             Version 1, February 1989
  63. X
  64. X Copyright (C) 1989 Free Software Foundation, Inc.
  65. X                    675 Mass Ave, Cambridge, MA 02139, USA
  66. X Everyone is permitted to copy and distribute verbatim copies
  67. X of this license document, but changing it is not allowed.
  68. X
  69. X                Preamble
  70. X
  71. X  The license agreements of most software companies try to keep users
  72. Xat the mercy of those companies.  By contrast, our General Public
  73. XLicense is intended to guarantee your freedom to share and change free
  74. Xsoftware--to make sure the software is free for all its users.  The
  75. XGeneral Public License applies to the Free Software Foundation's
  76. Xsoftware and to any other program whose authors commit to using it.
  77. XYou can use it for your programs, too.
  78. X
  79. X  When we speak of free software, we are referring to freedom, not
  80. Xprice.  Specifically, the General Public License is designed to make
  81. Xsure that you have the freedom to give away or sell copies of free
  82. Xsoftware, that you receive source code or can get it if you want it,
  83. Xthat you can change the software or use pieces of it in new free
  84. Xprograms; and that you know you can do these things.
  85. X
  86. X  To protect your rights, we need to make restrictions that forbid
  87. Xanyone to deny you these rights or to ask you to surrender the rights.
  88. XThese restrictions translate to certain responsibilities for you if you
  89. Xdistribute copies of the software, or if you modify it.
  90. X
  91. X  For example, if you distribute copies of a such a program, whether
  92. Xgratis or for a fee, you must give the recipients all the rights that
  93. Xyou have.  You must make sure that they, too, receive or can get the
  94. Xsource code.  And you must tell them their rights.
  95. X
  96. X  We protect your rights with two steps: (1) copyright the software, and
  97. X(2) offer you this license which gives you legal permission to copy,
  98. Xdistribute and/or modify the software.
  99. X
  100. X  Also, for each author's protection and ours, we want to make certain
  101. Xthat everyone understands that there is no warranty for this free
  102. Xsoftware.  If the software is modified by someone else and passed on, we
  103. Xwant its recipients to know that what they have is not the original, so
  104. Xthat any problems introduced by others will not reflect on the original
  105. Xauthors' reputations.
  106. X
  107. X  The precise terms and conditions for copying, distribution and
  108. Xmodification follow.
  109. X
  110. X            GNU GENERAL PUBLIC LICENSE
  111. X   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  112. X
  113. X  0. This License Agreement applies to any program or other work which
  114. Xcontains a notice placed by the copyright holder saying it may be
  115. Xdistributed under the terms of this General Public License.  The
  116. X"Program", below, refers to any such program or work, and a "work based
  117. Xon the Program" means either the Program or any work containing the
  118. XProgram or a portion of it, either verbatim or with modifications.  Each
  119. Xlicensee is addressed as "you".
  120. X
  121. X  1. You may copy and distribute verbatim copies of the Program's source
  122. Xcode as you receive it, in any medium, provided that you conspicuously and
  123. Xappropriately publish on each copy an appropriate copyright notice and
  124. Xdisclaimer of warranty; keep intact all the notices that refer to this
  125. XGeneral Public License and to the absence of any warranty; and give any
  126. Xother recipients of the Program a copy of this General Public License
  127. Xalong with the Program.  You may charge a fee for the physical act of
  128. Xtransferring a copy.
  129. X
  130. X  2. You may modify your copy or copies of the Program or any portion of
  131. Xit, and copy and distribute such modifications under the terms of Paragraph
  132. X1 above, provided that you also do the following:
  133. X
  134. X    a) cause the modified files to carry prominent notices stating that
  135. X    you changed the files and the date of any change; and
  136. X
  137. X    b) cause the whole of any work that you distribute or publish, that
  138. X    in whole or in part contains the Program or any part thereof, either
  139. X    with or without modifications, to be licensed at no charge to all
  140. X    third parties under the terms of this General Public License (except
  141. X    that you may choose to grant warranty protection to some or all
  142. X    third parties, at your option).
  143. X
  144. X    c) If the modified program normally reads commands interactively when
  145. X    run, you must cause it, when started running for such interactive use
  146. X    in the simplest and most usual way, to print or display an
  147. X    announcement including an appropriate copyright notice and a notice
  148. X    that there is no warranty (or else, saying that you provide a
  149. X    warranty) and that users may redistribute the program under these
  150. X    conditions, and telling the user how to view a copy of this General
  151. X    Public License.
  152. X
  153. X    d) You may charge a fee for the physical act of transferring a
  154. X    copy, and you may at your option offer warranty protection in
  155. X    exchange for a fee.
  156. X
  157. XMere aggregation of another independent work with the Program (or its
  158. Xderivative) on a volume of a storage or distribution medium does not bring
  159. Xthe other work under the scope of these terms.
  160. X
  161. X  3. You may copy and distribute the Program (or a portion or derivative of
  162. Xit, under Paragraph 2) in object code or executable form under the terms of
  163. XParagraphs 1 and 2 above provided that you also do one of the following:
  164. X
  165. X    a) accompany it with the complete corresponding machine-readable
  166. X    source code, which must be distributed under the terms of
  167. X    Paragraphs 1 and 2 above; or,
  168. X
  169. X    b) accompany it with a written offer, valid for at least three
  170. X    years, to give any third party free (except for a nominal charge
  171. X    for the cost of distribution) a complete machine-readable copy of the
  172. X    corresponding source code, to be distributed under the terms of
  173. X    Paragraphs 1 and 2 above; or,
  174. X
  175. X    c) accompany it with the information you received as to where the
  176. X    corresponding source code may be obtained.  (This alternative is
  177. X    allowed only for noncommercial distribution and only if you
  178. X    received the program in object code or executable form alone.)
  179. X
  180. XSource code for a work means the preferred form of the work for making
  181. Xmodifications to it.  For an executable file, complete source code means
  182. Xall the source code for all modules it contains; but, as a special
  183. Xexception, it need not include source code for modules which are standard
  184. Xlibraries that accompany the operating system on which the executable
  185. Xfile runs, or for standard header files or definitions files that
  186. Xaccompany that operating system.
  187. X
  188. X  4. You may not copy, modify, sublicense, distribute or transfer the
  189. XProgram except as expressly provided under this General Public License.
  190. XAny attempt otherwise to copy, modify, sublicense, distribute or transfer
  191. Xthe Program is void, and will automatically terminate your rights to use
  192. Xthe Program under this License.  However, parties who have received
  193. Xcopies, or rights to use copies, from you under this General Public
  194. XLicense will not have their licenses terminated so long as such parties
  195. Xremain in full compliance.
  196. X
  197. X  5. By copying, distributing or modifying the Program (or any work based
  198. Xon the Program) you indicate your acceptance of this license to do so,
  199. Xand all its terms and conditions.
  200. X
  201. X  6. Each time you redistribute the Program (or any work based on the
  202. XProgram), the recipient automatically receives a license from the original
  203. Xlicensor to copy, distribute or modify the Program subject to these
  204. Xterms and conditions.  You may not impose any further restrictions on the
  205. Xrecipients' exercise of the rights granted herein.
  206. X
  207. X  7. The Free Software Foundation may publish revised and/or new versions
  208. Xof the General Public License from time to time.  Such new versions will
  209. Xbe similar in spirit to the present version, but may differ in detail to
  210. Xaddress new problems or concerns.
  211. X
  212. XEach version is given a distinguishing version number.  If the Program
  213. Xspecifies a version number of the license which applies to it and "any
  214. Xlater version", you have the option of following the terms and conditions
  215. Xeither of that version or of any later version published by the Free
  216. XSoftware Foundation.  If the Program does not specify a version number of
  217. Xthe license, you may choose any version ever published by the Free Software
  218. XFoundation.
  219. X
  220. X  8. If you wish to incorporate parts of the Program into other free
  221. Xprograms whose distribution conditions are different, write to the author
  222. Xto ask for permission.  For software which is copyrighted by the Free
  223. XSoftware Foundation, write to the Free Software Foundation; we sometimes
  224. Xmake exceptions for this.  Our decision will be guided by the two goals
  225. Xof preserving the free status of all derivatives of our free software and
  226. Xof promoting the sharing and reuse of software generally.
  227. X
  228. X                NO WARRANTY
  229. X
  230. X  9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
  231. XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
  232. XOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
  233. XPROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
  234. XOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  235. XMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
  236. XTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
  237. XPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
  238. XREPAIR OR CORRECTION.
  239. X
  240. X  10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
  241. XWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
  242. XREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
  243. XINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
  244. XOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
  245. XTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
  246. XYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
  247. XPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
  248. XPOSSIBILITY OF SUCH DAMAGES.
  249. X
  250. SHAR_EOF
  251. chmod 0644 COPYING || echo "restore of COPYING fails"
  252. echo "x - extracting Makefile (Text)"
  253. sed 's/^X//' << 'SHAR_EOF' > Makefile &&
  254. XINCL    =
  255. XCOPTS    = -O
  256. XCFLAGS    = $(COPTS) $(CEXT) $(INCL)
  257. XCC    = cc
  258. XDEPEND    = $(CC) -MM $(INCL)
  259. XLOADLIBES = -lm
  260. XINSTALL    = install
  261. X
  262. XALL    = plot2ps libPS.a
  263. X
  264. XLIBSRCS    = arc.c circle.c closepl.c cont.c erase.c label.c line.c \
  265. X      linemod.c move.c openpl.c output.c point.c space.c dot.c
  266. XLIBOBJS    = arc.o circle.o closepl.o cont.o erase.o label.o line.o \
  267. X      linemod.o move.o openpl.o output.o point.o space.o dot.o
  268. XLIBHDRS    = defs.h
  269. X
  270. XSRCS    = plot2ps.c
  271. XOBJS    = plot2ps.o
  272. X
  273. XBINDIR    = /usr/local/bin
  274. XMANDIR    = /usr/man/man1
  275. XLIBDIR    = /usr/lib
  276. X
  277. Xall:    $(ALL)
  278. X
  279. Xinstall:  $(ALL)
  280. X    $(INSTALL) -c -s -m 755 plot2ps $(BINDIR)
  281. X    $(INSTALL) -c  libPS.a $(LIBDIR)
  282. X    ranlib -t $(LIBDIR)/libPS.a
  283. X    @echo Installation done.
  284. X
  285. XlibPS.a: $(LIBOBJS)
  286. X    ar cru $@ $?
  287. X    ranlib $@
  288. X
  289. Xplot2ps: plot2ps.o libPS.a
  290. X    $(CC) $(CFLAGS) $(LDFLAGS) -o $@ plot2ps.o libPS.a $(LOADLIBES)
  291. X
  292. Xtags:    $(SRCS) $(HDRS) $(LIBSRCS) $(LIBHDRS)
  293. X    etags $(SRCS) $(HDRS) $(LIBSRCS) $(LIBHDRS)
  294. X
  295. Xid:
  296. X    mkid $(SRCS) $(HRDS) $(LIBSRCS) $(LIBHDRS)
  297. X
  298. Xclean:
  299. X    rm -f $(ALL) $(OBJS) $(LIBOBJS) *~ '#*' core a.out
  300. X
  301. Xdepend:    ${SRCS} $(LIBSRCS)
  302. X    for i in $(SRCS) $(LIBSRCS); do $(DEPEND) $$i >> makedep; done
  303. X    echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
  304. X    echo '$$r makedep' >>eddep
  305. X    echo 'w' >>eddep
  306. X    cp Makefile Makefile.bak
  307. X    ed - Makefile < eddep
  308. X    rm eddep makedep
  309. X    echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
  310. X    echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
  311. X    echo '# see make depend above' >> Makefile
  312. X
  313. X# DO NOT DELETE THIS LINE
  314. X
  315. Xplot2ps.o: plot2ps.c
  316. Xplot2ps.o: /usr/include/stdio.h
  317. Xplot2ps.o: ./bytesex.h
  318. Xarc.o: arc.c
  319. Xarc.o: ./defs.h
  320. Xarc.o: /usr/include/stdio.h
  321. Xcircle.o: circle.c
  322. Xcircle.o: ./defs.h
  323. Xcircle.o: /usr/include/stdio.h
  324. Xclosepl.o: closepl.c
  325. Xclosepl.o: ./defs.h
  326. Xclosepl.o: /usr/include/stdio.h
  327. Xcont.o: cont.c
  328. Xcont.o: ./defs.h
  329. Xcont.o: /usr/include/stdio.h
  330. Xerase.o: erase.c
  331. Xerase.o: ./defs.h
  332. Xerase.o: /usr/include/stdio.h
  333. Xlabel.o: label.c
  334. Xlabel.o: ./defs.h
  335. Xlabel.o: /usr/include/stdio.h
  336. Xline.o: line.c
  337. Xline.o: ./defs.h
  338. Xline.o: /usr/include/stdio.h
  339. Xlinemod.o: linemod.c
  340. Xlinemod.o: ./defs.h
  341. Xlinemod.o: /usr/include/stdio.h
  342. Xmove.o: move.c
  343. Xmove.o: ./defs.h
  344. Xmove.o: /usr/include/stdio.h
  345. Xopenpl.o: openpl.c
  346. Xopenpl.o: ./defs.h
  347. Xopenpl.o: /usr/include/stdio.h
  348. Xoutput.o: output.c
  349. Xoutput.o: ./defs.h
  350. Xoutput.o: /usr/include/stdio.h
  351. Xpoint.o: point.c
  352. Xpoint.o: ./defs.h
  353. Xpoint.o: /usr/include/stdio.h
  354. Xspace.o: space.c
  355. Xspace.o: ./defs.h
  356. Xspace.o: /usr/include/stdio.h
  357. Xdot.o: dot.c
  358. Xdot.o: ./defs.h
  359. Xdot.o: /usr/include/stdio.h
  360. X# DEPENDENCIES MUST END AT END OF FILE
  361. X# IF YOU PUT STUFF HERE IT WILL GO AWAY
  362. X# see make depend above
  363. SHAR_EOF
  364. chmod 0644 Makefile || echo "restore of Makefile fails"
  365. echo "x - extracting README (Text)"
  366. sed 's/^X//' << 'SHAR_EOF' > README &&
  367. XThis is a program to convert plot(5) data to PostScript.
  368. X
  369. XThis package includes a general purpose plot library which outputs PostScript.
  370. X
  371. XYou should edit bytesex.h to reflect the byteorder of your machine, since the
  372. Xplot format is not portable across architectures.  The only place BIG_ENDIAN
  373. Xis used in in getsi() in plot2ps.c.
  374. X
  375. XNow we have this splendid GNU GENERAL PUBLIC LICENSE, I have made this program
  376. Xsubject to it.  That means, as usual, you're free to copy, modify and
  377. Xredistribute this program, but not to disallow others to do so.
  378. SHAR_EOF
  379. chmod 0644 README || echo "restore of README fails"
  380. echo "x - extracting arc.c (Text)"
  381. sed 's/^X//' << 'SHAR_EOF' > arc.c &&
  382. X/*
  383. X    This file is part of plot2ps.
  384. X
  385. X    Copyright (C) 1989 Rene' Seindal
  386. X
  387. X    This program is free software; you can redistribute it and/or modify
  388. X    it under the terms of the GNU General Public License as published by
  389. X    the Free Software Foundation; either version 1, or (at your option)
  390. X    any later version.
  391. X
  392. X    This program is distributed in the hope that it will be useful,
  393. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  394. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  395. X    GNU General Public License for more details.
  396. X
  397. X    You should have received a copy of the GNU General Public License
  398. X    along with this program; if not, write to the Free Software
  399. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  400. X
  401. X    My current address is: seindal@diku.dk
  402. X*/
  403. X
  404. X#include "defs.h"
  405. X
  406. X#define PI  ((double)3.14159265358979323844)
  407. X#define radtodeg(x)  ((double)(x)*180.0/PI)
  408. X
  409. Xarc(x, y, x0, y0, x1, y1)
  410. X{
  411. X    double theta0, theta1, rad;
  412. X    int rx0, ry0, rx1, ry1;
  413. X
  414. X    rx0 = x0 - x;
  415. X    ry0 = y0 - y;
  416. X    rx1 = x1 - x;
  417. X    ry1 = y1 - y;
  418. X
  419. X    rad = hypot( X(x0) - X(x), Y(y0) - Y(y) );
  420. X    theta0 = (rx0 == 0) ? 180.0 : radtodeg( atan2((double)ry0, (double)rx0) );
  421. X    theta1 = (rx1 == 0) ? 180.0 : radtodeg( atan2((double)ry1, (double)rx1) );
  422. X
  423. X    clear();
  424. X    printf( "%g %g %g %g %g arc\n", X(x), Y(y), rad, theta0, theta1 );
  425. X    DIRTYPATH;
  426. X}
  427. SHAR_EOF
  428. chmod 0644 arc.c || echo "restore of arc.c fails"
  429. echo "x - extracting bytesex.h (Text)"
  430. sed 's/^X//' << 'SHAR_EOF' > bytesex.h &&
  431. X/*
  432. X    This file is part of plot2ps.
  433. X
  434. X    Copyright (C) 1989 Rene' Seindal
  435. X
  436. X    This program is free software; you can redistribute it and/or modify
  437. X    it under the terms of the GNU General Public License as published by
  438. X    the Free Software Foundation; either version 1, or (at your option)
  439. X    any later version.
  440. X
  441. X    This program is distributed in the hope that it will be useful,
  442. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  443. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  444. X    GNU General Public License for more details.
  445. X
  446. X    You should have received a copy of the GNU General Public License
  447. X    along with this program; if not, write to the Free Software
  448. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  449. X
  450. X    My current address is: seindal@diku.dk
  451. X*/
  452. X
  453. X/* 
  454. X * Define BIG_ENDIAN as appropriate for your machine
  455. X */
  456. X
  457. X#ifdef vax 
  458. X#define BIG_ENDIAN
  459. X#endif
  460. X
  461. X#if defined(sparc) || defined(mc68000)
  462. X#undef BIG_ENDIAN
  463. X#endif
  464. SHAR_EOF
  465. chmod 0644 bytesex.h || echo "restore of bytesex.h fails"
  466. echo "x - extracting circle.c (Text)"
  467. sed 's/^X//' << 'SHAR_EOF' > circle.c &&
  468. X/*
  469. X    This file is part of plot2ps.
  470. X
  471. X    Copyright (C) 1989 Rene' Seindal
  472. X
  473. X    This program is free software; you can redistribute it and/or modify
  474. X    it under the terms of the GNU General Public License as published by
  475. X    the Free Software Foundation; either version 1, or (at your option)
  476. X    any later version.
  477. X
  478. X    This program is distributed in the hope that it will be useful,
  479. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  480. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  481. X    GNU General Public License for more details.
  482. X
  483. X    You should have received a copy of the GNU General Public License
  484. X    along with this program; if not, write to the Free Software
  485. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  486. X
  487. X    My current address is: seindal@diku.dk
  488. X*/
  489. X
  490. X#include "defs.h"
  491. X
  492. Xcircle(x, y, r)
  493. X{
  494. X    clear();            /* new path to avoid funny lines */
  495. X    shipout( "%g %g %g 0 360 arc\n", X(x), Y(y), xscale * (double)r );
  496. X    DIRTYPATH;
  497. X}
  498. SHAR_EOF
  499. chmod 0644 circle.c || echo "restore of circle.c fails"
  500. echo "x - extracting closepl.c (Text)"
  501. sed 's/^X//' << 'SHAR_EOF' > closepl.c &&
  502. X/*
  503. X    This file is part of plot2ps.
  504. X
  505. X    Copyright (C) 1989 Rene' Seindal
  506. X
  507. X    This program is free software; you can redistribute it and/or modify
  508. X    it under the terms of the GNU General Public License as published by
  509. X    the Free Software Foundation; either version 1, or (at your option)
  510. X    any later version.
  511. X
  512. X    This program is distributed in the hope that it will be useful,
  513. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  514. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  515. X    GNU General Public License for more details.
  516. X
  517. X    You should have received a copy of the GNU General Public License
  518. X    along with this program; if not, write to the Free Software
  519. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  520. X
  521. X    My current address is: seindal@diku.dk
  522. X*/
  523. X
  524. X#include "defs.h"
  525. X
  526. X
  527. Xclosepl()
  528. X{
  529. X    if ( !(state & CLEANPAGE) ) 
  530. X    printf( "stroke showpage\n" );
  531. X    fflush( stdout );
  532. X    restpathlen = 0;
  533. X    state = INVALID;
  534. X}
  535. SHAR_EOF
  536. chmod 0644 closepl.c || echo "restore of closepl.c fails"
  537. echo "x - extracting cont.c (Text)"
  538. sed 's/^X//' << 'SHAR_EOF' > cont.c &&
  539. X/*
  540. X    This file is part of plot2ps.
  541. X
  542. X    Copyright (C) 1989 Rene' Seindal
  543. X
  544. X    This program is free software; you can redistribute it and/or modify
  545. X    it under the terms of the GNU General Public License as published by
  546. X    the Free Software Foundation; either version 1, or (at your option)
  547. X    any later version.
  548. X
  549. X    This program is distributed in the hope that it will be useful,
  550. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  551. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  552. X    GNU General Public License for more details.
  553. X
  554. X    You should have received a copy of the GNU General Public License
  555. X    along with this program; if not, write to the Free Software
  556. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  557. X
  558. X    My current address is: seindal@diku.dk
  559. X*/
  560. X
  561. X#include "defs.h"
  562. X
  563. X
  564. Xcont( x, y )
  565. X{
  566. X    shipout( "%g %g lineto\n", X(x), Y(y) );
  567. X}
  568. SHAR_EOF
  569. chmod 0644 cont.c || echo "restore of cont.c fails"
  570. echo "x - extracting defs.h (Text)"
  571. sed 's/^X//' << 'SHAR_EOF' > defs.h &&
  572. X/*
  573. X    This file is part of plot2ps.
  574. X
  575. X    Copyright (C) 1989 Rene' Seindal
  576. X
  577. X    This program is free software; you can redistribute it and/or modify
  578. X    it under the terms of the GNU General Public License as published by
  579. X    the Free Software Foundation; either version 1, or (at your option)
  580. X    any later version.
  581. X
  582. X    This program is distributed in the hope that it will be useful,
  583. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  584. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  585. X    GNU General Public License for more details.
  586. X
  587. X    You should have received a copy of the GNU General Public License
  588. X    along with this program; if not, write to the Free Software
  589. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  590. X
  591. X    My current address is: seindal@diku.dk
  592. X*/
  593. X
  594. X#include <stdio.h>
  595. X
  596. X/* CONSTANTS */
  597. X
  598. X#define XMAX        572    /* physical pagesizes in points */
  599. X#define YMAX        579    /* (should be 818) */
  600. X
  601. X#define XMIN        18    /* lower left x coordiate (ALW) */
  602. X#define YMIN        25    /* lower left y coordiate (ALW) */
  603. X
  604. X#define XRANGE        4096    /* default logical coor (values 0..XRANGE-1) */
  605. X#define YRANGE        4096    /* values 0..YRANGE-1 */
  606. X
  607. X#define FONT        "Helvetica"
  608. X#define PTSIZE        12    /* pointsize for text (in points) */
  609. X#define LINEWIDTH    0.1    /* width of lines (in points) */
  610. X#define POINTDIAM    0.5    /* diameter of points (in points!) */
  611. X#define MAXPATHLENGTH     1024    /* no path generated will contain */
  612. X                /* more segments than MAXPATHLENGTH */
  613. X
  614. X/* COORDINATES AND SCALING */
  615. X
  616. Xextern double xscale;
  617. Xextern double yscale;
  618. Xextern double xoffset;
  619. Xextern double yoffset;
  620. X
  621. X#define X(x) (xscale * ((double)(x)) + xoffset)
  622. X#define Y(y) (yscale * ((double)(y)) + yoffset)
  623. X
  624. X/*  POSTSCRIPT OUTPUT */
  625. X
  626. X#define INVALID        0x01    /* plot not initialised or closed */
  627. X#define CLEANPAGE    0x02    /* page is blank */
  628. X#define CLEANPATH    0x04    /* current path is empty */
  629. X
  630. X#define DIRTYPAGE state &= ~CLEANPAGE
  631. X#define DIRTYPATH state &= ~(CLEANPAGE | CLEANPATH)
  632. X
  633. Xextern int state;    /* state of the page */
  634. Xextern int restpathlen;        /* length of current path */
  635. SHAR_EOF
  636. chmod 0644 defs.h || echo "restore of defs.h fails"
  637. echo "x - extracting dot.c (Text)"
  638. sed 's/^X//' << 'SHAR_EOF' > dot.c &&
  639. X/*
  640. X    This file is part of plot2ps.
  641. X
  642. X    Copyright (C) 1989 Rene' Seindal
  643. X
  644. X    This program is free software; you can redistribute it and/or modify
  645. X    it under the terms of the GNU General Public License as published by
  646. X    the Free Software Foundation; either version 1, or (at your option)
  647. X    any later version.
  648. X
  649. X    This program is distributed in the hope that it will be useful,
  650. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  651. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  652. X    GNU General Public License for more details.
  653. X
  654. X    You should have received a copy of the GNU General Public License
  655. X    along with this program; if not, write to the Free Software
  656. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  657. X
  658. X    My current address is: seindal@diku.dk
  659. X*/
  660. X
  661. X#include "defs.h"
  662. X
  663. Xdot()
  664. X{
  665. X}
  666. SHAR_EOF
  667. chmod 0644 dot.c || echo "restore of dot.c fails"
  668. echo "x - extracting erase.c (Text)"
  669. sed 's/^X//' << 'SHAR_EOF' > erase.c &&
  670. X/*
  671. X    This file is part of plot2ps.
  672. X
  673. X    Copyright (C) 1989 Rene' Seindal
  674. X
  675. X    This program is free software; you can redistribute it and/or modify
  676. X    it under the terms of the GNU General Public License as published by
  677. X    the Free Software Foundation; either version 1, or (at your option)
  678. X    any later version.
  679. X
  680. X    This program is distributed in the hope that it will be useful,
  681. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  682. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  683. X    GNU General Public License for more details.
  684. X
  685. X    You should have received a copy of the GNU General Public License
  686. X    along with this program; if not, write to the Free Software
  687. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  688. X
  689. X    My current address is: seindal@diku.dk
  690. X*/
  691. X
  692. X#include "defs.h"
  693. X
  694. X
  695. Xerase()
  696. X{
  697. X    if ( state & CLEANPAGE )
  698. X    return;
  699. X    if ( !(state & CLEANPATH) )
  700. X    printf( "stroke " );
  701. X    printf( "showpage newpath\n");
  702. X    everypage();
  703. X    state = CLEANPAGE | CLEANPATH;
  704. X    restpathlen = MAXPATHLENGTH;
  705. X}
  706. SHAR_EOF
  707. chmod 0644 erase.c || echo "restore of erase.c fails"
  708. echo "x - extracting label.c (Text)"
  709. sed 's/^X//' << 'SHAR_EOF' > label.c &&
  710. X/*
  711. X    This file is part of plot2ps.
  712. X
  713. X    Copyright (C) 1989 Rene' Seindal
  714. X
  715. X    This program is free software; you can redistribute it and/or modify
  716. X    it under the terms of the GNU General Public License as published by
  717. X    the Free Software Foundation; either version 1, or (at your option)
  718. X    any later version.
  719. X
  720. X    This program is distributed in the hope that it will be useful,
  721. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  722. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  723. X    GNU General Public License for more details.
  724. X
  725. X    You should have received a copy of the GNU General Public License
  726. X    along with this program; if not, write to the Free Software
  727. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  728. X
  729. X    My current address is: seindal@diku.dk
  730. X*/
  731. X
  732. X#include "defs.h"
  733. X
  734. Xlabel(s)
  735. X    char *s;
  736. X{
  737. X    char t[1024];
  738. X    register char *u = t;
  739. X
  740. X    do {
  741. X    if ( *s == '(' || *s == ')' || *s == '\\' )
  742. X        *u++ = '\\';
  743. X    if ( *s == '\0' || *s == '\n' )
  744. X        break;
  745. X    if ( u - t >= 1024 )
  746. X        break;
  747. X    } while ( *u++ = *s++ );
  748. X    *u = '\0';
  749. X
  750. X    printf( "(%s) show\n", t );
  751. X    DIRTYPATH;
  752. X}
  753. X
  754. SHAR_EOF
  755. chmod 0644 label.c || echo "restore of label.c fails"
  756. echo "x - extracting line.c (Text)"
  757. sed 's/^X//' << 'SHAR_EOF' > line.c &&
  758. X/*
  759. X    This file is part of plot2ps.
  760. X
  761. X    Copyright (C) 1989 Rene' Seindal
  762. X
  763. X    This program is free software; you can redistribute it and/or modify
  764. X    it under the terms of the GNU General Public License as published by
  765. X    the Free Software Foundation; either version 1, or (at your option)
  766. X    any later version.
  767. X
  768. X    This program is distributed in the hope that it will be useful,
  769. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  770. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  771. X    GNU General Public License for more details.
  772. X
  773. X    You should have received a copy of the GNU General Public License
  774. X    along with this program; if not, write to the Free Software
  775. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  776. X
  777. X    My current address is: seindal@diku.dk
  778. X*/
  779. X
  780. X#include "defs.h"
  781. X
  782. X
  783. Xline( x0, y0, x1, y1 )
  784. X{
  785. X    shipout( "%g %g moveto  ", X(x0), Y(y0) );
  786. X    shipout( "%g %g lineto\n", X(x1), Y(y1) );
  787. X}
  788. SHAR_EOF
  789. chmod 0644 line.c || echo "restore of line.c fails"
  790. echo "x - extracting linemod.c (Text)"
  791. sed 's/^X//' << 'SHAR_EOF' > linemod.c &&
  792. X/*
  793. X    This file is part of plot2ps.
  794. X
  795. X    Copyright (C) 1989 Rene' Seindal
  796. X
  797. X    This program is free software; you can redistribute it and/or modify
  798. X    it under the terms of the GNU General Public License as published by
  799. X    the Free Software Foundation; either version 1, or (at your option)
  800. X    any later version.
  801. X
  802. X    This program is distributed in the hope that it will be useful,
  803. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  804. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  805. X    GNU General Public License for more details.
  806. X
  807. X    You should have received a copy of the GNU General Public License
  808. X    along with this program; if not, write to the Free Software
  809. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  810. X
  811. X    My current address is: seindal@diku.dk
  812. X*/
  813. X
  814. X#include "defs.h"
  815. X
  816. Xstruct linemod {
  817. X    char *name;
  818. X    char *pat;
  819. X} linemods[] = {
  820. X    { "solid", "[] 0" },
  821. X    { "dotted", "[1 2] 0" },
  822. X    { "longdashed",  "[9 2] 0" },
  823. X    { "shortdashed", "[4.5 2] 0" },
  824. X    { "dotdashed" , "[9 2 1 2] 0" },
  825. X    { 0 , 0 },
  826. X};
  827. X
  828. Xlinemod(s)
  829. X    char *s;
  830. X{
  831. X    struct linemod *lm;
  832. X
  833. X    for ( lm = linemods; lm->name && strcmp( lm->name, s ); lm++ )
  834. X    ;
  835. X    if ( lm->name == 0 )
  836. X    lm = linemods;
  837. X
  838. X    clear();
  839. X    printf( "%s setdash\n", lm->pat );
  840. X}
  841. X
  842. SHAR_EOF
  843. chmod 0644 linemod.c || echo "restore of linemod.c fails"
  844. echo "x - extracting move.c (Text)"
  845. sed 's/^X//' << 'SHAR_EOF' > move.c &&
  846. X/*
  847. X    This file is part of plot2ps.
  848. X
  849. X    Copyright (C) 1989 Rene' Seindal
  850. X
  851. X    This program is free software; you can redistribute it and/or modify
  852. X    it under the terms of the GNU General Public License as published by
  853. X    the Free Software Foundation; either version 1, or (at your option)
  854. X    any later version.
  855. X
  856. X    This program is distributed in the hope that it will be useful,
  857. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  858. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  859. X    GNU General Public License for more details.
  860. X
  861. X    You should have received a copy of the GNU General Public License
  862. X    along with this program; if not, write to the Free Software
  863. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  864. X
  865. X    My current address is: seindal@diku.dk
  866. X*/
  867. X
  868. X#include "defs.h"
  869. X
  870. Xmove( x, y )
  871. X{
  872. X    shipout( "%g %g moveto\n", X(x), Y(y) );
  873. X}
  874. SHAR_EOF
  875. chmod 0644 move.c || echo "restore of move.c fails"
  876. echo "x - extracting openpl.c (Text)"
  877. sed 's/^X//' << 'SHAR_EOF' > openpl.c &&
  878. X/*
  879. X    This file is part of plot2ps.
  880. X
  881. X    Copyright (C) 1989 Rene' Seindal
  882. X
  883. X    This program is free software; you can redistribute it and/or modify
  884. X    it under the terms of the GNU General Public License as published by
  885. X    the Free Software Foundation; either version 1, or (at your option)
  886. X    any later version.
  887. X
  888. X    This program is distributed in the hope that it will be useful,
  889. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  890. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  891. X    GNU General Public License for more details.
  892. X
  893. X    You should have received a copy of the GNU General Public License
  894. X    along with this program; if not, write to the Free Software
  895. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  896. X
  897. X    My current address is: seindal@diku.dk
  898. X*/
  899. X
  900. X#include "defs.h"
  901. X
  902. Xdouble xscale = (double)(XMAX - XMIN) / (double)XRANGE;
  903. Xdouble yscale = (double)(YMAX - YMIN) / (double)YRANGE;
  904. Xdouble xoffset = (double)XMIN;
  905. Xdouble yoffset = (double)XMAX;
  906. X
  907. Xint state = INVALID;        /* state of the page */
  908. Xint restpathlen;        /* length of current path */
  909. X
  910. Xopenpl ()
  911. X{
  912. X    printf( "/%s findfont %g scalefont setfont\n", FONT, (double)PTSIZE );
  913. X    everypage();
  914. X    restpathlen = MAXPATHLENGTH;
  915. X    state = CLEANPAGE | CLEANPATH;
  916. X}
  917. SHAR_EOF
  918. chmod 0644 openpl.c || echo "restore of openpl.c fails"
  919. echo "x - extracting output.c (Text)"
  920. sed 's/^X//' << 'SHAR_EOF' > output.c &&
  921. X/*
  922. X    This file is part of plot2ps.
  923. X
  924. X    Copyright (C) 1989 Rene' Seindal
  925. X
  926. X    This program is free software; you can redistribute it and/or modify
  927. X    it under the terms of the GNU General Public License as published by
  928. X    the Free Software Foundation; either version 1, or (at your option)
  929. X    any later version.
  930. X
  931. X    This program is distributed in the hope that it will be useful,
  932. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  933. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  934. X    GNU General Public License for more details.
  935. X
  936. X    You should have received a copy of the GNU General Public License
  937. X    along with this program; if not, write to the Free Software
  938. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  939. X
  940. X    My current address is: seindal@diku.dk
  941. X*/
  942. X
  943. X#include "defs.h"
  944. X
  945. Xeverypage()
  946. X{
  947. X    printf( "%g setlinewidth newpath\n", (double)LINEWIDTH );
  948. X}
  949. X
  950. X
  951. Xvoid shipout( fmt, arg1, arg2, arg3, arg4 )
  952. X    char *fmt;
  953. X    double arg1, arg2, arg3, arg4;
  954. X{
  955. X    if ( --restpathlen == 0 ) {
  956. X    restpathlen = MAXPATHLENGTH;
  957. X    printf( "currentpoint stroke newpath moveto\n" );
  958. X    }
  959. X    printf( fmt, arg1, arg2, arg3, arg4 );
  960. X    
  961. X    DIRTYPATH;
  962. X}
  963. X
  964. Xclear()
  965. X{
  966. X    if ( state & CLEANPATH )
  967. X    return;
  968. X    printf( "stroke newpath\n" );
  969. X    state |= CLEANPATH;
  970. X    restpathlen = MAXPATHLENGTH;
  971. X}
  972. SHAR_EOF
  973. chmod 0644 output.c || echo "restore of output.c fails"
  974. echo "x - extracting plot2ps.1 (Text)"
  975. sed 's/^X//' << 'SHAR_EOF' > plot2ps.1 &&
  976. X.\" Rene' Seindal (seindal@skinfaxe.diku.dk) Tue Mar 28 06:10:24 1989
  977. X.TH PLOT2PS 1 "Mar 28 1989"
  978. X.SH NAME
  979. Xplot2ps \- convert plot(5) data to PostScript
  980. X.SH SYNOPSIS
  981. X.B plot2ps
  982. X.SH DESCRIPTION
  983. X.I Plot2ps
  984. Xconverts 
  985. X.IR plot "(5)"
  986. Xdata from standard input to PostScript on standard output.
  987. X.SH SEE ALSO
  988. Xplot(1), plot(5)
  989. X.SH AUTHOR
  990. XRen\'e Seindal, DIKU, U. of Copenhagen.
  991. X
  992. SHAR_EOF
  993. chmod 0644 plot2ps.1 || echo "restore of plot2ps.1 fails"
  994. echo "x - extracting plot2ps.c (Text)"
  995. sed 's/^X//' << 'SHAR_EOF' > plot2ps.c &&
  996. X/*
  997. X    plot2ps --- convert Unix plot(5) data to PostScript
  998. X
  999. X    Copyright (C) 1989 Rene' Seindal
  1000. X
  1001. X    This program is free software; you can redistribute it and/or modify
  1002. X    it under the terms of the GNU General Public License as published by
  1003. X    the Free Software Foundation; either version 1, or (at your option)
  1004. X    any later version.
  1005. X
  1006. X    This program is distributed in the hope that it will be useful,
  1007. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  1008. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1009. X    GNU General Public License for more details.
  1010. X
  1011. X    You should have received a copy of the GNU General Public License
  1012. X    along with this program; if not, write to the Free Software
  1013. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1014. X
  1015. X    My current address is: seindal@diku.dk
  1016. X*/
  1017. X
  1018. X#include <stdio.h>
  1019. X
  1020. X/* routines for reading plot data */
  1021. Xint  getch();            /* get a byte */
  1022. Xint  getsi();            /* get a signed short */
  1023. Xchar *getstr();            /* get a string */
  1024. X
  1025. X#include "bytesex.h"
  1026. X
  1027. Xmain(argc,argv)
  1028. X    int    argc;
  1029. X    char **argv;
  1030. X{
  1031. X    int cmd;
  1032. X    int x, y, x0, y0, x1, y1;    /* (x, y) coordinates */
  1033. X    int r;            /* circle radius */
  1034. X    char *l;            /* label/linemods */
  1035. X
  1036. X    openpl();
  1037. X    while ( (cmd = getch()) != EOF ) {
  1038. X    switch (cmd) {
  1039. X    case 'm':
  1040. X        x = getsi();
  1041. X        y = getsi();
  1042. X        move( x, y );
  1043. X        break;
  1044. X    case 'n':
  1045. X        x = getsi();
  1046. X        y = getsi();
  1047. X        cont( x, y );
  1048. X        break;
  1049. X    case 'p':
  1050. X        x = getsi();
  1051. X        y = getsi();
  1052. X        point( x, y );
  1053. X        break;
  1054. X    case 'l':
  1055. X        x = getsi();
  1056. X        y = getsi();
  1057. X        x0 = getsi();
  1058. X        y0 = getsi();
  1059. X        line( x, y, x0, y0 );
  1060. X        break;
  1061. X    case 't':
  1062. X        l = getstr();
  1063. X        label( l );
  1064. X        break;
  1065. X    case 'a':
  1066. X        x = getsi();
  1067. X        y = getsi();
  1068. X        x0 = getsi();
  1069. X        y0 = getsi();
  1070. X        x1 = getsi();
  1071. X        y1 = getsi();
  1072. X        arc( x,y, x0, y0, x1, y1 );
  1073. X        break;
  1074. X    case 'c':
  1075. X        x = getsi();
  1076. X        y = getsi();
  1077. X        r = getsi();
  1078. X        circle( x, y, r );
  1079. X        break;
  1080. X    case 'e':
  1081. X        erase();
  1082. X        break;
  1083. X    case 'f':
  1084. X        l = getstr();
  1085. X        linemod( l );
  1086. X        break;
  1087. X    case 's':
  1088. X        x = getsi();
  1089. X        y = getsi();
  1090. X        x0 = getsi();
  1091. X        y0 = getsi();
  1092. X        space( x, y, x0, y0 );
  1093. X        break;
  1094. X    default:
  1095. X        fprintf( stderr, "Undefinde plot command 0%o\n", cmd );
  1096. X    }
  1097. X    }
  1098. X    closepl();
  1099. X}
  1100. X
  1101. X/* getch() reads a single byte from stdin, not reading EOF more than once,
  1102. X * and not returning more than 8 bits.
  1103. X */
  1104. Xint getch()
  1105. X{
  1106. X    int ch;
  1107. X    static char eof = '\0';
  1108. X
  1109. X    if (eof) return EOF;
  1110. X    
  1111. X    if ( (ch = getchar()) == EOF ) {
  1112. X    eof = '\1';
  1113. X    return EOF;
  1114. X    }
  1115. X    return ch&0377;
  1116. X}
  1117. X
  1118. X/* getsi() return a signed short integer, big endian and sign extending.
  1119. X * Returns EOF on end of file.
  1120. X */
  1121. Xint getsi()
  1122. X{
  1123. X    int m, n;
  1124. X    int val;
  1125. X
  1126. X    n = getch();
  1127. X    if ( n == EOF )
  1128. X    return EOF;
  1129. X
  1130. X    m = getch();
  1131. X    if ( m == EOF )
  1132. X    return EOF;
  1133. X
  1134. X#ifdef BIG_ENDIAN
  1135. X    val = ((m << 8) | n);
  1136. X#else
  1137. X    val = ((n << 8) | m);
  1138. X#endif
  1139. X    if ( val & 0x8000 )
  1140. X    val |= ~0x7fff;
  1141. X    return val;
  1142. X}
  1143. X
  1144. X/* getstr() reads a string from stdin.  The string is terminated by EOF,
  1145. X * newline or '\0'.
  1146. X */
  1147. Xchar *getstr()
  1148. X{
  1149. X    char str[1024];
  1150. X    char *s = str;
  1151. X    int ch;
  1152. X
  1153. X    while ( (ch = getch()) != EOF && ch != '\n' && ch != '\0' )
  1154. X    *s++ = ch;
  1155. X    *s = '\0';
  1156. X
  1157. X    return str;
  1158. X}
  1159. X
  1160. X    
  1161. SHAR_EOF
  1162. chmod 0644 plot2ps.c || echo "restore of plot2ps.c fails"
  1163. echo "x - extracting point.c (Text)"
  1164. sed 's/^X//' << 'SHAR_EOF' > point.c &&
  1165. X/*
  1166. X    This file is part of plot2ps.
  1167. X
  1168. X    Copyright (C) 1989 Rene' Seindal
  1169. X
  1170. X    This program is free software; you can redistribute it and/or modify
  1171. X    it under the terms of the GNU General Public License as published by
  1172. X    the Free Software Foundation; either version 1, or (at your option)
  1173. X    any later version.
  1174. X
  1175. X    This program is distributed in the hope that it will be useful,
  1176. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  1177. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1178. X    GNU General Public License for more details.
  1179. X
  1180. X    You should have received a copy of the GNU General Public License
  1181. X    along with this program; if not, write to the Free Software
  1182. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1183. X
  1184. X    My current address is: seindal@diku.dk
  1185. X*/
  1186. X
  1187. X#include "defs.h"
  1188. X
  1189. X
  1190. Xpoint( x, y )
  1191. X{
  1192. X    clear();
  1193. X    printf( "%g %g %g 0 360 arc closepath fill newpath\n",
  1194. X       X(x), Y(y), (double)POINTDIAM );
  1195. X    state |= CLEANPATH;
  1196. X    DIRTYPAGE;
  1197. X}
  1198. SHAR_EOF
  1199. chmod 0644 point.c || echo "restore of point.c fails"
  1200. echo "x - extracting space.c (Text)"
  1201. sed 's/^X//' << 'SHAR_EOF' > space.c &&
  1202. X/*
  1203. X    This file is part of plot2ps.
  1204. X
  1205. X    Copyright (C) 1989 Rene' Seindal
  1206. X
  1207. X    This program is free software; you can redistribute it and/or modify
  1208. X    it under the terms of the GNU General Public License as published by
  1209. X    the Free Software Foundation; either version 1, or (at your option)
  1210. X    any later version.
  1211. X
  1212. X    This program is distributed in the hope that it will be useful,
  1213. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  1214. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1215. X    GNU General Public License for more details.
  1216. X
  1217. X    You should have received a copy of the GNU General Public License
  1218. X    along with this program; if not, write to the Free Software
  1219. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1220. X
  1221. X    My current address is: seindal@diku.dk
  1222. X*/
  1223. X
  1224. X#include "defs.h"
  1225. X
  1226. Xspace( x0, y0, x1, y1 )
  1227. X{
  1228. X    xscale = (double)(XMAX - XMIN) / (double)(x1 - x0);
  1229. X    yscale = (double)(YMAX - YMIN) / (double)(y1 - y0);
  1230. X
  1231. X    xoffset = XMIN - xscale * (double)(x0);
  1232. X    yoffset = YMIN - yscale * (double)(y0);
  1233. X}
  1234. SHAR_EOF
  1235. chmod 0644 space.c || echo "restore of space.c fails"
  1236. exit 0
  1237.  
  1238.  
  1239.