home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume27 / transfig-2.1.8 / part02 < prev    next >
Encoding:
Text File  |  1993-10-05  |  74.0 KB  |  2,539 lines

  1. Newsgroups: comp.sources.unix
  2. From: envbvs@epb12.lbl.gov (Brian V. Smith)
  3. Subject: v27i056: transfig-2.1.8 - a set of tools for creating TeX documents with graphics, Part02/07
  4. References: <1.749903574.10622@gw.home.vix.com>
  5. Sender: unix-sources-moderator@gw.home.vix.com
  6. Approved: vixie@gw.home.vix.com
  7.  
  8. Submitted-By: envbvs@epb12.lbl.gov (Brian V. Smith)
  9. Posting-Number: Volume 27, Issue 56
  10. Archive-Name: transfig-2.1.8/part02
  11.  
  12. #! /bin/sh
  13. # This is a shell archive.  Remove anything before this line, then unpack
  14. # it by saving it into a file and typing "sh file".  To overwrite existing
  15. # files, type "sh file -c".  You can also feed this as standard input via
  16. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  17. # will see the following message at the end:
  18. #        "End of archive 2 (of 7)."
  19. # Contents:  doc/tpic.spec fig2dev/dev/Makefile fig2dev/dev/genpstex.c
  20. #   fig2dev/dev/tpicfonts.h fig2dev/fig2dev.c fig2dev/getopt.c
  21. #   fig2dev/latex_line.c fig2dev/object.h fig2dev/psfonts.c
  22. #   transfig/mkfile.c transfig/transfig.c
  23. # Wrapped by envbvs@epb12.lbl.gov.lbl.gov on Fri Oct  1 14:55:45 1993
  24. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  25. if test -f 'doc/tpic.spec' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'doc/tpic.spec'\"
  27. else
  28. echo shar: Extracting \"'doc/tpic.spec'\" \(8799 characters\)
  29. sed "s/^X//" >'doc/tpic.spec' <<'END_OF_FILE'
  30. X\section{Output Specification}
  31. XThis section defines the output language which is generated by
  32. X\tpic/.  It is intended only for use by writers of
  33. X{\sc dvi} device drivers.  The first lines of output will
  34. Xexecute a \tcom{newbox} command to define \tcom{graph} if it
  35. Xhas not already been defined.  Each picture is enclosed in a \tcom{vtop}
  36. Xwhich is assigned to \tcom{graph}.  The width and height of this box are
  37. Xthe size of the picture as known to \tpic/ (text doesn't count because
  38. X\tpic/ can't know how wide it may be).  Inside this box are a
  39. Xsequence of \tcom{special} commands which define all the graphics,
  40. Xalong with \tcom{hbox} commands setting the text left, right, or center
  41. Xof a given point.
  42. XEach graphical element is placed relative to \TeX's idea of the location
  43. Xof this \tcom{special} on the page.  Each \tcom{special} is set at the
  44. Xtop left corner of the \tcom{graph} box.  This point is considered the
  45. Xorigin of the graph.  The $x$ axis is positive to the right, and the $y$
  46. Xaxis is positive moving down the page.  Thus the coordinates in the
  47. Xgraphics commands are in terms of a virtual page with axes oriented the
  48. Xsame as on many printers and workstation screens, like this:
  49. X.PS
  50. X"0,0" at (0,0) above
  51. Xarrow from (0,0) to (0.5,0)
  52. X"\ $+x$" at (0.5,0) ljust
  53. Xarrow from (0,0) to (0,-0.5)
  54. X"$+y$" at end of last arrow below
  55. X.PE
  56. X\centerline{\box\graph}
  57. XAngles are measured in the conventional way, from $+x$ towards $+y$.
  58. XUnfortunately, that reverses the meaning of "counterclockwise" from
  59. Xwhat you see in the output.  Angle measurements are in radians, from
  60. X0 to $2\pi$.  A complete circle or ellipse will have
  61. X$\hbox{\it start angle}=0$ and $\hbox{\it end angle} \ge 2\pi$.
  62. XThus, each distance (expressed in milli-inches) will be a positive number,
  63. Xsince the box encloses all of the graphical elements.
  64. XThe possible \tcom{special} commands which must be implemented are
  65. Xas follows.  All numbers which represent distances
  66. Xare integers except where noted.  Angles are always measured in radians,
  67. Xand they are measured in the conventional way from $+x$ towards $+y$.
  68. XNormally, this would be ``counterclockwise''.
  69. XUnfortunately, since the $y$ axis points down
  70. Xinstead of up, this turns out to be backwards.
  71. XThis is especially confusing because in the input language, $+y$
  72. Xpoint upwards.  Device driver writers should beware of this point.
  73. XIt is best to do all arithmetic in the coordinates of \tpic/'s output,
  74. Xthen convert the resulting endpoints to the device's coordinates
  75. Xfor printing; this should produce correct results in all cases.
  76. X\begin{description}
  77. X\item[pn $s$]           Sets the pen size to $s$ milli-inches.
  78. X\item[pa $x$ $y$]       Add point $(x,y)$ to a ``path'' which is
  79. X                        being stored in the {\sc dvi} interpreter.
  80. X                        The values of $x$ and $y$ are in milli-inches.
  81. X\item[fp]               Flush (i.e., print using the current pen size)
  82. X                        a previously defined path.  The number of path
  83. X                        elements is reset to zero.  If shading has been
  84. X                        specified, and if the path is closed, then the
  85. X                        enclosed area should be shaded.  Currently,
  86. X                        \tpic/ can only specify closed regions which are
  87. X                        rectangles using the {\tt pa} command, and
  88. X                        circles/ellipses are specified with the {\tt ar}
  89. X                        command; however, device driver writers should
  90. X                        not rely on this restriction.  Someday, \tpic/
  91. X                        may be able to specify arbitrary closed areas
  92. X                        using {\tt pa} commands.  Currently, the only
  93. X                        example of this is the shading of arrowheads,
  94. X                        which are triangular.
  95. X\item[ip]               This is the same as {\tt fp} except that the
  96. X                        path is not actually drawn.  Shading of the defined
  97. X                        region is performed if it has been specified.
  98. X\item[da $f$]           This is the same as {\tt fp} except that the line
  99. X                        is drawn as a dashed line with $f$ inches per dash
  100. X                        ($f$ is a real number).
  101. X\item[dt $f$]           This is the same as {\tt da} except that a dotted
  102. X                        line is drawn, with $f$ inches between each
  103. X                        dot ($f$ is a real number).
  104. X\item[sp $d$]           This is the same as {\tt fp} except that a spline
  105. X                        is drawn through the points.  The spline is guaranteed
  106. X                        to go through only the first and last points,
  107. X                        depending on the relative positions of any
  108. X                        intermediate points.  The argument $d$ is an
  109. X                        optional real value.  If $d=0$ or the argument
  110. X                        is omitted,
  111. X                        the spline is drawn normally, as a solid line.
  112. X                        If $d>0$, it is dashed with $d$ as the dashwid, else
  113. X                        if $d<0$, the spline is dotted with $-d$ as the dotwid.
  114. X\item[ar $x$ $y$ $r_x$ $r_y$ $s$ $e$]
  115. X                        Draw an arc with center at $(x,y)$, from
  116. X                        starting angle $s$ to ending angle $e$.
  117. X                        If it's a complete circle or ellipse, then
  118. X                        $r_x$ and $r_y$ determine the $x$ and $y$ radii,
  119. X                        respectively.  Otherwise, $r_x=r_y$ will hold,
  120. X                        and an arc from $s$ to $e$ should be drawn.
  121. X\item[ia $x$ $y$ $r_x$ $r_y$ $s$ $e$] The {\tt ia} command is to {\tt ar} what
  122. X                        {\tt ip} is to {\tt fp}.
  123. X\end{description}
  124. XThe following command is optional in {\sc dvi} driver implementations
  125. Xof \tpic/.  Drivers which do not implement it should silently ignore it.
  126. X\begin{description}
  127. X\item[sh $s$]           Shade the interior of the next closed figure defined
  128. X                        with three or more {\tt pa} commands followed
  129. X                        by a {\tt fp} or {\tt ip} command, or by an
  130. X                        {\tt ar} or {\tt ia} command.  The value $s$ is
  131. X                        a floating point number from 0 to 1.  Zero implies
  132. X                        a completely white interior (including erasing
  133. X                        anything underneath), while 1 implies completely
  134. X                        black.  A value of 0.5 is a default
  135. X                        ``normal'' gray shading.  If $s$ is not specified,
  136. X                        a value of 0.5 should be used.  NB: Shading applies
  137. X                        to the interior of the object only; the borders of
  138. X                        the object are still drawn using the current pen,
  139. X                        which is particularly important for dvi drivers
  140. X                        which do not support the {\tt sh} command.  The
  141. X                        pixels generated by the shading value should be
  142. X                        ``ANDed'' with the pixels already in the area.
  143. X                        Subsequent text pixels should be ``ORed''.  Thus,
  144. X                        text {\it followed\/} by a ``{\tt sh 0}'' command
  145. X                        covering the same area will disappear.  Any shading
  146. X                        value greater than zero should add the shading
  147. X                        to the existing text, with the text remaining
  148. X                        visible.  Of course, a shading value of one will
  149. X                        be completely black, so any text that is there
  150. X                        won't be distinguishable.
  151. X\end{description}
  152. XThe following two opcodes are considered obsolete, but they probably should be
  153. Ximplemented for backwards compatibility:
  154. X\begin{description}
  155. X\item[wh]               This is the same as ``{\tt sh 0}''.
  156. X\item[bk]               This is the same as ``{\tt sh 1}''.
  157. X\item[tx]               This command was used to specify a texture
  158. X                        to be used in shading instead of the default
  159. X                        one.  Its use was limited to
  160. X                        only one particular Imagen device driver,
  161. X                        and it was very device-specific.  Its
  162. X                        implementation is discouraged in favor of
  163. X                        support for the argument to the {\tt sh} command.
  164. X\end{description}
  165. X-----------------,------------------------------,------------------------------
  166. XMichael N. Lipp  !  Institut fuer Datentechnik  !  Phone: 49-6151-163776
  167. X                 !  Merckstr. 25     ,----------'  Fax:   49-6151-164976
  168. X                 !  D-6100 Darmstadt ! E-Mail:        xdatmnlx@ddathd21.bitnet
  169. X                 !  (Germany)        !    mnl@idtsun.e-technik.th-darmstadt.de
  170. X-----------------'-------------------'-----------------------------------------
  171. END_OF_FILE
  172. if test 8799 -ne `wc -c <'doc/tpic.spec'`; then
  173.     echo shar: \"'doc/tpic.spec'\" unpacked with wrong size!
  174. fi
  175. # end of 'doc/tpic.spec'
  176. fi
  177. if test -f 'fig2dev/dev/Makefile' -a "${1}" != "-c" ; then 
  178.   echo shar: Will not clobber existing file \"'fig2dev/dev/Makefile'\"
  179. else
  180. echo shar: Extracting \"'fig2dev/dev/Makefile'\" \(9932 characters\)
  181. sed "s/^X//" >'fig2dev/dev/Makefile' <<'END_OF_FILE'
  182. X# Makefile generated by imake - do not edit!
  183. X# $XConsortium: imake.c,v 1.65 91/07/25 17:50:17 rws Exp $
  184. X#
  185. X# The cpp used on this machine replaces all newlines and multiple tabs and
  186. X# spaces in a macro expansion with a single space.  Imake tries to compensate
  187. X# for this, but is not always successful.
  188. X#
  189. X
  190. X# -------------------------------------------------------------------------
  191. X# Makefile generated from "Imake.tmpl" and </tmp/IIf.a21026>
  192. X# $XConsortium: Imake.tmpl,v 1.139 91/09/16 08:52:48 rws Exp $
  193. X#
  194. X# Platform-specific parameters may be set in the appropriate <vendor>.cf
  195. X# configuration files.  Site-specific parameters should be set in the file
  196. X# site.def.  Full rebuilds are recommended if any parameters are changed.
  197. X#
  198. X# If your C preprocessor does not define any unique symbols, you will need
  199. X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
  200. X# "make World" the first time).
  201. X#
  202. X
  203. X# -------------------------------------------------------------------------
  204. X# site-specific configuration parameters that need to come before
  205. X# the platform-specific parameters - edit site.def to change
  206. X
  207. X# site:  $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $
  208. X
  209. X# -------------------------------------------------------------------------
  210. X# platform-specific configuration parameters - edit sun.cf to change
  211. X
  212. X# platform:  $XConsortium: sun.cf,v 1.72.1.1 92/03/18 13:13:37 rws Exp $
  213. X
  214. X# operating system:  SunOS 4.1.2
  215. X
  216. X# $XConsortium: sunLib.rules,v 1.7 91/12/20 11:19:47 rws Exp $
  217. X
  218. X# -------------------------------------------------------------------------
  219. X# site-specific configuration parameters that go after
  220. X# the platform-specific parameters - edit site.def to change
  221. X
  222. X# site:  $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $
  223. X
  224. X            SHELL = /bin/sh
  225. X
  226. X              TOP = ../../.
  227. X      CURRENT_DIR = ./fig2dev/dev
  228. X
  229. X               AR = ar clq
  230. X  BOOTSTRAPCFLAGS =
  231. X               CC = cc
  232. X               AS = as
  233. X
  234. X         COMPRESS = compress
  235. X              CPP = /lib/cpp $(STD_CPP_DEFINES)
  236. X    PREPROCESSCMD = cc -E $(STD_CPP_DEFINES)
  237. X          INSTALL = install
  238. X               LD = ld
  239. X             LINT = lint
  240. X      LINTLIBFLAG = -C
  241. X         LINTOPTS = -axz
  242. X               LN = ln -s
  243. X             MAKE = make
  244. X               MV = mv
  245. X               CP = cp
  246. X
  247. X           RANLIB = ranlib
  248. X  RANLIBINSTFLAGS =
  249. X
  250. X               RM = rm -f
  251. X            TROFF = psroff
  252. X         MSMACROS = -ms
  253. X              TBL = tbl
  254. X              EQN = eqn
  255. X     STD_INCLUDES =
  256. X  STD_CPP_DEFINES =
  257. X      STD_DEFINES =
  258. X EXTRA_LOAD_FLAGS =
  259. X  EXTRA_LIBRARIES =
  260. X             TAGS = ctags
  261. X
  262. X    SHAREDCODEDEF = -DSHAREDCODE
  263. X         SHLIBDEF = -DSUNSHLIB
  264. X
  265. X    PROTO_DEFINES =
  266. X
  267. X     INSTPGMFLAGS =
  268. X
  269. X     INSTBINFLAGS = -m 0755
  270. X     INSTUIDFLAGS = -m 4755
  271. X     INSTLIBFLAGS = -m 0644
  272. X     INSTINCFLAGS = -m 0444
  273. X     INSTMANFLAGS = -m 0444
  274. X     INSTDATFLAGS = -m 0444
  275. X    INSTKMEMFLAGS = -g kmem -m 2755
  276. X
  277. X      CDEBUGFLAGS = -O
  278. X        CCOPTIONS =
  279. X
  280. X      ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES)
  281. X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(DEFINES)
  282. X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)
  283. X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
  284. X
  285. X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  286. X
  287. X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) $(LOCAL_LDFLAGS)
  288. X
  289. X   LDCOMBINEFLAGS = -X -r
  290. X      DEPENDFLAGS =
  291. X
  292. X        MACROFILE = sun.cf
  293. X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
  294. X
  295. X    IMAKE_DEFINES =
  296. X
  297. X         IRULESRC = $(CONFIGDIR)
  298. X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
  299. X
  300. X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \
  301. X            $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \
  302. X            $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
  303. X
  304. X# -------------------------------------------------------------------------
  305. X# X Window System Build Parameters
  306. X# $XConsortium: Project.tmpl,v 1.138 91/09/10 09:02:12 rws Exp $
  307. X
  308. X# -------------------------------------------------------------------------
  309. X# X Window System make variables; this need to be coordinated with rules
  310. X
  311. X          PATHSEP = /
  312. X        USRLIBDIR = /usr/lib
  313. X           BINDIR = /usr/bin/X11
  314. X          INCROOT = /usr/include
  315. X     BUILDINCROOT = $(TOP)
  316. X      BUILDINCDIR = $(BUILDINCROOT)/X11
  317. X      BUILDINCTOP = ..
  318. X           INCDIR = $(INCROOT)/X11
  319. X           ADMDIR = /usr/adm
  320. X           LIBDIR = $(USRLIBDIR)/X11
  321. X        CONFIGDIR = $(LIBDIR)/config
  322. X       LINTLIBDIR = $(USRLIBDIR)/lint
  323. X
  324. X          FONTDIR = $(LIBDIR)/fonts
  325. X         XINITDIR = $(LIBDIR)/xinit
  326. X           XDMDIR = $(LIBDIR)/xdm
  327. X           TWMDIR = $(LIBDIR)/twm
  328. X          MANPATH = /usr/man
  329. X    MANSOURCEPATH = $(MANPATH)/man
  330. X        MANSUFFIX = l
  331. X     LIBMANSUFFIX = 3
  332. X           MANDIR = $(MANSOURCEPATH)$(MANSUFFIX)
  333. X        LIBMANDIR = $(MANSOURCEPATH)$(LIBMANSUFFIX)
  334. X           NLSDIR = $(LIBDIR)/nls
  335. X        PEXAPIDIR = $(LIBDIR)/PEX
  336. X      XAPPLOADDIR = $(LIBDIR)/app-defaults
  337. X       FONTCFLAGS = -t
  338. X
  339. X     INSTAPPFLAGS = $(INSTDATFLAGS)
  340. X
  341. X            IMAKE = imake
  342. X           DEPEND = makedepend
  343. X              RGB = rgb
  344. X
  345. X            FONTC = bdftopcf
  346. X
  347. X        MKFONTDIR = mkfontdir
  348. X        MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier
  349. X
  350. X        CONFIGSRC = $(TOP)/config
  351. X       DOCUTILSRC = $(TOP)/doc/util
  352. X        CLIENTSRC = $(TOP)/clients
  353. X          DEMOSRC = $(TOP)/demos
  354. X           LIBSRC = $(TOP)/lib
  355. X          FONTSRC = $(TOP)/fonts
  356. X       INCLUDESRC = $(TOP)/X11
  357. X        SERVERSRC = $(TOP)/server
  358. X          UTILSRC = $(TOP)/util
  359. X        SCRIPTSRC = $(UTILSRC)/scripts
  360. X       EXAMPLESRC = $(TOP)/examples
  361. X       CONTRIBSRC = $(TOP)/../contrib
  362. X           DOCSRC = $(TOP)/doc
  363. X           RGBSRC = $(TOP)/rgb
  364. X        DEPENDSRC = $(UTILSRC)/makedepend
  365. X         IMAKESRC = $(CONFIGSRC)
  366. X         XAUTHSRC = $(LIBSRC)/Xau
  367. X          XLIBSRC = $(LIBSRC)/X
  368. X           XMUSRC = $(LIBSRC)/Xmu
  369. X       TOOLKITSRC = $(LIBSRC)/Xt
  370. X       AWIDGETSRC = $(LIBSRC)/Xaw
  371. X       OLDXLIBSRC = $(LIBSRC)/oldX
  372. X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
  373. X      BDFTOSNFSRC = $(FONTSRC)/bdftosnf
  374. X      BDFTOSNFSRC = $(FONTSRC)/clients/bdftosnf
  375. X      BDFTOPCFSRC = $(FONTSRC)/clients/bdftopcf
  376. X     MKFONTDIRSRC = $(FONTSRC)/clients/mkfontdir
  377. X         FSLIBSRC = $(FONTSRC)/lib/fs
  378. X    FONTSERVERSRC = $(FONTSRC)/server
  379. X     EXTENSIONSRC = $(TOP)/extensions
  380. X         XILIBSRC = $(EXTENSIONSRC)/lib/xinput
  381. X      PHIGSLIBSRC = $(EXTENSIONSRC)/lib/PEX
  382. X
  383. X# $XConsortium: sunLib.tmpl,v 1.14.1.1 92/03/17 14:58:46 rws Exp $
  384. X
  385. XSHLIBLDFLAGS = -assert pure-text
  386. XPICFLAGS = -pic
  387. X
  388. X  DEPEXTENSIONLIB =
  389. X     EXTENSIONLIB = -lXext
  390. X
  391. X          DEPXLIB = $(DEPEXTENSIONLIB)
  392. X             XLIB = $(EXTENSIONLIB) -lX11
  393. X
  394. X        DEPXMULIB = $(USRLIBDIR)/libXmu.sa.$(SOXMUREV)
  395. X       XMULIBONLY = -lXmu
  396. X           XMULIB = -lXmu
  397. X
  398. X       DEPOLDXLIB =
  399. X          OLDXLIB = -loldX
  400. X
  401. X      DEPXTOOLLIB = $(USRLIBDIR)/libXt.sa.$(SOXTREV)
  402. X         XTOOLLIB = -lXt
  403. X
  404. X        DEPXAWLIB = $(USRLIBDIR)/libXaw.sa.$(SOXAWREV)
  405. X           XAWLIB = -lXaw
  406. X
  407. X        DEPXILIB =
  408. X           XILIB = -lXi
  409. X
  410. X        SOXLIBREV = 4.10
  411. X          SOXTREV = 4.10
  412. X         SOXAWREV = 5.0
  413. X        SOOLDXREV = 4.10
  414. X         SOXMUREV = 4.10
  415. X        SOXEXTREV = 4.10
  416. X      SOXINPUTREV = 4.10
  417. X
  418. X      DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
  419. X         XAUTHLIB =  -lXau
  420. X      DEPXDMCPLIB = $(USRLIBDIR)/libXdmcp.a
  421. X         XDMCPLIB =  -lXdmcp
  422. X
  423. X        DEPPHIGSLIB = $(USRLIBDIR)/libphigs.a
  424. X           PHIGSLIB =  -lphigs
  425. X
  426. X       DEPXBSDLIB = $(USRLIBDIR)/libXbsd.a
  427. X          XBSDLIB =  -lXbsd
  428. X
  429. X LINTEXTENSIONLIB = $(LINTLIBDIR)/llib-lXext.ln
  430. X         LINTXLIB = $(LINTLIBDIR)/llib-lX11.ln
  431. X          LINTXMU = $(LINTLIBDIR)/llib-lXmu.ln
  432. X        LINTXTOOL = $(LINTLIBDIR)/llib-lXt.ln
  433. X          LINTXAW = $(LINTLIBDIR)/llib-lXaw.ln
  434. X           LINTXI = $(LINTLIBDIR)/llib-lXi.ln
  435. X        LINTPHIGS = $(LINTLIBDIR)/llib-lphigs.ln
  436. X
  437. X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
  438. X
  439. X         DEPLIBS1 = $(DEPLIBS)
  440. X         DEPLIBS2 = $(DEPLIBS)
  441. X         DEPLIBS3 = $(DEPLIBS)
  442. X
  443. X# -------------------------------------------------------------------------
  444. X# Imake rules for building libraries, programs, scripts, and data files
  445. X# rules:  $XConsortium: Imake.rules,v 1.123 91/09/16 20:12:16 rws Exp $
  446. X
  447. X# -------------------------------------------------------------------------
  448. X# start of Imakefile
  449. X
  450. X#
  451. X#    Fig2dev Driver Library Makefile
  452. X#
  453. X# to set paper size to A4             add -DA4d    to DEFINES list
  454. X# to set IBM Graphics Enhancement Cartridge    add -DIBMGEC    to DEFINES list
  455. X# to set DVI-to-PostScript driver to dvips    add -DDVIPS    to DEFINES list
  456. X#
  457. XDEFINES = -DDVIPS
  458. XDEPLIBS =
  459. XINCLUDES = -I..
  460. X
  461. XSRCS =  genbox.c genepic.c genibmgl.c genlatex.c genpic.c genpictex.c \
  462. X    genps.c genpstex.c gentextyl.c gentpic.c setfigfont.c
  463. XLIBOBJS = genbox.o genepic.o genibmgl.o genlatex.o genpic.o genpictex.o \
  464. X    genps.o genpstex.o gentextyl.o gentpic.o setfigfont.o
  465. X
  466. XLIB = transfig
  467. X
  468. Xall:: lib$(LIB).a
  469. X
  470. Xlib$(LIB).a: $(LIBOBJS)
  471. X    $(RM) $@
  472. X    $(AR) $@ $(LIBOBJS)
  473. X    $(RANLIB) $@
  474. X
  475. Xdepend::
  476. X    $(DEPEND) $(DEPENDFLAGS) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
  477. X
  478. X# -------------------------------------------------------------------------
  479. X# common rules for all Makefiles - do not edit
  480. X
  481. Xemptyrule::
  482. X
  483. Xclean::
  484. X    $(RM_CMD) "#"*
  485. X
  486. XMakefile::
  487. X    -@if [ -f Makefile ]; then set -x; \
  488. X    $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
  489. X    else exit 0; fi
  490. X    $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
  491. X
  492. Xtags::
  493. X    $(TAGS) -w *.[ch]
  494. X    $(TAGS) -xw *.[ch] > TAGS
  495. X
  496. Xsaber:
  497. X    # load $(ALLDEFINES) $(SRCS)
  498. X
  499. Xosaber:
  500. X    # load $(ALLDEFINES) $(OBJS)
  501. X
  502. X# -------------------------------------------------------------------------
  503. X# empty rules for directories that do not have SUBDIRS - do not edit
  504. X
  505. Xinstall::
  506. X    @echo "install in $(CURRENT_DIR) done"
  507. X
  508. Xinstall.man::
  509. X    @echo "install.man in $(CURRENT_DIR) done"
  510. X
  511. XMakefiles::
  512. X
  513. Xincludes::
  514. X
  515. X# -------------------------------------------------------------------------
  516. X# dependencies generated by makedepend
  517. X
  518. END_OF_FILE
  519. if test 9932 -ne `wc -c <'fig2dev/dev/Makefile'`; then
  520.     echo shar: \"'fig2dev/dev/Makefile'\" unpacked with wrong size!
  521. fi
  522. # end of 'fig2dev/dev/Makefile'
  523. fi
  524. if test -f 'fig2dev/dev/genpstex.c' -a "${1}" != "-c" ; then 
  525.   echo shar: Will not clobber existing file \"'fig2dev/dev/genpstex.c'\"
  526. else
  527. echo shar: Extracting \"'fig2dev/dev/genpstex.c'\" \(3764 characters\)
  528. sed "s/^X//" >'fig2dev/dev/genpstex.c' <<'END_OF_FILE'
  529. X/*
  530. X * TransFig: Facility for Translating Fig code
  531. X * Copyright (c) 1985 Supoj Sutantavibul
  532. X * Copyright (c) 1991 Micah Beck
  533. X *
  534. X * Permission to use, copy, modify, distribute, and sell this software and its
  535. X * documentation for any purpose is hereby granted without fee, provided that
  536. X * the above copyright notice appear in all copies and that both that
  537. X * copyright notice and this permission notice appear in supporting
  538. X * documentation. The authors make no representations about the suitability 
  539. X * of this software for any purpose.  It is provided "as is" without express 
  540. X * or implied warranty.
  541. X *
  542. X * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  543. X * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  544. X * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  545. X * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  546. X * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  547. X * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  548. X * PERFORMANCE OF THIS SOFTWARE.
  549. X *
  550. X */
  551. X
  552. X/* 
  553. X *    genpstex.c : psTeX and psTeX_t drivers for fig2dev
  554. X *
  555. X *    Author: Jose Alberto Fernandez R /Maryland CP 9/90
  556. X *     It uses the LaTeX and PostScript drivers to generate 
  557. X *      LaTeX processed text for a Postscript figure.
  558. X *
  559. X * The pstex_t driver is like a latex driver that only translates 
  560. X * text defined in the defaul font.
  561. X *
  562. X * The pstex driver is like a PostScript driver that translates 
  563. X * everything except for text in the default font.
  564. X *
  565. X * The option '-p file' added to the pstex_t translator specifies
  566. X * the name of the PostScript file to be called in the psfig macro.
  567. X * If not set or its value is null then no PS file will be inserted.
  568. X *
  569. X * Jose Alberto.
  570. X */
  571. X
  572. X#if defined(hpux) || defined(SYSV)
  573. X#include <sys/types.h>
  574. X#endif
  575. X#include <sys/file.h>
  576. X#include <stdio.h>
  577. X#include <math.h>
  578. X#include "object.h"
  579. X#include "fig2dev.h"
  580. X#include "texfonts.h"
  581. X
  582. X#ifndef fabs
  583. Xextern double fabs();
  584. X#endif
  585. X#ifndef sin
  586. Xextern double sin();
  587. X#endif
  588. X#ifndef cos
  589. Xextern double cos();
  590. X#endif
  591. X#ifndef acos
  592. Xextern double acos();
  593. X#endif
  594. X#ifndef atan
  595. Xextern double atan();
  596. X#endif
  597. Xextern double rad2deg;
  598. X
  599. X#ifdef hpux
  600. X#define rint(a) floor((a)+0.5)     /* close enough? */
  601. X#endif
  602. X
  603. X#ifdef gould
  604. X#define rint(a) floor((a)+0.5)     /* close enough? */
  605. X#endif
  606. X
  607. Xextern void genlatex_start (),
  608. X    gendev_null (),
  609. X    genlatex_end (),
  610. X         genps_option (),
  611. X    genps_start (),
  612. X    genps_arc (),
  613. X    genps_ellipse (),
  614. X    genps_line (),
  615. X    genps_spline (),
  616. X    genps_end (),
  617. X        genlatex_option (),
  618. X        genlatex_text (),
  619. X        genps_text ();
  620. X
  621. Xstatic char pstex_file[1000] = "";
  622. X
  623. Xvoid genpstex_t_option(opt, optarg)
  624. Xchar opt, *optarg;
  625. X{
  626. X       if (opt == 'p') strcpy(pstex_file, optarg);
  627. X       else genlatex_option(opt, optarg);
  628. X}
  629. X
  630. X
  631. Xvoid genpstex_t_start(objects)
  632. XF_compound    *objects;
  633. X{
  634. X    /* Put PostScript Image if any*/
  635. X        if (pstex_file[0] != '\0')
  636. X        {
  637. X        fprintf(tfp, "\\begin{picture}(0,0)%%\n");
  638. X        fprintf(tfp, "\\special{psfile=%s}%%\n",pstex_file);
  639. X        fprintf(tfp, "\\end{picture}%%\n");
  640. X    }
  641. X        genlatex_start(objects);
  642. X
  643. X}
  644. X
  645. Xvoid genpstex_t_text(t)
  646. XF_text    *t;
  647. X{
  648. X
  649. X    if (!special_text(t))
  650. X      gendev_null(t);
  651. X    else genlatex_text(t);
  652. X}
  653. X
  654. Xvoid genpstex_text(t)
  655. XF_text    *t;
  656. X{
  657. X
  658. X    if (!special_text(t))
  659. X      genps_text(t);
  660. X    else gendev_null(t);
  661. X}
  662. X
  663. Xvoid genpstex_option(opt, optarg)
  664. Xchar opt, *optarg;
  665. X{
  666. X       if (opt != 'p') genlatex_option(opt, optarg);
  667. X}
  668. X
  669. Xstruct driver dev_pstex_t = {
  670. X         genpstex_t_option,
  671. X    genpstex_t_start,
  672. X    gendev_null,
  673. X    gendev_null,
  674. X    gendev_null,
  675. X    gendev_null,
  676. X    genpstex_t_text,
  677. X    genlatex_end,
  678. X    EXCLUDE_TEXT
  679. X};
  680. X
  681. Xstruct driver dev_pstex = {
  682. X         genpstex_option,
  683. X    genps_start,
  684. X    genps_arc,
  685. X    genps_ellipse,
  686. X    genps_line,
  687. X    genps_spline,
  688. X    genpstex_text,
  689. X    genps_end,
  690. X    INCLUDE_TEXT
  691. X};
  692. X
  693. X
  694. END_OF_FILE
  695. if test 3764 -ne `wc -c <'fig2dev/dev/genpstex.c'`; then
  696.     echo shar: \"'fig2dev/dev/genpstex.c'\" unpacked with wrong size!
  697. fi
  698. # end of 'fig2dev/dev/genpstex.c'
  699. fi
  700. if test -f 'fig2dev/dev/tpicfonts.h' -a "${1}" != "-c" ; then 
  701.   echo shar: Will not clobber existing file \"'fig2dev/dev/tpicfonts.h'\"
  702. else
  703. echo shar: Extracting \"'fig2dev/dev/tpicfonts.h'\" \(4655 characters\)
  704. sed "s/^X//" >'fig2dev/dev/tpicfonts.h' <<'END_OF_FILE'
  705. X/*
  706. X * TransFig: Facility for Translating Fig code
  707. X * Copyright (c) 1985 Supoj Sutantavibul
  708. X * Copyright (c) 1991 Micah Beck
  709. X *
  710. X * Permission to use, copy, modify, distribute, and sell this software and its
  711. X * documentation for any purpose is hereby granted without fee, provided that
  712. X * the above copyright notice appear in all copies and that both that
  713. X * copyright notice and this permission notice appear in supporting
  714. X * documentation. The authors make no representations about the suitability 
  715. X * of this software for any purpose.  It is provided "as is" without express 
  716. X * or implied warranty.
  717. X *
  718. X * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  719. X * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  720. X * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  721. X * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  722. X * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  723. X * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  724. X * PERFORMANCE OF THIS SOFTWARE.
  725. X *
  726. X */
  727. X
  728. Xstatic char        *texfontnames[] = {
  729. X            "rm",            /* default */
  730. X            "rm",            /* roman */
  731. X            "bf",            /* bold */
  732. X            "it",            /* italic */
  733. X            "sf",             /* sans serif */
  734. X            "sl",            /* slanted */
  735. X            "tt",            /* typewriter */
  736. X            /* Virtual fonts from here on */
  737. X            "avant",
  738. X            "avantcsc",
  739. X            "avantd",
  740. X            "avantdi",
  741. X            "avanti",
  742. X            "bookd",
  743. X            "bookdi",
  744. X            "bookl",
  745. X            "booklcsc",
  746. X            "bookli",
  747. X            "chanc",
  748. X            "cour",
  749. X            "courb",
  750. X            "courbi",
  751. X            "couri",
  752. X            "helv",
  753. X            "helvb",
  754. X            "helvbi",
  755. X            "helvc",
  756. X            "helvcb",
  757. X            "helvcbi",
  758. X            "helvci",
  759. X            "helvcsc",
  760. X            "helvi",
  761. X            "pal",
  762. X            "palb",
  763. X            "palbi",
  764. X            "palbu",
  765. X            "palc",
  766. X            "palcsc",
  767. X            "pali",
  768. X            "palsl",
  769. X            "palu",
  770. X            "palx",
  771. X            "times",
  772. X            "timesb",
  773. X            "timesbi",
  774. X            "timesc",
  775. X            "timescsc",
  776. X            "timesi",
  777. X            "timessl",
  778. X            "timesx"
  779. X        };
  780. X
  781. X#define    MAX_TPICFONT    48
  782. X
  783. X/* The selection of font names may be site dependent.
  784. X * Not all fonts are preloaded at all sizes.
  785. X */
  786. X
  787. Xstatic char        *texfontsizes[] = {
  788. X            "ten",            /* default */
  789. X            "fiv", "fiv", "fiv", "fiv",     /* small fonts */
  790. X            "fiv",            /* five point font */
  791. X            "six", "sev", "egt",    /* etc */
  792. X            "nin", "ten", "elv",
  793. X            "twl", "twl", "frtn",    
  794. X            "frtn", "frtn", "svtn",
  795. X            "svtn", "svtn", "twty",
  796. X            "twty", "twty", "twty", "twty", "twfv"
  797. X            };
  798. X
  799. Xstatic int        TeXfontsizes[] = {
  800. X            10,        /* default */
  801. X            5, 5, 5, 5,     /* small fonts */
  802. X            5,            /* five point font */
  803. X            6, 7, 8,    /* etc */
  804. X            9, 10, 11,
  805. X            12, 12, 14,    
  806. X            14, 14, 17,
  807. X            17, 17, 20,
  808. X            20, 20, 20, 20, 25
  809. X            };
  810. X
  811. X
  812. X#define MAXFONTSIZE 25
  813. X
  814. X#define TEXFONT(F)    (texfontnames[((F) <= MAX_TPICFONT) ? (F) : MAX_TPICFONT])
  815. X#define TEXFONTSIZE(S)    (texfontsizes[((S) <= MAXFONTSIZE) ? (S) : MAXFONTSIZE])
  816. X#define TEXFONTMAG(T)    TEXFONTSIZE((int)(T->size*(rigid_text(T) ? 1.0 : mag)))
  817. X#define TEXFONTSIZEINT(S)    (TeXfontsizes[((S) <= MAXFONTSIZE) ? (S) : MAXFONTSIZE])
  818. X#define TEXFONTMAGINT(T)    TEXFONTSIZEINT((int)(T->size*(rigid_text(T) ? 1.0 : mag)))
  819. X
  820. Xstatic char    *texture_patterns[] = {
  821. X    "8 0 8 0 4 1 3 e 0 8 0 8 1 4 e 3",    /* scales */
  822. X    "f f 8 0 8 0 8 0 f f 0 8 0 8 0 8",    /* bricks */
  823. X    "8 1 4 2 2 4 1 8 8 1 4 2 2 4 1 8",    /* waves */
  824. X    "8 0 4 0 2 0 1 0 0 8 0 4 0 2 0 1",    /* light backslash alternating */
  825. X    "e 0 7 0 3 8 1 c 0 e 0 7 8 3 c 1",    /* heavy backslash alternating */
  826. X    "7 7 b b d d e e 7 7 b b d d e e",    /* heavy backslash */
  827. X    "8 8 4 4 2 2 1 1 8 8 4 4 2 2 1 1",    /* light backslash */
  828. X    "9 9 c c 6 6 3 3 9 9 c c 6 6 3 3",    /* medium backslash */
  829. X    "2 0 4 0 8 0 0 0 0 8 0 4 0 2 0 0",    /* light hash */
  830. X    "f f 0 0 f f 0 0 f f 0 0 f f 0 0",    /* horizontal lines */
  831. X    "f f 0 0 0 0 0 0 f f 0 0 0 0 0 0",    /* spaced horizontal lines */
  832. X    "c c 0 0 0 0 0 0 3 3 0 0 0 0 0 0",    /* spaced horizontal dashed lines */
  833. X    "f 0 f 0 f 0 f 0 0 f 0 f 0 f 0 f",    /* chessboard */
  834. X    "f f 8 8 8 8 8 8 f f 8 8 8 8 8 8",    /* light meshed lines */
  835. X    "a a 4 4 a a 1 1 a a 4 4 a a 1 1",    /* hashed dotted lines */
  836. X    "0 1 0 2 0 4 0 8 1 0 2 0 4 0 8 0",    /* spaced light frontslash */
  837. X    "8 3 0 7 0 e 1 c 3 8 7 0 e 0 c 1",    /* spaced heavy frontslash */
  838. X    "e e d d b b 7 7 e e d d b b 7 7",    /* heavy frontslash */
  839. X    "1 1 2 2 4 4 8 8 1 1 2 2 4 4 8 8",    /* light frontslash */
  840. X    "3 3 6 6 c c 9 9 3 3 6 6 c c 9 9",    /* medium frontslash */
  841. X    "4 0 a 0 0 0 0 0 0 4 0 a 0 0 0 0",    /* wallpaper - birds */
  842. X    "a a a a a a a a a a a a a a a a",    /* vertical lines */
  843. X    "8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8",    /* spaced vertical lines */
  844. X    "0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 0",    /* vertical dashed lines */
  845. X    "0 0 0 8 1 4 2 a 5 5 2 a 1 4 0 8",    /* hashed diamonds */
  846. X    "f f 8 0 8 0 8 0 8 0 8 0 8 0 8 0",    /* spaced meshed lines */
  847. X    "8 2 4 4 2 8 1 0 2 8 4 4 8 2 0 1"    /* hashed dotted lines */
  848. X};
  849. X
  850. X#define    MAXPATTERNS    27
  851. END_OF_FILE
  852. if test 4655 -ne `wc -c <'fig2dev/dev/tpicfonts.h'`; then
  853.     echo shar: \"'fig2dev/dev/tpicfonts.h'\" unpacked with wrong size!
  854. fi
  855. # end of 'fig2dev/dev/tpicfonts.h'
  856. fi
  857. if test -f 'fig2dev/fig2dev.c' -a "${1}" != "-c" ; then 
  858.   echo shar: Will not clobber existing file \"'fig2dev/fig2dev.c'\"
  859. else
  860. echo shar: Extracting \"'fig2dev/fig2dev.c'\" \(7009 characters\)
  861. sed "s/^X//" >'fig2dev/fig2dev.c' <<'END_OF_FILE'
  862. X/*
  863. X * TransFig: Facility for Translating Fig code
  864. X * Copyright (c) 1985 Supoj Sutantavibul
  865. X * Copyright (c) 1991 Micah Beck
  866. X *
  867. X * Permission to use, copy, modify, distribute, and sell this software and its
  868. X * documentation for any purpose is hereby granted without fee, provided that
  869. X * the above copyright notice appear in all copies and that both that
  870. X * copyright notice and this permission notice appear in supporting
  871. X * documentation. The authors make no representations about the suitability 
  872. X * of this software for any purpose.  It is provided "as is" without express 
  873. X * or implied warranty.
  874. X *
  875. X * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  876. X * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  877. X * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  878. X * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  879. X * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  880. X * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  881. X * PERFORMANCE OF THIS SOFTWARE.
  882. X *
  883. X */
  884. X
  885. X/* 
  886. X *    Fig2dev : General Fig code translation program
  887. X *
  888. X*/
  889. X#if defined(hpux) || defined(SYSV)
  890. X#include <sys/types.h>
  891. X#endif
  892. X#include <sys/file.h>
  893. X#include <stdio.h>
  894. X#include <ctype.h>
  895. X#include "patchlevel.h"
  896. X#include "object.h"
  897. X#include "fig2dev.h"
  898. X#include "drivers.h"
  899. X
  900. Xextern int getopt();
  901. Xextern char *optarg;
  902. Xextern int optind;
  903. X
  904. X#define DEFAULT_FONT_SIZE 11
  905. X
  906. Xstruct driver *dev = NULL;
  907. X
  908. Xchar        Usage[] = "Usage: %s [-L language] [-f font] [-s size] [-m scale] [input [output]]\n";
  909. Xchar        Err_badarg[] = "Argument -%c unkown to %s driver.";
  910. Xchar        Err_incomp[] = "Incomplete %s object at line %d.";
  911. Xchar        Err_mem[] = "Running out of memory.";
  912. X
  913. Xchar        *prog;
  914. Xchar        *from = NULL, *to = NULL;
  915. Xint        font_size = 0;
  916. Xdouble        mag = 1.0;
  917. XFILE        *tfp = NULL;
  918. Xint        llx = 0, lly = 0, urx = 0, ury = 0;
  919. X
  920. Xstruct obj_rec {
  921. X    void (*gendev)();
  922. X    char *obj;
  923. X    int depth;
  924. X};
  925. X
  926. Xput_msg(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
  927. Xchar   *format, *arg1, *arg2, *arg3, *arg4, *arg5, *arg6, *arg7, *arg8;
  928. X{
  929. X    fprintf(stderr, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
  930. X    fprintf(stderr, "\n");
  931. X    }
  932. X
  933. Xget_args(argc, argv)
  934. Xint     argc;
  935. Xchar    *argv[];
  936. X{
  937. X      int    c, i;
  938. X    double    atof();
  939. X
  940. X    prog = *argv;
  941. X/* add :? */
  942. X    while ((c = getopt(argc, argv, "acd:f:l:L:m:Pp:s:S:vVwW?")) != EOF) {
  943. X
  944. X      /* generic option handling */
  945. X      switch (c) {
  946. X
  947. X        case 'V': 
  948. X            fprintf(stderr, "TransFig Version %s Patchlevel %s\n",
  949. X                            VERSION, PATCHLEVEL);
  950. X            exit(0);
  951. X            break;
  952. X
  953. X        case 'L':            /* set output language */
  954. X            for (i=0; *drivers[i].name; i++) 
  955. X            if (!strcmp(optarg, drivers[i].name))
  956. X                dev = drivers[i].dev;
  957. X            if (!dev) {
  958. X            fprintf(stderr,
  959. X                "Unknown graphics language %s\n", optarg);
  960. X            fprintf(stderr,"Known languages are:\n");
  961. X            /* display available languages - 23/01/90 */
  962. X            for (i=0; *drivers[i].name; i++)
  963. X                fprintf(stderr,"%s ",drivers[i].name);
  964. X            fprintf(stderr,"\n");
  965. X            exit(1);
  966. X            }
  967. X            break;
  968. X
  969. X        case 's':            /* set default font size */
  970. X            font_size = atoi(optarg);
  971. X            break;
  972. X
  973. X        case 'm':            /* set magnification */
  974. X            mag = atof(optarg);
  975. X            break;
  976. X
  977. X        case '?':            /* usage         */
  978. X            fprintf(stderr,Usage,prog);
  979. X            exit(1);
  980. X        }
  981. X
  982. X        /* pass options through to driver */
  983. X        if (!dev) {
  984. X        fprintf(stderr, "No graphics language specified.\n");
  985. X        exit(1);
  986. X        }
  987. X        dev->option(c, optarg);
  988. X          }
  989. X          if (!dev) {
  990. X        fprintf(stderr, "No graphics language specified.\n");
  991. X        exit(1);
  992. X          }
  993. X
  994. X    /* default font size is scaled if not specified */
  995. X    if (!font_size) font_size = DEFAULT_FONT_SIZE*mag + 0.5;
  996. X
  997. X    if (optind < argc) from = argv[optind++];  /*  from file  */
  998. X    if (optind < argc) to   = argv[optind];  /*  to file    */
  999. X}
  1000. X
  1001. Xmain(argc, argv)
  1002. Xint     argc;
  1003. Xchar    *argv[];
  1004. X{
  1005. X    F_compound    objects;
  1006. X    int        status;
  1007. X
  1008. X    get_args(argc, argv);
  1009. X
  1010. X    if (from)
  1011. X        status = read_fig(from, &objects);
  1012. X    else    /* read from stdin */
  1013. X        status = readfp_fig(stdin, &objects);
  1014. X
  1015. X    if (status != 0) {
  1016. X        if (from) read_fail_message(from, status);
  1017. X        exit(1);
  1018. X        }
  1019. X
  1020. X    if (to == NULL)
  1021. X        tfp = stdout;
  1022. X    else if ((tfp = fopen(to, "w")) == NULL) {
  1023. X        fprintf(stderr, "Couldn't open %s", to);
  1024. X        fprintf(stderr, Usage, prog);
  1025. X        exit(1);
  1026. X        }
  1027. X
  1028. X    gendev_objects(&objects, dev);
  1029. X    if (tfp != stdout) (void)fclose(tfp);
  1030. X    exit(0);
  1031. X    }
  1032. X
  1033. X/* count primitive objects & create pointer array */
  1034. Xstatic int compound_dump(com, array, count, dev)
  1035. XF_compound *com;
  1036. Xstruct obj_rec *array;
  1037. Xint count;
  1038. Xstruct driver *dev;
  1039. X{
  1040. X      F_arc        *a;
  1041. X    F_compound    *c;
  1042. X    F_ellipse    *e;
  1043. X    F_line        *l;
  1044. X    F_spline    *s;
  1045. X    F_text        *t;
  1046. X
  1047. X    for (c = com->compounds; c != NULL; c = c->next)
  1048. X      count = compound_dump(c, array, count, dev);
  1049. X    for (a = com->arcs; a != NULL; a = a->next) {
  1050. X      if (array) {
  1051. X        array[count].gendev = dev->arc;
  1052. X        array[count].obj = (char *)a;
  1053. X        array[count].depth = a->depth;
  1054. X      }
  1055. X      count += 1;
  1056. X    }
  1057. X    for (e = com->ellipses; e != NULL; e = e->next) {
  1058. X      if (array) {
  1059. X        array[count].gendev = dev->ellipse;
  1060. X        array[count].obj = (char *)e;
  1061. X        array[count].depth = e->depth;
  1062. X      }
  1063. X      count += 1;
  1064. X    }
  1065. X    for (l = com->lines; l != NULL; l = l->next) {
  1066. X      if (array) {
  1067. X        array[count].gendev = dev->line;
  1068. X        array[count].obj = (char *)l;
  1069. X        array[count].depth = l->depth;
  1070. X      }
  1071. X      count += 1;
  1072. X    }
  1073. X    for (s = com->splines; s != NULL; s = s->next) {
  1074. X      if (array) {
  1075. X        array[count].gendev = dev->spline;
  1076. X        array[count].obj = (char *)s;
  1077. X        array[count].depth = s->depth;
  1078. X      }
  1079. X      count += 1;
  1080. X    }
  1081. X    for (t = com->texts; t != NULL; t = t->next) {
  1082. X      if (array) {
  1083. X        array[count].gendev = dev->text;
  1084. X        array[count].obj = (char *)t;
  1085. X        array[count].depth = t->depth;
  1086. X      }
  1087. X      count += 1;
  1088. X    }
  1089. X    return count;
  1090. X}
  1091. X
  1092. Xgendev_objects(objects, dev)
  1093. XF_compound    *objects;
  1094. Xstruct driver *dev;
  1095. X{
  1096. X    F_arc        *a;
  1097. X    F_compound    *c;
  1098. X    F_ellipse    *e;
  1099. X    F_line        *l;
  1100. X    F_spline    *s;
  1101. X    F_text        *t;
  1102. X
  1103. X    int obj_count, rec_comp();
  1104. X    struct obj_rec *rec_array, *r; 
  1105. X
  1106. X    if (0 == (double)objects->nwcorner.x) {
  1107. X        fprintf(stderr, "Resolution is zero!! default to 80 ppi\n");
  1108. X        objects->nwcorner.x = 80;
  1109. X        }
  1110. X    if (objects->nwcorner.y != 1 && objects->nwcorner.y != 2) {
  1111. X        fprintf(stderr, "Wrong coordinate system; cannot continue\n");
  1112. X        return;
  1113. X        }
  1114. X
  1115. X    /* Compute bounding box of objects, supressing texts if indicated */
  1116. X    compound_bound(objects, &llx, &lly, &urx, &ury, dev->text_include);
  1117. X
  1118. X    /* dump object pointers to an array */
  1119. X    obj_count = compound_dump(objects, 0, 0, dev);
  1120. X    if (!obj_count) {
  1121. X        fprintf(stderr, "No object");
  1122. X        return;
  1123. X        }
  1124. X    rec_array = (struct obj_rec *)malloc(obj_count*sizeof(struct obj_rec));
  1125. X    (void)compound_dump(objects, rec_array, 0, dev);
  1126. X
  1127. X    /* sort object array by depth */
  1128. X    qsort(rec_array, obj_count, sizeof(struct obj_rec), rec_comp);
  1129. X
  1130. X    /* generate header */
  1131. X    (*dev->start)(objects);
  1132. X
  1133. X    /* generate objects in sorted order */
  1134. X    for (r = rec_array; r<rec_array+obj_count; r++)
  1135. X        (*(r->gendev))(r->obj);
  1136. X
  1137. X    /* generate trailer */
  1138. X    (*dev->end)();
  1139. X}
  1140. X
  1141. Xint rec_comp(r1, r2)
  1142. Xstruct obj_rec *r1, *r2;
  1143. X{
  1144. X    return (r2->depth - r1->depth);
  1145. X}
  1146. X
  1147. X/* null operation */
  1148. Xvoid gendev_null() {};
  1149. END_OF_FILE
  1150. if test 7009 -ne `wc -c <'fig2dev/fig2dev.c'`; then
  1151.     echo shar: \"'fig2dev/fig2dev.c'\" unpacked with wrong size!
  1152. fi
  1153. # end of 'fig2dev/fig2dev.c'
  1154. fi
  1155. if test -f 'fig2dev/getopt.c' -a "${1}" != "-c" ; then 
  1156.   echo shar: Will not clobber existing file \"'fig2dev/getopt.c'\"
  1157. else
  1158. echo shar: Extracting \"'fig2dev/getopt.c'\" \(4071 characters\)
  1159. sed "s/^X//" >'fig2dev/getopt.c' <<'END_OF_FILE'
  1160. X/*
  1161. X * TransFig: Facility for Translating Fig code
  1162. X * Copyright (c) 1985 Supoj Sutantavibul
  1163. X * Copyright (c) 1991 Micah Beck
  1164. X *
  1165. X * Permission to use, copy, modify, distribute, and sell this software and its
  1166. X * documentation for any purpose is hereby granted without fee, provided that
  1167. X * the above copyright notice appear in all copies and that both that
  1168. X * copyright notice and this permission notice appear in supporting
  1169. X * documentation. The authors make no representations about the suitability 
  1170. X * of this software for any purpose.  It is provided "as is" without express 
  1171. X * or implied warranty.
  1172. X *
  1173. X * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  1174. X * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  1175. X * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  1176. X * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  1177. X * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  1178. X * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1179. X * PERFORMANCE OF THIS SOFTWARE.
  1180. X *
  1181. X */
  1182. X
  1183. X/*
  1184. X    I got this off net.sources from Henry Spencer.
  1185. X    It is a public domain getopt(3) like in System V.
  1186. X    I have made the following modifications:
  1187. X
  1188. X    index(s,c) was added because too many people could
  1189. X    not compile getopt without it.
  1190. X
  1191. X    A test main program was added, ifdeffed by GETOPT.
  1192. X    This main program is a public domain implementation
  1193. X    of the getopt(1) program like in System V.  The getopt
  1194. X    program can be used to standardize shell option handling.
  1195. X        e.g.  cc -DGETOPT getopt.c -o getopt
  1196. X*/
  1197. X#include <stdio.h>
  1198. X
  1199. X#ifndef lint
  1200. Xstatic    char    sccsfid[] = "@(#) getopt.c 5.0 (UTZoo) 1985";
  1201. X#endif
  1202. X
  1203. X#define    ARGCH    (int)':'
  1204. X#define BADCH     (int)'?'
  1205. X#define EMSG     ""
  1206. X#define    ENDARGS  "--"
  1207. X
  1208. X/* this is included because index is not on some UNIX systems */
  1209. Xstatic
  1210. Xchar *
  1211. Xindex (s, c)
  1212. Xregister    char    *s;
  1213. Xregister    int     c;
  1214. X    {
  1215. X    while (*s)
  1216. X        if (c == *s) return (s);
  1217. X        else s++;
  1218. X    return (NULL);
  1219. X    }
  1220. X
  1221. X/*
  1222. X * get option letter from argument vector
  1223. X */
  1224. Xint    opterr = 1,        /* useless, never set or used */
  1225. X    optind = 1,        /* index into parent argv vector */
  1226. X    optopt;            /* character checked for validity */
  1227. Xchar    *optarg;        /* argument associated with option */
  1228. X
  1229. X#define tell(s)    fputs(*nargv,stderr);fputs(s,stderr); \
  1230. X        fputc(optopt,stderr);fputc('\n',stderr);return(BADCH);
  1231. X
  1232. X
  1233. Xgetopt(nargc,nargv,ostr)
  1234. Xint    nargc;
  1235. Xchar    **nargv,
  1236. X    *ostr;
  1237. X{
  1238. X    static char    *place = EMSG;    /* option letter processing */
  1239. X    register char    *oli;        /* option letter list index */
  1240. X    char    *index();
  1241. X
  1242. X    if(!*place) {            /* update scanning pointer */
  1243. X        if(optind >= nargc || *(place = nargv[optind]) != '-' || !*++place) return(EOF);
  1244. X        if (*place == '-') {    /* found "--" */
  1245. X            ++optind;
  1246. X            return(EOF);
  1247. X        }
  1248. X    }                /* option letter okay? */
  1249. X    if ((optopt = (int)*place++) == ARGCH || !(oli = index(ostr,optopt))) {
  1250. X        if(!*place) ++optind;
  1251. X        tell(": illegal option -- ");
  1252. X    }
  1253. X    if (*++oli != ARGCH) {        /* don't need argument */
  1254. X        optarg = NULL;
  1255. X        if (!*place) ++optind;
  1256. X    }
  1257. X    else {                /* need an argument */
  1258. X        if (*place) optarg = place;    /* no white space */
  1259. X        else if (nargc <= ++optind) {    /* no arg */
  1260. X            place = EMSG;
  1261. X            tell(": option requires an argument -- ");
  1262. X        }
  1263. X         else optarg = nargv[optind];    /* white space */
  1264. X        place = EMSG;
  1265. X        ++optind;
  1266. X    }
  1267. X    return(optopt);            /* dump back option letter */
  1268. X}
  1269. X
  1270. X
  1271. X#ifdef GETOPT
  1272. X
  1273. X#ifndef lint
  1274. Xstatic    char    sccspid[] = "@(#) getopt.c 5.1 (WangInst) 6/15/85";
  1275. X#endif
  1276. X
  1277. Xmain (argc, argv) char **argv;
  1278. X    {
  1279. X    char    *optstring = argv[1];
  1280. X    char    *argv0 = argv[0];
  1281. X    extern    int     optind;
  1282. X    extern    char    *optarg;
  1283. X    int     opterr = 0;
  1284. X    int     C;
  1285. X    char    *opi;
  1286. X    if (argc == 1)
  1287. X        {
  1288. X        fprintf (stderr, "Usage: %s optstring args\n", argv0);
  1289. X        exit (1);
  1290. X        }
  1291. X    argv++;
  1292. X    argc--;
  1293. X    argv[0] = argv0;
  1294. X    while ((C = getopt (argc, argv, optstring)) != EOF)
  1295. X        {
  1296. X        if (C == BADCH) opterr++;
  1297. X        printf ("-%c ", C);
  1298. X        opi = index (optstring, C);
  1299. X        if (opi && opi[1] == ARGCH)
  1300. X            if (optarg)
  1301. X                printf ("\"%s\" ", optarg);
  1302. X            else opterr++;
  1303. X        }
  1304. X    printf ("%s", ENDARGS);
  1305. X    while (optind < argc)
  1306. X        printf (" \"%s\"", argv[optind++]);
  1307. X    putchar ('\n');
  1308. X    exit (opterr);
  1309. X    }
  1310. X
  1311. X#endif
  1312. END_OF_FILE
  1313. if test 4071 -ne `wc -c <'fig2dev/getopt.c'`; then
  1314.     echo shar: \"'fig2dev/getopt.c'\" unpacked with wrong size!
  1315. fi
  1316. # end of 'fig2dev/getopt.c'
  1317. fi
  1318. if test -f 'fig2dev/latex_line.c' -a "${1}" != "-c" ; then 
  1319.   echo shar: Will not clobber existing file \"'fig2dev/latex_line.c'\"
  1320. else
  1321. echo shar: Extracting \"'fig2dev/latex_line.c'\" \(5574 characters\)
  1322. sed "s/^X//" >'fig2dev/latex_line.c' <<'END_OF_FILE'
  1323. X/*
  1324. X * TransFig: Facility for Translating Fig code
  1325. X * Copyright (c) 1985 Supoj Sutantavibul
  1326. X * Copyright (c) 1991 Micah Beck
  1327. X *
  1328. X * Permission to use, copy, modify, distribute, and sell this software and its
  1329. X * documentation for any purpose is hereby granted without fee, provided that
  1330. X * the above copyright notice appear in all copies and that both that
  1331. X * copyright notice and this permission notice appear in supporting
  1332. X * documentation. The authors make no representations about the suitability 
  1333. X * of this software for any purpose.  It is provided "as is" without express 
  1334. X * or implied warranty.
  1335. X *
  1336. X * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  1337. X * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  1338. X * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  1339. X * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  1340. X * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  1341. X * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1342. X * PERFORMANCE OF THIS SOFTWARE.
  1343. X *
  1344. X */
  1345. X
  1346. X#include <stdio.h>
  1347. X#include <math.h>
  1348. X/* 
  1349. X *    latex_line.c: 
  1350. X *        Subroutines for drawing and translating lines for the LaTeX
  1351. X *        picture environment.
  1352. X *    Written by Frank Schmuck (schmuck@svax.cs.cornell.edu)
  1353. X *    June 1988
  1354. X *
  1355. X *    The LaTeX picture environment allows generating pictures in standard
  1356. X *    LaTeX.  However, some restrictions apply:  lines and vectors (a vector
  1357. X *    is a line with an arrow at the end) can only be drawn with a finite
  1358. X *    number of slopes.  The available slopes are given by dy/dx where
  1359. X *    dx and dy must be integers <= 6 for lines and <= 4 for vectors.
  1360. X *
  1361. X *    The subroutines in this file are used in fig2latex to approximate
  1362. X *    an arbitrary line or vector by a LaTeX line/vector, and in fig to 
  1363. X *    restrict line drawing to slopes supported by LaTeX.
  1364. X */
  1365. X
  1366. X/*
  1367. X * Constant for converting from radian to degrees
  1368. X */
  1369. Xdouble rad2deg = 57.295779513082320877;
  1370. X
  1371. Xint  pgcd(a,b)
  1372. X    int a, b;
  1373. X/*
  1374. X *  compute greatest common divisor, assuming 0 < a <= b
  1375. X */
  1376. X{
  1377. X    b = b % a;
  1378. X    return (b)? gcd(b, a): a;
  1379. X}
  1380. X
  1381. Xint  gcd(a, b)
  1382. X    int a, b;
  1383. X/*
  1384. X *  compute greatest common divisor
  1385. X */
  1386. X{
  1387. X    if (a < 0) a = -a;
  1388. X    if (b < 0) b = -b;
  1389. X    return (a <= b)? pgcd(a, b): pgcd(b, a);
  1390. X}
  1391. X
  1392. Xint  lcm(a, b)
  1393. X    int a, b;
  1394. X/*
  1395. X *  Compute least common multiple
  1396. X */
  1397. X{
  1398. X    return abs(a*b)/gcd(a,b);
  1399. X}
  1400. X
  1401. X/*
  1402. X *  Tables of line and vector slopes supported by LaTeX
  1403. X */
  1404. Xstruct angle_table {
  1405. X    int    x, y;
  1406. X    double angle;
  1407. X};
  1408. X
  1409. X#define N_LINE 25
  1410. X
  1411. Xstruct angle_table line_angles[N_LINE] =
  1412. X  { {0, 1, 90.0}, 
  1413. X    {1, 0,  0.0},
  1414. X    {1, 1, 45.0}, 
  1415. X    {1, 2, 63.434948822922010648},
  1416. X    {1, 3, 71.565051177077989351},
  1417. X    {1, 4, 75.963756532073521417},
  1418. X    {1, 5, 78.690067525979786913},
  1419. X    {1, 6, 80.537677791974382609},
  1420. X    {2, 1, 26.565051177077989351},
  1421. X    {2, 3, 56.309932474020213086},
  1422. X    {2, 5, 68.198590513648188229}, 
  1423. X    {3, 1, 18.434948822922010648},
  1424. X    {3, 2, 33.690067525979786913},
  1425. X    {3, 4, 53.130102354155978703},
  1426. X    {3, 5, 59.036243467926478582},
  1427. X    {4, 1, 14.036243467926478588},
  1428. X    {4, 3, 36.869897645844021297},
  1429. X    {4, 5, 51.340191745909909396},
  1430. X    {5, 1, 11.309932474020213086},
  1431. X    {5, 2, 21.801409486351811770},
  1432. X    {5, 3, 30.963756532073521417},
  1433. X    {5, 4, 38.659808254090090604},
  1434. X    {5, 6, 50.194428907734805993},
  1435. X    {6, 1, 9.4623222080256173906},
  1436. X    {6, 5, 39.805571092265194006}
  1437. X  };
  1438. X
  1439. X#define N_ARROW 13
  1440. X
  1441. Xstruct angle_table arrow_angles[N_ARROW] =
  1442. X  { {0, 1, 90.0}, 
  1443. X    {1, 0,  0.0},
  1444. X    {1, 1, 45.0}, 
  1445. X    {1, 2, 63.434948822922010648},
  1446. X    {1, 3, 71.565051177077989351},
  1447. X    {1, 4, 75.963756532073521417},
  1448. X    {2, 1, 26.565051177077989351},
  1449. X    {2, 3, 56.309932474020213086},
  1450. X    {3, 1, 18.434948822922010648},
  1451. X    {3, 2, 33.690067525979786913},
  1452. X    {3, 4, 53.130102354155978703},
  1453. X    {4, 1, 14.036243467926478588},
  1454. X    {4, 3, 36.869897645844021297},
  1455. X  };
  1456. X
  1457. Xget_slope(dx, dy, sxp, syp, arrow)
  1458. X    int  dx, dy, *sxp, *syp, arrow;
  1459. X/*
  1460. X *  Find the LaTeX line slope that is closest to the one given by dx, dy.
  1461. X *  Result is returned in *sxp, *syp.  If (arrow != 0) the closest LaTeX
  1462. X *  vector slope is selected.
  1463. X */
  1464. X{
  1465. X    double angle;
  1466. X    int    i, s, max;
  1467. X    double d, d1;
  1468. X    struct angle_table *st;
  1469. X
  1470. X    if (dx == 0) {
  1471. X    *sxp = 0;
  1472. X    *syp = (dy < 0)? -1: 1;
  1473. X    return;
  1474. X    }
  1475. X    angle = atan((double)abs(dy) / (double)abs(dx)) * rad2deg;
  1476. X    if (arrow) {
  1477. X    st = arrow_angles;
  1478. X    max = N_ARROW;
  1479. X    } else {
  1480. X    st = line_angles;
  1481. X    max = N_LINE;
  1482. X    }
  1483. X    s = 0;
  1484. X    d = 9.9e9;
  1485. X    for (i = 0; i < max; i++) {
  1486. X    d1 = fabs(angle - st[i].angle);
  1487. X    if (d1 < d) {
  1488. X        s = i;
  1489. X        d = d1;
  1490. X    } 
  1491. X    }
  1492. X    *sxp = st[s].x;
  1493. X    if (dx < 0) *sxp = -*sxp;
  1494. X    *syp = st[s].y;
  1495. X    if (dy < 0) *syp = -*syp;
  1496. X}
  1497. X
  1498. Xlatex_endpoint(x1, y1, x2, y2, xout, yout, arrow, magnet)
  1499. X    int  x1, y1, x2, y2;
  1500. X    int  *xout, *yout;
  1501. X    int  arrow, magnet;
  1502. X/*
  1503. X *  Computes a point "close" to (x2,y2) that is reachable from (x1,y1)
  1504. X *  by a LaTeX line (LaTeX vector if arrow != 0).  The result is returned
  1505. X *  in *xout, *yout.  If (magnet > 1) the point returned is selected such that
  1506. X *  (*xout - x1) and (*yout - y1) are both multiples of magnet.
  1507. X */
  1508. X{
  1509. X    int    dx, dy, sx, sy, ds, dsx, dsy;
  1510. X
  1511. X    dx = x2-x1;
  1512. X    dy = y2-y1;
  1513. X    get_slope(dx, dy, &sx, &sy, arrow);
  1514. X    if (abs(sx) >= abs(sy)) {
  1515. X    ds = lcm(sx, magnet*gcd(sx,magnet));
  1516. X    dsx = (2*abs(dx)/ds + 1)/2;
  1517. X    dsx = (dx >= 0)? dsx*ds: -dsx*ds;
  1518. X    *xout = x1 + dsx;
  1519. X    *yout = y1 + dsx*sy/sx;
  1520. X    } else {
  1521. X    ds = lcm(sy, magnet*gcd(sy,magnet));
  1522. X    dsy = (2*abs(dy)/ds + 1)/2;
  1523. X    dsy = (dy >= 0)? dsy*ds: -dsy*ds;
  1524. X    *yout = y1 + dsy;
  1525. X    *xout = x1 + dsy*sx/sy;
  1526. X    }
  1527. X}
  1528. END_OF_FILE
  1529. if test 5574 -ne `wc -c <'fig2dev/latex_line.c'`; then
  1530.     echo shar: \"'fig2dev/latex_line.c'\" unpacked with wrong size!
  1531. fi
  1532. # end of 'fig2dev/latex_line.c'
  1533. fi
  1534. if test -f 'fig2dev/object.h' -a "${1}" != "-c" ; then 
  1535.   echo shar: Will not clobber existing file \"'fig2dev/object.h'\"
  1536. else
  1537. echo shar: Extracting \"'fig2dev/object.h'\" \(6541 characters\)
  1538. sed "s/^X//" >'fig2dev/object.h' <<'END_OF_FILE'
  1539. X/*
  1540. X * TransFig: Facility for Translating Fig code
  1541. X * Copyright (c) 1985 Supoj Sutantavibul
  1542. X * Copyright (c) 1991 Micah Beck
  1543. X *
  1544. X * Permission to use, copy, modify, distribute, and sell this software and its
  1545. X * documentation for any purpose is hereby granted without fee, provided that
  1546. X * the above copyright notice appear in all copies and that both that
  1547. X * copyright notice and this permission notice appear in supporting
  1548. X * documentation. The authors make no representations about the suitability 
  1549. X * of this software for any purpose.  It is provided "as is" without express 
  1550. X * or implied warranty.
  1551. X *
  1552. X * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  1553. X * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  1554. X * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  1555. X * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  1556. X * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  1557. X * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1558. X * PERFORMANCE OF THIS SOFTWARE.
  1559. X *
  1560. X */
  1561. X
  1562. X#define        DEFAULT                (-1)
  1563. X
  1564. Xtypedef        struct f_point {
  1565. X            int            x, y;
  1566. X            struct f_point        *next;
  1567. X            }
  1568. X        F_point;
  1569. X
  1570. Xtypedef        struct f_pos {
  1571. X            int            x, y;
  1572. X            }
  1573. X        F_pos;
  1574. X
  1575. Xtypedef        struct f_arrow {
  1576. X            int            type;
  1577. X            int            style;
  1578. X            double            thickness;
  1579. X            double            wid;
  1580. X            double            ht;
  1581. X            }
  1582. X        F_arrow;
  1583. X
  1584. Xtypedef        struct f_ellipse {
  1585. X            int            type;
  1586. X#define                    T_ELLIPSE_BY_RAD    1
  1587. X#define                    T_ELLIPSE_BY_DIA    2
  1588. X#define                    T_CIRCLE_BY_RAD        3
  1589. X#define                    T_CIRCLE_BY_DIA        4
  1590. X            int            style;
  1591. X            int            thickness;
  1592. X            int            color;
  1593. X#define                  BLACK_COLOR        0
  1594. X#define                    BLUE_COLOR        1
  1595. X#define                    GREEN_COLOR        2
  1596. X#define                    CYAN_COLOR        3
  1597. X#define                    RED_COLOR        4
  1598. X#define                    MAGENTA_COLOR        5
  1599. X#define                    YELLOW_COLOR        6
  1600. X#define                    WHITE_COLOR        7
  1601. X            int            depth;
  1602. X            int            direction;
  1603. X            double            style_val;
  1604. X            double            angle;
  1605. X            int            pen;
  1606. X            int            area_fill;
  1607. X#define                           UNFILLED    0
  1608. X#define                           WHITE_FILL    1
  1609. X#define                           BLACK_FILL    21
  1610. X            struct f_pos        center;
  1611. X            struct f_pos        radiuses;
  1612. X            struct f_pos        start;
  1613. X            struct f_pos        end;
  1614. X            struct f_ellipse    *next;
  1615. X            }
  1616. X        F_ellipse;
  1617. X
  1618. Xtypedef        struct f_arc {
  1619. X            int            type;
  1620. X#define                    T_3_POINTS_ARC        1
  1621. X            int            style;
  1622. X            int            thickness;
  1623. X            int            color;
  1624. X            int            depth;
  1625. X            int            pen;
  1626. X            int            area_fill;
  1627. X            double            style_val;
  1628. X            int            direction;
  1629. X            struct f_arrow        *for_arrow;
  1630. X            struct f_arrow        *back_arrow;
  1631. X            struct {double x, y;}    center;
  1632. X            struct f_pos        point[3];
  1633. X            struct f_arc        *next;
  1634. X            }
  1635. X        F_arc;
  1636. X
  1637. Xtypedef        struct f_line {
  1638. X            int            type;
  1639. X#define                    T_POLYLINE    1
  1640. X#define                    T_BOX        2
  1641. X#define                    T_POLYGON    3
  1642. X#define                                    T_ARC_BOX       4
  1643. X#define                                    T_EPS_BOX       5 
  1644. X
  1645. X            int            style;
  1646. X            int            thickness;
  1647. X            int            color;
  1648. X            int            depth;
  1649. X            double            style_val;
  1650. X            int            pen;
  1651. X             int            area_fill;
  1652. X            int            radius;    /* for T_ARC_BOX */
  1653. X            struct f_arrow        *for_arrow;
  1654. X            struct f_arrow        *back_arrow;
  1655. X            struct f_point        *points;
  1656. X                struct f_eps           *eps;
  1657. X            struct f_line        *next;
  1658. X            }
  1659. X        F_line;
  1660. X
  1661. Xtypedef struct f_eps {
  1662. X    char            file[256];
  1663. X    int             flipped;
  1664. X    unsigned char  *bitmap;
  1665. X    float        hw_ratio;
  1666. X    struct f_pos    bit_size;
  1667. X    int             pix_rotation, pix_width, pix_height, pix_flipped;
  1668. X}
  1669. X        F_eps;
  1670. X
  1671. Xextern char EMPTY_EPS[];
  1672. X
  1673. Xtypedef        struct f_text {
  1674. X            int            type;
  1675. X#define                    T_LEFT_JUSTIFIED    0
  1676. X#define                    T_CENTER_JUSTIFIED    1
  1677. X#define                    T_RIGHT_JUSTIFIED    2
  1678. X            int            font;
  1679. X#define                    DEFAULT_FONT        0
  1680. X#define                    ROMAN_FONT        1
  1681. X#define                    BOLD_FONT        2
  1682. X#define                    ITALIC_FONT        3
  1683. X#define                    MODERN_FONT        4
  1684. X#define                    TYPEWRITER_FONT        5
  1685. X#define                    MAX_FONT        5
  1686. X            double            size;    /* point size */
  1687. X            int            color;
  1688. X            int            depth;
  1689. X            double            angle;    /* in radian */
  1690. X            int            flags;
  1691. X#define                    RIGID_TEXT    1    
  1692. X#define                    SPECIAL_TEXT    2
  1693. X#define                    PSFONT_TEXT    4
  1694. X            double            height;    /* pixels */
  1695. X            double            length;    /* pixels */
  1696. X            int            base_x;
  1697. X            int            base_y;
  1698. X            int            pen;
  1699. X            char            *cstring;
  1700. X            struct f_text        *next;
  1701. X            }
  1702. X        F_text;
  1703. X
  1704. X#define MAX_PSFONT    35
  1705. X#define MAXFONT(T) (psfont_text(T) ? MAX_PSFONT : MAX_FONT)
  1706. X
  1707. X#define        rigid_text(t) \
  1708. X            (t->flags == DEFAULT \
  1709. X                || (t->flags & RIGID_TEXT))
  1710. X
  1711. X#define        special_text(t) \
  1712. X            ((t->flags != DEFAULT \
  1713. X                && (t->flags & SPECIAL_TEXT)))
  1714. X
  1715. X#define        psfont_text(t) \
  1716. X            (t->flags != DEFAULT \
  1717. X                && (t->flags & PSFONT_TEXT))
  1718. X
  1719. Xtypedef        struct f_control {
  1720. X            double            lx, ly, rx, ry;
  1721. X            struct f_control    *next;
  1722. X            }
  1723. X        F_control;
  1724. X
  1725. X#define        int_spline(s)        (s->type & 0x2)
  1726. X#define        normal_spline(s)    (!(s->type & 0x2))
  1727. X#define        closed_spline(s)    (s->type & 0x1)
  1728. X#define        open_spline(s)        (!(s->type & 0x1))
  1729. X
  1730. Xtypedef        struct f_spline {
  1731. X            int            type;
  1732. X#define                    T_OPEN_NORMAL        0
  1733. X#define                    T_CLOSED_NORMAL        1
  1734. X#define                    T_OPEN_INTERPOLATED    2
  1735. X#define                    T_CLOSED_INTERPOLATED    3
  1736. X            int            style;
  1737. X            int            thickness;
  1738. X            int            color;
  1739. X            int            depth;
  1740. X            double            style_val;
  1741. X            int            pen;
  1742. X            int            area_fill;
  1743. X            struct f_arrow        *for_arrow;
  1744. X            struct f_arrow        *back_arrow;
  1745. X            /*
  1746. X            For T_OPEN_NORMAL and T_CLOSED_NORMAL points
  1747. X            are control points while they are knots for
  1748. X            T_OPEN_INTERPOLATED and T_CLOSED_INTERPOLTED
  1749. X            whose control points are stored in controls.
  1750. X            */
  1751. X            struct f_point        *points;
  1752. X            struct f_control    *controls;
  1753. X            struct f_spline        *next;
  1754. X            }
  1755. X        F_spline;
  1756. X
  1757. Xtypedef        struct f_compound {
  1758. X            struct f_pos        nwcorner;
  1759. X            struct f_pos        secorner;
  1760. X            struct f_line        *lines;
  1761. X            struct f_ellipse    *ellipses;
  1762. X            struct f_spline        *splines;
  1763. X            struct f_text        *texts;
  1764. X            struct f_arc        *arcs;
  1765. X            struct f_compound    *compounds;
  1766. X            struct f_compound    *next;
  1767. X            }
  1768. X        F_compound;
  1769. X
  1770. X#define        ARROW_SIZE        sizeof(struct f_arrow)
  1771. X#define        POINT_SIZE        sizeof(struct f_point)
  1772. X#define        CONTROL_SIZE        sizeof(struct f_control)
  1773. X#define        ELLOBJ_SIZE        sizeof(struct f_ellipse)
  1774. X#define        ARCOBJ_SIZE        sizeof(struct f_arc)
  1775. X#define        LINOBJ_SIZE        sizeof(struct f_line)
  1776. X#define        EPS_SIZE        sizeof(struct f_eps)
  1777. X#define        TEXOBJ_SIZE        sizeof(struct f_text)
  1778. X#define        SPLOBJ_SIZE        sizeof(struct f_spline)
  1779. X#define        COMOBJ_SIZE        sizeof(struct f_compound)
  1780. X
  1781. X/**********************  object codes  **********************/
  1782. X
  1783. X#define        O_ELLIPSE        1
  1784. X#define        O_POLYLINE        2
  1785. X#define        O_SPLINE        3
  1786. X#define        O_TEXT            4
  1787. X#define        O_ARC            5
  1788. X#define        O_COMPOUND        6
  1789. X#define        O_END_COMPOUND        (-O_COMPOUND)
  1790. X#define        O_ALL_OBJECT        99
  1791. X
  1792. X/************  object styles (except for f_text)  ************/
  1793. X
  1794. X#define        SOLID_LINE        0
  1795. X#define        DASH_LINE        1
  1796. X#define        DOTTED_LINE        2
  1797. X
  1798. X#define        CLOSED_PATH        0
  1799. X#define        OPEN_PATH        1
  1800. END_OF_FILE
  1801. if test 6541 -ne `wc -c <'fig2dev/object.h'`; then
  1802.     echo shar: \"'fig2dev/object.h'\" unpacked with wrong size!
  1803. fi
  1804. # end of 'fig2dev/object.h'
  1805. fi
  1806. if test -f 'fig2dev/psfonts.c' -a "${1}" != "-c" ; then 
  1807.   echo shar: Will not clobber existing file \"'fig2dev/psfonts.c'\"
  1808. else
  1809. echo shar: Extracting \"'fig2dev/psfonts.c'\" \(6461 characters\)
  1810. sed "s/^X//" >'fig2dev/psfonts.c' <<'END_OF_FILE'
  1811. X/*
  1812. X * TransFig: Facility for Translating Fig code
  1813. X * Copyright (c) 1985 Supoj Sutantavibul
  1814. X * Copyright (c) 1991 Micah Beck
  1815. X *
  1816. X * Permission to use, copy, modify, distribute, and sell this software and its
  1817. X * documentation for any purpose is hereby granted without fee, provided that
  1818. X * the above copyright notice appear in all copies and that both that
  1819. X * copyright notice and this permission notice appear in supporting
  1820. X * documentation. The authors make no representations about the suitability 
  1821. X * of this software for any purpose.  It is provided "as is" without express 
  1822. X * or implied warranty.
  1823. X *
  1824. X * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  1825. X * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  1826. X * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  1827. X * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  1828. X * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  1829. X * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1830. X * PERFORMANCE OF THIS SOFTWARE.
  1831. X *
  1832. X */
  1833. X
  1834. X/* 
  1835. X *    psfont.c : PostScript font mappings
  1836. X *
  1837. X*/
  1838. X#include <stdio.h>
  1839. X#include "object.h"
  1840. X
  1841. Xchar            *PSfontnames[] = {
  1842. X            "Times-Roman", "Times-Roman",    /* default */
  1843. X            "Times-Italic",            /* italic */
  1844. X            "Times-Bold",            /* bold */
  1845. X            "Times-BoldItalic",
  1846. X            "AvantGarde-Book",
  1847. X            "AvantGarde-BookOblique",
  1848. X            "AvantGarde-Demi",
  1849. X            "AvantGarde-DemiOblique",
  1850. X            "Bookman-Light",
  1851. X            "Bookman-LightItalic",
  1852. X            "Bookman-Demi",
  1853. X            "Bookman-DemiItalic",
  1854. X            "Courier",    
  1855. X            "Courier-Oblique",
  1856. X            "Courier-Bold",
  1857. X            "Courier-BoldOblique",
  1858. X            "Helvetica",
  1859. X            "Helvetica-Oblique",
  1860. X            "Helvetica-Bold",
  1861. X            "Helvetica-BoldOblique",
  1862. X            "Helvetica-Narrow",
  1863. X            "Helvetica-Narrow-Oblique",
  1864. X            "Helvetica-Narrow-Bold",
  1865. X            "Helvetica-Narrow-BoldOblique",
  1866. X            "NewCenturySchlbk-Roman",
  1867. X            "NewCenturySchlbk-Italic",
  1868. X            "NewCenturySchlbk-Bold",
  1869. X            "NewCenturySchlbk-BoldItalic",
  1870. X            "Palatino-Roman",
  1871. X            "Palatino-Italic",
  1872. X            "Palatino-Bold",
  1873. X            "Palatino-BoldItalic",
  1874. X            "Symbol",
  1875. X            "ZapfChancery-MediumItalic",
  1876. X            "ZapfDingbats"
  1877. X        };
  1878. X
  1879. Xstatic int    PSfontmap[] = {
  1880. X        ROMAN_FONT, ROMAN_FONT,        /* Times-Roman */
  1881. X        ITALIC_FONT,            /* Times-Italic */
  1882. X        BOLD_FONT,            /* Times-Bold */
  1883. X        BOLD_FONT,            /* Times-BoldItalic */
  1884. X        ROMAN_FONT,            /* AvantGarde */
  1885. X        ROMAN_FONT,            /* AvantGarde-BookOblique */
  1886. X        ROMAN_FONT,            /* AvantGarde-Demi */
  1887. X        ROMAN_FONT,            /* AvantGarde-DemiOblique */
  1888. X        ROMAN_FONT,            /* Bookman-Light */
  1889. X        ITALIC_FONT,            /* Bookman-LightItalic */
  1890. X        ROMAN_FONT,            /* Bookman-Demi */
  1891. X        ITALIC_FONT,            /* Bookman-DemiItalic */
  1892. X        TYPEWRITER_FONT,        /* Courier */
  1893. X        TYPEWRITER_FONT,        /* Courier-Oblique */
  1894. X        BOLD_FONT,            /* Courier-Bold */
  1895. X        BOLD_FONT,            /* Courier-BoldItalic */
  1896. X        MODERN_FONT,            /* Helvetica */
  1897. X        MODERN_FONT,            /* Helvetica-Oblique */
  1898. X        BOLD_FONT,            /* Helvetica-Bold */
  1899. X        BOLD_FONT,            /* Helvetica-BoldOblique */
  1900. X        MODERN_FONT,            /* Helvetica-Narrow */
  1901. X        MODERN_FONT,            /* Helvetica-Narrow-Oblique */
  1902. X        BOLD_FONT,            /* Helvetica-Narrow-Bold */
  1903. X        BOLD_FONT,        /* Helvetica-Narrow-BoldOblique */
  1904. X        ROMAN_FONT,            /* NewCenturySchlbk-Roman */
  1905. X        ITALIC_FONT,            /* NewCenturySchlbk-Italic */
  1906. X        BOLD_FONT,            /* NewCenturySchlbk-Bold */
  1907. X        BOLD_FONT,        /* NewCenturySchlbk-BoldItalic */
  1908. X        ROMAN_FONT,            /* Palatino-Roman */
  1909. X        ITALIC_FONT,            /* Palatino-Italic */
  1910. X        BOLD_FONT,            /* Palatino-Bold */
  1911. X        BOLD_FONT,            /* Palatino-BoldItalic */
  1912. X        ROMAN_FONT,            /* Symbol */
  1913. X        ROMAN_FONT,            /* ZapfChancery-MediumItalic */
  1914. X        ROMAN_FONT            /* ZapfDingbats */
  1915. X        };
  1916. X
  1917. X#define    NO    2
  1918. X#define    FALSE    0
  1919. X#define    TRUE    1
  1920. X
  1921. Xstatic int    PSmapwarn[] = {
  1922. X        FALSE, FALSE,            /* Times-Roman */
  1923. X        FALSE,                /* Times-Italic */
  1924. X        FALSE,                /* Times-Bold */
  1925. X        FALSE,                /* Times-BoldItalic */
  1926. X        TRUE,                /* AvantGarde */
  1927. X        TRUE,                /* AvantGarde-BookOblique */
  1928. X        TRUE,                /* AvantGarde-Demi */
  1929. X        TRUE,                /* AvantGarde-DemiOblique */
  1930. X        TRUE,                /* Bookman-Light */
  1931. X        TRUE,                /* Bookman-LightItalic */
  1932. X        TRUE,                /* Bookman-Demi */
  1933. X        TRUE,                /* Bookman-DemiItalic */
  1934. X        FALSE,                /* Courier */
  1935. X        TRUE,                /* Courier-Oblique */
  1936. X        TRUE,                /* Courier-Bold */
  1937. X        TRUE,                /* Courier-BoldItalic */
  1938. X        FALSE,                /* Helvetica */
  1939. X        TRUE,                /* Helvetica-Oblique */
  1940. X        TRUE,                /* Helvetica-Bold */
  1941. X        TRUE,                /* Helvetica-BoldOblique */
  1942. X        TRUE,                /* Helvetica-Narrow */
  1943. X        TRUE,                /* Helvetica-Narrow-Oblique */
  1944. X        TRUE,                /* Helvetica-Narrow-Bold */
  1945. X        TRUE,            /* Helvetica-Narrow-BoldOblique */
  1946. X        TRUE,                /* NewCenturySchlbk-Roman */
  1947. X        TRUE,                /* NewCenturySchlbk-Italic */
  1948. X        TRUE,                /* NewCenturySchlbk-Bold */
  1949. X        TRUE,            /* NewCenturySchlbk-BoldItalic */
  1950. X        TRUE,                /* Palatino-Roman */
  1951. X        TRUE,                /* Palatino-Italic */
  1952. X        TRUE,                /* Palatino-Bold */
  1953. X        TRUE,                /* Palatino-BoldItalic */
  1954. X        TRUE,                /* Symbol */
  1955. X        TRUE,                /* ZapfChancery-MediumItalic */
  1956. X        TRUE                /* ZapfDingbats */
  1957. X        };
  1958. X
  1959. Xint            PSisomap[] = {
  1960. X        FALSE, FALSE,            /* Times-Roman */
  1961. X        FALSE,                /* Times-Italic */
  1962. X        FALSE,                /* Times-Bold */
  1963. X        FALSE,                /* Times-BoldItalic */
  1964. X        FALSE,                /* AvantGarde */
  1965. X        FALSE,                /* AvantGarde-BookOblique */
  1966. X        FALSE,                /* AvantGarde-Demi */
  1967. X        FALSE,                /* AvantGarde-DemiOblique */
  1968. X        FALSE,                /* Bookman-Light */
  1969. X        FALSE,                /* Bookman-LightItalic */
  1970. X        FALSE,                /* Bookman-Demi */
  1971. X        FALSE,                /* Bookman-DemiItalic */
  1972. X        FALSE,                /* Courier */
  1973. X        FALSE,                /* Courier-Oblique */
  1974. X        FALSE,                /* Courier-Bold */
  1975. X        FALSE,                /* Courier-BoldItalic */
  1976. X        FALSE,                /* Helvetica */
  1977. X        FALSE,                /* Helvetica-Oblique */
  1978. X        FALSE,                /* Helvetica-Bold */
  1979. X        FALSE,                /* Helvetica-BoldOblique */
  1980. X        FALSE,                /* Helvetica-Narrow */
  1981. X        FALSE,                /* Helvetica-Narrow-Oblique */
  1982. X        FALSE,                /* Helvetica-Narrow-Bold */
  1983. X        FALSE,            /* Helvetica-Narrow-BoldOblique */
  1984. X        FALSE,                /* NewCenturySchlbk-Roman */
  1985. X        FALSE,                /* NewCenturySchlbk-Italic */
  1986. X        FALSE,                /* NewCenturySchlbk-Bold */
  1987. X        FALSE,            /* NewCenturySchlbk-BoldItalic */
  1988. X        FALSE,                /* Palatino-Roman */
  1989. X        FALSE,                /* Palatino-Italic */
  1990. X        FALSE,                /* Palatino-Bold */
  1991. X        FALSE,                /* Palatino-BoldItalic */
  1992. X        NO,                /* Symbol */
  1993. X        FALSE,                /* ZapfChancery-MediumItalic */
  1994. X        NO                /* ZapfDingbats */
  1995. X        };
  1996. X
  1997. Xstatic char *figfontnames[] = {
  1998. X        "Roman", "Roman",
  1999. X        "Roman", 
  2000. X        "Bold",
  2001. X        "Italic",
  2002. X        "Modern",
  2003. X        "Typewriter"
  2004. X        };
  2005. X
  2006. Xvoid unpsfont(t)
  2007. XF_text    *t;
  2008. X{
  2009. X    if (!psfont_text(t)) return;
  2010. X    if (PSmapwarn[t->font+1])
  2011. X      fprintf(stderr, "PS fonts not supported; substituting %s for %s\n",
  2012. X        figfontnames[PSfontmap[t->font+1]+1], PSfontnames[t->font+1]);
  2013. X    t->font = PSfontmap[t->font+1];
  2014. X}
  2015. X
  2016. END_OF_FILE
  2017. if test 6461 -ne `wc -c <'fig2dev/psfonts.c'`; then
  2018.     echo shar: \"'fig2dev/psfonts.c'\" unpacked with wrong size!
  2019. fi
  2020. # end of 'fig2dev/psfonts.c'
  2021. fi
  2022. if test -f 'transfig/mkfile.c' -a "${1}" != "-c" ; then 
  2023.   echo shar: Will not clobber existing file \"'transfig/mkfile.c'\"
  2024. else
  2025. echo shar: Extracting \"'transfig/mkfile.c'\" \(5471 characters\)
  2026. sed "s/^X//" >'transfig/mkfile.c' <<'END_OF_FILE'
  2027. X/*
  2028. X * TransFig: Facility for Translating Fig code
  2029. X * Copyright (c) 1985 Supoj Sutantavibul
  2030. X * Copyright (c) 1991 Micah Beck
  2031. X *
  2032. X * Permission to use, copy, modify, distribute, and sell this software and its
  2033. X * documentation for any purpose is hereby granted without fee, provided that
  2034. X * the above copyright notice appear in all copies and that both that
  2035. X * copyright notice and this permission notice appear in supporting
  2036. X * documentation. The authors make no representations about the suitability 
  2037. X * of this software for any purpose.  It is provided "as is" without express 
  2038. X * or implied warranty.
  2039. X *
  2040. X * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  2041. X * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  2042. X * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  2043. X * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  2044. X * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  2045. X * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  2046. X * PERFORMANCE OF THIS SOFTWARE.
  2047. X *
  2048. X */
  2049. X
  2050. X#include <stdio.h>
  2051. X#include "transfig.h"
  2052. X
  2053. X/*
  2054. X * create an appropriate makefile
  2055. X */
  2056. Xmakefile(mk, altfonts, arg_list)
  2057. XFILE *mk;
  2058. Xint  altfonts;
  2059. Xargument *arg_list;
  2060. X{
  2061. X  argument *a;
  2062. X  char *i;
  2063. X  enum language to;
  2064. X  int needps, needpic, needfig;
  2065. X  
  2066. X
  2067. X  fprintf(mk, "#\n# TransFig makefile\n#\n");
  2068. X
  2069. X  fprintf(mk, "\nall: ");
  2070. X  for (a = arglist; a; a = a->next)
  2071. X        fprintf(mk, "%s.tex ", a->name);
  2072. X  fprintf(mk, "\n");
  2073. X
  2074. X  for (a = arglist; a; a = a->next)
  2075. X  {
  2076. X    i = a->name;
  2077. X    to = a->tolang;
  2078. X
  2079. X    needps = needpic = needfig = 0;
  2080. X
  2081. X    fprintf(mk, "\n# translation into %s\n\n", lname[(int)to]);
  2082. X
  2083. X    switch (to)
  2084. X    {
  2085. X    case box:
  2086. X        putfig(mk, box, altfonts, NULL, NULL, a->m, NULL, i, "tex");
  2087. X        needfig = 1;
  2088. X        break;
  2089. X
  2090. X    case eepicemu:
  2091. X    case epic:
  2092. X    case eepic:
  2093. X        putfig(mk, to, altfonts, a->f, a->s, a->m, a->o, i, "tex");
  2094. X        needfig = 1;
  2095. X        break;
  2096. X
  2097. X    case latex:
  2098. X        putfig(mk, latex, altfonts, a->f, a->s, a->m, a->o, i, "tex");
  2099. X        needfig = 1;
  2100. X        break;
  2101. X
  2102. X    case pictex:
  2103. X        putfig(mk, pictex, altfonts, a->f, a->s, a->m, a->o, i, "tex");
  2104. X        needfig = 1;
  2105. X        break;
  2106. X
  2107. X    case postscript:
  2108. X                puttarget(mk, i, "tex", "ps");
  2109. X                fprintf(mk, "\tfig2ps2tex %s.ps >%s.tex\n", i, i);
  2110. X        needps = 1;
  2111. X                break;
  2112. X
  2113. X        case psfig:
  2114. X                puttarget(mk, i, "tex", "ps");
  2115. X        fprintf(mk,"\techo '\\strut\\psfig{figure=%s.ps}' >%s.tex\n",
  2116. X                          i, i);
  2117. X        needps = 1;
  2118. X                break;
  2119. X
  2120. X    case pstex:
  2121. X
  2122. X        /*
  2123. X         * The makefile for the pstex need to update two files.
  2124. X         * file.ps with is created using fig2dev -L texps file.fig
  2125. X         * and
  2126. X         * file.tex with fig2dev -L pstex -p file.ps file.fig
  2127. X         * 
  2128. X         */
  2129. X        puttarget(mk, i, "tex", "ps");
  2130. X        fprintf(mk, "\tfig2dev -L pstex_t -p %s.ps ", i);
  2131. X        putoptions(mk, altfonts, a->f, a->s, a->m, a->o, i, "tex");
  2132. X        needps = 1;
  2133. X        break;
  2134. X
  2135. X    case textyl:
  2136. X        putfig(mk, textyl, altfonts, a->f, a->s, a->m, a->o, i, "tex");
  2137. X        needfig = 1;
  2138. X        break;
  2139. X
  2140. X    case tpic:
  2141. X        puttarget(mk, i, "tex", "pic");
  2142. X        /* fprintf(mk, "\ttpic %s.pic\n", i); */
  2143. X        fprintf(mk, "\tpic2tpic %s.pic | tpic > %s.tex\n", i, i);
  2144. X        fprintf(mk, "\techo \'\\strut\\box\\graph\' >>%s.tex\n", i);
  2145. X        needpic = 1;
  2146. X        break;
  2147. X
  2148. X    }
  2149. X
  2150. X    putclean(mk, i, "tex" );
  2151. X
  2152. X    /* conversion to postscript */
  2153. X    if (needps && a->type != ps) {
  2154. X        if ( a->tops ) {
  2155. X            puttarget(mk, i, "ps", iname[(int)a->type]);
  2156. X            fprintf(mk, "\t%s %s.%s > %s.ps\n", a->tops, i, iname[(int)a->type], i);
  2157. X        }
  2158. X        else {
  2159. X                    putfig(mk, (to == pstex ? pstex : postscript), 
  2160. X               altfonts, a->f, a->s, a->m, a->o, i, "ps");
  2161. X                    a->interm = mksuff(i, ".ps");
  2162. X            needfig = 1;
  2163. X        }
  2164. X        putclean(mk, i, "ps" );
  2165. X    }
  2166. X
  2167. X    /* conversion to pic */
  2168. X    if (needpic && a->type != pic) {
  2169. X        if ( a->topic ) {
  2170. X            puttarget(mk, i, "pic", iname[(int)a->type]);
  2171. X            fprintf(mk, "\t%s %s.%s > %s.pic\n", a->topic, i, iname[(int)a->type],i);
  2172. X        }
  2173. X        else {
  2174. X            putfig(mk, tpic, altfonts, a->f, a->s, a->m, a->o, i, "pic");
  2175. X
  2176. X            needfig = 1;
  2177. X        }
  2178. X        putclean(mk, i, "pic" );
  2179. X    }
  2180. X
  2181. X    /* conversion to fig */
  2182. X    if (needfig && a->type != fig) {
  2183. X        if ( a->tofig ) {
  2184. X            puttarget(mk, i, "fig", iname[(int)a->type]);
  2185. X            fprintf(mk, "\t%s %s.%s > %s.fig\n", a->tofig, i, iname[(int)a->type],i);
  2186. X            a->interm = mksuff(i, ".fig");
  2187. X        }
  2188. X        else {
  2189. X            fprintf(stderr, "transfig: warning: don't now how to make %s\n", mksuff(i, ".fig") );
  2190. X        }
  2191. X        putclean(mk, i, "fig" );
  2192. X    }
  2193. X  }
  2194. X}
  2195. X
  2196. Xputtarget(mk, i, suf1, suf2)
  2197. XFILE *mk;
  2198. Xchar *i, *suf1, *suf2;
  2199. X{
  2200. X    fprintf(mk, "%s.%s: %s.%s %s\n", i, suf1, i, suf2, mkfile);
  2201. X}
  2202. X
  2203. Xputfig(mk, to, altfonts, f, s, m, o, i, suf)
  2204. XFILE *mk;
  2205. Xenum language to;
  2206. Xint altfonts;
  2207. Xchar *f, *s, *m, *o, *i, *suf;
  2208. X{
  2209. X  fprintf(mk, "%s%s%s: %s.fig %s\n",
  2210. X           i, (suf ? "." : ""), (suf ? suf : ""), i, mkfile);
  2211. X
  2212. X  if ( to == tpic )
  2213. X      fprintf(mk, "\tfig2dev -L pic ");
  2214. X  else
  2215. X      fprintf(mk, "\tfig2dev -L %s ", lname[(int)to]);
  2216. X
  2217. X  putoptions(mk, altfonts, f, s, m, o, i, suf);
  2218. X}
  2219. X
  2220. Xputoptions(mk, altfonts, f, s, m, o, i, suf)
  2221. XFILE *mk;
  2222. Xint altfonts;
  2223. Xchar *f, *s, *m, *o, *i, *suf;
  2224. X{
  2225. X  if (altfonts==1) fprintf(mk, "-a ");
  2226. X  if (f && *f) fprintf(mk, "-f %s ", f);
  2227. X  if (s && *s) fprintf(mk, "-s %s ", s);
  2228. X  if (m && *m) fprintf(mk, "-m %s ", m);
  2229. X  if (o && *o) fprintf(mk, "%s ", o);
  2230. X
  2231. X  fprintf(mk, "%s.fig > %s%s%s\n", i, i, (suf ? "." : ""), (suf ? suf : ""));
  2232. X}
  2233. X
  2234. Xputclean(mk, i, suf)
  2235. XFILE *mk;
  2236. Xchar *i, *suf;
  2237. X{
  2238. X   fprintf(mk, "clean::\n");
  2239. X   fprintf(mk, "\trm -f %s.%s\n", i, suf);
  2240. X   fprintf(mk, "\n");
  2241. X}
  2242. END_OF_FILE
  2243. if test 5471 -ne `wc -c <'transfig/mkfile.c'`; then
  2244.     echo shar: \"'transfig/mkfile.c'\" unpacked with wrong size!
  2245. fi
  2246. # end of 'transfig/mkfile.c'
  2247. fi
  2248. if test -f 'transfig/transfig.c' -a "${1}" != "-c" ; then 
  2249.   echo shar: Will not clobber existing file \"'transfig/transfig.c'\"
  2250. else
  2251. echo shar: Extracting \"'transfig/transfig.c'\" \(4940 characters\)
  2252. sed "s/^X//" >'transfig/transfig.c' <<'END_OF_FILE'
  2253. X/*
  2254. X * TransFig: Facility for Translating Fig code
  2255. X * Copyright (c) 1985 Supoj Sutantavibul
  2256. X * Copyright (c) 1991 Micah Beck
  2257. X *
  2258. X * Permission to use, copy, modify, distribute, and sell this software and its
  2259. X * documentation for any purpose is hereby granted without fee, provided that
  2260. X * the above copyright notice appear in all copies and that both that
  2261. X * copyright notice and this permission notice appear in supporting
  2262. X * documentation. The authors make no representations about the suitability 
  2263. X * of this software for any purpose.  It is provided "as is" without express 
  2264. X * or implied warranty.
  2265. X *
  2266. X * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  2267. X * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  2268. X * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  2269. X * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  2270. X * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  2271. X * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  2272. X * PERFORMANCE OF THIS SOFTWARE.
  2273. X *
  2274. X */
  2275. X
  2276. X/*
  2277. X * transfig:     figure translation setup program
  2278. X *        creates TeX macro file and makefile
  2279. X *
  2280. X * usage: transfig <option> ... [[<flag> ... ] [<figure>] ... ] ...
  2281. X *
  2282. X * where:    <option> = -L <language> | -M <makefile> | -T <texfile>
  2283. X *        <flag>     = -f <font> | -s <size> | -m <scale>
  2284. X */
  2285. X
  2286. X#include <stdio.h>
  2287. X#include "patchlevel.h"
  2288. X#include "transfig.h"
  2289. X
  2290. X
  2291. Xargument *parse_arg(), *arglist = NULL, *lastarg = NULL;
  2292. Xchar *strip();
  2293. X
  2294. Xchar *mkfile = "Makefile";
  2295. Xchar *txfile = "transfig.tex";
  2296. Xchar *input = "";
  2297. Xint  altfonts = 0;
  2298. X
  2299. Xchar *lname[] = {
  2300. X    "box",
  2301. X    "epic",
  2302. X    "eepic",
  2303. X    "eepicemu",
  2304. X    "latex",
  2305. X    "pictex",
  2306. X    "ps",
  2307. X    "psfig",
  2308. X    "pstex",
  2309. X    "textyl",
  2310. X    "tpic"};
  2311. X
  2312. X/* enum input {apg, fig, pic, ps}; */
  2313. Xchar *iname[] = {
  2314. X    "apg",
  2315. X    "fig",
  2316. X      "pic",
  2317. X    "ps"};
  2318. Xmain(argc, argv)
  2319. Xint argc;
  2320. Xchar *argv[];
  2321. X{
  2322. X  FILE *mk, *tx;
  2323. X  enum language tolang = epic;
  2324. X  argument *a;
  2325. X  char c, *cp; 
  2326. X  char *arg_f = NULL, *arg_s = NULL, *arg_m = NULL, *arg_o = NULL, *argbuf;
  2327. X
  2328. X  for ( optind = 1; optind < argc; optind++ ) {
  2329. X    cp = argv[optind];
  2330. X    if (*cp == '-')
  2331. X    {
  2332. X      if (!cp[1])
  2333. X    {
  2334. X        fprintf(stderr, "transfig: bad option format '-'\n");
  2335. X        exit(1);
  2336. X    }
  2337. X    if (cp[1] == 'V') 
  2338. X    {
  2339. X        fprintf(stderr, "TransFig Version %s Patchlevel %s\n",
  2340. X                            VERSION, PATCHLEVEL);
  2341. X        exit(0);
  2342. X    }
  2343. X    if (cp[2])
  2344. X    {
  2345. X        optarg = &cp[2];
  2346. X    } else
  2347. X    {
  2348. X        if (cp[1] != 'a') {
  2349. X            optind += 1;
  2350. X            if (optind == argc)
  2351. X            {
  2352. X                fprintf(stderr,
  2353. X                    "transfig: no value for '%c' arg\n", cp[1]);
  2354. X                exit(1);
  2355. X            }
  2356. X            optarg = argv[optind];
  2357. X        }
  2358. X    }
  2359. X     switch (cp[1]) {
  2360. X
  2361. X    case 'I':
  2362. X        input = optarg;
  2363. X        break;
  2364. X
  2365. X      case 'L':
  2366. X        tolang = str2lang(optarg);
  2367. X        break;
  2368. X      case 'M':
  2369. X        mkfile = optarg;
  2370. X        break;
  2371. X      case 'T':
  2372. X        txfile = optarg;
  2373. X        break;
  2374. X    case 'a':
  2375. X        altfonts = 1;
  2376. X        break;
  2377. X    case 'f':
  2378. X        arg_f = optarg;
  2379. X        break;
  2380. X    case 's':
  2381. X        arg_s = optarg;    
  2382. X        break;
  2383. X    case 'm':
  2384. X        arg_m = optarg;    
  2385. X        break;
  2386. X
  2387. X    case 'o':
  2388. X        arg_o = optarg;
  2389. X        break;
  2390. X
  2391. X      default:
  2392. X        fprintf(stderr, "transfig: illegal option -- '%c'\n", cp[1]);
  2393. X        exit(1);
  2394. X      }
  2395. X    } else
  2396. X    {
  2397. X    a = parse_arg(tolang, arg_f, arg_s, arg_m, arg_o, argv[optind]);
  2398. X
  2399. X    if ( !lastarg )
  2400. X        arglist = a;
  2401. X    else
  2402. X        lastarg->next = a; 
  2403. X    lastarg = a;
  2404. X    }
  2405. X  }
  2406. X
  2407. X  /* no files specified -> all files */
  2408. X  if (!arglist)
  2409. X  {
  2410. X    argbuf = sysls();
  2411. X    while (cp = strchr(argbuf, '\n'))
  2412. X    {
  2413. X        *cp = '\0';
  2414. X        a = parse_arg(tolang, arg_f, arg_s, arg_m, arg_o, argbuf);
  2415. X        if ( !lastarg )
  2416. X            arglist = a;
  2417. X        else
  2418. X            lastarg->next = a; 
  2419. X        lastarg = a;
  2420. X        argbuf = cp+1;
  2421. X    }
  2422. X  }
  2423. X
  2424. X  sysmv(txfile);
  2425. X  tx = fopen(txfile, "w");
  2426. X  texfile(tx, input, altfonts, arglist);
  2427. X
  2428. X  sysmv(mkfile);
  2429. X  mk = fopen(mkfile, "w");
  2430. X  makefile(mk, altfonts, arglist);
  2431. X  exit(0);
  2432. X}
  2433. X
  2434. Xenum language str2lang(s)
  2435. Xchar *s;
  2436. X{
  2437. X  int i;
  2438. X
  2439. X  /* aliases */
  2440. X  if (!strcmp(s, "pic")) return tpic;
  2441. X  if (!strcmp(s, "postscript")) return postscript;
  2442. X  if (!strcmp(s, "latexps")) return pstex;
  2443. X  if (!strcmp(s, "null")) return box;
  2444. X
  2445. X  /* real names*/
  2446. X  for (i = 0; i <= (int)MAXLANG; i++)
  2447. X    if (!strcmp(lname[i], s)) return (enum language)i;
  2448. X
  2449. X  /* other strings */
  2450. X  fprintf(stderr, "Unknown output language \"%s\"\n", s);
  2451. X  exit(1);
  2452. X}
  2453. X
  2454. Xargument *parse_arg(tolang, arg_f, arg_s, arg_m, arg_o, arg)
  2455. Xenum language tolang;
  2456. Xchar *arg_f, *arg_s, *arg_m, *arg_o, *arg;
  2457. X{
  2458. X  argument *a;
  2459. X
  2460. X  a = (argument *)malloc(sizeof(argument));
  2461. X  a->f = arg_f;
  2462. X  a->s = arg_s;
  2463. X  a->m = arg_m;
  2464. X  a->o = arg_o;
  2465. X  a->next = NULL;
  2466. X  a->tofig = NULL;
  2467. X  a->topic = NULL;
  2468. X  a->tops = NULL;
  2469. X  a->tolang = tolang;
  2470. X  
  2471. X  /* PIC */
  2472. X  if (strip(arg, ".pic"))
  2473. X  {
  2474. X      a->name = mksuff(arg, "");
  2475. X      a->type = pic;
  2476. X    a->tofig = PIC2FIG;
  2477. X    return a;
  2478. X  }
  2479. X
  2480. X  /* PS format */
  2481. X  if (strip(arg, ".ps"))
  2482. X  {
  2483. X      a->name = mksuff(arg, "");
  2484. X      a->type = ps;
  2485. X     return a;
  2486. X  }
  2487. X
  2488. X  /* ApGraph format */
  2489. X  if (strip(arg, ".apg"))
  2490. X  {
  2491. X      a->name = mksuff(arg, "");
  2492. X      a->type = apg;
  2493. X    a->tofig = APG2FIG;
  2494. X     return a;
  2495. X  }
  2496. X
  2497. X  /* Fig format */
  2498. X  strip(arg, ".fig");
  2499. X  a->name = mksuff(arg, "");
  2500. X  a->type = fig;
  2501. X  return a;
  2502. X}
  2503. END_OF_FILE
  2504. if test 4940 -ne `wc -c <'transfig/transfig.c'`; then
  2505.     echo shar: \"'transfig/transfig.c'\" unpacked with wrong size!
  2506. fi
  2507. # end of 'transfig/transfig.c'
  2508. fi
  2509. echo shar: End of archive 2 \(of 7\).
  2510. cp /dev/null ark2isdone
  2511. MISSING=""
  2512. for I in 1 2 3 4 5 6 7 ; do
  2513.     if test ! -f ark${I}isdone ; then
  2514.     MISSING="${MISSING} ${I}"
  2515.     fi
  2516. done
  2517. if test "${MISSING}" = "" ; then
  2518.     echo You have unpacked all 7 archives.
  2519.     rm -f ark[1-9]isdone
  2520. else
  2521.     echo You still need to unpack the following archives:
  2522.     echo "        " ${MISSING}
  2523. fi
  2524. ##  End of shell archive.
  2525. exit 0
  2526.