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

  1. Newsgroups: comp.sources.misc
  2. From: woo@playfair.stanford.edu ("Alexander Woo")
  3. Subject: v40i031:  gnuplot - interactive function plotting utility, Part19/33
  4. Message-ID: <1993Oct22.163708.24314@sparky.sterling.com>
  5. X-Md4-Signature: c1f1089cc31d11f2f5b07d734214409a
  6. Sender: kent@sparky.sterling.com (Kent Landfield)
  7. Organization: Sterling Software
  8. Date: Fri, 22 Oct 1993 16:37:08 GMT
  9. Approved: kent@sparky.sterling.com
  10.  
  11. Submitted-by: woo@playfair.stanford.edu ("Alexander Woo")
  12. Posting-number: Volume 40, Issue 31
  13. Archive-name: gnuplot/part19
  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/configure gnuplot/makefile.emx
  22. #   gnuplot/term/apollo.trm gnuplot/term/mif.trm gnuplot/win/wmenu.c
  23. # Wrapped by kent@sparky on Wed Oct 20 17:14:53 1993
  24. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  25. echo If this archive is complete, you will see the following message:
  26. echo '          "shar: End of archive 19 (of 33)."'
  27. if test -f 'gnuplot/configure' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'gnuplot/configure'\"
  29. else
  30.   echo shar: Extracting \"'gnuplot/configure'\" \(16895 characters\)
  31.   sed "s/^X//" >'gnuplot/configure' <<'END_OF_FILE'
  32. X#!/bin/sh
  33. X# Guess values for system-dependent variables and create Makefiles.
  34. X# Generated automatically using autoconf.
  35. X# Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
  36. X
  37. X# This program is free software; you can redistribute it and/or modify
  38. X# it under the terms of the GNU General Public License as published by
  39. X# the Free Software Foundation; either version 2, or (at your option)
  40. X# any later version.
  41. X
  42. X# This program is distributed in the hope that it will be useful,
  43. X# but WITHOUT ANY WARRANTY; without even the implied warranty of
  44. X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  45. X# GNU General Public License for more details.
  46. X
  47. X# You should have received a copy of the GNU General Public License
  48. X# along with this program; if not, write to the Free Software
  49. X# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  50. X
  51. X# Usage: configure [--srcdir=DIR] [--host=HOST] [--gas] [--nfp] [--no-create]
  52. X#        [--prefix=PREFIX] [--exec-prefix=PREFIX] [--with-PACKAGE] [TARGET]
  53. X# Ignores all args except --srcdir, --prefix, --exec-prefix, --no-create, and
  54. X# --with-PACKAGE unless this script has special code to handle it.
  55. X
  56. X
  57. Xfor arg
  58. Xdo
  59. X  # Handle --exec-prefix with a space before the argument.
  60. X  if test x$next_exec_prefix = xyes; then exec_prefix=$arg; next_exec_prefix=
  61. X  # Handle --host with a space before the argument.
  62. X  elif test x$next_host = xyes; then next_host=
  63. X  # Handle --prefix with a space before the argument.
  64. X  elif test x$next_prefix = xyes; then prefix=$arg; next_prefix=
  65. X  # Handle --srcdir with a space before the argument.
  66. X  elif test x$next_srcdir = xyes; then srcdir=$arg; next_srcdir=
  67. X  else
  68. X    case $arg in
  69. X     # For backward compatibility, also recognize exact --exec_prefix.
  70. X     -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* | --exec=* | --exe=* | --ex=* | --e=*)
  71. X    exec_prefix=`echo $arg | sed 's/[-a-z_]*=//'` ;;
  72. X     -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- | --exec | --exe | --ex | --e)
  73. X    next_exec_prefix=yes ;;
  74. X
  75. X     -gas | --gas | --ga | --g) ;;
  76. X
  77. X     -host=* | --host=* | --hos=* | --ho=* | --h=*) ;;
  78. X     -host | --host | --hos | --ho | --h)
  79. X    next_host=yes ;;
  80. X
  81. X     -nfp | --nfp | --nf) ;;
  82. X
  83. X     -no-create | --no-create | --no-creat | --no-crea | --no-cre | --no-cr | --no-c | --no- | --no)
  84. X        no_create=1 ;;
  85. X
  86. X     -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
  87. X    prefix=`echo $arg | sed 's/[-a-z_]*=//'` ;;
  88. X     -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
  89. X    next_prefix=yes ;;
  90. X
  91. X     -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=* | --s=*)
  92. X    srcdir=`echo $arg | sed 's/[-a-z_]*=//'` ;;
  93. X     -srcdir | --srcdir | --srcdi | --srcd | --src | --sr | --s)
  94. X    next_srcdir=yes ;;
  95. X
  96. X     -with-* | --with-*)
  97. X       package=`echo $arg|sed 's/-*with-//'`
  98. X       # Delete all the valid chars; see if any are left.
  99. X       if test -n "`echo $package|sed 's/[-a-zA-Z0-9_]*//g'`"; then
  100. X         echo "configure: $package: invalid package name" >&2; exit 1
  101. X       fi
  102. X       eval "with_`echo $package|sed s/-/_/g`=1" ;;
  103. X
  104. X     -v | -verbose | --verbose | --verbos | --verbo | --verb | --ver | --ve | --v)
  105. X       verbose=yes ;;
  106. X
  107. X     *) ;;
  108. X    esac
  109. X  fi
  110. Xdone
  111. X
  112. Xtrap 'rm -fr conftest* core; exit 1' 1 3 15
  113. X
  114. X# NLS nuisances.
  115. X# These must not be set unconditionally because not all systems understand
  116. X# e.g. LANG=C (notably SCO).
  117. Xif test "${LC_ALL+set}" = 'set' ; then LC_ALL=C; export LC_ALL; fi
  118. Xif test "${LANG+set}"   = 'set' ; then LANG=C;   export LANG;   fi
  119. X
  120. Xrm -f conftest*
  121. Xcompile='${CC-cc} $CFLAGS $DEFS conftest.c -o conftest $LIBS >/dev/null 2>&1'
  122. X
  123. X# A filename unique to this package, relative to the directory that
  124. X# configure is in, which we can look for to find out if srcdir is correct.
  125. Xunique_file=graphics.c
  126. X
  127. X# Find the source files, if location was not specified.
  128. Xif test -z "$srcdir"; then
  129. X  srcdirdefaulted=yes
  130. X  # Try the directory containing this script, then `..'.
  131. X  prog=$0
  132. X  confdir=`echo $prog|sed 's%/[^/][^/]*$%%'`
  133. X  test "X$confdir" = "X$prog" && confdir=.
  134. X  srcdir=$confdir
  135. X  if test ! -r $srcdir/$unique_file; then
  136. X    srcdir=..
  137. X  fi
  138. Xfi
  139. Xif test ! -r $srcdir/$unique_file; then
  140. X  if test x$srcdirdefaulted = xyes; then
  141. X    echo "configure: Can not find sources in \`${confdir}' or \`..'." 1>&2
  142. X  else
  143. X    echo "configure: Can not find sources in \`${srcdir}'." 1>&2
  144. X  fi
  145. X  exit 1
  146. Xfi
  147. X# Preserve a srcdir of `.' to avoid automounter screwups with pwd.
  148. X# But we can't avoid them for `..', to make subdirectories work.
  149. Xcase $srcdir in
  150. X  .|/*|~*) ;;
  151. X  *) srcdir=`cd $srcdir; pwd` ;; # Make relative path absolute.
  152. Xesac
  153. X
  154. X# Save the original args to write them into config.status later.
  155. Xconfigure_args="$*"
  156. X
  157. X
  158. Xif test -z "$CC"; then
  159. X  # Extract the first word of `gcc', so it can be a program name with args.
  160. X  set dummy gcc; word=$2
  161. X  echo checking for $word
  162. X  IFS="${IFS=     }"; saveifs="$IFS"; IFS="${IFS}:"
  163. X  for dir in $PATH; do
  164. X    test -z "$dir" && dir=.
  165. X    if test -f $dir/$word; then
  166. X      CC="gcc"
  167. X      break
  168. X    fi
  169. X  done
  170. X  IFS="$saveifs"
  171. Xfi
  172. Xtest -z "$CC" && CC="cc"
  173. Xtest -n "$CC" -a -n "$verbose" && echo "    setting CC to $CC"
  174. X
  175. X# Find out if we are using GNU C, under whatever name.
  176. Xcat > conftest.c <<EOF
  177. X#ifdef __GNUC__
  178. X  yes
  179. X#endif
  180. XEOF
  181. X${CC-cc} -E conftest.c > conftest.out 2>&1
  182. Xif egrep yes conftest.out >/dev/null 2>&1; then
  183. X  GCC=1 # For later tests.
  184. Xfi
  185. Xrm -f conftest*
  186. X
  187. X# Make sure to not get the incompatible SysV /etc/install and
  188. X# /usr/sbin/install, which might be in PATH before a BSD-like install,
  189. X# or the SunOS /usr/etc/install directory, or the AIX /bin/install,
  190. X# or the AFS install, which mishandles nonexistent args, or
  191. X# /usr/ucb/install on SVR4, which tries to use the nonexistent group
  192. X# `staff'.  On most BSDish systems install is in /usr/bin, not /usr/ucb
  193. X# anyway.  Sigh.
  194. Xif test "z${INSTALL}" = "z" ; then
  195. X  echo checking for install
  196. X  IFS="${IFS=     }"; saveifs="$IFS"; IFS="${IFS}:"
  197. X  for dir in $PATH; do
  198. X    test -z "$dir" && dir=.
  199. X    case $dir in
  200. X    /etc|/usr/sbin|/usr/etc|/usr/afsws/bin|/usr/ucb) ;;
  201. X    *)
  202. X      if test -f $dir/installbsd; then
  203. X    INSTALL="$dir/installbsd -c" # OSF1
  204. X    INSTALL_PROGRAM='$(INSTALL)'
  205. X    INSTALL_DATA='$(INSTALL) -m 644'
  206. X    break
  207. X      fi
  208. X      if test -f $dir/install; then
  209. X    if grep dspmsg $dir/install >/dev/null 2>&1; then
  210. X      : # AIX
  211. X    else
  212. X      INSTALL="$dir/install -c"
  213. X      INSTALL_PROGRAM='$(INSTALL)'
  214. X      INSTALL_DATA='$(INSTALL) -m 644'
  215. X      break
  216. X    fi
  217. X      fi
  218. X      ;;
  219. X    esac
  220. X  done
  221. X  IFS="$saveifs"
  222. Xfi
  223. XINSTALL=${INSTALL-cp}
  224. XINSTALL_PROGRAM=${INSTALL_PROGRAM-'$(INSTALL)'}
  225. XINSTALL_DATA=${INSTALL_DATA-'$(INSTALL)'}
  226. X
  227. X
  228. X# check whether --with-no-readline was given
  229. Xif test -n "$with_no_readline"; then
  230. X  :
  231. Xelse
  232. X  
  233. X{
  234. Xtest -n "$verbose" && \
  235. Xecho "    defining READLINE"
  236. XDEFS="$DEFS -DREADLINE=1"
  237. X}
  238. X
  239. Xfi
  240. X
  241. X# check whether --with-cwdrc was given
  242. Xif test -n "$with_cwdrc"; then
  243. X  :
  244. Xelse
  245. X  
  246. X{
  247. Xtest -n "$verbose" && \
  248. Xecho "    defining NOCWDRC"
  249. XDEFS="$DEFS -DNOCWDRC=1"
  250. X}
  251. X
  252. Xfi
  253. X
  254. X
  255. X# check whether --with-lasergnu was given
  256. Xif test -n "$with_lasergnu"; then
  257. X  LASERGNU=lasergnu_install
  258. Xelse
  259. X  LASERGNU=lasergnu_noinstall
  260. Xfi
  261. X
  262. X
  263. X
  264. X
  265. X
  266. X# If we find X, set shell vars x_includes and x_libraries to the paths.
  267. Xecho checking for X include and library files with xmkmf
  268. Xrm -fr conftestdir
  269. Xif mkdir conftestdir; then
  270. X  cd conftestdir
  271. X  cat > Imakefile <<\EOF
  272. Xacfindx:
  273. X    @echo "x_includes=$(INCROOT); x_libraries=$(USRLIBDIR)"
  274. XEOF
  275. X  if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
  276. X    eval `make acfindx`
  277. X  fi
  278. X  cd ..
  279. X  rm -fr conftestdir
  280. Xfi
  281. X
  282. Xif test -z "$x_includes" || test -z "$x_libraries"; then
  283. X  X_INCLUDES= X_LIBRARIES= PROGS=
  284. Xelse
  285. X  X_INCLUDES="-I$x_includes" X_LIBRARIES="-L$x_libraries -lX11"
  286. X  PROGS=gnuplot_x11
  287. X  
  288. X{
  289. Xtest -n "$verbose" && \
  290. Xecho "    defining X11"
  291. XDEFS="$DEFS -DX11=1"
  292. X}
  293. X
  294. Xfi
  295. X
  296. Xecho checking for NeXT
  297. Xecho checking how to run the C preprocessor
  298. Xif test -z "$CPP"; then
  299. X  # This must be in double quotes, not single quotes, because CPP may get
  300. X  # substituted into the Makefile and ``${CC-cc}'' will simply confuse
  301. X  # make.  It must be expanded now.
  302. X  CPP="${CC-cc} -E"
  303. X  cat > conftest.c <<EOF
  304. X#include <stdio.h>
  305. XSyntax Error
  306. XEOF
  307. Xerr=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"`
  308. Xif test -z "$err"; then
  309. X  :
  310. Xelse
  311. X  CPP=/lib/cpp
  312. Xfi
  313. Xrm -f conftest*
  314. Xfi
  315. Xtest ".${verbose}" != "." && echo "    setting CPP to $CPP"
  316. X
  317. Xcat > conftest.c <<EOF
  318. X#ifdef __NeXT__
  319. X  yes
  320. X#endif
  321. X
  322. XEOF
  323. Xeval "$CPP \$DEFS conftest.c > conftest.out 2>&1"
  324. Xif egrep "yes" conftest.out >/dev/null 2>&1; then
  325. X  
  326. X{
  327. Xtest -n "$verbose" && \
  328. Xecho "    defining NEXT"
  329. XDEFS="$DEFS -DNEXT=1"
  330. X}
  331. X{
  332. Xtest -n "$verbose" && \
  333. Xecho "    defining NeXT"
  334. XDEFS="$DEFS -DNeXT=1"
  335. X}
  336. X
  337. Xfi
  338. Xrm -f conftest*
  339. X
  340. Xecho checking for OSF/1
  341. Xecho checking for sys/bkmac.h
  342. Xcat > conftest.c <<EOF
  343. X#include <sys/bkmac.h>
  344. XEOF
  345. Xerr=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"`
  346. Xif test -z "$err"; then
  347. X  
  348. X{
  349. Xtest -n "$verbose" && \
  350. Xecho "    defining OSF1"
  351. XDEFS="$DEFS -DOSF1=1"
  352. X}
  353. X{
  354. Xtest -n "$verbose" && \
  355. Xecho "    defining _OSF_SOURCE"
  356. XDEFS="$DEFS -D_OSF_SOURCE=1"
  357. X}
  358. X
  359. Xfi
  360. Xrm -f conftest*
  361. X
  362. Xecho checking for Solaris
  363. Xecho checking for libgenIO.h
  364. Xcat > conftest.c <<EOF
  365. X#include <libgenIO.h>
  366. XEOF
  367. Xerr=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"`
  368. Xif test -z "$err"; then
  369. X  
  370. X{
  371. Xtest -n "$verbose" && \
  372. Xecho "    defining SOLARIS"
  373. XDEFS="$DEFS -DSOLARIS=1"
  374. X}
  375. X
  376. Xfi
  377. Xrm -f conftest*
  378. X
  379. X
  380. Xecho checking for sys/bsdtypes.h
  381. Xcat > conftest.c <<EOF
  382. X#include <sys/bsdtypes.h>
  383. XEOF
  384. Xerr=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"`
  385. Xif test -z "$err"; then
  386. X  
  387. X{
  388. Xtest -n "$verbose" && \
  389. Xecho "    defining BSD_TYPES"
  390. XDEFS="$DEFS -DBSD_TYPES=1"
  391. X}
  392. X
  393. Xfi
  394. Xrm -f conftest*
  395. X
  396. Xhave_hdr=
  397. Xecho checking for termios.h
  398. Xcat > conftest.c <<EOF
  399. X#include <termios.h>
  400. XEOF
  401. Xerr=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"`
  402. Xif test -z "$err"; then
  403. X  
  404. X{
  405. Xtest -n "$verbose" && \
  406. Xecho "    defining TERMIOS"
  407. XDEFS="$DEFS -DTERMIOS=1"
  408. X}
  409. X have_hdr=1
  410. Xfi
  411. Xrm -f conftest*
  412. X
  413. Xif test -z "$have_hdr"; then
  414. X  echo checking for sgtty.h
  415. Xcat > conftest.c <<EOF
  416. X#include <sgtty.h>
  417. XEOF
  418. Xerr=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"`
  419. Xif test -z "$err"; then
  420. X  
  421. X{
  422. Xtest -n "$verbose" && \
  423. Xecho "    defining SGTTY"
  424. XDEFS="$DEFS -DSGTTY=1"
  425. X}
  426. X
  427. Xfi
  428. Xrm -f conftest*
  429. X
  430. Xfi
  431. X
  432. Xecho checking for lgamma
  433. Xcat > conftest.c <<EOF
  434. X#include <ctype.h>
  435. Xint main() { exit(0); }
  436. Xint t() { 
  437. X/* The GNU C library defines this for functions which it implements
  438. X    to always fail with ENOSYS.  Some functions are actually named
  439. X    something starting with __ and the normal name is an alias.  */
  440. X#if defined (__stub_lgamma) || defined (__stub___lgamma)
  441. Xchoke me
  442. X#else
  443. X/* Override any gcc2 internal prototype to avoid an error.  */
  444. Xextern char lgamma(); lgamma();
  445. X#endif
  446. X }
  447. XEOF
  448. Xif eval $compile; then
  449. X  {
  450. Xtest -n "$verbose" && \
  451. Xecho "    defining GAMMA to be lgamma"
  452. XDEFS="$DEFS -DGAMMA=lgamma"
  453. X}
  454. X
  455. Xelse
  456. X  {
  457. Xtest -n "$verbose" && \
  458. Xecho "    defining GAMMA to be gamma"
  459. XDEFS="$DEFS -DGAMMA=gamma"
  460. X}
  461. X
  462. Xfi
  463. Xrm -f conftest*
  464. X
  465. Xecho checking for getcwd
  466. Xcat > conftest.c <<EOF
  467. X#include <ctype.h>
  468. Xint main() { exit(0); }
  469. Xint t() { 
  470. X/* The GNU C library defines this for functions which it implements
  471. X    to always fail with ENOSYS.  Some functions are actually named
  472. X    something starting with __ and the normal name is an alias.  */
  473. X#if defined (__stub_getcwd) || defined (__stub___getcwd)
  474. Xchoke me
  475. X#else
  476. X/* Override any gcc2 internal prototype to avoid an error.  */
  477. Xextern char getcwd(); getcwd();
  478. X#endif
  479. X }
  480. XEOF
  481. Xif eval $compile; then
  482. X  {
  483. Xtest -n "$verbose" && \
  484. Xecho "    defining GETCWD"
  485. XDEFS="$DEFS -DGETCWD=1"
  486. X}
  487. X
  488. Xfi
  489. Xrm -f conftest*
  490. X
  491. Xecho checking for memcpy
  492. Xcat > conftest.c <<EOF
  493. X#include <ctype.h>
  494. Xint main() { exit(0); }
  495. Xint t() { 
  496. X/* The GNU C library defines this for functions which it implements
  497. X    to always fail with ENOSYS.  Some functions are actually named
  498. X    something starting with __ and the normal name is an alias.  */
  499. X#if defined (__stub_memcpy) || defined (__stub___memcpy)
  500. Xchoke me
  501. X#else
  502. X/* Override any gcc2 internal prototype to avoid an error.  */
  503. Xextern char memcpy(); memcpy();
  504. X#endif
  505. X }
  506. XEOF
  507. Xif eval $compile; then
  508. X  {
  509. Xtest -n "$verbose" && \
  510. Xecho "    defining MEMCPY"
  511. XDEFS="$DEFS -DMEMCPY=1"
  512. X}
  513. X
  514. Xfi
  515. Xrm -f conftest*
  516. X
  517. Xecho checking for memset
  518. Xcat > conftest.c <<EOF
  519. X#include <ctype.h>
  520. Xint main() { exit(0); }
  521. Xint t() { 
  522. X/* The GNU C library defines this for functions which it implements
  523. X    to always fail with ENOSYS.  Some functions are actually named
  524. X    something starting with __ and the normal name is an alias.  */
  525. X#if defined (__stub_memset) || defined (__stub___memset)
  526. Xchoke me
  527. X#else
  528. X/* Override any gcc2 internal prototype to avoid an error.  */
  529. Xextern char memset(); memset();
  530. X#endif
  531. X }
  532. XEOF
  533. Xif eval $compile; then
  534. X  {
  535. Xtest -n "$verbose" && \
  536. Xecho "    defining MEMSET"
  537. XDEFS="$DEFS -DMEMSET=1"
  538. X}
  539. X
  540. Xfi
  541. Xrm -f conftest*
  542. X
  543. Xecho checking for setlocale
  544. Xcat > conftest.c <<EOF
  545. X#include <ctype.h>
  546. Xint main() { exit(0); }
  547. Xint t() { 
  548. X/* The GNU C library defines this for functions which it implements
  549. X    to always fail with ENOSYS.  Some functions are actually named
  550. X    something starting with __ and the normal name is an alias.  */
  551. X#if defined (__stub_setlocale) || defined (__stub___setlocale)
  552. Xchoke me
  553. X#else
  554. X/* Override any gcc2 internal prototype to avoid an error.  */
  555. Xextern char setlocale(); setlocale();
  556. X#endif
  557. X }
  558. XEOF
  559. Xif eval $compile; then
  560. X  {
  561. Xtest -n "$verbose" && \
  562. Xecho "    defining XPG3_LOCALE"
  563. XDEFS="$DEFS -DXPG3_LOCALE=1"
  564. X}
  565. X
  566. Xfi
  567. Xrm -f conftest*
  568. X
  569. Xecho checking for setlinebuf
  570. Xcat > conftest.c <<EOF
  571. X#include <ctype.h>
  572. Xint main() { exit(0); }
  573. Xint t() { 
  574. X/* The GNU C library defines this for functions which it implements
  575. X    to always fail with ENOSYS.  Some functions are actually named
  576. X    something starting with __ and the normal name is an alias.  */
  577. X#if defined (__stub_setlinebuf) || defined (__stub___setlinebuf)
  578. Xchoke me
  579. X#else
  580. X/* Override any gcc2 internal prototype to avoid an error.  */
  581. Xextern char setlinebuf(); setlinebuf();
  582. X#endif
  583. X }
  584. XEOF
  585. Xif eval $compile; then
  586. X  {
  587. Xtest -n "$verbose" && \
  588. Xecho "    defining UNIX"
  589. XDEFS="$DEFS -DUNIX=1"
  590. X}
  591. X
  592. Xfi
  593. Xrm -f conftest*
  594. X
  595. X
  596. X
  597. XLIBS_save="${LIBS}"
  598. XLIBS="${LIBS} -lsocket"
  599. Xhave_lib=""
  600. Xecho checking for -lsocket
  601. Xcat > conftest.c <<EOF
  602. X
  603. Xint main() { exit(0); }
  604. Xint t() { main(); }
  605. XEOF
  606. Xif eval $compile; then
  607. X  have_lib="1"
  608. Xfi
  609. Xrm -f conftest*
  610. XLIBS="${LIBS_save}"
  611. Xif test -n "${have_lib}"; then
  612. X   :; LIBS="$LIBS -lsocket"
  613. Xelse
  614. X   :; 
  615. Xfi
  616. X
  617. X
  618. X
  619. X
  620. X{
  621. Xtest -n "$verbose" && \
  622. Xecho "    defining NOVFORK"
  623. XDEFS="$DEFS -DNOVFORK=1"
  624. X}
  625. X
  626. X
  627. X{
  628. Xtest -n "$verbose" && \
  629. Xecho "    defining unix"
  630. XDEFS="$DEFS -Dunix=1"
  631. X}
  632. X
  633. X
  634. Xif test -n "$prefix"; then
  635. X  test -z "$exec_prefix" && exec_prefix='${prefix}'
  636. X  prsub="s%^prefix\\([     ]*\\)=\\([     ]*\\).*$%prefix\\1=\\2$prefix%"
  637. Xfi
  638. Xif test -n "$exec_prefix"; then
  639. X  prsub="$prsub
  640. Xs%^exec_prefix\\([     ]*\\)=\\([     ]*\\).*$%exec_prefix\\1=\\2$exec_prefix%"
  641. Xfi
  642. Xcat >conftest.def <<EOF
  643. X$DEFS
  644. XEOF
  645. Xescape_ampersand_and_backslash='s%[&\\]%\\&%g'
  646. XDEFS=`sed "$escape_ampersand_and_backslash" <conftest.def`
  647. Xrm -f conftest.def
  648. X
  649. Xtrap 'rm -f config.status; exit 1' 1 3 15
  650. Xecho creating config.status
  651. Xrm -f config.status
  652. Xcat > config.status <<EOF
  653. X#!/bin/sh
  654. X# Generated automatically by configure.
  655. X# Run this file to recreate the current configuration.
  656. X# This directory was configured as follows,
  657. X# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
  658. X#
  659. X# $0 $configure_args
  660. X
  661. Xfor arg
  662. Xdo
  663. X  case "\$arg" in
  664. X    -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
  665. X    exec /bin/sh $0 $configure_args ;;
  666. X    *) echo "Usage: config.status --recheck" 2>&1; exit 1 ;;
  667. X  esac
  668. Xdone
  669. X
  670. Xtrap 'rm -f Makefile docs/Makefile docs/latextut/Makefile; exit 1' 1 3 15
  671. XCC='$CC'
  672. XINSTALL='$INSTALL'
  673. XINSTALL_PROGRAM='$INSTALL_PROGRAM'
  674. XINSTALL_DATA='$INSTALL_DATA'
  675. XLASERGNU='$LASERGNU'
  676. XX_INCLUDES='$X_INCLUDES'
  677. XX_LIBRARIES='$X_LIBRARIES'
  678. XPROGS='$PROGS'
  679. XCPP='$CPP'
  680. XLIBS='$LIBS'
  681. Xsrcdir='$srcdir'
  682. XDEFS='$DEFS'
  683. Xprefix='$prefix'
  684. Xexec_prefix='$exec_prefix'
  685. Xprsub='$prsub'
  686. XEOF
  687. Xcat >> config.status <<\EOF
  688. X
  689. Xtop_srcdir=$srcdir
  690. X
  691. X# Allow make-time overrides of the generated file list.
  692. Xtest -n "$gen_files" || gen_files="Makefile docs/Makefile docs/latextut/Makefile"
  693. X
  694. Xfor file in .. $gen_files; do if [ "x$file" != "x.." ]; then
  695. X  srcdir=$top_srcdir
  696. X  # Remove last slash and all that follows it.  Not all systems have dirname.
  697. X  dir=`echo $file|sed 's%/[^/][^/]*$%%'`
  698. X  if test "$dir" != "$file"; then
  699. X    test "$top_srcdir" != . && srcdir=$top_srcdir/$dir
  700. X    test ! -d $dir && mkdir $dir
  701. X  fi
  702. X  echo creating $file
  703. X  rm -f $file
  704. X  echo "# Generated automatically from `echo $file|sed 's|.*/||'`.in by configure." > $file
  705. X  sed -e "
  706. X$prsub
  707. Xs%@CC@%$CC%g
  708. Xs%@INSTALL@%$INSTALL%g
  709. Xs%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
  710. Xs%@INSTALL_DATA@%$INSTALL_DATA%g
  711. Xs%@LASERGNU@%$LASERGNU%g
  712. Xs%@X_INCLUDES@%$X_INCLUDES%g
  713. Xs%@X_LIBRARIES@%$X_LIBRARIES%g
  714. Xs%@PROGS@%$PROGS%g
  715. Xs%@CPP@%$CPP%g
  716. Xs%@LIBS@%$LIBS%g
  717. Xs%@srcdir@%$srcdir%g
  718. Xs%@DEFS@%$DEFS%
  719. X" $top_srcdir/${file}.in >> $file
  720. Xfi; done
  721. X
  722. Xexit 0
  723. XEOF
  724. Xchmod +x config.status
  725. Xtest -n "$no_create" || ./config.status
  726. X
  727. END_OF_FILE
  728.   if test 16895 -ne `wc -c <'gnuplot/configure'`; then
  729.     echo shar: \"'gnuplot/configure'\" unpacked with wrong size!
  730.   fi
  731.   chmod +x 'gnuplot/configure'
  732.   # end of 'gnuplot/configure'
  733. fi
  734. if test -f 'gnuplot/makefile.emx' -a "${1}" != "-c" ; then 
  735.   echo shar: Will not clobber existing file \"'gnuplot/makefile.emx'\"
  736. else
  737.   echo shar: Extracting \"'gnuplot/makefile.emx'\" \(3535 characters\)
  738.   sed "s/^X//" >'gnuplot/makefile.emx' <<'END_OF_FILE'
  739. X#
  740. X# Make file for use with emx-0.8f/gcc and ndmake 4.5
  741. X# for compiling for MS-DOS
  742. X# 
  743. X# This version has had very little testing.
  744. X
  745. XEMXPATH = c:/emx
  746. X
  747. X# uncomment the following two lines if you have 
  748. X# Johannes Martin's SVGA/VESA extensions
  749. X# A VESA 1.2 compatible display, and the vesa_emx.com TSR are required.
  750. X# "set term vgal" needs vesa_ibm.com with svgakit/vesa_emx version 1.2.
  751. X# VESA = -DEMXVESA
  752. X# VESALIB = -lvesa
  753. X
  754. X# where to place gnuplot.gih helpfile
  755. XHELPFILE = gnuplot.gih
  756. X
  757. XCFLAGS = -c -O2 -DMSDOS -DREADLINE
  758. X
  759. X# see other terminal defines in term.h
  760. XTERMFLAGS = -DEMXVGA $(VESA)
  761. X
  762. XOBJS =     bitmap.o command.o contour.o eval.o graphics.o graph3d.o \
  763. X    help.o internal.o misc.o parse.o plot.o readline.o specfun.o \
  764. X    scanner.o setshow.o standard.o term.o util.o version.o \
  765. X        binary.o gnubin.o
  766. X
  767. XCSOURCE5 = term\aed.trm term\cgi.trm term/dumb.trm term/dxf.trm term\dxy.trm \
  768. X    term\eepic.trm term\epson.trm term\fig.trm term\hp26.trm \
  769. X    term\hp2648.trm term\hpgl.trm term\hpljii.trm 
  770. XCSOURCE6 = term\impcodes.h term\imagen.trm term\object.h \
  771. X    term\iris4d.trm term\kyo.trm term\latex.trm term/pbm.trm term\pm.trm 
  772. XCSOURCE7 = term\post.trm term\qms.trm term\regis.trm term\sun.trm \
  773. X    term\t410x.trm term\tek.trm term\unixpc.trm term\unixplot.trm \
  774. X    term\v384.trm term\x11.trm term\emxvga.trm
  775. XCSOURCE8 = contour.c
  776. X
  777. Xall: gnuplotx.exe $(HELPFILE)
  778. X
  779. X# default rules
  780. XCCC = gcc $(CFLAGS) -o $*.o $*.c
  781. X
  782. Xgnuplotx.exe: $(OBJS) emxlink.rsp
  783. X        gcc -o gnuplot @emxlink.rsp -lm -lgraph $(VESALIB)
  784. X    emxbind $(EMXPATH)/bin/emx.exe gnuplot gnuplotx.exe -p -acmi
  785. X
  786. Xemxlink.rsp: makefile.emx
  787. X    echo bitmap.o> emxlink.rsp
  788. X    echo command.o>> emxlink.rsp
  789. X    echo contour.o>> emxlink.rsp
  790. X    echo eval.o>> emxlink.rsp
  791. X    echo graphics.o>> emxlink.rsp
  792. X    echo graph3d.o>> emxlink.rsp
  793. X    echo help.o>> emxlink.rsp
  794. X    echo internal.o>> emxlink.rsp
  795. X    echo misc.o>> emxlink.rsp
  796. X    echo parse.o>> emxlink.rsp
  797. X    echo plot.o>> emxlink.rsp
  798. X    echo readline.o>> emxlink.rsp
  799. X    echo specfun.o>> emxlink.rsp
  800. X    echo scanner.o>> emxlink.rsp
  801. X    echo setshow.o>> emxlink.rsp
  802. X    echo standard.o>> emxlink.rsp
  803. X    echo term.o>> emxlink.rsp
  804. X    echo util.o>> emxlink.rsp
  805. X    echo version.o>> emxlink.rsp
  806. X    echo binary.o>> emxlink.rsp
  807. X    echo gnubin.o>> emxlink.rsp
  808. X
  809. Xbitmap.o: bitmap.c bitmap.h plot.h
  810. X    $(CCC)
  811. X
  812. Xbinary.o: binary.c plot.h
  813. X    $(CCC)
  814. X
  815. Xgnubin.o: gnubin.c plot.h
  816. X    $(CCC)
  817. X
  818. Xcommand.o: command.c plot.h setshow.h help.h
  819. X    $(CCC) -DHELPFILE=\"$(HELPFILE)\"
  820. X
  821. Xcontour.o: contour.c plot.h
  822. X    $(CCC)
  823. X
  824. Xeval.o: eval.c plot.h
  825. X    $(CCC)
  826. X
  827. Xgraphics.o: graphics.c plot.h setshow.h
  828. X    $(CCC)
  829. X
  830. Xgraph3d.o: graph3d.c plot.h setshow.h
  831. X    $(CCC)
  832. X
  833. Xhelp.o: help.c plot.h help.h
  834. X    $(CCC)
  835. X
  836. Xinternal.o: internal.c plot.h
  837. X    $(CCC)
  838. X
  839. Xmisc.o: misc.c plot.h setshow.h
  840. X    $(CCC)
  841. X
  842. Xparse.o: parse.c plot.h
  843. X    $(CCC)
  844. X
  845. Xplot.o: plot.c plot.h setshow.h
  846. X    $(CCC)
  847. X
  848. Xreadline.o: readline.c
  849. X    $(CCC)
  850. X
  851. Xscanner.o: scanner.c plot.h
  852. X    $(CCC)
  853. X
  854. Xsetshow.o: setshow.c plot.h setshow.h
  855. X    $(CCC)
  856. X
  857. Xspecfun.o: specfun.c plot.h
  858. X    $(CCC)
  859. X
  860. Xstandard.o: standard.c plot.h
  861. X    $(CCC)
  862. X
  863. Xterm.o: term.c term.h plot.h setshow.h bitmap.h $(CSOURCE5) $(CSOURCE6) $(CSOURCE7)
  864. X    $(CCC) $(TERMFLAGS) -Iterm
  865. X
  866. Xutil.o: util.c plot.h
  867. X    $(CCC)
  868. X
  869. Xversion.o: version.c
  870. X    $(CCC)
  871. X
  872. X# convert gnuplot.doc to gnuplot.gih
  873. Xdoc2gih.exe: docs\doc2gih.c
  874. X    gcc -o doc2gih  docs/doc2gih.c
  875. X    emxbind $(EMXPATH)/bin/emx.exe doc2gih doc2gih.exe
  876. X
  877. X$(HELPFILE): doc2gih.exe docs\gnuplot.doc
  878. X    doc2gih docs\gnuplot.doc $(HELPFILE)
  879. X
  880. Xclean:
  881. X    del *.o
  882. X    del emxlink.rsp
  883. X    del gnuplot
  884. X    del doc2gih
  885. X
  886. X# veryclean target - remove all files created by the makefile
  887. X
  888. Xveryclean: clean
  889. X    del gnuplot.exe
  890. X    del doc2gih.exe
  891. X    del gnuplot.gih
  892. X
  893. X
  894. END_OF_FILE
  895.   if test 3535 -ne `wc -c <'gnuplot/makefile.emx'`; then
  896.     echo shar: \"'gnuplot/makefile.emx'\" unpacked with wrong size!
  897.   fi
  898.   # end of 'gnuplot/makefile.emx'
  899. fi
  900. if test -f 'gnuplot/term/apollo.trm' -a "${1}" != "-c" ; then 
  901.   echo shar: Will not clobber existing file \"'gnuplot/term/apollo.trm'\"
  902. else
  903.   echo shar: Extracting \"'gnuplot/term/apollo.trm'\" \(17140 characters\)
  904.   sed "s/^X//" >'gnuplot/term/apollo.trm' <<'END_OF_FILE'
  905. X/*
  906. X * $Id: apollo.trm%v 3.50 1993/07/09 05:35:24 woo Exp $
  907. X *
  908. X */
  909. X
  910. X/* GNUPLOT - apollo.trm */
  911. X/*
  912. X    Apollo terminal driver for GNUplot.
  913. X
  914. X    Open a pad for the graphics, and use GPR routines.  For additional
  915. X    speed, we do the graphics to a separate bitmap, and the blt the
  916. X    entire bitmap to the display.  When the user specifies an output
  917. X    file name, however, we draw directly to the screen, so the graphics
  918. X    are written to the file correctly.  Thus, the user can save the
  919. X    graphics in a file, to be viewed later.  If we try the bitmap
  920. X    trick, it looks funny.
  921. X
  922. X    Ray Lischner (uunet!mntgfx!lisch)
  923. X    4 October 1989    file created for GNUplot 1.1
  924. X    26 March 1990    updated for GNUplot 2.0
  925. X    30 October 1991    fixed minor problem in apollo_tic_sizes
  926. X*/
  927. X
  928. X#include <apollo/base.h>
  929. X#include <apollo/error.h>
  930. X#include <apollo/pad.h>
  931. X#include <apollo/gpr.h>
  932. X
  933. X/* default tick sizes for small windows */
  934. X#define APOLLO_VTIC     6
  935. X#define APOLLO_HTIC     6    
  936. X
  937. X/* issue an error message, using additional text "s" */
  938. X#define apollo_error(s)    error_$print_name(status, (s), strlen(s))
  939. X
  940. X/* if "status" indicates an error, then issue an error message */
  941. X#define apollo_check(s)    if (status.all != status_$ok) apollo_error(s)
  942. X
  943. Xstatic ios_$id_t stream = -1;           /* the stream for the pad */
  944. Xstatic gpr_$bitmap_desc_t screen_desc;  /* the screen's bitmap */
  945. Xstatic gpr_$bitmap_desc_t bitmap_desc;  /* the graphics bitmap */
  946. Xstatic gpr_$attribute_desc_t attr;      /* attribute block for saved bitmap */
  947. Xstatic short draw_width;                /* default GPR draw width */
  948. Xstatic name_$long_pname_t font_name;    /* font path name */
  949. Xstatic int APOLLO_XMAX, APOLLO_YMAX;    /* window size */
  950. Xstatic boolean use_bitmap;              /* use a separate bitmap? */
  951. X
  952. X/* return whether stdout is a DM pad */
  953. Xapollo_isa_pad()
  954. X{
  955. X    status_$t status;
  956. X    pad_$isa(1, &status);
  957. X    return (status.all == status_$ok);
  958. X}
  959. X
  960. X/*
  961. X    Find out what the default font is for the pad, and save the
  962. X    character height and width information.
  963. X
  964. X    Note that we must save the font file name because we need
  965. X    to reload the font file everytime the window changes size.
  966. X*/
  967. Xstatic void apollo_font_info(struct termentry* tbl, char* fname)
  968. X{
  969. X    short fwidth, fheight, flen;
  970. X    status_$t status;
  971. X
  972. X    /* get the font size & update the termentry table */
  973. X    pad_$inq_font(stream, &fwidth, &fheight, fname, name_$long_pnamlen_max,
  974. X          &flen, &status);
  975. X    apollo_check("inq_font");
  976. X    fname[flen] = '\0';
  977. X
  978. X    tbl->v_char = fheight;
  979. X    tbl->h_char = fwidth;
  980. X}
  981. X
  982. X/*
  983. X    Initialize all the GPR stuff.  To save time, we draw into a separate
  984. X    bitmap, and then blt it onto the screen all at once.  This results
  985. X    in 5-10 times speed-up in the graphics, with only a little
  986. X    complication.  Most of the complication is right here, making sure
  987. X    we allocate the right bitmaps, etc., in the right order.  The rest
  988. X    is in APOLLO_text(), where we actually BLT the bitmap onto the screen.
  989. X    Everything else is the same.
  990. X
  991. X    The bitmaps have the same size as the window.  If the window changes
  992. X    size, then the bitmaps retain the same size, so the user sees part
  993. X    of the plot or a lot of space around the plot.  Drawing a new plot,
  994. X    or replotting the previous one causes APOLLO_graphics() to see if
  995. X    the window has changed size, in which case the GPR is terminated,
  996. X    and this routine is called again.  Thus, make sure any changes
  997. X    preserve this ability.  Anything that should only be done once
  998. X    to the pad should be handled by APOLLO_init().
  999. X
  1000. X    By the way, we save the current draw width, to be used later
  1001. X    for drawing extra wide lines.  This way we don't need to know
  1002. X    anything about the current output device characteristics;
  1003. X    we can just draw the default width, or twice the default width, etc.
  1004. X*/
  1005. Xstatic void apollo_gpr_init(struct termentry* tbl, pad_$window_desc_t* window)
  1006. X{
  1007. X    gpr_$offset_t size;
  1008. X    short fontid;
  1009. X    status_$t status;
  1010. X
  1011. X    size.x_size = APOLLO_XMAX = tbl->xmax = window->width;
  1012. X    size.y_size = APOLLO_YMAX = tbl->ymax = window->height;
  1013. X
  1014. X    /* now initialize GPR */
  1015. X    gpr_$init(gpr_$frame, stream, size, 1, &screen_desc, &status);
  1016. X    apollo_check("gpr_$init");
  1017. X
  1018. X    if (use_bitmap)
  1019. X    {
  1020. X    /* allocate the bitmap and its attribute block */
  1021. X    gpr_$allocate_attribute_block(&attr, &status);
  1022. X    apollo_check("allocate_attribute_block");
  1023. X
  1024. X    gpr_$allocate_bitmap(size, 1, attr, &bitmap_desc, &status);
  1025. X    apollo_check("allocate_bitmap");
  1026. X
  1027. X    gpr_$set_bitmap(bitmap_desc, &status);
  1028. X    apollo_check("set_bitmap");
  1029. X    }
  1030. X
  1031. X    /* set the font file */
  1032. X    gpr_$load_font_file(font_name, strlen(font_name), &fontid, &status);
  1033. X    apollo_check(font_name);
  1034. X
  1035. X    gpr_$set_text_font(fontid, &status);
  1036. X    apollo_check("set_text_font");
  1037. X
  1038. X    gpr_$inq_draw_width(&draw_width, &status);
  1039. X    apollo_check("inq_draw_width");
  1040. X}
  1041. X
  1042. X/*
  1043. X    Determine the tick sizes to be used for labelling borders.
  1044. X    By default, we use 1/50 of the window size, which looks nice to me.
  1045. X    If this makes the ticks too small, however, we use a minimum
  1046. X    size, to make sure they are visible.  The minimum size was also
  1047. X    determined experimentally.
  1048. X
  1049. X    Feel free to changes the sizes to something you feel looks better.
  1050. X
  1051. X    This routine must be called after apollo_gpr_init(), because we
  1052. X    need to know the window size, as stored in the termentry table.
  1053. X*/
  1054. Xstatic void apollo_tic_sizes(struct termentry* tbl)
  1055. X{
  1056. X    /* base the tick size on the window size */
  1057. X    tbl->v_tic = tbl->ymax / 50;
  1058. X    if (tbl->v_tic < APOLLO_VTIC)
  1059. X    tbl->v_tic = APOLLO_VTIC;
  1060. X    tbl->h_tic = tbl->xmax / 50;
  1061. X    if (tbl->h_tic < APOLLO_HTIC)
  1062. X    tbl->h_tic = APOLLO_HTIC;
  1063. X}
  1064. X
  1065. X/*
  1066. X    Terminate the GPR.  This is called whenever the window size
  1067. X    changes, and we need to reinitialize the GPR.  I assume that
  1068. X    calling gpr_$terminate() also deallocates the bitmaps and
  1069. X    attribute blocks because deallocating the screen's bitmap
  1070. X    causes terminate() to think GPR has already been terminated.
  1071. X
  1072. X    Since this can be called many times, make sure nothing
  1073. X    drastic is done here, like closing the stream to the pad.
  1074. X    The only actions should be those that will be reinitialized
  1075. X    by apollo_gpr_init().
  1076. X*/
  1077. Xstatic void apollo_gpr_terminate()
  1078. X{
  1079. X    status_$t status;
  1080. X
  1081. X    gpr_$terminate(false, &status);
  1082. X    apollo_check("terminate");
  1083. X}
  1084. X
  1085. X/*
  1086. X    Initialize the graphics.  This is called once, so we do things
  1087. X    here that should be done exactly once, such as opening the window.
  1088. X    I like to give windows names, so it is obvious what the window's
  1089. X    contents are, but this causes a transcript to be kept in a file
  1090. X    whose name is the window's name.  This might be nice in some
  1091. X    circumstances, but to me it is a nuisance, so the file is
  1092. X    deleted immediately.  The name is unlikely to appear normally,
  1093. X    so there should be little interference with users' normal files.
  1094. X    If the user has explicitly set the output file, however, then
  1095. X    we use that name, and do not delete the file.  Thus, the
  1096. X    user can get a metafile of the plot.  We can tell if the
  1097. X    output file has been set because outstr is "STDOUT".  Otherwise,
  1098. X    outstr is the filename, in single quotes.  We need to strip
  1099. X    the quotes to make the file name.
  1100. X
  1101. X    The DM defaults are used for window sizes and positions.  If
  1102. X    the user doesn't like it, he or she can change is and issue
  1103. X    a replot command (assuming a plot has already been generated).
  1104. X
  1105. X    Note, also, that we must call pad_$set_scale() or else
  1106. X    pad_$inq_windows() returns scaled values, which is not what
  1107. X    we want.  Setting the scale to one (1) turns off the scaling,
  1108. X    so we get real pixel sizes.
  1109. X
  1110. X    Finally, we get the name and size of the default font.  The
  1111. X    name is kept, as explained earlier.  Then we can initialize
  1112. X    the GPR stuff.
  1113. X
  1114. X    Note that there is a way that APOLLO_init() gets called more
  1115. X    than once.  If the user issues the "set terminal apollo" command
  1116. X    more than once, then this is called, so we need to make sure
  1117. X    that we do not keep creating windows.
  1118. X
  1119. X    An alternative strategy would be to interpret multiple "set term
  1120. X    apollo"s to mean create multiple windows.  The user could only
  1121. X    access the most recent window because GNUplot has no concept of
  1122. X    multiple terminals.  The user would, in fact, have no way of
  1123. X    removing old windows because they are still active.  We could try
  1124. X    catching keyboard events to see if the user presses EXIT, but I do
  1125. X    not want to start getting into that mess.  If the user really
  1126. X    wants this kind of functionality, then he or she can run gnuplot
  1127. X    multiple times.  I think that is a lot cleaner, don't you?
  1128. X*/
  1129. XAPOLLO_init()
  1130. X{
  1131. X    /* only initialize once */
  1132. X    if (stream == -1)
  1133. X    {
  1134. X    extern char outstr[];
  1135. X    struct termentry* tbl;
  1136. X    pad_$window_desc_t window;
  1137. X    name_$long_name_t wname;
  1138. X    short wnum;            /* junk needed by pad_$inq_windows() */
  1139. X    boolean unlink_wname;
  1140. X    status_$t status;
  1141. X
  1142. X    tbl = &term_tbl[term];
  1143. X
  1144. X    /* make the window name unique, with "gnuplot" in the label */
  1145. X    if (strcmp(outstr, "STDOUT") == 0)
  1146. X    {
  1147. X        sprintf(wname, "gnuplot-%d", getpid());
  1148. X        unlink_wname = true;
  1149. X    }
  1150. X    else
  1151. X    {
  1152. X        /* strip the single quotes around the file name */
  1153. X        strcpy(wname, outstr + 1);
  1154. X        wname[strlen(wname) - 1] = '\0';
  1155. X        unlink_wname = false;
  1156. X    }
  1157. X
  1158. X    use_bitmap = unlink_wname;
  1159. X
  1160. X    /* use the default window position and size */
  1161. X    window.top = window.left = window.width = window.height = 0;
  1162. X    pad_$create_window(wname, strlen(wname), pad_$transcript, 1, window,
  1163. X               &stream, &status);
  1164. X    apollo_check("create_window");
  1165. X
  1166. X    /* if this is not the user's name, then delete the file */
  1167. X    if (unlink_wname)
  1168. X        unlink(wname);
  1169. X
  1170. X    /* remove all scaling, to revert to pixel units, not char. units */
  1171. X    pad_$set_scale(stream, 1, 1, &status);
  1172. X    apollo_check("set_scale");
  1173. X
  1174. X    /* get rid of the window when the program exits */
  1175. X    pad_$set_auto_close(stream, 1, true, &status);
  1176. X    apollo_check("set_auto_close");
  1177. X
  1178. X    /* now determine the window size & update the termentry table */
  1179. X    pad_$inq_windows(stream, &window, 1, &wnum, &status);
  1180. X    apollo_check("inq_windows");
  1181. X
  1182. X    /* the order of the next three calls is important */
  1183. X    apollo_font_info(tbl, font_name);
  1184. X    apollo_gpr_init(tbl, &window);
  1185. X    apollo_tic_sizes(tbl);
  1186. X    }
  1187. X}
  1188. X
  1189. X/*
  1190. X    Prepare for graphics output.  Since this is what the user wants to
  1191. X    do when preparing a new plot, this is a meaningful time to see if
  1192. X    the window has changed size.  Thus, we avoid mucking about with
  1193. X    asynchronous traps, and we avoid the bigger problem of dealing
  1194. X    with a half-finished plot when the window changes size.
  1195. X
  1196. X    Simply put, get the current window size, and if it has changed,
  1197. X    then get rid of the old bitmaps, etc., and allocate new ones at
  1198. X    the new size.  We also need to update the termentry table.
  1199. X    If the window stays the same size, then just clear it.
  1200. X*/
  1201. Xstatic void apollo_redo_window(pad_$window_desc_t* window)
  1202. X{
  1203. X    struct termentry* tbl = &term_tbl[term];
  1204. X    status_$t status;
  1205. X
  1206. X    /* the order of the following calls is important */
  1207. X    apollo_gpr_terminate();
  1208. X    apollo_gpr_init(tbl, window);
  1209. X    apollo_tic_sizes(tbl);
  1210. X}
  1211. X
  1212. XAPOLLO_graphics()
  1213. X{
  1214. X    pad_$window_desc_t window;
  1215. X    short wnum;
  1216. X    status_$t status;
  1217. X
  1218. X    pad_$inq_windows(stream, &window, 1, &wnum, &status);
  1219. X    apollo_check("inq_windows");
  1220. X
  1221. X    if (window.width != APOLLO_XMAX || window.height != APOLLO_YMAX)
  1222. X    apollo_redo_window(&window);
  1223. X    else
  1224. X    {
  1225. X    gpr_$clear(0, &status);
  1226. X    apollo_check("clear");
  1227. X    }
  1228. X}
  1229. X
  1230. X/* set a line type:
  1231. X   -2 heavy, solid    (border)
  1232. X   -1 heavy, dotted    (axis)
  1233. X   0  solid        (normal)
  1234. X   1  dots        (other curves)
  1235. X   2  short dash
  1236. X   3  long dash
  1237. X   4  dash dot
  1238. X
  1239. X   Apparently, GPUplot draws a lot of short line segments, and each
  1240. X   one starts a new pattern.  This makes the patterns somewhat useless,
  1241. X   but one can still tell the difference between solid, dotted, and
  1242. X   dashed lines.  The utility of fancier styles is limited, however.
  1243. X
  1244. X   On a color workstation, we should use different colors, but I
  1245. X   don't have one.
  1246. X*/
  1247. X
  1248. X/*
  1249. X    To draw different line styles on an Apollo, we use two different
  1250. X    parameters.  One is a line thickness, which is just an integral
  1251. X    multiple of the default line thickness.  The second is a 16-bit
  1252. X    pattern that is repeated.  We could use fancier patterns, since
  1253. X    GPR supports up to 64-bits, but, as I explained earlier, this
  1254. X    really does not buy us anything.
  1255. X
  1256. X    I used patterns that do not start with all bits on because
  1257. X    GNUplot seems to use lots of short line segments to draw
  1258. X    a curve, and this might make a very curvey plot seem like
  1259. X    a solid line, regardless of pattern.  I don't want to start
  1260. X    with too many zeros, however, or else the curve might not
  1261. X    appear at all!  All the patterns, therefore, start with one
  1262. X    bit on.  The rest of the bits determine the true pattern.
  1263. X
  1264. X    By examining graphics.c, we see that linetype -2 is used exclusively
  1265. X    for the border, -1 for the axes, and the non-negative integers for
  1266. X    the curves.  We use heavy lines for the border and axes, and normal
  1267. X    width lines for the curves.
  1268. X
  1269. X    Since C arrays start at zero, make sure all the offsets are correct,
  1270. X    so that it is easy to access the array with -2...n linetypes.
  1271. X*/
  1272. X
  1273. Xtypedef struct {
  1274. X    short width;
  1275. X    short pattern;
  1276. X} APOLLO_LINE;
  1277. X
  1278. Xstatic APOLLO_LINE apollo_lines[] = {
  1279. X    { 2, ~0 },        /* heavy, solid */
  1280. X    { 2, 0x6666 },    /* heavy, dotted */
  1281. X    { 1, ~0 },        /* normal */
  1282. X    { 1, 0xAAAA },    /* dotted */
  1283. X    { 1, 0xC3C3 },    /* short dash */
  1284. X    { 1, 0xE01F },    /* long dash */
  1285. X    { 1, 0x87F8 },    /* dash dot */
  1286. X    { 1, 0x6666 },    /* big dots */
  1287. X};
  1288. X
  1289. X#define BITS_PER_LINETYPE    16
  1290. X
  1291. X/* apollo_line(-2) is the border style, etc. */
  1292. X#define apollo_line(x)        apollo_lines[(x)+2]
  1293. X#define apollo_pattern(x)    &apollo_line(x).pattern
  1294. X#define apollo_width(x)        apollo_line(x).width
  1295. X
  1296. X#define APOLLO_MIN_LINE        (-2)
  1297. X#define APOLLO_MAX_LINE        (sizeof(apollo_lines)/sizeof(*apollo_lines)-2)
  1298. X
  1299. X/* set the line style */
  1300. XAPOLLO_linetype(ltype)
  1301. Xint ltype;
  1302. X{
  1303. X    status_$t status;
  1304. X
  1305. X    if (ltype < APOLLO_MIN_LINE)
  1306. X    ltype = APOLLO_MIN_LINE;
  1307. X    if (ltype >= APOLLO_MAX_LINE)
  1308. X    ltype %= APOLLO_MAX_LINE;
  1309. X
  1310. X    gpr_$set_line_pattern(1, apollo_pattern(ltype), BITS_PER_LINETYPE, &status);
  1311. X    apollo_check("set_line_pattern");
  1312. X
  1313. X    gpr_$set_draw_width(draw_width * apollo_width(ltype), &status);
  1314. X    apollo_check("set_draw_width");
  1315. X}
  1316. X
  1317. X/* issue an error message that includes an (x, y) coordinate */
  1318. Xstatic void apollo_xy_error(char* s, int x, int y, status_$t status)
  1319. X{
  1320. X    char buffer[128];
  1321. X
  1322. X    sprintf(buffer, "%s(%d, %d)", s, x, y);
  1323. X    apollo_error(buffer);
  1324. X}
  1325. X
  1326. X#define apollo_xy_check(s)    \
  1327. X    if (status.all != status_$ok) apollo_xy_error((s), x, y, status)
  1328. X
  1329. X/*
  1330. X    Note that GNUplot and GPR have reversed ideas of where the Y origin is.
  1331. X    This means subtracting the Y coordinate from Y max.
  1332. X*/
  1333. X#define plot_to_gpr(y)        (APOLLO_YMAX - (y))
  1334. X
  1335. X/* move to a new position */
  1336. XAPOLLO_move(unsigned int x, unsigned int y)
  1337. X{
  1338. X    status_$t status;
  1339. X
  1340. X    gpr_$move((gpr_$coordinate_t) x, plot_to_gpr(y), &status);
  1341. X    apollo_xy_check("move");
  1342. X}
  1343. X
  1344. X/* draw a line to a new position */
  1345. XAPOLLO_vector(unsigned int x, unsigned int y)
  1346. X{
  1347. X    status_$t status;
  1348. X
  1349. X    gpr_$line((gpr_$coordinate_t) x, plot_to_gpr(y), &status);
  1350. X    apollo_xy_check("line");
  1351. X}
  1352. X
  1353. X/*
  1354. X    On terminals, this switches to text mode.  The real meaning,
  1355. X    however, is that the graphics are finished.  This means we can
  1356. X    now display the saved bitmap.
  1357. X*/
  1358. XAPOLLO_text()
  1359. X{
  1360. X    if (use_bitmap)
  1361. X    {
  1362. X    static gpr_$position_t pos;        /* always zero */
  1363. X    gpr_$window_t window;
  1364. X    status_$t status;
  1365. X
  1366. X    /* bitblt the entire bitmap to the entire window */
  1367. X    window.window_base.x_coord = 0;
  1368. X    window.window_base.y_coord = 0;
  1369. X    window.window_size.x_size = APOLLO_XMAX;
  1370. X    window.window_size.y_size = APOLLO_YMAX;
  1371. X
  1372. X    gpr_$set_bitmap(screen_desc, &status);
  1373. X    apollo_check("set_bitmap(screen_desc)");
  1374. X
  1375. X    gpr_$pixel_blt(bitmap_desc, window, pos, &status);
  1376. X    apollo_check("bitblt");
  1377. X
  1378. X    gpr_$set_bitmap(bitmap_desc, &status);
  1379. X    apollo_check("set_bitmap(bitmap_desc)");
  1380. X    }
  1381. X}
  1382. X
  1383. XAPOLLO_text_angle(ang)
  1384. Xint ang;
  1385. X{
  1386. X    status_$t status;
  1387. X
  1388. X    gpr_$set_text_path(ang ? gpr_$up : gpr_$right, &status);
  1389. X    apollo_check("set_text_path");
  1390. X    return TRUE;
  1391. X}
  1392. X
  1393. Xstatic enum JUSTIFY apollo_text_mode;
  1394. X
  1395. XAPOLLO_justify_text(mode)
  1396. Xenum JUSTIFY mode;
  1397. X{
  1398. X    apollo_text_mode = mode;
  1399. X    return TRUE;
  1400. X}
  1401. X
  1402. X/*
  1403. X    Write "str" right justified on row "row".  A row is assumed to
  1404. X    have whatever height the current text has.  Make sure the
  1405. X    text does not cover the tick marks.
  1406. X*/
  1407. XAPOLLO_put_text(x, y, str)
  1408. Xunsigned int x, y;
  1409. Xchar str[];
  1410. X{
  1411. X    gpr_$offset_t size;
  1412. X    status_$t status;
  1413. X
  1414. X    gpr_$inq_text_extent(str, strlen(str), &size, &status);
  1415. X    apollo_check("inq_text_extent");
  1416. X
  1417. X    y -= size.y_size / 2;    /* center around "y" */
  1418. X    switch (apollo_text_mode)
  1419. X    {
  1420. X    case LEFT:
  1421. X    break;
  1422. X    case CENTRE:
  1423. X    x -= size.x_size / 2;
  1424. X    break;
  1425. X    case RIGHT:
  1426. X    x -= size.x_size;
  1427. X    break;
  1428. X    }
  1429. X    APOLLO_move(x, y);
  1430. X
  1431. X    gpr_$text(str, strlen(str), &status);
  1432. X    apollo_check("put_text");
  1433. X}
  1434. X
  1435. X/* reset the graphics state and terminate */
  1436. XAPOLLO_reset()
  1437. X{
  1438. X    if (stream != -1)
  1439. X    {
  1440. X    apollo_gpr_terminate();
  1441. X    stream = -1;
  1442. X    }
  1443. X}
  1444. END_OF_FILE
  1445.   if test 17140 -ne `wc -c <'gnuplot/term/apollo.trm'`; then
  1446.     echo shar: \"'gnuplot/term/apollo.trm'\" unpacked with wrong size!
  1447.   fi
  1448.   # end of 'gnuplot/term/apollo.trm'
  1449. fi
  1450. if test -f 'gnuplot/term/mif.trm' -a "${1}" != "-c" ; then 
  1451.   echo shar: Will not clobber existing file \"'gnuplot/term/mif.trm'\"
  1452. else
  1453.   echo shar: Extracting \"'gnuplot/term/mif.trm'\" \(19730 characters\)
  1454.   sed "s/^X//" >'gnuplot/term/mif.trm' <<'END_OF_FILE'
  1455. X/* GNUPLOT -- mif.trm */
  1456. X/*
  1457. X * Copyright (C) 1992, 1993
  1458. X *
  1459. X * Permission to use, copy, and distribute this software and its
  1460. X * documentation for any purpose with or without fee is hereby granted, 
  1461. X * provided that the above copyright notice appear in all copies and 
  1462. X * that both that copyright notice and this permission notice appear 
  1463. X * in supporting documentation.
  1464. X *
  1465. X * Permission to modify the software is granted, but not the right to
  1466. X * distribute the modified code.  Modifications are to be distributed 
  1467. X * as patches to released version.
  1468. X *  
  1469. X * This software  is provided "as is" without express or implied warranty.
  1470. X * 
  1471. X * This file is included by ../term.c.
  1472. X *
  1473. X * This terminal driver was developed for
  1474. X *      gnuplot for unix version 3.0 (patchlevel 1)
  1475. X *      gnuplot for unix version 3.2 (patchlevel 2)
  1476. X *
  1477. X * This terminal driver supports:
  1478. X *      Frame Maker MIF format version 3.00
  1479. X *
  1480. X * Options for this terminal driver (set terminal mif [options]):
  1481. X *      colour /        Draw primitives with line types >= 0 in colour (sep. 2-7)
  1482. X *      monochrome      Draw primitives in black (sep. 0)
  1483. X *
  1484. X *      polyline /      Draw lines as continous curves
  1485. X *      vectors         Draw lines as collections of vectors
  1486. X *
  1487. X *      help / ?        Print short usage description on stderr
  1488. X *
  1489. X * Properties for this terminal driver:
  1490. X *     -Gnuplot size of worksheet:              MIF_XMAX * MIF_YMAX
  1491. X *     -Unit in MIF output:                     cm
  1492. X *     -Plot primitives with the same pen will
  1493. X *      be grouped in the same MIF group.
  1494. X *     -Plot primitives with line types >= 0
  1495. X *      will as default be drawn in colour.
  1496. X *     -Lines are plotted as collections of
  1497. X *      vectors, or as continous lines (default)
  1498. X *     -Plot primitives in a plot will be in a
  1499. X *      Frame in MIF. Several plot Frames will
  1500. X *      be collected in one large Frame.
  1501. X *     -Point size of MIF output characters:    MIF_PSIZE
  1502. X *     -Used font for MIF output characters:    Times
  1503. X *     -Supports vertical text
  1504. X *
  1505. X * AUTHORS:
  1506. X *      Olof Franksson, Physics IV, KTH, S-100 44 Stockholm, Sweden
  1507. X * 
  1508. X * COMMENTS:
  1509. X *      Send comments and/or suggestions to olof@fysik4.kth.se
  1510. X * 
  1511. X * CHANGES:
  1512. X *      Changed order of routine declarations.          olof@fysik4.kth.se
  1513. X *      Changed mechanism for pen pattern selection.    kssingvo@immd4.informatik.uni-erlangen.de
  1514. X *      Support for vertical text.                      kssingvo@immd4.informatik.uni-erlangen.de
  1515. X *      Fixed plot bug for "set size XS,YS", XS/YS > 1. olof@fysik4.kth.se
  1516. X *
  1517. X */
  1518. X#if !defined(cfree)
  1519. X#define cfree free
  1520. X#endif
  1521. X
  1522. X/** Coordinates **/
  1523. X#define GNP_TO_MIF(P)   (((float) (P)) / 1000.0)        /* Converts gnuplot units to MIF units */
  1524. X#define MIF_XMAX 15000                  /* Basic unit: 0.01 mm (15cm -> 15*10*100=15000) */
  1525. X#define MIF_YMAX 10000                  /* Basic unit: 0.01 mm (10cm -> 10*10*100=10000) */
  1526. X
  1527. X#define MIF_XLAST (MIF_XMAX - 1)
  1528. X#define MIF_YLAST (MIF_YMAX - 1)
  1529. X
  1530. Xstatic struct mif_line { /* Line point structure specification */
  1531. X    float fpos_x;           /* Line point X coordinate */
  1532. X    float fpos_y;           /*            Y coordinate */
  1533. X    struct mif_line *next;  /* Pointer to next line point */
  1534. X    struct mif_line *prev;  /* Pointer to previous line point */
  1535. X} mif_line = { /* Current position structure. Adjust for orign. Local for this file. */
  1536. X    GNP_TO_MIF(0),
  1537. X    GNP_TO_MIF(MIF_YLAST),
  1538. X    &mif_line,
  1539. X    &mif_line
  1540. X};
  1541. X
  1542. X/** Characters **/
  1543. X#define MIF_PSIZE 9                     /* Point size of used characters */
  1544. X
  1545. X#define MIF_VCHAR (MIF_YMAX/31)         /* Distance between rows (a guess) */
  1546. X#define MIF_HCHAR (MIF_XMAX/95)         /* Distance between characters (a guess) */
  1547. X
  1548. X/** Scale marks **/
  1549. X#define MIF_VTIC  (MIF_YMAX/150)        /* Size of scale mark (vert) */
  1550. X#define MIF_HTIC  (MIF_XMAX/225)        /* Size of scale mark (hor) */
  1551. X
  1552. X/** Drawing properties **/
  1553. Xstatic char mif_justify[64];                    /* How to justify the used text */
  1554. Xstatic char mif_pen[64], mif_pen_width[64], mif_separation[64];         /* How to plot */
  1555. X
  1556. X#define MIF_TEXT_HOR  0
  1557. X#define MIF_TEXT_VER  1
  1558. Xstatic int mif_text_ang = MIF_TEXT_HOR;         /* Rotation angle of text */
  1559. X
  1560. X#define MIF_NPENS 16                    /* Number of MIF pen types */
  1561. Xstatic int mif_pentype = 0;             /* Pen type to use. Also used to create groups for graphics */
  1562. X#define MIF_PEN_TO_GROUP(P)     ( 1 + (P) )     /* Map pen type to group number. Must be >= 1 */
  1563. X
  1564. Xstatic int mif_pattern_table[MIF_NPENS] = {     /* Table, which pattern should be used for drawing */
  1565. X    0,                          /* border  */
  1566. X    1,                          /* not used */
  1567. X    2, 3, 4, 8, 12, 13,         /* other lines: functions, data, ... (5 is used for grid; 6,7 is (nearly) invisible) */
  1568. X    5,                          /* grid */
  1569. X    9, 10, 11, 12, 13, 14, 15   /* not used */
  1570. X};
  1571. X
  1572. X/** MIF groups administration **/
  1573. X#define MIF_NGROUP_ID           20
  1574. Xstatic struct mif_group_id {
  1575. X    int group_existance;
  1576. X#define MIF_GROUP_EXISTS        1       /* This group id should generate a MIF group */
  1577. X#define MIF_GROUP_NOT_EXISTS    0       /* This group id should not generate a MIF group */
  1578. X
  1579. X    int group_id;
  1580. X#define MIF_INVALID_GROUP_ID    0       /* An invalid MIF group ID */
  1581. X
  1582. X} mif_group_id[MIF_NGROUP_ID];            /* List of used group ID:s and corresponding MIF groups existance */
  1583. X
  1584. X/** Semaphores **/
  1585. Xstatic int mif_initialized = 0;        /* != 0 when output is active */
  1586. Xstatic int mif_in_frame = 0;            /* != 0 when inside a plot frame */
  1587. Xstatic int mif_frameno = -1;            /* Current frame number */
  1588. Xstatic int mif_colour = TRUE;           /* == TRUE when colour should be used */
  1589. Xstatic int mif_polyline = TRUE;         /* == TRUE when lines are drawn as continous curves */
  1590. X
  1591. X/** Declaration of routine/s for internal use **/
  1592. Xstatic int insert_mif_line(), proc_group_id();
  1593. X
  1594. X/** Routine/s **/
  1595. X
  1596. X/* Called when this terminal type is set in order to parse options */
  1597. XMIF_options()
  1598. X{
  1599. X    extern char term_options[];     /* Declared in ../setshow.c */
  1600. X
  1601. X    if (!END_OF_COMMAND) {
  1602. X        /* Colour options */
  1603. X        if (!END_OF_COMMAND && almost_equals(c_token, "m$onochrome")) {    /* Compare up to $ */
  1604. X            mif_colour = FALSE;
  1605. X            c_token++;
  1606. X        }
  1607. X        if (!END_OF_COMMAND && almost_equals(c_token, "c$olour")) {   /* Compare up to $ */
  1608. X            mif_colour = TRUE;
  1609. X            c_token++;
  1610. X        }
  1611. X
  1612. X        /* Curve options */
  1613. X        if (!END_OF_COMMAND && almost_equals(c_token, "v$ectors")) {   /* Compare up to $ */
  1614. X            mif_polyline = FALSE;
  1615. X            c_token++;
  1616. X        }
  1617. X        if (!END_OF_COMMAND && almost_equals(c_token, "p$olyline")) {   /* Compare up to $ */
  1618. X            mif_polyline = TRUE;
  1619. X            c_token++;
  1620. X        }
  1621. X
  1622. X        /* Short help */
  1623. X        if ( !END_OF_COMMAND &&
  1624. X             (almost_equals(c_token, "h$elp") ||
  1625. X              almost_equals(c_token, "?$")) ) { /* Compare up to $ */
  1626. X            fprintf(stderr, "Usage: set terminal mif [options]\n");
  1627. X            fprintf(stderr, "\toptions:\n");
  1628. X            fprintf(stderr, "\t\tcolour /        Draw primitives with line types >= 0 in colour (sep. 2-7)\n");
  1629. X            fprintf(stderr, "\t\tmonochrome      Draw primitives in black (sep. 0)                        \n");
  1630. X            fprintf(stderr, "\n");
  1631. X            fprintf(stderr, "\t\tpolyline /      Draw lines as continous curves                           \n");
  1632. X            fprintf(stderr, "\t\tvectors         Draw lines as collections of vectors                     \n");
  1633. X            fprintf(stderr, "\n");
  1634. X            fprintf(stderr, "\t\thelp / ?        Print short usage description on stderr                  \n");
  1635. X
  1636. X            c_token++;
  1637. X        }
  1638. X    }
  1639. X
  1640. X    sprintf(term_options, "%s %s", (mif_colour == TRUE)? "colour": "monochrome",
  1641. X                       (mif_polyline == TRUE)? "polyline": "vectors");
  1642. X}
  1643. X
  1644. X/* Deallocate the used line structure elements */
  1645. Xstatic int free_mif_line()
  1646. X{
  1647. X    struct mif_line *tline;
  1648. X
  1649. X    while (mif_line.prev != &mif_line) {
  1650. X        /* Unlink */
  1651. X        tline = mif_line.prev;
  1652. X        mif_line.prev = mif_line.prev->prev;
  1653. X        mif_line.prev->next = &mif_line;
  1654. X
  1655. X        /* Deallocate */
  1656. X        free(tline);
  1657. X    }
  1658. X
  1659. X    /* Make sure that the list will be empty */
  1660. X    mif_line.prev = &mif_line;
  1661. X    mif_line.next = &mif_line;
  1662. X}
  1663. X
  1664. X/* Draw the pending line. Change current position. */
  1665. Xstatic int put_mif_line()
  1666. X{
  1667. X    int np, i;
  1668. X    struct mif_line *tline;
  1669. X
  1670. X    /* Process if inside a Frame */
  1671. X    if (mif_initialized != 0 && mif_in_frame != 0) {
  1672. X
  1673. X        /* Count the number of available points */
  1674. X        for (tline = mif_line.next, np = 1; tline != &mif_line; tline = tline->next, np++)
  1675. X            ;
  1676. X
  1677. X        /* Draw line (at least two points) */
  1678. X        if (np >= 2) {
  1679. X            /* Line preamble */
  1680. X            fprintf(outfile, "\t<PolyLine <GroupID %d> %s %s %s\n",
  1681. X                     MIF_PEN_TO_GROUP(mif_pentype), mif_pen, mif_pen_width, mif_separation);
  1682. X
  1683. X            /* Draw the line elements */
  1684. X            fprintf(outfile, "\t\t<NumPoints %d> ", np);
  1685. X            for (i = 0, tline = &mif_line; i < np; i++, tline = tline->next) {
  1686. X                if (i%4 == 0)
  1687. X                    fprintf(outfile, "\n\t\t");
  1688. X                fprintf(outfile, "<Point  %.3f %.3f> ", tline->fpos_x, tline->fpos_y);
  1689. X            }
  1690. X
  1691. X            /* Line post amble */
  1692. X            fprintf(outfile, "\n\t>\n");
  1693. X
  1694. X            /* Register the used group ID */
  1695. X            proc_group_id(MIF_PEN_TO_GROUP(mif_pentype));
  1696. X
  1697. X            /* Avoid to redraw this. The MIF system should remember it. */
  1698. X            mif_pen[0] = '\0';
  1699. X            mif_pen_width[0] = '\0';
  1700. X            mif_separation[0] = '\0';
  1701. X
  1702. X            /* Move current position to end of line */
  1703. X            mif_line.fpos_x = mif_line.prev->fpos_x;
  1704. X            mif_line.fpos_y = mif_line.prev->fpos_y;
  1705. X
  1706. X            /* Restore the line */
  1707. X            free_mif_line();
  1708. X        }
  1709. X
  1710. X    } /* Line processed */
  1711. X}
  1712. X
  1713. X/* Set up a MIF output file */
  1714. XMIF_init()
  1715. X{
  1716. X    int i;
  1717. X
  1718. X    extern char version[];        /* Declared in ../version.c */
  1719. X    extern char patchlevel[];
  1720. X
  1721. X    /* Process if not inside a MIF file and Frame */
  1722. X    if (mif_initialized == 0 && mif_in_frame == 0) {
  1723. X        /* Tell this terminal driver that the output is initialized and no current frames are processed */
  1724. X        mif_initialized = 1;
  1725. X        mif_in_frame = 0;
  1726. X
  1727. X        /* Reset internal position */
  1728. X        free_mif_line();
  1729. X        mif_line.fpos_x = GNP_TO_MIF(0);
  1730. X        mif_line.fpos_y = GNP_TO_MIF(MIF_YLAST);
  1731. X
  1732. X        /* Reset drawing properties strings */
  1733. X        mif_pen[0] = '\0';
  1734. X        mif_pen_width[0] = '\0';
  1735. X        mif_separation[0] = '\0';
  1736. X        sprintf(mif_justify, " <TLAlignment Left> ");
  1737. X
  1738. X        /* Reset group ID generator */
  1739. X        for (i = 0; i < MIF_NGROUP_ID; i++) {
  1740. X            mif_group_id[i].group_id = MIF_INVALID_GROUP_ID;
  1741. X            mif_group_id[i].group_existance = MIF_GROUP_NOT_EXISTS;
  1742. X        }
  1743. X
  1744. X        /* Identify ourselves */
  1745. X        fprintf(outfile, "<MIFFile 3.00> # Generated by gnuplot version %s patchlevel %s; identifies this as a MIF file\n", version, patchlevel);
  1746. X        fprintf(outfile, "#\n");
  1747. X
  1748. X        /* Setup a default environment to use */
  1749. X        fprintf(outfile, "# Set a default pen pattern, pen width, unit and font for subsequent objects\n");
  1750. X        fprintf(outfile, "<Pen 0>\n");
  1751. X        fprintf(outfile, "<Fill 15>\n");
  1752. X        fprintf(outfile, "<PenWidth 0.5 pt>\n");
  1753. X        fprintf(outfile, "<Separation 0>\n");
  1754. X        fprintf(outfile, "<Units Ucm>\n");
  1755. X        fprintf(outfile, "<Font <FFamily `Times'> <FSize %d> <FPlain Yes>>\n", MIF_PSIZE);
  1756. X        fprintf(outfile, "#\n");
  1757. X    } /* MIF file created */
  1758. X}
  1759. X
  1760. X/* Finish of a MIF output file */
  1761. XMIF_reset()
  1762. X{
  1763. X    /* Process if inside a MIF file and not inside a Frame */
  1764. X    if (mif_initialized != 0 && mif_in_frame == 0) {
  1765. X        /* Finish off the MIF file */
  1766. X        fprintf(outfile, "#\n");
  1767. X        fprintf(outfile, "# End of MIFFile\n");
  1768. X
  1769. X        /* Tell this terminal driver that the output is finished */
  1770. X        mif_initialized = 0;
  1771. X    } /* MIF file finished */
  1772. X}
  1773. X
  1774. X/* Start plotting a Frame (-> graphics mode) */
  1775. XMIF_graphics()
  1776. X{
  1777. X    int i;
  1778. X
  1779. X    /* Process if not inside a Frame */
  1780. X    if (mif_initialized != 0 && mif_in_frame == 0) {
  1781. X        /* Tell that this terminal driver is working with a plot frame */
  1782. X        mif_in_frame = 1;
  1783. X
  1784. X        /* Update frame number */
  1785. X        mif_frameno++;
  1786. X
  1787. X        /* Set current position */
  1788. X        free_mif_line();
  1789. X        mif_line.fpos_x = GNP_TO_MIF(0);
  1790. X        mif_line.fpos_y = GNP_TO_MIF(MIF_YLAST);
  1791. X
  1792. X        /* Set drawing properties */
  1793. X        mif_pen[0] = '\0';
  1794. X        mif_pen_width[0] = '\0';
  1795. X        mif_separation[0] = '\0';
  1796. X        sprintf(mif_justify, " <TLAlignment Left> ");
  1797. X
  1798. X        /* Reset group ID generator */
  1799. X        for (i = 0; i < MIF_NGROUP_ID; i++) {
  1800. X            mif_group_id[i].group_id = MIF_INVALID_GROUP_ID;
  1801. X            mif_group_id[i].group_existance = MIF_GROUP_NOT_EXISTS;
  1802. X        }
  1803. X
  1804. X        /* Frame preamble */
  1805. X        fprintf(outfile, "#\n");
  1806. X        fprintf(outfile, "# Frame number %d with plot of graphics\n", mif_frameno);
  1807. X        fprintf(outfile, "<Frame\n");
  1808. X        fprintf(outfile, "\t<Pen 15>\n");
  1809. X        fprintf(outfile, "\t<Fill 15>\n");
  1810. X        fprintf(outfile, "\t<PenWidth  0.5 pt>\n");
  1811. X        fprintf(outfile, "\t<Separation 0>\n");
  1812. X        fprintf(outfile, "\t<BRect 0.000 %.3f %.3f %.3f>\n",
  1813. X                 ((float) mif_frameno)*GNP_TO_MIF(MIF_YMAX+100), GNP_TO_MIF(MIF_XMAX), GNP_TO_MIF(MIF_YMAX));
  1814. X        fprintf(outfile, "\t<NSOffset  0.000>\n");
  1815. X        fprintf(outfile, "\t<BLOffset  0.000>\n");
  1816. X    } /* Frame created */
  1817. X}
  1818. X
  1819. X/* Stop plotting a Frame (-> text mode) */
  1820. XMIF_text()
  1821. X{
  1822. X    int i;
  1823. X
  1824. X    /* Process if inside a Frame */
  1825. X    if (mif_initialized != 0 && mif_in_frame != 0) {
  1826. X
  1827. X        /* Draw pending line */
  1828. X        if (mif_polyline == TRUE)
  1829. X            put_mif_line();
  1830. X
  1831. X        /* Group the used plot primitives */
  1832. X        fprintf(outfile, "\t#\n");
  1833. X        fprintf(outfile, "\t# Group the the objects in groups to make the chart easier to manipulate\n");
  1834. X        fprintf(outfile, "\t# after it's imported into FrameMaker.\n");
  1835. X
  1836. X        for (i = 0; i < MIF_NGROUP_ID; i++) {
  1837. X            if (mif_group_id[i].group_id != MIF_INVALID_GROUP_ID &&
  1838. X                mif_group_id[i].group_existance == MIF_GROUP_EXISTS) {
  1839. X                fprintf(outfile, "\t<Group\n");
  1840. X                fprintf(outfile, "\t\t<ID %d>\n", mif_group_id[i].group_id);
  1841. X                fprintf(outfile, "\t>\n");
  1842. X            }
  1843. X        }
  1844. X
  1845. X        /* Frame post amble */
  1846. X        fprintf(outfile, ">\n");
  1847. X        fprintf(outfile, "# End of Frame number %d\n", mif_frameno);
  1848. X        fprintf(outfile, "#\n");
  1849. X
  1850. X        /* Tell that this terminal driver is not working with a plot frame */
  1851. X        mif_in_frame = 0;
  1852. X    } /* Frame finshed */
  1853. X}
  1854. X
  1855. X/* Select type of line in grapics */
  1856. X/* NOTE: actually written to output the first time a primitive is drawn AFTER this call */
  1857. XMIF_linetype(linetype)
  1858. Xint linetype;           /* -2=border, -1=X/Y-axis, 0-13=lines, and 14-=mapped back */
  1859. X{
  1860. X    /* Process if inside a Frame */
  1861. X    if (mif_initialized != 0 && mif_in_frame != 0) {
  1862. X
  1863. X        /* Draw pending line */
  1864. X        if (mif_polyline == TRUE)
  1865. X            put_mif_line();
  1866. X
  1867. X        /* Translate gnuplot pen types to MIF pen types */
  1868. X        if (linetype < 0) {     /* Special lines */
  1869. X            if (linetype == -1) {
  1870. X                mif_pentype = 8+MIF_NPENS;      /* -1 */
  1871. X                if (mif_colour == TRUE)
  1872. X                    sprintf(mif_separation, " <Separation 0> ");
  1873. X            }
  1874. X            else {
  1875. X                mif_pentype = 0+MIF_NPENS;      /* -2 or less */
  1876. X                if (mif_colour == TRUE)
  1877. X                    sprintf(mif_separation, " <Separation 0> ");
  1878. X            }
  1879. X            sprintf(mif_pen_width, " <PenWidth 1.0 pt> ");
  1880. X        }
  1881. X        else {                  /* Normal lines */
  1882. X            mif_pentype = (linetype)%MIF_NPENS;     /* 0-(MIF_NPENS-1) */
  1883. X            sprintf(mif_pen_width, " <PenWidth 0.5 pt> ");
  1884. X            if (mif_colour == TRUE)
  1885. X                sprintf(mif_separation, " <Separation %d> ", 2+(mif_pentype%6));        /* 2-7 */
  1886. X        }
  1887. X
  1888. X        /* Set pen type */
  1889. X        sprintf(mif_pen, " <Pen %d> ", mif_pattern_table[mif_pentype%MIF_NPENS]);
  1890. X
  1891. X    } /* Primitive processed */
  1892. X}
  1893. X
  1894. X/* Draw the text horisontally or vertically (90 degrees counterclockwise) */
  1895. Xint MIF_text_angle(ang)
  1896. Xint ang;
  1897. X{
  1898. X    if (ang != 0)
  1899. X    mif_text_ang = MIF_TEXT_VER;
  1900. X    else
  1901. X    mif_text_ang = MIF_TEXT_HOR;
  1902. X
  1903. X    return(TRUE);
  1904. X}
  1905. X
  1906. X/* Justify following text lines (MIF_put_text()) relative to the insertion point */
  1907. XMIF_justify_text(mode)
  1908. X/* NOTE: actually written to output in text primitives which are drawn AFTER this call */
  1909. Xenum JUSTIFY mode;
  1910. X{
  1911. X    int rval = TRUE;
  1912. X
  1913. X    /* Process if inside a Frame */
  1914. X    if (mif_initialized != 0 && mif_in_frame != 0) {
  1915. X        switch (mode) {
  1916. X        case LEFT:
  1917. X            sprintf(mif_justify, " <TLAlignment Left> ");
  1918. X            break;
  1919. X        case CENTRE:
  1920. X            sprintf(mif_justify, " <TLAlignment Center> ");
  1921. X            break;
  1922. X        case RIGHT:
  1923. X            sprintf(mif_justify, " <TLAlignment Right> ");
  1924. X            break;
  1925. X        default:
  1926. X            rval = FALSE;
  1927. X            break;
  1928. X        }
  1929. X
  1930. X    } /* Primitive processed */
  1931. X    else {
  1932. X        rval = FALSE;
  1933. X    }
  1934. X
  1935. X    return(rval);
  1936. X}
  1937. X
  1938. X/* Draw a vector from current position to (x, y) and change current position. */
  1939. X/* NOTE: actually written to output the first time another primitive is called AFTER this call */
  1940. XMIF_vector(x, y)
  1941. Xunsigned int x, y;
  1942. X{
  1943. X    /* Process if inside a Frame */
  1944. X    if (mif_initialized != 0 && mif_in_frame != 0) {
  1945. X
  1946. X        /* Setup the vector as a part of the line */
  1947. X        insert_mif_line(GNP_TO_MIF(x), GNP_TO_MIF(MIF_YLAST-(int)y));
  1948. X
  1949. X        /* Draw pending line -> vector */
  1950. X        if (mif_polyline == FALSE)
  1951. X            put_mif_line();
  1952. X
  1953. X    } /* Vector processed */
  1954. X}
  1955. X
  1956. X/* Move current position */
  1957. XMIF_move(x, y)
  1958. Xunsigned int x, y;
  1959. X{
  1960. X    /* Process if inside a Frame */
  1961. X    if (mif_initialized != 0 && mif_in_frame != 0) {
  1962. X
  1963. X        /* Draw pending line */
  1964. X        if (mif_polyline == TRUE)
  1965. X            put_mif_line();
  1966. X
  1967. X        mif_line.fpos_x = GNP_TO_MIF(x);
  1968. X        mif_line.fpos_y = GNP_TO_MIF(MIF_YLAST-(int)y);
  1969. X    }
  1970. X}
  1971. X
  1972. X/* Draw the text string str at (x, y). Adjust according to MIF_justify_text(). Change current position. */
  1973. XMIF_put_text(x, y, str)
  1974. Xunsigned int x, y;
  1975. Xchar str[];
  1976. X{
  1977. X    /* Process if inside a Frame */
  1978. X    if (mif_initialized != 0 && mif_in_frame != 0) {
  1979. X
  1980. X        /* Draw pending line */
  1981. X        if (mif_polyline == TRUE)
  1982. X            put_mif_line();
  1983. X
  1984. X        /* Adjust current position for text-graphics alignment */
  1985. X        MIF_move(x, y-MIF_VCHAR/5);
  1986. X
  1987. X        if (strlen(str) > 0) {
  1988. X
  1989. X            /* Draw the text */
  1990. X            fprintf(outfile, "\t<TextLine <GroupID %d> %s %s %s\n",
  1991. X                     MIF_PEN_TO_GROUP(mif_pentype), mif_pen, mif_pen_width, mif_separation);
  1992. X            fprintf(outfile, "\t\t<TLOrigin  %.3f %.3f> %s %s <String `%s'>\n",
  1993. X                     mif_line.fpos_x, mif_line.fpos_y, mif_justify,
  1994. X                     (mif_text_ang == MIF_TEXT_VER)? "<Angle 90>": "",
  1995. X                     str);
  1996. X            fprintf(outfile, "\t>\n");
  1997. X
  1998. X            /* Register the used group ID */
  1999. X            proc_group_id(MIF_PEN_TO_GROUP(mif_pentype));
  2000. X
  2001. X            /* Avoid to redraw this. The MIF system should remember it. */
  2002. X            mif_pen[0] = '\0';
  2003. X            mif_pen_width[0] = '\0';
  2004. X            mif_separation[0] = '\0';
  2005. X
  2006. X            mif_justify[0] = '\0';  /* Independent of linetype */
  2007. X        }
  2008. X    } /* Text processed */
  2009. X}
  2010. X
  2011. X
  2012. X/* Insert one point in the line */
  2013. Xstatic int insert_mif_line(fx, fy)
  2014. Xfloat fx, fy;
  2015. X{
  2016. X    int rval = TRUE;
  2017. X
  2018. X    if ((mif_line.prev->next = (struct mif_line *) alloc(sizeof(struct mif_line),"MIF driver")) != (struct mif_line *) NULL) {
  2019. X        /* Link */
  2020. X        mif_line.prev->next->next = &mif_line;
  2021. X        mif_line.prev->next->prev = mif_line.prev;
  2022. X        mif_line.prev = mif_line.prev->next;
  2023. X
  2024. X        /* Fill */
  2025. X        mif_line.prev->fpos_x = fx;
  2026. X        mif_line.prev->fpos_y = fy;
  2027. X
  2028. X        rval = TRUE;
  2029. X    }
  2030. X    else { /* Failed to allocate */
  2031. X        /* Relink */
  2032. X        mif_line.prev->next = &mif_line;
  2033. X
  2034. X        rval = FALSE;
  2035. X    }
  2036. X
  2037. X    return(rval);
  2038. X}
  2039. X
  2040. X
  2041. X/* Register group ID. Update group ID existance. */
  2042. X/* Returns:     1       group_id belongs to a MIF group
  2043. X        0       group_id does not belong to a MIF group
  2044. X           -1       not inside a Frame
  2045. X           -2       group ID list is full
  2046. X */
  2047. Xstatic int proc_group_id(group_id)
  2048. Xint group_id;
  2049. X{
  2050. X    int i, rval = 0;
  2051. X
  2052. X    /* Process if inside a Frame */
  2053. X    if (mif_initialized != 0 && mif_in_frame != 0) {
  2054. X
  2055. X        /* Find out the group ID, or a free group ID slot index. */
  2056. X        for (i = 0; i < MIF_NGROUP_ID &&
  2057. X                mif_group_id[i].group_id != MIF_INVALID_GROUP_ID &&
  2058. X                mif_group_id[i].group_id != group_id;
  2059. X                                        i++) {
  2060. X            /* Don't check the group_existance variable */
  2061. X        }
  2062. X
  2063. X        if (i < MIF_NGROUP_ID) {
  2064. X            if (mif_group_id[i].group_id == MIF_INVALID_GROUP_ID) {
  2065. X                /* Register as new group ID for eventual use as MIF group */
  2066. X                mif_group_id[i].group_id = group_id;
  2067. X                mif_group_id[i].group_existance = MIF_GROUP_NOT_EXISTS;
  2068. X            }
  2069. X            else {
  2070. X                /* If second use of this group ID -> create a new MIF group */
  2071. X                if (mif_group_id[i].group_id == group_id) {
  2072. X                    mif_group_id[i].group_existance = MIF_GROUP_EXISTS;
  2073. X                    /* NOTE: a group MUST have at least two members. */
  2074. X                    rval = 1;
  2075. X                }
  2076. X            }
  2077. X        }
  2078. X        else {
  2079. X            rval = -2;      /* No place for this group ID in the list */
  2080. X        }
  2081. X
  2082. X    } /* Group ID processed */
  2083. X    else {
  2084. X        rval = -1;      /* Not inside a Frame */
  2085. X    }
  2086. X
  2087. X    /* Return MIF group status */
  2088. X    return(rval);
  2089. X}
  2090. X
  2091. END_OF_FILE
  2092.   if test 19730 -ne `wc -c <'gnuplot/term/mif.trm'`; then
  2093.     echo shar: \"'gnuplot/term/mif.trm'\" unpacked with wrong size!
  2094.   fi
  2095.   # end of 'gnuplot/term/mif.trm'
  2096. fi
  2097. if test -f 'gnuplot/win/wmenu.c' -a "${1}" != "-c" ; then 
  2098.   echo shar: Will not clobber existing file \"'gnuplot/win/wmenu.c'\"
  2099. else
  2100.   echo shar: Extracting \"'gnuplot/win/wmenu.c'\" \(18486 characters\)
  2101.   sed "s/^X//" >'gnuplot/win/wmenu.c' <<'END_OF_FILE'
  2102. X#ifndef lint
  2103. Xstatic char *RCSid = "$Id: wmenu.c%v 3.50 1993/07/09 05:35:24 woo Exp $";
  2104. X#endif
  2105. X
  2106. X/* GNUPLOT - win/wmenu.c */
  2107. X/*
  2108. X * Copyright (C) 1992   Maurice Castro, Russell Lang
  2109. X *
  2110. X * Permission to use, copy, and distribute this software and its
  2111. X * documentation for any purpose with or without fee is hereby granted, 
  2112. X * provided that the above copyright notice appear in all copies and 
  2113. X * that both that copyright notice and this permission notice appear 
  2114. X * in supporting documentation.
  2115. X *
  2116. X * Permission to modify the software is granted, but not the right to
  2117. X * distribute the modified code.  Modifications are to be distributed 
  2118. X * as patches to released version.
  2119. X *  
  2120. X * This software is provided "as is" without express or implied warranty.
  2121. X * 
  2122. X *
  2123. X * AUTHORS
  2124. X * 
  2125. X *   Maurice Castro
  2126. X *   Russell Lang
  2127. X * 
  2128. X * Send your comments or suggestions to 
  2129. X *  info-gnuplot@dartmouth.edu.
  2130. X * This is a mailing list; to join it send a note to 
  2131. X *  info-gnuplot-request@dartmouth.edu.  
  2132. X * Send bug reports to
  2133. X *  bug-gnuplot@dartmouth.edu.
  2134. X */
  2135. X
  2136. X#define STRICT
  2137. X#include <windows.h>
  2138. X#include <windowsx.h>
  2139. X#if WINVER >= 0x030a
  2140. X#include <commdlg.h>
  2141. X#endif
  2142. X#include <string.h>    /* only use far items */
  2143. X#include "wgnuplib.h"
  2144. X#include "wresource.h"
  2145. X#include "wcommon.h"
  2146. X
  2147. XBOOL CALLBACK _export InputBoxDlgProc(HWND, UINT, WPARAM, LPARAM);
  2148. XLRESULT CALLBACK _export MenuButtonProc(HWND, UINT, WPARAM, LPARAM);
  2149. X
  2150. X/* limits */
  2151. X#define MAXSTR 255
  2152. X#define MACROLEN 5000
  2153. X/* #define NUMMENU 256  defined in wresourc.h */
  2154. X#define MENUDEPTH 3
  2155. X
  2156. X/* menu tokens */
  2157. X#define CMDMIN 129
  2158. X#define INPUT 129
  2159. X#define EOS 130
  2160. X#define OPEN 131
  2161. X#define SAVE 132
  2162. X#define CMDMAX 132
  2163. Xchar * keyword[] = {
  2164. X    "[INPUT]", "[EOS]", "[OPEN]", "[SAVE]",
  2165. X        "{ENTER}", "{ESC}", "{TAB}",
  2166. X        "{^A}", "{^B}", "{^C}", "{^D}", "{^E}", "{^F}", "{^G}", "{^H}", 
  2167. X    "{^I}", "{^J}", "{^K}", "{^L}", "{^M}", "{^N}", "{^O}", "{^P}", 
  2168. X    "{^Q}", "{^R}", "{^S}", "{^T}", "{^U}", "{^V}", "{^W}", "{^X}", 
  2169. X    "{^Y}", "{^Z}", "{^[}", "{^\\}", "{^]}", "{^^}", "{^_}",
  2170. X    NULL};
  2171. XBYTE keyeq[] = {
  2172. X    INPUT, EOS, OPEN, SAVE,
  2173. X        13, 27, 9,
  2174. X        1, 2, 3, 4, 5, 6, 7, 8,
  2175. X    9, 10, 11, 12, 13, 14, 15, 16,
  2176. X    17, 18, 19, 20, 21, 22, 23, 24, 
  2177. X    25, 26, 28, 29, 30, 31,
  2178. X    NULL};
  2179. X
  2180. X
  2181. X/* Send a macro to the text window */
  2182. Xvoid
  2183. XSendMacro(LPTW lptw, UINT m)
  2184. X{
  2185. XBYTE FAR *s;
  2186. Xchar *d;
  2187. Xchar *buf;
  2188. XBOOL flag=TRUE;
  2189. Xint i;
  2190. XLPMW lpmw = lptw->lpmw;
  2191. X#if WINVER >= 0x030a
  2192. XOPENFILENAME ofn;
  2193. Xchar *szTitle;
  2194. Xchar *szFile;
  2195. Xchar *szFilter;
  2196. X#endif
  2197. X
  2198. X    if ( (buf = LocalAllocPtr(LHND, MAXSTR+1)) == (char *)NULL )
  2199. X        return;
  2200. X
  2201. X    if (m>=lpmw->nCountMenu)
  2202. X        return;
  2203. X    s = lpmw->macro[m];
  2204. X    d = buf;
  2205. X    *d = '\0';
  2206. X    while (s && *s && (d-buf < MAXSTR)) {
  2207. X        if (*s>=CMDMIN  && *s<=CMDMAX) {
  2208. X        switch (*s) {
  2209. X            case SAVE: /* [SAVE] - get a save filename from a file list box */
  2210. X            case OPEN: /* [OPEN] - get a filename from a file list box */
  2211. X#if WINVER >= 0x030a
  2212. X                /* This uses COMMDLG.DLL from Windows 3.1 
  2213. X                   COMMDLG.DLL is redistributable */
  2214. X                {
  2215. X                BOOL save;
  2216. X                if ( (szTitle = LocalAllocPtr(LHND, MAXSTR+1)) == (char *)NULL )
  2217. X                    return;
  2218. X                if ( (szFile = LocalAllocPtr(LHND, MAXSTR+1)) == (char *)NULL )
  2219. X                    return;
  2220. X                if ( (szFilter = LocalAllocPtr(LHND, MAXSTR+1)) == (char *)NULL )
  2221. X                    return;
  2222. X
  2223. X                save = (*s==SAVE);
  2224. X                s++;
  2225. X                        for(i=0; (*s >= 32 && *s <= 126); i++)
  2226. X                            szTitle[i] = *s++;    /* get dialog box title */
  2227. X                szTitle[i]='\0';
  2228. X                s++;
  2229. X                        for(i=0; (*s >= 32 && *s <= 126); i++)
  2230. X                            szFile[i] = *s++;    /* temporary copy of filter */
  2231. X                szFile[i++]='\0';
  2232. X                lstrcpy(szFilter,"Default (");
  2233. X                lstrcat(szFilter,szFile);
  2234. X                lstrcat(szFilter,")");
  2235. X                i=lstrlen(szFilter);
  2236. X                i++;    /* move past NULL */
  2237. X                lstrcpy(szFilter+i,szFile);
  2238. X                i+=lstrlen(szFilter+i);
  2239. X                i++;    /* move past NULL */
  2240. X                lstrcpy(szFilter+i,"All Files (*.*)");
  2241. X                i+=lstrlen(szFilter+i);
  2242. X                i++;    /* move past NULL */
  2243. X                lstrcpy(szFilter+i,"*.*");
  2244. X                i+=lstrlen(szFilter+i);
  2245. X                i++;    /* move past NULL */
  2246. X                szFilter[i++]='\0';    /* add a second NULL */
  2247. X                flag = 0;
  2248. X
  2249. X                /* the Windows 3.1 implentation - MC */
  2250. X                szFile[0] = '\0';
  2251. X                /* clear the structrure */
  2252. X                _fmemset(&ofn, 0, sizeof(OPENFILENAME));
  2253. X                ofn.lStructSize = sizeof(OPENFILENAME);
  2254. X                ofn.hwndOwner = lptw->hWndParent;
  2255. X                ofn.lpstrFilter = szFilter;
  2256. X                ofn.nFilterIndex = 1;
  2257. X                ofn.lpstrFile = szFile;
  2258. X                ofn.nMaxFile = MAXSTR;
  2259. X                ofn.lpstrFileTitle = szFile;
  2260. X                ofn.nMaxFileTitle = MAXSTR;
  2261. X                ofn.lpstrTitle = szTitle;
  2262. X                ofn.lpstrInitialDir = (LPSTR)NULL;
  2263. X                ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
  2264. X                flag = (save ? GetSaveFileName(&ofn) : GetOpenFileName(&ofn));
  2265. X                if( flag ) {
  2266. X                    lpmw->nChar = lstrlen(ofn.lpstrFile);
  2267. X                    for (i=0; i<lpmw->nChar; i++)
  2268. X                        *d++=ofn.lpstrFile[i];
  2269. X                }
  2270. X
  2271. X                LocalFreePtr((void NEAR *)OFFSETOF(szTitle));
  2272. X                LocalFreePtr((void NEAR *)OFFSETOF(szFilter));
  2273. X                LocalFreePtr((void NEAR *)OFFSETOF(szFile));
  2274. X
  2275. X                }
  2276. X                break;
  2277. X#else
  2278. X                /* Use InputBox if you don't have COMMDLG.DLL.
  2279. X                s++;    /* skip list box title */
  2280. X                for(i=0; (*s >= 32 && *s <= 126); i++)
  2281. X                    s++;
  2282. X#endif
  2283. X            case INPUT: /* [INPUT] - input a string of characters */
  2284. X                s++;
  2285. X                for(i=0; (*s >= 32 && *s <= 126); i++)
  2286. X                    lpmw->szPrompt[i] = *s++;
  2287. X                lpmw->szPrompt[i]='\0';
  2288. X#ifdef __DLL__
  2289. X                lpmw->lpProcInput = (DLGPROC)GetProcAddress(hdllInstance, "InputBoxDlgProc");
  2290. X#else
  2291. X                lpmw->lpProcInput = (DLGPROC)MakeProcInstance((FARPROC)InputBoxDlgProc, hdllInstance);
  2292. X#endif
  2293. X                flag = DialogBox( hdllInstance, "InputDlgBox", lptw->hWndParent, lpmw->lpProcInput);
  2294. X                if( flag ) {
  2295. X                    for (i=0; i<lpmw->nChar; i++)
  2296. X                        *d++=lpmw->szAnswer[i];
  2297. X                }
  2298. X#ifndef __DLL__
  2299. X                FreeProcInstance((FARPROC)lpmw->lpProcInput);
  2300. X#endif
  2301. X                break;
  2302. X            case EOS: /* [EOS] - End Of String - do nothing */
  2303. X                default:
  2304. X                s++;
  2305. X                break;
  2306. X        }
  2307. X        if (!flag) { /* abort */
  2308. X            d = buf;
  2309. X            s = (BYTE FAR *)"";
  2310. X        }
  2311. X        }
  2312. X        else {
  2313. X        *d++ = *s++;
  2314. X        }
  2315. X    }
  2316. X    *d = '\0';
  2317. X    if (buf[0]!='\0') {
  2318. X        d = buf;
  2319. X        while (*d) {
  2320. X            SendMessage(lptw->hWndText,WM_CHAR,*d,1L);
  2321. X            d++;
  2322. X        }
  2323. X    }
  2324. X}
  2325. X
  2326. X
  2327. X#define GBUFSIZE 512
  2328. Xtypedef struct tagGFILE {
  2329. X    HFILE    hfile;
  2330. X    char     getbuf[GBUFSIZE];
  2331. X    int    getnext;
  2332. X    int    getleft;
  2333. X} GFILE;
  2334. X
  2335. XGFILE * Gfopen(LPSTR lpszFileName, int fnOpenMode)
  2336. X{
  2337. XGFILE *gfile;
  2338. X    
  2339. X    gfile = (GFILE *)LocalAllocPtr(LHND, sizeof(GFILE));
  2340. X    if (!gfile)
  2341. X        return NULL;
  2342. X
  2343. X    gfile->hfile = _lopen(lpszFileName, fnOpenMode);
  2344. X    if (gfile->hfile == HFILE_ERROR) {
  2345. X        LocalFreePtr((void NEAR *)OFFSETOF(gfile));
  2346. X        return NULL;
  2347. X    }
  2348. X    gfile->getleft = 0;
  2349. X    gfile->getnext = 0;
  2350. X    return gfile;
  2351. X}
  2352. X
  2353. Xvoid Gfclose(GFILE * gfile)
  2354. X{
  2355. X    
  2356. X    _lclose(gfile->hfile);
  2357. X    LocalFreePtr((void NEAR *)OFFSETOF(gfile));
  2358. X    return;
  2359. X}
  2360. X
  2361. X/* returns number of characters read */
  2362. Xint
  2363. XGfgets(LPSTR lp, int size, GFILE *gfile)
  2364. X{
  2365. Xint i;
  2366. Xint ch;
  2367. X    for (i=0; i<size; i++) {
  2368. X        if (gfile->getleft <= 0) {
  2369. X            if ( (gfile->getleft = _lread(gfile->hfile, gfile->getbuf, GBUFSIZE)) == 0)
  2370. X                break;
  2371. X            gfile->getnext = 0;
  2372. X        }
  2373. X        ch = *lp++ = gfile->getbuf[gfile->getnext++];
  2374. X        gfile->getleft --;
  2375. X        if (ch == '\r') {
  2376. X            i--;
  2377. X            lp--;
  2378. X        }
  2379. X        if (ch == '\n') {
  2380. X            i++;
  2381. X            break;
  2382. X        }
  2383. X    }
  2384. X    if (i<size)
  2385. X        *lp++ = '\0';
  2386. X    return i;
  2387. X}
  2388. X
  2389. X/* Get a line from the menu file */
  2390. X/* Return number of lines read from file including comment lines */
  2391. Xint GetLine(char * buffer, int len, GFILE *gfile)
  2392. X{
  2393. XBOOL  status;
  2394. Xint nLine = 0;
  2395. X    
  2396. X   status = (Gfgets(buffer,len,gfile) != 0);
  2397. X   nLine++;
  2398. X   while( status && ( buffer[0] == NULL || buffer[0] == '\n' || buffer[0] == ';' ) ) {
  2399. X      /* blank line or comment - ignore */ 
  2400. X         status = (Gfgets(buffer,len,gfile) != 0);
  2401. X      nLine++;
  2402. X   }
  2403. X   if (lstrlen(buffer)>0)
  2404. X      buffer[lstrlen(buffer)-1] = '\0';    /* remove trailing \n */
  2405. X
  2406. X   if (!status)
  2407. X      nLine = 0;    /* zero lines if file error */
  2408. X        
  2409. X    return nLine;
  2410. X}
  2411. X
  2412. X/* Left justify string */
  2413. Xvoid LeftJustify(char *d, char *s)
  2414. X{
  2415. X    while ( *s && (*s==' ' || *s=='\t') )
  2416. X        s++;    /* skip over space */
  2417. X    do {
  2418. X        *d++ = *s;
  2419. X    } while (*s++);
  2420. X}
  2421. X
  2422. X/* Translate string to tokenized macro */
  2423. Xvoid TranslateMacro(char *string)
  2424. X{
  2425. Xint i, len;
  2426. XLPSTR ptr;
  2427. X
  2428. X    for( i=0; keyword[i]!=(char *)NULL; i++ ) {
  2429. X        if( (ptr = _fstrstr( string, keyword[i] )) != NULL ) {
  2430. X            len = lstrlen( keyword[i] );
  2431. X            *ptr = keyeq[i];
  2432. X            lstrcpy( ptr+1, ptr+len );
  2433. X            i--;       /* allows for more than one occurrence of keyword */
  2434. X            }
  2435. X        }
  2436. X}
  2437. X
  2438. X/* Load Macros, and create Menu from Menu file */
  2439. Xvoid 
  2440. XLoadMacros(LPTW lptw)
  2441. X{
  2442. XGFILE *menufile;
  2443. XBYTE FAR *macroptr;
  2444. Xchar *buf;
  2445. Xint nMenuLevel;
  2446. XHMENU hMenu[MENUDEPTH+1];
  2447. XLPMW lpmw;
  2448. Xint nLine = 1;
  2449. Xint nInc;
  2450. XHGLOBAL hmacro, hmacrobuf;
  2451. X
  2452. Xint i;
  2453. XHDC hdc;
  2454. XTEXTMETRIC tm;
  2455. XRECT rect;
  2456. Xint ButtonX, ButtonY;
  2457. Xchar FAR *ButtonText[BUTTONMAX];
  2458. X
  2459. X    lpmw = lptw->lpmw;
  2460. X
  2461. X    /* mark all buffers and menu file as unused */
  2462. X    buf = (char *)NULL;
  2463. X    hmacro = 0;
  2464. X    hmacrobuf = 0;
  2465. X    lpmw->macro = (BYTE FAR * FAR *)NULL;
  2466. X    lpmw->macrobuf = (BYTE FAR *)NULL;
  2467. X    lpmw->szPrompt = (char *)NULL;
  2468. X    lpmw->szAnswer = (char *)NULL;
  2469. X    menufile = (GFILE *)NULL;
  2470. X
  2471. X    /* open menu file */
  2472. X    if ((menufile=Gfopen(lpmw->szMenuName,READ)) == (GFILE *)NULL)
  2473. X        goto errorcleanup;
  2474. X
  2475. X    /* allocate buffers */
  2476. X    if ((buf = LocalAllocPtr(LHND, MAXSTR)) == (char *)NULL)
  2477. X        goto nomemory;
  2478. X    hmacro = GlobalAlloc(GHND,(NUMMENU) * sizeof(BYTE FAR *));
  2479. X    if ((lpmw->macro = (BYTE FAR * FAR *)GlobalLock(hmacro))  == (BYTE FAR * FAR *)NULL)
  2480. X        goto nomemory;
  2481. X    hmacrobuf = GlobalAlloc(GHND, MACROLEN);
  2482. X    if ((lpmw->macrobuf = (BYTE FAR*)GlobalLock(hmacrobuf)) == (BYTE FAR *)NULL)
  2483. X        goto nomemory;
  2484. X    if ((lpmw->szPrompt = LocalAllocPtr(LHND, MAXSTR)) == (char *)NULL)
  2485. X        goto nomemory;
  2486. X    if ((lpmw->szAnswer = LocalAllocPtr(LHND, MAXSTR)) == (char *)NULL)
  2487. X        goto nomemory;
  2488. X
  2489. X    macroptr = lpmw->macrobuf;
  2490. X    lpmw->nButton = 0;
  2491. X    lpmw->nCountMenu = 0;
  2492. X    lpmw->hMenu = hMenu[0] = CreateMenu();
  2493. X    nMenuLevel = 0;
  2494. X
  2495. X    while ((nInc = GetLine(buf,MAXSTR,menufile)) != 0) {
  2496. X      nLine += nInc;
  2497. X      LeftJustify(buf,buf);
  2498. X      if (buf[0]=='\0') {
  2499. X        /* ignore blank lines */
  2500. X      }
  2501. X      else if (!lstrcmpi(buf,"[Menu]")) {
  2502. X        /* new menu */
  2503. X        if (!(nInc = GetLine(buf,MAXSTR,menufile))) {
  2504. X            nLine += nInc;
  2505. X            wsprintf(buf,"Problem on line %d of %s\n",nLine,lpmw->szMenuName);
  2506. X                    MessageBox(lptw->hWndParent,(LPSTR) buf,lptw->Title, MB_ICONEXCLAMATION);
  2507. X            goto errorcleanup;
  2508. X        }
  2509. X        LeftJustify(buf,buf);
  2510. X        if (nMenuLevel<MENUDEPTH)
  2511. X            nMenuLevel++;
  2512. X        else {
  2513. X            wsprintf(buf,"Menu is too deep at line %d of %s\n",nLine,lpmw->szMenuName);
  2514. X                    MessageBox(lptw->hWndParent,(LPSTR) buf,lptw->Title, MB_ICONEXCLAMATION);
  2515. X            goto errorcleanup;
  2516. X        }
  2517. X        hMenu[nMenuLevel] = CreateMenu();
  2518. X        AppendMenu(hMenu[nMenuLevel > 0 ? nMenuLevel-1 : 0],
  2519. X            MF_STRING | MF_POPUP, (UINT)hMenu[nMenuLevel], (LPCSTR)buf);
  2520. X      }
  2521. X      else if (!lstrcmpi(buf,"[EndMenu]")) {
  2522. X        if (nMenuLevel > 0)
  2523. X            nMenuLevel--;    /* back up one menu */
  2524. X      }
  2525. X      else if (!lstrcmpi(buf,"[Button]")) {
  2526. X        /* button macro */
  2527. X        if (lpmw->nButton >= BUTTONMAX) {
  2528. X            wsprintf(buf,"Too many buttons at line %d of %s\n",nLine,lpmw->szMenuName);
  2529. X                       MessageBox(lptw->hWndParent,(LPSTR) buf,lptw->Title, MB_ICONEXCLAMATION);
  2530. X            goto errorcleanup;
  2531. X        }
  2532. X        if (!(nInc = GetLine(buf,MAXSTR,menufile))) {
  2533. X            nLine += nInc;
  2534. X            wsprintf(buf,"Problem on line %d of %s\n",nLine,lpmw->szMenuName);
  2535. X                    MessageBox(lptw->hWndParent,(LPSTR) buf,lptw->Title, MB_ICONEXCLAMATION);
  2536. X            goto errorcleanup;
  2537. X        }
  2538. X        LeftJustify(buf,buf);
  2539. X        if (lstrlen(buf)+1 < MACROLEN - (macroptr-lpmw->macrobuf))
  2540. X            lstrcpy((char FAR *)macroptr,buf);
  2541. X        else {
  2542. X            wsprintf(buf,"Out of space for storing menu macros\n at line %d of \n",nLine,lpmw->szMenuName);
  2543. X                       MessageBox(lptw->hWndParent,(LPSTR) buf,lptw->Title, MB_ICONEXCLAMATION);
  2544. X            goto errorcleanup;
  2545. X        }
  2546. X        ButtonText[lpmw->nButton] = (char FAR *)macroptr;
  2547. X        macroptr += lstrlen((char FAR *)macroptr)+1;
  2548. X        *macroptr = '\0';
  2549. X        if (!(nInc = GetLine(buf,MAXSTR,menufile))) {
  2550. X            nLine += nInc;
  2551. X            wsprintf(buf,"Problem on line %d of %s\n",nLine,lpmw->szMenuName);
  2552. X                       MessageBox(lptw->hWndParent,(LPSTR) buf,lptw->Title, MB_ICONEXCLAMATION);
  2553. X            goto errorcleanup;
  2554. X        }
  2555. X        LeftJustify(buf,buf);
  2556. X        TranslateMacro(buf);
  2557. X        if (lstrlen(buf)+1 < MACROLEN - (macroptr-lpmw->macrobuf))
  2558. X            lstrcpy((char FAR *)macroptr,buf);
  2559. X        else {
  2560. X            wsprintf(buf,"Out of space for storing menu macros\n at line %d of \n",nLine,lpmw->szMenuName);
  2561. X                       MessageBox(lptw->hWndParent,(LPSTR) buf,lptw->Title, MB_ICONEXCLAMATION);
  2562. X            goto errorcleanup;
  2563. X        }
  2564. X        lpmw->hButtonID[lpmw->nButton] = lpmw->nCountMenu;
  2565. X        lpmw->macro[lpmw->nCountMenu] = macroptr;
  2566. X        macroptr += lstrlen((char FAR *)macroptr)+1;
  2567. X        *macroptr = '\0';
  2568. X        lpmw->nCountMenu++;
  2569. X        lpmw->nButton++;
  2570. X      }
  2571. X      else {
  2572. X        /* menu item */
  2573. X        if (lpmw->nCountMenu>=NUMMENU) {
  2574. X            wsprintf(buf,"Too many menu items at line %d of %s\n",nLine,lpmw->szMenuName);
  2575. X                       MessageBox(lptw->hWndParent,(LPSTR) buf,lptw->Title, MB_ICONEXCLAMATION);
  2576. X            goto errorcleanup;
  2577. X        }
  2578. X        LeftJustify(buf,buf);
  2579. X        if (buf[0]=='-') {
  2580. X            if (nMenuLevel == 0)
  2581. X            AppendMenu(hMenu[0], MF_MENUBREAK, 0, (LPSTR)NULL);
  2582. X            else
  2583. X            AppendMenu(hMenu[nMenuLevel], MF_SEPARATOR, 0, (LPSTR)NULL);
  2584. X        }
  2585. X        else if (buf[0]=='|') {
  2586. X            AppendMenu(hMenu[nMenuLevel], MF_MENUBARBREAK, 0, (LPSTR)NULL);
  2587. X        }
  2588. X        else {
  2589. X            AppendMenu(hMenu[nMenuLevel],MF_STRING, lpmw->nCountMenu, (LPSTR)buf);
  2590. X            if (!(nInc = GetLine(buf,MAXSTR,menufile))) {
  2591. X                nLine += nInc;
  2592. X                wsprintf(buf,"Problem on line %d of %s\n",nLine,lpmw->szMenuName);
  2593. X                        MessageBox(lptw->hWndParent,(LPSTR) buf,lptw->Title, MB_ICONEXCLAMATION);
  2594. X                goto errorcleanup;
  2595. X            }
  2596. X            LeftJustify(buf,buf);
  2597. X            TranslateMacro(buf);
  2598. X            if (lstrlen(buf)+1 < MACROLEN - (macroptr-lpmw->macrobuf))
  2599. X                lstrcpy((char FAR *)macroptr,buf);
  2600. X            else {
  2601. X                wsprintf(buf,"Out of space for storing menu macros\n at line %d of %s\n",nLine,lpmw->szMenuName);
  2602. X                        MessageBox(lptw->hWndParent,(LPSTR) buf,lptw->Title, MB_ICONEXCLAMATION);
  2603. X                goto errorcleanup;
  2604. X            }
  2605. X            lpmw->macro[lpmw->nCountMenu] = macroptr;
  2606. X            macroptr += lstrlen((char FAR *)macroptr)+1;
  2607. X            *macroptr = '\0';
  2608. X            lpmw->nCountMenu++;
  2609. X        }
  2610. X      }
  2611. X    }
  2612. X
  2613. X    if ( (lpmw->nCountMenu - lpmw->nButton) > 0 ) {
  2614. X        /* we have a menu bar so put it on the window */
  2615. X        SetMenu(lptw->hWndParent,lpmw->hMenu);
  2616. X        DrawMenuBar(lptw->hWndParent);
  2617. X    }
  2618. X
  2619. X    if (!lpmw->nButton)
  2620. X        goto cleanup;        /* no buttons */
  2621. X
  2622. X    /* calculate size of buttons */
  2623. X    hdc = GetDC(lptw->hWndParent);
  2624. X    SelectFont(hdc, GetStockFont(SYSTEM_FIXED_FONT));
  2625. X    GetTextMetrics(hdc, &tm);
  2626. X    ButtonX = 8 * tm.tmAveCharWidth;
  2627. X    ButtonY = 6 * (tm.tmHeight + tm.tmExternalLeading) / 4;
  2628. X    ReleaseDC(lptw->hWndParent,hdc);
  2629. X
  2630. X    /* move top of client text window down to allow space for buttons */
  2631. X    lptw->ButtonHeight = ButtonY+1;
  2632. X    GetClientRect(lptw->hWndParent, &rect);
  2633. X    SetWindowPos(lptw->hWndText, (HWND)NULL, 0, lptw->ButtonHeight,
  2634. X            rect.right, rect.bottom-lptw->ButtonHeight, 
  2635. X            SWP_NOZORDER | SWP_NOACTIVATE);
  2636. X
  2637. X    /* create the buttons */
  2638. X#ifdef __DLL__
  2639. X    lpmw->lpfnMenuButtonProc = (WNDPROC)GetProcAddress(hdllInstance, "MenuButtonProc");
  2640. X#else
  2641. X    lpmw->lpfnMenuButtonProc = (WNDPROC)MakeProcInstance((FARPROC)MenuButtonProc, hdllInstance);
  2642. X#endif
  2643. X    for (i=0; i<lpmw->nButton; i++) {
  2644. X        lpmw->hButton[i] = CreateWindow("button", ButtonText[i],
  2645. X            WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
  2646. X                i * ButtonX, 0,
  2647. X                ButtonX, ButtonY,
  2648. X                lptw->hWndParent, (HMENU)i,
  2649. X                lptw->hInstance, lptw);
  2650. X        lpmw->lpfnButtonProc[i] = (WNDPROC) GetWindowLong(lpmw->hButton[i], GWL_WNDPROC);
  2651. X        SetWindowLong(lpmw->hButton[i], GWL_WNDPROC, (LONG)lpmw->lpfnMenuButtonProc);
  2652. X    }
  2653. X
  2654. X    goto cleanup;
  2655. X
  2656. X
  2657. Xnomemory:
  2658. X    MessageBox(lptw->hWndParent,"Out of memory",lptw->Title, MB_ICONEXCLAMATION);
  2659. Xerrorcleanup:
  2660. X    if (hmacro) {
  2661. X        GlobalUnlock(hmacro);
  2662. X        GlobalFree(hmacro);
  2663. X    }
  2664. X    if (hmacrobuf) {
  2665. X        GlobalUnlock(hmacrobuf);
  2666. X        GlobalFree(hmacrobuf);
  2667. X    }
  2668. X    if (lpmw->szPrompt != (char *)NULL)
  2669. X        LocalFreePtr((void NEAR *)OFFSETOF(lpmw->szPrompt));
  2670. X    if (lpmw->szAnswer != (char *)NULL)
  2671. X        LocalFreePtr((void NEAR *)OFFSETOF(lpmw->szAnswer));
  2672. X
  2673. Xcleanup:
  2674. X    if (buf != (char *)NULL)
  2675. X        LocalFreePtr((void NEAR *)OFFSETOF(buf));
  2676. X    if (menufile != (GFILE *)NULL)
  2677. X        Gfclose(menufile);
  2678. X    return;
  2679. X
  2680. X}
  2681. X
  2682. Xvoid
  2683. XCloseMacros(LPTW lptw)
  2684. X{
  2685. XHGLOBAL hglobal;
  2686. XLPMW lpmw;
  2687. X    lpmw = lptw->lpmw;
  2688. X
  2689. X#ifndef __DLL__
  2690. X    if (lpmw->lpfnMenuButtonProc)
  2691. X        FreeProcInstance((FARPROC)lpmw->lpfnMenuButtonProc);
  2692. X#endif
  2693. X    hglobal = (HGLOBAL)GlobalHandle( SELECTOROF(lpmw->macro) );
  2694. X    if (hglobal) {
  2695. X        GlobalUnlock(hglobal);
  2696. X        GlobalFree(hglobal);
  2697. X    }
  2698. X    hglobal = (HGLOBAL)GlobalHandle( SELECTOROF(lpmw->macrobuf) );
  2699. X    if (hglobal) {
  2700. X        GlobalUnlock(hglobal);
  2701. X        GlobalFree(hglobal);
  2702. X    }
  2703. X    if (lpmw->szPrompt != (char *)NULL)
  2704. X        LocalFreePtr((void NEAR *)OFFSETOF(lpmw->szPrompt));
  2705. X    if (lpmw->szAnswer != (char *)NULL)
  2706. X        LocalFreePtr((void NEAR *)OFFSETOF(lpmw->szAnswer));
  2707. X}
  2708. X
  2709. X
  2710. X/***********************************************************************/
  2711. X/* InputBoxDlgProc() -  Message handling routine for Input dialog box         */
  2712. X/***********************************************************************/
  2713. X
  2714. XBOOL CALLBACK _export
  2715. XInputBoxDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  2716. X{
  2717. XLPTW lptw;
  2718. XLPMW lpmw;
  2719. X    lptw = (LPTW)GetWindowLong(GetParent(hDlg), 0);
  2720. X    lpmw = lptw->lpmw;
  2721. X
  2722. X    switch( message) {
  2723. X        case WM_INITDIALOG:
  2724. X            SetDlgItemText( hDlg, ID_PROMPT, lpmw->szPrompt);
  2725. X            return( TRUE);
  2726. X
  2727. X        case WM_COMMAND:
  2728. X            switch(LOWORD(wParam)) {
  2729. X                case ID_ANSWER:
  2730. X                    return( TRUE);
  2731. X
  2732. X                case IDOK:
  2733. X                    lpmw->nChar = GetDlgItemText( hDlg, ID_ANSWER, lpmw->szAnswer, MAXSTR);
  2734. X                    EndDialog( hDlg, TRUE);
  2735. X                    return( TRUE);
  2736. X
  2737. X                case IDCANCEL:
  2738. X                    lpmw->szAnswer[0] = NULL;
  2739. X                    EndDialog( hDlg, FALSE);
  2740. X                    return( TRUE);
  2741. X
  2742. X                default:
  2743. X                    return( FALSE);
  2744. X                }
  2745. X        default:
  2746. X            return( FALSE);
  2747. X        }
  2748. X    }
  2749. X
  2750. X
  2751. XLRESULT CALLBACK _export
  2752. XMenuButtonProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  2753. X{
  2754. XLPTW lptw;
  2755. XLPMW lpmw;
  2756. X#ifdef WIN32
  2757. XLONG n = GetWindowLong(hwnd, GWL_ID);
  2758. X#else
  2759. XWORD n = GetWindowWord(hwnd, GWW_ID);
  2760. X#endif
  2761. X    lptw = (LPTW)GetWindowLong(GetParent(hwnd), 0);
  2762. X    lpmw = lptw->lpmw;
  2763. X
  2764. X    switch(message) {
  2765. X        case WM_LBUTTONUP:
  2766. X            {
  2767. X            RECT rect;
  2768. X            POINT pt;
  2769. X            GetWindowRect(hwnd, &rect);
  2770. X            GetCursorPos(&pt);
  2771. X            if (PtInRect(&rect, pt))
  2772. X                SendMessage(lptw->hWndText, WM_COMMAND, lpmw->hButtonID[n], 0L);
  2773. X            SetFocus(lptw->hWndText);
  2774. X            }
  2775. X            break;
  2776. X    }
  2777. X    return CallWindowProc((lpmw->lpfnButtonProc[n]), hwnd, message, wParam, lParam);
  2778. X}
  2779. END_OF_FILE
  2780.   if test 18486 -ne `wc -c <'gnuplot/win/wmenu.c'`; then
  2781.     echo shar: \"'gnuplot/win/wmenu.c'\" unpacked with wrong size!
  2782.   fi
  2783.   # end of 'gnuplot/win/wmenu.c'
  2784. fi
  2785. echo shar: End of archive 19 \(of 33\).
  2786. cp /dev/null ark19isdone
  2787. MISSING=""
  2788. 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
  2789.     if test ! -f ark${I}isdone ; then
  2790.     MISSING="${MISSING} ${I}"
  2791.     fi
  2792. done
  2793. if test "${MISSING}" = "" ; then
  2794.     echo You have unpacked all 33 archives.
  2795.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2796. else
  2797.     echo You still must unpack the following archives:
  2798.     echo "        " ${MISSING}
  2799. fi
  2800. exit 0
  2801. exit 0 # Just in case...
  2802.