home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume40 / gnuplot / part23 < prev    next >
Encoding:
Text File  |  1993-10-22  |  80.3 KB  |  2,816 lines

  1. Newsgroups: comp.sources.misc
  2. From: woo@playfair.stanford.edu ("Alexander Woo")
  3. Subject: v40i035:  gnuplot - interactive function plotting utility, Part23/33
  4. Message-ID: <1993Oct22.163838.24661@sparky.sterling.com>
  5. X-Md4-Signature: e0016ff963f6fc90a86f412319297dc8
  6. Sender: kent@sparky.sterling.com (Kent Landfield)
  7. Organization: Sterling Software
  8. Date: Fri, 22 Oct 1993 16:38:38 GMT
  9. Approved: kent@sparky.sterling.com
  10.  
  11. Submitted-by: woo@playfair.stanford.edu ("Alexander Woo")
  12. Posting-number: Volume 40, Issue 35
  13. Archive-name: gnuplot/part23
  14. Environment: UNIX, MS-DOS, VMS
  15. Supersedes: gnuplot3: Volume 24, Issue 23-48
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then feed it
  19. # into a shell via "sh file" or similar.  To overwrite existing files,
  20. # type "sh file -c".
  21. # Contents:  gnuplot/Makefile.in gnuplot/scanner.c
  22. #   gnuplot/term/atari.trm gnuplot/term/corel.trm
  23. #   gnuplot/term/grass.trm gnuplot/term/hp500c.trm
  24. #   gnuplot/win/wprinter.c
  25. # Wrapped by kent@sparky on Wed Oct 20 17:14:56 1993
  26. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  27. echo If this archive is complete, you will see the following message:
  28. echo '          "shar: End of archive 23 (of 33)."'
  29. if test -f 'gnuplot/Makefile.in' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'gnuplot/Makefile.in'\"
  31. else
  32.   echo shar: Extracting \"'gnuplot/Makefile.in'\" \(11003 characters\)
  33.   sed "s/^X//" >'gnuplot/Makefile.in' <<'END_OF_FILE'
  34. X############################################################
  35. X#
  36. X# GNUPLOT 3.4 Makefile (Unix X11 support)
  37. X# Adapted from makefile.unx by djm@gnu.ai.mit.edu
  38. X############################################################
  39. X
  40. X.NOEXPORT:
  41. XSHELL = /bin/sh
  42. X
  43. Xsrcdir = @srcdir@
  44. XVPATH = @srcdir@
  45. X
  46. Xprefix = /usr/local
  47. Xexec_prefix = $(prefix)
  48. Xbindir = $(exec_prefix)/bin
  49. Xdatadir = $(prefix)/lib
  50. Xmandir = $(prefix)/man/man1
  51. X
  52. XINSTALL = @INSTALL@
  53. XINSTALL_PROGRAM = @INSTALL_PROGRAM@
  54. XINSTALL_DATA = @INSTALL_DATA@
  55. X
  56. XCC     = @CC@
  57. XDEFS   = @DEFS@ @X_INCLUDES@
  58. XCFLAGS = -O2
  59. XLDFLAGS = -s
  60. X
  61. X# Additional devices you can add.
  62. X# -DAPOLLO      Apollo Graphics Primitive Resource (window resize after replot)
  63. X# -DGPR         Apollo Graphics Primitive Resource (fixed-size window)
  64. X# -DCGI         SCO CGI
  65. X# -DIRIS4D      IRIS4D series computer
  66. X# -DSUN         Sun Microsystems Workstation
  67. X# -DUNIXPC      unixpc (ATT 3b1 or ATT 7300)
  68. X# -DUNIXPLOT    unixplot
  69. X# -DGNUGRAPH    use GNU graphics version of UNIX plot library
  70. X#               This can only be used in combination with -DUNIXPLOT
  71. XTERMFLAGS = 
  72. X
  73. X#  -lplot if you have -DUNIXPLOT in TERMFLAGS
  74. X#  -lsuntool -lsunwindow -lpixrect  if you have -DSUN in TERMFLAGS
  75. X#  -lgl_s if -DIRIS4D in TERMFLAGS
  76. X#  -lccgi if -DCGI in TERMFLAGS
  77. XTERMLIBS = 
  78. X
  79. XLIBS = $(TERMLIBS) @X_LIBRARIES@ -lm @LIBS@
  80. X
  81. X# Where to send email about bugs and comments (locally)
  82. XEMAIL=bug-gnuplot@dartmouth.edu
  83. X
  84. X# Lasergnu is a handy shell script for creating a plot from the
  85. X# command line and sending it directly to the printer. It currently
  86. X# supports PostScript and imagen printers, and probably would need
  87. X# tailoring to your site.
  88. X# Use lasergnu_install to install lasergnu.
  89. X# Use lasergnu_noinstall to not install lasergnu (default).
  90. XLASERGNU = @LASERGNU@
  91. X
  92. X############################################################
  93. X# -DREADLINE:
  94. X#   If READLINE is defined, then command-line editing is supported.
  95. X#   Otherwise, your normal terminal editing is all you get.
  96. X#   Some machines will not support this, and they will turn this
  97. X#   option off (for example, apollos running SR10.2 or SR10.3 and
  98. X#   loaded with BSD4.3 instead of SYS5). Note: problems with
  99. X#   gnuplot prompts have been noted when this feature is selected
  100. X#   on IBM RS/6000 AIX, and compile errors are encountered on
  101. X#   Sequent Dynix 3 and Convex OS 9.0.
  102. X# -DNOCWDRC:
  103. X#   If NOCWDRC is defined, then any .gnuplot in the current directory
  104. X#   is not read on startup. This is a security consideration
  105. X#   especially for root users ( we recommend you define -DNOCWDRC ).
  106. X
  107. X# -DOLD_SELECT if you have an old 4.2 BSD OS (e.g. Sun OS 3.5) and
  108. X#   encounter compile error for missing FD_* macros for select
  109. X# -DBSD_TYPES if your system defines FD_* macros for select in
  110. X#   <sys/bsdtypes.h>
  111. X# -ISC22 to circumvent missing plots past the first on ISC 2.2
  112. X
  113. X#  -DNOVFORK if you're unix and you have don't have vfork()
  114. X#  -DMEMSET if you need to use memset() instead of bzero()
  115. X#  -DMEMCPY if your bcopy() is called memcpy()
  116. X#  -DNOCOPY if you don't have a memcpy() by any name
  117. X#  -DGAMMA=foo if your gamma function is called foo(). Apollos have
  118. X#    lgamma(3m). The default is -DGAMMA=gamma.
  119. X#  -DGETCWD if your unix uses getcwd() instead of getcd()
  120. X#    this is needed by HP-UX and Cray Unicos systems.
  121. X#  -DULTRIX_KLUDGE if you run X windows on Ultrix and experience the
  122. X#    "every other plot" problem.
  123. X#  -DCRIPPLED_SELECT if "select errors" are encountered with X. This
  124. X#    option is needed on SVR3 platforms with incomplete support for
  125. X#    the BSD select() system call
  126. X#  -DXPG3_LOCALE if your system uses the 'setlocale' function to
  127. X#    support foreign charactersets (currently only ISO8859-1).
  128. X#  -Dunix is required to explicitly define "unix" for SCO and IBM
  129. X#          RS/6000 running AIX 3.2
  130. X
  131. X#
  132. X# You probably don't need to change anything below here.
  133. X#
  134. X
  135. X####################################################################
  136. X# List of object files except version.o
  137. XOBJS = bitmap.o command.o contour.o eval.o graphics.o graph3d.o help.o \
  138. X       internal.o misc.o parse.o plot.o readline.o scanner.o \
  139. X       setshow.o specfun.o standard.o term.o util.o gnubin.o binary.o
  140. X
  141. X####################################################################
  142. X# List of source files
  143. X# Used for making shar files, lint, and some dependencies.
  144. XDIRS = term demo docs docs/latextut
  145. X
  146. XCSOURCE1 = bf_test.c binary.c command.c setshow.c
  147. XCSOURCE2 = help.c gnubin.c graphics.c graph3d.c internal.c
  148. XCSOURCE3 = misc.c eval.c parse.c plot.c readline.c scanner.c standard.c
  149. XCSOURCE4 = bitmap.c term.c util.c version.c
  150. XCSOURCE5 = term/ai.trm term/amiga.trm term/aed.trm term/atari.trm \
  151. X    term/bigfig.trm term/cgi.trm term/corel.trm \
  152. X    term/djsvga.trm term/dumb.trm \
  153. X    term/dxf.trm term/dxy.trm term/debug.trm \
  154. X    term/emxvga.trm term/eepic.trm term/epson.trm term/excl.trm \
  155. X    term/fig.trm term/grass.trm term/hp26.trm term/hp2648.trm term/hpgl.trm \
  156. X    term/hp500c.trm term/hpljii.trm term/metafont.trm \
  157. X    term/apollo.trm term/gpr.trm term/hppj.trm term/compact.c
  158. XCSOURCE6 = term/impcodes.h term/imagen.trm term/next.trm term/object.h \
  159. X    term/iris4d.trm term/kyo.trm term/latex.trm term/mif.trm \
  160. X    term/pbm.trm term/pslatex.trm term/gpic.trm
  161. XCSOURCE7 = term/post.trm term/pstricks.trm term/qms.trm term/regis.trm \
  162. X    term/rgip.trm term/sun.trm \
  163. X    term/t410x.trm term/tek.trm term/texdraw.trm term/tgif.h \
  164. X    term/tgif.trm term/tpic.trm \
  165. X    term/unixpc.trm term/unixplot.trm \
  166. X    term/v384.trm term/vws.trm term/x11.trm term/xlib.trm
  167. XCSOURCE8 = contour.c specfun.c gplt_x11.c
  168. XNEXTSRC  = epsviewe.m epsviewe.h
  169. X# not C code, but still needed
  170. X
  171. XDEMOS = demo/1.dat demo/2.dat demo/3.dat demo/contours.dem \
  172. X    demo/controls.dem demo/electron.dem demo/glass.dat demo/param.dem \
  173. X    demo/polar.dem demo/simple.dem demo/surface1.dem \
  174. X    demo/surface2.dem demo/using.dat demo/using.dem demo/world.cor \
  175. X    demo/world.dat demo/world.dem \
  176. X    demo/err.dat demo/poldat.dem demo/polar.dat demo/errorbar.dem \
  177. X    demo/antenna.dat demo/all.dem demo/animate.dem demo/bivariat.dem \
  178. X    demo/prob.dem demo/stat.inc demo/prob2.dem demo/random.dem \
  179. X    demo/discrete.dem demo/hidden.dem demo/airfoil.dem demo/gnuplot.rot\
  180. X    demo/binary.dem demo/spline.dem demo/steps.dem demo/steps.dat \
  181. X    demo/multimsh.dem demo/whale.dat demo/hemisphr.dat \
  182. X    demo/scatter.dem demo/scatter2.dat demo/singulr.dem demo/klein.dat
  183. X
  184. XETC = Copyright 0README README.gnu README.ami makefile.unx makefile.vms \
  185. X    linkopt.amg makefile.amg makefile.ami linkopt.vms buildvms.com \
  186. X    lasergnu makefile.r makefile.nt makefile.g 0FAQ 0BUGS\
  187. X    term/README History gnuplot.el intergra.x11 0INSTALL\
  188. X    README.3p2 README.3p3 README.3p4 README.pro README.nex README.x11 \
  189. X    README.3d README.mf README.win configure configure.in Makefile.in
  190. X
  191. X#BETA files (not standard distribution files)
  192. XBETA = BETA
  193. X# PC-specific files
  194. XPC = corgraph.asm corplot.c header.mac hrcgraph.asm lineproc.mac \
  195. X    linkopt.msc makefile.msc makefile.tc makefile.st makefile.djg \
  196. X    pcgraph.asm gnuplot.def makefile.286 gnuplot.prj makefile.emx \
  197. X    makefile.ztc linkopt.ztc term/fg.trm term/pc.trm
  198. XWINDOWS = makefile.win makefile.msw README.win win/wcommon.h \
  199. X    win/wgnuplib.c win/wgnuplib.def win/wgnuplib.h win/wgnuplib.rc \
  200. X    win/wgnuplot.def win/wgnuplot.hpj win/wgnuplot.mnu win/wgnuplot.rc \
  201. X    win/wgraph.c win/winmain.c win/wmenu.c win/wpause.c \
  202. X    win/wprinter.c win/wresourc.h win/wtext.c win/wtext.h \
  203. X    win/geticon.c docs/doc2rtf.c term/win.trm
  204. XOS2 = makefile.os2 os2/makefile os2/dialogs.c os2/dialogs.h os2/gclient.c \
  205. X    os2/gnuicon.uue os2/gnupmdrv.c os2/gnupmdrv.def os2/gnupmdrv.h \
  206. X    os2/gnupmdrv.itl os2/gnupmdrv.rc os2/print.c docs/doc2ipf.c \
  207. X    README.os2 term/pm.trm
  208. X
  209. X# Documentation and help files
  210. XDOCS1 = docs/makefile.org docs/README docs/checkdoc.c docs/doc2gih.c \
  211. X    docs/doc2hlp.c docs/doc2hlp.com docs/doc2ms.c docs/doc2tex.c \
  212. X    docs/gnuplot.1 docs/lasergnu.1 docs/toc_entr.sty docs/doc2info.pl \
  213. X    docs/titlepag.ms docs/titlepag.tex docs/makefile.ami \
  214. X    docs/doc2rtf.c docs/Makefile.in
  215. XDOCS2 = docs/gnuplot.doc docs/gpcard.tex
  216. XDOCS3 = docs/latextut/makefile.org docs/latextut/eg1.plt \
  217. X    docs/latextut/eg2.plt docs/latextut/eg3.dat docs/latextut/eg3.plt \
  218. X    docs/latextut/eg4.plt docs/latextut/eg5.plt docs/latextut/eg6.plt \
  219. X    docs/latextut/header.tex docs/latextut/tutorial.tex \
  220. X    docs/latextut/linepoin.plt docs/latextut/Makefile.in
  221. X
  222. X#########################################################################
  223. X
  224. Xall: gnuplot @PROGS@ doc
  225. X
  226. Xgnuplot: $(OBJS) version.o
  227. X    $(CC) -o $@ $(OBJS) version.o $(LDFLAGS) $(LIBS)
  228. X
  229. Xdoc:
  230. X    ( cd docs; $(MAKE) $(MFLAGS) gnuplot.gih )
  231. X
  232. Xgnuplot_x11: gplt_x11.o
  233. X    $(CC) -o $@ gplt_x11.o $(LDFLAGS) $(LIBS)
  234. X
  235. Xcheck: all demo/binary1
  236. X
  237. Xdemo/binary1 demo/binary2 demo/binary3: bf_test
  238. X    ( wd=`pwd`; cd $(srcdir)/demo; $$wd/bf_test )
  239. X
  240. Xbf_test: bf_test.o binary.o
  241. X    $(CC) -o $@ bf_test.o binary.o $(LDFLAGS) $(LIBS)
  242. X
  243. X################################################################
  244. X
  245. Xinstall: all $(LASERGNU)
  246. X    $(INSTALL_PROGRAM) gnuplot $(bindir)/gnuplot
  247. X    test ! -f gnuplot_x11 || $(INSTALL_PROGRAM) gnuplot_x11 $(bindir)/gnuplot_x11
  248. X    -$(INSTALL_DATA) $(srcdir)/docs/gnuplot.1 $(mandir)/gnuplot.1
  249. X    ( cd docs; $(MAKE) $(MFLAGS) install datadir=$(datadir) )
  250. X
  251. Xlasergnu_install: lasergnu docs/lasergnu.1
  252. X    $(INSTALL_PROGRAM) lasergnu $(bindir)/lasergnu
  253. X    $(INSTALL_DATA) $(srcdir)/docs/lasergnu.1 $(mandir)/lasergnu.1
  254. X
  255. Xlasergnu_noinstall:
  256. X
  257. Xuninstall:
  258. X    rm -f $(bindir)/gnuplot $(bindir)/gnuplot_x11
  259. X    rm -f $(mandir)/gnuplot.1 $(mandir)/lasergnu.1
  260. X    ( cd docs; $(MAKE) $(MFLAGS) uninstall datadir=$(datadir) )
  261. X
  262. X################################################################
  263. X# Dependencies
  264. X
  265. X.c.o:
  266. X    $(CC) -c $(CPPFLAGS) $(DEFS) $(CFLAGS) $<
  267. X
  268. Xterm.o: term.h term.c $(CSOURCE5) $(CSOURCE6) $(CSOURCE7)
  269. X    $(CC) -c -I$(srcdir)/term $(TERMFLAGS) $(CPPFLAGS) $(DEFS) $(CFLAGS) $(srcdir)/term.c
  270. X
  271. Xversion.o:
  272. X    $(CC) -c -DCONTACT=\"$(EMAIL)\" $(CPPFLAGS) $(DEFS) $(CFLAGS) $(srcdir)/version.c
  273. X
  274. X$(OBJS): plot.h
  275. X
  276. Xcommand.o: command.c
  277. X    $(CC) -c -DHELPFILE=\"$(datadir)/gnuplot.gih\" $(CPPFLAGS) $(DEFS) $(CFLAGS) $(srcdir)/command.c
  278. X
  279. Xcommand.o help.o misc.o: help.h
  280. X
  281. Xcommand.o graphics.o graph3d.o misc.o plot.o setshow.o term.o: setshow.h
  282. X
  283. Xbitmap.o term.o: bitmap.h
  284. X
  285. X################################################################
  286. X
  287. XMakefile: Makefile.in config.status
  288. X    $(SHELL) config.status
  289. Xconfig.status: configure
  290. X    $(SHELL) config.status --recheck
  291. Xconfigure: configure.in
  292. X    cd $(srcdir); autoconf
  293. X
  294. X################################################################
  295. X# Miscellaneous targets
  296. X
  297. XSOURCES=plot.h help.h setshow.h bitmap.h term.h $(CSOURCE1) $(CSOURCE2) \
  298. X    $(CSOURCE3) $(CSOURCE4) $(CSOURCE5) $(CSOURCE6) $(CSOURCE7)\
  299. X    $(CSOURCE8) $(NEXTSRC) $(WINDOWS) $(OS2)
  300. X
  301. XDOCS  = $(DOCS1) $(DOCS2) $(DOCS3)
  302. X
  303. Xclean:
  304. X    rm -f gnuplot gnuplot_x11 bf_test *.o core
  305. X    ( cd docs; $(MAKE) $(MFLAGS) clean )
  306. X    ( cd docs/latextut; $(MAKE) $(MFLAGS) clean )
  307. X
  308. Xmostlyclean: clean
  309. X
  310. Xdistclean: clean
  311. X    rm -f Makefile config.status
  312. X
  313. Xrealclean: distclean
  314. X    rm -f TAGS
  315. X
  316. Xdist: $(ETC) $(SOURCES) $(PC) $(DEMOS) $(BETA) $(DOCS)
  317. X    $(TAR) cvf /tmp/gnuplot.tar $(ETC) $(SOURCES) $(PC)\
  318. X         $(DEMOS) $(BETA) $(DOCS)
  319. END_OF_FILE
  320.   if test 11003 -ne `wc -c <'gnuplot/Makefile.in'`; then
  321.     echo shar: \"'gnuplot/Makefile.in'\" unpacked with wrong size!
  322.   fi
  323.   # end of 'gnuplot/Makefile.in'
  324. fi
  325. if test -f 'gnuplot/scanner.c' -a "${1}" != "-c" ; then 
  326.   echo shar: Will not clobber existing file \"'gnuplot/scanner.c'\"
  327. else
  328.   echo shar: Extracting \"'gnuplot/scanner.c'\" \(10587 characters\)
  329.   sed "s/^X//" >'gnuplot/scanner.c' <<'END_OF_FILE'
  330. X#ifndef lint
  331. Xstatic char *RCSid = "$Id: scanner.c%v 3.50 1993/07/09 05:35:24 woo Exp $";
  332. X#endif
  333. X
  334. X
  335. X/* GNUPLOT - scanner.c */
  336. X/*
  337. X * Copyright (C) 1986 - 1993   Thomas Williams, Colin Kelley
  338. X *
  339. X * Permission to use, copy, and distribute this software and its
  340. X * documentation for any purpose with or without fee is hereby granted, 
  341. X * provided that the above copyright notice appear in all copies and 
  342. X * that both that copyright notice and this permission notice appear 
  343. X * in supporting documentation.
  344. X *
  345. X * Permission to modify the software is granted, but not the right to
  346. X * distribute the modified code.  Modifications are to be distributed 
  347. X * as patches to released version.
  348. X *  
  349. X * This software is provided "as is" without express or implied warranty.
  350. X * 
  351. X *
  352. X * AUTHORS
  353. X * 
  354. X *   Original Software:
  355. X *     Thomas Williams,  Colin Kelley.
  356. X * 
  357. X *   Gnuplot 2.0 additions:
  358. X *       Russell Lang, Dave Kotz, John Campbell.
  359. X *
  360. X *   Gnuplot 3.0 additions:
  361. X *       Gershon Elber and many others.
  362. X * 
  363. X * There is a mailing list for gnuplot users. Note, however, that the
  364. X * newsgroup 
  365. X *    comp.graphics.gnuplot 
  366. X * is identical to the mailing list (they
  367. X * both carry the same set of messages). We prefer that you read the
  368. X * messages through that newsgroup, to subscribing to the mailing list.
  369. X * (If you can read that newsgroup, and are already on the mailing list,
  370. X * please send a message info-gnuplot-request@dartmouth.edu, asking to be
  371. X * removed from the mailing list.)
  372. X *
  373. X * The address for mailing to list members is
  374. X *       info-gnuplot@dartmouth.edu
  375. X * and for mailing administrative requests is 
  376. X *       info-gnuplot-request@dartmouth.edu
  377. X * The mailing list for bug reports is 
  378. X *       bug-gnuplot@dartmouth.edu
  379. X * The list of those interested in beta-test versions is
  380. X *       info-gnuplot-beta@dartmouth.edu
  381. X */
  382. X
  383. X#include <stdio.h>
  384. X#include <ctype.h>
  385. X#include "plot.h"
  386. X
  387. X#ifdef AMIGA_AC_5
  388. X#define O_RDONLY    0
  389. Xint open(const char * _name, int _mode, ...);
  390. Xint close(int);
  391. X#endif
  392. X
  393. X#ifdef vms
  394. X
  395. X#include stdio
  396. X#include descrip
  397. X#include errno
  398. X
  399. X#define MAILBOX "PLOT$MAILBOX"
  400. X#define pclose(f) fclose(f)
  401. X
  402. X#endif /* vms */
  403. X
  404. X
  405. X#define isident(c) (isalnum(c) || (c) == '_')
  406. X
  407. X#ifndef STDOUT
  408. X#define STDOUT 1
  409. X#endif
  410. X
  411. X#define LBRACE '{'
  412. X#define RBRACE '}'
  413. X
  414. X#define APPEND_TOKEN {token[t_num].length++; current++;}
  415. X
  416. X#define SCAN_IDENTIFIER while (isident(expression[current + 1]))\
  417. X                APPEND_TOKEN
  418. X
  419. Xextern struct lexical_unit token[MAX_TOKENS];
  420. X
  421. Xstatic int t_num;    /* number of token I'm working on */
  422. X
  423. X#ifndef AMIGA_SC_6_1
  424. Xchar *strcat(), *strcpy(), *strncpy();
  425. X#endif /* !AMIGA_SC_6_1 */
  426. X
  427. X/*
  428. X * scanner() breaks expression[] into lexical units, storing them in token[].
  429. X *   The total number of tokens found is returned as the function value.
  430. X *   Scanning will stop when '\0' is found in expression[], or when token[]
  431. X *     is full.
  432. X *
  433. X *     Scanning is performed by following rules:
  434. X *
  435. X *    Current char    token should contain
  436. X *     -------------    -----------------------
  437. X *    1.  alpha,_    all following alpha-numerics
  438. X *    2.  digit    0 or more following digits, 0 or 1 decimal point,
  439. X *                0 or more digits, 0 or 1 'e' or 'E',
  440. X *                0 or more digits.
  441. X *    3.  ^,+,-,/    only current char
  442. X *        %,~,(,)
  443. X *        [,],;,:,
  444. X *        ?,comma
  445. X *    4.  &,|,=,*    current char; also next if next is same
  446. X *    5.  !,<,>    current char; also next if next is =
  447. X *    6.  ", '    all chars up until matching quote
  448. X *    7.  #        this token cuts off scanning of the line (DFK).
  449. X *
  450. X *            white space between tokens is ignored
  451. X */
  452. Xscanner(expression)
  453. Xchar expression[];
  454. X{
  455. Xregister int current;    /* index of current char in expression[] */
  456. Xregister int quote;
  457. Xchar brace;
  458. X
  459. X    for (current = t_num = 0;
  460. X        t_num < MAX_TOKENS && expression[current] != '\0';
  461. X        current++) {
  462. Xagain:
  463. X        if (isspace(expression[current]))
  464. X            continue;                        /* skip the whitespace */
  465. X        token[t_num].start_index = current;
  466. X        token[t_num].length = 1;
  467. X        token[t_num].is_token = TRUE;    /* to start with...*/
  468. X
  469. X        if (expression[current] == '`') {
  470. X            substitute(&expression[current],MAX_LINE_LEN - current);
  471. X            goto again;
  472. X        }
  473. X        /* allow _ to be the first character of an identifier */
  474. X        if (isalpha(expression[current]) || expression[current] == '_') {
  475. X            SCAN_IDENTIFIER;
  476. X        } else if (isdigit(expression[current]) || expression[current] == '.'){
  477. X            token[t_num].is_token = FALSE;
  478. X            token[t_num].length = get_num(&expression[current]);
  479. X            current += (token[t_num].length - 1);
  480. X        } else if (expression[current] == LBRACE) {
  481. X            token[t_num].is_token = FALSE;
  482. X            token[t_num].l_val.type = CMPLX;
  483. X#ifdef __PUREC__
  484. X            { char    l[80];
  485. X            if ((sscanf(&expression[++current],"%lf,%lf%[ }]s",
  486. X                &token[t_num].l_val.v.cmplx_val.real,
  487. X                &token[t_num].l_val.v.cmplx_val.imag,
  488. X                &l)    != 3) || (!strchr(l, RBRACE))  )
  489. X                    int_error("invalid complex constant",t_num);
  490. X            }
  491. X#else
  492. X            if ((sscanf(&expression[++current],"%lf , %lf %c",
  493. X                &token[t_num].l_val.v.cmplx_val.real,
  494. X                &token[t_num].l_val.v.cmplx_val.imag,
  495. X                &brace) != 3) || (brace != RBRACE))
  496. X                    int_error("invalid complex constant",t_num);
  497. X#endif
  498. X            token[t_num].length += 2;
  499. X            while (expression[++current] != RBRACE) {
  500. X                token[t_num].length++;
  501. X                if (expression[current] == '\0')            /* { for vi % */
  502. X                    int_error("no matching '}'", t_num);
  503. X            }
  504. X        } else if (expression[current] == '\'' || expression[current] == '\"'){
  505. X            token[t_num].length++;
  506. X            quote = expression[current];
  507. X            while (expression[++current] != quote) {
  508. X                if (!expression[current]) {
  509. X                    expression[current] = quote;
  510. X                    expression[current+1] = '\0';
  511. X                    break;
  512. X                } else
  513. X                    token[t_num].length++;
  514. X            }
  515. X        } else switch (expression[current]) {
  516. X             case '#':        /* DFK: add comments to gnuplot */
  517. X                  goto endline; /* ignore the rest of the line */
  518. X            case '^':
  519. X            case '+':
  520. X            case '-':
  521. X            case '/':
  522. X            case '%':
  523. X            case '~':
  524. X            case '(':
  525. X            case ')':
  526. X            case '[':
  527. X            case ']':
  528. X            case ';':
  529. X            case ':':
  530. X            case '?':
  531. X            case ',':
  532. X                break;
  533. X            case '&':
  534. X            case '|':
  535. X            case '=':
  536. X            case '*':
  537. X                if (expression[current] == expression[current + 1])
  538. X                    APPEND_TOKEN;
  539. X                break;
  540. X            case '!':
  541. X            case '<':
  542. X            case '>':
  543. X                if (expression[current + 1] == '=')
  544. X                    APPEND_TOKEN;
  545. X                break;
  546. X            default:
  547. X                int_error("invalid character",t_num);
  548. X            }
  549. X        ++t_num;    /* next token if not white space */
  550. X    }
  551. X
  552. Xendline:                    /* comments jump here to ignore line */
  553. X
  554. X/* Now kludge an extra token which points to '\0' at end of expression[].
  555. X   This is useful so printerror() looks nice even if we've fallen off the
  556. X   line. */
  557. X
  558. X        token[t_num].start_index = current;
  559. X        token[t_num].length = 0;
  560. X    return(t_num);
  561. X}
  562. X
  563. X
  564. Xget_num(str)
  565. Xchar str[];
  566. X{
  567. Xdouble atof();
  568. Xregister int count = 0;
  569. Xlong atol();
  570. Xregister long lval;
  571. X
  572. X    token[t_num].is_token = FALSE;
  573. X    token[t_num].l_val.type = INTGR;        /* assume unless . or E found */
  574. X    while (isdigit(str[count]))
  575. X        count++;
  576. X    if (str[count] == '.') {
  577. X        token[t_num].l_val.type = CMPLX;
  578. X        while (isdigit(str[++count]))    /* swallow up digits until non-digit */
  579. X            ;
  580. X        /* now str[count] is other than a digit */
  581. X    }
  582. X    if (str[count] == 'e' || str[count] == 'E') {
  583. X        token[t_num].l_val.type = CMPLX;
  584. X/* modified if statement to allow + sign in exponent
  585. X   rjl 26 July 1988 */
  586. X        count++;
  587. X        if (str[count] == '-' || str[count] == '+')
  588. X            count++;
  589. X        if (!isdigit(str[count])) {
  590. X            token[t_num].start_index += count;
  591. X            int_error("expecting exponent",t_num);
  592. X        }
  593. X        while (isdigit(str[++count]))
  594. X            ;
  595. X    }
  596. X    if (token[t_num].l_val.type == INTGR) {
  597. X         lval = atol(str);
  598. X        if ((token[t_num].l_val.v.int_val = lval) != lval)
  599. X            int_error("integer overflow; change to floating point",t_num);
  600. X    } else {
  601. X        token[t_num].l_val.v.cmplx_val.imag = 0.0;
  602. X        token[t_num].l_val.v.cmplx_val.real = atof(str);
  603. X    }
  604. X    return(count);
  605. X}
  606. X
  607. X#if defined(unix) || defined(vms) || defined(PIPES) || (defined(ATARI) && defined(__PUREC__))
  608. X
  609. Xsubstitute(str,max)            /* substitute output from ` ` */
  610. Xchar *str;
  611. Xint max;
  612. X{
  613. Xregister char *last;
  614. Xregister int i,c;
  615. Xregister FILE *f;
  616. X#ifdef AMIGA_AC_5
  617. Xint fd;
  618. X#else
  619. X#if defined(ATARI) && defined(__PUREC__)
  620. Xchar    *atari_tmpfile;
  621. Xchar    *atari_pgm[MAX_LINE_LEN+100];
  622. X#else
  623. XFILE *popen();
  624. X#endif /* ATARI && PUREC */
  625. X#endif
  626. Xstatic char pgm[MAX_LINE_LEN+1],output[MAX_LINE_LEN+1];
  627. X
  628. X#ifdef vms
  629. Xint chan;
  630. Xstatic $DESCRIPTOR(pgmdsc,pgm);
  631. Xstatic $DESCRIPTOR(lognamedsc,MAILBOX);
  632. X#endif /* vms */
  633. X
  634. X    i = 0;
  635. X    last = str;
  636. X    while (*(++last) != '`') {
  637. X        if (*last == '\0')
  638. X            int_error("unmatched `",t_num);
  639. X        pgm[i++] = *last;
  640. X    }
  641. X    pgm[i] = '\0';        /* end with null */
  642. X    max -= strlen(last);    /* max is now the max length of output sub. */
  643. X  
  644. X#ifdef vms
  645. X      pgmdsc.dsc$w_length = i;
  646. X       if (!((vaxc$errno = sys$crembx(0,&chan,0,0,0,0,&lognamedsc)) & 1))
  647. X           os_error("sys$crembx failed",NO_CARET);
  648. X   
  649. X       if (!((vaxc$errno = lib$spawn(&pgmdsc,0,&lognamedsc,&1)) & 1))
  650. X           os_error("lib$spawn failed",NO_CARET);
  651. X   
  652. X       if ((f = fopen(MAILBOX,"r")) == NULL)
  653. X           os_error("mailbox open failed",NO_CARET);
  654. X#else /* vms */
  655. X#if defined(ATARI) && defined(__PUREC__)
  656. X        if (system(NULL) == 0)
  657. X            os_error("no command shell");
  658. X        if ((strlen(atari_tmpfile) + strlen(pgm) + 5) > MAX_LINE_LEN+100)
  659. X            os_error("sorry, command to long");
  660. X        atari_tmpfile = tmpnam(NULL);
  661. X        strcpy(atari_pgm, pgm);
  662. X        strcat(atari_pgm, " >> ");
  663. X        strcat(atari_pgm, atari_tmpfile);
  664. X        system(atari_pgm);
  665. X        if ((f = fopen(atari_tmpfile, "r")) == NULL)
  666. X#else
  667. X#ifdef AMIGA_AC_5
  668. X      if ((fd = open(pgm,"O_RDONLY")) == -1)
  669. X#else
  670. X      if ((f = popen(pgm,"r")) == NULL)
  671. X#endif
  672. X#endif    /* ATARI && PUREC */
  673. X          os_error("popen failed",NO_CARET);
  674. X#endif /* vms */
  675. X
  676. X    i = 0;
  677. X    while ((c = getc(f)) != EOF) {
  678. X        output[i++] = ((c == '\n') ? ' ' : c);    /* newlines become blanks*/
  679. X        if (i == max) {
  680. X#ifdef AMIGA_AC_5
  681. X            (void) close(fd);
  682. X#else
  683. X#if defined(ATARI) && defined(__PUREC__)
  684. X            (void) fclose(f);
  685. X            (void) unlink(atari_tmpfile);
  686. X#else
  687. X            (void) pclose(f);
  688. X#endif /* ATARI && PUREC */
  689. X#endif
  690. X            int_error("substitution overflow", t_num);
  691. X        }
  692. X    }
  693. X#ifdef AMIGA_AC_5
  694. X    (void) close(fd);
  695. X#else
  696. X#if defined(ATARI) && defined(__PUREC__)
  697. X    (void) fclose(f);
  698. X    (void) unlink(atari_tmpfile);
  699. X#else
  700. X    (void) pclose(f);
  701. X#endif /* ATARI && PUREC */
  702. X#endif
  703. X
  704. X    if (i + strlen(last) > max)
  705. X        int_error("substitution overflowed rest of line", t_num);
  706. X    (void) strncpy(output+i,last+1,MAX_LINE_LEN-i);
  707. X                                    /* tack on rest of line to output */
  708. X    (void) strcpy(str,output);                /* now replace ` ` with output */
  709. X    screen_ok = FALSE;
  710. X}
  711. X
  712. X#else /* unix || vms || PIPES || ATARI && PUREC */
  713. X
  714. X#ifdef __ZTC__
  715. Xsubstitute(char *str,int max)
  716. X#else
  717. Xsubstitute()
  718. X#endif
  719. X{
  720. X    char line[100];
  721. X
  722. X    int_error( strcat(strcpy(line,"substitution not supported by "),OS),t_num);
  723. X}
  724. X#endif /* unix || vms || PIPES || ATARI && PUREC */
  725. END_OF_FILE
  726.   if test 10587 -ne `wc -c <'gnuplot/scanner.c'`; then
  727.     echo shar: \"'gnuplot/scanner.c'\" unpacked with wrong size!
  728.   fi
  729.   # end of 'gnuplot/scanner.c'
  730. fi
  731. if test -f 'gnuplot/term/atari.trm' -a "${1}" != "-c" ; then 
  732.   echo shar: Will not clobber existing file \"'gnuplot/term/atari.trm'\"
  733. else
  734.   echo shar: Extracting \"'gnuplot/term/atari.trm'\" \(9626 characters\)
  735.   sed "s/^X//" >'gnuplot/term/atari.trm' <<'END_OF_FILE'
  736. X/*
  737. X * $Id: atari.trm%v 3.50 1993/07/09 05:35:24 woo Exp $
  738. X *
  739. X */
  740. X
  741. X/* GNUPLOT - atari.trm */
  742. X/*
  743. X * Copyright (C) 1992
  744. X *
  745. X * Permission to use, copy, and distribute this software and its
  746. X * documentation for any purpose with or without fee is hereby granted,
  747. X * provided that the above copyright notice appear in all copies and
  748. X * that both that copyright notice and this permission notice appear
  749. X * in supporting documentation.
  750. X *
  751. X * Permission to modify the software is granted, but not the right to
  752. X * distribute the modified code.  Modifications are to be distributed
  753. X * as patches to released version.
  754. X *
  755. X * This software  is provided "as is" without express or implied warranty.
  756. X *
  757. X * This file is included by ../term.c.
  758. X *
  759. X * This terminal driver supports:
  760. X *   Atari Screens working with the normal VDI
  761. X *     (this should include TT and big screens)
  762. X *
  763. X * AUTHORS
  764. X *  Alexander Lehmann
  765. X *  HE Koechling
  766. X *
  767. X * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
  768. X *
  769. X * ATARI-related comments please to alexlehm@iti.informatik.th-darmstadt.de
  770. X *
  771. X */
  772. X
  773. X#ifdef __PUREC__
  774. X/* why did they have to change these names ??? */
  775. X#include <aes.h>
  776. X#include <vdi.h>
  777. X#include <tos.h>
  778. X#else /* !__PUREC__ i.e. __GNUC__, maybe others */
  779. X#include <aesbind.h>
  780. X#include <vdibind.h>
  781. X#include <osbind.h>
  782. X#endif
  783. X
  784. X/* default to hi-res */
  785. X
  786. X#define ATARI_XMAX 640
  787. X#define ATARI_YMAX 400
  788. X#define ATARI_VCHAR 16
  789. X#define ATARI_HCHAR 8
  790. X#define ATARI_HTIC (ATARI_XMAX/100)
  791. X#define ATARI_VTIC ATARI_HTIC
  792. X
  793. X#define ATARI_yc(y) (ATARI_maxycoord-(y))
  794. X#define ATARI_LINETYPES_MAX    11
  795. Xstatic int ATARI_linetypes[ATARI_LINETYPES_MAX] = {
  796. X        0xffff, 0x1111,
  797. X        0xffff, 0x5555, 0x3333, 0x7777,
  798. X        0x3f3f, 0x0f0f, 0x5f5f, 0xe4e4, 0x55f5};
  799. Xstatic int ATARI_lt;
  800. Xstatic int vdi_handle=-1;
  801. Xstatic int ATARI_maxycoord;
  802. Xstatic int ATARI_rotation;
  803. Xstatic int ATARI_numcolors;
  804. Xstatic int pxy[128];            /* Maximum of 64 pixels per v_pline */
  805. Xstatic int pxy_index;
  806. Xstatic int ATARI_colors[16];
  807. Xstatic int ATARI_savecolors[16][3];
  808. Xstatic int ATARI_numpalette;
  809. X#define ATARI_c_height_default 6 /* well, well ...               */
  810. Xstatic int ATARI_c_height = ATARI_c_height_default;
  811. X
  812. XATARI_options( )
  813. X{
  814. X#define ATARIHEXERROR "palette values 3 hex digits, please"
  815. X#define ATARIHEIGHTERROR "expecting a character height"
  816. X    char opt[4];
  817. X    int i;
  818. X    char *tok_end;
  819. X
  820. X    term_options[0]='\0';
  821. X    ATARI_c_height=ATARI_c_height_default;
  822. X
  823. X    for( i=0 ; i<17 ; i++ ) {
  824. X        if(END_OF_COMMAND) break;
  825. X        if (token[c_token].length>3) {
  826. X            ATARI_numpalette=0;
  827. X            ATARI_c_height=ATARI_c_height_default;
  828. X            term_options[0]='\0';
  829. X            int_error(ATARIHEXERROR, c_token);
  830. X        }
  831. X
  832. X        capture( opt, c_token, c_token );
  833. X        if (!i) {
  834. X            ATARI_c_height = strtoul( opt, &tok_end, 10 );
  835. X            if( *tok_end!='\0' ) {
  836. X                ATARI_numpalette=0;
  837. X                ATARI_c_height=ATARI_c_height_default;
  838. X                term_options[0]='\0';
  839. X                int_error(ATARIHEIGHTERROR, c_token);
  840. X            }
  841. X            if( ATARI_c_height>999 )
  842. X                ATARI_c_height=999;  /* avoid opt length overflow */
  843. X            sprintf( opt, "%d ", ATARI_c_height );
  844. X        }
  845. X        else {
  846. X            ATARI_colors[i-1]=strtoul( opt, &tok_end, 16 );
  847. X            if( *tok_end!='\0' ) {
  848. X                ATARI_numpalette=0;
  849. X                ATARI_c_height=ATARI_c_height_default;
  850. X                term_options[0]='\0';
  851. X                int_error(ATARIHEXERROR, c_token);
  852. X            }
  853. X
  854. X            sprintf( opt, "%03X ", ATARI_colors[i-1] );
  855. X        }
  856. X        strcat( term_options, opt );
  857. X        c_token++;
  858. X    }
  859. X    ATARI_numpalette=(i==0 ? 0 : i-1);
  860. X}
  861. X
  862. XATARI_init( )
  863. X{
  864. X    int work_in[11];
  865. X    int work_out[57];
  866. X    int i;
  867. X    int hchar, wchar, dummy;
  868. X    int rgb[3];
  869. X    int num_save;
  870. X    char *colors,*tok_end;
  871. X
  872. X    if( ATARI_numpalette==0 && (colors=getenv("GNUCOLORS")) && *colors ) {
  873. X        for( i=0 ; i<17 ; i++ ) {
  874. X            if (!i) {
  875. X                ATARI_c_height = strtoul( colors, &tok_end, 10 );
  876. X                 if( colors==tok_end ) {
  877. X                    i=0;
  878. X                    ATARI_c_height=ATARI_c_height_default;
  879. X                    break;
  880. X                }
  881. X           }
  882. X            else {
  883. X                if( *colors=='\0' ) break;
  884. X                ATARI_colors[i]=strtoul( colors, &tok_end, 16 );
  885. X                if( colors==tok_end || (unsigned)ATARI_colors[i]>0xfff ) {
  886. X                    i=0;
  887. X                    break;
  888. X                }
  889. X            }
  890. X            colors=tok_end;
  891. X
  892. X            while( *colors==' ' ) colors++;
  893. X        }
  894. X        ATARI_numpalette=(i==0 ? 0 : i-1);
  895. X    }
  896. X
  897. X    vdi_handle=graf_handle( &wchar, &hchar, &dummy, &dummy );
  898. X    if( !vdi_handle )
  899. X        int_error("Fatal error opening virtual workstation", NO_CARET);
  900. X
  901. X    for( i=0 ; i<10 ; work_in[i++]=1 );
  902. X        work_in[10]=2;                  /* use raster coordinates */
  903. X    v_opnvwk( work_in, &vdi_handle, work_out );
  904. X    if( !vdi_handle )
  905. X        int_error("Fatal error opening virtual workstation", NO_CARET);
  906. X
  907. X    vst_height(vdi_handle, ATARI_c_height, &dummy, &dummy, &wchar, &hchar);
  908. X
  909. X    vs_clip( vdi_handle, 0, work_in ); /* turn clipping off */
  910. X
  911. X    term_tbl[term].xmax=work_out[0]+1;
  912. X    term_tbl[term].ymax=work_out[1]+1;
  913. X    term_tbl[term].h_char=wchar;
  914. X    term_tbl[term].v_char=hchar;    /* hchar stands for height this time */
  915. X    term_tbl[term].h_tic=(work_out[0]+1)/100;
  916. X    term_tbl[term].v_tic=term_tbl[term].h_tic;
  917. X
  918. X    ATARI_maxycoord=work_out[1];
  919. X    ATARI_numcolors=work_out[13];
  920. X    pxy_index=0;
  921. X
  922. X    for( i=0 ; i<ATARI_numpalette ; i++ ) {
  923. X        vq_color( vdi_handle, i, 1, ATARI_savecolors[i] );
  924. X
  925. X        rgb[0]=1000*(ATARI_colors[i]>>8);
  926. X        rgb[0]/=15;
  927. X        rgb[1]=1000*((ATARI_colors[i]>>4)&15);
  928. X        rgb[1]/=15;
  929. X        rgb[2]=1000*(ATARI_colors[i]&15);
  930. X        rgb[2]/=15;
  931. X        vs_color(vdi_handle, i, rgb );
  932. X    }
  933. X#ifdef __PUREC__
  934. X/* currently the PureC version runs as .prg and the GCC version runs as .ttp.
  935. X   Let's hope that we soon figure out which way is the best */
  936. X    v_hide_c(vdi_handle);
  937. X#endif
  938. X}
  939. X
  940. XATARI_reset( )
  941. X{
  942. X    int i;
  943. X
  944. X    if( vdi_handle!=-1 ) {
  945. X        for( i=0 ; i<ATARI_numpalette ; i++ ) {
  946. X            vs_color(vdi_handle, i, ATARI_savecolors[i] );
  947. X        }
  948. X#ifdef __PUREC__
  949. X/* see above */
  950. X    v_show_c(vdi_handle, 0);
  951. X#endif
  952. X        v_clsvwk( vdi_handle );
  953. X        vdi_handle=-1;
  954. X    }
  955. X}
  956. X
  957. XATARI_graphics( )
  958. X{
  959. X    int pxy[8];
  960. X    MFDB mfdb;
  961. X
  962. X    fflush( stdout );
  963. X    fflush( stderr );
  964. X    Cconws( "\033f" ); /* turn cursor off */
  965. X/*  apparently v_clrwk doesn't work with overscan. We'll blit the screen clear.
  966. X    v_clrwk( vdi_handle );
  967. X*/
  968. X    mfdb.fd_addr=NULL; /* NULL means actual screen. So we don't need size etc. */
  969. X
  970. X    pxy[0]=pxy[4]=0;
  971. X    pxy[1]=pxy[5]=0;
  972. X    pxy[2]=pxy[6]=term_tbl[term].xmax-1;
  973. X    pxy[3]=pxy[7]=term_tbl[term].ymax-1;
  974. X
  975. X    vro_cpyfm( vdi_handle, ALL_WHITE /*0*/, pxy, &mfdb, &mfdb );
  976. X
  977. X    pxy_index=0;
  978. X}
  979. X
  980. Xflush_line( )
  981. X{
  982. X    int line_type;
  983. X    int color_index;
  984. X    int i;
  985. X
  986. X    if( pxy_index>=2 ) {
  987. X        if( ATARI_numcolors==2 ) { /* Monochrome */
  988. X            color_index=1;
  989. X            line_type=ATARI_lt;
  990. X            if (line_type >= 0)
  991. X                line_type %= (ATARI_LINETYPES_MAX - 2);
  992. X        } else { /* Color */
  993. X            if (ATARI_lt<0) {
  994. X                color_index=1;
  995. X                line_type= ATARI_lt;
  996. X            }
  997. X            else {
  998. X                color_index=2+ATARI_lt%(ATARI_numcolors-2);
  999. X                line_type=(ATARI_lt/(ATARI_numcolors-2)) % (ATARI_LINETYPES_MAX - 2);
  1000. X            }
  1001. X        }
  1002. X
  1003. X        vswr_mode( vdi_handle, MD_TRANS);
  1004. X        vsl_color( vdi_handle, color_index );
  1005. X
  1006. X        vsl_type( vdi_handle, 7 );
  1007. X        vsl_udsty( vdi_handle, ATARI_linetypes[line_type + 2] );
  1008. X
  1009. X        v_pline( vdi_handle, pxy_index, pxy );
  1010. X    }
  1011. X
  1012. X    if( pxy_index>=1 ) {
  1013. X        pxy[0]=pxy[2*(pxy_index-1)];
  1014. X        pxy[1]=pxy[2*(pxy_index-1)+1];
  1015. X        pxy_index=1;
  1016. X    }
  1017. X}
  1018. X
  1019. XATARI_text( )
  1020. X{
  1021. X    flush_line( );
  1022. X    Cnecin();        /* wait for any char --> enable screen dump */
  1023. X    Cconws( "\033e" );  /* turn cursor on again */
  1024. X}
  1025. X
  1026. XATARI_move( int x, int y )
  1027. X{
  1028. X    flush_line( );
  1029. X
  1030. X    pxy_index=1;
  1031. X    pxy[0]=x;
  1032. X    pxy[1]=ATARI_yc(y);
  1033. X}
  1034. X
  1035. XATARI_vector( int x, int y )
  1036. X{
  1037. X    pxy[2*pxy_index]=x;
  1038. X    pxy[2*pxy_index+1]=ATARI_yc(y);
  1039. X    pxy_index++;
  1040. X
  1041. X    if( pxy_index==64 ) {   /* we're all full */
  1042. X        flush_line( );
  1043. X    }
  1044. X}
  1045. X
  1046. XATARI_linetype( int lt )
  1047. X{
  1048. X    flush_line( );
  1049. X
  1050. X    ATARI_lt=lt;
  1051. X}
  1052. X
  1053. XATARI_put_text( int x, int y, char *str )
  1054. X{
  1055. X    int vchar=term_tbl[term].v_char;
  1056. X    int dummy;
  1057. X
  1058. X    if( !strlen(str) ) return;
  1059. X
  1060. X    if( x<0 ) x=0;
  1061. X    if( y<0 ) y=0;
  1062. X
  1063. X    /* align text left and to middle of char height */
  1064. X    vst_alignment( vdi_handle, 0, 5, &dummy, &dummy );
  1065. X    vst_rotation( vdi_handle, (ATARI_rotation ? 900 : 0) );
  1066. X    if( ATARI_rotation ) 
  1067. X        v_gtext( vdi_handle, x-vchar/2+1, ATARI_yc(y)-1, str );
  1068. X    else
  1069. X        v_gtext( vdi_handle, x+1, ATARI_yc(y)-vchar/2+1, str );
  1070. X}
  1071. X
  1072. XTBOOLEAN ATARI_text_angle( int ang )
  1073. X{
  1074. X    ATARI_rotation=ang;
  1075. X
  1076. X    return TRUE;
  1077. X}
  1078. X
  1079. XTBOOLEAN ATARI_justify_text( int mode )
  1080. X{
  1081. X    return FALSE;
  1082. X}
  1083. X
  1084. XATARI_point( int x, int y, int number )
  1085. X{
  1086. X    int old_linetype;
  1087. X
  1088. X    if( ATARI_numcolors==2 ) {
  1089. X        line_and_point( x, y, number ); /* monochrome */
  1090. X    } else {
  1091. X    /* we map colors that exceed our limit to dotted lines, but we can't do
  1092. X       that with the markers (sortof a generalized line_and_point) */
  1093. X    old_linetype=ATARI_lt;
  1094. X    if( ATARI_lt>ATARI_numcolors-2 )
  1095. X        ATARI_linetype(ATARI_lt%(ATARI_numcolors-2)); /* same color, but no dots */
  1096. X        do_point( x, y, number );
  1097. X    ATARI_linetype(old_linetype);
  1098. X    }
  1099. X}
  1100. END_OF_FILE
  1101.   if test 9626 -ne `wc -c <'gnuplot/term/atari.trm'`; then
  1102.     echo shar: \"'gnuplot/term/atari.trm'\" unpacked with wrong size!
  1103.   fi
  1104.   # end of 'gnuplot/term/atari.trm'
  1105. fi
  1106. if test -f 'gnuplot/term/corel.trm' -a "${1}" != "-c" ; then 
  1107.   echo shar: Will not clobber existing file \"'gnuplot/term/corel.trm'\"
  1108. else
  1109.   echo shar: Extracting \"'gnuplot/term/corel.trm'\" \(10937 characters\)
  1110.   sed "s/^X//" >'gnuplot/term/corel.trm' <<'END_OF_FILE'
  1111. X/*
  1112. X * $Id: corel.trm%v 3.50 1993/07/09 05:35:24 woo Exp $
  1113. X */
  1114. X
  1115. X/*
  1116. X   corel.trm
  1117. X
  1118. X   A modified ai.trm for CorelDraw import filters
  1119. X   by Chris Parks, parks@physics.purdue.edu
  1120. X   Import from CorelDraw with the CorelTrace filter
  1121. X
  1122. X   syntax: set terminal default
  1123. X           set terminal mode "fontname" fontsize,xsize,ysize,linewidth
  1124. X
  1125. X           mode= color or monochrome             (default=mono)
  1126. X           "fontname"= postscript font name      (default="SwitzerlandLight")
  1127. X           fontsize  = size of font in points    (default=22pt)
  1128. X           xsize     = width of page in inches   (default=8.2in)
  1129. X           ysize     = height of page in inches  (default=10in)
  1130. X           linewidth = width of lines in points  (default=1.2pt)
  1131. X
  1132. X*/
  1133. X
  1134. X/* plots for publication should be sans-serif (don't use TimesRoman) */
  1135. Xchar corel_font[MAX_ID_LEN+1] = "SwitzerlandLight" ; /* name of font */
  1136. Xint corel_fontsize = 22;                            /* size of font in pts */
  1137. XTBOOLEAN corel_color = FALSE;
  1138. XTBOOLEAN corel_stroke = FALSE;
  1139. Xint corel_path_count=0;            /* count of lines in path */
  1140. Xint corel_ang=0;                   /* text angle */
  1141. Xenum JUSTIFY corel_justify=LEFT;   /* text is flush left */
  1142. X
  1143. X
  1144. X/* default mode constants */
  1145. X#define CORELD_XOFF  0               /* page offset in pts */
  1146. X#define CORELD_YOFF  0
  1147. X#define COREL_SC     (10.0)           /* scale is 1pt = 10 units */
  1148. X#define CORELD_LW    (1.2*COREL_SC)  /* linewidth = 1.2 pts */
  1149. X#define CORELD_XMAX  5960            /* 8.2 inches wide */
  1150. X#define CORELD_YMAX  7200            /* 10 inches high  */
  1151. X#define CORELD_VTIC  (CORELD_YMAX/80)
  1152. X#define CORELD_HTIC  (CORELD_YMAX/80)
  1153. X#define CORELD_VCHAR (22*COREL_SC)      /* default is 22 point characters */
  1154. X#define CORELD_HCHAR (22*COREL_SC*6/10)
  1155. X
  1156. Xunsigned int corel_xmax=CORELD_XMAX;
  1157. Xunsigned int corel_ymax=CORELD_YMAX;
  1158. Xfloat corel_lw=CORELD_LW;
  1159. X
  1160. XCOREL_options()
  1161. X{
  1162. X    extern struct value *const_express();
  1163. X    extern double real();
  1164. X        struct value a;
  1165. X
  1166. X                if (!END_OF_COMMAND && almost_equals(c_token,"def$ault")) {
  1167. X                        corel_color=FALSE;
  1168. X                        strcpy(corel_font,"SwitzerlandLight");
  1169. X                        corel_fontsize = 22;
  1170. X                        corel_lw=CORELD_LW;
  1171. X                corel_xmax=CORELD_XMAX;
  1172. X                corel_ymax=CORELD_YMAX;
  1173. X            c_token++;
  1174. X                }
  1175. X                if (!END_OF_COMMAND && almost_equals(c_token,"mono$chrome")) {
  1176. X                        corel_color=FALSE;
  1177. X            c_token++;
  1178. X                } else
  1179. X                if (!END_OF_COMMAND && almost_equals(c_token,"color$")) {
  1180. X                        corel_color=TRUE;
  1181. X            c_token++;
  1182. X                }
  1183. X                if (!END_OF_COMMAND && isstring(c_token)) {
  1184. X                  quote_str(corel_font,c_token);
  1185. X                  c_token++;
  1186. X                }
  1187. X                if (!END_OF_COMMAND) {
  1188. X                  /* We have font size specified */
  1189. X                  corel_fontsize = (int)real(const_express(&a));
  1190. X                  c_token++;
  1191. X                  term_tbl[term].v_char = (unsigned int)(corel_fontsize*COREL_SC);
  1192. X                  term_tbl[term].h_char = (unsigned int)(corel_fontsize*COREL_SC*6/10);
  1193. X                }
  1194. X                if (!END_OF_COMMAND) {
  1195. X                  corel_xmax=(unsigned int)(real(const_express(&a))*720);
  1196. X                  c_token++;
  1197. X                  if (!END_OF_COMMAND) {
  1198. X                    corel_ymax=(unsigned int)(real(const_express(&a))*720);
  1199. X                    c_token++;
  1200. X                  }
  1201. X                  term_tbl[term].xmax=corel_xmax;
  1202. X                  term_tbl[term].ymax=corel_ymax;
  1203. X                  term_tbl[term].v_tic=corel_ymax/80;
  1204. X                  term_tbl[term].h_tic=corel_ymax/80;
  1205. X                }
  1206. X                if (!END_OF_COMMAND) {
  1207. X                  corel_lw= real(const_express(&a))*COREL_SC;
  1208. X                  c_token++;
  1209. X                }
  1210. X
  1211. X        sprintf(term_options,"%s \"%s\" %d,%0.1f,%0.1f,%0.1f",
  1212. X                corel_color ? "color" : "monochrome",corel_font,
  1213. X                corel_fontsize,corel_xmax/720.0,corel_ymax/720.0,
  1214. X                corel_lw/COREL_SC);
  1215. X}
  1216. X
  1217. XCOREL_init()
  1218. X{
  1219. X    fprintf(outfile,"%%!PS-Adobe-2.0 EPSF-1.2\n");
  1220. X        fprintf(outfile,"%%%%BoundingBox: %d %d %d %d\n", CORELD_XOFF,CORELD_YOFF,
  1221. X                (int)((corel_xmax)/COREL_SC+0.5+CORELD_XOFF),
  1222. X                (int)((corel_ymax)/COREL_SC+0.5+CORELD_YOFF) );
  1223. X        fprintf(outfile,"%%%%TemplateBox: %d %d %d %d\n", CORELD_XOFF,CORELD_YOFF,
  1224. X                (int)((corel_xmax)/COREL_SC+0.5+CORELD_XOFF),
  1225. X                (int)((corel_ymax)/COREL_SC+0.5+CORELD_YOFF) );
  1226. X    fprintf(outfile,"%%%%EndComments\n");
  1227. X    fprintf(outfile,"%%%%EndProlog\n");
  1228. X        fprintf(outfile,"%%%%BeginSetup\n%%%%EndSetup\n");
  1229. X}
  1230. X
  1231. X
  1232. XCOREL_graphics()
  1233. X{
  1234. X        corel_path_count = 0;
  1235. X        corel_stroke = FALSE;
  1236. X}
  1237. X
  1238. X
  1239. XCOREL_text()
  1240. X{
  1241. X        if (corel_stroke) {
  1242. X        fprintf(outfile,"S\n");
  1243. X                corel_stroke = FALSE;
  1244. X    }
  1245. X        corel_path_count = 0;
  1246. X}
  1247. X
  1248. X
  1249. XCOREL_reset()
  1250. X{
  1251. X    fprintf(outfile,"%%%%Trailer\n");
  1252. X}
  1253. X
  1254. X
  1255. XCOREL_linetype(linetype)
  1256. Xint linetype;
  1257. X{
  1258. X        if (corel_stroke) {
  1259. X        fprintf(outfile,"S\n");
  1260. X                corel_stroke = FALSE;
  1261. X    }
  1262. X    switch(linetype) {
  1263. X                case -2 : fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  1264. X                                if (corel_color) {
  1265. X                    fprintf(outfile,"0 0 0 1 K\n");
  1266. X                }
  1267. X                else {                
  1268. X                                        fprintf(outfile,"[] 0 d\n");
  1269. X                                        fprintf(outfile,"0 j\n0 G\n");
  1270. X                }
  1271. X                break;
  1272. X
  1273. X                case -1 : fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  1274. X                                if (corel_color) {
  1275. X                    fprintf(outfile,"0 0 0 1 K\n");
  1276. X                }
  1277. X                else {                
  1278. X                    fprintf(outfile,"[1 2] 0 d\n");
  1279. X                                        fprintf(outfile,"0 j\n0 G\n");
  1280. X                                }
  1281. X                break;
  1282. X                
  1283. X                case 0 :  fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  1284. X                                if (corel_color) {
  1285. X                    fprintf(outfile,"1 0 1 0 K\n");
  1286. X                }
  1287. X                else {                
  1288. X                    fprintf(outfile,"[] 0 d\n");
  1289. X                                        fprintf(outfile,"2 j\n0 G\n");
  1290. X                                }
  1291. X                break;
  1292. X                
  1293. X                case 1 :  fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  1294. X                                if (corel_color) {
  1295. X                    fprintf(outfile,"1 1 0 0 K\n");
  1296. X                }
  1297. X                else {                
  1298. X                    fprintf(outfile,"[4 2] 0 d\n");
  1299. X                                        fprintf(outfile,"2 j\n0 G\n");
  1300. X                                }
  1301. X                break;
  1302. X                
  1303. X                case 2 :  fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  1304. X                                if (corel_color) {
  1305. X                    fprintf(outfile,"0 1 1 0 K\n");
  1306. X                }
  1307. X                else {                
  1308. X                                        fprintf(outfile,"[2 3] 0 d\n");
  1309. X                                        fprintf(outfile,"2 j\n0 G\n");
  1310. X                                }
  1311. X                break;
  1312. X                
  1313. X                case 3 :  fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  1314. X                                if (corel_color) {
  1315. X                    fprintf(outfile,"0 1 0 0 K\n");
  1316. X                }
  1317. X                else {                
  1318. X                    fprintf(outfile,"[1 1.5] 0 d\n");
  1319. X                                        fprintf(outfile,"2 j\n0 G\n");
  1320. X                                }
  1321. X                break;
  1322. X                
  1323. X                case 4 :  fprintf(outfile,"%f w\n",corel_lw/COREL_SC);
  1324. X                                if (corel_color) {
  1325. X                    fprintf(outfile,"1 0 0 0 K\n");
  1326. X                                }
  1327. X                else {                
  1328. X                    fprintf(outfile,"[5 2 1 2] 0 d\n");
  1329. X                                        fprintf(outfile,"2 j\n0 G\n");
  1330. X                                }
  1331. X                break;
  1332. X                
  1333. X                case 5 : fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  1334. X                                if (corel_color) {
  1335. X                    fprintf(outfile,"0 0 1 0 K\n");
  1336. X                }
  1337. X                else {                
  1338. X                    fprintf(outfile,"[4 3 1 3] 0 d\n");
  1339. X                                        fprintf(outfile,"2 j\n0 G\n");
  1340. X                                }
  1341. X                break;
  1342. X                
  1343. X                case 6 : fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  1344. X                                if (corel_color) {
  1345. X                    fprintf(outfile,"0 0 0 1 K\n");
  1346. X                }
  1347. X                else {                
  1348. X                    fprintf(outfile,"[2 2 2 4] 0 d\n");
  1349. X                                        fprintf(outfile,"2 j\n0 G\n");
  1350. X                                }
  1351. X                break;
  1352. X                
  1353. X                case 7 : fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  1354. X                                if (corel_color) {
  1355. X                    fprintf(outfile,"0 0.7 1 0 K\n");
  1356. X                }
  1357. X                else {                
  1358. X                    fprintf(outfile,"[2 2 2 2 2 4] 0 d\n");
  1359. X                                        fprintf(outfile,"2 j\n0 G\n");
  1360. X                                }
  1361. X                break;
  1362. X                
  1363. X                case 8 : fprintf(outfile,"%.2f w\n",corel_lw/COREL_SC);
  1364. X                                if (corel_color) {
  1365. X                    fprintf(outfile,"0.5 0.5 0.5 0 K\n");
  1366. X                }
  1367. X                else {                
  1368. X                    fprintf(outfile,"[2 2 2 2 2 2 2 4] 0 d\n");
  1369. X                                        fprintf(outfile,"2 j\n0 G\n");
  1370. X                                }
  1371. X                break;
  1372. X        }
  1373. X        corel_path_count = 0;
  1374. X}
  1375. X
  1376. X
  1377. XCOREL_move(x,y)
  1378. Xunsigned int x,y;
  1379. X{
  1380. X        if (corel_stroke) fprintf(outfile,"S\n");
  1381. X        fprintf(outfile,"%0.2f %0.2f m\n", x/COREL_SC, y/COREL_SC);
  1382. X        corel_path_count += 1;
  1383. X        corel_stroke = TRUE;
  1384. X}
  1385. X
  1386. X
  1387. XCOREL_vector(x,y)
  1388. Xunsigned int x,y;
  1389. X{
  1390. X        fprintf(outfile,"%.2f %.2f l\n", x/COREL_SC, y/COREL_SC);
  1391. X        corel_path_count += 1;
  1392. X        corel_stroke = TRUE;
  1393. X        if (corel_path_count >= 400) {
  1394. X                fprintf(outfile,"S\n%.2f %.2f m\n",x/COREL_SC,y/COREL_SC);
  1395. X                corel_path_count = 0;
  1396. X    }
  1397. X}
  1398. X
  1399. X
  1400. XCOREL_put_text(x,y,str)
  1401. Xunsigned int x, y;
  1402. Xchar *str;
  1403. X{
  1404. Xchar ch;
  1405. X        if (corel_stroke) {
  1406. X        fprintf(outfile,"S\n");
  1407. X                corel_stroke = FALSE;
  1408. X    }
  1409. X        switch(corel_justify) {
  1410. X                case LEFT :   fprintf(outfile,"/_%s %d %d 0 0 z\n",
  1411. X                                      corel_font,corel_fontsize,corel_fontsize);
  1412. X            break;
  1413. X                case CENTRE : fprintf(outfile,"/_%s %d %d 0 1 z\n",
  1414. X                                      corel_font,corel_fontsize,corel_fontsize);
  1415. X            break;
  1416. X                case RIGHT :  fprintf(outfile,"/_%s %d %d 0 2 z\n",
  1417. X                                      corel_font,corel_fontsize,corel_fontsize);
  1418. X            break;
  1419. X    }
  1420. X        if (corel_ang==0) {
  1421. X                fprintf(outfile,"[1 0 0 1 %.2f %.2f]e\n0 g\n",
  1422. X                        x/COREL_SC,y/COREL_SC - corel_fontsize/3.0);
  1423. X    }
  1424. X    else {
  1425. X                fprintf(outfile,"[0 1 -1 0 %.2f %.2f]e\n0 g\n",
  1426. X                        x/COREL_SC - corel_fontsize/3.0,y/COREL_SC);
  1427. X    }
  1428. X        
  1429. X    putc('(',outfile);
  1430. X    ch = *str++;
  1431. X    while(ch!='\0') {
  1432. X        if ( (ch=='(') || (ch==')') || (ch=='\\') )
  1433. X            putc('\\',outfile);
  1434. X        putc(ch,outfile);
  1435. X        ch = *str++;
  1436. X    }
  1437. X        fprintf(outfile,")t\nT\n");
  1438. X        corel_path_count = 0;
  1439. X}
  1440. X
  1441. Xint COREL_text_angle(ang)
  1442. Xint ang;
  1443. X{
  1444. X        corel_ang=ang;
  1445. X    return TRUE;
  1446. X}
  1447. X
  1448. Xint COREL_justify_text(mode)
  1449. Xenum JUSTIFY mode;
  1450. X{
  1451. X        corel_justify=mode;
  1452. X    return TRUE;
  1453. X}
  1454. X
  1455. END_OF_FILE
  1456.   if test 10937 -ne `wc -c <'gnuplot/term/corel.trm'`; then
  1457.     echo shar: \"'gnuplot/term/corel.trm'\" unpacked with wrong size!
  1458.   fi
  1459.   # end of 'gnuplot/term/corel.trm'
  1460. fi
  1461. if test -f 'gnuplot/term/grass.trm' -a "${1}" != "-c" ; then 
  1462.   echo shar: Will not clobber existing file \"'gnuplot/term/grass.trm'\"
  1463. else
  1464.   echo shar: Extracting \"'gnuplot/term/grass.trm'\" \(10800 characters\)
  1465.   sed "s/^X//" >'gnuplot/term/grass.trm' <<'END_OF_FILE'
  1466. X/* GNUPLOT - grass.trm */
  1467. X/*-
  1468. X * Copyright (C) 1992,1993. James Darrell McCauley
  1469. X *
  1470. X * Permission to use, copy, and distribute this software and its
  1471. X * documentation for any purpose with or without fee is hereby granted,
  1472. X * provided that the above copyright notice appear in all copies and
  1473. X * that both that copyright notice and this permission notice appear
  1474. X * in supporting documentation.
  1475. X *
  1476. X * Permission to modify the software is granted, but not the right to
  1477. X * distribute the modified code.  Modifications are to be distributed
  1478. X * as patches to released version.
  1479. X *
  1480. X * This software  is provided "as is" without express or implied warranty.
  1481. X *
  1482. X * This file is included by ../term.c.
  1483. X *
  1484. X * This terminal driver supports:
  1485. X *  GRASS graphics driver
  1486. X *
  1487. X * AUTHOR
  1488. X *  James Darrell McCauley
  1489. X *
  1490. X * send your comments or suggestions to (grassp-list@moon.cecer.army.mil).
  1491. X *
  1492. X */
  1493. X#include <stdio.h>
  1494. X/* #include "gis.h" */ /* this causes conflicts with things in term.c */
  1495. X
  1496. X#define GRASS_XMAX 1000
  1497. X#define GRASS_YMAX 1000
  1498. X#define GRASS_VCHAR 5
  1499. X#define GRASS_HCHAR 5
  1500. X#define GRASS_VTIC 3
  1501. X#define GRASS_HTIC 3
  1502. X
  1503. X#define PNT_SIZE 3
  1504. X#define TYPE_DOT  -1
  1505. X#define TYPE_X  0
  1506. X#define TYPE_PLUS   1
  1507. X#define TYPE_BOX    2
  1508. X#define TYPE_DIAMOND    3    /* need type 4 and 5 */
  1509. X#define TYPE_TRIANGLE 4
  1510. X#define TYPE_OCTO 5
  1511. X#define TYPE_ITRIANGLE 6
  1512. X#define TYPE_FBOX 7
  1513. X#define TYPE_FTRIANGLE 8
  1514. X#define TYPE_FITRIANGLE 9
  1515. X#define TYPE_FOCTO 10
  1516. X
  1517. Xint R__curx, R__cury;
  1518. X
  1519. Xint yoffset;
  1520. Xint xoffset;
  1521. Xint y_max;
  1522. Xint points_buf_x[PNT_SIZE*PNT_SIZE]; /* for filled point types */
  1523. Xint points_buf_y[PNT_SIZE*PNT_SIZE];
  1524. X
  1525. XGRASS_move (x, y)
  1526. X  int x, y;
  1527. X{
  1528. X  /* R_move_abs (xoffset+x, yoffset-y + y_max); */
  1529. X  R_move_abs (xoffset+x, yoffset-y);
  1530. X}
  1531. X
  1532. Xcont_abs (x, y)
  1533. X  int x, y;
  1534. X{
  1535. X  /* R_cont_abs (xoffset+x, xoffset-y + y_max); */
  1536. X  R_cont_abs (xoffset+x, yoffset-y);
  1537. X}
  1538. X
  1539. XGRASS_options ()
  1540. X{
  1541. X  options_null ();        /* no options to begin with */
  1542. X}
  1543. X
  1544. XGRASS_init ()
  1545. X{
  1546. X  char buff[128];
  1547. X  char window_name[64];
  1548. X  float size = 3.0;
  1549. X  int backcolor;
  1550. X  int dots_per_line;
  1551. X  int top, b, l, r;
  1552. X  int textcolor;
  1553. X  struct termentry *t = &term_tbl[term];
  1554. X
  1555. X  G_gisinit ("g.gnuplot");
  1556. X
  1557. X  R_open_driver ();
  1558. X
  1559. X  D_setup (0); 
  1560. X
  1561. X  if (D_get_cur_wind (window_name))
  1562. X    G_fatal_error ("No current window");
  1563. X
  1564. X  if (D_set_cur_wind (window_name))
  1565. X    G_fatal_error ("Current window not available");
  1566. X
  1567. X  /* Set up the screen, conversions, and graphics */
  1568. X  D_get_screen_window (&top, &b, &l, &r);
  1569. X/*
  1570. X  if (D_cell_draw_setup (top, b, l, r))
  1571. X  {
  1572. X    sprintf (buff, "Cannot use current window");
  1573. X    G_fatal_error (buff);
  1574. X  }
  1575. X*/
  1576. X  /* D_set_overlay_mode (1); */
  1577. X
  1578. X  /* Figure out where to put text */
  1579. X
  1580. X  R_set_window (top, b, l, r);
  1581. X  t->xmax = r-l;
  1582. X  t->ymax = b-top;
  1583. X  xoffset=l;
  1584. X  yoffset=b;
  1585. X
  1586. X  dots_per_line = (int) (size / 100.0 * (float) (t->ymax));
  1587. X  t->v_char = t->h_char = (int) (.8 * (float) dots_per_line);
  1588. X  R_text_size (t->h_char, t->v_char);
  1589. X
  1590. X  t->v_tic = t->h_tic = 4;
  1591. X
  1592. X  y_max = t->ymax; /* kludge? */
  1593. X
  1594. X  R__curx = R_screen_top ();
  1595. X  R__cury = R_screen_bot () + yoffset;
  1596. X
  1597. X  D_erase_window();
  1598. X/*
  1599. Xfprintf(stderr,"**********************************************\n");
  1600. Xfprintf(stderr,"DIAGNOSTIC TERMINAL SETUP\n");
  1601. Xfprintf(stderr,"top = %d\tb = %d\tl = %d\tr = %d\n", top,b,l,r);
  1602. Xfprintf(stderr,"name = %s\n", t->name);
  1603. Xfprintf(stderr,"description = %s\n", t->description);
  1604. Xfprintf(stderr,"xmax = %d\t", (int)t->xmax);
  1605. Xfprintf(stderr,"ymax = %d\n", (int)t->ymax);
  1606. Xfprintf(stderr,"v_char = %d\t", (int)t->v_char);
  1607. Xfprintf(stderr,"h_char = %d\n", (int)t->h_char);
  1608. Xfprintf(stderr,"v_tic = %d\t", (int)t->v_tic);
  1609. Xfprintf(stderr,"h_tic = %d\n", (int)t->h_tic);
  1610. Xfprintf(stderr,"**********************************************\n\n");
  1611. X*/
  1612. X}
  1613. X
  1614. XGRASS_reset ()
  1615. X{
  1616. X  R_standard_color (D_translate_color ("black"));
  1617. X  /* D_erase_window(); /* don't clear after g.gnuplot is finished */ 
  1618. X  R_flush ();
  1619. X  R_stabilize ();
  1620. X  R_close_driver ();
  1621. X}
  1622. X
  1623. XGRASS_graphics ()
  1624. X{
  1625. X  R_flush ();
  1626. X  R_stabilize ();
  1627. X  R_standard_color (D_translate_color ("black"));
  1628. X  D_erase_window();
  1629. X  return;
  1630. X}
  1631. X
  1632. XGRASS_text ()
  1633. X{
  1634. X  R_flush ();
  1635. X  R_stabilize ();
  1636. X  return;            /* device can't be used as a terminal */
  1637. X}
  1638. X
  1639. XGRASS_vector (x, y)
  1640. X  int x, y;
  1641. X{
  1642. X  cont_abs (x, y);
  1643. X  R_flush ();
  1644. X  R_stabilize ();
  1645. X}
  1646. X
  1647. XGRASS_linetype (lt)
  1648. X  int lt;
  1649. X{
  1650. X
  1651. X  while (lt > 10) lt-=10;
  1652. X
  1653. X  if (lt <= -2)
  1654. X    R_standard_color (D_translate_color ("gray"));
  1655. X  else if (lt == -1)
  1656. X    R_standard_color (D_translate_color ("white"));
  1657. X  else if (lt == 0)
  1658. X    R_standard_color (D_translate_color ("red"));
  1659. X  else if (lt == 1)
  1660. X    R_standard_color (D_translate_color ("green"));
  1661. X  else if (lt == 2)
  1662. X    R_standard_color (D_translate_color ("magenta"));
  1663. X  else if (lt == 3)
  1664. X    R_standard_color (D_translate_color ("brown"));
  1665. X  else if (lt == 4)
  1666. X    R_standard_color (D_translate_color ("orange"));
  1667. X  else if (lt == 5)
  1668. X    R_standard_color (D_translate_color ("yellow"));
  1669. X  else if (lt == 6)
  1670. X    R_standard_color (D_translate_color ("blue"));
  1671. X  else if (lt == 7)
  1672. X    R_standard_color (D_translate_color ("violet"));
  1673. X  else if (lt == 8) 
  1674. X    R_standard_color (D_translate_color ("indigo"));
  1675. X  else if (lt == 9)
  1676. X    R_standard_color (D_translate_color ("gray"));
  1677. X  else /* if (lt == 10) */
  1678. X    R_standard_color (D_translate_color ("white"));
  1679. X  R_flush ();
  1680. X  R_stabilize ();
  1681. X  return;
  1682. X}
  1683. X
  1684. X/* originally /usr/grass4/src/display/d.label/cmd/label.c */
  1685. X
  1686. XGRASS_put_text (x, y, str)
  1687. X  int x, y;
  1688. X  char *str;
  1689. X{
  1690. X
  1691. X  if (strlen (str) == 0)
  1692. X    return;
  1693. X
  1694. X  GRASS_move (x, y);
  1695. X  /* R_standard_color (D_translate_color ("white")); */
  1696. X  R_text (str);
  1697. X  R_flush ();
  1698. X  R_stabilize ();
  1699. X}
  1700. X
  1701. Xint GRASS_text_angle (ang)
  1702. X{
  1703. X  return FALSE;            /* GRASS cannot rotate text */
  1704. X}
  1705. X
  1706. Xint GRASS_justify_text (mode)
  1707. X  int mode;
  1708. X{
  1709. X  return (FALSE);        /* don't mess with this now */
  1710. X}
  1711. X
  1712. X
  1713. XGRASS_point (x, y, point)
  1714. X{
  1715. X  switch (point)
  1716. X  {
  1717. X  case TYPE_DOT:
  1718. X    draw_points_dot (x, y);
  1719. X    break;
  1720. X  case TYPE_X:
  1721. X    draw_points_x (x, y);
  1722. X    break;
  1723. X  case TYPE_PLUS:
  1724. X    draw_points_plus (x, y);
  1725. X    break;
  1726. X  case TYPE_BOX:
  1727. X    draw_points_box (x, y);
  1728. X    break;
  1729. X  case TYPE_DIAMOND:
  1730. X    draw_points_diamond (x, y);
  1731. X    break;
  1732. X  case TYPE_TRIANGLE:
  1733. X    draw_points_triangle (x, y);
  1734. X    break;
  1735. X  case TYPE_OCTO:
  1736. X    draw_points_octo (x, y);
  1737. X    break;
  1738. X  case TYPE_ITRIANGLE:
  1739. X    draw_points_itriangle (x, y);
  1740. X    break;
  1741. X  case TYPE_FBOX:
  1742. X    draw_points_fbox (x, y);
  1743. X    break;
  1744. X  case TYPE_FTRIANGLE:
  1745. X    draw_points_ftriangle (x, y);
  1746. X    break;
  1747. X  case TYPE_FITRIANGLE:
  1748. X    draw_points_fitriangle (x, y);
  1749. X    break;
  1750. X  case TYPE_FOCTO:
  1751. X    draw_points_focto (x, y);
  1752. X    break;
  1753. X  }
  1754. X}
  1755. X
  1756. X/* modified from /usr/grass4/src/display/d.points/cmd/main.c */
  1757. X
  1758. Xdraw_points_dot (x, y)
  1759. X  int x, y;
  1760. X{
  1761. X  GRASS_move (x, y);
  1762. X  cont_abs (x, y);
  1763. X}
  1764. X
  1765. Xdraw_points_diamond (x, y)
  1766. X  int x, y;
  1767. X{
  1768. X  GRASS_move (x, y + PNT_SIZE);
  1769. X  GRASS_vector (x + PNT_SIZE, y);
  1770. X  GRASS_vector (x, y - PNT_SIZE);
  1771. X  GRASS_vector (x - PNT_SIZE, y);
  1772. X  GRASS_vector (x, y + PNT_SIZE);
  1773. X}
  1774. X
  1775. Xdraw_points_box (x, y)
  1776. X  int x, y;
  1777. X{
  1778. X  GRASS_move (x - PNT_SIZE, y - PNT_SIZE);
  1779. X  GRASS_vector (x - PNT_SIZE, y + PNT_SIZE);
  1780. X  GRASS_vector (x + PNT_SIZE, y + PNT_SIZE);
  1781. X  GRASS_vector (x + PNT_SIZE, y - PNT_SIZE);
  1782. X  GRASS_vector (x - PNT_SIZE, y - PNT_SIZE);
  1783. X}
  1784. X
  1785. Xdraw_points_fbox (x, y)
  1786. X  int x, y;
  1787. X{
  1788. X  points_buf_x[0] = xoffset + x - PNT_SIZE; 
  1789. X  points_buf_y[0]= yoffset - (y + PNT_SIZE);
  1790. X  points_buf_x[1] = xoffset + x + PNT_SIZE; 
  1791. X  points_buf_y[1]= yoffset - (y + PNT_SIZE);
  1792. X  points_buf_x[2] = xoffset + x + PNT_SIZE; 
  1793. X  points_buf_y[2]= yoffset - (y - PNT_SIZE);
  1794. X  points_buf_x[3] = xoffset + x - PNT_SIZE; 
  1795. X  points_buf_y[3]= yoffset - (y - PNT_SIZE);
  1796. X  R_polygon_abs(points_buf_x, points_buf_y, 4 );
  1797. X}
  1798. X
  1799. Xdraw_points_itriangle (x, y)
  1800. X  int x, y;
  1801. X{
  1802. X  GRASS_move (x - PNT_SIZE, y + PNT_SIZE);
  1803. X  GRASS_vector (x + PNT_SIZE, y + PNT_SIZE);
  1804. X  GRASS_vector (x , y - PNT_SIZE);
  1805. X  GRASS_vector (x - PNT_SIZE, y + PNT_SIZE);
  1806. X}
  1807. X
  1808. Xdraw_points_fitriangle (x, y)
  1809. X  int x, y;
  1810. X{
  1811. X  points_buf_x[0] = xoffset + x + PNT_SIZE; 
  1812. X  points_buf_y[0] = yoffset - (y + PNT_SIZE);
  1813. X  points_buf_x[1] = xoffset + x ;           
  1814. X  points_buf_y[1] = yoffset - (y - PNT_SIZE);
  1815. X  points_buf_x[2] = xoffset + x - PNT_SIZE; 
  1816. X  points_buf_y[2] = yoffset - (y + PNT_SIZE);
  1817. X  R_polygon_abs(points_buf_x, points_buf_y, 3 );
  1818. X}
  1819. X
  1820. Xdraw_points_triangle (x, y)
  1821. X  int x, y;
  1822. X{
  1823. X  GRASS_move (x - PNT_SIZE, y - PNT_SIZE);
  1824. X  GRASS_vector (x , y + PNT_SIZE);
  1825. X  GRASS_vector (x + PNT_SIZE, y - PNT_SIZE);
  1826. X  GRASS_vector (x - PNT_SIZE, y - PNT_SIZE);
  1827. X}
  1828. X
  1829. Xdraw_points_ftriangle (x, y)
  1830. X  int x, y;
  1831. X{
  1832. X  points_buf_x[0] = xoffset + x;            
  1833. X  points_buf_y[0]= yoffset - (y + PNT_SIZE);
  1834. X  points_buf_x[1] = xoffset + x + PNT_SIZE; 
  1835. X  points_buf_y[1]= yoffset - (y - PNT_SIZE);
  1836. X  points_buf_x[2] = xoffset + x - PNT_SIZE; 
  1837. X  points_buf_y[2]= yoffset - (y - PNT_SIZE);
  1838. X  R_polygon_abs(points_buf_x, points_buf_y, 3 );
  1839. X}
  1840. X
  1841. Xdraw_points_plus (x, y)
  1842. X  int x, y;
  1843. X{
  1844. X  GRASS_move (x - PNT_SIZE, y);
  1845. X  GRASS_vector (x + PNT_SIZE, y);
  1846. X  GRASS_move (x, y - PNT_SIZE);
  1847. X  GRASS_vector (x, y + PNT_SIZE);
  1848. X}
  1849. X
  1850. X/* depends on PNT_SIZE */
  1851. Xdraw_points_octo (x, y)
  1852. X  int x, y;
  1853. X{
  1854. X  /* CCW */
  1855. X  GRASS_move (x - (int) (PNT_SIZE/3), y - PNT_SIZE);   /* 1 */
  1856. X  GRASS_vector (x + (int) (PNT_SIZE/3), y - PNT_SIZE); /* 2 */
  1857. X  GRASS_vector (x + PNT_SIZE, y - (int) (PNT_SIZE/3)); /* 3 */
  1858. X  GRASS_vector (x + PNT_SIZE, y + (int) (PNT_SIZE/3)); /* 4 */
  1859. X  GRASS_vector (x + (int) (PNT_SIZE/3), y + PNT_SIZE); /* 5 */
  1860. X  GRASS_vector (x - (int) (PNT_SIZE/3), y + PNT_SIZE); /* 6 */
  1861. X  GRASS_vector (x - PNT_SIZE, y + (int) (PNT_SIZE/3)); /* 7 */
  1862. X  GRASS_vector (x - PNT_SIZE, y - (int) (PNT_SIZE/3)); /* 8 */
  1863. X  GRASS_vector (x - (int) (PNT_SIZE/3), y - PNT_SIZE); /* 1 */
  1864. X}
  1865. X
  1866. X/* depends on PNT_SIZE */
  1867. Xdraw_points_focto (x, y)
  1868. X  int x, y;
  1869. X{
  1870. X  /* CCW */
  1871. X  points_buf_x[0] = xoffset + x + (int) (PNT_SIZE/3);
  1872. X  points_buf_y[0] = yoffset - (y - PNT_SIZE); 
  1873. X  points_buf_x[1] = xoffset + x + PNT_SIZE;
  1874. X  points_buf_y[1] = yoffset - (y - (int) (PNT_SIZE/3)); 
  1875. X  points_buf_x[2] = xoffset + x + PNT_SIZE;
  1876. X  points_buf_y[2] = yoffset - (y + (int) (PNT_SIZE/3));
  1877. X  points_buf_x[3] = xoffset + x + (int) (PNT_SIZE/3);
  1878. X  points_buf_y[3] = yoffset - (y + PNT_SIZE); 
  1879. X  points_buf_x[4] = xoffset + x - (int) (PNT_SIZE/3);
  1880. X  points_buf_y[4] = yoffset - (y + PNT_SIZE);
  1881. X  points_buf_x[5] = xoffset + x - PNT_SIZE;
  1882. X  points_buf_y[5] = yoffset - (y + (int) (PNT_SIZE/3)); 
  1883. X  points_buf_x[6] = xoffset + x - PNT_SIZE;
  1884. X  points_buf_y[6] = yoffset - (y - (int) (PNT_SIZE/3));
  1885. X  points_buf_x[7] = xoffset + x - (int) (PNT_SIZE/3);
  1886. X  points_buf_y[7] = yoffset - (y - PNT_SIZE); 
  1887. X  R_polygon_abs(points_buf_x, points_buf_y, 8 );
  1888. X}
  1889. X
  1890. Xdraw_points_x (x, y)
  1891. X{
  1892. X  GRASS_move (x - PNT_SIZE, y - PNT_SIZE);
  1893. X  GRASS_vector (x + PNT_SIZE, y + PNT_SIZE);
  1894. X  GRASS_move (x + PNT_SIZE, y - PNT_SIZE);
  1895. X  GRASS_vector (x - PNT_SIZE, y + PNT_SIZE);
  1896. X}
  1897. X
  1898. X
  1899. X/* need to fix */
  1900. XGRASS_arrow (sx, sy, ex, ey, head)
  1901. X  int sx, sy, ex, ey, head;
  1902. X{
  1903. X  do_arrow (sx, sy, ex, ey, 1);
  1904. X  return;
  1905. X}
  1906. X
  1907. X
  1908. END_OF_FILE
  1909.   if test 10800 -ne `wc -c <'gnuplot/term/grass.trm'`; then
  1910.     echo shar: \"'gnuplot/term/grass.trm'\" unpacked with wrong size!
  1911.   fi
  1912.   # end of 'gnuplot/term/grass.trm'
  1913. fi
  1914. if test -f 'gnuplot/term/hp500c.trm' -a "${1}" != "-c" ; then 
  1915.   echo shar: Will not clobber existing file \"'gnuplot/term/hp500c.trm'\"
  1916. else
  1917.   echo shar: Extracting \"'gnuplot/term/hp500c.trm'\" \(11009 characters\)
  1918.   sed "s/^X//" >'gnuplot/term/hp500c.trm' <<'END_OF_FILE'
  1919. X/*
  1920. X * $Id: hp500c.trm%v 3.50.1.11 1993/08/10 03:55:03 woo Exp $
  1921. X *
  1922. X */
  1923. X/* GNUPLOT - hp500c.trm */
  1924. X/*
  1925. X * Copyright (C) 1993
  1926. X *
  1927. X * Permission to use, copy, and distribute this software and its
  1928. X * documentation for any purpose with or without fee is hereby granted, 
  1929. X * provided that the above copyright notice appear in all copies and 
  1930. X * that both that copyright notice and this permission notice appear 
  1931. X * in supporting documentation.
  1932. X *
  1933. X * Permission to modify the software is granted, but not the right to
  1934. X * distribute the modified code.  Modifications are to be distributed 
  1935. X * as patches to released version.
  1936. X *  
  1937. X * This software  is provided "as is" without express or implied warranty.
  1938. X * 
  1939. X * This file is included by ../term.c.
  1940. X *
  1941. X * This terminal driver supports:
  1942. X *  hpdj 500c
  1943. X *
  1944. X * AUTHORS
  1945. X *  John Engels      -- \
  1946. X *  Russell Lang     ----> HPLJII.trm
  1947. X *  Maurice Castro   -- /
  1948. X *  UdoHessenauer    ----> derived this version from the above one
  1949. X *
  1950. X * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
  1951. X * 
  1952. X */
  1953. X
  1954. X/* The following HP Deskjet500c  driver uses generic bit mapped graphics
  1955. X   routines from bitmap.c to build up a bit map in memory.  The driver
  1956. X   interchanges colomns and lines in order to access entire lines
  1957. X   easily and returns the lines to get bits in the right order :
  1958. X   (x,y) -> (y,XMAX-1-x). */
  1959. X/* This interchange is done by calling b_makebitmap() with reversed 
  1960. X   xmax and ymax, and then setting b_rastermode to TRUE.  b_setpixel()
  1961. X   will then perform the interchange before each pixel is plotted */
  1962. X/* by John Engels JENGELS@BNANDP51.BITNET, inspired by the hpljet driver
  1963. X   of Jyrki Yli-Nokari */
  1964. X
  1965. X#ifdef HP500C
  1966. X
  1967. X/* We define 4 different print qualities : 300ppi, 150ppi, 100ppi and
  1968. X   75ppi.  (Pixel size = 1, 2, 3, 4 dots) */
  1969. X
  1970. X#define HP500C_DPP (hpdj_dpp)   /* dots per pixel */
  1971. X#define HP500C_PPI (300/HP500C_DPP) /* pixel per inch */
  1972. X/* make XMAX and YMAX a multiple of 8 */
  1973. X#define HP500C_XMAX (8*(unsigned int)(xsize*1920/HP500C_DPP/8.0+0.9))
  1974. X#define HP500C_YMAX (8*(unsigned int)(ysize*1920/HP500C_DPP/8.0+0.9))
  1975. X
  1976. X#define HP500C_VCHAR (HP500C_PPI/6) /* Courier font with 6 lines per inch */
  1977. X#define HP500C_HCHAR (HP500C_PPI/10) /* Courier font with 10 caracters
  1978. Xper inch */
  1979. X
  1980. X/* default values for term_tbl */
  1981. X#define HP500C_75PPI_XMAX (1920/4)
  1982. X#define HP500C_75PPI_YMAX (1920/4)
  1983. X#define HP500C_75PPI_HCHAR (1920/4/6)
  1984. X#define HP500C_75PPI_VCHAR (1920/4/10)
  1985. X#define HP500C_75PPI_VTIC 5
  1986. X#define HP500C_75PPI_HTIC 5
  1987. X
  1988. X
  1989. X#define HP500C_PUSH_CURSOR fprintf(outfile,"\033&f0S") /* Save current
  1990. Xcursor position */
  1991. X#define HP500C_POP_CURSOR fprintf(outfile,"\033&f1S") /* Restore
  1992. Xcursor position */
  1993. X#define HP500C_COURIER fprintf(outfile,"\033(0N\033(s0p10.0h12.0v0s0b3T\033&l6D")
  1994. X/* be sure to use courier font with 6lpi and 10cpi */
  1995. X
  1996. Xstatic int hpdj_dpp=4;
  1997. Xstatic int HP_COMP_MODE = 0;
  1998. X
  1999. X/* bm_pattern not appropriate for 300ppi graphics */
  2000. X#ifndef HPLJII
  2001. Xstatic unsigned int b_300ppi_pattern[] = {
  2002. X  0xffff, 0x1111,
  2003. X  0xffff, 0x3333, 0x0f0f, 0x3f3f, 0x0fff, 0x00ff, 0x33ff};
  2004. X#endif
  2005. X
  2006. X
  2007. XHP500Coptions()
  2008. X{
  2009. X  char opt[6];
  2010. X  
  2011. X#define HPDJCERROR "expecting dots per inch size 75, 100, 150 or 300 and/or compression method"
  2012. X  while (!END_OF_COMMAND) {
  2013. X    if (token[c_token].length>4)
  2014. X      int_error(HPDJCERROR,c_token);
  2015. X    
  2016. X    /* almost_equals() won't accept numbers - use strcmp() instead */
  2017. X    capture(opt,c_token,c_token);
  2018. X    if (!strcmp(opt,"75")) {
  2019. X      hpdj_dpp = 4;
  2020. X      HP_COMP_MODE = 0;
  2021. X    
  2022. X}
  2023. X    else if (!strcmp(opt,"100")) {
  2024. X      hpdj_dpp = 3;
  2025. X      HP_COMP_MODE = 0;
  2026. X    }
  2027. X    else if (!strcmp(opt,"150")) {
  2028. X      hpdj_dpp = 2;
  2029. X      HP_COMP_MODE = 0;
  2030. X    }
  2031. X    else if (!strcmp(opt,"300")) {
  2032. X      hpdj_dpp = 1;
  2033. X      HP_COMP_MODE = 0;
  2034. X    }
  2035. X    else if (!strcmp(opt,"rle")){
  2036. X      HP_COMP_MODE = 1;
  2037. X    }
  2038. X    else if (!strcmp(opt,"tiff")){
  2039. X      HP_COMP_MODE = 2;
  2040. X    }
  2041. X    c_token++;
  2042. X  }
  2043. X  
  2044. X  term_tbl[term].xmax = HP500C_XMAX;
  2045. X  term_tbl[term].ymax = HP500C_YMAX;
  2046. X  switch(hpdj_dpp) {
  2047. X  case 1:
  2048. X    strcpy(term_options,"300");
  2049. X    term_tbl[term].v_tic = 15;
  2050. X    term_tbl[term].h_tic = 15;
  2051. X    break;
  2052. X  case 2:
  2053. X    strcpy(term_options,"150");
  2054. X    term_tbl[term].v_tic = 8;
  2055. X    term_tbl[term].h_tic = 8;
  2056. X    break;
  2057. X  case 3:
  2058. X    strcpy(term_options,"100");
  2059. X    term_tbl[term].v_tic = 6;
  2060. X    term_tbl[term].h_tic = 6;
  2061. X    break;
  2062. X  case 4:
  2063. X    strcpy(term_options,"75");
  2064. X    term_tbl[term].v_tic = 5;
  2065. X    term_tbl[term].h_tic = 5;
  2066. X    break; 
  2067. X  }
  2068. X  switch(HP_COMP_MODE) {
  2069. X  case 0:
  2070. X    strcat(term_options," no comp");
  2071. X    break;
  2072. X  case 1:
  2073. X    strcat(term_options," RLE");
  2074. X    break;
  2075. X  case 2:
  2076. X    strcat(term_options," TIFF");
  2077. X    break;
  2078. X  case 3:     /* not implemented yet */
  2079. X    strcat(term_options," Delta Row");
  2080. X    break;
  2081. X  }
  2082. X}
  2083. X
  2084. XHP500Cinit()
  2085. X{
  2086. X#ifdef vms
  2087. X    reopen_binary();
  2088. X#endif /* vms */
  2089. X#ifdef PC
  2090. X    reopen_binary();
  2091. X#endif /* PC */
  2092. X}
  2093. X
  2094. XHP500Creset()
  2095. X{
  2096. X#ifdef vms
  2097. X    fflush_binary();
  2098. X#endif
  2099. X}
  2100. X
  2101. X
  2102. X
  2103. X/* HP DeskJet 500c routines */
  2104. X
  2105. XHP500Clinetype(linetype)
  2106. Xint linetype;
  2107. X{
  2108. X    if (linetype < 0)
  2109. X        linetype = 7;
  2110. X    else if (linetype >=8){
  2111. X        linetype %=8;
  2112. X    }
  2113. X    switch (linetype){
  2114. X    case 0 :
  2115. X        linetype = 6;
  2116. X        break;
  2117. X    case 1 :
  2118. X        linetype = 5;
  2119. X        break;
  2120. X    case 2 :
  2121. X        linetype = 3;
  2122. X        break;
  2123. X    case 3 :
  2124. X        linetype = 2;
  2125. X        break;
  2126. X    case 4 :
  2127. X        linetype = 1;
  2128. X        break;
  2129. X    case 5 :
  2130. X        linetype = 4;
  2131. X        break;
  2132. X    case 6 :
  2133. X        linetype = 7;
  2134. X    }
  2135. X    b_setvalue(linetype);
  2136. X
  2137. X}
  2138. X
  2139. X/*
  2140. XHP500Cpoint(x,y,value)
  2141. Xint x;
  2142. Xint y;
  2143. Xint value;
  2144. X{
  2145. X     HP500Clinetype(value);
  2146. X     do_point(x,y,value);
  2147. X}
  2148. X*/
  2149. X
  2150. XHP500Cgraphics()
  2151. X{
  2152. X    switch(hpdj_dpp) {
  2153. X    case 1:
  2154. X        b_charsize(FNT13X25);
  2155. X        term_tbl[term].v_char = FNT13X25_VCHAR;
  2156. X        term_tbl[term].h_char = FNT13X25_HCHAR;
  2157. X        break;
  2158. X    case 2:
  2159. X        b_charsize(FNT13X25);
  2160. X        term_tbl[term].v_char = FNT13X25_VCHAR;
  2161. X        term_tbl[term].h_char = FNT13X25_HCHAR;
  2162. X        break;
  2163. X    case 3:
  2164. X        b_charsize(FNT9X17);
  2165. X        term_tbl[term].v_char = FNT9X17_VCHAR;
  2166. X        term_tbl[term].h_char = FNT9X17_HCHAR;
  2167. X        break;
  2168. X    case 4:
  2169. X        b_charsize(FNT5X9);
  2170. X        term_tbl[term].v_char = FNT5X9_VCHAR;
  2171. X        term_tbl[term].h_char = FNT5X9_HCHAR;
  2172. X        break;
  2173. X    }
  2174. X    /* rotate plot -90 degrees by reversing XMAX and YMAX and by 
  2175. X    setting b_rastermode to TRUE */
  2176. X    b_makebitmap(HP500C_YMAX,HP500C_XMAX,3);
  2177. X    b_rastermode = TRUE;
  2178. X}
  2179. X/*
  2180. X * Run-length encoding for the DeskJet. We have pairs of <count>
  2181. X * <what>, where count goes from 0 (meaning one count) to 255
  2182. X * this might double the size of the image.
  2183. X */
  2184. X
  2185. Xstatic int  compress(op, oe, cp)
  2186. Xunsigned char *op, *oe, *cp;
  2187. X{
  2188. X    unsigned char *ce = cp;
  2189. X    while ( op < oe ) {
  2190. X        unsigned char prevchar;
  2191. X        unsigned char count;
  2192. X
  2193. X        prevchar = *op;     /* remember char */
  2194. X        count = 1;          /* its read the first time */
  2195. X
  2196. X        while ( ++op < oe && *op == prevchar && count < 255){  /* set op to the next char */
  2197. X            count++;                                             /* and count it  */
  2198. X        }
  2199. X        *ce++ = --count; /* were ready, so correct the count */
  2200. X        *ce++ = prevchar; /* and store <what> */
  2201. X    }
  2202. X    *ce = 0;          /* just to be safe   */
  2203. X    return ce - cp;    /* length of  cbufs */
  2204. X}
  2205. X
  2206. Xunsigned char complement(c)
  2207. Xint c;
  2208. X{
  2209. X    return (unsigned char)(256 - c);
  2210. X}
  2211. X
  2212. X
  2213. Xstatic int compress_to_TIFF(op,oe,cp)
  2214. X     unsigned char *op;     /* original pointer */
  2215. X     unsigned char *oe;     /* end of orig string */
  2216. X     unsigned char *cp;     /* pointer for compressed data */
  2217. X{
  2218. X  unsigned char *countposition;
  2219. X  unsigned char *ce = cp;
  2220. X  while ( op < oe ) {
  2221. X    unsigned char prevchar;
  2222. X    unsigned char count;
  2223. X    
  2224. X    prevchar = *op;     /* gelesenes Zeichen aufbewaren */
  2225. X    count = 1;          /* bisher wurde es einmal gelesen */
  2226. X    
  2227. X    while ( ++op < oe && *op == prevchar && count < 128){  
  2228. X      count++;                                           
  2229. X    }
  2230. X    *ce = complement(count-1);
  2231. X    countposition = ce++;           /* remember count for building blocks of literal bytes */
  2232. X    *ce++ = prevchar;           
  2233. X    
  2234. X    if (count < 2) {      
  2235. X      while(op < oe && (prevchar!=*op||*op != *(op + 1))){/* only use rle for at leat 3 equal bytes */
  2236. X    
  2237. X    *ce++ = *op;                                       
  2238. X    count++;                                         
  2239. X    prevchar = *op++;                              
  2240. X    if (op > oe)
  2241. X      puts("FATAL op> oe!!\n");
  2242. X      }
  2243. X      if (op < oe && prevchar == *op){                             
  2244. X    op--;                                           
  2245. X    count--;                                       
  2246. X    ce--;                                         
  2247. X      }
  2248. X      
  2249. X      *countposition = count-1;                           
  2250. X    }
  2251. X  }
  2252. X  return ce - cp;  
  2253. X  
  2254. X}
  2255. X
  2256. Xstatic int
  2257. Xnocompress(op,oe,cp)
  2258. X     unsigned char *op;
  2259. X     unsigned char *oe;
  2260. X     unsigned char *cp;
  2261. X{
  2262. X  unsigned char *ce = cp;
  2263. X  while(op < oe)
  2264. X    *ce++ = *op++;
  2265. X  return ce - cp;
  2266. X}
  2267. X
  2268. X/* 0 compression raster bitmap dump. Compatible with HP DeskJet 500
  2269. X   hopefully compatible with other HP Deskjet printers */
  2270. X
  2271. XHP500Ctext()
  2272. X{
  2273. X  register int x,j,row,count;
  2274. X  char *obuf,*oe,*cbuf,*ce;
  2275. X  
  2276. X  if((obuf = (char *) malloc(100*b_psize))==0)
  2277. X    puts("FATAL!-- couldn't get enough memory for obuf");
  2278. X  if((cbuf = (char *) malloc(400*b_psize))==0)
  2279. X    puts("FATAL!-- couldn't get enough memory for cbuf");
  2280. X  
  2281. X  oe = obuf;
  2282. X  
  2283. X  fprintf(outfile,"\033*t%dR", HP500C_PPI);
  2284. X  fprintf(outfile, "\033*r1A");
  2285. X  fprintf(outfile,"\033*b%1dM",HP_COMP_MODE);
  2286. X  fprintf(outfile, "\033*r%dS",b_ysize);
  2287. X  fprintf(outfile,"\033*r-3U");
  2288. X  
  2289. X  
  2290. X  /* dump bitmap in raster mode */
  2291. X  for (x = b_xsize-1; x >= 0; x--) {
  2292. X    row = (b_ysize/8)-1;
  2293. X    for (j = row; j >= 0; j-- ) {
  2294. X      *oe++ =  (char)(*((*b_p)[j]+x));    
  2295. X    }
  2296. X    switch (HP_COMP_MODE){
  2297. X    case 2 :
  2298. X      count = compress_to_TIFF(obuf,oe,cbuf);
  2299. X      break;
  2300. X    case 1 :
  2301. X      count = compress(obuf,oe,cbuf);
  2302. X      break;
  2303. X    case 0 :
  2304. X      count = nocompress(obuf,oe,cbuf);
  2305. X      break;
  2306. X    }
  2307. X    fprintf(outfile, "\033*b%dV", count);
  2308. X    ce = cbuf;
  2309. X    while(count--)
  2310. X      fputc(*ce++,outfile);
  2311. X    oe = obuf;
  2312. X    
  2313. X    for (j = row; j >=0; j-- ) {
  2314. X      *oe++ = (char)(*((*b_p)[j+b_psize]+x));
  2315. X    }
  2316. X    switch (HP_COMP_MODE){
  2317. X    case 2 :
  2318. X      count = compress_to_TIFF(obuf,oe,cbuf);
  2319. X      break;
  2320. X    case 1 :
  2321. X      count = compress(obuf,oe,cbuf);
  2322. X      break;
  2323. X    case 0 :
  2324. X      count = nocompress(obuf,oe,cbuf);
  2325. X      break;
  2326. X      
  2327. X    }
  2328. X    
  2329. X    fprintf(outfile, "\033*b%dV", count);
  2330. X    ce = cbuf;
  2331. X    while(count--)
  2332. X      fputc(*ce++,outfile);
  2333. X    oe = obuf;
  2334. X    
  2335. X    for (j = row; j >=0; j-- ) {
  2336. X      *oe++ =  (char)(*((*b_p)[j+(2*b_psize)]+x));
  2337. X    }
  2338. X    switch (HP_COMP_MODE){
  2339. X    case 2 :
  2340. X      count = compress_to_TIFF(obuf,oe,cbuf);
  2341. X      break;
  2342. X    case 1 :
  2343. X      count = compress(obuf,oe,cbuf);
  2344. X      break;
  2345. X    case 0 :
  2346. X      count = nocompress(obuf,oe,cbuf);
  2347. X      break;
  2348. X    }
  2349. X    fprintf(outfile, "\033*b%dW", count);
  2350. X    ce = cbuf;
  2351. X    while(count--)
  2352. X      fputc(*ce++,outfile);
  2353. X    oe = obuf;
  2354. X    
  2355. X  }
  2356. X  fprintf(outfile, "\033*rbC");
  2357. X  free(cbuf);
  2358. X  free(obuf);  
  2359. X  b_freebitmap();
  2360. X  
  2361. X#ifndef vms  /* most vms spoolers add a formfeed character */
  2362. X  fprintf(outfile,"\f");
  2363. X#endif /* not vms */
  2364. X}
  2365. X
  2366. X#define HP500Ctext_angle b_text_angle
  2367. X#define HP500Cput_text b_put_text
  2368. X#define HP500Cmove b_move
  2369. X#define HP500Cvector b_vector
  2370. X
  2371. X#endif /* HP500C */
  2372. X
  2373. END_OF_FILE
  2374.   if test 11009 -ne `wc -c <'gnuplot/term/hp500c.trm'`; then
  2375.     echo shar: \"'gnuplot/term/hp500c.trm'\" unpacked with wrong size!
  2376.   fi
  2377.   # end of 'gnuplot/term/hp500c.trm'
  2378. fi
  2379. if test -f 'gnuplot/win/wprinter.c' -a "${1}" != "-c" ; then 
  2380.   echo shar: Will not clobber existing file \"'gnuplot/win/wprinter.c'\"
  2381. else
  2382.   echo shar: Extracting \"'gnuplot/win/wprinter.c'\" \(10679 characters\)
  2383.   sed "s/^X//" >'gnuplot/win/wprinter.c' <<'END_OF_FILE'
  2384. X#ifndef lint
  2385. Xstatic char *RCSid = "$Id: wprinter.c%v 3.50.1.13 1993/08/19 03:21:26 woo Exp $";
  2386. X#endif
  2387. X
  2388. X/* GNUPLOT - win/wprinter.c */
  2389. X/*
  2390. X * Copyright (C) 1992   Maurice Castro, Russell Lang
  2391. X *
  2392. X * Permission to use, copy, and distribute this software and its
  2393. X * documentation for any purpose with or without fee is hereby granted, 
  2394. X * provided that the above copyright notice appear in all copies and 
  2395. X * that both that copyright notice and this permission notice appear 
  2396. X * in supporting documentation.
  2397. X *
  2398. X * Permission to modify the software is granted, but not the right to
  2399. X * distribute the modified code.  Modifications are to be distributed 
  2400. X * as patches to released version.
  2401. X *  
  2402. X * This software is provided "as is" without express or implied warranty.
  2403. X * 
  2404. X *
  2405. X * AUTHORS
  2406. X * 
  2407. X *   Maurice Castro
  2408. X *   Russell Lang
  2409. X * 
  2410. X * Send your comments or suggestions to 
  2411. X *  info-gnuplot@dartmouth.edu.
  2412. X * This is a mailing list; to join it send a note to 
  2413. X *  info-gnuplot-request@dartmouth.edu.  
  2414. X * Send bug reports to
  2415. X *  bug-gnuplot@dartmouth.edu.
  2416. X */
  2417. X
  2418. X/* Dump a file to the printer */
  2419. X
  2420. X#define STRICT
  2421. X#include <windows.h>
  2422. X#include <windowsx.h>
  2423. X#if WINVER >= 0x030a
  2424. X#include <commdlg.h>
  2425. X#endif
  2426. X#ifdef __MSC__
  2427. X#include <memory.h>
  2428. X#else
  2429. X#include <mem.h>
  2430. X#endif
  2431. X#include "wgnuplib.h"
  2432. X#include "wresourc.h"
  2433. X#include "wcommon.h"
  2434. X
  2435. XLPPRINT prlist = NULL;
  2436. X
  2437. XBOOL CALLBACK _export PrintSizeDlgProc(HWND hdlg, UINT wmsg, WPARAM wparam, LPARAM lparam);
  2438. X
  2439. XBOOL CALLBACK _export
  2440. XPrintSizeDlgProc(HWND hdlg, UINT wmsg, WPARAM wparam, LPARAM lparam)
  2441. X{
  2442. X    char buf[8];
  2443. X    LPPRINT lpr;
  2444. X    lpr = (LPPRINT)GetWindowLong(GetParent(hdlg), 4);
  2445. X
  2446. X    switch (wmsg) {
  2447. X        case WM_INITDIALOG:
  2448. X            wsprintf(buf,"%d",lpr->pdef.x);
  2449. X            SetDlgItemText(hdlg, PSIZE_DEFX, buf);
  2450. X            wsprintf(buf,"%d",lpr->pdef.y);
  2451. X            SetDlgItemText(hdlg, PSIZE_DEFY, buf);
  2452. X            wsprintf(buf,"%d",lpr->poff.x);
  2453. X            SetDlgItemText(hdlg, PSIZE_OFFX, buf);
  2454. X            wsprintf(buf,"%d",lpr->poff.y);
  2455. X            SetDlgItemText(hdlg, PSIZE_OFFY, buf);
  2456. X            wsprintf(buf,"%d",lpr->psize.x);
  2457. X            SetDlgItemText(hdlg, PSIZE_X, buf);
  2458. X            wsprintf(buf,"%d",lpr->psize.y);
  2459. X            SetDlgItemText(hdlg, PSIZE_Y, buf);
  2460. X            CheckDlgButton(hdlg, PSIZE_DEF, TRUE);
  2461. X            EnableWindow(GetDlgItem(hdlg, PSIZE_X), FALSE);
  2462. X            EnableWindow(GetDlgItem(hdlg, PSIZE_Y), FALSE);
  2463. X            return TRUE;
  2464. X        case WM_COMMAND:
  2465. X            switch (wparam) {
  2466. X                case PSIZE_DEF:
  2467. X                    EnableWindow(GetDlgItem(hdlg, PSIZE_X), FALSE);
  2468. X                    EnableWindow(GetDlgItem(hdlg, PSIZE_Y), FALSE);
  2469. X                    return FALSE;
  2470. X                case PSIZE_OTHER:
  2471. X                    EnableWindow(GetDlgItem(hdlg, PSIZE_X), TRUE);
  2472. X                    EnableWindow(GetDlgItem(hdlg, PSIZE_Y), TRUE);
  2473. X                    return FALSE;
  2474. X                case IDOK:
  2475. X                    if (SendDlgItemMessage(hdlg, PSIZE_OTHER, BM_GETCHECK, 0, 0L)) {
  2476. X                        SendDlgItemMessage(hdlg, PSIZE_X, WM_GETTEXT, 7, (LPARAM)((LPSTR)buf));
  2477. X                        GetInt(buf, &lpr->psize.x);
  2478. X                        SendDlgItemMessage(hdlg, PSIZE_Y, WM_GETTEXT, 7, (LPARAM)((LPSTR)buf));
  2479. X                        GetInt(buf, &lpr->psize.y);
  2480. X                    }
  2481. X                    else {
  2482. X                        lpr->psize.x = lpr->pdef.x;
  2483. X                        lpr->psize.y = lpr->pdef.y;
  2484. X                    }
  2485. X                    SendDlgItemMessage(hdlg, PSIZE_OFFX, WM_GETTEXT, 7, (LPARAM)((LPSTR)buf));
  2486. X                    GetInt(buf, &lpr->poff.x);
  2487. X                    SendDlgItemMessage(hdlg, PSIZE_OFFY, WM_GETTEXT, 7, (LPARAM)((LPSTR)buf));
  2488. X                    GetInt(buf, &lpr->poff.y);
  2489. X
  2490. X                    if (lpr->psize.x <= 0)
  2491. X                        lpr->psize.x = lpr->pdef.x;
  2492. X                    if (lpr->psize.y <= 0)
  2493. X                        lpr->psize.y = lpr->pdef.y;
  2494. X
  2495. X                    EndDialog(hdlg, IDOK);
  2496. X                    return TRUE;
  2497. X                case IDCANCEL:
  2498. X                    EndDialog(hdlg, IDCANCEL);
  2499. X                    return TRUE;
  2500. X            }
  2501. X            break;
  2502. X    }
  2503. X    return FALSE;
  2504. X}
  2505. X
  2506. X
  2507. X
  2508. X/* GetWindowLong(hwnd, 4) must be available for use */
  2509. XBOOL
  2510. XPrintSize(HDC printer, HWND hwnd, LPRECT lprect)
  2511. X{
  2512. XHDC hdc;
  2513. XDLGPROC lpfnPrintSizeDlgProc ;
  2514. XBOOL status = FALSE;
  2515. XPRINT pr;
  2516. X
  2517. X    SetWindowLong(hwnd, 4, (LONG)((LPPRINT)&pr));
  2518. X    pr.poff.x = 0;
  2519. X    pr.poff.y = 0;
  2520. X    pr.psize.x = GetDeviceCaps(printer, HORZSIZE);
  2521. X    pr.psize.y = GetDeviceCaps(printer, VERTSIZE);
  2522. X    hdc = GetDC(hwnd);
  2523. X    GetClientRect(hwnd,lprect);
  2524. X    pr.pdef.x = MulDiv(lprect->right-lprect->left, 254, 10*GetDeviceCaps(hdc, LOGPIXELSX));
  2525. X    pr.pdef.y = MulDiv(lprect->bottom-lprect->top, 254, 10*GetDeviceCaps(hdc, LOGPIXELSX));
  2526. X    ReleaseDC(hwnd,hdc);
  2527. X#ifdef __DLL__
  2528. X    lpfnPrintSizeDlgProc = (DLGPROC)GetProcAddress(hdllInstance, "PrintSizeDlgProc");
  2529. X#else
  2530. X    lpfnPrintSizeDlgProc = (DLGPROC)MakeProcInstance((FARPROC)PrintSizeDlgProc, hdllInstance);
  2531. X#endif
  2532. X    if (DialogBox (hdllInstance, "PrintSizeDlgBox", hwnd, lpfnPrintSizeDlgProc)
  2533. X        == IDOK) {
  2534. X        lprect->left = MulDiv(pr.poff.x*10, GetDeviceCaps(printer, LOGPIXELSX), 254);
  2535. X        lprect->top = MulDiv(pr.poff.y*10, GetDeviceCaps(printer, LOGPIXELSY), 254);
  2536. X        lprect->right = lprect->left + MulDiv(pr.psize.x*10, GetDeviceCaps(printer, LOGPIXELSX), 254);
  2537. X        lprect->bottom = lprect->top + MulDiv(pr.psize.y*10, GetDeviceCaps(printer, LOGPIXELSY), 254);
  2538. X        status = TRUE;
  2539. X    }
  2540. X#ifndef __DLL__
  2541. X    FreeProcInstance((FARPROC)lpfnPrintSizeDlgProc);
  2542. X#endif
  2543. X    SetWindowLong(hwnd, 4, (LONG)(0L));
  2544. X    return status;
  2545. X}
  2546. X
  2547. Xvoid 
  2548. XPrintRegister(LPPRINT lpr)
  2549. X{
  2550. X    LPPRINT next;
  2551. X    next = prlist;
  2552. X    prlist = lpr;
  2553. X    lpr->next = next;
  2554. X}
  2555. X
  2556. XLPPRINT
  2557. XPrintFind(HDC hdc)
  2558. X{
  2559. X    LPPRINT this;
  2560. X    this = prlist;
  2561. X    while (this && (this->hdcPrn!=hdc)) {
  2562. X        this = this->next;
  2563. X    }
  2564. X    return this;
  2565. X}
  2566. X
  2567. Xvoid
  2568. XPrintUnregister(LPPRINT lpr)
  2569. X{
  2570. X    LPPRINT this, prev;
  2571. X    prev = (LPPRINT)NULL;
  2572. X    this = prlist;
  2573. X    while (this && (this!=lpr)) {
  2574. X        prev = this;
  2575. X        this = this->next;
  2576. X    }
  2577. X    if (this && (this == lpr)) {
  2578. X        /* unhook it */
  2579. X        if (prev)
  2580. X            prev->next = this->next;
  2581. X        else
  2582. X            prlist = this->next;
  2583. X    }
  2584. X}
  2585. X
  2586. X
  2587. X/* GetWindowLong(GetParent(hDlg), 4) must be available for use */
  2588. XBOOL CALLBACK _export
  2589. XPrintDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  2590. X{
  2591. X    LPPRINT lpr;
  2592. X    lpr = (LPPRINT)GetWindowLong(GetParent(hDlg), 4);
  2593. X
  2594. X    switch(message) {
  2595. X        case WM_INITDIALOG:
  2596. X            lpr->hDlgPrint = hDlg;
  2597. X            SetWindowText(hDlg,(LPSTR)lParam);
  2598. X            EnableMenuItem(GetSystemMenu(hDlg,FALSE),SC_CLOSE,MF_GRAYED);
  2599. X            return TRUE;
  2600. X        case WM_COMMAND:
  2601. X            lpr->bUserAbort = TRUE;
  2602. X            lpr->hDlgPrint = 0;
  2603. X            EnableWindow(GetParent(hDlg),TRUE);
  2604. X            EndDialog(hDlg, FALSE);
  2605. X            return TRUE;
  2606. X    }
  2607. X    return FALSE;
  2608. X}
  2609. X
  2610. X    
  2611. XBOOL CALLBACK _export
  2612. XPrintAbortProc(HDC hdcPrn, int code)
  2613. X{
  2614. X    MSG msg;
  2615. X    LPPRINT lpr;
  2616. X    lpr = PrintFind(hdcPrn);
  2617. X
  2618. X    while (!lpr->bUserAbort && PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
  2619. X        if (!lpr->hDlgPrint || !IsDialogMessage(lpr->hDlgPrint,&msg)) {
  2620. X            TranslateMessage(&msg);
  2621. X            DispatchMessage(&msg);
  2622. X        }
  2623. X    }
  2624. X    return(!lpr->bUserAbort);
  2625. X}
  2626. X
  2627. X
  2628. X
  2629. X/* documented in Device Driver Adaptation Guide */
  2630. X/* Prototypes taken from print.h */
  2631. XDECLARE_HANDLE(HPJOB);
  2632. X
  2633. XHPJOB   WINAPI OpenJob(LPSTR, LPSTR, HPJOB);
  2634. Xint     WINAPI StartSpoolPage(HPJOB);
  2635. Xint     WINAPI EndSpoolPage(HPJOB);
  2636. Xint     WINAPI WriteSpool(HPJOB, LPSTR, int);
  2637. Xint     WINAPI CloseJob(HPJOB);
  2638. Xint     WINAPI DeleteJob(HPJOB, int);
  2639. Xint     WINAPI WriteDialog(HPJOB, LPSTR, int);
  2640. Xint     WINAPI DeleteSpoolPage(HPJOB);
  2641. X
  2642. X
  2643. X/* Modeless dialog box - Cancel printing */
  2644. XBOOL CALLBACK _export
  2645. XCancelDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  2646. X{
  2647. X    switch(message) {
  2648. X    case WM_INITDIALOG:
  2649. X        SetWindowText(hDlg,(LPSTR)lParam);
  2650. X        return TRUE;
  2651. X    case WM_COMMAND:
  2652. X        switch(LOWORD(wParam)) {
  2653. X        case IDCANCEL:
  2654. X            DestroyWindow(hDlg);
  2655. X            return TRUE;
  2656. X        }
  2657. X    }
  2658. X    return FALSE;
  2659. X}
  2660. X
  2661. X/* Dialog box to select printer port */
  2662. XBOOL CALLBACK _export
  2663. XSpoolDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  2664. X{
  2665. XLPSTR entry;
  2666. X    switch(message) {
  2667. X    case WM_INITDIALOG:
  2668. X        entry = (LPSTR)lParam;
  2669. X        while (*entry) {
  2670. X        SendDlgItemMessage(hDlg, SPOOL_PORT, LB_ADDSTRING, 0, (LPARAM)entry);
  2671. X        entry += lstrlen(entry)+1;
  2672. X        }
  2673. X        SendDlgItemMessage(hDlg, SPOOL_PORT, LB_SETCURSEL, 0, (LPARAM)0);
  2674. X        return TRUE;
  2675. X    case WM_COMMAND:
  2676. X        switch(LOWORD(wParam)) {
  2677. X        case SPOOL_PORT:
  2678. X#ifdef WIN32
  2679. X            if (HIWORD(wParam)
  2680. X#else
  2681. X            if (HIWORD(lParam)
  2682. X#endif
  2683. X                           == LBN_DBLCLK)
  2684. X            PostMessage(hDlg, WM_COMMAND, IDOK, 0L);
  2685. X            return FALSE;
  2686. X        case IDOK:
  2687. X            EndDialog(hDlg, 1+(int)SendDlgItemMessage(hDlg, SPOOL_PORT, LB_GETCURSEL, 0, 0L));
  2688. X            return TRUE;
  2689. X        case IDCANCEL:
  2690. X            EndDialog(hDlg, 0);
  2691. X            return TRUE;
  2692. X        }
  2693. X    }
  2694. X    return FALSE;
  2695. X}
  2696. X
  2697. X/* Print File to port */
  2698. Xvoid WDPROC
  2699. XDumpPrinter(HWND hwnd, LPSTR szAppName, LPSTR szFileName)
  2700. X{
  2701. X#define PRINT_BUF_SIZE 4096
  2702. Xchar *buffer;
  2703. Xchar *portname;
  2704. XDLGPROC lpfnSpoolProc;
  2705. Xint i, iport;
  2706. XHPJOB hJob;
  2707. XUINT count;
  2708. XHFILE hf;
  2709. Xint error = FALSE;
  2710. XDLGPROC lpfnCancelProc;
  2711. Xlong lsize;
  2712. Xlong ldone;
  2713. Xchar fmt[64];
  2714. Xchar pcdone[10];
  2715. XMSG msg;
  2716. XHWND hDlgModeless;
  2717. X
  2718. X    if ((buffer = LocalAllocPtr(LHND, PRINT_BUF_SIZE)) == (char *)NULL)
  2719. X        return;
  2720. X    /* get list of ports */
  2721. X    GetProfileString("ports", NULL, "", buffer, PRINT_BUF_SIZE);
  2722. X    /* select a port */
  2723. X    lpfnSpoolProc = (DLGPROC)MakeProcInstance((FARPROC)SpoolDlgProc, hdllInstance);
  2724. X    iport = DialogBoxParam(hdllInstance, "SpoolDlgBox", hwnd, lpfnSpoolProc, (LPARAM)buffer);
  2725. X    FreeProcInstance((FARPROC)lpfnSpoolProc);
  2726. X    if (!iport) {
  2727. X        LocalFreePtr((void NEAR *)buffer);
  2728. X        return;
  2729. X    }
  2730. X    portname = buffer;
  2731. X    for (i=1; i<iport && lstrlen(portname)!=0; i++)
  2732. X        portname += lstrlen(portname)+1;
  2733. X    
  2734. X    /* open file and get length */
  2735. X    hf = _lopen(szFileName, READ);
  2736. X    if (hf == HFILE_ERROR) {
  2737. X        LocalFreePtr((void NEAR *)buffer);
  2738. X        return;
  2739. X    }
  2740. X    lsize = _llseek(hf, 0L, 2);
  2741. X    (void)_llseek(hf, 0L, 0);
  2742. X    if (lsize <= 0)
  2743. X        lsize = 1;
  2744. X
  2745. X    hJob = OpenJob(portname, szFileName, (HDC)NULL);
  2746. X    switch ((int)hJob) {
  2747. X        case SP_APPABORT:
  2748. X        case SP_ERROR:
  2749. X        case SP_OUTOFDISK:
  2750. X        case SP_OUTOFMEMORY:
  2751. X        case SP_USERABORT:
  2752. X            _lclose(hf);
  2753. X        LocalFreePtr((void NEAR *)buffer);
  2754. X            return;
  2755. X    }
  2756. X    if (StartSpoolPage(hJob) < 0)
  2757. X        error = TRUE;
  2758. X
  2759. X    ldone = 0;
  2760. X    lpfnCancelProc = (DLGPROC)MakeProcInstance((FARPROC)CancelDlgProc, hdllInstance);
  2761. X    hDlgModeless = CreateDialogParam(hdllInstance, "CancelDlgBox", hwnd, lpfnCancelProc, (LPARAM)szAppName);
  2762. X
  2763. X    while (!error && hDlgModeless && IsWindow(hDlgModeless)
  2764. X          && ((count = _lread(hf, buffer, PRINT_BUF_SIZE))!= 0) ) {
  2765. X        wsprintf(pcdone, "%d%% done", (int)(ldone * 100 / lsize));
  2766. X        SetWindowText(GetDlgItem(hDlgModeless, CANCEL_PCDONE), pcdone);
  2767. X        if (WriteSpool(hJob, buffer, count) < 0)
  2768. X        error = TRUE;
  2769. X        ldone += count;
  2770. X        while (IsWindow(hDlgModeless) && PeekMessage(&msg, hDlgModeless, 0, 0, PM_REMOVE)) {
  2771. X            if (!IsDialogMessage(hDlgModeless, &msg)) {
  2772. X            TranslateMessage(&msg);
  2773. X            DispatchMessage(&msg);
  2774. X        }
  2775. X        }
  2776. X    }
  2777. X    LocalFreePtr((void NEAR *)buffer);
  2778. X    _lclose(hf);
  2779. X
  2780. X    if (!hDlgModeless || !IsWindow(hDlgModeless))
  2781. X        error=TRUE;
  2782. X    if (IsWindow(hDlgModeless))
  2783. X        DestroyWindow(hDlgModeless);
  2784. X    hDlgModeless = 0;
  2785. X    FreeProcInstance((FARPROC)lpfnCancelProc);
  2786. X    EndSpoolPage(hJob);
  2787. X    if (error)
  2788. X        DeleteJob(hJob, 0);
  2789. X    else
  2790. X        CloseJob(hJob);
  2791. X}
  2792. X
  2793. END_OF_FILE
  2794.   if test 10679 -ne `wc -c <'gnuplot/win/wprinter.c'`; then
  2795.     echo shar: \"'gnuplot/win/wprinter.c'\" unpacked with wrong size!
  2796.   fi
  2797.   # end of 'gnuplot/win/wprinter.c'
  2798. fi
  2799. echo shar: End of archive 23 \(of 33\).
  2800. cp /dev/null ark23isdone
  2801. MISSING=""
  2802. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 ; do
  2803.     if test ! -f ark${I}isdone ; then
  2804.     MISSING="${MISSING} ${I}"
  2805.     fi
  2806. done
  2807. if test "${MISSING}" = "" ; then
  2808.     echo You have unpacked all 33 archives.
  2809.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2810. else
  2811.     echo You still must unpack the following archives:
  2812.     echo "        " ${MISSING}
  2813. fi
  2814. exit 0
  2815. exit 0 # Just in case...
  2816.