xgraph-12.1.orig/0042775000175000000620000000000007625474712012335 5ustar bapstaffxgraph-12.1.orig/Makefile.am0100664000175000000620000000221207360237475014360 0ustar bapstaff## Process this file with automake to produce Makefile.in # Copyright (C) 1999 by John Heidemann ## shallow AUTOMAKE_OPTIONS = 1.0 foreign bin_PROGRAMS = xgraph xgraph_c_sources = \ xgraph.c xgX.c hard_devices.c dialog.c hpgl.c \ ps.c idraw.c xtb.c st.c params.c alloc.c draw.c \ init.c read.c tgif.c derivative.c \ copyright.h \ general.h \ hard_devices.h \ params.h \ plotter.h \ st.h \ xgout.h \ xgraph.h \ xtb.h xgraph_SOURCES = $(xgraph_c_sources) man_MANS = xgraph.man EXTRA_DIST=\ $(man_MANS) \ README.ANNOUNCE \ README.GENERAL \ README.HARDCOPY \ README.INSTALL \ README.NEWFEATURES \ bitmaps/dot.11 \ bitmaps/gray \ bitmaps/mark1.11 \ bitmaps/mark2.11 \ bitmaps/mark3.11 \ bitmaps/mark4.11 \ bitmaps/mark5.11 \ bitmaps/mark6.11 \ bitmaps/mark7.11 \ bitmaps/mark8.11 \ examples/Animation.xg \ examples/bar.xg \ examples/surface.xg \ examples/surface2.xg \ examples/surface3.xg \ examples/xgtest.xg # C_WARNINGS = -Wall C_WARNINGS = CFLAGS=$(ADDITIONAL_INCLUDES) $(C_WARNINGS) -g $(X_CFLAGS) xgraph_LDADD= $(ADDITIONAL_LIBS) $(X_LIBS) $(X_PRE_LIBS) $(X_EXTRA_LIBS) -lX11 -lm xgraph-12.1.orig/INSTALL0100664000175000000620000001572407360237475013371 0ustar bapstaff XGRAPH INSTALLATION =================== Quick Start ----------- - download the source code - extract tar file with gzip (gnu zip, not pkzip) and tar (typically "gunzip BEFORE posting to the mailing list. Mailing list info can be found at the xgraph web page. Xgraph-specific configure options --------------------------------- Use --with-additional-includes=/path/to/includes and --with-additional-libs=/path/to/libs if configure can't find particular includes or libraries on your system. Basic Installation ================== These are generic installation instructions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, a file `config.cache' that saves the results of its tests to speed up reconfiguring, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.in' is used to create `configure' by a program called `autoconf'. You only need `configure.in' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes awhile. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. You can give `configure' initial values for variables by setting them in the environment. Using a Bourne-compatible shell, you can do that on the command line like this: CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure Or on systems that have the `env' program, you can do it like this: env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you must use a version of `make' that supports the `VPATH' variable, such as GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. If you have to use a `make' that does not supports the `VPATH' variable, you have to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' will install the package's files in `/usr/local/bin', `/usr/local/man', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PATH'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you give `configure' the option `--exec-prefix=PATH', the package will use PATH as the prefix for installing programs and libraries. Documentation and other data files will still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=PATH' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Operation Controls ================== `configure' recognizes the following options to control how it operates. `--cache-file=FILE' Use and save the results of the tests in FILE instead of `./config.cache'. Set FILE to `/dev/null' to disable caching, for debugging `configure'. `--help' Print a summary of the options to `configure', and exit. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--version' Print the version of Autoconf used to generate the `configure' script, and exit. `configure' also accepts some other, not widely useful, options. xgraph-12.1.orig/bitmaps/0042775000175000000620000000000007625474712013774 5ustar bapstaffxgraph-12.1.orig/bitmaps/mark1.110100775000175000000620000000025207355433460015142 0ustar bapstaff#define mark1_width 8 #define mark1_height 8 #define mark1_x_hot 3 #define mark1_y_hot 3 static char mark1_bits[] = { 0x00, 0x00, 0x1c, 0x1c, 0x1c, 0x00, 0x00, 0x00}; xgraph-12.1.orig/bitmaps/dot.110100775000175000000620000000017007355433460014714 0ustar bapstaff#define dot_width 8 #define dot_height 8 static char dot_bits[] = { 0x00, 0x3c, 0x7e, 0x7e, 0x7e, 0x7e, 0x3c, 0x00}; xgraph-12.1.orig/bitmaps/gray0100664000175000000620000000042307355433460014646 0ustar bapstaff#define gray_width 16 #define gray_height 16 static char gray_bits[] = { 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa}; xgraph-12.1.orig/bitmaps/mark2.110100775000175000000620000000025207355433460015143 0ustar bapstaff#define mark2_width 8 #define mark2_height 8 #define mark2_x_hot 3 #define mark2_y_hot 3 static char mark2_bits[] = { 0x00, 0x3e, 0x22, 0x22, 0x22, 0x3e, 0x00, 0x00}; xgraph-12.1.orig/bitmaps/mark3.110100775000175000000620000000025207355433460015144 0ustar bapstaff#define mark3_width 8 #define mark3_height 8 #define mark3_x_hot 3 #define mark3_y_hot 3 static char mark3_bits[] = { 0x00, 0x1c, 0x36, 0x22, 0x36, 0x1c, 0x00, 0x00}; xgraph-12.1.orig/bitmaps/mark4.110100775000175000000620000000025207355433460015145 0ustar bapstaff#define mark4_width 8 #define mark4_height 8 #define mark4_x_hot 3 #define mark4_y_hot 3 static char mark4_bits[] = { 0x00, 0x22, 0x14, 0x08, 0x14, 0x22, 0x00, 0x00}; xgraph-12.1.orig/bitmaps/mark5.110100775000175000000620000000025207355433460015146 0ustar bapstaff#define mark5_width 8 #define mark5_height 8 #define mark5_x_hot 3 #define mark5_y_hot 3 static char mark5_bits[] = { 0x00, 0x08, 0x14, 0x22, 0x14, 0x08, 0x00, 0x00}; xgraph-12.1.orig/bitmaps/mark6.110100775000175000000620000000025207355433460015147 0ustar bapstaff#define mark6_width 8 #define mark6_height 8 #define mark6_x_hot 3 #define mark6_y_hot 3 static char mark6_bits[] = { 0x00, 0x1c, 0x14, 0x1c, 0x14, 0x1c, 0x00, 0x00}; xgraph-12.1.orig/bitmaps/mark7.110100775000175000000620000000025207355433460015150 0ustar bapstaff#define mark7_width 8 #define mark7_height 8 #define mark7_x_hot 3 #define mark7_y_hot 3 static char mark7_bits[] = { 0x00, 0x1c, 0x2a, 0x36, 0x2a, 0x1c, 0x00, 0x00}; xgraph-12.1.orig/bitmaps/mark8.110100775000175000000620000000025207355433460015151 0ustar bapstaff#define mark8_width 8 #define mark8_height 8 #define mark8_x_hot 3 #define mark8_y_hot 3 static char mark8_bits[] = { 0x00, 0x3e, 0x1c, 0x08, 0x1c, 0x3e, 0x00, 0x00}; xgraph-12.1.orig/Makefile.in0100664000175000000620000003227507360237474014404 0ustar bapstaff# Makefile.in generated automatically by automake 1.4 from Makefile.am # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. # Copyright (C) 1999 by John Heidemann SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include DESTDIR = pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = . ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : ADDITIONAL_INCLUDES = @ADDITIONAL_INCLUDES@ ADDITIONAL_LIBS = @ADDITIONAL_LIBS@ CC = @CC@ MAKEINFO = @MAKEINFO@ PACKAGE = @PACKAGE@ VERSION = @VERSION@ AUTOMAKE_OPTIONS = 1.0 foreign bin_PROGRAMS = xgraph xgraph_c_sources = xgraph.c xgX.c hard_devices.c dialog.c hpgl.c ps.c idraw.c xtb.c st.c params.c alloc.c draw.c init.c read.c tgif.c derivative.c copyright.h general.h hard_devices.h params.h plotter.h st.h xgout.h xgraph.h xtb.h xgraph_SOURCES = $(xgraph_c_sources) man_MANS = xgraph.man EXTRA_DIST = $(man_MANS) README.ANNOUNCE README.GENERAL README.HARDCOPY README.INSTALL README.NEWFEATURES bitmaps/dot.11 bitmaps/gray bitmaps/mark1.11 bitmaps/mark2.11 bitmaps/mark3.11 bitmaps/mark4.11 bitmaps/mark5.11 bitmaps/mark6.11 bitmaps/mark7.11 bitmaps/mark8.11 examples/Animation.xg examples/bar.xg examples/surface.xg examples/surface2.xg examples/surface3.xg examples/xgtest.xg # C_WARNINGS = -Wall C_WARNINGS = CFLAGS = $(ADDITIONAL_INCLUDES) $(C_WARNINGS) -g $(X_CFLAGS) xgraph_LDADD = $(ADDITIONAL_LIBS) $(X_LIBS) $(X_PRE_LIBS) $(X_EXTRA_LIBS) -lX11 -lm ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = autoconf.h CONFIG_CLEAN_FILES = PROGRAMS = $(bin_PROGRAMS) DEFS = @DEFS@ -I. -I$(srcdir) -I. CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ X_CFLAGS = @X_CFLAGS@ X_LIBS = @X_LIBS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ xgraph_OBJECTS = xgraph.o xgX.o hard_devices.o dialog.o hpgl.o ps.o \ idraw.o xtb.o st.o params.o alloc.o draw.o init.o read.o tgif.o \ derivative.o xgraph_DEPENDENCIES = xgraph_LDFLAGS = COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ manmdir = $(mandir)/manm MANS = $(man_MANS) NROFF = nroff DIST_COMMON = README ./stamp-h.in INSTALL Makefile.am Makefile.in \ aclocal.m4 autoconf.h.in configure configure.in install-sh missing \ mkinstalldirs DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = gtar GZIP_ENV = --best SOURCES = $(xgraph_SOURCES) OBJECTS = $(xgraph_OBJECTS) all: all-redirect .SUFFIXES: .SUFFIXES: .S .c .o .s $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --foreign --include-deps Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) \ && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status $(ACLOCAL_M4): configure.in cd $(srcdir) && $(ACLOCAL) config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) cd $(srcdir) && $(AUTOCONF) autoconf.h: stamp-h @if test ! -f $@; then \ rm -f stamp-h; \ $(MAKE) stamp-h; \ else :; fi stamp-h: $(srcdir)/autoconf.h.in $(top_builddir)/config.status cd $(top_builddir) \ && CONFIG_FILES= CONFIG_HEADERS=autoconf.h \ $(SHELL) ./config.status @echo timestamp > stamp-h 2> /dev/null $(srcdir)/autoconf.h.in: $(srcdir)/stamp-h.in @if test ! -f $@; then \ rm -f $(srcdir)/stamp-h.in; \ $(MAKE) $(srcdir)/stamp-h.in; \ else :; fi $(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOHEADER) @echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null mostlyclean-hdr: clean-hdr: distclean-hdr: -rm -f autoconf.h maintainer-clean-hdr: mostlyclean-binPROGRAMS: clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) distclean-binPROGRAMS: maintainer-clean-binPROGRAMS: install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(bindir) @list='$(bin_PROGRAMS)'; for p in $$list; do \ if test -f $$p; then \ echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ else :; fi; \ done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) list='$(bin_PROGRAMS)'; for p in $$list; do \ rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ done .c.o: $(COMPILE) -c $< .s.o: $(COMPILE) -c $< .S.o: $(COMPILE) -c $< mostlyclean-compile: -rm -f *.o core *.core clean-compile: distclean-compile: -rm -f *.tab.c maintainer-clean-compile: xgraph: $(xgraph_OBJECTS) $(xgraph_DEPENDENCIES) @rm -f xgraph $(LINK) $(xgraph_LDFLAGS) $(xgraph_OBJECTS) $(xgraph_LDADD) $(LIBS) install-manm: $(mkinstalldirs) $(DESTDIR)$(manmdir) @list='$(manm_MANS)'; \ l2='$(man_MANS)'; for i in $$l2; do \ case "$$i" in \ *.m*) list="$$list $$i" ;; \ esac; \ done; \ for i in $$list; do \ if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ else file=$$i; fi; \ ext=`echo $$i | sed -e 's/^.*\\.//'`; \ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ inst=`echo $$inst | sed '$(transform)'`.$$ext; \ echo " $(INSTALL_DATA) $$file $(DESTDIR)$(manmdir)/$$inst"; \ $(INSTALL_DATA) $$file $(DESTDIR)$(manmdir)/$$inst; \ done uninstall-manm: @list='$(manm_MANS)'; \ l2='$(man_MANS)'; for i in $$l2; do \ case "$$i" in \ *.m*) list="$$list $$i" ;; \ esac; \ done; \ for i in $$list; do \ ext=`echo $$i | sed -e 's/^.*\\.//'`; \ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ inst=`echo $$inst | sed '$(transform)'`.$$ext; \ echo " rm -f $(DESTDIR)$(manmdir)/$$inst"; \ rm -f $(DESTDIR)$(manmdir)/$$inst; \ done install-man: $(MANS) @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) install-manm uninstall-man: @$(NORMAL_UNINSTALL) $(MAKE) $(AM_MAKEFLAGS) uninstall-manm tags: TAGS ID: $(HEADERS) $(SOURCES) $(LISP) list='$(SOURCES) $(HEADERS)'; \ unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ here=`pwd` && cd $(srcdir) \ && mkid -f$$here/ID $$unique $(LISP) TAGS: $(HEADERS) $(SOURCES) autoconf.h.in $(TAGS_DEPENDENCIES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS)'; \ unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ test -z "$(ETAGS_ARGS)autoconf.h.in$$unique$(LISP)$$tags" \ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags autoconf.h.in $$unique $(LISP) -o $$here/TAGS) mostlyclean-tags: clean-tags: distclean-tags: -rm -f TAGS ID maintainer-clean-tags: distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist -rm -rf $(distdir) GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz mkdir $(distdir)/=build mkdir $(distdir)/=inst dc_install_base=`cd $(distdir)/=inst && pwd`; \ cd $(distdir)/=build \ && ../configure --srcdir=.. --prefix=$$dc_install_base \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) dist -rm -rf $(distdir) @banner="$(distdir).tar.gz is ready for distribution"; \ dashes=`echo "$$banner" | sed s/./=/g`; \ echo "$$dashes"; \ echo "$$banner"; \ echo "$$dashes" dist: distdir -chmod -R a+r $(distdir) GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) -rm -rf $(distdir) dist-all: distdir -chmod -R a+r $(distdir) GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) -rm -rf $(distdir) distdir: $(DISTFILES) -rm -rf $(distdir) mkdir $(distdir) -chmod 777 $(distdir) $(mkinstalldirs) $(distdir)/bitmaps $(distdir)/examples @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ cp -pr $$/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ || cp -p $$d/$$file $(distdir)/$$file || :; \ fi; \ done alloc.o: alloc.c derivative.o: derivative.c xgraph.h autoconf.h xgout.h dialog.o: dialog.c copyright.h xgout.h xgraph.h autoconf.h \ hard_devices.h xtb.h params.h draw.o: draw.c copyright.h xgraph.h autoconf.h xgout.h xtb.h \ hard_devices.h params.h hard_devices.o: hard_devices.c copyright.h xgout.h hard_devices.h \ params.h xgraph.h autoconf.h hpgl.o: hpgl.c copyright.h xgraph.h autoconf.h xgout.h plotter.h idraw.o: idraw.c hard_devices.h xgout.h init.o: init.c copyright.h xgraph.h autoconf.h xgout.h xtb.h \ hard_devices.h params.h params.o: params.c st.h params.h xgraph.h autoconf.h xgout.h \ hard_devices.h ps.o: ps.c copyright.h xgraph.h autoconf.h xgout.h read.o: read.c copyright.h xgraph.h autoconf.h xgout.h xtb.h \ hard_devices.h params.h st.o: st.c copyright.h st.h xgraph.h autoconf.h xgout.h tgif.o: tgif.c hard_devices.h xgout.h xgX.o: xgX.c copyright.h xgout.h params.h xgraph.h autoconf.h \ bitmaps/dot.11 bitmaps/mark1.11 bitmaps/mark2.11 \ bitmaps/mark3.11 bitmaps/mark4.11 bitmaps/mark5.11 \ bitmaps/mark6.11 bitmaps/mark7.11 bitmaps/mark8.11 xgraph.o: xgraph.c copyright.h xgraph.h autoconf.h xgout.h xtb.h \ hard_devices.h params.h xtb.o: xtb.c xtb.h copyright.h info-am: info: info-am dvi-am: dvi: dvi-am check-am: all-am check: check-am installcheck-am: installcheck: installcheck-am all-recursive-am: autoconf.h $(MAKE) $(AM_MAKEFLAGS) all-recursive install-exec-am: install-binPROGRAMS install-exec: install-exec-am install-data-am: install-man install-data: install-data-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am install: install-am uninstall-am: uninstall-binPROGRAMS uninstall-man uninstall: uninstall-am all-am: Makefile $(PROGRAMS) $(MANS) autoconf.h all-redirect: all-am install-strip: $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs: $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/manm mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f config.cache config.log stamp-h stamp-h[0-9]* maintainer-clean-generic: mostlyclean-am: mostlyclean-hdr mostlyclean-binPROGRAMS \ mostlyclean-compile mostlyclean-tags \ mostlyclean-generic mostlyclean: mostlyclean-am clean-am: clean-hdr clean-binPROGRAMS clean-compile clean-tags \ clean-generic mostlyclean-am clean: clean-am distclean-am: distclean-hdr distclean-binPROGRAMS distclean-compile \ distclean-tags distclean-generic clean-am distclean: distclean-am -rm -f config.status maintainer-clean-am: maintainer-clean-hdr maintainer-clean-binPROGRAMS \ maintainer-clean-compile maintainer-clean-tags \ maintainer-clean-generic distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." maintainer-clean: maintainer-clean-am -rm -f config.status .PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \ mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \ maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \ mostlyclean-compile distclean-compile clean-compile \ maintainer-clean-compile install-manm uninstall-manm install-man \ uninstall-man tags mostlyclean-tags distclean-tags clean-tags \ maintainer-clean-tags distdir info-am info dvi-am dvi check check-am \ installcheck-am installcheck all-recursive-am install-exec-am \ install-exec install-data-am install-data install-am install \ uninstall-am uninstall all-redirect all-am all installdirs \ mostlyclean-generic distclean-generic clean-generic \ maintainer-clean-generic clean mostlyclean distclean maintainer-clean # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: xgraph-12.1.orig/README0100664000175000000620000000123107360237474013203 0ustar bapstaff xgraph 12.1 distributed by the VINT project Welcome to the VINT release of xgraph. Xgraph is an X-Windows application that includes: - interactive plotting and graphing, by David Harrison of UC Berkeley - animation and deritives, added by Paul Walker of NCSA - portability and bug fixes, by the VINT project See the file "INSTALL" for installation instructions. If you have installation problems or questions, check: BEFORE posting to the mailing list. Mailing list info can be found at the xgraph web page. xgraph-12.1.orig/README.ANNOUNCE0100664000175000000620000000652507360237512014414 0ustar bapstaff A new version of xgraph is now available. Xgraph is a popular two-dimensional plotting program that accepts data in a form similar to the unix program graph and displays line graphs, scatter plots, or bar charts on an X11 display. These graphs are fully annotated with a title, axis numbering and labels, and a legend. Zooming in on regions of a graph is supported. The program can automatically generate hardcopy output to Postscript printers and HPGL plotters. A new option allows xgraph output to be directly pasted into idraw for further annotation. This program is NOT a widget. It is a stand-alone program written at the Xlib level and should run on any machine with a reasonable implementation of X11 release 3 or later. The source for the program is available through anonymous ftp to shambhala.Berkeley.EDU (128.32.132.54): % ftp shambhala.Berkeley.EDU Name: anonymous Password: ftp> cd pub ftp> binary ftp> get xgraph-11.tar.Z ftp> quit % uncompress xgraph-11.tar.Z % tar xf xgraph-11.tar This will create a directory called xgraph-11. In that directory you will find a file called README.INSTALL that contains directions for building the program. I plan to submit the sources to the moderator of comp.sources.x after I have tested the program under X11 release 4 (meaning a few weeks after the X Consortium releases the distribution). Those who do not have ftp access can obtain the source for xgraph using a mail archive system I have installed on dent.Berkeley.EDU (courtesy of Brian Reid at Digital). An example is given below: To: ucbvax!dent!archive-server Subject: send programs xgraph.shar.01 xgraph.shar.02 send programs xgraph.shar.03 xgraph.shar.04 xgraph.shar.05 send programs xgraph.shar.06 xgraph.shar.07 xgraph.shar.08 The archive server will send you these files as time and load permits. They are standard shell archives and can be unpacked by running them through /bin/sh (in order). If you would like to know more about the mail server, send a message with a subject of "help". I am afraid I am no mail wizard so I cannot help you determine a path to dent. For those familar with xgraph, the most important changes are summarized below: - A new data reader has been written that allows discontinuous data in each data set. Also, nearly all of the display options for xgraph can be set in the data file. The reader is also more forgiving about blank lines and excess white space. - A new option has been added to the Postscript hardcopy facility to allow xgraph output to be included in other documents using psfig. As mentioned above, xgraph output can be imported into idraw for further annotation if necessary. - I received lots of complaints about the way xgraph obtains fonts and visuals. The new xgraph uses a much simpler scheme to obtain these resources and has fall back code to insure it will run in almost any situation. - Options handling has been cleaned up substantially. Xgraph options can now be specified as X resources (~/.Xdefaults), in the data file, or on the command line. - Drawing is somewhat faster on some servers due to a better choice of initial defaults. Please send all bug reports, questions, comments or suggestions to the electronic address below. David Harrison UC Berkeley Electronics Research Lab (davidh@ic.Berkeley.EDU, ...!ucbvax!ucbcad!davidh) xgraph-12.1.orig/README.GENERAL0100664000175000000620000000663507360237513014266 0ustar bapstaff This directory contains source for the X11 version of xgraph, a two-dimensional data plotting program. Those familar with the X10 version of this program will find that is completely compatible. However, there are a few important notes and changes you should be aware of: 1. The program was developed and tested on X11 release 3 on a color VAXstation GPX and on a color DECstation 3100. It should work on most other servers without change but has not been tested on these other configurations. If you have problems, please send a note to: davidh@ic.Berkeley.EDU or ...!ucbvax!ucbcad!davidh 2. This version includes an improved hardcopy facility. An additional option, "Include in Document", has been added since the first X11 release. A new output type, Idraw, has also been added. See the manual page for details about the hardcopy dialog. 3. There are several changes to the input format for xgraph. However, the new format is compatible with the old and there should be no problem running xgraph with old data sets. The new form allows discontinuous data in data sets (using the "move" operator), parameter specification using a format similar to that found in the ~/.Xdefaults file, and comments. See the manual page for details. 4. In some cases, xgraph uses dashed lines to distinguish different data sets. Some servers are notoriously slow at rendering dashed lines. Be prepared for a significantly reduced performance on those servers. 5. Xgraph now uses software clipping to clip data to its display windows. This means you should be able to zoom in much farther on large data sets than was possible under the X10 version. 6. Xgraph used to use some rather sophisticated heuristics to handle visuals and colormaps. Due to complaints, I have removed these heuristics. Xgraph will display on whatever screen is specified in the DISPLAY environment variable or on the command line. 7. I plan to add full ICCCM support when X11 release 4 becomes available. In the meantime, the program should work under most window mangers (it is somewhat conformant already). 8. As a follow-on to (7), note that the operation of the program is heavily influenced by your choice of window managers. Focus based window managers (like dxwm from Digital) will require you to set focus in the text input slots of the hardcopy dialog box. 9. Many people have sent me notes about the state of code of xgraph. Xgraph was constructed initially as a challenge from another programmer here at Berkeley. The first version of the program was written in an afternoon. Since then, the program has "evolved" quite dramatically. Since this is not my primary work, I generally tacked on features quickly as the need became apparent. Some day, I would truely like to rewrite it. Until then, please bear with me. 10. Since xgraph has become quite popular, those in positions of power have recommended I add the standard UC Berkeley copyright notice to this software. See copyright.h for details. 11. Many people have sent me suggestions and comments. Some have written new code or sent patches to fix problems. I greately appreciate these contributions. Special thanks go to Beorn Johnson and Alan Kramer for the idraw output code. David Harrison UC Berkeley Electronics Research Lab (davidh@ic.Berkeley.EDU, ...!ucbvax!ucbcad!davidh) xgraph-12.1.orig/README.HARDCOPY0100664000175000000620000002651007360237513014414 0ustar bapstaff/* * Hardcopy Interface for Xgraph * * Major differences from first version: * A flags argument has been added to xg_init(). This new argument * is used to specify a new binary option: D_DOCU. See below * for details. * * Four new parameters are passed to the device initialization routine: * title_family, title_size, axis_family, and axis_size. See the * description of xg_init() for details. * * Clipping is done automatically by xgraph. The xg_clip() routine * is obsolete. * * The xg_line() routine has become the xg_seg() routine. It now * draws segments rather than a series of lines. * * A new field (max_segs) in the device structure now specifies * the maximum number of segments the device can handle in a group. */ /* * Adding an output device to xgraph * * Step 1 * Write versions of the following routines for your device: * xg_init(), xg_text(), xg_seg(), xg_dot(), and xg_end(). * The interface and function of these routines are described * in detail below. These routines should be named according * to your device. For example, the initialization routine * for the Postscript output device is psInit(). Also, name * your source file after your device (e.g. the postscript * routines are in the file ps.c). Instructions continue * after the description of the interface routines. * * The definitions below are quoted here as a convenience. In * your output module, you can include "xgout.h" to obtain these * definitions. */ #define D_COLOR 0x01 #define ERRBUFSIZE 2048 #define D_DOCU 0x01 typedef struct xg_out { int dev_flags; /* Device characteristic flags */ int area_w, area_h; /* Width and height in pixels */ int bdr_pad; /* Padding from border */ int axis_pad; /* Extra space around axis labels */ int tick_len; /* Length of a tick mark */ int legend_pad; /* Top of legend text to legend line */ int axis_width; /* Width of big character of axis font */ int axis_height; /* Height of big character of axis font */ int title_width; /* Width of big character of title font */ int title_height; /* Height of big character of title font */ int max_segs; /* Maximum number of segments in group */ void (*xg_text)(); /* Draws text at a location */ void (*xg_seg)(); /* Draws a series of segments */ void (*xg_dot)(); /* Draws a dot or marker at a location */ void (*xg_end)(); /* Stops the drawing sequence */ char *user_state; /* User supplied state information */ } xgOut; int xg_init(strm, width, height, title_family, title_size, axis_family, axis_size, out_info, errmsg) FILE *strm; /* Output stream */ int width, height; /* Size of space (microns) */ char *title_family; /* Name of title font family */ double title_size; /* Title font height (points) */ char *axis_family; /* Name of axis font family */ double axis_size; /* Axis font height (points) */ int flags; /* Flags (see below) */ xgOut *out_info; /* Device info (RETURN) */ char errmsg[ERRBUFSIZE]; /* Error message area */ /* * This routine is called by xgraph just before drawing is to * begin. The desired size of the plot is given by `width' * and `height'. The parameters `title_family', `title_size', * `axis_family', and `axis_size' specify the names of the * title and axis fonts and their vertical sizes (in points). * These parameters can be ignored if your device does not * support multiple fonts. The `flags' argument specifies * certain binary flags to the output routines. These * flags are: * D_DOCU: * If this flag is set, it indicates the user has specified that * the output will be included in some larger document. Devices * may choose to use this information to produce output that * can be integrated into documents with less effort. For example, * the Postscript output routines produce bounding box information * when this flag is set. * The routine should fill in all of the fields of `out_info' with * appropriate values. The values are described below: * area_w, area_h: * Size of the drawing space in device coordinates. * This should take in account the requested area * given by `width', and `height'. * bdr_pad: * Xgraph will leave this number of device coordinates around * all of the outer edges of the graph. * axis_pad: * Additional space around axis labels (in devcoords) * so that the labels do not appear crowded. * legend_pad: * Space (in devcoords) from the top of legend text to * the representative line drawn above the legend text. * tick_len: * Size of a tick mark placed on axis (in devcoords) * axis_width: * An estimate of the width of a large character in * the axis font (in devcoords). This can be an overestimate. An * underestimate may produce bad results. * axis_height: * An estimate of the height of a large character in * the axis labeling font (in devcoords). * title_width, title_height: * Same as above except for the title font. * max_segs: * Due to buffering constraints, some devices may not be able to * handle massive segment lists. This parameter tells xgraph not * to send more than `max_segs' segments in one request. * Output to the device should be written to the stream `strm'. * The functions are described individually below. After filling * in the parameters and setting the function pointers, the routine * should initialize its drawing state and store any extra needed * information in `user_state'. This value will be passed to all * other routines during the drawing sequence. If the device * cannot initialize, it should return a zero status and fill * `errmsg' with an informative error message. */ /* Text justifications */ #define T_CENTER 0 #define T_LEFT 1 #define T_UPPERLEFT 2 #define T_TOP 3 #define T_UPPERRIGHT 4 #define T_RIGHT 5 #define T_LOWERRIGHT 6 #define T_BOTTOM 7 #define T_LOWERLEFT 8 /* Text styles */ #define T_AXIS 0 #define T_TITLE 1 void xg_text(user_state, x, y, text, just, style) char *user_state; /* Value set in xg_init */ int x, y; /* Text position (pixels) */ char *text; /* Null terminated text */ int just; /* Justification (above) */ int style; /* Text style (above) */ /* * This routine should draw text at the indicated position using * the indicated justification and style. The justification refers * to the location of the point in reference to the text. For example, * if just is T_LOWERLEFT, (x,y) should be located at the lower left * edge of the text string. */ /* Line Styles */ #define L_AXIS 0 #define L_ZERO 1 #define L_VAR 2 void xg_seg(user_state, ns, seglist, width, style, lappr, color) char *user_state; /* Value set in xg_init */ int ns; /* Number of segments */ XSegment *seglist; /* X array of segments */ int width; /* Width of lines */ int style; /* See above */ int lappr; /* Line appearence */ int color; /* Line color (if any) */ /* * This routine draws a number of line segments at the points * given in `seglist'. Note that contiguous segments need not share * endpoints but often do. All segments should be `width' devcoords wide * and drawn in style `style'. The `width' may be zero meaning that * the line should be drawn as thin as the device allows. If `style' is * L_VAR, the parameters `color' and `lappr' should be used to draw the * line. Both parameters vary from 0 to 7. If the device is capable of * color, `color' varies faster than `style'. If the device * has no color, `style' will vary faster than `color' and * `color' can be safely ignored. However, if the * the device has more than 8 line appearences, the two can * be combined to specify 64 line style variations. * Xgraph promises not to send more than the `max_segs' in the * xgOut structure passed back from xg_init(). */ /* Marker styles */ #define P_PIXEL 0 #define P_DOT 1 #define P_MARK 2 void xg_dot(user_state, x, y, style, type, color) char *user_state; /* Value set in xg_init */ int x, y; /* Location in pixel units */ int style; /* Dot style */ int type; /* Type of marker */ int color; /* Marker color (if any) */ /* * This routine should draw a marker at location `x,y'. If the * style is P_PIXEL, the dot should be a single pixel. If * the style is P_DOT, the dot should be a reasonably large * dot. If the style is P_MARK, it should be a distinguished * mark which is specified by `type' (0-7). If the output * device is capable of color, the marker should be drawn in * `color' (0-7) which corresponds with the color for xg_line. */ void xg_end(user_state) char *user_state; /* * This routine is called after a drawing sequence is complete. * It can be used to clean up the user state and set the device * state appropriately. This routine is optional in the structure. */ /* * Adding an output device to xgraph * * Step 2 * Edit the file hard_devices.c. Declare your initialization * function and add your device to the list of devices, * hard_devices[]. The structure hard_dev is described below * and is defined in hard_devices.h: */ #define MFNAME 25 typedef enum hard_dev_docu_defn { NONE, NO, YES } hard_dev_docu; typedef struct hard_dev { char *dev_name; /* Device name */ int (*dev_init)(); /* Initialization function */ char *dev_spec; /* Default pipe program */ char dev_file[MFNAME]; /* Default file name */ char dev_printer[MFNAME]; /* Default printer name */ double dev_max_dim; /* Default maximum dimension (cm) */ char dev_title_font[MFNAME];/* Default name of title font */ double dev_title_size; /* Default size of title font (pnts) */ char dev_axis_font[MFNAME]; /* Default name of axis font */ double dev_axis_size; /* Default size of axis font (pnts) */ hard_dev_docu dev_docu; /* Document predicate */ }; /* * dev_spec: * The dev_spec field should be a command that directly outputs to * your device. The command should contain one %s directive that * will be filled in with the name of the device from the hardcopy * dialog. * dev_file: * The default file to write output to if the user selects `To File'. * dev_printer: * The default printer to write output to if the user selects * `To Device'. * dev_max_dim: * The default maximum dimension for the device in centimeters. * dev_title_font, dev_title_size: * The default title font and size. Sizes are specified in * points (1/72 inch). * dev_axis_font, dev_axis_size: * The default axis font and size. * dev_docu * Some devices may require extra preparation when including xgraph * output in a document. This parameter indicates the default * value of the Document predicate in the hardcopy dialog. If * the value is NONE, the device doesn't need any special preparation * for producing output for inclusion in documents. */ /* * Adding an output device to xgraph * * Step 3 * Edit the file Makefile. Add your source file to the SRC variable * and the corresponding object file to the OBJ variable. Finally, * remake xgraph. Your device should now be available in the * hardcopy dialog. */ xgraph-12.1.orig/README.INSTALL0100664000175000000620000000566207360237513014316 0ustar bapstaff This file contains instructions for building the X11 version of xgraph. When unpacked, the source is distributed in three directories: xgraph-11 Source for the program xgraph-11/bitmaps Bitmaps used for cursors and markers xgraph-11/examples Sample data for trying out the program First, you should examine the file hard_devices.c. This file lists the default hardcopy parameters for each hardcopy output device. Some of these defaults are site-specific and should be taylored to your site. For example, at our site, the default HPGL plotter is called "paper" and the default Postscript printer is called "lps40". You can change these names in this file. See hard_devices.h for a description of the initialization fields. If you do not like the default values for xgraph options, you can change these by editing the default values as listed on the third page in xgraph.c. Remember that changing these values changes the default behaviour for everyone running the program. Personal preference should be left for specification in the user's Xresources or Xdefaults file. An Imakefile is provided for compiling the program in an X11 release 3 source tree. If you have such a source tree, type the following in the xgraph-11 directory: % make TOP= where is the top level directory of the X11 release 3 source tree. If you don't have an X11 source tree but you have all of the X libraries and include files installed in "standard locations", type the following the in the xgraph-11 directory: % make -f Makefile.std Either of these commands will produce an executable xgraph in the xgraph-11 directory. If you are installing the program in an X11 source tree, you can use the following to install the program and manual page in the proper locations: % make TOP= install % make TOP= install.man You might want to try these commands with the "-n" option once to make sure the program and manual page are installed in the proper directories. If they aren't, you may want to change the DESTDIR variable and try again. If you really need to change the Makefile options, you can generate a new Makefile from the Imakefile using imake as provided on the X11 release tape. Several example data sets are provided in the xgraph-11/examples directory. Try the following to check out xgraph: % xgraph examples/xgtest.xg This should produce a graph with a series of parabolic curves. Other documentation files are included. A summary of these files is given below: README.ANNOUNCE Message submitted to comp.windows.x announcing the program and how to obtain it. README.GENERAL Important notes about differences and quirks of the program. README.HARDCOPY Documenation for writing your own hardcopy driver library. README.INSTALL This file. xgraph.man Xgraph manual page. David Harrison UC Berkeley Electronics Research Lab (davidh@ic.Berkeley.EDU, ...!ucbvax!ucbcad!davidh) xgraph-12.1.orig/README.NEWFEATURES0100664000175000000620000000367207360237513014777 0ustar bapstaffThis code is essentially XGraph release 11.4, with some modifications which were made for use by the NCSA Relativity group. These modifications were made by Paul Walker, and he should be contacted at the below address if you have any problems/questions regarding these features. 1. Animation. XGraph will now do a *very* crude animation of your data sets. It occasionally has problems with refreshes and will consequently run your animation three of four times. Consider this an undocumented feature! You can adjust the speed of the animation with the -dl option. I find "2" works well on a sparc displaying on MacX, "5" on a sparc on its own display, and "10" on an SGI or RS6K on its own display. Remeber, this animation is not being advertised as anything other than very crude, so if you are looking for production quality video, turn elsewhere. We find it useful as it will quickly generate animation which shows time evolution. 2. Differentation. You can press the "Derivative" button to see the first and second derivatives of your data set. The method is a standard centered difference. You cannot display higher than second derivatives. Animation, zooming, etc... work in each of the derivative windows. Endpoints are found linearly interpolating inner values to ends, so pay them little heed! 3. New Color Map. We couldn't differentiate the colors once we got past yellow, so we created a new color map. If you don't like it, look in init.c for the variable "defColors" and comment out the new one, replacing it with the commented old one. Of course, you are free to insert your own choices here also ... Just use standard X color names. These modifications were made by Paul Walker, and distributed with the Original author's consent. See Copyright.h for information about distribution and ownership of these changes. Contact Paul Walker at Paul Walker NCSA 605 E. Springfield Ave Champaign IL 61820 pwalker@ncsa.uiuc.edu xgraph-12.1.orig/aclocal.m40100664000175000000620000001142007360237475014165 0ustar bapstaffdnl aclocal.m4 generated automatically by aclocal 1.4 dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A dnl PARTICULAR PURPOSE. # Do all the work for Automake. This macro actually does too much -- # some checks are only needed if your package does certain things. # But this isn't really a big deal. # serial 1 dnl Usage: dnl AM_INIT_AUTOMAKE(package,version, [no-define]) AC_DEFUN(AM_INIT_AUTOMAKE, [AC_REQUIRE([AC_PROG_INSTALL]) PACKAGE=[$1] AC_SUBST(PACKAGE) VERSION=[$2] AC_SUBST(VERSION) dnl test to see if srcdir already configured if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi ifelse([$3],, AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])) AC_REQUIRE([AM_SANITY_CHECK]) AC_REQUIRE([AC_ARG_PROGRAM]) dnl FIXME This is truly gross. missing_dir=`cd $ac_aux_dir && pwd` AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir) AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir) AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir) AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir) AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir) AC_REQUIRE([AC_PROG_MAKE_SET])]) # # Check to make sure that the build environment is sane. # AC_DEFUN(AM_SANITY_CHECK, [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftestfile # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` if test "[$]*" = "X"; then # -L didn't work. set X `ls -t $srcdir/configure conftestfile` fi if test "[$]*" != "X $srcdir/configure conftestfile" \ && test "[$]*" != "X conftestfile $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "[$]2" = conftestfile ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi rm -f conftest* AC_MSG_RESULT(yes)]) dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY) dnl The program must properly implement --version. AC_DEFUN(AM_MISSING_PROG, [AC_MSG_CHECKING(for working $2) # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if ($2 --version) < /dev/null > /dev/null 2>&1; then $1=$2 AC_MSG_RESULT(found) else $1="$3/missing $2" AC_MSG_RESULT(missing) fi AC_SUBST($1)]) # Like AC_CONFIG_HEADER, but automatically create stamp file. AC_DEFUN(AM_CONFIG_HEADER, [AC_PREREQ([2.12]) AC_CONFIG_HEADER([$1]) dnl When config.status generates a header, we must update the stamp-h file. dnl This file resides in the same directory as the config header dnl that is generated. We must strip everything past the first ":", dnl and everything past the last "/". AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>, <>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>, <>; do case " <<$>>CONFIG_HEADERS " in *" <<$>>am_file "*<<)>> echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx ;; esac am_indx=`expr "<<$>>am_indx" + 1` done<<>>dnl>>) changequote([,]))]) # serial 1 AC_DEFUN(AM_WITH_DMALLOC, [AC_MSG_CHECKING(if malloc debugging is wanted) AC_ARG_WITH(dmalloc, [ --with-dmalloc use dmalloc, as in ftp://ftp.letters.com/src/dmalloc/dmalloc.tar.gz], [if test "$withval" = yes; then AC_MSG_RESULT(yes) AC_DEFINE(WITH_DMALLOC,1, [Define if using the dmalloc debugging malloc package]) LIBS="$LIBS -ldmalloc" LDFLAGS="$LDFLAGS -g" else AC_MSG_RESULT(no) fi], [AC_MSG_RESULT(no)]) ]) xgraph-12.1.orig/alloc.c0100664000175000000620000001242607360237507013566 0ustar bapstaff/* $Header: /usr/src/mash/repository/vint/xgraph/alloc.c,v 1.1.1.1 1999/12/03 23:15:53 heideman Exp $ */ /* * * alloc.c : Memory checked Malloc. This malloc keeps track of memory usage. * * Routines: * char * Malloc(); * char * Calloc(); * char * Realloc(); * void Free(); * unsigned MemStat(); * unsigned MemPtr(); * void MemChain(); * * $Log: alloc.c,v $ * Revision 1.1.1.1 1999/12/03 23:15:53 heideman * xgraph-12.0 * * Revision 1.10 1991/02/01 08:12:55 christos * Overhaul... Simplified and added calloc. * * Revision 1.9 1990/10/02 18:11:24 christos * Another Realloc() bug! * * Revision 1.8 90/10/02 17:32:45 christos * Fixed Realloc() bug. * * Revision 1.7 90/08/24 02:28:15 christos * Changed bigstruct_t to align_t * for lint. * * Revision 1.6 90/07/15 17:31:33 christos * Fixed MemPtr Bug * * Revision 1.5 90/07/11 16:19:31 christos * Added Realloc() * * Revision 1.4 90/03/21 12:58:44 christos * Fixed void buggy computations. * * Revision 1.3 90/02/26 02:15:11 christos * ANSI conformance. * * Revision 1.2 89/08/29 14:08:25 christos * Fixed. * * Revision 1.1 89/03/27 14:23:40 christos * Initial revision * */ #ifndef lint static char rcsid[] = "$Id: alloc.c,v 1.1.1.1 1999/12/03 23:15:53 heideman Exp $"; #endif /* lint */ #include #ifdef __STDC__ #include #include #else extern char *malloc(); extern char *calloc(); extern char *realloc(); extern void free(); extern void abort(); extern char *memset(); #endif #ifndef NIL #define NIL(a) ((a *) 0) #endif /* NIL */ #ifndef MIN #define MIN(a, b) ((a) > (b) ? (b) : (a)) #endif /* MIN */ #ifndef MAX #define MAX(a, b) ((a) < (b) ? (b) : (a)) #endif /* MAX */ #ifndef private #define private static #endif /* private */ #ifndef public #define public #endif /* public */ #define SIG_GOOD 0x01020304 #define SIG_FREE 0x04030201 #define OVERHEAD (sizeof(long) + sizeof(unsigned)) private unsigned memused = 0; private unsigned memalloc = 0; #ifdef __STDC__ typedef void *Ptr; #else typedef char *Ptr; #endif /* _chaina(): * Check things for validity and allocate space */ private Ptr _chaina(n, routine, action, tptr) unsigned n; Ptr(*routine) (); char *action; Ptr tptr; { char *ptr; if (n == 0) { (void) fprintf(stderr, "*** %s zero length block.\n", action); if (tptr != (Ptr) 0) { ptr = tptr; *((long *) ptr) = SIG_GOOD; memused += *((unsigned *) &ptr[sizeof(long)]); memalloc++; } abort(); } ptr = (tptr == (Ptr) 0) ? (char *) (*routine) (n + OVERHEAD) : (char *) (*routine) (tptr, n + OVERHEAD); if (ptr == NIL(char)) { if (tptr != (Ptr) 0) *((long *) tptr) = SIG_GOOD; (void) fprintf(stderr, "*** Out of memory in %s (current allocation %d).\n", action, memused, n); abort(); } *((long *) ptr) = SIG_GOOD; memused += (*((unsigned *) &ptr[sizeof(long)]) = n); memalloc++; ptr += OVERHEAD; return ((Ptr) ptr); } /* end _chaina */ /* _chainc(): * Check the pointer given */ private unsigned _chainc(ptr, action) char **ptr; char *action; { static char *msg = "*** %s %s pointer.\n"; if (*ptr == NIL(char)) { (void) fprintf(stderr, msg, action, "nil"); abort(); } *ptr -= OVERHEAD; switch (*((long *) *ptr)) { case SIG_GOOD: return (*((unsigned *) &((*ptr)[sizeof(long)]))); case SIG_FREE: (void) fprintf(stderr, msg, action, "free"); abort(); default: (void) fprintf(stderr, msg, action, "invalid"); abort(); } return (0); } /* end _chainc */ /* Malloc(): * real alloc */ public Ptr Malloc(n) unsigned n; { static char *routine = "malloc"; return (_chaina(n, malloc, routine, (Ptr) 0)); } /* end Malloc */ /* Calloc(): * real alloc */ public Ptr Calloc(n, sz) unsigned n, sz; { Ptr ptr; static char *routine = "calloc"; n *= sz; ptr = _chaina(n, malloc, routine, (Ptr) 0); memset((char *) ptr, 0, n); return (ptr); } /* end Calloc */ /* Realloc(): * real alloc */ public Ptr Realloc(ptr, n) Ptr ptr; unsigned n; { static char *routine = "realloc"; memused -= _chainc((char **) &ptr, routine); memalloc--; *((long *) ptr) = SIG_FREE; return (_chaina(n, realloc, routine, ptr)); } /* end Realloc */ /* Free(): * free memory counting the number of bytes freed */ public void Free(ptr) Ptr ptr; { static char *routine = "free"; memused -= _chainc((char **) &ptr, routine); memalloc--; *((long *) ptr) = SIG_FREE; free(ptr); } /* end Free */ /* MemChain(): * Dump the chain */ public void MemChain() { if (memused == 0 && memalloc == 0) (void) fprintf(stdout, "\tNo memory allocated.\n"); else { (void) fprintf(stdout, "\t%u Bytes allocated in %u chunks.\n", memused, memalloc); (void) fprintf(stdout, "\tAverage chunk length %u bytes.\n", memused / memalloc); } } /* end MemChain */ /* MemStat(): * return the amount of memory in use */ public unsigned MemStat() { return (memused); } /* end MemStat */ /* MemPtr(): * return the amount of memory used by the pointer */ public unsigned MemPtr(ptr) Ptr ptr; { static char *routine = "get size"; return (_chainc((char **) &ptr, routine)); } /* end MemPtr */ xgraph-12.1.orig/autoconf.h.in0100664000175000000620000000154707360237475014732 0ustar bapstaff/* autoconf.h.in. Generated automatically from configure.in by autoheader. */ /* Define if the X Window System is missing or not being used. */ #undef X_DISPLAY_MISSING /* Define if you have the strcasecmp function. */ #undef HAVE_STRCASECMP /* Define if you have the header file. */ #undef HAVE_FLOAT_H /* Define if you have the header file. */ #undef HAVE_LIMITS_H /* Define if you have the header file. */ #undef HAVE_STDLIB_H /* Define if you have the header file. */ #undef HAVE_STRING_H /* Define if you have the header file. */ #undef HAVE_STRINGS_H /* Define if you have the header file. */ #undef HAVE_UNISTD_H /* Name of package */ #undef PACKAGE /* Version number of package */ #undef VERSION /* Define if using the dmalloc debugging malloc package */ #undef WITH_DMALLOC xgraph-12.1.orig/configure0100775000175000000620000022762307360237500014237 0ustar bapstaff#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated automatically using autoconf version 2.13 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. # Defaults: ac_help= ac_default_prefix=/usr/local # Any additions from configure.in: ac_help="$ac_help --with-dmalloc use dmalloc, as in ftp://ftp.letters.com/src/dmalloc/dmalloc.tar.gz" ac_help="$ac_help --with-x use the X Window System" ac_help="$ac_help --with-additional-includes=path" ac_help="$ac_help --with-additional-libs=path" # Initialize some variables set by options. # The variables have the same names as the options, with # dashes changed to underlines. build=NONE cache_file=./config.cache exec_prefix=NONE host=NONE no_create= nonopt=NONE no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= target=NONE verbose= x_includes=NONE x_libraries=NONE bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datadir='${prefix}/share' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' infodir='${prefix}/info' mandir='${prefix}/man' # Initialize some other variables. subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. ac_max_here_lines=12 ac_prev= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" ac_prev= continue fi case "$ac_option" in -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; *) ac_optarg= ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case "$ac_option" in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir="$ac_optarg" ;; -build | --build | --buil | --bui | --bu) ac_prev=build ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build="$ac_optarg" ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file="$ac_optarg" ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) datadir="$ac_optarg" ;; -disable-* | --disable-*) ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } fi ac_feature=`echo $ac_feature| sed 's/-/_/g'` eval "enable_${ac_feature}=no" ;; -enable-* | --enable-*) ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } fi ac_feature=`echo $ac_feature| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes ;; esac eval "enable_${ac_feature}='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix="$ac_optarg" ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he) # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat << EOF Usage: configure [options] [host] Options: [defaults in brackets after descriptions] Configuration: --cache-file=FILE cache test results in FILE --help print this message --no-create do not create output files --quiet, --silent do not print \`checking...' messages --version print the version of autoconf that created configure Directory and file names: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [same as prefix] --bindir=DIR user executables in DIR [EPREFIX/bin] --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] --libexecdir=DIR program executables in DIR [EPREFIX/libexec] --datadir=DIR read-only architecture-independent data in DIR [PREFIX/share] --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data in DIR [PREFIX/com] --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] --libdir=DIR object code libraries in DIR [EPREFIX/lib] --includedir=DIR C header files in DIR [PREFIX/include] --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] --infodir=DIR info documentation in DIR [PREFIX/info] --mandir=DIR man documentation in DIR [PREFIX/man] --srcdir=DIR find the sources in DIR [configure dir or ..] --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names EOF cat << EOF Host type: --build=BUILD configure for building on BUILD [BUILD=HOST] --host=HOST configure for HOST [guessed] --target=TARGET configure for TARGET [TARGET=HOST] Features and packages: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --x-includes=DIR X include files are in DIR --x-libraries=DIR X library files are in DIR EOF if test -n "$ac_help"; then echo "--enable and --with options recognized:$ac_help" fi exit 0 ;; -host | --host | --hos | --ho) ac_prev=host ;; -host=* | --host=* | --hos=* | --ho=*) host="$ac_optarg" ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir="$ac_optarg" ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir="$ac_optarg" ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir="$ac_optarg" ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir="$ac_optarg" ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ | --locals | --local | --loca | --loc | --lo) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) localstatedir="$ac_optarg" ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir="$ac_optarg" ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir="$ac_optarg" ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix="$ac_optarg" ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix="$ac_optarg" ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix="$ac_optarg" ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name="$ac_optarg" ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir="$ac_optarg" ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir="$ac_optarg" ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site="$ac_optarg" ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir="$ac_optarg" ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir="$ac_optarg" ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target="$ac_optarg" ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers) echo "configure generated by autoconf version 2.13" exit 0 ;; -with-* | --with-*) ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } fi ac_package=`echo $ac_package| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes ;; esac eval "with_${ac_package}='$ac_optarg'" ;; -without-* | --without-*) ac_package=`echo $ac_option|sed -e 's/-*without-//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } fi ac_package=`echo $ac_package| sed 's/-/_/g'` eval "with_${ac_package}=no" ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes="$ac_optarg" ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries="$ac_optarg" ;; -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } ;; *) if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then echo "configure: warning: $ac_option: invalid host type" 1>&2 fi if test "x$nonopt" != xNONE; then { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } fi nonopt="$ac_option" ;; esac done if test -n "$ac_prev"; then { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } fi trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 # File descriptor usage: # 0 standard input # 1 file creation # 2 errors and warnings # 3 some systems may open it to /dev/tty # 4 used on the Kubota Titan # 6 checking for... messages and results # 5 compiler messages saved in config.log if test "$silent" = yes; then exec 6>/dev/null else exec 6>&1 fi exec 5>./config.log echo "\ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. " 1>&5 # Strip out --no-create and --no-recursion so they do not pile up. # Also quote any args containing shell metacharacters. ac_configure_args= for ac_arg do case "$ac_arg" in -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) ac_configure_args="$ac_configure_args '$ac_arg'" ;; *) ac_configure_args="$ac_configure_args $ac_arg" ;; esac done # NLS nuisances. # Only set these to C if already set. These must not be set unconditionally # because not all systems understand e.g. LANG=C (notably SCO). # Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! # Non-C LC_CTYPE values break the ctype check. if test "${LANG+set}" = set; then LANG=C; export LANG; fi if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -rf conftest* confdefs.h # AIX cpp loses on an empty file, so make sure it contains at least a newline. echo > confdefs.h # A filename unique to this package, relative to the directory that # configure is in, which we can look for to find out if srcdir is correct. ac_unique_file=xgraph.c # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. ac_prog=$0 ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. srcdir=$ac_confdir if test ! -r $srcdir/$ac_unique_file; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r $srcdir/$ac_unique_file; then if test "$ac_srcdir_defaulted" = yes; then { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } else { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } fi fi srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" else CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then echo "loading site script $ac_site_file" . "$ac_site_file" fi done if test -r "$cache_file"; then echo "loading cache $cache_file" . $cache_file else echo "creating cache $cache_file" > $cache_file fi ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross ac_exeext= ac_objext=o if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then ac_n= ac_c=' ' ac_t=' ' else ac_n=-n ac_c= ac_t= fi else ac_n= ac_c='\c' ac_t= fi ac_aux_dir= for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do if test -f $ac_dir/install-sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f $ac_dir/install.sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break fi done if test -z "$ac_aux_dir"; then { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } fi ac_config_guess=$ac_aux_dir/config.guess ac_config_sub=$ac_aux_dir/config.sub ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 echo "configure:565: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" for ac_dir in $PATH; do # Account for people who put trailing slashes in PATH elements. case "$ac_dir/" in /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do if test -f $ac_dir/$ac_prog; then if test $ac_prog = install && grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : else ac_cv_path_install="$ac_dir/$ac_prog -c" break 2 fi fi done ;; esac done IFS="$ac_save_IFS" fi if test "${ac_cv_path_install+set}" = set; then INSTALL="$ac_cv_path_install" else # As a last resort, use the slow shell script. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. INSTALL="$ac_install_sh" fi fi echo "$ac_t""$INSTALL" 1>&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 echo "configure:618: checking whether build environment is sane" >&5 # Just in case sleep 1 echo timestamp > conftestfile # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t $srcdir/configure conftestfile` fi if test "$*" != "X $srcdir/configure conftestfile" \ && test "$*" != "X conftestfile $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". { echo "configure: error: ls -t appears to fail. Make sure there is not a broken alias in your environment" 1>&2; exit 1; } fi test "$2" = conftestfile ) then # Ok. : else { echo "configure: error: newly created file is older than distributed files! Check your system clock" 1>&2; exit 1; } fi rm -f conftest* echo "$ac_t""yes" 1>&6 if test "$program_transform_name" = s,x,x,; then program_transform_name= else # Double any \ or $. echo might interpret backslashes. cat <<\EOF_SED > conftestsed s,\\,\\\\,g; s,\$,$$,g EOF_SED program_transform_name="`echo $program_transform_name|sed -f conftestsed`" rm -f conftestsed fi test "$program_prefix" != NONE && program_transform_name="s,^,${program_prefix},; $program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s,\$\$,${program_suffix},; $program_transform_name" # sed with no file args requires a program. test "$program_transform_name" = "" && program_transform_name="s,x,x," echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 echo "configure:675: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftestmake <<\EOF all: @echo 'ac_maketemp="${MAKE}"' EOF # GNU make sometimes prints "make[1]: Entering...", which would confuse us. eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=` if test -n "$ac_maketemp"; then eval ac_cv_prog_make_${ac_make}_set=yes else eval ac_cv_prog_make_${ac_make}_set=no fi rm -f conftestmake fi if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then echo "$ac_t""yes" 1>&6 SET_MAKE= else echo "$ac_t""no" 1>&6 SET_MAKE="MAKE=${MAKE-make}" fi PACKAGE=xgraph VERSION=12.1 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } fi cat >> confdefs.h <> confdefs.h <&6 echo "configure:721: checking for working aclocal" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (aclocal --version) < /dev/null > /dev/null 2>&1; then ACLOCAL=aclocal echo "$ac_t""found" 1>&6 else ACLOCAL="$missing_dir/missing aclocal" echo "$ac_t""missing" 1>&6 fi echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 echo "configure:734: checking for working autoconf" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (autoconf --version) < /dev/null > /dev/null 2>&1; then AUTOCONF=autoconf echo "$ac_t""found" 1>&6 else AUTOCONF="$missing_dir/missing autoconf" echo "$ac_t""missing" 1>&6 fi echo $ac_n "checking for working automake""... $ac_c" 1>&6 echo "configure:747: checking for working automake" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (automake --version) < /dev/null > /dev/null 2>&1; then AUTOMAKE=automake echo "$ac_t""found" 1>&6 else AUTOMAKE="$missing_dir/missing automake" echo "$ac_t""missing" 1>&6 fi echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 echo "configure:760: checking for working autoheader" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (autoheader --version) < /dev/null > /dev/null 2>&1; then AUTOHEADER=autoheader echo "$ac_t""found" 1>&6 else AUTOHEADER="$missing_dir/missing autoheader" echo "$ac_t""missing" 1>&6 fi echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 echo "configure:773: checking for working makeinfo" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (makeinfo --version) < /dev/null > /dev/null 2>&1; then MAKEINFO=makeinfo echo "$ac_t""found" 1>&6 else MAKEINFO="$missing_dir/missing makeinfo" echo "$ac_t""missing" 1>&6 fi echo $ac_n "checking if malloc debugging is wanted""... $ac_c" 1>&6 echo "configure:792: checking if malloc debugging is wanted" >&5 # Check whether --with-dmalloc or --without-dmalloc was given. if test "${with_dmalloc+set}" = set; then withval="$with_dmalloc" if test "$withval" = yes; then echo "$ac_t""yes" 1>&6 cat >> confdefs.h <<\EOF #define WITH_DMALLOC 1 EOF LIBS="$LIBS -ldmalloc" LDFLAGS="$LDFLAGS -g" else echo "$ac_t""no" 1>&6 fi else echo "$ac_t""no" 1>&6 fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:816: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="gcc" break fi done IFS="$ac_save_ifs" fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:846: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_prog_rejected=no ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" break fi done IFS="$ac_save_ifs" if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# -gt 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift set dummy "$ac_dir/$ac_word" "$@" shift ac_cv_prog_CC="$@" fi fi fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi if test -z "$CC"; then case "`uname -s`" in *win32* | *WIN32*) # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:897: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="cl" break fi done IFS="$ac_save_ifs" fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi ;; esac fi test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 echo "configure:929: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF #line 940 "configure" #include "confdefs.h" main(){return(0);} EOF if { (eval echo configure:945: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then ac_cv_prog_cc_cross=no else ac_cv_prog_cc_cross=yes fi else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_prog_cc_works=no fi rm -fr conftest* ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 echo "configure:971: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 echo "configure:976: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no fi fi echo "$ac_t""$ac_cv_prog_gcc" 1>&6 if test $ac_cv_prog_gcc = yes; then GCC=yes else GCC= fi ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 echo "configure:1004: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else echo 'void f(){}' > conftest.c if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then ac_cv_prog_cc_g=yes else ac_cv_prog_cc_g=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 if test "$ac_test_CFLAGS" = set; then CFLAGS="$ac_save_CFLAGS" elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 echo "configure:1037: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else # This must be in double quotes, not single quotes, because CPP may get # substituted into the Makefile and "${CC-cc}" will confuse make. CPP="${CC-cc} -E" # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1058: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1075: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1092: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP=/lib/cpp fi rm -f conftest* fi rm -f conftest* fi rm -f conftest* ac_cv_prog_CPP="$CPP" fi CPP="$ac_cv_prog_CPP" else ac_cv_prog_CPP="$CPP" fi echo "$ac_t""$CPP" 1>&6 # If we find X, set shell vars x_includes and x_libraries to the # paths, otherwise set no_x=yes. # Uses ac_ vars as temps to allow command line to override cache and checks. # --without-x overrides everything else, but does not touch the cache. echo $ac_n "checking for X""... $ac_c" 1>&6 echo "configure:1121: checking for X" >&5 # Check whether --with-x or --without-x was given. if test "${with_x+set}" = set; then withval="$with_x" : fi # $have_x is `yes', `no', `disabled', or empty when we do not yet know. if test "x$with_x" = xno; then # The user explicitly disabled X. have_x=disabled else if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then # Both variables are already set. have_x=yes else if eval "test \"`echo '$''{'ac_cv_have_x'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else # One or both of the vars are not set, and there is no cached value. ac_x_includes=NO ac_x_libraries=NO rm -fr conftestdir if mkdir conftestdir; then cd conftestdir # Make sure to not put "make" in the Imakefile rules, since we grep it out. cat > Imakefile <<'EOF' acfindx: @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"' EOF if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then # GNU make sometimes prints "make[1]: Entering...", which would confuse us. eval `${MAKE-make} acfindx 2>/dev/null | grep -v make` # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR. for ac_extension in a so sl; do if test ! -f $ac_im_usrlibdir/libX11.$ac_extension && test -f $ac_im_libdir/libX11.$ac_extension; then ac_im_usrlibdir=$ac_im_libdir; break fi done # Screen out bogus values from the imake configuration. They are # bogus both because they are the default anyway, and because # using them would break gcc on systems where it needs fixed includes. case "$ac_im_incroot" in /usr/include) ;; *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes="$ac_im_incroot" ;; esac case "$ac_im_usrlibdir" in /usr/lib | /lib) ;; *) test -d "$ac_im_usrlibdir" && ac_x_libraries="$ac_im_usrlibdir" ;; esac fi cd .. rm -fr conftestdir fi if test "$ac_x_includes" = NO; then # Guess where to find include files, by looking for this one X11 .h file. test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h # First, try using that file with no special directory specified. cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1188: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* # We can compile using X headers with no special include directory. ac_x_includes= else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Look for the header file in a standard set of common directories. # Check X11 before X11Rn because it is often a symlink to the current release. for ac_dir in \ /usr/X11/include \ /usr/X11R6/include \ /usr/X11R5/include \ /usr/X11R4/include \ \ /usr/include/X11 \ /usr/include/X11R6 \ /usr/include/X11R5 \ /usr/include/X11R4 \ \ /usr/local/X11/include \ /usr/local/X11R6/include \ /usr/local/X11R5/include \ /usr/local/X11R4/include \ \ /usr/local/include/X11 \ /usr/local/include/X11R6 \ /usr/local/include/X11R5 \ /usr/local/include/X11R4 \ \ /usr/X386/include \ /usr/x386/include \ /usr/XFree86/include/X11 \ \ /usr/include \ /usr/local/include \ /usr/unsupported/include \ /usr/athena/include \ /usr/local/x11r5/include \ /usr/lpp/Xamples/include \ \ /usr/openwin/include \ /usr/openwin/share/include \ ; \ do if test -r "$ac_dir/$x_direct_test_include"; then ac_x_includes=$ac_dir break fi done fi rm -f conftest* fi # $ac_x_includes = NO if test "$ac_x_libraries" = NO; then # Check for the libraries. test -z "$x_direct_test_library" && x_direct_test_library=Xt test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc # See if we find them without any special options. # Don't add to $LIBS permanently. ac_save_LIBS="$LIBS" LIBS="-l$x_direct_test_library $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* LIBS="$ac_save_LIBS" # We can link X programs with no special library path. ac_x_libraries= else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* LIBS="$ac_save_LIBS" # First see if replacing the include by lib works. # Check X11 before X11Rn because it is often a symlink to the current release. for ac_dir in `echo "$ac_x_includes" | sed s/include/lib/` \ /usr/X11/lib \ /usr/X11R6/lib \ /usr/X11R5/lib \ /usr/X11R4/lib \ \ /usr/lib/X11 \ /usr/lib/X11R6 \ /usr/lib/X11R5 \ /usr/lib/X11R4 \ \ /usr/local/X11/lib \ /usr/local/X11R6/lib \ /usr/local/X11R5/lib \ /usr/local/X11R4/lib \ \ /usr/local/lib/X11 \ /usr/local/lib/X11R6 \ /usr/local/lib/X11R5 \ /usr/local/lib/X11R4 \ \ /usr/X386/lib \ /usr/x386/lib \ /usr/XFree86/lib/X11 \ \ /usr/lib \ /usr/local/lib \ /usr/unsupported/lib \ /usr/athena/lib \ /usr/local/x11r5/lib \ /usr/lpp/Xamples/lib \ /lib/usr/lib/X11 \ \ /usr/openwin/lib \ /usr/openwin/share/lib \ ; \ do for ac_extension in a so sl; do if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then ac_x_libraries=$ac_dir break 2 fi done done fi rm -f conftest* fi # $ac_x_libraries = NO if test "$ac_x_includes" = NO || test "$ac_x_libraries" = NO; then # Didn't find X anywhere. Cache the known absence of X. ac_cv_have_x="have_x=no" else # Record where we found X for the cache. ac_cv_have_x="have_x=yes \ ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries" fi fi fi eval "$ac_cv_have_x" fi # $with_x != no if test "$have_x" != yes; then echo "$ac_t""$have_x" 1>&6 no_x=yes else # If each of the values was on the command line, it overrides each guess. test "x$x_includes" = xNONE && x_includes=$ac_x_includes test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries # Update the cache value to reflect the command line values. ac_cv_have_x="have_x=yes \ ac_x_includes=$x_includes ac_x_libraries=$x_libraries" echo "$ac_t""libraries $x_libraries, headers $x_includes" 1>&6 fi if test "$no_x" = yes; then # Not all programs may use this symbol, but it does not hurt to define it. cat >> confdefs.h <<\EOF #define X_DISPLAY_MISSING 1 EOF X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS= else if test -n "$x_includes"; then X_CFLAGS="$X_CFLAGS -I$x_includes" fi # It would also be nice to do this for all -L options, not just this one. if test -n "$x_libraries"; then X_LIBS="$X_LIBS -L$x_libraries" # For Solaris; some versions of Sun CC require a space after -R and # others require no space. Words are not sufficient . . . . case "`(uname -sr) 2>/dev/null`" in "SunOS 5"*) echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6 echo "configure:1370: checking whether -R must be followed by a space" >&5 ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_R_nospace=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_R_nospace=no fi rm -f conftest* if test $ac_R_nospace = yes; then echo "$ac_t""no" 1>&6 X_LIBS="$X_LIBS -R$x_libraries" else LIBS="$ac_xsave_LIBS -R $x_libraries" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_R_space=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_R_space=no fi rm -f conftest* if test $ac_R_space = yes; then echo "$ac_t""yes" 1>&6 X_LIBS="$X_LIBS -R $x_libraries" else echo "$ac_t""neither works" 1>&6 fi fi LIBS="$ac_xsave_LIBS" esac fi # Check for system-dependent libraries X programs must link with. # Do this before checking for the system-independent R6 libraries # (-lICE), since we may need -lsocket or whatever for X linking. if test "$ISC" = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet" else # Martyn.Johnson@cl.cam.ac.uk says this is needed for Ultrix, if the X # libraries were built with DECnet support. And karl@cs.umb.edu says # the Alpha needs dnet_stub (dnet does not exist). echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6 echo "configure:1435: checking for dnet_ntoa in -ldnet" >&5 ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-ldnet $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" else echo "$ac_t""no" 1>&6 fi if test $ac_cv_lib_dnet_dnet_ntoa = no; then echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6 echo "configure:1476: checking for dnet_ntoa in -ldnet_stub" >&5 ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-ldnet_stub $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub" else echo "$ac_t""no" 1>&6 fi fi # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT, # to get the SysV transport functions. # chad@anasazi.com says the Pyramis MIS-ES running DC/OSx (SVR4) # needs -lnsl. # The nsl library prevents programs from opening the X display # on Irix 5.2, according to dickey@clark.net. echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6 echo "configure:1524: checking for gethostbyname" >&5 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char gethostbyname(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_gethostbyname) || defined (__stub___gethostbyname) choke me #else gethostbyname(); #endif ; return 0; } EOF if { (eval echo configure:1552: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_gethostbyname=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_gethostbyname=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'gethostbyname`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 fi if test $ac_cv_func_gethostbyname = no; then echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6 echo "configure:1573: checking for gethostbyname in -lnsl" >&5 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl" else echo "$ac_t""no" 1>&6 fi fi # lieder@skyler.mavd.honeywell.com says without -lsocket, # socket/setsockopt and other routines are undefined under SCO ODT # 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary # on later versions), says simon@lia.di.epfl.ch: it contains # gethostby* variants that don't use the nameserver (or something). # -lsocket must be given before -lnsl if both are needed. # We assume that if connect needs -lnsl, so does gethostbyname. echo $ac_n "checking for connect""... $ac_c" 1>&6 echo "configure:1622: checking for connect" >&5 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char connect(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_connect) || defined (__stub___connect) choke me #else connect(); #endif ; return 0; } EOF if { (eval echo configure:1650: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_connect=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_connect=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'connect`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 fi if test $ac_cv_func_connect = no; then echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6 echo "configure:1671: checking for connect in -lsocket" >&5 ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lsocket $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS" else echo "$ac_t""no" 1>&6 fi fi # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX. echo $ac_n "checking for remove""... $ac_c" 1>&6 echo "configure:1714: checking for remove" >&5 if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char remove(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_remove) || defined (__stub___remove) choke me #else remove(); #endif ; return 0; } EOF if { (eval echo configure:1742: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_remove=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_remove=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'remove`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 fi if test $ac_cv_func_remove = no; then echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6 echo "configure:1763: checking for remove in -lposix" >&5 ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lposix $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix" else echo "$ac_t""no" 1>&6 fi fi # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. echo $ac_n "checking for shmat""... $ac_c" 1>&6 echo "configure:1806: checking for shmat" >&5 if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char shmat(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_shmat) || defined (__stub___shmat) choke me #else shmat(); #endif ; return 0; } EOF if { (eval echo configure:1834: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_shmat=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_shmat=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'shmat`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 fi if test $ac_cv_func_shmat = no; then echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6 echo "configure:1855: checking for shmat in -lipc" >&5 ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lipc $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc" else echo "$ac_t""no" 1>&6 fi fi fi # Check for libraries that X11R6 Xt/Xaw programs need. ac_save_LDFLAGS="$LDFLAGS" test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries" # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to # check for ICE first), but we must link in the order -lSM -lICE or # we get undefined symbols. So assume we have SM if we have ICE. # These have to be linked with before -lX11, unlike the other # libraries we check for below, so use a different variable. # --interran@uluru.Stanford.EDU, kb@cs.umb.edu. echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6 echo "configure:1907: checking for IceConnectionNumber in -lICE" >&5 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lICE $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE" else echo "$ac_t""no" 1>&6 fi LDFLAGS="$ac_save_LDFLAGS" fi for ac_hdr in float.h limits.h stdlib.h string.h strings.h unistd.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:1955: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1965: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done for ac_func in strcasecmp do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:1996: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:2024: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 fi done # Check whether --with-additional-includes or --without-additional-includes was given. if test "${with_additional_includes+set}" = set; then withval="$with_additional_includes" ADDITIONAL_INCLUDES=$withval else ADDITIONAL_INCLUDES="" fi # Check whether --with-additional-libs or --without-additional-libs was given. if test "${with_additional_libs+set}" = set; then withval="$with_additional_libs" ADDITIONAL_LIBS=$withval else ADDITIONAL_LIBS="" fi trap '' 1 2 15 cat > confcache <<\EOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs. It is not useful on other systems. # If it contains results you don't want to keep, you may remove or edit it. # # By default, configure uses ./config.cache as the cache file, # creating it if it does not exist already. You can give configure # the --cache-file=FILE option to use a different cache file; that is # what configure does when it calls configure scripts in # subdirectories, so they share the cache. # Giving --cache-file=/dev/null disables caching, for debugging configure. # config.status only pays attention to the cache file if you give it the # --recheck option to rerun configure. # EOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. (set) 2>&1 | case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote substitution # turns \\\\ into \\, and sed turns \\ into \). sed -n \ -e "s/'/'\\\\''/g" \ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' ;; esac >> confcache if cmp -s $cache_file confcache; then : else if test -w $cache_file; then echo "updating cache $cache_file" cat confcache > $cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # Any assignment to VPATH causes Sun make to only execute # the first set of double-colon rules, so remove it if not needed. # If there is a colon in the path, we need to keep it. if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' fi trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 DEFS=-DHAVE_CONFIG_H # Without the "./", some shells look in PATH for config.status. : ${CONFIG_STATUS=./config.status} echo creating $CONFIG_STATUS rm -f $CONFIG_STATUS cat > $CONFIG_STATUS </dev/null | sed 1q`: # # $0 $ac_configure_args # # Compiler output produced by configure, useful for debugging # configure, is in ./config.log if it exists. ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" for ac_option do case "\$ac_option" in -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) echo "$CONFIG_STATUS generated by autoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; *) echo "\$ac_cs_usage"; exit 1 ;; esac done ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" trap 'rm -fr `echo "Makefile autoconf.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF $ac_vpsub $extrasub s%@SHELL@%$SHELL%g s%@CFLAGS@%$CFLAGS%g s%@CPPFLAGS@%$CPPFLAGS%g s%@CXXFLAGS@%$CXXFLAGS%g s%@FFLAGS@%$FFLAGS%g s%@DEFS@%$DEFS%g s%@LDFLAGS@%$LDFLAGS%g s%@LIBS@%$LIBS%g s%@exec_prefix@%$exec_prefix%g s%@prefix@%$prefix%g s%@program_transform_name@%$program_transform_name%g s%@bindir@%$bindir%g s%@sbindir@%$sbindir%g s%@libexecdir@%$libexecdir%g s%@datadir@%$datadir%g s%@sysconfdir@%$sysconfdir%g s%@sharedstatedir@%$sharedstatedir%g s%@localstatedir@%$localstatedir%g s%@libdir@%$libdir%g s%@includedir@%$includedir%g s%@oldincludedir@%$oldincludedir%g s%@infodir@%$infodir%g s%@mandir@%$mandir%g s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g s%@INSTALL_DATA@%$INSTALL_DATA%g s%@PACKAGE@%$PACKAGE%g s%@VERSION@%$VERSION%g s%@ACLOCAL@%$ACLOCAL%g s%@AUTOCONF@%$AUTOCONF%g s%@AUTOMAKE@%$AUTOMAKE%g s%@AUTOHEADER@%$AUTOHEADER%g s%@MAKEINFO@%$MAKEINFO%g s%@SET_MAKE@%$SET_MAKE%g s%@CC@%$CC%g s%@CPP@%$CPP%g s%@X_CFLAGS@%$X_CFLAGS%g s%@X_PRE_LIBS@%$X_PRE_LIBS%g s%@X_LIBS@%$X_LIBS%g s%@X_EXTRA_LIBS@%$X_EXTRA_LIBS%g s%@ADDITIONAL_INCLUDES@%$ADDITIONAL_INCLUDES%g s%@ADDITIONAL_LIBS@%$ADDITIONAL_LIBS%g CEOF EOF cat >> $CONFIG_STATUS <<\EOF # Split the substitutions into bite-sized pieces for seds with # small command number limits, like on Digital OSF/1 and HP-UX. ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. ac_file=1 # Number of current file. ac_beg=1 # First line for current file. ac_end=$ac_max_sed_cmds # Line after last line for current file. ac_more_lines=: ac_sed_cmds="" while $ac_more_lines; do if test $ac_beg -gt 1; then sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file else sed "${ac_end}q" conftest.subs > conftest.s$ac_file fi if test ! -s conftest.s$ac_file; then ac_more_lines=false rm -f conftest.s$ac_file else if test -z "$ac_sed_cmds"; then ac_sed_cmds="sed -f conftest.s$ac_file" else ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" fi ac_file=`expr $ac_file + 1` ac_beg=$ac_end ac_end=`expr $ac_end + $ac_max_sed_cmds` fi done if test -z "$ac_sed_cmds"; then ac_sed_cmds=cat fi EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; *) ac_file_in="${ac_file}.in" ;; esac # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. # Remove last slash and all that follows it. Not all systems have dirname. ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then # The file is in a subdirectory. test ! -d "$ac_dir" && mkdir "$ac_dir" ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" # A "../" for each directory in $ac_dir_suffix. ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` else ac_dir_suffix= ac_dots= fi case "$ac_given_srcdir" in .) srcdir=. if test -z "$ac_dots"; then top_srcdir=. else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; *) # Relative path. srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" top_srcdir="$ac_dots$ac_given_srcdir" ;; esac case "$ac_given_INSTALL" in [/$]*) INSTALL="$ac_given_INSTALL" ;; *) INSTALL="$ac_dots$ac_given_INSTALL" ;; esac echo creating "$ac_file" rm -f "$ac_file" configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." case "$ac_file" in *Makefile*) ac_comsub="1i\\ # $configure_input" ;; *) ac_comsub= ;; esac ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` sed -e "$ac_comsub s%@configure_input@%$configure_input%g s%@srcdir@%$srcdir%g s%@top_srcdir@%$top_srcdir%g s%@INSTALL@%$INSTALL%g " $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file fi; done rm -f conftest.s* # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. # # ac_d sets the value in "#define NAME VALUE" lines. ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' ac_dC='\3' ac_dD='%g' # ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_uB='\([ ]\)%\1#\2define\3' ac_uC=' ' ac_uD='\4%g' # ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_eB='$%\1#\2define\3' ac_eC=' ' ac_eD='%g' if test "${CONFIG_HEADERS+set}" != set; then EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF fi for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; *) ac_file_in="${ac_file}.in" ;; esac echo creating $ac_file rm -f conftest.frag conftest.in conftest.out ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` cat $ac_file_inputs > conftest.in EOF # Transform confdefs.h into a sed script conftest.vals that substitutes # the proper values into config.h.in to produce config.h. And first: # Protect against being on the right side of a sed subst in config.status. # Protect against being in an unquoted here document in config.status. rm -f conftest.vals cat > conftest.hdr <<\EOF s/[\\&%]/\\&/g s%[\\$`]%\\&%g s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp s%ac_d%ac_u%gp s%ac_u%ac_e%gp EOF sed -n -f conftest.hdr confdefs.h > conftest.vals rm -f conftest.hdr # This sed command replaces #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. cat >> conftest.vals <<\EOF s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% EOF # Break up conftest.vals because some shells have a limit on # the size of here documents, and old seds have small limits too. rm -f conftest.tail while : do ac_lines=`grep -c . conftest.vals` # grep -c gives empty output for an empty file on some AIX systems. if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi # Write a limited-size here document to conftest.frag. echo ' cat > conftest.frag <> $CONFIG_STATUS sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS echo 'CEOF sed -f conftest.frag conftest.in > conftest.out rm -f conftest.in mv conftest.out conftest.in ' >> $CONFIG_STATUS sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail rm -f conftest.vals mv conftest.tail conftest.vals done rm -f conftest.vals cat >> $CONFIG_STATUS <<\EOF rm -f conftest.frag conftest.h echo "/* $ac_file. Generated automatically by configure. */" > conftest.h cat conftest.in >> conftest.h rm -f conftest.in if cmp -s $ac_file conftest.h 2>/dev/null; then echo "$ac_file is unchanged" rm -f conftest.h else # Remove last slash and all that follows it. Not all systems have dirname. ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then # The file is in a subdirectory. test ! -d "$ac_dir" && mkdir "$ac_dir" fi rm -f $ac_file mv conftest.h $ac_file fi fi; done EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h exit 0 EOF chmod +x $CONFIG_STATUS rm -fr confdefs* $ac_clean_files test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 xgraph-12.1.orig/configure.in0100664000175000000620000000147007360237500014627 0ustar bapstaffdnl Process this file with autoconf to produce a configure script. AC_INIT(xgraph.c) AM_INIT_AUTOMAKE(xgraph,12.1) AM_CONFIG_HEADER(autoconf.h) AM_WITH_DMALLOC dnl Checks for programs. AC_PROG_CC dnl Checks for libraries. AC_PATH_XTRA dnl check header files. AC_CHECK_HEADERS(float.h limits.h stdlib.h string.h strings.h unistd.h) dnl checks for typedefs dnl checks for structures dnl checks for compiler characteristics dnl checks for library functions AC_CHECK_FUNCS(strcasecmp) dnl checks for system services AC_ARG_WITH(additional-includes, --with-additional-includes=path, ADDITIONAL_INCLUDES=$withval,ADDITIONAL_INCLUDES="") AC_ARG_WITH(additional-libs, --with-additional-libs=path, ADDITIONAL_LIBS=$withval,ADDITIONAL_LIBS="") AC_SUBST(ADDITIONAL_INCLUDES) AC_SUBST(ADDITIONAL_LIBS) AC_OUTPUT([Makefile]) xgraph-12.1.orig/copyright.h0100664000175000000620000000512107360237511014476 0ustar bapstaff/* * xgraph - program to graphically display numerical data * * David Harrison * University of California, Berkeley * 1989 * * Animation, Differentiation by Paul Walker * NCSA and University of Illinois at Urbana Champaign Dept. of Physics * * Copyright (c) 1988, 1989, Regents of the University of California. * All rights reserved. * * Use and copying of this software and preparation of derivative works * based upon this software are permitted. However, any distribution of * this software or derivative works must include the above copyright * notice. * * This software is made available AS IS, and neither the Electronics * Research Laboratory or the University of California make any * warranty about the software, its performance or its conformity to * any specification. * Animation and differentiation routines were added by Paul Walker, NCSA and UIUC Dept of Physics. The following copyright and disclaimer applies to these parts of the code only. UNIVERSITY OF ILLINOIS (UI), NATIONAL CENTER FOR SUPERCOMPUTING APPLICATIONS (NCSA), Software Distribution Policy for Copyrighted Software The above mentioned modifications to XGraph made with the authors consent are copyrighted, but available without fee for education, academic research and non-commercial purposes. The modifications are copyrighted in the name of the UI, and ownership of the modifications remains with the UI. Users may distribute the binary and source code to third parties provided that the copyright notice and this statement appears on all copies and that no charge is made for such copies. Any entity wishing to integrate all or part of the source code into a product for commercial use or resale, should contact the University of Illinois, c/o NCSA, to negotiate an appropriate license for such commercial use. UI MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. THE UI SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY THE USER OF THIS SOFTWARE. The software may have been developed under agreements between the UI and the Federal Government which entitle the Government to certain rights. By copying this program, you, the user, agree to abide by the copyright conditions and understandings with respect to any software which is marked with a copyright notice. Send all comments about the modifications to Paul Walker, pwalker@ncsa.uiuc.edu * */ #ifndef _RIGHTS_ #define _RIGHTS_ static char copyright[] = "Copyright (c) 1989, Regents of the University of California. All rights reserved."; #endif /* _RIGHTS_ */ xgraph-12.1.orig/derivative.c0100664000175000000620000001041207360237511014622 0ustar bapstaff/* This entire routine written by PW. */ #include #include #include "xgraph.h" void Der1() { PointList *theList, *D1List, *D2List; double m,b; int i; for (i=0;inumPoints = D2List->numPoints = theList->numPoints; D1List->xvec = (double *)malloc(sizeof(double)*theList->numPoints); D1List->yvec = (double *)malloc(sizeof(double)*theList->numPoints); D1List->next = NULL; D2List->xvec = (double *)malloc(sizeof(double)*theList->numPoints); D2List->yvec = (double *)malloc(sizeof(double)*theList->numPoints); D2List->next = NULL; for (j=1;jnumPoints-1;j++) { D1List->xvec[j] = D2List->xvec[j] = theList->xvec[j]; D1List->yvec[j] = (theList->yvec[j+1] - theList->yvec[j-1]) / (theList->xvec[j+1] - theList->xvec[j-1]); D2List->yvec[j] = (theList->yvec[j+1] + theList->yvec[j-1] - 2.0*theList->yvec[j]) / ((theList->xvec[j+1] - theList->xvec[j]) * (theList->xvec[j]-theList->xvec[j-1])); } /* Extrapolate to get the endpoints ... */ /* end near 0 */ D1List->xvec[0] = theList->xvec[0]; D1List->xvec[theList->numPoints-1] = theList->xvec[theList->numPoints-1]; m = (D1List->yvec[2]-D1List->yvec[1]) / (theList->xvec[2]-theList->xvec[1]); b = D1List->yvec[1] - m*theList->xvec[1]; D1List->yvec[0] = m*theList->xvec[0] + b; /* end near numPoints-1 */ m = (D1List->yvec[theList->numPoints-2]- D1List->yvec[theList->numPoints-3]) / (theList->xvec[theList->numPoints-2]- theList->xvec[theList->numPoints-3]); b = D1List->yvec [theList->numPoints-2] - m*theList->xvec[theList->numPoints-2]; D1List->yvec[theList->numPoints-1] = m*theList->xvec[theList->numPoints-1] + b; /* Extrapolate to get the endpoints ... */ /* end near 0 */ D2List->xvec[0] = theList->xvec[0]; D2List->xvec[theList->numPoints-1] = theList->xvec[theList->numPoints-1]; m = (D2List->yvec[2]-D2List->yvec[1]) / (theList->xvec[2]-theList->xvec[1]); b = D2List->yvec[1] - m*theList->xvec[1]; D2List->yvec[0] = m*theList->xvec[0] + b; /* end near numPoints-1 */ m = (D2List->yvec[theList->numPoints-2]- D2List->yvec[theList->numPoints-3]) / (theList->xvec[theList->numPoints-2]- theList->xvec[theList->numPoints-3]); b = D2List->yvec[theList->numPoints-2] - m*theList->xvec[theList->numPoints-2]; D2List->yvec[theList->numPoints-1] = m*theList->xvec[theList->numPoints-1] + b; theList = theList->next; if (theList) { D1List->next = (PointList *)malloc(sizeof(PointList)); D2List->next = (PointList *)malloc(sizeof(PointList)); D1List = D1List->next; D2List = D2List->next; } } } } void Bounds(loX, loY, hiX, hiY, Ord) double *loX, *loY, *hiX, *hiY; int Ord; { int i; PointList *theList; if ((Ord<1) || (Ord>2)) { printf ("Internal Error - Cannot eval deriv > 2 in Bounds.\n"); exit(1); } *loX = *loY = *hiX = *hiY = 0.0; for (i=0;inumPoints;j++) { *loX = (theList->xvec[j]<*loX?theList->xvec[j]:*loX); *loY = (theList->yvec[j]<*loY?theList->yvec[j]:*loY); *hiX = (theList->xvec[j]>*hiX?theList->xvec[j]:*hiX); *hiY = (theList->yvec[j]>*hiY?theList->yvec[j]:*hiY); } theList = theList->next; } } } xgraph-12.1.orig/dialog.c0100664000175000000620000006505607360237503013736 0ustar bapstaff/* * Xgraph Dialog Boxes * * This file constructs the hardcopy and error dialog * boxes used by xgraph. It uses the mini-toolbox given * in toolbox.c. */ #include "copyright.h" #include "xgout.h" #include "xgraph.h" #include "hard_devices.h" #include "xtb.h" #include "params.h" #include #include void do_error(); #define MAXCHBUF 1024 #ifdef SHADOW #define gray_width 16 #define gray_height 16 static short gray_bits[] = { 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa}; #endif static void make_msg_box(); static void del_msg_box(); #define D_VPAD 2 #define D_HPAD 2 #define D_INT 4 #define D_BRDR 2 #define D_INP 35 #define D_DSP 10 #define D_FS 10 struct d_info { char *prog; /* Program name */ xtb_data cookie; /* Info used by do_harcopy */ Window choices; /* Output device choices */ Window fod; /* File or device flag */ Window fodspec; /* File or device spec */ Window docu_p; /* Document predicate */ Window dimspec; /* Maximum dimension spec */ Window tf_family; /* Title font family spec */ Window tf_size; /* Title font size spec */ Window af_family; /* Axis font family spec */ Window af_size; /* Axis font size spec */ }; #define BACKSPACE 0010 #define DELETE 0177 #define CONTROL_U 0025 #define CONTROL_X 0030 /*ARGSUSED*/ static xtb_hret df_fun(win, ch, text, val) Window win; /* Widget window */ int ch; /* Typed character */ char *text; /* Copy of text */ xtb_data val; /* User info */ /* * This is the handler function for the text widget for * specifing the file or device name. It supports simple * line editing operations. */ { if ((ch == BACKSPACE) || (ch == DELETE)) { if (!xtb_ti_dch(win)) XBell(disp, 0); } else if ((ch == CONTROL_U) || (ch == CONTROL_X)) { (void) xtb_ti_set(win, "", (xtb_data) 0); } else { /* Insert if printable - ascii dependent */ if ((ch < ' ') || (ch >= DELETE) || !xtb_ti_ins(win, ch)) { XBell(disp, 0); } } return XTB_HANDLED; } /*ARGSUSED*/ static xtb_hret ok_fun(win, bval, info) Window win; /* Button window */ int bval; /* Button value */ xtb_data info; /* Local button info */ /* * This is the handler function for when the `Ok' button * is hit. It sets the button, does the hardcopy output, * and turns the button off. It returns a status which * deactivates the dialog. */ { struct d_info *real_info = (struct d_info *) info; int val, dev_p, doc_p; char file_or_dev[MAXCHBUF], dim_spec[MAXCHBUF], *dev_spec; char tfam[MAXCHBUF], afam[MAXCHBUF]; char tsizstr[MAXCHBUF], asizstr[MAXCHBUF]; double centimeters, tsize, asize; xtb_hret rtn; (void) xtb_bt_set(win, 1, (xtb_data) 0, 0); val = xtb_br_get(real_info->choices); if ((val >= 0) && (val < hard_count)) { dev_p = xtb_br_get(real_info->fod); if ((dev_p == 0) || (dev_p == 1)) { xtb_ti_get(real_info->fodspec, file_or_dev, (xtb_data *) 0); doc_p = xtb_bt_get(real_info->docu_p, (xtb_data *) 0, (int *) 0); xtb_ti_get(real_info->dimspec, dim_spec, (xtb_data *) 0); if (sscanf(dim_spec, "%lf", ¢imeters) == 1) { xtb_ti_get(real_info->tf_family, tfam, (xtb_data *) 0); xtb_ti_get(real_info->af_family, afam, (xtb_data *) 0); xtb_ti_get(real_info->tf_size, tsizstr, (xtb_data *) 0); if (sscanf(tsizstr, "%lf", &tsize) == 1) { xtb_ti_get(real_info->af_size, asizstr, (xtb_data *) 0); if (sscanf(asizstr, "%lf", &asize) == 1) { /* Got all the info */ if (dev_p) { dev_spec = (char *) 0; } else { dev_spec = hard_devices[val].dev_spec; } do_hardcopy(real_info->prog, real_info->cookie, hard_devices[val].dev_init, dev_spec, file_or_dev, centimeters, tfam, tsize, afam, asize, doc_p); rtn = XTB_STOP; } else { /* Bad axis size */ do_error("Bad axis font size\n"); rtn = XTB_HANDLED; } } else { /* Bad title size */ do_error("Bad title font size\n"); rtn = XTB_HANDLED; } } else { /* Bad max dimension */ do_error("Bad maximum dimension\n"); rtn = XTB_HANDLED; } } else { /* Bad device spec */ do_error("Must specify `To File' or `To Device'\n"); rtn = XTB_HANDLED; } } else { /* Bad value spec */ do_error("Must specify an output device\n"); rtn = XTB_HANDLED; } (void) xtb_bt_set(win, 0, (xtb_data) 0, 0); return rtn; } /*ARGSUSED*/ static xtb_hret can_fun(win, val, info) Window win; /* Button window */ int val; /* Button value */ xtb_data info; /* Local button info */ /* * This is the handler function for the cancel button. It * turns itself on and off and then exits with a status * which kills the dialog. */ { (void) xtb_bt_set(win, 1, (xtb_data) 0, 0); (void) xtb_bt_set(win, 0, (xtb_data) 0, 0); return XTB_STOP; } /*ARGSUSED*/ static xtb_hret docu_fun(win, val, info) Window win; /* Button window */ int val; /* Button value */ xtb_data info; /* Local button info */ /* * This is the handler function for the document button. It * toggles it's state. */ { int state; state = xtb_bt_get(win, (xtb_data *) 0, (int *) 0); xtb_bt_set(win, (state == 0), (xtb_data) 0, 0); return XTB_HANDLED; } /*ARGSUSED*/ static xtb_hret dev_fun(win, old, new, info) Window win; /* Button row window */ int old; /* Previous button */ int new; /* Current button */ xtb_data info; /* User data */ /* * This routine swaps the device specific information * in the dialog based on what device is selected. The * information passed is the information for the whole * dialog. */ { struct d_info *data = (struct d_info *) info; char text[MAXCHBUF]; int fod_spot, inactive; fod_spot = xtb_br_get(data->fod); if ((old >= 0) && (old < hard_count)) { /* Save old info */ xtb_ti_get(data->fodspec, text, (xtb_data *) 0); if (fod_spot == 1) { strncpy(hard_devices[old].dev_file, text, MFNAME - 1); } else if (fod_spot == 0) { strncpy(hard_devices[old].dev_printer, text, MFNAME - 1); } if (xtb_bt_get(data->docu_p, (xtb_data *) 0, &inactive)) { if (inactive) hard_devices[old].dev_docu = NONE; else hard_devices[old].dev_docu = YES; } else if (inactive) hard_devices[old].dev_docu = NONE; else hard_devices[old].dev_docu = NO; xtb_ti_get(data->dimspec, text, (xtb_data *) 0); if (sscanf(text, "%lf", &hard_devices[old].dev_max_dim) != 1) { do_error("Warning: can't read maximum dimension"); } xtb_ti_get(data->tf_family, text, (xtb_data *) 0); strncpy(hard_devices[old].dev_title_font, text, MFNAME - 1); xtb_ti_get(data->tf_size, text, (xtb_data *) 0); if (sscanf(text, "%lf", &hard_devices[old].dev_title_size) != 1) { do_error("Warning: can't read title font size"); } xtb_ti_get(data->af_family, text, (xtb_data *) 0); strncpy(hard_devices[old].dev_axis_font, text, MFNAME - 1); xtb_ti_get(data->af_size, text, (xtb_data *) 0); if (sscanf(text, "%lf", &hard_devices[old].dev_axis_size) != 1) { do_error("Warning: can't read axis font size"); } } /* Insert new info */ if ((new >= 0) && (new < hard_count)) { if (fod_spot == 1) { xtb_ti_set(data->fodspec, hard_devices[new].dev_file, (xtb_data) 0); } else if (fod_spot == 0) { xtb_ti_set(data->fodspec, hard_devices[new].dev_printer, (xtb_data) 0); } else { xtb_ti_set(data->fodspec, "", (xtb_data) 0); } switch (hard_devices[new].dev_docu) { case NONE: (void) xtb_bt_set(data->docu_p, 0, (xtb_data) 0, 1); break; case NO: (void) xtb_bt_set(data->docu_p, 0, (xtb_data) 0, 0); break; case YES: (void) xtb_bt_set(data->docu_p, 1, (xtb_data) 0, 0); break; } (void) sprintf(text, "%lg", hard_devices[new].dev_max_dim); xtb_ti_set(data->dimspec, text, (xtb_data) 0); xtb_ti_set(data->tf_family, hard_devices[new].dev_title_font, (xtb_data) 0); (void) sprintf(text, "%lg", hard_devices[new].dev_title_size); xtb_ti_set(data->tf_size, text, (xtb_data) 0); xtb_ti_set(data->af_family, hard_devices[new].dev_axis_font, (xtb_data) 0); (void) sprintf(text, "%lg", hard_devices[new].dev_axis_size); xtb_ti_set(data->af_size, text, (xtb_data) 0); } return XTB_HANDLED; } /*ARGSUSED*/ static xtb_hret fd_fun(win, old, new, info) Window win; /* Button row window */ int old; /* Previous button */ int new; /* Current button */ xtb_data info; /* User data */ /* * This routine swaps the default file or device names * based on the state of the file or device buttons. * The information passed is the information for the whole * dialog. */ { struct d_info *data = (struct d_info *) info; char text[MAXCHBUF]; int which_one; which_one = xtb_br_get(data->choices); if ((which_one >= 0) && (which_one < hard_count)) { if (old == 0) { /* Save into device space */ xtb_ti_get(data->fodspec, text, (xtb_data *) 0); strncpy(hard_devices[which_one].dev_printer, text, MFNAME - 1); } else if (old == 1) { /* Save into file space */ xtb_ti_get(data->fodspec, text, (xtb_data *) 0); which_one = xtb_br_get(data->choices); strncpy(hard_devices[which_one].dev_file, text, MFNAME - 1); } if (new == 0) { /* Restore into device */ xtb_ti_set(data->fodspec, hard_devices[which_one].dev_printer, (xtb_data *) 0); } else if (new == 1) { xtb_ti_set(data->fodspec, hard_devices[which_one].dev_file, (xtb_data *) 0); } } return XTB_HANDLED; } /* Indices for frames made in make_dialog */ enum d_frames_defn { TITLE_F, ODEVLBL_F, ODEVROW_F, DISPLBL_F, DISPROW_F, FDLBL_F, FDINP_F, OPTLBL_F, DOCU_F, MDIMLBL_F, MDIMI_F, TFLBL_F, TFFAMLBL_F, TFFAM_F, TFSIZLBL_F, TFSIZ_F, AFLBL_F, AFFAMLBL_F, AFFAM_F, AFSIZLBL_F, AFSIZ_F, OK_F, CAN_F, BAR_F, LAST_F } d_frames; #define AF(ix) af[(int) (ix)] #define BAR_SLACK 10 static void make_dialog(win, spawned, prog, cookie, okbtn, frame) Window win; /* Parent window */ Window spawned; /* Spawned from window */ char *prog; /* Program name */ xtb_data cookie; /* Info for do_hardcopy */ xtb_frame *okbtn; /* Frame for OK button */ xtb_frame *frame; /* Returned window/size */ /* * This routine constructs a new dialog for asking the user about * hardcopy devices. The dialog and its size is returned in * `frame'. The window of the `ok' button is returned in `btnwin'. * This can be used to reset some of the button state to reuse the dialog. */ { Window overall; xtb_frame AF(LAST_F); xtb_fmt *def, *cntrl, *mindim, *tfarea, *afarea; Cursor diag_cursor; XColor fg_color, bg_color; XSizeHints hints; unsigned long wamask; XSetWindowAttributes wattr; struct d_info *info; int i, found, max_width, which_one, fodi; char **names; static char *fodstrs[] = {"To Device", "To File"}; XFontStruct *bigFont = PM_FONT("TitleFont"); XFontStruct *medFont = PM_FONT("LabelFont"); char *Odevice = PM_STR("Device"); char *Odisp = PM_STR("Disposition"); char *OfileDev = PM_STR("FileOrDev"); wamask = CWBackPixel | CWBorderPixel | CWOverrideRedirect | CWSaveUnder | CWColormap; wattr.background_pixel = PM_PIXEL("Background"); wattr.border_pixel = PM_PIXEL("Border"); wattr.override_redirect = True; wattr.save_under = True; wattr.colormap = cmap; overall = XCreateWindow(disp, win, 0, 0, 1, 1, D_BRDR, depth, InputOutput, vis, wamask, &wattr); frame->win = overall; frame->width = frame->height = frame->x_loc = frame->y_loc = 0; XStoreName(disp, overall, "Hardcopy Dialog"); XSetTransientForHint(disp, spawned, overall); info = (struct d_info *) Malloc(sizeof(struct d_info)); info->prog = prog; info->cookie = cookie; /* Make all frames */ xtb_to_new(overall, "Hardcopy Options", bigFont, &AF(TITLE_F)); xtb_to_new(overall, "Output device:", medFont, &AF(ODEVLBL_F)); found = -1; names = (char **) Malloc((unsigned) (sizeof(char *) * hard_count)); for (i = 0; i < hard_count; i++) { names[i] = hard_devices[i].dev_name; if (strcmp(Odevice, names[i]) == 0) { found = i; } } xtb_br_new(overall, hard_count, names, found, dev_fun, (xtb_data) info, &AF(ODEVROW_F)); info->choices = AF(ODEVROW_F).win; xtb_to_new(overall, "Disposition:", medFont, &AF(DISPLBL_F)); found = -1; for (i = 0; i < 2; i++) { if (strcmp(Odisp, fodstrs[i]) == 0) { found = i; } } xtb_br_new(overall, 2, fodstrs, found, fd_fun, (xtb_data) info, &AF(DISPROW_F)); info->fod = AF(DISPROW_F).win; xtb_to_new(overall, "File or Device Name:", medFont, &AF(FDLBL_F)); xtb_ti_new(overall, "", D_INP, df_fun, (xtb_data) 0, &AF(FDINP_F)); if (OfileDev && strlen(OfileDev)) { which_one = xtb_br_get(info->choices); if ((which_one >= 0) && (which_one < hard_count)) { fodi = xtb_br_get(info->fod); if (fodi == 0) { strncpy(hard_devices[which_one].dev_printer, OfileDev, MFNAME - 1); } else if (fodi == 1) { strncpy(hard_devices[which_one].dev_file, OfileDev, MFNAME - 1); } } } info->fodspec = AF(FDINP_F).win; xtb_to_new(overall, "Optional Parameters", bigFont, &AF(OPTLBL_F)); xtb_bt_new(overall, "Include in Document", docu_fun, (xtb_data) 0, &AF(DOCU_F)); info->docu_p = AF(DOCU_F).win; xtb_to_new(overall, "Maximum Dimension (cm):", medFont, &AF(MDIMLBL_F)); xtb_ti_new(overall, "", D_DSP, df_fun, (xtb_data) 0, &AF(MDIMI_F)); info->dimspec = AF(MDIMI_F).win; xtb_to_new(overall, "Title Font", medFont, &AF(TFLBL_F)); xtb_to_new(overall, "Family:", medFont, &AF(TFFAMLBL_F)); xtb_ti_new(overall, "", MFNAME, df_fun, (xtb_data) 0, &AF(TFFAM_F)); info->tf_family = AF(TFFAM_F).win; xtb_to_new(overall, "Size (pnts):", medFont, &AF(TFSIZLBL_F)); xtb_ti_new(overall, "", D_FS, df_fun, (xtb_data) 0, &AF(TFSIZ_F)); info->tf_size = AF(TFSIZ_F).win; xtb_to_new(overall, "Axis Font", medFont, &AF(AFLBL_F)); xtb_to_new(overall, "Family:", medFont, &AF(AFFAMLBL_F)); xtb_ti_new(overall, "", MFNAME, df_fun, (xtb_data) 0, &AF(AFFAM_F)); info->af_family = AF(AFFAM_F).win; xtb_to_new(overall, "Size (pnts):", medFont, &AF(AFSIZLBL_F)); xtb_ti_new(overall, "", D_FS, df_fun, (xtb_data) 0, &AF(AFSIZ_F)); info->af_size = AF(AFSIZ_F).win; xtb_bt_new(overall, " Ok ", ok_fun, (xtb_data) info, &AF(OK_F)); xtb_bt_new(overall, "Cancel", can_fun, (xtb_data) 0, &AF(CAN_F)); /* Dividing bar */ max_width = 0; for (i = 0; i < ((int) BAR_F); i++) { if (AF(i).width > max_width) max_width = AF(i).width; } xtb_bk_new(overall, max_width - BAR_SLACK, 1, &AF(BAR_F)); /* Set device specific info */ (void) dev_fun(info->choices, -1, xtb_br_get(info->choices), (xtb_data) info); (void) fd_fun(info->fod, -1, xtb_br_get(info->fod), (xtb_data) info); /* * Now place elements - could make this one expression but pcc is too * wimpy. */ cntrl = xtb_vert(XTB_LEFT, D_VPAD, D_INT, xtb_hort(XTB_CENTER, D_HPAD, D_INT, xtb_w(&AF(ODEVLBL_F)), xtb_w(&AF(ODEVROW_F)), NE), xtb_hort(XTB_CENTER, D_HPAD, D_INT, xtb_w(&AF(DISPLBL_F)), xtb_w(&AF(DISPROW_F)), NE), xtb_hort(XTB_CENTER, D_HPAD, D_INT, xtb_w(&AF(FDLBL_F)), xtb_w(&AF(FDINP_F)), NE), NE); mindim = xtb_vert(XTB_LEFT, D_VPAD, D_INT, xtb_hort(XTB_CENTER, D_HPAD, D_INT, xtb_w(&AF(MDIMLBL_F)), xtb_w(&AF(MDIMI_F)), NE), NE); tfarea = xtb_vert(XTB_LEFT, D_VPAD, D_INT, xtb_hort(XTB_CENTER, D_HPAD, D_INT, xtb_w(&AF(TFFAMLBL_F)), xtb_w(&AF(TFFAM_F)), xtb_w(&AF(TFSIZLBL_F)), xtb_w(&AF(TFSIZ_F)), NE), NE); afarea = xtb_vert(XTB_LEFT, D_VPAD, D_INT, xtb_hort(XTB_CENTER, D_HPAD, D_INT, xtb_w(&AF(AFFAMLBL_F)), xtb_w(&AF(AFFAM_F)), xtb_w(&AF(AFSIZLBL_F)), xtb_w(&AF(AFSIZ_F)), NE), NE); def = xtb_fmt_do (xtb_vert(XTB_CENTER, D_VPAD, D_INT, xtb_w(&AF(TITLE_F)), cntrl, xtb_w(&AF(BAR_F)), xtb_w(&AF(OPTLBL_F)), mindim, xtb_w(&AF(DOCU_F)), xtb_w(&AF(TFLBL_F)), tfarea, xtb_w(&AF(AFLBL_F)), afarea, xtb_hort(XTB_CENTER, D_HPAD, D_INT, xtb_w(&AF(OK_F)), xtb_w(&AF(CAN_F)), NE), NE), &frame->width, &frame->height); xtb_mv_frames(LAST_F, af); xtb_fmt_free(def); /* Make window large enough to contain the info */ XResizeWindow(disp, overall, frame->width, frame->height); hints.flags = PSize; hints.width = frame->width; hints.height = frame->height; XSetNormalHints(disp, overall, &hints); diag_cursor = XCreateFontCursor(disp, XC_dotbox); fg_color.pixel = PM_PIXEL("Foreground"); XQueryColor(disp, cmap, &fg_color); bg_color.pixel = PM_PIXEL("Background"); XQueryColor(disp, cmap, &bg_color); XRecolorCursor(disp, diag_cursor, &fg_color, &bg_color); XDefineCursor(disp, overall, diag_cursor); frame->width += (2 * D_BRDR); frame->height += (2 * D_BRDR); *okbtn = AF(OK_F); } #ifdef SHADOW Window make_shadow(w, h) int w, h; /* * Makes a shadow window for a pop-up window of the specified size. * Needs hint work as well. Try no background window. */ { Window shadow; Bitmap gray_bm; Pixmap gray_pm; gray_bm = XStoreBitmap(gray_width, gray_height, gray_bits); gray_pm = XMakePixmap(gray_bm, PM_PIXEL("Foreground"), PM_PIXEL("Background")); shadow = XCreateWindow(RootWindow, 0, 0, w, h, 0, BlackPixmap, gray_pm); XFreePixmap(gray_pm); XFreeBitmap(gray_bm); return shadow; } #endif #define SH_W 5 #define SH_H 5 void ho_dialog(parent, prog, cookie) Window parent; /* Parent window */ char *prog; /* Program name */ xtb_data cookie; /* Info passed to do_hardcopy */ /* * Asks the user about hardcopy devices. A table of hardcopy * device names and function pointers to their initialization * functions is assumed to be in the global `hard_devices' and * `hard_count'. Returns a non-zero status if the dialog was * sucessfully posted. Calls do_hardcopy in xgraph to actually * output information. */ { #ifdef SHADOW static Window shadow; #endif static Window dummy; static xtb_frame overall = {(Window) 0, 0, 0, 0, 0}; static xtb_frame okbtn; XEvent evt; XWindowAttributes winInfo; XSizeHints hints; struct d_info *info; if (!overall.win) { make_dialog(RootWindow(disp, screen), parent, prog, cookie, &okbtn, &overall); #ifdef SHADOW shadow = make_shadow(d_w, d_h); #endif } else { /* Change the button information */ (void) xtb_bt_get(okbtn.win, (xtb_data *) & info, (int *) 0); info->prog = prog; info->cookie = cookie; } XGetWindowAttributes(disp, parent, &winInfo); XTranslateCoordinates(disp, parent, RootWindow(disp, screen), 0, 0, &winInfo.x, &winInfo.y, &dummy); XMoveWindow(disp, overall.win, (int) (winInfo.x + winInfo.width / 2 - overall.width / 2), (int) (winInfo.y + winInfo.height / 2 - overall.height / 2)); hints.flags = PPosition; hints.x = winInfo.x + winInfo.width / 2 - overall.width / 2; hints.y = winInfo.y + winInfo.height / 2 - overall.height / 2; XSetNormalHints(disp, overall.win, &hints); #ifdef SHADOW XMoveWindow(disp, shadow, winInfo.x + winInfo.width / 2 - d_w / 2 + SH_W, winInfo.y + winInfo.height / 2 - d_h / 2 + SH_H); hints.flags = PPosition; hints.x = winInfo.x + winInfo.width / 2 - d_w / 2 + SH_W; hints.y = winInfo.y + winInfo.height / 2 - d_h / 2 + SH_H; XSetNormalHints(disp, shadow, &hints); XRaiseWindow(disp, shadow); XMapWindow(disp, shadow); #endif XRaiseWindow(disp, overall.win); XMapWindow(disp, overall.win); do { XNextEvent(disp, &evt); } while (xtb_dispatch(&evt) != XTB_STOP); XUnmapWindow(disp, overall.win); #ifdef SHADOW XUnmapWindow(disp, shadow); #endif } /*ARGSUSED*/ static xtb_hret err_func(win, bval, info) Window win; /* Button window */ int bval; /* Button value */ xtb_data info; /* Local button info */ /* * Handler function for button in error box. Simply stops dialog. */ { (void) xtb_bt_set(win, 1, (xtb_data) 0, 0); (void) xtb_bt_set(win, 0, (xtb_data) 0, 0); return XTB_STOP; } struct err_info { Window title; Window contbtn; int num_lines; int alloc_lines; Window *lines; }; #define E_LINES 2 #define E_VPAD 3 #define E_HPAD 3 #define E_INTER 1 #define ML 256 static void make_msg_box(text, title, frame) char *text; /* Error text */ char *title; /* Title text */ xtb_frame *frame; /* Returned frame */ /* * Makes an error box with a title. */ { XSizeHints hints; struct err_info *new_info; xtb_frame tf, cf, lf; char *lineptr, line[ML]; int y, i; unsigned long wamask; XSetWindowAttributes wattr; XFontStruct *bigFont = PM_FONT("TitleFont"); XFontStruct *medFont = PM_FONT("LabelFont"); wamask = CWBackPixel | CWBorderPixel | CWOverrideRedirect | CWSaveUnder | CWColormap; wattr.background_pixel = PM_PIXEL("Background"); wattr.border_pixel = PM_PIXEL("Border"); wattr.override_redirect = True; wattr.save_under = True; wattr.colormap = cmap; frame->win = XCreateWindow(disp, RootWindow(disp, screen), 0, 0, 1, 1, D_BRDR, depth, InputOutput, vis, wamask, &wattr); frame->x_loc = frame->y_loc = frame->width = frame->height = 0; XStoreName(disp, frame->win, "Error Dialog"); XSetTransientForHint(disp, RootWindow(disp, screen), frame->win); new_info = (struct err_info *) Malloc((unsigned) sizeof(struct err_info)); xtb_to_new(frame->win, title, bigFont, &tf); new_info->title = tf.win; if (tf.width > frame->width) frame->width = tf.width; xtb_bt_new(frame->win, "Dismiss", err_func, (xtb_data) 0, &cf); new_info->contbtn = cf.win; if (cf.width > frame->width) frame->width = cf.width; new_info->alloc_lines = E_LINES; new_info->num_lines = 0; new_info->lines = (Window *) Malloc((unsigned) (sizeof(Window) * E_LINES)); /* zero the memory out of paranoia */ memset(new_info->lines, 0, sizeof(Window) * E_LINES); lineptr = text; while (getline(&lineptr, line)) { if (new_info->num_lines >= new_info->alloc_lines) { int old_alloc_lines_size = new_info->alloc_lines * sizeof(Window); new_info->alloc_lines *= 2; new_info->lines = (Window *) Realloc((char *) new_info->lines, (unsigned) (new_info->alloc_lines * sizeof(Window))); memset(((char*)new_info->lines) + old_alloc_lines_size, 0, old_alloc_lines_size); } xtb_to_new(frame->win, line, medFont, &lf); new_info->lines[new_info->num_lines] = lf.win; new_info->num_lines += 1; if (lf.width > frame->width) frame->width = lf.width; } /* Placement */ frame->width += (2 * E_HPAD); y = E_VPAD; /* Title */ XMoveWindow(disp, new_info->title, (int) (frame->width / 2 - tf.width / 2), y); y += (tf.height + E_INTER); /* All lines */ for (i = 0; i < new_info->num_lines; i++) { XMoveWindow(disp, new_info->lines[i], E_HPAD, y); y += (lf.height + E_INTER); } /* Button */ XMoveWindow(disp, new_info->contbtn, (int) (frame->width / 2 - cf.width / 2), y); y += (cf.height + E_INTER); /* Make dialog the right size */ y += (E_VPAD - E_INTER); XResizeWindow(disp, frame->win, frame->width, (unsigned int) y); hints.flags = PSize; hints.width = frame->width; hints.height = (unsigned int) y; XSetNormalHints(disp, frame->win, &hints); frame->width += (2 * D_BRDR); frame->height = y + (2 * D_BRDR); xtb_register(frame->win, (xtb_hret(*) ()) 0, (xtb_data) new_info); } void msg_box(title, text) char *title, *text; /* * This posts a dialog that contains lines of text and a continue * button. The text may be multiple lines. The dialog is remade * each time. */ { #ifdef SHADOW Window shadow; #endif XWindowAttributes info; XEvent evt; XSizeHints hints; xtb_frame text_frame; make_msg_box(text, title, &text_frame); #ifdef SHADOW shadow = make_shadow(w, h); #endif XGetWindowAttributes(disp, RootWindow(disp, screen), &info); XMoveWindow(disp, text_frame.win, (int) (info.width / 2 - text_frame.width / 2), (int) (info.height / 2 - text_frame.height / 2)); hints.flags = PPosition; hints.x = info.width / 2 - text_frame.width / 2; hints.y = info.height / 2 - text_frame.height / 2; XSetNormalHints(disp, text_frame.win, &hints); #ifdef SHADOW XMoveWindow(disp, shadow, info.width / 2 - w / 2 + SH_W, info.height / 2 - h / 2 + SH_H); hints.flags = PPosition; hints.x = info.width / 2 - w / 2 + SH_W; hints.y = info.height / 2 - h / 2 + SH_H; XSetNormalHints(disp, text_frame.win, &hints); XRaiseWindow(disp, shadow); XMapWindow(disp, shadow); #endif XRaiseWindow(disp, text_frame.win); XMapWindow(disp, text_frame.win); do { XNextEvent(disp, &evt); } while (xtb_dispatch(&evt) != XTB_STOP); #ifdef SHADOW XDestroyWindow(disp, shadow); #endif del_msg_box(text_frame.win); } void do_error(err_text) char *err_text; { if (PM_INT("Output Device") == D_XWINDOWS) msg_box("Xgraph Error", err_text); else fputs(err_text, stderr); } int getline(tptr, lptr) char **tptr; char *lptr; /* * Returns next line from tptr. Assumes `lptr' is large enough to * accept the line. */ { char *start; start = *tptr; while (*tptr && **tptr && (**tptr != '\n')) { (*tptr)++; } if (*tptr > start) { (void) strncpy(lptr, start, (*tptr - start)); lptr[*tptr - start] = '\0'; if (**tptr == '\n') (*tptr)++; return 1; } else { return 0; } } static void del_msg_box(msg) Window msg; /* * Deletes all components of an msg box */ { struct err_info *info; char *dummy; int i; if (xtb_unregister(msg, (xtb_data *) & info)) { xtb_to_del(info->title); xtb_bt_del(info->contbtn, (xtb_data *) & dummy); for (i = 0; i < info->num_lines; i++) { xtb_to_del(info->lines[i]); } Free((char *) info->lines); Free((char *) info); XDestroyWindow(disp, msg); } } xgraph-12.1.orig/draw.c0100664000175000000620000010253407360237510013423 0ustar bapstaff/* $Header: /usr/src/mash/repository/vint/xgraph/draw.c,v 1.1.1.1 1999/12/03 23:15:53 heideman Exp $ */ /* * draw.c: xgraph drawing code * * Routines: * void DrawWindow(); * * $Log: draw.c,v $ * Revision 1.1.1.1 1999/12/03 23:15:53 heideman * xgraph-12.0 * */ #ifndef lint static char rcsid[] = "$Id: draw.c,v 1.1.1.1 1999/12/03 23:15:53 heideman Exp $"; #endif #include "copyright.h" #include #include #include #include #include "xgraph.h" #include "xtb.h" #include "hard_devices.h" #include "params.h" static void DrawTitle(); static void DrawGridAndAxis(); static void WriteValue(); static void DrawData(); static void DrawLegend(); static int TransformCompute(); static double initGrid(); static double stepGrid(); static double RoundUp(); static void set_mark_flags(); void DrawWindow(win_info) LocalWin *win_info; /* Window information */ /* * Draws the data in the window. Does not clear the window. * The data is scaled so that all of the data will fit. * Grid lines are drawn at the nearest power of 10 in engineering * notation. Draws axis numbers along bottom and left hand edges. * Centers title at top of window. */ { /* Figure out the transformation constants */ if (TransformCompute(win_info)) { /* Draw the title */ DrawTitle(win_info); /* Draw the legend */ if (!PM_BOOL("NoLegend")) DrawLegend(win_info); /* Draw the axis unit labels, grid lines, and grid labels */ DrawGridAndAxis(win_info); /* Draw the data sets themselves */ DrawData(win_info); } } static void DrawTitle(wi) LocalWin *wi; /* Window information */ /* * This routine draws the title of the graph centered in * the window. It is spaced down from the top by an amount * specified by the constant PADDING. The font must be * fixed width. The routine returns the height of the * title in pixels. */ { if (wi->DOrder == 0) wi->dev_info.xg_text(wi->dev_info.user_state, (int)(wi->dev_info.area_w*0.95) , wi->dev_info.axis_pad, PM_STR("TitleText"), T_UPPERRIGHT, T_TITLE); else if (wi->DOrder == 1) wi->dev_info.xg_text(wi->dev_info.user_state, (int)(wi->dev_info.area_w*0.95) , wi->dev_info.axis_pad, "First Derivative", T_UPPERRIGHT, T_TITLE); else if (wi->DOrder == 2) wi->dev_info.xg_text(wi->dev_info.user_state, (int)(wi->dev_info.area_w*0.95) , wi->dev_info.axis_pad, "Second Derivative", T_UPPERRIGHT, T_TITLE); } static int TransformCompute(wi) LocalWin *wi; /* Window information */ /* * This routine figures out how to draw the axis labels and grid lines. * Both linear and logarithmic axes are supported. Axis labels are * drawn in engineering notation. The power of the axes are labeled * in the normal axis labeling spots. The routine also figures * out the necessary transformation information for the display * of the points (it touches XOrgX, XOrgY, UsrOrgX, UsrOrgY, and * UnitsPerPixel). */ { double bbCenX, bbCenY, bbHalfWidth, bbHalfHeight; int idx, maxName, leftWidth; char err[MAXBUFSIZE]; char *XUnitText = PM_STR("XUnitText"); /* * First, we figure out the origin in the X window. Above the space we * have the title and the Y axis unit label. To the left of the space we * have the Y axis grid labels. */ wi->XOrgX = wi->dev_info.bdr_pad + (7 * wi->dev_info.axis_width) + wi->dev_info.bdr_pad; wi->XOrgY = wi->dev_info.bdr_pad + wi->dev_info.title_height + wi->dev_info.bdr_pad + wi->dev_info.axis_height + wi->dev_info.axis_height / 2 + wi->dev_info.bdr_pad; /* * Now we find the lower right corner. Below the space we have the X axis * grid labels. To the right of the space we have the X axis unit label * and the legend. We assume the worst case size for the unit label. */ maxName = 0; for (idx = 0; idx < MAXSETS; idx++) { if (PlotData[idx].list) { int tempSize; tempSize = strlen(PlotData[idx].setName); if (tempSize > maxName) maxName = tempSize; } } if (PM_BOOL("NoLegend")) maxName = 0; /* Worst case size of the X axis label: */ leftWidth = (strlen(XUnitText)) * wi->dev_info.axis_width; if ((maxName * wi->dev_info.axis_width) + wi->dev_info.bdr_pad > leftWidth) leftWidth = maxName * wi->dev_info.axis_width + wi->dev_info.bdr_pad; wi->XOppX = wi->dev_info.area_w - wi->dev_info.bdr_pad - leftWidth; wi->XOppY = wi->dev_info.area_h - wi->dev_info.bdr_pad - wi->dev_info.axis_height - wi->dev_info.bdr_pad; if ((wi->XOrgX >= wi->XOppX) || (wi->XOrgY >= wi->XOppY)) { do_error(strcpy(err, "Drawing area is too small\n")); return 0; } /* * We now have a bounding box for the drawing region. Figure out the units * per pixel using the data set bounding box. */ wi->XUnitsPerPixel = (wi->hiX - wi->loX) / ((double) (wi->XOppX - wi->XOrgX)); wi->YUnitsPerPixel = (wi->hiY - wi->loY) / ((double) (wi->XOppY - wi->XOrgY)); /* * Find origin in user coordinate space. We keep the center of the * original bounding box in the same place. */ bbCenX = (wi->loX + wi->hiX) / 2.0; bbCenY = (wi->loY + wi->hiY) / 2.0; bbHalfWidth = ((double) (wi->XOppX - wi->XOrgX)) / 2.0 * wi->XUnitsPerPixel; bbHalfHeight = ((double) (wi->XOppY - wi->XOrgY)) / 2.0 * wi->YUnitsPerPixel; wi->UsrOrgX = bbCenX - bbHalfWidth; wi->UsrOrgY = bbCenY - bbHalfHeight; wi->UsrOppX = bbCenX + bbHalfWidth; wi->UsrOppY = bbCenY + bbHalfHeight; /* * Everything is defined so we can now use the SCREENX and SCREENY * transformations. */ return 1; } static void DrawGridAndAxis(wi) LocalWin *wi; /* Window information */ /* * This routine draws grid line labels in engineering notation, * the grid lines themselves, and unit labels on the axes. */ { int expX, expY; /* Engineering powers */ int startX; int Yspot, Xspot; char power[10], value[10], final[MAXBUFSIZE + 10]; double Xincr, Yincr, Xstart, Ystart, Yindex, Xindex, larger; XSegment segs[2]; double initGrid(), stepGrid(); int tickFlag = PM_BOOL("Ticks"); int axisFlag = PM_BOOL("TickAxis"); int logXFlag = PM_BOOL("LogX"); int logYFlag = PM_BOOL("LogY"); char *XUnitText = PM_STR("XUnitText"); char *YUnitText = PM_STR("YUnitText"); /* * Grid display powers are computed by taking the log of the largest * numbers and rounding down to the nearest multiple of 3. */ if (logXFlag) { expX = 0; } else { if (fabs(wi->UsrOrgX) > fabs(wi->UsrOppX)) { larger = fabs(wi->UsrOrgX); } else { larger = fabs(wi->UsrOppX); } expX = ((int) floor(nlog10(larger) / 3.0)) * 3; } if (logYFlag) { expY = 0; } else { if (fabs(wi->UsrOrgY) > fabs(wi->UsrOppY)) { larger = fabs(wi->UsrOrgY); } else { larger = fabs(wi->UsrOppY); } expY = ((int) floor(nlog10(larger) / 3.0)) * 3; } /* * With the powers computed, we can draw the axis labels. */ if (expY != 0) { (void) strcpy(final, YUnitText); (void) strcat(final, " x 10"); Xspot = wi->dev_info.bdr_pad + ((strlen(YUnitText) + 5) * wi->dev_info.axis_width); Yspot = wi->dev_info.bdr_pad * 2 + wi->dev_info.title_height + wi->dev_info.axis_height / 2; wi->dev_info.xg_text(wi->dev_info.user_state, Xspot, Yspot, final, T_RIGHT, T_AXIS); (void) sprintf(power, "%d", expY); wi->dev_info.xg_text(wi->dev_info.user_state, Xspot, Yspot, power, T_LOWERLEFT, T_AXIS); } else { Yspot = wi->dev_info.bdr_pad * 2 + wi->dev_info.title_height; wi->dev_info.xg_text(wi->dev_info.user_state, wi->dev_info.bdr_pad, Yspot, YUnitText, T_UPPERLEFT, T_AXIS); } startX = wi->dev_info.area_w - wi->dev_info.bdr_pad; if (expX != 0) { (void) sprintf(power, "%d", expX); startX -= (strlen(power) * wi->dev_info.axis_width); wi->dev_info.xg_text(wi->dev_info.user_state, startX, wi->XOppY, power, T_LOWERLEFT, T_AXIS); (void) strcpy(final, XUnitText); (void) strcat(final, " x 10"); wi->dev_info.xg_text(wi->dev_info.user_state, startX, wi->XOppY, final, T_RIGHT, T_AXIS); } else { wi->dev_info.xg_text(wi->dev_info.user_state, startX, wi->XOppY, XUnitText, T_RIGHT, T_AXIS); } /* * First, the grid line labels */ Yincr = (wi->dev_info.axis_pad + wi->dev_info.axis_height) * wi->YUnitsPerPixel; Ystart = initGrid(wi->UsrOrgY, Yincr, logYFlag); for (Yindex = Ystart; Yindex < wi->UsrOppY; Yindex = stepGrid()) { Yspot = SCREENY(wi, Yindex); /* Write the axis label */ WriteValue(value, PM_STR("Format X"), Yindex, expY, logYFlag); wi->dev_info.xg_text(wi->dev_info.user_state, wi->dev_info.bdr_pad + (7 * wi->dev_info.axis_width), Yspot, value, T_RIGHT, T_AXIS); } Xincr = (wi->dev_info.axis_pad + (wi->dev_info.axis_width * 7)) * wi->XUnitsPerPixel; Xstart = initGrid(wi->UsrOrgX, Xincr, logXFlag); for (Xindex = Xstart; Xindex < wi->UsrOppX; Xindex = stepGrid()) { Xspot = SCREENX(wi, Xindex); /* Write the axis label */ WriteValue(value, PM_STR("Format Y"), Xindex, expX, logXFlag); wi->dev_info.xg_text(wi->dev_info.user_state, Xspot, wi->dev_info.area_h - wi->dev_info.bdr_pad, value, T_BOTTOM, T_AXIS); } /* * Now, the grid lines or tick marks */ Yincr = (wi->dev_info.axis_pad + wi->dev_info.axis_height) * wi->YUnitsPerPixel; Ystart = initGrid(wi->UsrOrgY, Yincr, logYFlag); for (Yindex = Ystart; Yindex < wi->UsrOppY; Yindex = stepGrid()) { Yspot = SCREENY(wi, Yindex); /* Draw the grid line or tick mark */ if (tickFlag && !(axisFlag && Yindex == Ystart)) { segs[0].x1 = wi->XOrgX; segs[0].x2 = wi->XOrgX + wi->dev_info.tick_len; segs[1].x1 = wi->XOppX - wi->dev_info.tick_len; segs[1].x2 = wi->XOppX; segs[0].y1 = segs[0].y2 = segs[1].y1 = segs[1].y2 = Yspot; } else { segs[0].x1 = wi->XOrgX; segs[0].x2 = wi->XOppX; segs[0].y1 = segs[0].y2 = Yspot; } if ((ABS(Yindex) < ZERO_THRES) && !logYFlag) { wi->dev_info.xg_seg(wi->dev_info.user_state, 1, segs, PM_INT("ZeroWidth"), L_ZERO, 0, 0); if (tickFlag) { wi->dev_info.xg_seg(wi->dev_info.user_state, 1, &(segs[1]), PM_INT("ZeroWidth"), L_ZERO, 0, 0); } } else { wi->dev_info.xg_seg(wi->dev_info.user_state, 1, segs, PM_INT("GridSize"), L_AXIS, 0, 0); if (tickFlag) { wi->dev_info.xg_seg(wi->dev_info.user_state, 1, &(segs[1]), PM_INT("GridSize"), L_AXIS, 0, 0); } } } Xincr = (wi->dev_info.axis_pad + (wi->dev_info.axis_width * 7)) * wi->XUnitsPerPixel; Xstart = initGrid(wi->UsrOrgX, Xincr, logXFlag); for (Xindex = Xstart; Xindex < wi->UsrOppX; Xindex = stepGrid()) { Xspot = SCREENX(wi, Xindex); /* Draw the grid line or tick marks */ if (tickFlag && !(axisFlag && Xindex == Xstart)) { segs[0].x1 = segs[0].x2 = segs[1].x1 = segs[1].x2 = Xspot; segs[0].y1 = wi->XOrgY; segs[0].y2 = wi->XOrgY + wi->dev_info.tick_len; segs[1].y1 = wi->XOppY - wi->dev_info.tick_len; segs[1].y2 = wi->XOppY; } else { segs[0].x1 = segs[0].x2 = Xspot; segs[0].y1 = wi->XOrgY; segs[0].y2 = wi->XOppY; } if ((ABS(Xindex) < ZERO_THRES) && !logXFlag) { wi->dev_info.xg_seg(wi->dev_info.user_state, 1, segs, PM_INT("ZeroWidth"), L_ZERO, 0, 0); if (tickFlag) { wi->dev_info.xg_seg(wi->dev_info.user_state, 1, &(segs[1]), PM_INT("ZeroWidth"), L_ZERO, 0, 0); } } else { wi->dev_info.xg_seg(wi->dev_info.user_state, 1, segs, PM_INT("GridSize"), L_AXIS, 0, 0); if (tickFlag) { wi->dev_info.xg_seg(wi->dev_info.user_state, 1, &(segs[1]), PM_INT("GridSize"), L_AXIS, 0, 0); } } } /* Check to see if he wants a bounding box */ if (PM_BOOL("BoundBox")) { XSegment bb[4]; /* Draw bounding box */ bb[0].x1 = bb[0].x2 = bb[1].x1 = bb[3].x2 = wi->XOrgX; bb[0].y1 = bb[2].y2 = bb[3].y1 = bb[3].y2 = wi->XOrgY; bb[1].x2 = bb[2].x1 = bb[2].x2 = bb[3].x1 = wi->XOppX; bb[0].y2 = bb[1].y1 = bb[1].y2 = bb[2].y1 = wi->XOppY; wi->dev_info.xg_seg(wi->dev_info.user_state, 4, bb, PM_INT("GridSize"), L_AXIS, 0, 0); } } static double gridBase, gridStep, gridJuke[101]; static int gridNJuke, gridCurJuke; #define ADD_GRID(val) (gridJuke[gridNJuke++] = log10(val)) static double initGrid(low, step, logFlag) double low; /* desired low value */ double step; /* desired step (user coords) */ int logFlag; /* is axis logarithmic? */ { double ratio, x; double RoundUp(), stepGrid(); gridNJuke = gridCurJuke = 0; gridJuke[gridNJuke++] = 0.0; if (logFlag) { ratio = pow(10.0, step); gridBase = floor(low); gridStep = ceil(step); if (ratio <= 3.0) { if (ratio > 2.0) { ADD_GRID(3.0); } else if (ratio > 1.333) { ADD_GRID(2.0); ADD_GRID(5.0); } else if (ratio > 1.25) { ADD_GRID(1.5); ADD_GRID(2.0); ADD_GRID(3.0); ADD_GRID(5.0); ADD_GRID(7.0); } else { for (x = 1.0; x < 10.0 && (x + .5) / (x + .4) >= ratio; x += .5) { ADD_GRID(x + .1); ADD_GRID(x + .2); ADD_GRID(x + .3); ADD_GRID(x + .4); ADD_GRID(x + .5); } if (floor(x) != x) ADD_GRID(x += .5); for (; x < 10.0 && (x + 1.0) / (x + .5) >= ratio; x += 1.0) { ADD_GRID(x + .5); ADD_GRID(x + 1.0); } for (; x < 10.0 && (x + 1.0) / x >= ratio; x += 1.0) { ADD_GRID(x + 1.0); } if (x == 7.0) { gridNJuke--; x = 6.0; } if (x < 7.0) { ADD_GRID(x + 2.0); } if (x == 10.0) gridNJuke--; } x = low - gridBase; for (gridCurJuke = -1; x >= gridJuke[gridCurJuke + 1]; gridCurJuke++) { } } } else { gridStep = RoundUp(step); gridBase = floor(low / gridStep) * gridStep; } return (stepGrid()); } static double stepGrid() { if (++gridCurJuke >= gridNJuke) { gridCurJuke = 0; gridBase += gridStep; } return (gridBase + gridJuke[gridCurJuke]); } static double RoundUp(val) double val; /* Value */ /* * This routine rounds up the given positive number such that * it is some power of ten times either 1, 2, or 5. It is * used to find increments for grid lines. */ { int exponent, idx; exponent = (int) floor(nlog10(val)); if (exponent < 0) { for (idx = exponent; idx < 0; idx++) { val *= 10.0; } } else { for (idx = 0; idx < exponent; idx++) { val /= 10.0; } } if (val > 5.0) val = 10.0; else if (val > 2.0) val = 5.0; else if (val > 1.0) val = 2.0; else val = 1.0; if (exponent < 0) { for (idx = exponent; idx < 0; idx++) { val /= 10.0; } } else { for (idx = 0; idx < exponent; idx++) { val *= 10.0; } } return val; } static void WriteValue(str, fmt, val, expv, logFlag) char *str; /* String to write into */ char *fmt; /* Format to print str */ double val; /* Value to print */ int expv; /* Exponent */ int logFlag; /* Is this a log axis? */ /* * Writes the value provided into the string in a fixed format * consisting of seven characters. The format is: * -ddd.dd */ { int idx; if (logFlag) { if (val == floor(val)) { if (strcmp(fmt, "%.2f") == 0) fmt = "%.0e"; val = pow(10.0, val); } else { if (strcmp(fmt, "%.2f") == 0) fmt = "%.2g"; val = pow(10.0, val - floor(val)); } } else { if (expv < 0) { for (idx = expv; idx < 0; idx++) { val *= 10.0; } } else { for (idx = 0; idx < expv; idx++) { val /= 10.0; } } } if (strchr(fmt, 'd') || strchr(fmt, 'x')) (void) sprintf(str, fmt, (int) val); else (void) sprintf(str, fmt, val); } #define LEFT_CODE 0x01 #define RIGHT_CODE 0x02 #define BOTTOM_CODE 0x04 #define TOP_CODE 0x08 /* Clipping algorithm from Neumann and Sproull by Cohen and Sutherland */ #define C_CODE(xval, yval, rtn) \ rtn = 0; \ if ((xval) < wi->UsrOrgX) rtn = LEFT_CODE; \ else if ((xval) > wi->UsrOppX) rtn = RIGHT_CODE; \ if ((yval) < wi->UsrOrgY) rtn |= BOTTOM_CODE; \ else if ((yval) > wi->UsrOppY) rtn |= TOP_CODE void EraseData(wi) LocalWin *wi; /* * This routine draws the data sets themselves using the macros * for translating coordinates. */ { double sx1, sy1, sx2, sy2, tx = 0, ty = 0; int idx, subindex; int code1, code2, cd, mark_inside; int X_idx, StoreIDX; /* PW */ XSegment *ptr; PointList *thisList, *lastList; int markFlag, pixelMarks, bigPixel, colorMark; int noLines = PM_BOOL("NoLines"); int lineWidth = PM_INT("LineWidth"); /* PW Suggests we Flush and set first */ set_mark_flags(&markFlag, &pixelMarks, &bigPixel, &colorMark); for (idx = 0; idx < MAXSETS; idx++) { if (wi->DOrder == 0) thisList = PlotData[idx].list; else if (wi->DOrder == 1) thisList = DataD1[idx].list; else if (wi->DOrder == 2) thisList = DataD2[idx].list; else { printf ("Internal Error differentiating - order > 2!\n"); exit (1); } while (thisList) { X_idx = 0; for (subindex = 0; subindex < thisList->numPoints - 1; subindex++) { /* Put segment in (sx1,sy1) (sx2,sy2) */ sx1 = thisList->xvec[subindex]; sy1 = thisList->yvec[subindex]; sx2 = thisList->xvec[subindex + 1]; sy2 = thisList->yvec[subindex + 1]; /* Now clip to current window boundary */ C_CODE(sx1, sy1, code1); C_CODE(sx2, sy2, code2); mark_inside = (code1 == 0); while (code1 || code2) { if (code1 & code2) break; cd = (code1 ? code1 : code2); if (cd & LEFT_CODE) { /* Crosses left edge */ ty = sy1 + (sy2 - sy1) * (wi->UsrOrgX - sx1) / (sx2 - sx1); tx = wi->UsrOrgX; } else if (cd & RIGHT_CODE) { /* Crosses right edge */ ty = sy1 + (sy2 - sy1) * (wi->UsrOppX - sx1) / (sx2 - sx1); tx = wi->UsrOppX; } else if (cd & BOTTOM_CODE) {/* Crosses bottom edge */ tx = sx1 + (sx2 - sx1) * (wi->UsrOrgY - sy1) / (sy2 - sy1); ty = wi->UsrOrgY; } else if (cd & TOP_CODE) { /* Crosses top edge */ tx = sx1 + (sx2 - sx1) * (wi->UsrOppY - sy1) / (sy2 - sy1); ty = wi->UsrOppY; } if (cd == code1) { sx1 = tx; sy1 = ty; C_CODE(sx1, sy1, code1); } else { sx2 = tx; sy2 = ty; C_CODE(sx2, sy2, code2); } } if (!code1 && !code2) { /* Add segment to list */ Xsegs[0][X_idx].x1 = Xsegs[1][X_idx].x1; Xsegs[0][X_idx].y1 = Xsegs[1][X_idx].y1; Xsegs[0][X_idx].x2 = Xsegs[1][X_idx].x2; Xsegs[0][X_idx].y2 = Xsegs[1][X_idx].y2; Xsegs[1][X_idx].x1 = SCREENX(wi, sx1); Xsegs[1][X_idx].y1 = SCREENY(wi, sy1); Xsegs[1][X_idx].x2 = SCREENX(wi, sx2); Xsegs[1][X_idx].y2 = SCREENY(wi, sy2); X_idx++; } /* Draw markers if requested and they are in drawing region */ if (markFlag && mark_inside) { if (pixelMarks) { if (bigPixel) { wi->dev_info.xg_dot(wi->dev_info.user_state, Xsegs[1][X_idx - 1].x1, Xsegs[1][X_idx - 1].y1, P_DOT, 0, idx % MAXATTR); } else { wi->dev_info.xg_dot(wi->dev_info.user_state, Xsegs[1][X_idx - 1].x1, Xsegs[1][X_idx - 1].y1, P_PIXEL, 0, PIXVALUE(idx)); } } else { /* Distinctive markers */ wi->dev_info.xg_dot(wi->dev_info.user_state, Xsegs[1][X_idx - 1].x1, Xsegs[1][X_idx - 1].y1, P_MARK, MARKSTYLE(idx), PIXVALUE(idx)); } } /* Draw bar elements if requested */ if (PM_BOOL("BarGraph")) { int barPixels, baseSpot; XSegment line; barPixels = (int) ((PM_DBL("BarWidth") / wi->XUnitsPerPixel) + 0.5); if (barPixels <= 0) barPixels = 1; baseSpot = SCREENY(wi, PM_DBL("BarBase")); line.x1 = line.x2 = Xsegs[1][X_idx - 1].x1 + (int) ((PM_DBL("BarOffset") * idx / wi->XUnitsPerPixel) + 0.5); if (PM_BOOL("StackGraph") && idx != 0) line.y1 = Xsegs[0][X_idx - 1].y1; else line.y1 = baseSpot; line.y2 = Xsegs[1][X_idx - 1].y1; wi->dev_info.xg_seg(wi->dev_info.user_state, 1, &line, barPixels, L_VAR, LINESTYLE(idx), PIXVALUE(idx)); } } /* Handle last marker */ if (markFlag && (thisList->numPoints > 0)) { C_CODE(thisList->xvec[thisList->numPoints - 1], thisList->yvec[thisList->numPoints - 1], mark_inside); if (mark_inside == 0) { if (pixelMarks) { if (bigPixel) { wi->dev_info.xg_dot(wi->dev_info.user_state, Xsegs[1][X_idx - 1].x2, Xsegs[1][X_idx - 1].y2, P_DOT, 0, idx % MAXATTR); } else { wi->dev_info.xg_dot(wi->dev_info.user_state, Xsegs[1][X_idx - 1].x2, Xsegs[1][X_idx - 1].y2, P_PIXEL, 0, PIXVALUE(idx)); } } else { /* Distinctive markers */ wi->dev_info.xg_dot(wi->dev_info.user_state, Xsegs[1][X_idx - 1].x2, Xsegs[1][X_idx - 1].y2, P_MARK, MARKSTYLE(idx), PIXVALUE(idx)); } } } /* Handle last bar */ if ((thisList->numPoints > 0) && PM_BOOL("BarGraph")) { int barPixels, baseSpot; XSegment line; barPixels = (int) ((PM_DBL("BarWidth") / wi->XUnitsPerPixel) + 0.5); if (barPixels <= 0) barPixels = 1; baseSpot = SCREENY(wi, PM_DBL("BarBase")); line.x1 = line.x2 = Xsegs[1][X_idx - 1].x2 + (int) ((PM_DBL("BarOffset") * idx / wi->XUnitsPerPixel) + 0.5); if (PM_BOOL("StackGraph") && idx != 0) line.y1 = Xsegs[0][X_idx - 1].y2; else line.y1 = baseSpot; line.y2 = Xsegs[1][X_idx - 1].y2; wi->dev_info.xg_seg(wi->dev_info.user_state, 1, &line, barPixels, L_VAR, LINESTYLE(idx), PIXVALUE(idx)); } /* Erase segments */ if ((thisList->numPoints > 0) && (!noLines) && (X_idx > 0)) { ptr = Xsegs[1]; while (X_idx > wi->dev_info.max_segs) { wi->dev_info.xg_seg(wi->dev_info.user_state, wi->dev_info.max_segs, ptr, lineWidth, L_VAR, 16, (int)(1)); /*LINESTYLE(8), (int)(1));*/ ptr += wi->dev_info.max_segs; X_idx -= wi->dev_info.max_segs; } wi->dev_info.xg_seg(wi->dev_info.user_state, X_idx, ptr, lineWidth, L_VAR, 16,(int)(1)); } /* Next subset */ thisList = thisList->next; } } XFlush (disp); } static void DrawData(wi) LocalWin *wi; /* * This routine draws the data sets themselves using the macros * for translating coordinates. */ { double sx1, sy1, sx2, sy2, tx = 0, ty = 0; int idx, subindex; int code1, code2, cd, mark_inside; int X_idx, StoreIDX; /* PW */ XSegment *ptr; PointList *thisList, *lastList; int markFlag, pixelMarks, bigPixel, colorMark; int noLines = PM_BOOL("NoLines"); int lineWidth = PM_INT("LineWidth"); /* PW */ int theDelay; /* PW Suggests we Flush and set first */ theDelay = PM_INT("DelayValue")*100000; XFlush(disp); if (PM_BOOL("Animate")) sleep(1); set_mark_flags(&markFlag, &pixelMarks, &bigPixel, &colorMark); for (idx = 0; idx < MAXSETS; idx++) { if (wi->DOrder == 0) thisList = PlotData[idx].list; else if (wi->DOrder == 1) thisList = DataD1[idx].list; else if (wi->DOrder == 2) thisList = DataD2[idx].list; else { printf ("Internal Error differentiating - order > 2!\n"); exit (1); } while (thisList) { X_idx = 0; for (subindex = 0; subindex < thisList->numPoints - 1; subindex++) { /* Put segment in (sx1,sy1) (sx2,sy2) */ sx1 = thisList->xvec[subindex]; sy1 = thisList->yvec[subindex]; sx2 = thisList->xvec[subindex + 1]; sy2 = thisList->yvec[subindex + 1]; /* Now clip to current window boundary */ C_CODE(sx1, sy1, code1); C_CODE(sx2, sy2, code2); mark_inside = (code1 == 0); while (code1 || code2) { if (code1 & code2) break; cd = (code1 ? code1 : code2); if (cd & LEFT_CODE) { /* Crosses left edge */ ty = sy1 + (sy2 - sy1) * (wi->UsrOrgX - sx1) / (sx2 - sx1); tx = wi->UsrOrgX; } else if (cd & RIGHT_CODE) { /* Crosses right edge */ ty = sy1 + (sy2 - sy1) * (wi->UsrOppX - sx1) / (sx2 - sx1); tx = wi->UsrOppX; } else if (cd & BOTTOM_CODE) {/* Crosses bottom edge */ tx = sx1 + (sx2 - sx1) * (wi->UsrOrgY - sy1) / (sy2 - sy1); ty = wi->UsrOrgY; } else if (cd & TOP_CODE) { /* Crosses top edge */ tx = sx1 + (sx2 - sx1) * (wi->UsrOppY - sy1) / (sy2 - sy1); ty = wi->UsrOppY; } if (cd == code1) { sx1 = tx; sy1 = ty; C_CODE(sx1, sy1, code1); } else { sx2 = tx; sy2 = ty; C_CODE(sx2, sy2, code2); } } if (!code1 && !code2) { /* Add segment to list */ Xsegs[0][X_idx].x1 = Xsegs[1][X_idx].x1; Xsegs[0][X_idx].y1 = Xsegs[1][X_idx].y1; Xsegs[0][X_idx].x2 = Xsegs[1][X_idx].x2; Xsegs[0][X_idx].y2 = Xsegs[1][X_idx].y2; Xsegs[1][X_idx].x1 = SCREENX(wi, sx1); Xsegs[1][X_idx].y1 = SCREENY(wi, sy1); Xsegs[1][X_idx].x2 = SCREENX(wi, sx2); Xsegs[1][X_idx].y2 = SCREENY(wi, sy2); X_idx++; } /* Draw markers if requested and they are in drawing region */ if (markFlag && mark_inside) { if (pixelMarks) { if (bigPixel) { wi->dev_info.xg_dot(wi->dev_info.user_state, Xsegs[1][X_idx - 1].x1, Xsegs[1][X_idx - 1].y1, P_DOT, 0, idx % MAXATTR); } else { wi->dev_info.xg_dot(wi->dev_info.user_state, Xsegs[1][X_idx - 1].x1, Xsegs[1][X_idx - 1].y1, P_PIXEL, 0, PIXVALUE(idx)); } } else { /* Distinctive markers */ wi->dev_info.xg_dot(wi->dev_info.user_state, Xsegs[1][X_idx - 1].x1, Xsegs[1][X_idx - 1].y1, P_MARK, MARKSTYLE(idx), PIXVALUE(idx)); } } /* Draw bar elements if requested */ if (PM_BOOL("BarGraph")) { int barPixels, baseSpot; XSegment line; barPixels = (int) ((PM_DBL("BarWidth") / wi->XUnitsPerPixel) + 0.5); if (barPixels <= 0) barPixels = 1; baseSpot = SCREENY(wi, PM_DBL("BarBase")); line.x1 = line.x2 = Xsegs[1][X_idx - 1].x1 + (int) ((PM_DBL("BarOffset") * idx / wi->XUnitsPerPixel) + 0.5); if (PM_BOOL("StackGraph") && idx != 0) line.y1 = Xsegs[0][X_idx - 1].y1; else line.y1 = baseSpot; line.y2 = Xsegs[1][X_idx - 1].y1; wi->dev_info.xg_seg(wi->dev_info.user_state, 1, &line, barPixels, L_VAR, LINESTYLE(idx), PIXVALUE(idx)); } } /* Handle last marker */ if (markFlag && (thisList->numPoints > 0)) { C_CODE(thisList->xvec[thisList->numPoints - 1], thisList->yvec[thisList->numPoints - 1], mark_inside); if (mark_inside == 0) { if (pixelMarks) { if (bigPixel) { wi->dev_info.xg_dot(wi->dev_info.user_state, Xsegs[1][X_idx - 1].x2, Xsegs[1][X_idx - 1].y2, P_DOT, 0, idx % MAXATTR); } else { wi->dev_info.xg_dot(wi->dev_info.user_state, Xsegs[1][X_idx - 1].x2, Xsegs[1][X_idx - 1].y2, P_PIXEL, 0, PIXVALUE(idx)); } } else { /* Distinctive markers */ wi->dev_info.xg_dot(wi->dev_info.user_state, Xsegs[1][X_idx - 1].x2, Xsegs[1][X_idx - 1].y2, P_MARK, MARKSTYLE(idx), PIXVALUE(idx)); } } } /* Handle last bar */ if ((thisList->numPoints > 0) && PM_BOOL("BarGraph")) { int barPixels, baseSpot; XSegment line; barPixels = (int) ((PM_DBL("BarWidth") / wi->XUnitsPerPixel) + 0.5); if (barPixels <= 0) barPixels = 1; baseSpot = SCREENY(wi, PM_DBL("BarBase")); line.x1 = line.x2 = Xsegs[1][X_idx - 1].x2 + (int) ((PM_DBL("BarOffset") * idx / wi->XUnitsPerPixel) + 0.5); if (PM_BOOL("StackGraph") && idx != 0) line.y1 = Xsegs[0][X_idx - 1].y2; else line.y1 = baseSpot; line.y2 = Xsegs[1][X_idx - 1].y2; wi->dev_info.xg_seg(wi->dev_info.user_state, 1, &line, barPixels, L_VAR, LINESTYLE(idx), PIXVALUE(idx)); } /* Draw segments */ if (!PM_BOOL("Animate")) { if (thisList->numPoints > 0 && (!noLines) && (X_idx > 0)) { ptr = Xsegs[1]; while (X_idx > wi->dev_info.max_segs) { wi->dev_info.xg_seg(wi->dev_info.user_state, wi->dev_info.max_segs, ptr, lineWidth, L_VAR, LINESTYLE(idx), PIXVALUE(idx)); ptr += wi->dev_info.max_segs; X_idx -= wi->dev_info.max_segs; } wi->dev_info.xg_seg(wi->dev_info.user_state, X_idx, ptr, lineWidth, L_VAR, LINESTYLE(idx), PIXVALUE(idx)); } } else { StoreIDX = X_idx; if (thisList->numPoints > 0 && (!noLines) && (X_idx > 0)) { ptr = Xsegs[1]; while (X_idx > wi->dev_info.max_segs) { wi->dev_info.xg_seg(wi->dev_info.user_state, wi->dev_info.max_segs, ptr, lineWidth, L_VAR, LINESTYLE(1), PIXVALUE(2)); ptr += wi->dev_info.max_segs; X_idx -= wi->dev_info.max_segs; } wi->dev_info.xg_seg(wi->dev_info.user_state, X_idx, ptr, lineWidth, L_VAR, LINESTYLE(1), PIXVALUE(2)); } XFlush (disp); for (X_idx=1;X_idxnumPoints > 0) && (!noLines) && (X_idx > 0)) { ptr = Xsegs[1]; while (X_idx > wi->dev_info.max_segs) { wi->dev_info.xg_seg(wi->dev_info.user_state, wi->dev_info.max_segs, ptr, lineWidth, L_VAR, 16, (int)(1)); /*LINESTYLE(8), (int)(1));*/ ptr += wi->dev_info.max_segs; X_idx -= wi->dev_info.max_segs; } wi->dev_info.xg_seg(wi->dev_info.user_state, X_idx, ptr, lineWidth, L_VAR, 16,(int)(1)); } } /* Next subset */ lastList = thisList; thisList = thisList->next; } /* End While */ } if (PM_BOOL("Animate")) { X_idx = StoreIDX; thisList = lastList; if (thisList->numPoints > 0 && (!noLines) && (X_idx > 0)) { ptr = Xsegs[1]; while (X_idx > wi->dev_info.max_segs) { wi->dev_info.xg_seg(wi->dev_info.user_state, wi->dev_info.max_segs, ptr, lineWidth, L_VAR, LINESTYLE(1), PIXVALUE(2)); ptr += wi->dev_info.max_segs; X_idx -= wi->dev_info.max_segs; } wi->dev_info.xg_seg(wi->dev_info.user_state, X_idx, ptr, lineWidth, L_VAR, LINESTYLE(1), PIXVALUE(2)); } } XFlush (disp); } static void DrawLegend(wi) LocalWin *wi; /* * This draws a legend of the data sets displayed. Only those that * will fit are drawn. */ { int idx, spot, lineLen, oneLen, incr; XSegment leg_line; int markFlag, pixelMarks, bigPixel, colorMark; set_mark_flags(&markFlag, &pixelMarks, &bigPixel, &colorMark); spot = wi->XOrgY; lineLen = 0; incr = 2 + wi->dev_info.axis_height + wi->dev_info.bdr_pad; /* First pass draws the text */ for (idx = 0; idx < MAXSETS; idx++) { if ((PlotData[idx].list) && (spot + wi->dev_info.axis_height + 2 < wi->XOppY)) { /* Meets the criteria */ oneLen = strlen(PlotData[idx].setName); if (oneLen > lineLen) lineLen = oneLen; wi->dev_info.xg_text(wi->dev_info.user_state, wi->XOppX + wi->dev_info.bdr_pad, spot + 2, PlotData[idx].setName, T_UPPERLEFT, T_AXIS); spot += incr; } } lineLen = lineLen * wi->dev_info.axis_width; leg_line.x1 = wi->XOppX + wi->dev_info.bdr_pad; leg_line.x2 = leg_line.x1 + lineLen; spot = wi->XOrgY; /* second pass draws the lines */ for (idx = 0; idx < MAXSETS; idx++) { if ((PlotData[idx].list) && (spot + wi->dev_info.axis_height + 2 < wi->XOppY)) { leg_line.y1 = leg_line.y2 = spot - wi->dev_info.legend_pad; if (PM_BOOL("BarGraph")) wi->dev_info.xg_seg(wi->dev_info.user_state, 1, &leg_line, incr / 4, L_VAR, LINESTYLE(idx), PIXVALUE(idx)); if (!PM_BOOL("NoLines")) wi->dev_info.xg_seg(wi->dev_info.user_state, 1, &leg_line, 1, L_VAR, LINESTYLE(idx), PIXVALUE(idx)); if (markFlag && !pixelMarks) { wi->dev_info.xg_dot(wi->dev_info.user_state, leg_line.x1, leg_line.y1, P_MARK, MARKSTYLE(idx), PIXVALUE(idx)); } spot += incr; } } } static void set_mark_flags(markFlag, pixelMarks, bigPixel, colorMark) int *markFlag; int *pixelMarks; int *bigPixel; int *colorMark; /* * Determines the values of the old boolean flags based on the * new values in the parameters database. */ { *markFlag = 0; *pixelMarks = 0; *colorMark = 0; *bigPixel = 0; if (PM_BOOL("Markers")) { *markFlag = 1; *pixelMarks = 0; *colorMark = 0; } if (PM_BOOL("PixelMarkers")) { *markFlag = 1; *pixelMarks = 1; *bigPixel = 0; } if (PM_BOOL("LargePixels")) { *markFlag = 1; *pixelMarks = 1; *bigPixel = 1; } if (PM_BOOL("StyleMarkers")) { *markFlag = 1; *pixelMarks = 0; *colorMark = 1; } } #undef DELAY xgraph-12.1.orig/general.h0100664000175000000620000000000007355433460014077 0ustar bapstaffxgraph-12.1.orig/hard_devices.c0100664000175000000620000000524507360237502015110 0ustar bapstaff/* $Header: /usr/src/mash/repository/vint/xgraph/hard_devices.c,v 1.1.1.1 1999/12/03 23:15:52 heideman Exp $ */ /* * Hardcopy Devices * * This file contains the basic output device table. The hardcopy * dialog is automatically constructed from this table. * * $Log: hard_devices.c,v $ * Revision 1.1.1.1 1999/12/03 23:15:52 heideman * xgraph-12.0 * */ #ifndef lint static char rcsid[] = "$Id: hard_devices.c,v 1.1.1.1 1999/12/03 23:15:52 heideman Exp $"; #endif #include #include "copyright.h" #include "xgout.h" #include "hard_devices.h" #include "params.h" extern int hpglInit(); extern int psInit(); extern int idrawInit(); extern int tgifInit(); struct hard_dev hard_devices[] = { {"HPGL", hpglInit, "lpr -P%s", "xgraph.hpgl", "paper", 27.5, "1", 14.0, "1", 12.0, NONE}, {"Postscript", psInit, "lpr -P%s", "xgraph.ps", "$PRINTER", 19.0, "Times-Bold", 18.0, "Times-Roman", 12.0, NO}, {"Idraw", idrawInit, "cat > /usr/tmp/idraw.tmp.ps; %s /usr/tmp/idraw.tmp.ps&", "~/.clipboard", "/usr/bin/X11/idraw", 19.0, "Times-Bold", 18.0, "Times-Roman", 12.0, NONE}, {"Tgif", tgifInit, "cat > /usr/tmp/xgraph.obj; %s /usr/tmp/xgraph &", "xgraph.obj", "/usr/bin/X11/tgif", 19.0, "Times-Bold", 18.0, "Times-Roman", 12.0, NONE} }; int hard_count = sizeof(hard_devices) / sizeof(struct hard_dev); #define CHANGE_D(name, field) \ if (param_get(name, &val)) { \ if (val.type == DBL) { \ hard_devices[idx].field = val.dblv.value; \ } \ } #define CHANGE_S(name, field) \ if (param_get(name, &val)) { \ if (val.type == STR) { \ (void) strcpy(hard_devices[idx].field, val.strv.value); \ } \ } void hard_init() /* * Changes values in hard_devices structures in accordance with * parameters set using the parameters module. */ { char nn[BUFSIZ]; int idx; params val; for (idx = 0; idx < hard_count; idx++) { (void) sprintf(nn, "%s.Dimension", hard_devices[idx].dev_name); CHANGE_D(nn, dev_max_dim); (void) sprintf(nn, "%s.OutputTitleFont", hard_devices[idx].dev_name); CHANGE_S(nn, dev_title_font); (void) sprintf(nn, "%s.OutputTitleSize", hard_devices[idx].dev_name); CHANGE_D(nn, dev_title_size); (void) sprintf(nn, "%s.OutputAxisFont", hard_devices[idx].dev_name); CHANGE_S(nn, dev_axis_font); (void) sprintf(nn, "%s.OutputAxisSize", hard_devices[idx].dev_name); CHANGE_D(nn, dev_axis_size); if (hard_devices[idx].dev_printer[0] == '$') { extern char *getenv(); char *ptr; if ((ptr = getenv(&hard_devices[idx].dev_printer[1]))) { (void) strncpy(hard_devices[idx].dev_printer, ptr, MFNAME - 1); hard_devices[idx].dev_printer[MFNAME - 1] = '\0'; } } } } xgraph-12.1.orig/hard_devices.h0100775000175000000620000000231507360237511015113 0ustar bapstaff/* * Hardcopy Device Header * * This file declares the types required for the hardcopy table * found in hard_devices.c. */ #ifndef _h_hard_devices #define _h_hard_devices #define MFNAME 25 typedef enum hard_dev_docu_defn { NONE, NO, YES } hard_dev_docu; struct hard_dev { char *dev_name; /* Device name */ int (*dev_init) (); /* Initialization function */ char *dev_spec; /* Default pipe program */ char dev_file[MFNAME]; /* Default file name */ char dev_printer[MFNAME];/* Default printer name */ double dev_max_dim; /* Default maximum dimension (cm) */ char dev_title_font[MFNAME]; /* Default name of title font */ double dev_title_size; /* Default size of title font (pnts) */ char dev_axis_font[MFNAME]; /* Default name of axis font */ double dev_axis_size; /* Default size of axis font (pnts) */ hard_dev_docu dev_docu; /* Document predicate */ }; extern int hard_count; extern struct hard_dev hard_devices[]; #define D_HPGL 0 #define D_POSTSCRIPT 1 #define D_IDRAW 2 #define D_TGIF 3 #define D_XWINDOWS 4 extern void hard_init(); #endif /* _h_hard_devices */ xgraph-12.1.orig/hpgl.c0100664000175000000620000002337707360237503013431 0ustar bapstaff/* * HPGL Output * * Tom Quarles */ #define MAPX(state,x) ( (x) + P1X + state->clipminX ) #define MAPY(state,y) ( MAXY - (y) + P1Y - state->clipminY) #include "copyright.h" #include "xgraph.h" #include "plotter.h" #include #include static void hpglText(); static void hpglSeg(); static void hpglDot(); static void hpglEnd(); static xgOut hpglInfo = { D_COLOR, /* device characteristics */ MAXX, /* width */ MAXY, /* height */ 200, /* border padding */ 0, /* extra space around axis labels */ 250, /* tick length - approx 1/4 inch */ 50, /* spacing above legend lables */ 0, /* axis font width */ 0, /* axis font height */ 0, /* title font width */ 0, /* title font height */ 1000000, /* maximum number of segments */ hpglText, /* text output function */ hpglSeg, /* segment drawing function */ hpglDot, /* dot/marker drawing function */ hpglEnd, /* end of plot function */ NULL, /* userInfo */ }; typedef struct { double axis_w; double axis_h; double title_w; double title_h; FILE *plotterFile; int clipminX; int clipminY; int clipmaxX; int clipmaxY; } mydata; /*ARGSUSED*/ int hpglInit(stream, width, height, title_family, title_size, axis_family, axis_size, flags, outInfo, errmsg) FILE *stream; /* output stream */ int width; /* desired width of space in microns */ int height; /* desired height in microns */ char *title_family; /* name of font for titles */ double title_size; /* size of font for titles */ char *axis_family; /* name of font for axes */ double axis_size; /* size of font for axes */ int flags; /* predicate values (ignored) */ xgOut *outInfo; /* my structure */ char errmsg[ERRBUFSIZE]; /* a place to complain to */ { mydata *myInfo; myInfo = (mydata *) Malloc(sizeof(mydata)); if (myInfo == NULL) return 0; *outInfo = hpglInfo; outInfo->area_w = MIN(MAXX, width / 25); outInfo->area_h = MIN(MAXY, height / 25); /* magic formulas: input sizes are in points = 1/72 inch */ /* my sizes are in cm */ /* plotter units are in units of .025mm ~= 1/1016 inch */ /* * have to warn of height 1.5 times larger or get bitten by plotter's * internal padding */ /* widths are (arbitrarily) selected to be 2/3 of the height */ /* (cancels with width factor) */ myInfo->axis_w = axis_size * .666 * 2.54 / 72.; myInfo->axis_h = axis_size * 2.54 / 72.; myInfo->title_w = title_size * .666 * 2.54 / 72.; myInfo->title_h = title_size * 2.54 / 72.; outInfo->axis_pad = axis_size * 1016. * 1.5 / 72.; outInfo->axis_width = axis_size * 1016. * 1.5 / 72.; outInfo->axis_height = axis_size * 1016. * .666 / 72.; outInfo->title_width = title_size * 1016. * 1.5 / 72.; outInfo->title_height = title_size * 1016. * .666 / 72.; outInfo->user_state = (char *) myInfo; myInfo->plotterFile = stream; myInfo->clipminX = 0; myInfo->clipminY = 0; myInfo->clipmaxX = MAXX; myInfo->clipmaxY = MAXY; fprintf(myInfo->plotterFile, "PG;IN;\n"); fprintf(myInfo->plotterFile, "DI1,0;\n"); fprintf(myInfo->plotterFile, "IW%d,%d,%d,%d;\n", MAPX(myInfo, 0), MAPY(myInfo, myInfo->clipmaxY - myInfo->clipminY), MAPX(myInfo, myInfo->clipmaxX - myInfo->clipminX), MAPY(myInfo, 0)); return (1); } static void hpglText(userState, x, y, text, just, style) mydata *userState; /* my state information */ int x, y; /* coords of text origin */ char *text; /* what to put there */ int just; /* how to justify */ /* * where the origin is relative to where the text should go as a function of * the various values of just * * T_UPPERLEFT T_TOP T_UPPERRIGHT T_LEFT T_CENTER T_RIGHT * T_LOWERLEFT T_BOTTOM T_LOWERRIGHT * */ int style; /* T_AXIS = axis font, T_TITLE = title font */ { fprintf(userState->plotterFile, "PU;SP%d;", TEXTCOLOR); fprintf(userState->plotterFile, "PA%d,%d;", MAPX(userState, x), MAPY(userState, y)); switch (style) { case T_AXIS: fprintf(userState->plotterFile, "SI%f,%f;", userState->axis_w, userState->axis_h); break; case T_TITLE: fprintf(userState->plotterFile, "SI%f,%f;", userState->title_w, userState->title_h); break; default: printf("bad text style %d in hpglText\n", style); exit(1); break; } switch (just) { case T_UPPERLEFT: fprintf(userState->plotterFile, "LO3;\n"); break; case T_TOP: fprintf(userState->plotterFile, "LO6;\n"); break; case T_UPPERRIGHT: fprintf(userState->plotterFile, "LO9;\n"); break; case T_LEFT: fprintf(userState->plotterFile, "LO2;\n"); break; case T_CENTER: fprintf(userState->plotterFile, "LO5;\n"); break; case T_RIGHT: fprintf(userState->plotterFile, "LO8;\n"); break; case T_LOWERLEFT: fprintf(userState->plotterFile, "LO1;\n"); break; case T_BOTTOM: fprintf(userState->plotterFile, "LO4;\n"); break; case T_LOWERRIGHT: fprintf(userState->plotterFile, "LO7;\n"); break; default: printf("bad justification type %d in hpglText\n", just); exit(1); break; } fprintf(userState->plotterFile, "LB%s\03;", text); } static int penselect[8] = {PEN1, PEN2, PEN3, PEN4, PEN5, PEN6, PEN7, PEN8}; static int lineselect[8] = {LINE1, LINE2, LINE3, LINE4, LINE5, LINE6, LINE7, LINE8}; static void hpglSeg(userState, ns, segs, width, style, lappr, color) mydata *userState; /* my state information (not used) */ int ns; /* number of segments */ XSegment *segs; /* X array of segments */ int width; /* width of lines in pixels */ int style; /* L_VAR = dotted, L_AXIS = grid, L_ZERO = axis */ int lappr; /* line style */ int color; /* line color */ { int i; if (style == L_ZERO) { fprintf(userState->plotterFile, "SP%d;", PENAXIS); /* select correct pen */ fprintf(userState->plotterFile, "LT;"); /* solid line style */ } else if (style == L_AXIS) { fprintf(userState->plotterFile, "SP%d;", PENGRID); /* select correct pen */ fprintf(userState->plotterFile, "LT;"); /* solid line style */ } else if (style == L_VAR) { if ((color < 0) || (color > 7)) { printf("out of range line color %d in hpglLine\n", color); exit(1); } fprintf(userState->plotterFile, "SP%d;", penselect[color]); /* select correct pen */ if ((lappr < 0) || (lappr > 7)) { printf("out of range line style %d in hpglLine\n", lappr); exit(1); } if (lappr == 0) { fprintf(userState->plotterFile, "LT;"); /* select solid line * type */ } else { fprintf(userState->plotterFile, "LT%d;", lineselect[lappr]); /* select line type */ } } else { printf("unknown style %d in hpglLine\n", style); exit(1); } for (i = 0; i < ns; i++) { if (!i || ((segs[i].x1 != segs[i - 1].x2) || (segs[i].y1 != segs[i - 1].y2))) { /* MOVE */ fprintf(userState->plotterFile, "PU;PA%d,%d;\n", MAPX(userState, segs[i].x1), MAPY(userState, segs[i].y1)); } /* DRAW */ if (width <= 1) { fprintf(userState->plotterFile, "PD;PA%d,%d;\n", MAPX(userState, segs[i].x2), MAPY(userState, segs[i].y2)); } else { /* ugly - wide lines -> rectangles */ double frac; int lx, ly; int urx, ury, ulx, uly, llx, lly, lrx, lry; frac = (width / 2) / sqrt((double) ((segs[i].x1 - segs[i].x2) * (segs[i].x1 - segs[i].x2)) + ((segs[i].y1 - segs[i].y2) * (segs[i].y1 - segs[i].y2))); lx = frac * (segs[i].y2 - segs[i].y1); ly = -frac * (segs[i].x2 - segs[i].x1); urx = segs[i].x2 + lx; ury = segs[i].y2 + ly; ulx = segs[i].x2 - lx; uly = segs[i].y2 - ly; llx = segs[i].x1 - lx; lly = segs[i].y1 - ly; lrx = segs[i].x1 + lx; lry = segs[i].y1 + ly; fprintf(userState->plotterFile, "PU;PA%d,%d;", MAPX(userState, llx), MAPY(userState, lly)); fprintf(userState->plotterFile, "PM0;"); fprintf(userState->plotterFile, "PD,PA%d,%D;PA%d,%D;PA%d,%d;\n", MAPX(userState, lrx), MAPY(userState, lry), MAPX(userState, urx), MAPY(userState, ury), MAPX(userState, ulx), MAPY(userState, uly)); fprintf(userState->plotterFile, "PM2;FP;EP;"); } } fprintf(userState->plotterFile, "PU;"); } static char *markselect[8] = {MARK1, MARK2, MARK3, MARK4, MARK5, MARK6, MARK7, MARK8}; static void hpglDot(userState, x, y, style, type, color) mydata *userState; /* my state information (not used) */ int x, y; /* coord of dot */ int style; /* type of dot */ int type; /* dot style variation */ int color; /* color of dot */ { /* move to given coord */ fprintf(userState->plotterFile, "PU;PA%d,%d;\n", MAPX(userState, x), MAPY(userState, y)); if ((color < 0) || (color > 7)) { printf("unknown color %d in hpglDot\n", color); exit(1); } fprintf(userState->plotterFile, "SP%d;", penselect[color]); if (style == P_PIXEL) { fprintf(userState->plotterFile, "PD;PU;\n"); } else if (style == P_DOT) { fprintf(userState->plotterFile, "LT;PM0;CI40;PM2;FT;EP;\n"); } else if (style == P_MARK) { if ((type < 0) || (type > 7)) { printf("unknown marker type %d in hpglDot\n", type); exit(1); } /* * fprintf(userState->plotterFile,"LT;CA5;LO4;SI0.1;LB%s\03;\n",marksele * ct[type]); */ fprintf(userState->plotterFile, "LT;CS5;LO4;SI0.15;SM%s;PR0,0;SM;CS;\n", markselect[type]); } else { printf("unknown marker style %d in hpglDot\n", style); exit(1); } } static void hpglEnd(userState) mydata *userState; /* my state information (not used) */ { fprintf(userState->plotterFile, "SP;PG;IN;\n"); fflush(userState->plotterFile); return; } xgraph-12.1.orig/idraw.c0100664000175000000620000003436207360237504013602 0ustar bapstaff/* * Idraw Output * * Beorn Johnson * Alan Kramer * David Harrison */ #include #include #include "hard_devices.h" #include "xgout.h" #define HEIGHT 792 #define FIX(X) X = HEIGHT - X; typedef struct { char *title_font; char *axis_font; int title_size; int axis_size; FILE *strm; } Info; char *idraw_prologue[] = { "%I Idraw 4", "Begin", "%I b u", "%I cfg u", "%I cbg u", "%I f u", "%I p u", "%I t", "[ 1 0 0 1 0 0 ] concat", "/originalCTM matrix currentmatrix def", 0 }; /* * Hardcopy Interface for Xgraph * * Major differences from first version: * Four new parameters are passed to the device initialization routine: * title_family, title_size, axis_family, and axis_size. See the * description of xg_init() for details. * * Clipping is done automatically by xgraph. The xg_clip() routine * is obsolete. * * The xg_line() routine has become the xg_seg() routine. It now * draws segments rather than a series of lines. * * A new field (max_segs) in the device structure now specifies * the maximum number of segments the device can handle in a group. */ /* * Adding an output device to xgraph * * Step 1 * Write versions of the following routines for your device: * xg_init(), xg_text(), xg_seg(), xg_dot(), and xg_end(). * The interface and function of these routines are described * in detail below. These routines should be named according * to your device. For example, the initialization routine * for the Postscript output device is psInit(). Also, name * your source file after your device (e.g. the postscript * routines are in the file ps.c). Instructions continue * after the description of the interface routines. */ void idrawText(); void idrawDot(); void idrawSeg(); void idrawEnd(); int idrawInit(strm, width, height, title_family, title_size, axis_family, axis_size, flags, out_info, errmsg) FILE *strm; /* Output stream */ int width, height; /* Size of space (microns) */ char *title_family; /* Name of title font family */ double title_size; /* Title font height (points) */ char *axis_family; /* Name of axis font family */ double axis_size; /* Axis font height (points) */ int flags; /* Flags */ xgOut *out_info; /* Device info (RETURN) */ char errmsg[ERRBUFSIZE]; /* Error message area */ /* * This routine is called by xgraph just before drawing is to * begin. The desired size of the plot is given by `width' * and `height'. The parameters `title_family', `title_size', * `axis_family', and `axis_size' specify the names of the * title and axis fonts and their vertical sizes (in points). * These parameters can be ignored if your device does not * support multiple fonts. Binary flags are specified in * the `flags' field. These include: * D_DOCU: * If this flag is set, it indicates the user has specified that * the output will be included in some larger document. Devices * may choose to use this information to produce output that * can be integrated into documents with less effort. For example, * the Postscript output routines produce bounding box information * when this flag is set. * The routine should fill in all of the fields of `out_info' with * appropriate values. The values are described below: * area_w, area_h: * Size of the drawing space in device coordinates. * This should take in account the requested area * given by `width', and `height'. * bdr_pad: * Xgraph will leave this number of device coordinates around * all of the outer edges of the graph. * axis_pad: * Additional space around axis labels (in devcoords) * so that the labels do not appear crowded. * legend_pad: * Space (in devcoords) from the top of legend text to * the representative line drawn above the legend text. * tick_len: * Size of a tick mark placed on axis (in devcoords) * axis_width: * An estimate of the width of a large character in * the axis font (in devcoords). This can be an overestimate. An * underestimate may produce bad results. * axis_height: * An estimate of the height of a large character in * the axis labeling font (in devcoords). * title_width, title_height: * Same as above except for the title font. * max_segs: * Due to buffering constraints, some devices may not be able to * handle massive segment lists. This parameter tells xgraph not * to send more than `max_segs' segments in one request. * Output to the device should be written to the stream `strm'. * The functions are described individually below. After filling * in the parameters and setting the function pointers, the routine * should initialize its drawing state and store any extra needed * information in `user_state'. This value will be passed to all * other routines during the drawing sequence. If the device * cannot initialize, it should return a zero status and fill * `errmsg' with an informative error message. */ { Info *idraw_info; char **l; double scx, scy; idraw_info = (Info *) Malloc(sizeof(*idraw_info)); for (l = idraw_prologue; *l; l++) fprintf(strm, "%s\n", *l); out_info->dev_flags = 0; scx = width / 612; scy = height / 792.0; if (scx > scy) { scy /= scx; scx = 1; } else { scx /= scy; scy = 1; } out_info->bdr_pad = title_size / 4; out_info->axis_pad = 2.0 * axis_size; out_info->legend_pad = 0; out_info->area_w = width * 0.00283; /* pts per micron */ out_info->area_h = height * 0.00283; out_info->tick_len = axis_size; out_info->axis_height = axis_size; out_info->title_height = title_size; out_info->axis_width = (axis_size * 5.0) / 12.0; out_info->title_width = (title_size * 5.0) / 12.0; out_info->max_segs = 100; out_info->xg_text = idrawText; out_info->xg_seg = idrawSeg; out_info->xg_dot = idrawDot; out_info->xg_end = idrawEnd; out_info->user_state = (char *) idraw_info; idraw_info->title_font = title_family; idraw_info->axis_font = axis_family; idraw_info->title_size = title_size; idraw_info->axis_size = axis_size; idraw_info->strm = strm; return 1; } /* Text justifications */ #define T_CENTER 0 #define T_LEFT 1 #define T_UPPERLEFT 2 #define T_TOP 3 #define T_UPPERRIGHT 4 #define T_RIGHT 5 #define T_LOWERRIGHT 6 #define T_BOTTOM 7 #define T_LOWERLEFT 8 /* Text styles */ #define T_AXIS 0 #define T_TITLE 1 static void idraw_just(x, y, just, size, len) int *x, *y; /* Given location (lower left) */ int just; /* Justification */ int size; /* Size in points */ int len; /* Number of chars */ /* * Unfortunately, idraw really can't display text with a justification. * This is a horrible hack to try to get around the problem. It tries * to compute a rough bounding box for the text based on the text height * and the string length and offset `x,y' appropriately for the justification. * This is only a hack... */ { int t_width, t_height; t_height = size; t_width = (size * len * 5) / 12; /* Horrible estimate */ switch (just) { case T_CENTER: *x -= t_width / 2; *y += t_height / 2; break; case T_LEFT: *y += t_height / 2; break; case T_UPPERLEFT: /* nothing */ break; case T_TOP: *x -= t_width / 2; break; case T_UPPERRIGHT: *x -= t_width; break; case T_RIGHT: *x -= t_width; *y += t_height / 2; break; case T_LOWERRIGHT: *x -= t_width; *y += t_height; break; case T_BOTTOM: *x -= t_width / 2; *y += t_height; break; case T_LOWERLEFT: *y += t_height; break; } /* * Also, idraw seems to put a space above all text it draws. The * computation below compensates for this. */ *y += (size / 3); } void idrawText(user_state, x, y, text, just, style) char *user_state; /* Value set in xg_init */ int x, y; /* Text position (pixels) */ char *text; /* Null terminated text */ int just; /* Justification (above) */ int style; /* Text style (above) */ /* * This routine should draw text at the indicated position using * the indicated justification and style. The justification refers * to the location of the point in reference to the text. For example, * if just is T_LOWERLEFT, (x,y) should be located at the lower left * edge of the text string. */ { char *font; int size; Info *idraw = (Info *) user_state; FIX(y); font = style == T_AXIS ? idraw->axis_font : idraw->title_font; size = style == T_AXIS ? idraw->axis_size : idraw->title_size; idraw_just(&x, &y, just, size, strlen(text)); fprintf(idraw->strm, "Begin %%I Text\n"); fprintf(idraw->strm, "%%I cfg Black\n"); fprintf(idraw->strm, "0 0 0 SetCFg\n"); fprintf(idraw->strm, "%%I f *%s*-%d-*\n", font, size); fprintf(idraw->strm, "/%s %d SetF\n", font, size); fprintf(idraw->strm, "%%I t\n"); fprintf(idraw->strm, "[ 1 0 0 1 %d %d ] concat\n", x, y); fprintf(idraw->strm, "%%I\n"); fprintf(idraw->strm, "[\n"); fprintf(idraw->strm, "(%s)\n", text); fprintf(idraw->strm, "] Text\n"); fprintf(idraw->strm, "End\n"); } /* Line Styles */ #define L_AXIS 0 #define L_ZERO 1 #define L_VAR 2 void idrawSeg(user_state, ns, seglist, width, style, lappr, color) char *user_state; /* Value set in xg_init */ int ns; /* Number of segments */ XSegment *seglist; /* X array of segments */ int width; /* Width of lines */ int style; /* See above */ int lappr; /* Line appearence */ int color; /* Line color (if any) */ /* * This routine draws a number of line segments at the points * given in `seglist'. Note that contiguous segments need not share * endpoints but often do. All segments should be `width' devcoords wide * and drawn in style `style'. If `style' is L_VAR, the parameters * `color' and `lappr' should be used to draw the line. Both * parameters vary from 0 to 7. If the device is capable of * color, `color' varies faster than `style'. If the device * has no color, `style' will vary faster than `color' and * `color' can be safely ignored. However, if the * the device has more than 8 line appearences, the two can * be combined to specify 64 line style variations. * Xgraph promises not to send more than the `max_segs' in the * xgOut structure passed back from xg_init(). */ { Info *idraw = (Info *) user_state; short to_style; int i, j, k; static unsigned short style_list[] = { 0xffff, 0xf0f0, 0xcccc, 0xaaaa, 0xf060, 0xf198, 0x7f55, 0x0000, }; to_style = style == L_AXIS ? 65535 : style == L_ZERO ? 65535 : style_list[lappr]; for (i = 0; i < ns; i++) { FIX(seglist[i].y1); FIX(seglist[i].y2); } for (i = 0; i < ns; i = j) { for (j = i + 1; j < ns && seglist[j - 1].x2 == seglist[j].x1 && seglist[j - 1].y2 == seglist[j].y1; j++); fprintf(idraw->strm, "Begin %%I MLine\n"); fprintf(idraw->strm, "%%I b %d\n", to_style); fprintf(idraw->strm, "%d 0 0 [", width); /* fprintf(idraw -> strm, "%d"); */ fprintf(idraw->strm, "] 0 SetB\n"); fprintf(idraw->strm, "%%I cfg Black\n"); fprintf(idraw->strm, "0 0 0 SetCFg\n"); fprintf(idraw->strm, "%%I cbg White\n"); fprintf(idraw->strm, "1 1 1 SetCBg\n"); fprintf(idraw->strm, "none SetP %%I p n\n"); fprintf(idraw->strm, "%%I t u\n"); fprintf(idraw->strm, "%%I %d\n", j - i + 1); for (k = i; k < j; k++) fprintf(idraw->strm, "%d %d\n", seglist[k].x1, seglist[k].y1); fprintf(idraw->strm, "%d %d\n", seglist[k - 1].x2, seglist[k - 1].y2); fprintf(idraw->strm, "%d MLine\n", j - i + 1); fprintf(idraw->strm, "End\n"); } } /* Marker styles */ #define P_PIXEL 0 #define P_DOT 1 #define P_MARK 2 void idrawDot(user_state, x, y, style, type, color) char *user_state; /* Value set in xg_init */ int x, y; /* Location in pixel units */ int style; /* Dot style */ int type; /* Type of marker */ int color; /* Marker color (if any) */ /* * This routine should draw a marker at location `x,y'. If the * style is P_PIXEL, the dot should be a single pixel. If * the style is P_DOT, the dot should be a reasonably large * dot. If the style is P_MARK, it should be a distinguished * mark which is specified by `type' (0-7). If the output * device is capable of color, the marker should be drawn in * `color' (0-7) which corresponds with the color for xg_line. */ { } void idrawEnd(user_state) char *user_state; /* * This routine is called after a drawing sequence is complete. * It can be used to clean up the user state and set the device * state appropriately. This routine is optional in the structure. */ { Info *idraw = (Info *) user_state; fprintf(idraw->strm, "End %%I eop\n"); fclose(idraw->strm); } /* * Adding an output device to xgraph * * Step 2 * Edit the file hard_devices.c. Declare your initialization * function and add your device to the list of devices, * hard_devices[]. The structure hard_dev is described below: */ #ifdef notdef extern int idrawInit(); struct hard_dev idraw = { "idraw format", idrawInit, 0, ".clipboard", 0, 25, "Times-Bold", 18, "Times", 12 }; #endif /* * dev_spec: * The dev_spec field should be a command that directly outputs to * your device. The command should contain one %s directive that * will be filled in with the name of the device from the hardcopy * dialog. * dev_file: * The default file to write output to if the user selects `To File'. * dev_printer: * The default printer to write output to if the user selects * `To Device'. * dev_max_dim: * The default maximum dimension for the device in centimeters. * dev_title_font, dev_title_size: * The default title font and size. Sizes are specified in * points (1/72 inch). * dev_axis_font, dev_axis_size: * The default axis font and size. */ /* * Adding an output device to xgraph * * Step 3 * Edit the file Makefile. Add your source file to the SRC variable * and the corresponding object file to the OBJ variable. Finally, * remake xgraph. Your device should now be available in the * hardcopy dialog. */ xgraph-12.1.orig/init.c0100664000175000000620000004467007360237511013440 0ustar bapstaff/* $Header: /usr/src/mash/repository/vint/xgraph/init.c,v 1.2 1999/12/19 00:52:06 heideman Exp $ */ /* * init.c: xgraph initialization code * * Routines: * InitSets(); * ParseArgs(); * ReadDefaults(); * * $Log: init.c,v $ * Revision 1.2 1999/12/19 00:52:06 heideman * warning suppresion, slightly different flot ahndling * * Revision 1.1.1.1 1999/12/03 23:15:53 heideman * xgraph-12.0 * */ #ifndef lint static char rcsid[] = "$Id: init.c,v 1.2 1999/12/19 00:52:06 heideman Exp $"; #endif #include "copyright.h" #include #include #include #include #include "xgraph.h" #include "xtb.h" #include "hard_devices.h" #include "params.h" /* * Default settings for xgraph parameters */ /* PW */ #define DEF_ANIMATE "off" #define DEF_DELAY_VALUE "2" #define DEF_BORDER_WIDTH "2" #define DEF_BORDER_COLOR "Black" #define DEF_TITLE_TEXT "X Graph" #define DEF_XUNIT_TEXT "X" #define DEF_YUNIT_TEXT "Y" #define DEF_TICK_FLAG "off" #define DEF_TICKAXIS_FLAG "off" #define DEF_MARK_FLAG "off" #define DEF_PIXMARK_FLAG "off" #define DEF_LARGEPIX_FLAG "off" #define DEF_DIFFMARK_FLAG "off" #define DEF_BB_FLAG "off" #define DEF_NOLINE_FLAG "off" #define DEF_NOLEGEND_FLAG "off" #define DEF_NOBUTTON_FLAG "off" #define DEF_LOGX_FLAG "off" #define DEF_LOGY_FLAG "off" #define DEF_BAR_FLAG "off" #define DEF_STK_FLAG "off" #define DEF_FITX_FLAG "off" #define DEF_FITY_FLAG "off" #define DEF_BAR_BASE "0.0" #define DEF_BAR_OFFS "0.0" #define DEF_BAR_WIDTH "-1.0" #define DEF_LINE_WIDTH "0" #define DEF_GRID_SIZE "0" #define DEF_GRID_STYLE "10" #define DEF_LABEL_FONT "helvetica-10" #define DEF_TITLE_FONT "helvetica-18" #define DEF_GEOMETRY "" #define DEF_REVERSE "off" /* PW Changes these to please JM */ #define DEF_FMT_X "%.4f" #define DEF_FMT_Y "%.4f" #define DEF_DEVICE "" #define DEF_OUTPUT_DEVICE D_XWINDOWS #define DEF_DISPOSITION "To Device" #define DEF_FILEORDEV "" #define DEF_DOCUMENT "off" #define DEF_SCALE "1.0" #define DEF_MARKER_FLAG "off" #define DEF_DIFFMARK_FLAG "off" #define DEF_PIXMARK_FLAG "off" #define DEF_LARGEPIX_FLAG "off" /* Low > High means set it based on the data */ #define DEF_LOW_LIMIT "1.0" #define DEF_HIGH_LIMIT "0.0" /* Black and white defaults */ #define DEF_BW_BACKGROUND "white" #define DEF_BW_BORDER "black" #define DEF_BW_ZEROCOLOR "black" #define DEF_BW_ZEROWIDTH "3" #define DEF_BW_ZEROSTYLE "1" #define DEF_BW_FOREGROUND "black" /* Color defaults */ #define DEF_COL_BACKGROUND "#ccc" #define DEF_COL_BORDER "black" #define DEF_COL_ZEROCOLOR "white" #define DEF_COL_ZEROWIDTH "0" #define DEF_COL_ZEROSTYLE "1" #define DEF_COL_FOREGROUND "black" #define DEF_COL_FIRSTSTYLE "1" /* Default line styles */ static char *defStyle[MAXATTR] = { "1", "10", "11110000", "010111", "1110", "1111111100000000", "11001111", "0011000111" }; /* Default color names */ /*static char *defColors[MAXATTR] = { "red", "SpringGreen", "blue", "yellow", "cyan", "sienna", "orange", "coral" };*/ static char *defColors[MAXATTR] = { "red", "SpringGreen", "blue", "yellow", "purple", "orange", "hotpink", "cyan" }; void InitSets(o) int o; /* * Initializes the data sets with default information. Sets up * original values for parameters in parameters package. */ { int idx; char buf[1024]; if (o == D_XWINDOWS) { /* * Used to do all kinds of searching through visuals, etc. Got * complaints -- so back to the simple version. */ vis = DefaultVisual(disp, DefaultScreen(disp)); cmap = DefaultColormap(disp, DefaultScreen(disp)); screen = DefaultScreen(disp); depth = DefaultDepth(disp, DefaultScreen(disp)); param_init(disp, cmap); } else param_init(NULL, 0); param_set("Debug", BOOL, "false"); param_set("Geometry", STR, DEF_GEOMETRY); param_set("ReverseVideo", BOOL, DEF_REVERSE); param_set("BorderSize", INT, DEF_BORDER_WIDTH); param_set("TitleText", STR, DEF_TITLE_TEXT); param_set("XUnitText", STR, DEF_XUNIT_TEXT); param_set("YUnitText", STR, DEF_YUNIT_TEXT); /* YUnits */ param_set("Ticks", BOOL, DEF_TICK_FLAG); param_set("TickAxis", BOOL, DEF_TICKAXIS_FLAG); param_set("Markers", BOOL, DEF_MARKER_FLAG); /* markFlag (-m) */ param_set("StyleMarkers", BOOL, DEF_DIFFMARK_FLAG); /* colorMark (-M) */ param_set("PixelMarkers", BOOL, DEF_PIXMARK_FLAG); /* pixelMarks (-p) */ param_set("LargePixels", BOOL, DEF_LARGEPIX_FLAG); /* bigPixel (-P) */ param_set("BoundBox", BOOL, DEF_BB_FLAG); param_set("NoLines", BOOL, DEF_NOLINE_FLAG); param_set("NoLegend", BOOL, DEF_NOLEGEND_FLAG); param_set("NoButton", BOOL, DEF_NOBUTTON_FLAG); param_set("LogX", BOOL, DEF_LOGX_FLAG); param_set("LogY", BOOL, DEF_LOGY_FLAG); /* logYFlag */ param_set("BarGraph", BOOL, DEF_BAR_FLAG); param_set("StackGraph", BOOL, DEF_STK_FLAG); param_set("FitX", BOOL, DEF_FITX_FLAG); param_set("FitY", BOOL, DEF_FITY_FLAG); param_set("BarBase", DBL, DEF_BAR_BASE); param_set("BarWidth", DBL, DEF_BAR_WIDTH); param_set("BarOffset", DBL, DEF_BAR_OFFS); param_set("LineWidth", INT, DEF_LINE_WIDTH); param_set("GridSize", INT, DEF_GRID_SIZE); param_set("GridStyle", STYLE, DEF_GRID_STYLE); param_set("Format X", STR, DEF_FMT_X); param_set("Format Y", STR, DEF_FMT_Y); param_set("Device", STR, DEF_DEVICE); param_set("Disposition", STR, DEF_DISPOSITION); param_set("FileOrDev", STR, DEF_FILEORDEV); sprintf(buf, "%d", o); param_set("Output Device", INT, buf); param_set("Document", BOOL, DEF_DOCUMENT); param_set("Scale", DBL, DEF_SCALE); /* Set the user bounding box */ param_set("XLowLimit", DBL, DEF_LOW_LIMIT); param_set("YLowLimit", DBL, DEF_LOW_LIMIT); param_set("XHighLimit", DBL, DEF_HIGH_LIMIT); param_set("YHighLimit", DBL, DEF_HIGH_LIMIT); /* Depends critically on whether the display has color */ if (depth < 4) { /* Its black and white */ param_set("Background", PIXEL, DEF_BW_BACKGROUND); param_set("Border", PIXEL, DEF_BW_BORDER); param_set("ZeroColor", PIXEL, DEF_BW_ZEROCOLOR); param_set("ZeroWidth", INT, DEF_BW_ZEROWIDTH); param_set("ZeroStyle", STYLE, DEF_BW_ZEROSTYLE); param_set("Foreground", PIXEL, DEF_BW_FOREGROUND); /* Initialize set defaults */ for (idx = 0; idx < MAXATTR; idx++) { (void) sprintf(buf, "%d.Style", idx); param_set(buf, STYLE, defStyle[idx]); (void) sprintf(buf, "%d.Color", idx); param_set(buf, PIXEL, DEF_BW_FOREGROUND); } } else { /* Its color */ param_set("Background", PIXEL, DEF_COL_BACKGROUND); param_set("Border", PIXEL, DEF_COL_BORDER); param_set("ZeroColor", PIXEL, DEF_COL_ZEROCOLOR); param_set("ZeroWidth", INT, DEF_COL_ZEROWIDTH); param_set("ZeroStyle", STYLE, DEF_COL_ZEROSTYLE); param_set("Foreground", PIXEL, DEF_COL_FOREGROUND); /* Initalize attribute colors defaults */ for (idx = 0; idx < MAXATTR; idx++) { (void) sprintf(buf, "%d.Style", idx); param_set(buf, STYLE, defStyle[idx]); (void) sprintf(buf, "%d.Color", idx); param_set(buf, PIXEL, defColors[idx]); } } param_set("LabelFont", FONT, DEF_LABEL_FONT); param_set("TitleFont", FONT, DEF_TITLE_FONT); /* PW */ param_set("Animate", BOOL, DEF_ANIMATE); param_set("DelayValue", INT, DEF_DELAY_VALUE); /* Initialize the data sets */ for (idx = 0; idx < MAXSETS; idx++) { (void) sprintf(buf, "Set %d", idx); PlotData[idx].setName = STRDUP(buf); PlotData[idx].list = (PointList *) 0; } } static char *def_str; #define DEF(name, type) \ if (def_str = XGetDefault(disp, Prog_Name, name)) { \ param_set(name, type, def_str); \ } void ReadDefaults() /* * Reads X default values which override the hard-coded defaults * set up by InitSets. */ { char newname[100]; int idx; DEF("Debug", BOOL); DEF("Geometry", STR); DEF("Background", PIXEL); DEF("BorderSize", INT); DEF("Border", PIXEL); DEF("GridSize", INT); DEF("GridStyle", STYLE); DEF("Foreground", PIXEL); DEF("ZeroColor", PIXEL); DEF("ZeroStyle", STYLE); DEF("ZeroWidth", INT); DEF("LabelFont", FONT); DEF("TitleFont", FONT); DEF("Ticks", BOOL); DEF("TickAxis", BOOL); DEF("Device", STR); DEF("Disposition", STR); DEF("FileOrDev", STR); DEF("PixelMarkers", BOOL); DEF("LargePixels", BOOL); DEF("Markers", BOOL); DEF("StyleMarkers", BOOL); DEF("BoundBox", BOOL); DEF("NoLines", BOOL); DEF("LineWidth", INT); /* PW */ DEF("Animate",BOOL); DEF("DelayValue",INT); /* End PW */ /* Read device specific parameters */ for (idx = 0; idx < hard_count; idx++) { sprintf(newname, "%s.Dimension", hard_devices[idx].dev_name); DEF(newname, DBL); /* hard_devices[idx].dev_max_dim */ sprintf(newname, "%s.OutputTitleFont", hard_devices[idx].dev_name); DEF(newname, STR); /* hard_devices[idx].dev_title_font */ sprintf(newname, "%s.OutputTitleSize", hard_devices[idx].dev_name); DEF(newname, DBL); /* hard_devices[idx].dev_title_size */ sprintf(newname, "%s.OutputAxisFont", hard_devices[idx].dev_name); DEF(newname, STR); /* hard_devices[idx].dev_axis_font */ sprintf(newname, "%s.OutputAxisSize", hard_devices[idx].dev_name); DEF(newname, DBL); /* hard_devices[idx].dev_axis_size */ } /* Read the default line and color attributes */ for (idx = 0; idx < MAXATTR; idx++) { (void) sprintf(newname, "%d.Style", idx); DEF(newname, STYLE); /* AllAttrs[idx].lineStyleLen */ (void) sprintf(newname, "%d.Color", idx); DEF(newname, PIXEL); /* AllAttrs[idx].pixelValue */ } DEF("ReverseVideo", BOOL); } #define FS(str) (void) fprintf(stderr, str) static void argerror(err, val) char *err, *val; { (void) fprintf(stderr, "Error: %s: %s\n\n", val, err); FS("Usage: xgraph [-device ]\n"); FS("\t[-bd border_color] [-bg background_color] [-fg foreground_color]\n"); FS("\t[-bar] [-brb bar_base] [-brw bar_width] [-bof bar_offset] [-stk]\n"); FS("\t[-bw bdr_width] [-db] [-gw grid_size] [-fitx] [-fity]\n"); FS("\t[-gs grid_style] [-lf label_font] [-lnx] [-lny] [-lw line_width]\n"); FS("\t[-lx x1,x2] [-ly y1,y2] [-m] [-M] [-nl] [-ng] [-nb] [-p] [-P]\n"); FS("\t[-rv] [-t title] [-tf title_font] [-tk] [-scale factor]\n"); FS("\t[-x x_unit_name] [-y y_unit_name] [-fmtx format] [-fmty format]\n"); FS("\t[[-geometry |=]W=H+X+Y] [[-display] :.]\n"); FS("\t[-Pprinter|-o output_file|-O output_file] [[- set_name]\n"); FS("\t[-zg zero_color] [-zw zero_size] [-a] [-dl ] input_files...\n\n"); FS("-bar Draw bar graph with base -brb, width -brw, and offset -bof\n"); FS("-stk Draw bar graph stacking data sets.\n"); FS("-fitx Scale all sets to fit the x-axis [0,1].\n"); FS("-fity Scale all sets to fit the y-axis [0,1].\n"); FS("-fmtx Printf format for the x-axis\n"); FS("-fmty Printf format for the y-axis\n"); FS("-scale Scale the output file with factor\n"); FS("-O fn Printer ready output file\n"); FS("-o fn Encapsulated (document) output file\n"); FS("-bb Draw bounding box around data\n"); FS("-db Turn on debugging\n"); FS("-lnx Logarithmic scale for X axis\n"); FS("-lny Logarithmic scale for Y axis\n"); FS("-m -M Mark points distinctively (M varies with color)\n"); FS("-nl Don't draw lines (scatter plot)\n"); FS("-ng Don't draw legend\n"); FS("-nb Don't draw buttons\n"); FS("-p -P Mark points with dot (P means big dot)\n"); FS("-rv Reverse video on black and white displays\n"); FS("-tk Draw tick marks instead of full grid\n"); FS("-a Start in animation mode\n"); FS("-dl Animation delay. Default is 2\n"); exit(1); } #define ARG(opt, name) \ if (strcmp(argv[idx], opt) == 0) { \ if (do_it) param_set(name, BOOL, "on"); \ idx++; continue; \ } #define ARG2(opt, name, type, missing) \ if (strcmp(argv[idx], opt) == 0) { \ if (idx+1 >= argc) argerror(missing, argv[idx]); \ if (do_it) param_set(name, type, argv[idx+1]); \ idx += 2; continue;\ } #define MAXLO 30 int ParseArgs(argc, argv, do_it) int argc; char *argv[]; int do_it; /* * This routine parses the argument list for xgraph. There are too * many to mention here so I won't. If `do_it' is non-zero, options * are actually changed. If `do_it' is zero, the argument list * is parsed but the options aren't set. The routine is called * once to obtain the input files then again after the data is * read to set the options. */ { int idx, set, dflag; char *hi; dflag = DEF_OUTPUT_DEVICE; idx = 1; while (idx < argc) { if (argv[idx][0] == '-') { /* Check to see if its a data set name */ if (sscanf(argv[idx], "-%d", &set) == 1) { /* The next string is a set name */ if (idx + 1 >= argc) argerror("missing set name", argv[idx]); if (do_it) { PlotData[set].setName = argv[idx + 1]; } idx += 2; } else { /* Some non-dataset option */ ARG2("-x", "XUnitText", STR, "missing axis name"); ARG2("-y", "YUnitText", STR, "missing axis name"); ARG2("-t", "TitleText", STR, "missing plot title"); ARG2("-fg", "Foreground", PIXEL, "missing color name"); ARG2("-bg", "Background", PIXEL, "missing color name"); ARG2("-bd", "Border", PIXEL, "missing color name"); ARG2("-bw", "BorderSize", INT, "missing border size"); ARG2("-zg", "ZeroColor", PIXEL, "missing color name"); ARG2("-zw", "ZeroWidth", INT, "missing width"); ARG2("-tf", "TitleFont", FONT, "missing font name"); ARG2("-lf", "LabelFont", FONT, "missing font name"); /* PW */ ARG2("-dl", "DelayValue", INT, "missing delay value"); /* Doesn't make much sense to PW why this must be switched, but it must. */ ARG2("-digy", "Format X", STR, "Missing C-String"); ARG2("-digx", "Format Y", STR, "Missing C-String"); ARG("-a", "Animate"); /* End PW */ ARG("-rv", "ReverseVideo"); ARG("-tk", "Ticks"); ARG("-tkax", "TickAxis"); ARG("-bb", "BoundBox"); if (strcmp(argv[idx], "-lx") == 0) { /* Limit the X coordinates */ if (idx + 1 >= argc) argerror("missing coordinate(s)", argv[idx]); if (hi = index(argv[idx + 1], ',')) { char low[MAXLO]; (void) strncpy(low, argv[idx + 1], hi - argv[idx + 1]); low[hi - argv[idx + 1]] = '\0'; hi++; if (do_it) { param_set("XLowLimit", DBL, argv[idx + 1]); param_set("XHighLimit", DBL, hi); } } else { argerror("limit coordinates not specified right", argv[idx]); } idx += 2; continue; } if (strcmp(argv[idx], "-ly") == 0) { /* Limit the Y coordinates */ if (idx + 1 >= argc) argerror("missing coordinate(s)", argv[idx]); if (hi = index(argv[idx + 1], ',')) { char low[MAXLO]; (void) strncpy(low, argv[idx + 1], hi - argv[idx + 1]); low[hi - argv[idx + 1]] = '\0'; hi++; if (do_it) { param_set("YLowLimit", DBL, argv[idx + 1]); param_set("YHighLimit", DBL, hi); } } else { argerror("limit coordinates not specified right", argv[idx]); } idx += 2; continue; } ARG2("-lw", "LineWidth", INT, "missing line width"); ARG("-nl", "NoLines"); ARG("-ng", "NoLegend"); ARG("-nb", "NoButton"); ARG("-m", "Markers"); ARG("-M", "StyleMarkers"); ARG("-p", "PixelMarkers"); ARG("-P", "LargePixels"); ARG("-lnx", "LogX"); ARG("-lny", "LogY"); ARG("-bar", "BarGraph"); ARG("-stk", "StackGraph"); ARG("-fitx", "FitX"); ARG("-fity", "FitY"); ARG2("-brw", "BarWidth", DBL, "missing width"); ARG2("-bof", "BarOffset", DBL, "missing offset"); ARG2("-brb", "BarBase", DBL, "missing base"); ARG("-db", "Debug"); ARG2("-gw", "GridSize", INT, "missing grid size"); ARG2("-gs", "GridStyle", STYLE, "missing grid style"); if (strcmp(argv[idx], "-display") == 0) { /* Harmless display specification */ dflag = D_XWINDOWS; disp_name = argv[idx+1]; idx += 2; continue; } if (strcmp(argv[idx], "-geometry") == 0) { if (do_it) param_set("Geometry", STR, argv[idx + 1]); idx += 2; continue; } if (strcmp(argv[idx], "-device") == 0) { if (idx + 1 >= argc) argerror("missing device", argv[idx]); if (strcmp(argv[++idx], "hpgl") == 0) dflag = D_HPGL; else if (strcmp(argv[idx], "idraw") == 0) dflag = D_IDRAW; else if (strcmp(argv[idx], "x") == 0) dflag = D_XWINDOWS; else if (strcmp(argv[idx], "ps") == 0) dflag = D_POSTSCRIPT; else if (strcmp(argv[idx], "tgif") == 0) dflag = D_TGIF; else argerror("bad device specification", argv[idx]); idx++; continue; } if (strncmp(argv[idx], "-P", 2) == 0) { /* Printer spec */ if (do_it) param_set("Disposition", STR, "To Device"); if (do_it) param_set("FileOrDev", STR, &(argv[idx][2])); idx++; continue; } if (strcmp(argv[idx], "-o") == 0) { if (do_it) param_set("Disposition", STR, "To File"); if (idx + 1 >= argc) argerror("missing file", argv[idx]); if (do_it) param_set("FileOrDev", STR, argv[idx + 1]); idx += 2; continue; } if (strcmp(argv[idx], "-O") == 0) { if (do_it) param_set("Disposition", STR, "To File"); if (do_it) param_set("Document", BOOL, "on"); if (idx + 1 >= argc) argerror("missing file", argv[idx]); if (do_it) param_set("FileOrDev", STR, argv[idx + 1]); idx += 2; continue; } if (strcmp(argv[idx], "-fmtx") == 0) { if (idx + 1 >= argc) argerror("missing x format", argv[idx]); if (do_it) param_set("Format Y", STR, argv[idx + 1]); idx += 2; continue; } if (strcmp(argv[idx], "-fmty") == 0) { if (idx + 1 >= argc) argerror("missing y format", argv[idx]); if (do_it) param_set("Format X", STR, argv[idx + 1]); idx += 2; continue; } if (strcmp(argv[idx], "-scale") == 0) { if (idx + 1 >= argc) argerror("scale factor", argv[idx]); if (do_it) param_set("Scale", DBL, argv[idx + 1]); idx += 2; continue; } argerror("unknown option", argv[idx]); } } else if (argv[idx][0] == '=') { /* Its a geometry specification */ if (do_it) param_set("Geometry", STR, argv[idx] + 1); idx++; } else { /* It might be the host:display string */ if (rindex(argv[idx], ':') == (char *) 0) { /* Should be an input file */ inFileNames[numFiles] = argv[idx]; numFiles++; } idx++; } } return (dflag); } xgraph-12.1.orig/install-sh0100775000175000000620000001273607360237500014331 0ustar bapstaff#!/bin/sh # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: chmodcmd="" else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 xgraph-12.1.orig/missing0100775000175000000620000001421307360237500013714 0ustar bapstaff#! /bin/sh # Common stub for a few missing GNU programs while installing. # Copyright (C) 1996, 1997 Free Software Foundation, Inc. # Franc,ois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi case "$1" in -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file yacc create \`y.tab.[ch]', if possible, from existing .[ch]" ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing - GNU libit 0.0" ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; aclocal) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acinclude.m4' or \`configure.in'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`configure.in'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acconfig.h' or \`configure.in'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.in` test -z "$files" && files="config.h" touch_files= for f in $files; do case "$f" in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; bison|yacc) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.h fi ;; esac fi if [ ! -f y.tab.h ]; then echo >y.tab.h fi if [ ! -f y.tab.c ]; then echo 'main() { return 0; }' >y.tab.c fi ;; lex|flex) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if [ ! -f lex.yy.c ]; then echo 'main() { return 0; }' >lex.yy.c fi ;; makeinfo) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` fi touch $file ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and you do not seem to have it handy on your system. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequirements for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 xgraph-12.1.orig/mkinstalldirs0100775000175000000620000000132607360237500015124 0ustar bapstaff#! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman # Created: 1993-05-16 # Public domain # $Id: mkinstalldirs,v 1.1 1999/12/06 05:01:44 heideman Exp $ errstatus=0 for file do set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` shift pathcomp= for d do pathcomp="$pathcomp$d" case "$pathcomp" in -* ) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr fi fi pathcomp="$pathcomp/" done done exit $errstatus # mkinstalldirs ends here xgraph-12.1.orig/params.c0100664000175000000620000003054007360237507013754 0ustar bapstaff/* $Header: /usr/src/mash/repository/vint/xgraph/params.c,v 1.2 1999/12/08 19:32:41 heideman Exp $ */ /* * Xgraph Parameters * * This file contains routines for setting and retrieving * various X style display parameters for xgraph. * * $Log: params.c,v $ * Revision 1.2 1999/12/08 19:32:41 heideman * strcasecmp portability fix * * Revision 1.1.1.1 1999/12/03 23:15:52 heideman * xgraph-12.0 * */ #ifndef lint static char rcsid[] = "$Id: params.c,v 1.2 1999/12/08 19:32:41 heideman Exp $"; #endif #include #include #include "st.h" #include "params.h" #include "hard_devices.h" #include "xgraph.h" /* for string.h */ /* For use by convenience macros */ params param_temp, *param_temp_ptr; XColor param_null_color = {0, 0, 0, 0, 0, 0}; param_style param_null_style = {STYLE, 0, (char *) 0}; static st_table *param_table = (st_table *) 0; typedef struct param_full_defn { param_types type; char *text_form; params *real_form; } param_full; #define ISO_FONT "*-*-%s-medium-r-normal-*-*-%d-*-*-*-*-iso8859-*" static Display *param_disp; static Colormap param_cmap; static int param_scrn; static void free_resource(); static params *resolve_entry(); static int strihash(); static int do_color(); static int do_font(); static int do_style(); static int do_bool(); #define DEF_INT "0" #define DEF_STR "" #define DEF_FONT "fixed" #define DEF_PIXEL "black" #define DEF_STYLE "1" #define DEF_BOOL "false" #define DEF_DBL "0.0" #define DEF_MAX_FONT 1024 #define DEF_MAX_NAMES 10 #define DUP(str) \ strcpy((char *) Malloc((unsigned) (strlen(str)+1)), (str)) void param_init(disp, cmap) Display *disp; /* X Connection */ Colormap cmap; /* Colormap for colors */ /* * Initializes parameter package. The display and colormap arguments * are used to resolve font and pixel values. */ { param_table = st_init_table(stricmp, strihash); if (disp != NULL) { param_disp = disp; param_cmap = cmap; /* This could also be a parameter for greater generality */ param_scrn = DefaultScreen(disp); } } void param_set(name, type, val) char *name; /* Name of parameter */ param_types type; /* Type */ char *val; /* Text form for value */ /* * Sets the parameter with the given name to have the type * `type' and the text value `value'. This will be evaluated * to its full form the first time it is referenced using * param_get(). If it is already filled, the old value * will be reclaimed. */ { param_full *entry; if (!param_table) { (void) fprintf(stderr, "Parameter table not initialized\n"); return; } if (st_lookup(param_table, name, (char **) &entry)) { if (entry->real_form) free_resource(entry->real_form); entry->real_form = (params *) 0; } else { entry = (param_full *) Malloc(sizeof(param_full)); entry->text_form = (char *) 0; entry->real_form = (params *) 0; (void) st_insert(param_table, DUP(name), (char *) entry); } entry->type = type; if (entry->text_form) (void) Free((char *) (entry->text_form)); entry->text_form = DUP(val); } void param_reset(name, val) char *name; /* Name of parameter */ char *val; /* Text form for value */ /* * This routine sets the value of an existing parameter to a new * value. The type of the parameter remains the same. Changes * in type should be done by using param_set() directly. */ { param_full *entry; if (!param_table) { (void) fprintf(stderr, "Parameter table not initialized\n"); return; } if (st_lookup(param_table, name, (char **) &entry)) param_set(name, entry->type, val); else (void) fprintf(stderr, "Cannot reset unknown parameter `%s'\n", name); } params * param_get(name, val) char *name; /* Name of parameter */ params *val; /* Result value */ /* * Retrieves a value from the parameter table. The value * is placed in `val'. If successful, the routine will * return `val'. Otherwise, it will return zero. */ { param_full *entry; if (!param_table) { (void) fprintf(stderr, "Parameter table not initialized\n"); return (params *) 0; } if (st_lookup(param_table, name, (char **) &entry)) { if (!entry->real_form) entry->real_form = resolve_entry(name, entry->type, entry->text_form); *val = *(entry->real_form); return val; } else { return (params *) 0; } } static void free_resource(val) params *val; /* Value to free */ /* * Reclaims a resource based on its type. */ { switch (val->type) { case INT: case STR: case BOOL: case DBL: /* No reclaimation necessary */ break; case PIXEL: if ((val->pixv.value.pixel != WhitePixel(param_disp, param_scrn)) && (val->pixv.value.pixel != BlackPixel(param_disp, param_scrn))) XFreeColors(param_disp, param_cmap, &(val->pixv.value.pixel), 1, 0); break; case FONT: XFreeFont(param_disp, val->fontv.value); break; case STYLE: (void) Free(val->stylev.dash_list); break; } (void) Free((char *) val); } static params * resolve_entry(name, type, form) char *name; /* Name of item for errors */ param_types type; /* What type of thing */ char *form; /* Textual form */ /* * Allocates and returns an appropriate parameter structure * by translating `form' into its native type as given by `type'. * If it can't translate the given form, it will fall back onto * the default. */ { static char paramstr[] = "Parameter %s: can't translate `%s' into a %s (defaulting to `%s')\n"; params *result = (params *) Malloc(sizeof(params)); result->type = type; switch (type) { case INT: if (sscanf(form, "%d", &result->intv.value) != 1) { (void) fprintf(stderr, paramstr, name, form, "integer", DEF_INT); result->intv.value = atoi(DEF_INT); } break; case STR: result->strv.value = form; break; case PIXEL: if (!do_color(form, &result->pixv.value)) { (void) fprintf(stderr, paramstr, name, form, "color", DEF_PIXEL); (void) do_color(DEF_PIXEL, &result->pixv.value); } break; case FONT: if (!do_font(form, &result->fontv.value)) { (void) fprintf(stderr, paramstr, name, form, "font", DEF_FONT); (void) do_font(DEF_FONT, &result->fontv.value); } break; case STYLE: if (!do_style(form, &result->stylev)) { (void) fprintf(stderr, paramstr, name, form, "line style", DEF_STYLE); (void) do_style(DEF_STYLE, &result->stylev); } break; case BOOL: if (!do_bool(form, &result->boolv.value)) { (void) fprintf(stderr, paramstr, name, form, "boolean flag", DEF_BOOL); (void) do_bool(DEF_BOOL, &result->boolv.value); } break; case DBL: if (sscanf(form, "%lf", &result->dblv.value) != 1) { (void) fprintf(stderr, paramstr, name, form, "double", DEF_DBL); result->dblv.value = atof(DEF_DBL); } break; } return result; } static int do_color(name, color) char *name; /* Name for color */ XColor *color; /* Returned color */ /* * Translates `name' into a color and attempts to get the pixel * for the color using XAllocColor(). */ { int result = 1; if (PM_INT("Output Device") == D_XWINDOWS) { if (XParseColor(param_disp, param_cmap, name, color)) { if (stricmp(name, "black") == 0) { color->pixel = BlackPixel(param_disp, param_scrn); XQueryColor(param_disp, param_cmap, color); } else if (stricmp(name, "white") == 0) { color->pixel = WhitePixel(param_disp, param_scrn); XQueryColor(param_disp, param_cmap, color); } else result = XAllocColor(param_disp, param_cmap, color); } else result = 0; } return result; } static int do_font(name, font_info) char *name; /* Name of desired font */ XFontStruct **font_info; /* Returned font information */ /* * This routine translates a font name into a font structure. The * font name can be in two forms. The first form is -. * The family is a family name (like helvetica) and the size is * in points (like 12). If the font is not in this form, it * is assumed to be a regular X font name specification and * is looked up using the standard means. */ { char name_copy[DEF_MAX_FONT], query_spec[DEF_MAX_FONT]; char *font_family, *font_size, **font_list; int font_size_value, font_count, i; /* First attempt to interpret as font family/size */ if (PM_INT("Output Device") == D_XWINDOWS) { (void) strcpy(name_copy, name); if (font_size = index(name_copy, '-')) { *font_size = '\0'; font_family = name_copy; font_size++; font_size_value = atoi(font_size); if (font_size_value > 0) { /* * Still a little iffy -- what about weight and roman vs. other */ (void) sprintf(query_spec, ISO_FONT, font_family, font_size_value * 10); font_list = XListFonts(param_disp, query_spec, DEF_MAX_NAMES, &font_count); /* Load first one that you can */ for (i = 0; i < font_count; i++) if (*font_info = XLoadQueryFont(param_disp, font_list[i])) break; if (*font_info) return 1; } } /* Assume normal font name */ return (int) (*font_info = XLoadQueryFont(param_disp, name)); } } static int do_style(list, val) char *list; /* List of ones and zeros */ param_style *val; /* Line style returned */ /* * Translates a string representation of a dash specification into * a form suitable for use in XSetDashes(). Assumes `list' * is a null terminated string of ones and zeros. */ { char *i, *spot, last_char; int count; for (i = list; *i; i++) if ((*i != '0') && (*i != '1')) break; if (!*i) { val->len = 0; last_char = '\0'; for (i = list; *i; i++) { if (*i != last_char) { val->len += 1; last_char = *i; } } val->dash_list = (char *) Malloc((unsigned) (sizeof(char) * val->len + 1)); last_char = *list; spot = val->dash_list; count = 0; for (i = list; *i; i++) { if (*i != last_char) { *spot++ = (char) count; last_char = *i; count = 1; } else count++; } *spot = (char) count; return 1; } else { return 0; } } static char *positive[] = {"on", "yes", "true", "1", "affirmative", (char *) 0}; static char *negative[] = {"off", "no", "false", "0", "negative", (char *) 0}; static int do_bool(name, val) char *name; /* String representation */ int *val; /* Returned value */ /* * Translates a string representation into a suitable binary value. * Can parse all kinds of interesting boolean type words. */ { char **term; for (term = positive; *term; term++) { if (stricmp(name, *term) == 0) break; } if (*term) { *val = 1; return 1; } for (term = negative; *term; term++) if (stricmp(name, *term) == 0) break; if (*term) { *val = 0; return 1; } return 0; } /*ARGSUSED*/ static enum st_retval dump_it(key, value, arg) char *key, *value, *arg; { param_full *val = (param_full *) value; (void) fprintf(stdout, "%s (", key); switch (val->type) { case INT: (void) fprintf(stdout, "INT"); break; case STR: (void) fprintf(stdout, "STR"); break; case PIXEL: (void) fprintf(stdout, "PIXEL"); break; case FONT: (void) fprintf(stdout, "FONT"); break; case STYLE: (void) fprintf(stdout, "STYLE"); break; case BOOL: (void) fprintf(stdout, "BOOL"); break; case DBL: (void) fprintf(stdout, "DBL"); break; } (void) fprintf(stdout, ") = %s\n", val->text_form); return ST_CONTINUE; } void param_dump() /* * Dumps all of the parameter values to standard output. */ { st_foreach(param_table, dump_it, (char *) 0); } #ifdef HAVE_STRCASECMP int stricmp(a, b) char *a, *b; { return strcasecmp(a, b); } #else int stricmp(a, b) register char *a, *b; /* * This routine compares two strings disregarding case. */ { register int value; if ((a == (char *) 0) || (b == (char *) 0)) { return a - b; } for ( /* nothing */ ; ((*a | *b) && !(value = ((isupper(*a) ? *a - 'A' + 'a' : *a) - (isupper(*b) ? *b - 'A' + 'a' : *b)))); a++, b++) /* Empty Body */ ; return value; } #endif static int strihash(string, modulus) register char *string; int modulus; /* Case insensitive computation */ { register int val = 0; register int c; while ((c = *string++) != '\0') { if (isupper(c)) c = tolower(c); val = val * 997 + c; } return ((val < 0) ? -val : val) % modulus; } xgraph-12.1.orig/params.h0100664000175000000620000000577307360237511013766 0ustar bapstaff/* * Xgraph parameters */ #ifndef _PARAMS_H_ #define _PARAMS_H_ #include "xgraph.h" /* If you have an ANSI compiler, some checking will be done */ #ifdef __STDC__ #define DECLARE(func, rtn, args) extern rtn func args #else #define DECLARE(func, rtn, args) extern rtn func () #endif typedef enum param_types_defn { INT, STR, PIXEL, FONT, STYLE, BOOL, DBL } param_types; typedef struct params_int_defn { param_types type; /* INT */ int value; } param_int; typedef struct params_str_defn { param_types type; /* STR */ char *value; } param_str; typedef struct params_pix_defn { param_types type; /* PIXEL */ XColor value; } param_pix; typedef struct params_font_defn { param_types type; /* FONT */ XFontStruct *value; } param_font; typedef struct params_style_defn { param_types type; /* STYLE */ int len; char *dash_list; } param_style; typedef struct params_bool_defn { param_types type; /* BOOL */ int value; } param_bool; typedef struct params_dbl_defn { param_types type; /* DBL */ double value; } param_dbl; typedef union params_defn { param_types type; param_int intv; /* INT */ param_str strv; /* STR */ param_pix pixv; /* PIXEL */ param_font fontv; /* FONT */ param_style stylev; /* STYLE */ param_bool boolv; /* BOOL */ param_dbl dblv; /* DBL */ } params; DECLARE(param_init, void, (Display * disp, Colormap cmap)); DECLARE(param_set, void, (char *name, param_types type, char *val)); DECLARE(param_reset, void, (char *name, char *val)); DECLARE(param_get, params *, (char *name, params * val)); DECLARE(param_dump, void, ()); #ifdef stricmp #undef stricmp #endif DECLARE(stricmp, int, (char *a, char *b)); /* Some convenience macros */ extern params param_temp, *param_temp_ptr; extern XColor param_null_color; extern param_style param_null_style; #define PM_INT(name) \ ((param_temp_ptr = param_get(name, ¶m_temp)) ? \ param_temp_ptr->intv.value : \ (abort(), (int) 0)) #define PM_STR(name) \ ((param_temp_ptr = param_get(name, ¶m_temp)) ? \ param_temp_ptr->strv.value : \ (abort(), (char *) 0)) #define PM_COLOR(name) \ ((param_temp_ptr = param_get(name, ¶m_temp)) ? \ param_temp_ptr->pixv.value : \ (abort(), param_null_color)) #define PM_PIXEL(name) \ ((param_temp_ptr = param_get(name, ¶m_temp)) ? \ param_temp_ptr->pixv.value.pixel : \ (abort(), (Pixel) 0)) #define PM_FONT(name) \ ((param_temp_ptr = param_get(name, ¶m_temp)) ? \ param_temp_ptr->fontv.value : \ (abort(), (XFontStruct *) 0)) #define PM_STYLE(name) \ ((param_temp_ptr = param_get(name, ¶m_temp)) ? \ param_temp_ptr->stylev : \ (abort(), param_null_style)) #define PM_BOOL(name) \ ((param_temp_ptr = param_get(name, ¶m_temp)) ? \ param_temp_ptr->boolv.value : \ (abort(), 0)) #define PM_DBL(name) \ ((param_temp_ptr = param_get(name, ¶m_temp)) ? \ param_temp_ptr->dblv.value : \ (abort(), 0.0)) #endif /* _PARAMS_H_ */ xgraph-12.1.orig/plotter.h0100775000175000000620000000272507360237511014171 0ustar bapstaff#ifndef _h_plotter #define _h_plotter /* * HP plotter definition - these are dependent on the SPECIFIC MODEL of HP * plotter used, and should always be modified when going to a new * plotter. * * all dimensions are in plotter units. * * MINX and MINY are the smallest x and y values that are inside the soft * clip limits of the plotter MAXX and MAXY are the largest x and y values * that are inside the soft clip limits of the plotter MINUS MINX and * MINY, so they give the dimension of the soft clip area. * * PLOTTERTYPE is a character string which identifies the plotter that should * be used. control information will be read for * ~cad/lib/technology/$TECHNOLOGY/$PLOTTERTYPE.map and output will go to * /usr/ucb/lpr -Pplt$PLOTTERTYPE * */ #define PLOTTERTYPE "7550" #define P1X 80 #define P1Y 320 #define P2X 10080 #define P2Y 7520 #define MAXX 10000 #define MAXY 7200 #define PLOTTERNAME "paper" #define PENGRID 1 #define PENAXIS 2 #define TEXTCOLOR 1 #define PEN1 3 #define PEN2 4 #define PEN3 5 #define PEN4 6 #define PEN5 7 #define PEN6 8 #define PEN7 2 #define PEN8 1 #define LINE1 2 #define LINE2 4 #define LINE3 5 #define LINE4 6 #define LINE5 2 #define LINE6 4 #define LINE7 5 #define LINE8 6 #define MARK1 "L" #define MARK2 "K" #define MARK3 "M" #define MARK4 "O" #define MARK5 "G" #define MARK6 "F" #define MARK7 "E" #define MARK8 "A" #endif /* _h_plotter */ xgraph-12.1.orig/ps.c0100664000175000000620000004144107360237504013112 0ustar bapstaff/* * Postscript output for xgraph * * Rick Spickelmier * David Harrison */ #include "copyright.h" #include #include "xgraph.h" /* * Basic scaling parameters */ #define VDPI 1200.0 #define LDIM 11.0 #define SDIM 8.5 #define MICRONS_PER_INCH 2.54E+04 #define POINTS_PER_INCH 72.0 #define INCHES_PER_POINT 1.0/72.0 /* * Aesthetic parameters (inches) */ #define PS_BDR_PAD 0.075 #define PS_AXIS_PAD 0.1 #define PS_LEG_PAD 0.025 #define PS_TICK_LEN 0.125 #define BASE_DASH (1.0/48.0) #define BASE_WIDTH (1.0/8.0) #define PS_AXIS_WBASE 1 #define PS_ZERO_WBASE 4 #define PS_DATA_WBASE 7 #define PS_PIXEL 4 #define PS_DOT 12 #define PS_MARK 12 /* * Other constants */ #define FONT_WIDTH_EST 0.55 #define PS_MAX_SEGS 1000 #define PS_NO_TSTYLE -1 #define PS_NO_DSTYLE -1 #define PS_NO_WIDTH -1 #define PS_NO_LSTYLE -1 #define PS_NO_COLOR -1 /* * Working macros */ #define OUT (void) fprintf #define PS(str) OUT(psFile, str) #define PSU(str) OUT(ui->psFile, str) #define IY(val) (ui->height_devs - val) #define TEXTCOLOR 0 #define MAXCOLOR 8 /* Number of gray scales supported */ /* * Globals */ static double PS_scale; /* devs/micron */ /* * Externals and forwards */ static void psScale(), psFonts(), psMarks(), psText(), psSeg(), psDot(), psEnd(); /* * Local structures */ struct userInfo { FILE *psFile; int currentTextStyle; int currentDashStyle; int currentWidth; int currentLStyle; int currentColor; int baseWidth; int height_devs; char *title_family; double title_size; char *axis_family; double axis_size; int flags; }; int rd(dbl) double dbl; /* Short and sweet rounding function */ { if (dbl < 0.0) { return ((int) (dbl - 0.5)); } else { return ((int) (dbl + 0.5)); } } /*ARGSUSED*/ int psInit(psFile, width, height, tf, ts, af, as, flags, outInfo, errmsg) FILE *psFile; /* Output file */ int width, height; /* In microns */ char *tf, *af; /* Title and axis font */ double ts, as; /* Title and axis size */ int flags; /* Predicate flags */ xgOut *outInfo; /* Returned device info */ char errmsg[ERRBUFSIZE]; /* Returned error message */ /* * The basic coordinate system is points (roughly 1/72 inch). * However, most laser printers can do much better than that. * We invent a coordinate system based on VDPI dots per inch. * This goes along the long side of the page. The long side * of the page is LDIM inches in length, the short side * SDIM inches in length. We we call this unit a `dev'. * We map `width' and `height' into devs. */ { struct userInfo *ui; double font_size; ui = (struct userInfo *) Malloc(sizeof(struct userInfo)); ui->psFile = psFile; ui->currentTextStyle = PS_NO_TSTYLE; ui->currentDashStyle = PS_NO_DSTYLE; ui->currentWidth = PS_NO_WIDTH; ui->currentLStyle = PS_NO_LSTYLE; ui->currentColor = PS_NO_COLOR; ui->title_family = tf; ui->title_size = ts; ui->axis_family = af; ui->axis_size = as; /* Roughly, one-eighth a point in devs */ ui->baseWidth = rd(VDPI / POINTS_PER_INCH * BASE_WIDTH); ui->flags = flags; PS_scale = VDPI / MICRONS_PER_INCH; outInfo->dev_flags = 0; outInfo->area_w = rd(((double) width) * PS_scale); outInfo->area_h = rd(((double) height) * PS_scale); ui->height_devs = outInfo->area_h; outInfo->bdr_pad = rd(PS_BDR_PAD * VDPI); outInfo->axis_pad = rd(PS_AXIS_PAD * VDPI); outInfo->legend_pad = rd(PS_LEG_PAD * VDPI); outInfo->tick_len = rd(PS_TICK_LEN * VDPI); /* Font estimates */ font_size = as * INCHES_PER_POINT * VDPI; outInfo->axis_height = rd(font_size); outInfo->axis_width = rd(font_size * FONT_WIDTH_EST); font_size = ts * INCHES_PER_POINT * VDPI; outInfo->title_height = rd(font_size); outInfo->title_width = rd(font_size * FONT_WIDTH_EST); outInfo->max_segs = PS_MAX_SEGS; outInfo->xg_text = psText; outInfo->xg_seg = psSeg; outInfo->xg_dot = psDot; outInfo->xg_end = psEnd; outInfo->user_state = (char *) ui; /* Postscript file identification */ PS("%%!\n"); /* Definitions */ psScale(psFile, width, height, flags); psFonts(psFile); psMarks(psFile); PS("%%\n%% Main body begins here\n%%\n"); return 1; } static void psHeader(psFile, docu_flag) FILE *psFile; int docu_flag; /* * Prints out a standard greeting to the Postscript file. */ { PS("%%%%EndComments\n"); PS("%%\n"); PS("%% Xgraph postscript output\n"); PS("%% Rick Spickelmier and David Harrison\n"); PS("%% University of California, Berkeley\n"); if (docu_flag) { PS("%%\n"); PS("%% Output produced for inclusion in another document.\n"); PS("%% This file will not work properly if sent directly to a printer.\n"); } PS("%%\n"); } static void psScale(psFile, width, height, flags) FILE *psFile; /* Output stream */ int width; /* Output width */ int height; /* Output height */ int flags; /* Output options */ /* * This routine figures out how transform the basic postscript * transformation into one suitable for direct use by * the drawing primitives. Two variables X-CENTER-PLOT * and Y-CENTER-PLOT determine whether the plot is centered * on the page. If `flags' has D_DOCU set, then the plot * will not be rotated or centered and a bounding box will * be displayed. */ { double factor; double pnt_width, pnt_height; if (flags & D_DOCU) { OUT(psFile, "%%%%BoundingBox: %ld %ld %ld %ld\n", 0, 0, (int) (((double) width) / (MICRONS_PER_INCH * INCHES_PER_POINT) + 0.5), (int) (((double) height) / (MICRONS_PER_INCH * INCHES_PER_POINT) + 0.5) ); psHeader(psFile, 1); PS("%% Rotation and centering are turned off for inclusion in a document\n"); } else { psHeader(psFile, 0); PS("%% Scaling information\n"); PS("%%\n"); PS("%% Change these if you would like to change the centering\n"); PS("%% of the plot in either dimension\n"); PS("/X-CENTER-PLOT 1 def\n"); PS("/Y-CENTER-PLOT 1 def\n"); PS("%%\n"); /* * Determine page size */ PS("%% Page size computation\n"); PS("clippath pathbbox\n"); PS("/page-height exch def\n"); PS("/page-width exch def\n"); PS("pop pop\n"); /* * First: rotation. If the width is greater than the short dimension, * do the rotation. */ pnt_width = ((double) width) / MICRONS_PER_INCH * POINTS_PER_INCH; pnt_height = ((double) height) / MICRONS_PER_INCH * POINTS_PER_INCH; PS("%% Determine whether rotation is required\n"); OUT(psFile, "%lg page-width gt\n", pnt_width); PS("{ %% Rotation required\n"); PS(" 90 rotate\n"); PS(" 0 page-width neg translate\n"); PS(" %% Handle centering\n"); PS(" Y-CENTER-PLOT 1 eq { %% Center in y\n"); OUT(psFile, " page-height %lg sub 2 div\n", pnt_width); PS(" } { %% Don't center in y\n"); PS(" 0\n"); PS(" } ifelse\n"); PS(" X-CENTER-PLOT 1 eq { %% Center in x\n"); OUT(psFile, " page-width %lg sub 2 div\n", pnt_height); PS(" } { %% Don't center in x\n"); PS(" 0\n"); PS(" } ifelse\n"); PS(" translate\n"); PS("} { %% No rotation - just handle centering\n"); PS(" X-CENTER-PLOT 1 eq { %% Center in x\n"); OUT(psFile, " page-width %lg sub 2 div\n", pnt_width); PS(" } { %% Don't center in x\n"); PS(" 0\n"); PS(" } ifelse\n"); PS(" Y-CENTER-PLOT 1 eq { %% Center in y\n"); OUT(psFile, " page-height %lg sub 2 div\n", pnt_height); PS(" } { %% Don't center in y\n"); PS(" 0\n"); PS(" } ifelse\n"); PS(" translate\n"); PS("} ifelse\n"); } /* * Now: scaling. We have points. We want devs. */ factor = POINTS_PER_INCH / VDPI; PS("%% Set the scale\n"); OUT(psFile, "%lg %lg scale\n", factor, factor); } static void psFonts(psFile) FILE *psFile; /* Output stream */ /* * Downloads code for drawing title and axis labels */ { PS("%% Font Handling Functions\n"); PS("%%\n"); PS("%% Function giving y-offset to center of font\n"); PS("%% Assumes font is set and uses numbers to gauge center\n"); PS("%%\n"); PS("/choose-font %% stack: fontsize fontname => ---\n"); PS("{\n"); PS(" findfont \n"); PS(" exch scalefont \n"); PS(" setfont\n"); PS(" newpath\n"); PS(" 0 0 moveto (0) true charpath flattenpath pathbbox\n"); PS(" /top exch def pop\n"); PS(" /bottom exch def pop\n"); PS(" bottom top bottom top add 2 div\n"); PS(" /center-font-val exch def \n"); PS(" /upper-font-val exch def \n"); PS(" /lower-font-val exch def\n"); PS("} def\n"); PS("%%\n"); PS("%% Justfication offset routines\n"); PS("%%\n"); PS("/center-x-just %% stack: (string) x y => (string) newx y\n"); PS("{\n"); PS(" exch 2 index stringwidth pop 2 div sub exch\n"); PS("} def\n"); PS("%%\n"); PS("/left-x-just %% stack: (string) x y => (string) newx y\n"); PS("{ \n"); PS("} def\n"); PS("%%\n"); PS("/right-x-just %% stack: (string) x y => (string) newx y\n"); PS("{\n"); PS(" exch 2 index stringwidth pop sub exch\n"); PS("} def\n"); PS("%%\n"); PS("/center-y-just %% stack: (string) x y => (string) x newy\n"); PS("{\n"); PS(" center-font-val sub\n"); PS("} def\n"); PS("%%\n"); PS("/lower-y-just %% stack: (string) x y => (string) x newy\n"); PS("{\n"); PS(" lower-font-val sub\n"); PS("} def\n"); PS("%%\n"); PS("/upper-y-just %% stack: (string) x y => (string) x newy\n"); PS("{\n"); PS(" upper-font-val sub\n"); PS("} def\n"); PS("%%\n"); PS("%% Shows a string on the page subject to justification\n"); PS("%% \n"); PS("/just-string %% stack: (string) x y just => ---\n"); PS("{\n"); PS(" dup 0 eq { pop center-x-just center-y-just } if\n"); PS(" dup 1 eq { pop left-x-just center-y-just } if\n"); PS(" dup 2 eq { pop left-x-just upper-y-just } if\n"); PS(" dup 3 eq { pop center-x-just upper-y-just } if\n"); PS(" dup 4 eq { pop right-x-just upper-y-just } if\n"); PS(" dup 5 eq { pop right-x-just center-y-just } if\n"); PS(" dup 6 eq { pop right-x-just lower-y-just } if\n"); PS(" dup 7 eq { pop center-x-just lower-y-just } if\n"); PS(" dup 8 eq { pop left-x-just lower-y-just } if\n"); PS(" moveto show\n"); PS("} def\n"); PS("%%\n"); } static void psMarks(psFile) FILE *psFile; /* * Writes out marker definitions */ { PS("%% Marker definitions\n"); PS("/mark0 {/size exch def /y exch def /x exch def\n"); PS("newpath x size sub y size sub moveto\n"); PS("size size add 0 rlineto 0 size size add rlineto\n"); PS("0 size size add sub 0 rlineto closepath fill} def\n"); PS("/mark1 {/size exch def /y exch def /x exch def\n"); PS("newpath x size sub y size sub moveto\n"); PS("size size add 0 rlineto 0 size size add rlineto\n"); PS("0 size size add sub 0 rlineto closepath stroke} def\n"); PS("/mark2 {/size exch def /y exch def /x exch def\n"); PS("newpath x y moveto x y size 0 360 arc stroke} def\n"); PS("/mark3 {/size exch def /y exch def /x exch def\n"); PS("newpath x size sub y size sub moveto x size add y size add lineto\n"); PS("x size sub y size add moveto x size add y size sub lineto stroke} def\n"); PS("/mark4 {/size exch def /y exch def /x exch def\n"); PS("newpath x size sub y moveto x y size add lineto\n"); PS("x size add y lineto x y size sub lineto\n"); PS("closepath stroke} def\n"); PS("/mark5 {/size exch def /y exch def /x exch def\n"); PS("x y size mark1\n"); PS("newpath x size sub y moveto size size add 0 rlineto stroke} def\n"); PS("/mark6 {/size exch def /y exch def /x exch def\n"); PS("newpath x y moveto x y size 0 360 arc fill} def\n"); PS("/mark7 {/size exch def /y exch def /x exch def\n"); PS("newpath x y moveto x size sub y size sub lineto\n"); PS("x size add y size sub lineto closepath fill\n"); PS("newpath x y moveto x size add y size add lineto\n"); PS("x size sub y size add lineto closepath fill} def\n"); } static void psText(state, x, y, text, just, style) char *state; /* Really (struct userInfo *) */ int x, y; /* Text position (devs) */ char *text; /* Text itself */ int just; /* Justification */ int style; /* Style */ /* * Draws text at the given location with the given justification * and style. */ { struct userInfo *ui = (struct userInfo *) state; if (TEXTCOLOR != ui->currentColor) { OUT(ui->psFile, "%lg setgray\n", (double) TEXTCOLOR / 8); ui->currentColor = TEXTCOLOR; } if (style != ui->currentTextStyle) { switch (style) { case T_AXIS: OUT(ui->psFile, "%lg /%s choose-font\n", ui->axis_size * INCHES_PER_POINT * VDPI, ui->axis_family); break; case T_TITLE: OUT(ui->psFile, "%lg /%s choose-font\n", ui->title_size * INCHES_PER_POINT * VDPI, ui->title_family); break; } ui->currentTextStyle = style; } OUT(ui->psFile, "(%s) %d %d %d just-string\n", text, x, IY(y), just); } /*ARGSUSED*/ static void psSeg(state, ns, seglist, width, style, lappr, color) char *state; /* Really (struct userInfo *) */ int ns; /* Number of segments */ XSegment *seglist; /* X array of segments */ int width; /* Width of lines (devcoords) */ int style; /* L_AXIS, L_ZERO, L_VAR */ int lappr; /* Zero to seven */ int color; /* Zero to seven */ /* * Draws a number of line segments. Grid lines are drawn using * light lines. Variable lines (L_VAR) are drawn wider. This * version ignores the color argument. */ { struct userInfo *ui = (struct userInfo *) state; int newwidth = 0, i; if ((style != ui->currentLStyle) || (width != ui->currentWidth)) { switch (style) { case L_AXIS: newwidth = PS_AXIS_WBASE * ui->baseWidth; PSU("[] 0 setdash\n"); break; case L_ZERO: newwidth = PS_ZERO_WBASE * ui->baseWidth; PSU("[] 0 setdash\n"); break; case L_VAR: newwidth = PS_DATA_WBASE * ui->baseWidth; break; } ui->currentWidth = MAX(newwidth, width); ui->currentLStyle = style; OUT(ui->psFile, "%d setlinewidth\n", ui->currentWidth); } if (width > 4) { if (color > MAXCOLOR) color -= MAXCOLOR; else lappr = 0; } else color = TEXTCOLOR; if ((lappr != ui->currentDashStyle) && (style == L_VAR)) { if (lappr == 0) { PSU("[] 0 setdash\n"); } else { OUT(ui->psFile, "[%lg] 0 setdash\n", ((double) lappr) * BASE_DASH * VDPI); } ui->currentDashStyle = lappr; } if ((color != ui->currentColor) && (style == L_VAR)) { OUT(ui->psFile, "%lg setgray\n", (double) color / MAXCOLOR); ui->currentColor = color; } PSU("newpath\n"); OUT(ui->psFile, " %d %d moveto\n", seglist[0].x1, IY(seglist[0].y1)); OUT(ui->psFile, " %d %d lineto\n", seglist[0].x2, IY(seglist[0].y2)); for (i = 1; i < ns; i++) { if ((seglist[i].x1 != seglist[i - 1].x2) || (seglist[i].y1 != seglist[i - 1].y2)) { OUT(ui->psFile, " %d %d moveto\n", seglist[i].x1, IY(seglist[i].y1)); } OUT(ui->psFile, " %d %d lineto\n", seglist[i].x2, IY(seglist[i].y2)); } PSU("stroke\n"); } /*ARGSUSED*/ static void psDot(state, x, y, style, type, color) char *state; /* state information */ int x, y; /* coord of dot */ int style; /* type of dot */ int type; /* dot style variation */ int color; /* color of dot */ /* * Prints out a dot at the given location */ { struct userInfo *ui = (struct userInfo *) state; if (ui->currentDashStyle != PS_NO_DSTYLE) { OUT(ui->psFile, "[] 0 setdash "); ui->currentDashStyle = PS_NO_DSTYLE; } if (ui->currentWidth != PS_ZERO_WBASE * ui->baseWidth) { ui->currentWidth = PS_ZERO_WBASE * ui->baseWidth; OUT(ui->psFile, "%d setlinewidth ", ui->currentWidth); } if (color > MAXCOLOR) color -= MAXCOLOR; if ((color != ui->currentColor)) { OUT(ui->psFile, "%lg setgray\n", (double) color / MAXCOLOR); ui->currentColor = color; } switch (style) { case P_PIXEL: OUT(ui->psFile, "newpath %d %d moveto %d %d %d 0 360 arc fill\n", x, IY(y), x, IY(y), PS_PIXEL * ui->baseWidth); break; case P_DOT: OUT(ui->psFile, "newpath %d %d moveto %d %d %d 0 360 arc fill\n", x, IY(y), x, IY(y), PS_DOT * ui->baseWidth); break; case P_MARK: OUT(ui->psFile, "%d %d %d mark%d\n", x, IY(y), PS_MARK * ui->baseWidth, type); break; } return; } static void psEnd(userState) char *userState; /* state information */ { struct userInfo *ui = (struct userInfo *) userState; if (!(ui->flags & D_DOCU)) { PSU("showpage\n"); } PSU("%% End of xgraph output\n"); } xgraph-12.1.orig/read.c0100664000175000000620000001774607360237511013414 0ustar bapstaff/* $Header: /usr/src/mash/repository/vint/xgraph/read.c,v 1.2 1999/12/03 23:17:45 heideman Exp $ */ /* * read.c: Dataset read code * * Routines: * int ReadData(); * * $Log: read.c,v $ * Revision 1.2 1999/12/03 23:17:45 heideman * apply xgraph_no_animation.patch * * Revision 1.1.1.1 1999/12/03 23:15:53 heideman * xgraph-12.0 * */ #ifndef lint static char rcsid[] = "$Id: read.c,v 1.2 1999/12/03 23:17:45 heideman Exp $"; #endif #include "copyright.h" #include #include #include #include #include "xgraph.h" #include "xtb.h" #include "hard_devices.h" #include "params.h" /* * New dataset reading code */ static int setNumber = 0; static PointList **curSpot = (PointList **) 0; static PointList *curList = (PointList *) 0; static int newGroup = 0; static int redundant_set = 0; #ifdef DO_DER extern void Der1(); #endif static int rdSet(fn) char *fn; /* Reading from file `fn' */ /* * Set up new dataset. Will return zero if there are too many data sets. */ { char setname[100]; if (!redundant_set) { if (setNumber < MAXSETS) { (void) sprintf(setname, "Set %d", setNumber); if ((strcmp(PlotData[setNumber].setName, setname) == 0) && fn) { PlotData[setNumber].setName = fn; } curSpot = &(PlotData[setNumber].list); PlotData[setNumber].list = (PointList *) 0; newGroup = 1; setNumber++; redundant_set = 1; return 1; } else { return 0; } } else { return 1; } } static void rdSetName(name) char *name; /* New set name */ /* * Sets the name of a data set. Automatically makes a copy. */ { PlotData[setNumber - 1].setName = STRDUP(name); } static void rdGroup() /* * Set up for reading new group of points within a dataset. */ { newGroup = 1; } static void rdPoint(xval, yval) double xval, yval; /* New point */ /* * Adds a new point to the current group of the current * data set. */ { if (newGroup) { *curSpot = (PointList *) Malloc(sizeof(PointList)); curList = *curSpot; curSpot = &(curList->next); curList->numPoints = 0; curList->allocSize = INITSIZE; curList->xvec = (double *) Malloc((unsigned) (INITSIZE * sizeof(double))); curList->yvec = (double *) Malloc((unsigned) (INITSIZE * sizeof(double))); curList->next = (PointList *) 0; newGroup = 0; } if (curList->numPoints >= curList->allocSize) { curList->allocSize *= 2; curList->xvec = (double *) Realloc((char *) curList->xvec, (unsigned) (curList->allocSize * sizeof(double))); curList->yvec = (double *) Realloc((char *) curList->yvec, (unsigned) (curList->allocSize * sizeof(double))); } curList->xvec[curList->numPoints] = xval; curList->yvec[curList->numPoints] = yval; (curList->numPoints)++; redundant_set = 0; } static int rdFindMax() /* * Returns the maximum number of items in any one group of any * data set. */ { int i; PointList *list; int max = -1; for (i = 0; i < setNumber; i++) { for (list = PlotData[i].list; list; list = list->next) { if (list->numPoints > max) max = list->numPoints; } } return max; } typedef enum line_type { EMPTY, COMMENT, SETNAME, DRAWPNT, MOVEPNT, SETPARAM, ERROR } LineType; typedef struct point_defn { double xval, yval; } Point; typedef struct parmval_defn { char *name, *value; } ParmVals; typedef struct line_info { LineType type; union val_defn { char *str; /* SETNAME, ERROR */ Point pnt; /* DRAWPNT, MOVEPNT */ ParmVals parm; /* SETPARAM */ } val; } LineInfo; static LineType parse_line(line, result) char *line; /* Line to parse */ LineInfo *result; /* Returned result */ /* * Parses `line' into one of the types given in the definition * of LineInfo. The appropriate values are filled into `result'. * Below are the current formats for each type: * EMPTY: All white space * COMMENT: Starts with "#" * SETNAME: A name enclosed in double quotes * DRAWPNT: Two numbers optionally preceded by keyword "draw" * MOVEPNT: Two numbers preceded by keyword "move" * SETPARAM: Two non-null strings separated by ":" * ERROR: Not any of the above (an error message is returned) * Note that often the values are pointers into the line itself * and should be copied if they are to be used over a long period. */ { char *first; /* Find first non-space character */ while (*line && isspace(*line)) line++; if (*line) { if (*line == '#') { /* comment */ result->type = COMMENT; } else if (*line == '"') { /* setname */ result->type = SETNAME; line++; result->val.str = line; while (*line && (*line != '\n') && (*line != '"')) line++; if (*line) *line = '\0'; } else { first = line; while (*line && !isspace(*line)) line++; if (*line) { *line = '\0'; if (stricmp(first, "move") == 0) { /* MOVEPNT */ if (sscanf(line + 1, "%lf %lf", &result->val.pnt.xval, &result->val.pnt.yval) == 2) { result->type = MOVEPNT; } else { result->type = ERROR; result->val.str = "Cannot read move coordinates"; } } else if (stricmp(first, "draw") == 0) { /* DRAWPNT */ if (sscanf(line + 1, "%lf %lf", &result->val.pnt.xval, &result->val.pnt.yval) == 2) { result->type = DRAWPNT; } else { result->type = ERROR; result->val.str = "Cannot read draw coordinates"; } } else if (first[strlen(first) - 1] == ':') { /* SETPARAM */ first[strlen(first) - 1] = '\0'; result->val.parm.name = first; line++; while (*line && isspace(*line)) line++; /* may be a \n at end of it */ if (line[strlen(line) - 1] == '\n') { line[strlen(line) - 1] = '\0'; } result->val.parm.value = line; result->type = SETPARAM; } else if (sscanf(first, "%lf", &result->val.pnt.xval) == 1) { /* DRAWPNT */ if (sscanf(line + 1, "%lf", &result->val.pnt.yval) == 1) { result->type = DRAWPNT; } else { result->type = ERROR; result->val.str = "Cannot read second coordinate"; } } else { /* ERROR */ result->type = ERROR; result->val.str = "Unknown line type"; } } else { /* ERROR */ result->type = ERROR; result->val.str = "Premature end of line"; } } } else { /* empty */ result->type = EMPTY; } return result->type; } int ReadData(stream, filename) FILE *stream; char *filename; /* * Reads in the data sets from the supplied stream. If the format * is correct, it returns the current maximum number of points across * all data sets. If there is an error, it returns -1. */ { char buffer[MAXBUFSIZE]; LineInfo info; int line_count = 0; int errors = 0; if (!rdSet(filename)) { (void) fprintf(stderr, "Error in file `%s' at line %d:\n %s\n", filename, line_count, "Too many data sets - extra data ignored"); return -1; } while (fgets(buffer, MAXBUFSIZE, stream)) { line_count++; switch (parse_line(buffer, &info)) { case EMPTY: if (!rdSet(filename)) { (void) fprintf(stderr, "Error in file `%s' at line %d:\n %s\n", filename, line_count, "Too many data sets - extra data ignored"); return -1; } break; case COMMENT: /* nothing */ break; case SETNAME: rdSetName(info.val.str); break; case DRAWPNT: rdPoint(info.val.pnt.xval, info.val.pnt.yval); break; case MOVEPNT: rdGroup(); rdPoint(info.val.pnt.xval, info.val.pnt.yval); break; case SETPARAM: param_reset(info.val.parm.name, info.val.parm.value); break; default: if (filename) { (void) fprintf(stderr, "Error in file `%s' at line %d:\n %s\n", filename, line_count, info.val.str); errors++; } break; } } #ifdef DO_DER Der1(); #endif if (errors) return -1; else return rdFindMax(); } xgraph-12.1.orig/st.c0100664000175000000620000002607407360237506013125 0ustar bapstaff/*LINTLIBRARY*/ /* * String Table (Hash) Package * * Peter Moore * University of California, Berkeley * 1985 * * This is a general purpose hash table package. */ #include #include "copyright.h" #include "st.h" #include "xgraph.h" #define max(a,b) ((a) > (b) ? (a) : (b)) #define nil(type) ((type *) 0) #define alloc(type) (type *) Malloc(sizeof(type)) #define ABS(x) ((x) < 0 ? -(x) : (x)) #define ST_NUMCMP(x,y) ((int) (x) - (int) (y)) #define ST_NUMHASH(x,size) (ABS((int)x)%(size)) #define ST_PTRHASH(x,size) ((int)((unsigned)(x)>>2)%size) #define EQUAL(func, x, y) \ ((((func) == st_numcmp) || ((func) == st_ptrcmp)) ?\ (ST_NUMCMP((x),(y)) == 0) : ((*func)((x), (y)) == 0)) #define do_hash(key, table)\ ((table->hash == st_ptrhash) ? ST_PTRHASH((key),(table)->num_bins) :\ (table->hash == st_numhash) ? ST_NUMHASH((key), (table)->num_bins) :\ (*table->hash)((key), (table)->num_bins)) char st_pkg_name[] = "st"; /* Possible error conditions */ char *st_no_mem = "out of memory"; char *st_bad_ret = "bad return code from function passed to st_foreach"; char *st_bad_gen = "null or zero generator"; /* Forward declarations */ int st_numhash(), st_ptrhash(), st_numcmp(), st_ptrcmp(); static void rehash(); static void errRaise(); st_table * st_init_table_with_params(compare, hash, size, density, grow_factor, reorder_flag) int (*compare) (); int (*hash) (); int size; int density; double grow_factor; int reorder_flag; /* Detailed table allocator */ { st_table *new; new = alloc(st_table); if (!new) { errRaise(st_pkg_name, ST_NO_MEM, st_no_mem); /* NOTREACHED */ } new->compare = compare; new->hash = hash; new->num_entries = 0; new->max_density = density; new->grow_factor = grow_factor; new->reorder_flag = reorder_flag; if (size <= 0) { size = 1; } new->num_bins = size; new->bins = (st_table_entry **) Calloc((unsigned) size, sizeof(st_table_entry *)); if (!new->bins) { Free((char *) new); errRaise(st_pkg_name, ST_NO_MEM, st_no_mem); /* NOTREACHED */ } return new; } st_table * st_init_table(compare, hash) int (*compare) (); int (*hash) (); /* Default table allocator */ { return st_init_table_with_params(compare, hash, ST_DEFAULT_INIT_TABLE_SIZE, ST_DEFAULT_MAX_DENSITY, ST_DEFAULT_GROW_FACTOR, ST_DEFAULT_REORDER_FLAG); } void st_Free_table(table) st_table *table; /* Destroy a table */ { register st_table_entry *ptr, *next; int i; for (i = 0; i < table->num_bins; i++) { ptr = table->bins[i]; while (ptr != nil(st_table_entry)) { next = ptr->next; Free((char *) ptr); ptr = next; } } Free((char *) table->bins); Free((char *) table); } #define PTR_NOT_EQUAL(table, ptr, user_key)\ (ptr != nil(st_table_entry) && !EQUAL(table->compare, user_key, (ptr)->key)) #define FIND_ENTRY(table, hash_val, key, ptr, last) \ (last) = &(table)->bins[hash_val];\ (ptr) = *(last);\ while (PTR_NOT_EQUAL((table), (ptr), (key))) {\ (last) = &(ptr)->next; (ptr) = *(last);\ }\ if ((ptr) != nil(st_table_entry) && (table)->reorder_flag) {\ *(last) = (ptr)->next;\ (ptr)->next = (table)->bins[hash_val];\ (table)->bins[hash_val] = (ptr);\ } int st_lookup(table, key, value) st_table *table; register char *key; char **value; /* Look up item in table -- return zero if not found */ { int hash_val; register st_table_entry *ptr, **last; hash_val = do_hash(key, table); FIND_ENTRY(table, hash_val, key, ptr, last); if (ptr == nil(st_table_entry)) { return 0; } else { if (value != nil(char *)) *value = ptr->record; return 1; } } #define ADD_DIRECT(table, key, value, hash_val, new)\ {\ if (table->num_entries/table->num_bins >= table->max_density) {\ (void) rehash(table);\ hash_val = do_hash(key,table);\ }\ \ new = alloc(st_table_entry);\ \ if (new) {\ new->key = key;\ new->record = value;\ new->next = table->bins[hash_val];\ table->bins[hash_val] = new;\ table->num_entries++;\ } else {\ errRaise(st_pkg_name, ST_NO_MEM, st_no_mem);\ /* NOTREACHED */ \ } \ } int st_insert(table, key, value) register st_table *table; register char *key; char *value; /* Insert an item into the table - replacing if it already exists */ { int hash_val; st_table_entry *new; register st_table_entry *ptr, **last; hash_val = do_hash(key, table); FIND_ENTRY(table, hash_val, key, ptr, last); if (ptr == nil(st_table_entry)) { ADD_DIRECT(table, key, value, hash_val, new); return 0; } else { ptr->record = value; return 1; } } void st_add_direct(table, key, value) st_table *table; char *key; char *value; /* Add item to table without checking for existing item */ { int hash_val; st_table_entry *new; hash_val = do_hash(key, table); ADD_DIRECT(table, key, value, hash_val, new); } int st_find_or_add(table, key, slot) st_table *table; char *key; char ***slot; /* Return slot for key - make one if one doesn't exist */ { int hash_val; st_table_entry *new, *ptr, **last; hash_val = do_hash(key, table); FIND_ENTRY(table, hash_val, key, ptr, last); if (ptr == nil(st_table_entry)) { ADD_DIRECT(table, key, (char *) 0, hash_val, new); if (slot != nil(char **)) *slot = &new->record; return 0; } else { if (slot != nil(char **)) *slot = &ptr->record; return 1; } } int st_find(table, key, slot) st_table *table; char *key; char ***slot; /* Finds an entry in table */ { int hash_val; st_table_entry *ptr, **last; hash_val = do_hash(key, table); FIND_ENTRY(table, hash_val, key, ptr, last); if (ptr == nil(st_table_entry)) { return 0; } else { if (slot != nil(char **)) *slot = &ptr->record; return 1; } } static void rehash(table) register st_table *table; /* Grows table */ { register st_table_entry *ptr, *next, **old_bins = table->bins; int i, old_num_bins = table->num_bins, hash_val; table->num_bins = table->grow_factor * old_num_bins; if (table->num_bins % 2 == 0) { table->num_bins += 1; } table->bins = (st_table_entry **) Calloc((unsigned) table->num_bins, sizeof(st_table_entry *)); if (!table->bins) { /* If out of memory: don't resize */ table->bins = old_bins; table->num_bins = old_num_bins; return; } table->num_entries = 0; for (i = 0; i < old_num_bins; i++) { ptr = old_bins[i]; while (ptr != nil(st_table_entry)) { next = ptr->next; hash_val = do_hash(ptr->key, table); ptr->next = table->bins[hash_val]; table->bins[hash_val] = ptr; table->num_entries++; ptr = next; } } Free((char *) old_bins); } st_table * st_copy(old_table) st_table *old_table; { st_table *new_table; st_table_entry *ptr, *new; int i, num_bins = old_table->num_bins; new_table = alloc(st_table); if (new_table == nil(st_table)) { errRaise(st_pkg_name, ST_NO_MEM, st_no_mem); /* NOTREACHED */ } *new_table = *old_table; new_table->bins = (st_table_entry **) Calloc((unsigned) num_bins, sizeof(st_table_entry *)); if (new_table->bins == nil(st_table_entry *)) { Free((char *) new_table); errRaise(st_pkg_name, ST_NO_MEM, st_no_mem); /* NOTREACHED */ } for (i = 0; i < num_bins; i++) { new_table->bins[i] = nil(st_table_entry); ptr = old_table->bins[i]; while (ptr != nil(st_table_entry)) { new = alloc(st_table_entry); if (new == nil(st_table_entry)) { Free((char *) new_table->bins); Free((char *) new_table); errRaise(st_pkg_name, ST_NO_MEM, st_no_mem); /* NOTREACHED */ } *new = *ptr; new->next = new_table->bins[i]; new_table->bins[i] = new; ptr = ptr->next; } } return new_table; } int st_delete(table, keyp, value) register st_table *table; register char **keyp; char **value; { int hash_val; char *key = *keyp; register st_table_entry *ptr, **last; hash_val = do_hash(key, table); FIND_ENTRY(table, hash_val, key, ptr, last); if (ptr == nil(st_table_entry)) { return 0; } *last = ptr->next; if (value != nil(char *)) *value = ptr->record; *keyp = ptr->key; Free((char *) ptr); table->num_entries--; return 1; } int st_foreach(table, func, arg) st_table *table; enum st_retval (*func) (); char *arg; { st_table_entry *ptr, **last; enum st_retval retval; int i; for (i = 0; i < table->num_bins; i++) { last = &table->bins[i]; ptr = *last; while (ptr != nil(st_table_entry)) { retval = (*func) (ptr->key, ptr->record, arg); switch (retval) { case ST_CONTINUE: last = &ptr->next; ptr = *last; break; case ST_STOP: return 0; case ST_DELETE: *last = ptr->next; Free((char *) ptr); ptr = *last; break; default: errRaise(st_pkg_name, ST_BAD_RET, st_bad_ret); /* NOTREACHED */ } } } return 1; } int st_strhash(string, modulus) register char *string; int modulus; { register int val = 0; register int c; while ((c = *string++) != '\0') { val = val * 997 + c; } return ((val < 0) ? -val : val) % modulus; } int st_numhash(x, size) char *x; int size; { return ST_NUMHASH(x, size); } int st_ptrhash(x, size) char *x; int size; { return ST_PTRHASH(x, size); } int st_numcmp(x, y) char *x; char *y; { return ST_NUMCMP(x, y); } int st_ptrcmp(x, y) char *x; char *y; { return ST_NUMCMP(x, y); } st_generator * st_init_gen(table) st_table *table; /* Initializes generation of items in table */ { st_generator *gen; gen = alloc(st_generator); if (!gen) { errRaise(st_pkg_name, ST_NO_MEM, st_no_mem); /* NOTREACHED */ } gen->table = table; gen->entry = nil(st_table_entry); gen->idx = 0; return gen; } int st_gen(gen, key_p, value_p) st_generator *gen; char **key_p; char **value_p; /* Generates next item in generation sequence */ { register int i; if (!gen) { errRaise(st_pkg_name, ST_BAD_GEN, st_bad_gen); /* NOTREACHED */ } if (gen->entry == nil(st_table_entry)) { /* try to find next entry */ for (i = gen->idx; i < gen->table->num_bins; i++) { if (gen->table->bins[i] != nil(st_table_entry)) { gen->idx = i + 1; gen->entry = gen->table->bins[i]; break; } } if (gen->entry == nil(st_table_entry)) { return 0; /* that's all folks ! */ } } *key_p = gen->entry->key; if (value_p != 0) *value_p = gen->entry->record; gen->entry = gen->entry->next; return 1; } void st_Free_gen(gen) st_generator *gen; { if (gen) { Free((char *) gen); } else { errRaise(st_pkg_name, ST_BAD_GEN, st_bad_gen); /* NOTREACHED */ } } static void errRaise(pkg, num, msg) char *pkg; int num; char *msg; /* * In this standalone version of st, and error raise causes * an abort after printing a message. */ { (void) fprintf(stderr, "%s: %s\n", pkg, msg); abort(); } xgraph-12.1.orig/st.h0100664000175000000620000000543107360237512013121 0ustar bapstaff/* $Header: /usr/src/mash/repository/vint/xgraph/st.h,v 1.1.1.1 1999/12/03 23:15:53 heideman Exp $ */ #ifndef ST_INCLUDED #define ST_INCLUDED /* Function prototypes */ #ifdef __STDC__ #define ARGS(args) args #else #define ARGS(args) () #endif extern char st_pkg_name[]; /* Fatal error codes */ #define ST_NO_MEM 0 #define ST_BAD_RET 1 #define ST_BAD_GEN 2 typedef struct st_table_entry st_table_entry; struct st_table_entry { char *key; char *record; st_table_entry *next; }; typedef struct st_table st_table; struct st_table { int (*compare) (); int (*hash) (); int num_bins; int num_entries; int max_density; int reorder_flag; double grow_factor; st_table_entry **bins; }; typedef struct st_generator st_generator; struct st_generator { st_table *table; st_table_entry *entry; int idx; }; #define st_is_member(table,key) st_lookup(table,key,(char **) 0) #define st_count(table) ((table)->num_entries) enum st_retval { ST_CONTINUE, ST_STOP, ST_DELETE }; extern st_table *st_init_table_with_params ARGS((int (*compare) (), int (*hash) (), int size, int density, double grow_factor, int reorder_flag)); extern st_table *st_init_table ARGS((int (*compare) (), int (*hash) ())); extern void st_free_table ARGS((st_table * table)); extern int st_lookup ARGS((st_table * table, char *key, char **value)); extern int st_insert ARGS((st_table * table, char *key, char *value)); extern void st_add_direct ARGS((st_table * table, char *key, char *value)); extern int st_find_or_add ARGS((st_table * table, char *key, char ***slot)); extern int st_find ARGS((st_table * table, char *key, char ***slot)); extern st_table *st_copy ARGS((st_table * old_table)); extern int st_delete ARGS((st_table * table, char **keyp, char **value)); extern int st_foreach ARGS((st_table * table, enum st_retval(*func) (), char *arg)); extern int st_strhash ARGS((char *string, int modulus)); extern int st_numhash ARGS((char *x, int size)); extern int st_ptrhash ARGS((char *x, int size)); extern int st_numcmp ARGS((char *x, char *y)); extern int st_ptrcmp ARGS((char *x, char *y)); extern st_generator *st_init_gen ARGS((st_table * table)); extern int st_gen ARGS((st_generator * gen, char **key_p, char **value_p)); extern void st_free_gen ARGS((st_generator * gen)); #define ST_DEFAULT_MAX_DENSITY 5 #define ST_DEFAULT_INIT_TABLE_SIZE 11 #define ST_DEFAULT_GROW_FACTOR 2.0 #define ST_DEFAULT_REORDER_FLAG 0 #define st_foreach_item(table, gen, key_p, value_p) \ for(gen=st_init_gen(table); st_gen(gen,key_p,value_p) || (st_free_gen(gen),0);) #endif /* ST_INCLUDED */ xgraph-12.1.orig/stamp-h.in0100664000175000000620000000001207360237474014220 0ustar bapstafftimestamp xgraph-12.1.orig/tgif.c0100664000175000000620000002013407360237511013413 0ustar bapstaff/* * Tgif Output * * Christos Zoulas */ #include #include #include "hard_devices.h" #include "xgout.h" #define COLOR "DarkSlateGray" typedef struct { char *title_font; char *axis_font; int title_size; int axis_size; FILE *strm; } Info; char *tgif_prologue[] = { "state(0,13,0,0,0,16,1,5,1,1,0,0,1,0,1,0,1,0,4,0,0,0,10,0).\n", "%\n", "% Tgif xgraph output.\n", "%\n", 0 }; /* * Hardcopy Interface for Xgraph * * Major differences from first version: * Four new parameters are passed to the device initialization routine: * title_family, title_size, axis_family, and axis_size. See the * description of xg_init() for details. * * Clipping is done automatically by xgraph. The xg_clip() routine * is obsolete. * * The xg_line() routine has become the xg_seg() routine. It now * draws segments rather than a series of lines. * * A new field (max_segs) in the device structure now specifies * the maximum number of segments the device can handle in a group. */ void tgifText(); void tgifDot(); void tgifSeg(); void tgifEnd(); int tgifInit(strm, width, height, title_family, title_size, axis_family, axis_size, flags, out_info, errmsg) FILE *strm; /* Output stream */ int width, height; /* Size of space (microns) */ char *title_family; /* Name of title font family */ double title_size; /* Title font height (points) */ char *axis_family; /* Name of axis font family */ double axis_size; /* Axis font height (points) */ int flags; /* Flags */ xgOut *out_info; /* Device info (RETURN) */ char errmsg[ERRBUFSIZE]; /* Error message area */ { Info *tgif_info; char **l; double scx, scy; tgif_info = (Info *) Malloc(sizeof(*tgif_info)); for (l = tgif_prologue; *l; l++) fprintf(strm, "%s\n", *l); out_info->dev_flags = 0; scx = width / 512.0; scy = height / 512.0; if (scx > scy) { scy /= scx; scx = 1; } else { scx /= scy; scy = 1; } out_info->bdr_pad = title_size / 4; out_info->axis_pad = 2.0 * axis_size; out_info->legend_pad = 0; out_info->area_w = width * 0.00283 * scx; /* pts per micron */ out_info->area_h = height * 0.00283 * scy; out_info->tick_len = axis_size; out_info->axis_height = axis_size; out_info->title_height = title_size; out_info->axis_width = (axis_size * 5.0) / 12.0; out_info->title_width = (title_size * 5.0) / 12.0; out_info->max_segs = 100; out_info->xg_text = tgifText; out_info->xg_seg = tgifSeg; out_info->xg_dot = tgifDot; out_info->xg_end = tgifEnd; out_info->user_state = (char *) tgif_info; tgif_info->title_font = title_family; tgif_info->axis_font = axis_family; tgif_info->title_size = title_size; tgif_info->axis_size = axis_size; tgif_info->strm = strm; return 1; } /* Text justifications */ #define T_CENTER 0 #define T_LEFT 1 #define T_UPPERLEFT 2 #define T_TOP 3 #define T_UPPERRIGHT 4 #define T_RIGHT 5 #define T_LOWERRIGHT 6 #define T_BOTTOM 7 #define T_LOWERLEFT 8 /* Text styles */ #define T_AXIS 0 #define T_TITLE 1 static void tgif_just(x, y, just, size, len) int *x, *y; /* Given location (lower left) */ int just; /* Justification */ int size; /* Size in points */ int len; /* Number of chars */ /* * Unfortunately, tgif really can't display text with a justification. * This is a horrible hack to try to get around the problem. It tries * to compute a rough bounding box for the text based on the text height * and the string length and offset `x,y' appropriately for the justification. * This is only a hack... */ { int t_width, t_height; t_height = size; t_width = (size * len * 5) / 12; /* Horrible estimate */ switch (just) { case T_CENTER: *x -= t_width / 2; *y -= t_height / 2; break; case T_LEFT: *y -= t_height / 2; break; case T_UPPERLEFT: /* nothing */ break; case T_TOP: *x -= t_width / 2; break; case T_UPPERRIGHT: *x -= t_width; break; case T_RIGHT: *x -= t_width; *y -= t_height / 2; break; case T_LOWERRIGHT: *x -= t_width; *y -= t_height; break; case T_BOTTOM: *x -= t_width / 2; *y -= t_height; break; case T_LOWERLEFT: *y -= t_height; break; } /* * Also, tgif seems to put a space above all text it draws. The * computation below compensates for this. */ *y += (size / 3); } void tgifText(user_state, x, y, text, just, style) char *user_state; /* Value set in xg_init */ int x, y; /* Text position (pixels) */ char *text; /* Null terminated text */ int just; /* Justification (above) */ int style; /* Text style (above) */ /* * This routine should draw text at the indicated position using * the indicated justification and style. The justification refers * to the location of the point in reference to the text. For example, * if just is T_LOWERLEFT, (x,y) should be located at the lower left * edge of the text string. */ { char *font; int size; Info *tgif = (Info *) user_state; /* * Obj = text(_Color,_X,_Y,_Font,_TextStyle,_TextSize,_NumLines,_TextJust, * _TextRotate,_PenPat,_BBoxW,_BBoxH,_Id,_TextDPI,_Asc,_Des, * _ObjFill,_Vspace,StrList), */ /* font ok too */ style == T_AXIS ? tgif->axis_font : tgif->title_font; /* ok 0, 1 as in tgif */ size = style == T_AXIS ? tgif->axis_size : tgif->title_size; tgif_just(&x, &y, just, size, strlen(text)); if (size <= 8) size = 0; else if (size <= 10) size = 1; else if (size <= 12) size = 2; else if (size <= 14) size = 3; else if (size <= 18) size = 4; else size = 5; fprintf(tgif->strm, "text('%s',%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,[\n\t", COLOR, x, y, 0, style, size, 1, 0, 0, 1, 0, 0, 0, 0, 18, 4, 0, 0); fprintf(tgif->strm, "\"%s\"]).\n", text); } /* Line Styles */ #define L_AXIS 0 #define L_ZERO 1 #define L_VAR 2 void tgifSeg(user_state, ns, seglist, width, style, lappr, color) char *user_state; /* Value set in xg_init */ int ns; /* Number of segments */ XSegment *seglist; /* X array of segments */ int width; /* Width of lines */ int style; /* See above */ int lappr; /* Line appearence */ int color; /* Line color (if any) */ { Info *tgif = (Info *) user_state; int i, j, k; /* * poly(_Color,_NumVs,_Vs,_LineStyle,_LineWidth,_PenPat,_Id,_Spline, * _ObjFill,_Dash,AttrList), */ static int style_list[] = { 1, 10, 7, 6, 5, 4, 3, 2 }; for (i = 0; i < ns; i++) { fprintf(tgif->strm, "poly('%s',2,[%d,%d,%d,%d],", COLOR, seglist[i].x1, seglist[i].y1, seglist[i].x2, seglist[i].y2); fprintf(tgif->strm, "%d,%d,%d,%d,%d,%d,%d,[\n]).\n", 0, width, style_list[lappr], 0, 0, style_list[lappr], 0); } } /* Marker styles */ #define P_PIXEL 0 #define P_DOT 1 #define P_MARK 2 void tgifDot(user_state, x, y, style, type, color) char *user_state; /* Value set in xg_init */ int x, y; /* Location in pixel units */ int style; /* Dot style */ int type; /* Type of marker */ int color; /* Marker color (if any) */ /* * This routine should draw a marker at location `x,y'. If the * style is P_PIXEL, the dot should be a single pixel. If * the style is P_DOT, the dot should be a reasonably large * dot. If the style is P_MARK, it should be a distinguished * mark which is specified by `type' (0-7). If the output * device is capable of color, the marker should be drawn in * `color' (0-7) which corresponds with the color for xg_line. */ { } void tgifEnd(user_state) char *user_state; /* * This routine is called after a drawing sequence is complete. * It can be used to clean up the user state and set the device * state appropriately. This routine is optional in the structure. */ { Info *tgif = (Info *) user_state; fclose(tgif->strm); } xgraph-12.1.orig/xgX.c0100664000175000000620000003130307360237502013230 0ustar bapstaff/* * Generic Output Driver for X * X version 11 * * This is the primary output driver used by the new X graph * to display output to the X server. It has been factored * out of the original xgraph to allow mulitple hardcopy * output devices to share xgraph's capabilities. Note: * xgraph is still heavily X oriented. This is not intended * for porting to other window systems. */ #include "copyright.h" #include "xgout.h" #include "params.h" #define PADDING 2 #define SPACE 10 #define TICKLENGTH 5 #define MAXSEGS 1000 struct x_state { Window win; /* Primary window */ }; void text_X(); void seg_X(); void dot_X(); typedef struct attr_set { char lineStyle[MAXLS]; int lineStyleLen; Pixel pixelValue; Pixmap markStyle; } AttrSet; static AttrSet AllAttrs[MAXATTR]; static Pixmap dotMap = (Pixmap) 0; /* * Marker bitmaps */ #include "bitmaps/dot.11" #include "bitmaps/mark1.11" #include "bitmaps/mark2.11" #include "bitmaps/mark3.11" #include "bitmaps/mark4.11" #include "bitmaps/mark5.11" #include "bitmaps/mark6.11" #include "bitmaps/mark7.11" #include "bitmaps/mark8.11" /* Sizes exported for marker drawing */ static unsigned int dot_w = dot_width; static unsigned int dot_h = dot_height; static unsigned int mark_w = mark1_width; static unsigned int mark_h = mark1_height; static int mark_cx = mark1_x_hot; static int mark_cy = mark1_y_hot; void set_X(new_win, out_info) Window new_win; /* Newly created window */ xgOut *out_info; /* Information to set */ /* * Sets some of the common parameters for the X output device. */ { struct x_state *new_state; XFontStruct *font; out_info->dev_flags = ((depth > 3) ? D_COLOR : 0); out_info->area_w = out_info->area_h = 0; /* Set later */ out_info->bdr_pad = PADDING; out_info->axis_pad = SPACE; out_info->legend_pad = 0; out_info->tick_len = TICKLENGTH; font = PM_FONT("LabelFont"); #ifdef OLD out_info->axis_width = font->max_bounds.rbearing - font->max_bounds.lbearing; #endif out_info->axis_width = XTextWidth(font, "8", 1); out_info->axis_height = font->max_bounds.ascent + font->max_bounds.descent; font = PM_FONT("TitleFont"); #ifdef OLD out_info->title_width = font->max_bounds.rbearing - font->max_bounds.lbearing; #endif out_info->title_width = XTextWidth(font, "8", 1); out_info->title_height = font->max_bounds.ascent + font->max_bounds.descent; out_info->max_segs = MAXSEGS; out_info->xg_text = text_X; out_info->xg_seg = seg_X; out_info->xg_dot = dot_X; out_info->xg_end = (void (*) ()) 0; new_state = (struct x_state *) Malloc(sizeof(struct x_state)); new_state->win = new_win; out_info->user_state = (char *) new_state; } static void init_once() /* * Initializes AllAttrs. */ { Window temp_win; XSetWindowAttributes wattr; char name[1024]; int idx; params style_val; /* Get attributes out parameters database */ for (idx = 0; idx < MAXATTR; idx++) { (void) sprintf(name, "%d.Style", idx); (void) param_get(name, &style_val); AllAttrs[idx].lineStyleLen = style_val.stylev.len; (void) strncpy(AllAttrs[idx].lineStyle, style_val.stylev.dash_list, style_val.stylev.len); (void) sprintf(name, "%d.Color", idx); AllAttrs[idx].pixelValue = PM_PIXEL(name); } /* Create a temporary window for representing depth */ temp_win = XCreateWindow(disp, RootWindow(disp, screen), 0, 0, 10, 10, 0, depth, InputOutput, vis, (unsigned long) 0, &wattr); /* Store bitmaps for dots and markers */ dotMap = XCreateBitmapFromData(disp, temp_win, dot_bits, dot_w, dot_h); AllAttrs[0].markStyle = XCreateBitmapFromData(disp, temp_win, mark1_bits, mark_w, mark_h); AllAttrs[1].markStyle = XCreateBitmapFromData(disp, temp_win, mark2_bits, mark_w, mark_h); AllAttrs[2].markStyle = XCreateBitmapFromData(disp, temp_win, mark3_bits, mark_w, mark_h); AllAttrs[3].markStyle = XCreateBitmapFromData(disp, temp_win, mark4_bits, mark_w, mark_h); AllAttrs[4].markStyle = XCreateBitmapFromData(disp, temp_win, mark5_bits, mark_w, mark_h); AllAttrs[5].markStyle = XCreateBitmapFromData(disp, temp_win, mark6_bits, mark_w, mark_h); AllAttrs[6].markStyle = XCreateBitmapFromData(disp, temp_win, mark7_bits, mark_w, mark_h); AllAttrs[7].markStyle = XCreateBitmapFromData(disp, temp_win, mark8_bits, mark_w, mark_h); XDestroyWindow(disp, temp_win); } /*ARGSUSED*/ void init_X(user_state) char *user_state; /* * Initializes for an X drawing sequence. Sets up drawing attributes * by reading values from the parameter database. */ { static int initialized = 0; if (!initialized) { init_once(); initialized = 1; } } static GC textGC(t_win, t_font) Window t_win; /* Window for making GC */ XFontStruct *t_font; /* Text font */ /* * Sets the fields above in a global graphics context. If * the graphics context does not exist, it is created. */ { static GC text_gc = (GC) 0; XGCValues gcvals; unsigned long gcmask; gcvals.font = t_font->fid; gcmask = GCFont; if (text_gc == (GC) 0) { gcvals.foreground = PM_PIXEL("Foreground"); gcmask |= GCForeground; text_gc = XCreateGC(disp, t_win, gcmask, &gcvals); } else { XChangeGC(disp, text_gc, gcmask, &gcvals); } return text_gc; } static GC segGC(l_win, l_fg, l_style, l_width, l_chars, l_len) Window l_win; /* Window for making GC */ Pixel l_fg; /* Foreground color */ int l_style; /* Line style */ int l_width; /* Line width */ char *l_chars; /* Character spec */ int l_len; /* Length of spec */ /* * Sets the fields above in a global graphics context. If the * graphics context does not exist, it is created. */ { static GC segment_gc = (GC) 0; XGCValues gcvals; unsigned long gcmask; gcvals.foreground = l_fg; gcvals.line_style = l_style; gcvals.line_width = l_width; gcmask = GCForeground | GCLineStyle | GCLineWidth; if (segment_gc == (GC) 0) { segment_gc = XCreateGC(disp, l_win, gcmask, &gcvals); } else { XChangeGC(disp, segment_gc, gcmask, &gcvals); } if (l_len > 0) { XSetDashes(disp, segment_gc, 0, l_chars, l_len); } return segment_gc; } static GC dotGC(d_win, d_fg, d_clipmask, d_xorg, d_yorg) Window d_win; /* Window for making GC */ Pixel d_fg; /* Foreground color */ Pixmap d_clipmask; /* Clipmask */ int d_xorg, d_yorg; /* Clipmask origin */ /* * Sets the fields above in a global graphics context. If the * graphics context does not exist, it is created. */ { static GC dot_gc = (GC) 0; XGCValues gcvals; unsigned long gcmask; gcvals.foreground = d_fg; gcvals.clip_mask = d_clipmask; gcvals.clip_x_origin = d_xorg; gcvals.clip_y_origin = d_yorg; gcmask = GCForeground | GCClipMask | GCClipXOrigin | GCClipYOrigin; if (dot_gc == (GC) 0) { dot_gc = XCreateGC(disp, d_win, gcmask, &gcvals); } else { XChangeGC(disp, dot_gc, gcmask, &gcvals); } return dot_gc; } void text_X(user_state, x, y, text, just, style) char *user_state; /* Value set in xg_init */ int x, y; /* Text position (pixels) */ char *text; /* Null terminated text */ int just; /* Justification (above) */ int style; /* Text style (above) */ /* * This routine should draw text at the indicated position using * the indicated justification and style. The justification refers * to the location of the point in reference to the text. For example, * if just is T_LOWERLEFT, (x,y) should be located at the lower left * edge of the text string. */ { struct x_state *st = (struct x_state *) user_state; XCharStruct bb; int rx = 0, ry = 0, len, height, width, dir; int ascent, descent; XFontStruct *font; len = strlen(text); font = ((style == T_TITLE) ? PM_FONT("TitleFont") : PM_FONT("LabelFont")); XTextExtents(font, text, len, &dir, &ascent, &descent, &bb); width = bb.rbearing - bb.lbearing; height = bb.ascent + bb.descent; switch (just) { case T_CENTER: rx = x - (width / 2); ry = y - (height / 2); break; case T_LEFT: rx = x; ry = y - (height / 2); break; case T_UPPERLEFT: rx = x; ry = y; break; case T_TOP: rx = x - (width / 2); ry = y; break; case T_UPPERRIGHT: rx = x - width; ry = y; break; case T_RIGHT: rx = x - width; ry = y - (height / 2); break; case T_LOWERRIGHT: rx = x - width; ry = y - height; break; case T_BOTTOM: rx = x - (width / 2); ry = y - height; break; case T_LOWERLEFT: rx = x; ry = y - height; break; } XDrawString(disp, st->win, textGC(st->win, font), rx, ry + bb.ascent, text, len); } void seg_X(user_state, ns, segs, width, style, lappr, color) char *user_state; /* Value set in xg_init */ int ns; /* Number of segments */ XSegment *segs; /* X array of segments */ int width; /* Width of lines */ int style; /* See above */ int lappr; /* Line appearence */ int color; /* Line color (if any) */ /* * This routine draws a number of line segments at the points * given in `seglist'. Note that contiguous segments need not share * endpoints but often do. All segments should be `width' devcoords wide * and drawn in style `style'. If `style' is L_VAR, the parameters * `color' and `lappr' should be used to draw the line. Both * parameters vary from 0 to 7. If the device is capable of * color, `color' varies faster than `style'. If the device * has no color, `style' will vary faster than `color' and * `color' can be safely ignored. However, if the * the device has more than 8 line appearences, the two can * be combined to specify 64 line style variations. * Xgraph promises not to send more than the `max_segs' in the * xgOut structure passed back from xg_init(). */ { struct x_state *st = (struct x_state *) user_state; param_style ps; GC gc; if (style == L_AXIS) { ps = PM_STYLE("GridStyle"); if (ps.len < 2) { gc = segGC(st->win, PM_PIXEL("Foreground"), LineSolid, PM_INT("GridSize"), (char *) 0, 0); } else { gc = segGC(st->win, PM_PIXEL("Foreground"), LineOnOffDash, PM_INT("GridSize"), ps.dash_list, ps.len); } } else if (style == L_ZERO) { /* Set the color and line style */ ps = PM_STYLE("ZeroStyle"); if (ps.len < 2) { gc = segGC(st->win, PM_PIXEL("ZeroColor"), LineSolid, PM_INT("ZeroWidth"), (char *) 0, 0); } else { gc = segGC(st->win, PM_PIXEL("ZeroColor"), LineOnOffDash, PM_INT("ZeroWidth"), ps.dash_list, ps.len); } } else { /* Color and line style vary */ if (lappr == 0) { gc = segGC(st->win, AllAttrs[color].pixelValue, LineSolid, width, (char *) 0, 0); } else { gc = segGC(st->win, AllAttrs[color].pixelValue, LineOnOffDash, width, AllAttrs[lappr].lineStyle, AllAttrs[lappr].lineStyleLen); } /* PW */ if (lappr == 16) { gc = segGC(st->win, PM_PIXEL("BackGround"), LineSolid, width, (char *) 0, 0); } } XDrawSegments(disp, st->win, gc, segs, ns); } #define LAST_CHECK void dot_X(user_state, x, y, style, type, color) char *user_state; /* Value set in xg_init */ int x, y; /* Location in pixel units */ int style; /* Dot style */ int type; /* Type of marker */ int color; /* Marker color (if any) */ /* * This routine should draw a marker at location `x,y'. If the * style is P_PIXEL, the dot should be a single pixel. If * the style is P_DOT, the dot should be a reasonably large * dot. If the style is P_MARK, it should be a distinguished * mark which is specified by `type' (0-7). If the output * device is capable of color, the marker should be drawn in * `color' (0-7) which corresponds with the color for xg_line. */ { struct x_state *st = (struct x_state *) user_state; switch (style) { case P_PIXEL: XDrawPoint(disp, st->win, dotGC(st->win, AllAttrs[color].pixelValue, (Pixmap) 0, 0, 0), x, y); break; case P_DOT: XFillRectangle(disp, st->win, dotGC(st->win, AllAttrs[color].pixelValue, dotMap, (int) (x - (dot_w >> 1)), (int) (y - (dot_h >> 1))), (int) (x - (dot_w >> 1)), (int) (y - (dot_h >> 1)), dot_w, dot_h); break; case P_MARK: XFillRectangle(disp, st->win, dotGC(st->win, AllAttrs[color].pixelValue, AllAttrs[type].markStyle, (int) (x - mark_cx), (int) (y - mark_cy)), (int) (x - mark_cx), (int) (y - mark_cy), mark_w, mark_h); break; } } xgraph-12.1.orig/xgout.h0100775000175000000620000000366407360237512013652 0ustar bapstaff/* * Output Device Information * * This file contains definitions for output device interfaces * to the graphing program xgraph. */ #ifndef _h_xgout #define _h_xgout /* Passed device option flags */ #define D_DOCU 0x01 /* Returned device capability flags */ #define D_COLOR 0x01 /* Text justifications */ #define T_CENTER 0 #define T_LEFT 1 #define T_UPPERLEFT 2 #define T_TOP 3 #define T_UPPERRIGHT 4 #define T_RIGHT 5 #define T_LOWERRIGHT 6 #define T_BOTTOM 7 #define T_LOWERLEFT 8 /* Text styles */ #define T_AXIS 0 #define T_TITLE 1 /* Line Styles */ #define L_AXIS 0 #define L_ZERO 1 #define L_VAR 2 /* Marker Styles */ #define P_PIXEL 0 #define P_DOT 1 #define P_MARK 2 /* Output device information returned by initialization routine */ typedef struct xg_out { int dev_flags; /* Device characteristic flags */ int area_w, area_h; /* Width and height in pixels */ int bdr_pad; /* Padding from border */ int axis_pad; /* Extra space around axis labels */ int tick_len; /* Length of tick mark on axis */ int legend_pad; /* Top of legend text to legend line */ int axis_width; /* Width of big character of axis font */ int axis_height; /* Height of big character of axis font */ int title_width; /* Width of big character of title font */ int title_height; /* Height of big character of title font */ int max_segs; /* Maximum number of segments in group */ void (*xg_text) (); /* Draws text at a location */ void (*xg_seg) (); /* Draws a series of segments */ void (*xg_dot) (); /* Draws a dot or marker at a location */ void (*xg_end) (); /* Stops the drawing sequence */ char *user_state; /* User supplied data */ } xgOut; #define ERRBUFSIZE 2048 #endif /* _h_xgout */ xgraph-12.1.orig/xgraph.c0100664000175000000620000010026207360237501013753 0ustar bapstaff/* $Header: /usr/src/mash/repository/vint/xgraph/xgraph.c,v 1.3 1999/12/19 00:52:07 heideman Exp $ */ /* * xgraph - A Simple Plotter for X * * David Harrison * University of California, Berkeley * 1986, 1987, 1988, 1989 * * Please see copyright.h concerning the formal reproduction rights * of this software. * * $Log: xgraph.c,v $ * Revision 1.3 1999/12/19 00:52:07 heideman * warning suppresion, slightly different flot ahndling * * Revision 1.2 1999/12/03 23:17:46 heideman * apply xgraph_no_animation.patch * * Revision 1.1.1.1 1999/12/03 23:15:52 heideman * xgraph-12.0 * */ #ifndef lint static char rcsid[] = "$Id: xgraph.c,v 1.3 1999/12/19 00:52:07 heideman Exp $"; #endif #include "copyright.h" #include #include #include #include #include "xgraph.h" #include "xtb.h" #include "hard_devices.h" #include "params.h" extern void init_X(); extern void do_error(); #ifdef DO_DER extern void Bounds(); #endif /* DO_DER */ static char *tildeExpand(); static void ReverseIt(); static void Traverse(); static int XErrHandler(); NewDataSet PlotData[MAXSETS], DataD1[MAXSETS], DataD2[MAXSETS]; XSegment *Xsegs[2]; /* Point space for X */ /* Basic transformation stuff */ double llx, lly, urx, ury; /* Bounding box of all data */ static XContext win_context = (XContext) 0; /* Other globally set defaults */ Display *disp; /* Open display */ Visual *vis; /* Standard visual */ Colormap cmap; /* Standard colormap */ int screen; /* Screen number */ int depth; /* Depth of screen */ int numFiles = 0; /* Number of input files */ char *inFileNames[MAXSETS]; /* File names */ /* Total number of active windows */ int Num_Windows = 0; char *Prog_Name; char *disp_name; main(argc, argv) int argc; char *argv[]; /* * This sets up the hard-wired defaults and reads the X defaults. * The command line format is: xgraph [host:display]. */ { Window primary, NewWindow(); XEvent theEvent; LocalWin *win_info; Cursor zoomCursor; FILE *strm; XColor fg_color, bg_color; char keys[MAXKEYS]; int nbytes, idx, maxitems = 0, flags; int errs = 0; /* Open up new display */ Prog_Name = argv[0]; disp_name = ""; /* Parse the argument list looking for input files */ flags = ParseArgs(argc, argv, 0); if (flags == D_XWINDOWS) { disp = XOpenDisplay(disp_name); if (!disp) { (void) fprintf(stderr, "%s: cannot open display `%s'\n", argv[0], disp_name); exit(1); } XSetErrorHandler(XErrHandler); } /* Set up hard-wired defaults and allocate spaces */ InitSets(flags); /* Read X defaults and override hard-coded defaults */ if (PM_INT("Output Device") == D_XWINDOWS) ReadDefaults(); /* Read the data into the data sets */ llx = lly = MAXFLOAT; urx = ury = -MAXFLOAT; for (idx = 0; idx < numFiles; idx++) { strm = fopen(inFileNames[idx], "r"); if (!strm) { (void) fprintf(stderr, "Warning: cannot open file `%s'\n", inFileNames[idx]); } else { if ((maxitems = ReadData(strm, inFileNames[idx])) < 0) { errs++; } (void) fclose(strm); } } if (!numFiles) { if ((maxitems = ReadData(stdin, (char *) 0)) < 0) { errs++; } } if (errs) { (void) fprintf(stderr, "Problems found with input data.\n"); exit(1); } /* Parse the argument list to set options */ (void) ParseArgs(argc, argv, 1); if (PM_BOOL("Animate")) param_set("TitleText",STR,"Animated X Graph"); if (maxitems == 0) { (void) fprintf(stderr, "Nothing to plot.\n"); exit(1); } Xsegs[0] = (XSegment *) Malloc((unsigned) (maxitems * sizeof(XSegment))); Xsegs[1] = (XSegment *) Malloc((unsigned) (maxitems * sizeof(XSegment))); /* Reverse Video Hack */ if (PM_BOOL("ReverseVideo")) ReverseIt(); hard_init(); if (PM_BOOL("Debug")) { if (PM_INT("Output Device") == D_XWINDOWS) (void) XSynchronize(disp, 1); param_dump(); } /* Logarithmic and bounding box computation */ flags = 0; if (PM_BOOL("LogX")) flags |= LOG_X; if (PM_BOOL("LogY")) flags |= LOG_Y; if (PM_BOOL("StackGraph")) flags |= STK; if (PM_BOOL("FitX")) flags |= FITX; if (PM_BOOL("FitY")) flags |= FITY; Traverse(flags); /* Nasty hack here for bar graphs */ if (PM_BOOL("BarGraph")) { double base; llx -= PM_DBL("BarWidth"); urx += PM_DBL("BarWidth"); base = PM_DBL("BarBase"); if (base < lly) lly = base; if (base > ury) ury = base; } /* Create initial window */ if (PM_INT("Output Device") == D_XWINDOWS) { double asp; asp = 1.0; xtb_init(disp, screen, PM_PIXEL("Foreground"), PM_PIXEL("Background"), PM_FONT("LabelFont")); primary = NewWindow(Prog_Name, PM_DBL("XLowLimit"), PM_DBL("YLowLimit"), PM_DBL("XHighLimit"), PM_DBL("YHighLimit"), asp,0); if (!primary) { (void) fprintf(stderr, "Main window would not open\n"); exit(1); } zoomCursor = XCreateFontCursor(disp, XC_sizing); fg_color = PM_COLOR("Foreground"); bg_color = PM_COLOR("Background"); XRecolorCursor(disp, zoomCursor, &fg_color, &bg_color); Num_Windows = 1; while (Num_Windows > 0) { XNextEvent(disp, &theEvent); if (xtb_dispatch(&theEvent) != XTB_NOTDEF) continue; if (XFindContext(theEvent.xany.display, theEvent.xany.window, win_context, (caddr_t *) & win_info)) { /* Nothing found */ continue; } switch (theEvent.type) { case Expose: if (theEvent.xexpose.count <= 0) { XWindowAttributes win_attr; XGetWindowAttributes(disp, theEvent.xany.window, &win_attr); win_info->dev_info.area_w = win_attr.width; win_info->dev_info.area_h = win_attr.height; init_X(win_info->dev_info.user_state); EraseData(win_info); DrawWindow(win_info); } break; case KeyPress: nbytes = XLookupString(&theEvent.xkey, keys, MAXKEYS, (KeySym *) 0, (XComposeStatus *) 0); for (idx = 0; idx < nbytes; idx++) { if (keys[idx] == CONTROL_D) { /* Delete this window */ DelWindow(theEvent.xkey.window, win_info); } else if (keys[idx] == CONTROL_C) { /* Exit program */ Num_Windows = 0; } else if (keys[idx] == 'h') { PrintWindow(theEvent.xany.window, win_info); } } break; case ButtonPress: /* Handle creating a new window */ Num_Windows += HandleZoom(Prog_Name, &theEvent.xbutton, win_info, zoomCursor); break; default: (void) fprintf(stderr, "Unknown event type: %x\n", theEvent.type); break; } } } else { int Device = PM_INT("Output Device"); int dflag = strcmp(PM_STR("Disposition"), "To Device") == 0; primary = NewWindow(Prog_Name, PM_DBL("XLowLimit"), PM_DBL("YLowLimit"), PM_DBL("XHighLimit"), PM_DBL("YHighLimit"), 1.0,0); do_hardcopy(Prog_Name, primary, hard_devices[Device].dev_init, dflag ? hard_devices[Device].dev_spec : 0, PM_STR("FileOrDev"), (double) 19, hard_devices[Device].dev_title_font, hard_devices[Device].dev_title_size, hard_devices[Device].dev_axis_font, hard_devices[Device].dev_axis_size, PM_BOOL("Document") * D_DOCU); } return 0; } #define BLACK_THRES 30000 static void ReversePix(param_name) char *param_name; /* Name of color parameter */ /* * Looks up `param_name' in the parameters database. If found, the * color is examined and judged to be either black or white based * upon its red, green, and blue intensities. The sense of the * color is then reversed and reset to its opposite. */ { params val; if (param_get(param_name, &val)) { if ((val.pixv.value.red < BLACK_THRES) && (val.pixv.value.green < BLACK_THRES) && (val.pixv.value.blue < BLACK_THRES)) { /* Color is black */ param_reset(param_name, "white"); } else { /* Color is white */ param_reset(param_name, "black"); } } else { (void) fprintf(stderr, "Cannot reverse color `%s'\n", param_name); } } static void ReverseIt() /* * This routine attempts to implement reverse video. It steps through * all of the important colors in the parameters database and makes * black white (and vice versa). */ { int i; char buf[1024]; for (i = 0; i < MAXATTR; i++) { (void) sprintf(buf, "%d.Color", i); ReversePix(buf); } ReversePix("Foreground"); ReversePix("Border"); ReversePix("ZeroColor"); ReversePix("Background"); } static void Traverse(flags) int flags; /* Options */ /* * Traverses through all of the data applying certain options to the * data and computing the overall bounding box. The flags are: * LOG_X Take the log of the X axis * LOG_Y Take the log of the Y axis * STK Stack coordinates. * FITX Fit x-coordinates from zero to one * FITY Fit y-coordinates from zero to one */ { int i, j; PointList *spot; PointList *pspot; static char *paramstr[] = { "Cannot plot negative %s values\n", "when the logarithmic option is selected.\n", "Number of points in %d and %d don't match for stacking.\n", "Point %d in %d and %d doesn't match for stacking.\n", "Set %d has 0 %s.\n" }; if (flags & (FITX|FITY)) for (i = 0; i < MAXSETS; i++) for (spot = PlotData[i].list; spot; spot = spot->next) { float minx, maxx, miny, maxy; minx = maxx = spot->xvec[0]; maxy = miny = spot->yvec[0]; for (j = 1; j < spot->numPoints; j++) { minx = MIN(minx, spot->xvec[j]); miny = MIN(miny, spot->yvec[j]); maxx = MAX(maxx, spot->xvec[j]); maxy = MAX(maxy, spot->yvec[j]); } maxx = maxx - minx; maxy = maxy - miny; if (maxx == 0.0) { (void) fprintf(stderr, paramstr[3], i, "width"); maxx = 1.0; } if (maxy == 0.0) { (void) fprintf(stderr, paramstr[3], i, "height"); maxy = 1.0; } switch (flags & (FITX|FITY)) { case FITX: for (j = 0; j < spot->numPoints; j++) spot->xvec[j] = (-minx + spot->xvec[j]) / maxx; break; case FITY: for (j = 0; j < spot->numPoints; j++) spot->yvec[j] = (-miny + spot->yvec[j]) / maxy; break; case FITX|FITY: for (j = 0; j < spot->numPoints; j++) { spot->xvec[j] = (-minx + spot->xvec[j]) / maxx; spot->yvec[j] = (-miny + spot->yvec[j]) / maxy; } break; default: abort(); } } if (flags & STK) for (i = 1; i < MAXSETS; i++) { for (spot = PlotData[i].list, pspot = PlotData[i - 1].list; spot && pspot; spot = spot->next, pspot = pspot->next) { if (spot->numPoints != pspot->numPoints) { (void) fprintf(stderr, paramstr[2], i - 1, i); exit(1); } for (j = 0; j < spot->numPoints; j++) { if (spot->xvec[j] != pspot->xvec[j]) { (void) fprintf(stderr, paramstr[3], j, i - 1, i); exit(1); } spot->yvec[j] += pspot->yvec[j]; } } } for (i = 0; i < MAXSETS; i++) { for (spot = PlotData[i].list; spot; spot = spot->next) { for (j = 0; j < spot->numPoints; j++) { if (flags & LOG_Y) { if (spot->yvec[j] > 0.0) { spot->yvec[j] = log10(spot->yvec[j]); } else if (spot->yvec[j] == 0) spot->yvec[j] = 0.0; else { (void) fprintf(stderr, paramstr[0], "Y"); (void) fprintf(stderr, paramstr[1]); exit(1); } } if (flags & LOG_X) { if (spot->xvec[j] > 0.0) { spot->xvec[j] = log10(spot->xvec[j]); } else if (spot->xvec[j] == 0) spot->xvec[j] = 0.0; else { (void) fprintf(stderr, paramstr[0], "X"); (void) fprintf(stderr, paramstr[1]); exit(1); } } /* Update global bounding box */ if (spot->xvec[j] < llx) llx = spot->xvec[j]; if (spot->xvec[j] > urx) urx = spot->xvec[j]; if (spot->yvec[j] < lly) lly = spot->yvec[j]; if (spot->yvec[j] > ury) ury = spot->yvec[j]; } } } } /* * Button handling functions */ /*ARGSUSED*/ xtb_hret del_func(win, bval, info) Window win; /* Button window */ int bval; /* Button value */ char *info; /* User information */ /* * This routine is called when the `Close' button is pressed in * an xgraph window. It causes the window to go away. */ { Window the_win = (Window) info; LocalWin *win_info; xtb_bt_set(win, 1, (char *) 0, 0); if (!XFindContext(disp, the_win, win_context, (caddr_t *) & win_info)) { if (win_info->flags & HARDCOPY_IN_PROGRESS) { do_error("Can't close window while\nhardcopy dialog is posted.\n"); xtb_bt_set(win, 0, (char *) 0, 0); } else { DelWindow(the_win, win_info); } } return XTB_HANDLED; } /*ARGSUSED*/ xtb_hret hcpy_func(win, bval, info) Window win; /* Button Window */ int bval; /* Button value */ char *info; /* User Information */ /* * This routine is called when the hardcopy button is pressed * in an xgraph window. It causes the output dialog to be * posted. */ { Window the_win = (Window) info; LocalWin *win_info; xtb_bt_set(win, 1, (char *) 0, 0); if (!XFindContext(disp, the_win, win_context, (caddr_t *) & win_info)) { win_info->flags |= HARDCOPY_IN_PROGRESS; PrintWindow(the_win, win_info); win_info->flags &= (~HARDCOPY_IN_PROGRESS); } xtb_bt_set(win, 0, (char *) 0, 0); return XTB_HANDLED; } static /*ARGSUSED*/ xtb_hret abt_func(win, bval, info) Window win; /* Button window */ int bval; /* Button value */ char *info; /* User information */ { static char *msg_fmt = "Version %s\n\ XGraph + Animation and Derivatives\n\ Modification of code by David Harrison\n\ University of California, Berkeley\n\ (davidh@ic.Berkeley.EDU or \n\ ...!ucbvax!ucbic!davidh)\n\ Animation, differentiation, and a few other\n\ new features added by Paul Walker,\n\ National Center for Supercomputer Applications\n\ and Univ. Illinois at U-C Dept of Physics.\n\ Send comments or suggestions to\n\ pwalker@ncsa.uiuc.edu\n"; static int active = 0; char msg_buf[1024]; if (!active) { active = 1; xtb_bt_set(win, 1, (char *) 0, 0); (void) sprintf(msg_buf, msg_fmt, VERSION_STRING); msg_box("XGraph", msg_buf); xtb_bt_set(win, 0, (char *) 0, 0); active = 0; } return XTB_HANDLED; } #ifdef DO_DER static /*ARGSUSED PW*/ xtb_hret rew_func(win, bval, info) Window win; /* Button window */ int bval; /* Button value */ char *info; /* User information */ { /* This routine added, Paul Walker, to rewind the animation and start it over. The only even moderatly tricky part is erasing the last item, which still lives, and redrawing the axis. I do it by just copying the "Expose" information from the main routine. */ Window the_win = (Window) info; LocalWin *win_info; /* Set animation to True */ param_set("Animate",BOOL,"on"); if (!XFindContext(disp, the_win, win_context, (caddr_t *) & win_info)) { XWindowAttributes win_attr; XGetWindowAttributes(disp, the_win, &win_attr); win_info->dev_info.area_w = win_attr.width; win_info->dev_info.area_h = win_attr.height; init_X(win_info->dev_info.user_state); EraseData (win_info); DrawWindow(win_info); } return XTB_HANDLED; } static /*ARGSUSED PW*/ xtb_hret der_func(win, bval, info) Window win; /* Button window */ int bval; /* Button value */ char *info; /* User information */ { /* This routine added, Paul Walker, to rewind the animation and start it over. The only even moderatly tricky part is erasing the last item, which still lives, and redrawing the axis. I do it by just copying the "Expose" information from the main routine. */ Window the_win = (Window) info; Window new_win; LocalWin *win_info; double loX,loY,hiX,hiY,asp; static char *msg_fmt = "Version %s\n\ Currently unable to display\n\ or calculate derivatives\n\ higher than 2nd order\n"; static int active = 0; char msg_buf[1024]; XFindContext(disp, the_win, win_context, (caddr_t *) & win_info); if (win_info->DOrder == 2) { if (!active) { active = 1; xtb_bt_set(win, 1, (char *) 0, 0); (void) sprintf(msg_buf, msg_fmt, VERSION_STRING); msg_box("XGraph", msg_buf); xtb_bt_set(win, 0, (char *) 0, 0); active = 0; } return XTB_HANDLED; } Num_Windows += 1; asp = 1.0; Bounds(&loX,&loY,&hiX,&hiY,win_info->DOrder+1); new_win = NewWindow("Derivatives", loX, loY, hiX, hiY, asp, win_info->DOrder+1); if (!XFindContext(disp, new_win, win_context, (caddr_t *) & win_info)) { XWindowAttributes win_attr; XGetWindowAttributes(disp, new_win, &win_attr); win_info->dev_info.area_w = win_attr.width; win_info->dev_info.area_h = win_attr.height; init_X(win_info->dev_info.user_state); EraseData (win_info); DrawWindow(win_info); } return XTB_HANDLED; } static /*ARGSUSED PW*/ xtb_hret rpl_func(win, bval, info) Window win; /* Button window */ int bval; /* Button value */ char *info; /* User information */ { /* Puts us back into static mode ... */ Window the_win = (Window) info; LocalWin *win_info; /* Set animation to True */ param_set("Animate",BOOL,"off"); if (!XFindContext(disp, the_win, win_context, (caddr_t *) & win_info)) { XWindowAttributes win_attr; XGetWindowAttributes(disp, the_win, &win_attr); win_info->dev_info.area_w = win_attr.width; win_info->dev_info.area_h = win_attr.height; init_X(win_info->dev_info.user_state); EraseData (win_info); DrawWindow(win_info); } return XTB_HANDLED; } /* End change PW */ #endif /* DO_DER */ #define NORMSIZE 600 #define MINDIM 100 Window NewWindow(progname, lowX, lowY, upX, upY, asp, DO) char *progname; /* Name of program */ double lowX, lowY; /* Lower left corner */ double upX, upY; /* Upper right corner */ double asp; /* Aspect ratio */ int DO; /* Derivative Order. */ /* * Creates and maps a new window. This includes allocating its * local structure and associating it with the XId for the window. * The aspect ratio is specified as the ratio of width over height. */ { Window new_window; LocalWin *new_info; static Cursor theCursor = (Cursor) 0; XSizeHints sizehints; XSetWindowAttributes wattr; XWMHints wmhints; XColor fg_color, bg_color; int geo_mask; int width, height; unsigned long wamask; char defSpec[120]; double pad; new_info = (LocalWin *) Malloc(sizeof(LocalWin)); new_info->DOrder = DO; if (upX > lowX) { new_info->loX = lowX; new_info->hiX = upX; } else { new_info->loX = llx; new_info->hiX = urx; } if (upY > lowY) { new_info->loY = lowY; new_info->hiY = upY; } else { new_info->loY = lly; new_info->hiY = ury; } /* Increase the padding for aesthetics */ if (new_info->hiX - new_info->loX == 0.0) { pad = MAX(0.5, fabs(new_info->hiX / 2.0)); new_info->hiX += pad; new_info->loX -= pad; } if (new_info->hiY - new_info->loY == 0) { pad = MAX(0.5, fabs(ury / 2.0)); new_info->hiY += pad; new_info->loY -= pad; } /* Add 10% padding to bounding box (div by 20 yeilds 5%) */ pad = (new_info->hiX - new_info->loX) / 20.0; new_info->loX -= pad; new_info->hiX += pad; pad = (new_info->hiY - new_info->loY) / 20.0; new_info->loY -= pad; new_info->hiY += pad; /* Aspect ratio computation */ if (asp < 1.0) { height = NORMSIZE; width = ((int) (((double) NORMSIZE) * asp)); } else { width = NORMSIZE; height = ((int) (((double) NORMSIZE) / asp)); } height = MAX(MINDIM, height); width = MAX(MINDIM, width); if (PM_INT("Output Device") == D_XWINDOWS) { (void) sprintf(defSpec, "%dx%d+100+100", width, height); wamask = CWBackPixel | CWBorderPixel | CWColormap; wattr.background_pixel = PM_PIXEL("Background"); wattr.border_pixel = PM_PIXEL("Border"); wattr.colormap = cmap; sizehints.flags = PPosition | PSize; sizehints.x = sizehints.y = 100; sizehints.width = width; sizehints.height = height; geo_mask = XParseGeometry(PM_STR("Geometry"), &sizehints.x, &sizehints.y, (unsigned int *) &sizehints.width, (unsigned int *) &sizehints.height); if (geo_mask & (XValue|YValue)) sizehints.flags = (sizehints.flags & ~PPosition) | USPosition; if (geo_mask & (WidthValue | HeightValue)) sizehints.flags = (sizehints.flags & ~PSize) | USSize; new_window = XCreateWindow(disp, RootWindow(disp, screen), sizehints.x, sizehints.y, (unsigned int) sizehints.width, (unsigned int) sizehints.height, (unsigned int) PM_INT("BorderSize"), depth, InputOutput, vis, wamask, &wattr); if (new_window) { xtb_frame cl_frame, hd_frame, ab_frame, rw_frame, rp_frame, dx_frame; XStoreName(disp, new_window, progname); XSetIconName(disp, new_window, progname); wmhints.flags = InputHint | StateHint; wmhints.input = True; wmhints.initial_state = NormalState; XSetWMHints(disp, new_window, &wmhints); XSetWMNormalHints(disp, new_window, &sizehints); /* Set device info */ set_X(new_window, &(new_info->dev_info)); if (!PM_BOOL("NoButton")) { /* Make buttons */ xtb_bt_new(new_window, "Close", del_func, (xtb_data) new_window, &cl_frame); new_info->close = cl_frame.win; XMoveWindow(disp, new_info->close, (int) BTNPAD, (int) BTNPAD); xtb_bt_new(new_window, "Hdcpy", hcpy_func, (xtb_data) new_window, &hd_frame); new_info->hardcopy = hd_frame.win; XMoveWindow(disp, new_info->hardcopy, (int) (BTNPAD + cl_frame.width + BTNINTER), BTNPAD); xtb_bt_new(new_window, "About", abt_func, (xtb_data) new_window, &ab_frame); new_info->about = ab_frame.win; XMoveWindow(disp, new_info->about, (int) (BTNPAD + cl_frame.width + BTNINTER + hd_frame.width + BTNINTER), BTNPAD); #ifdef DO_DER /* These buttons added PW */ xtb_bt_new(new_window, "Anim", rew_func, (xtb_data) new_window, &rw_frame); new_info->rewind = rw_frame.win; XMoveWindow(disp, new_info->rewind, (int) (BTNPAD + cl_frame.width + BTNINTER + hd_frame.width + BTNINTER + ab_frame.width + BTNINTER), BTNPAD); xtb_bt_new(new_window, "Replot", rpl_func, (xtb_data) new_window, &rp_frame); new_info->replot = rp_frame.win; XMoveWindow(disp, new_info->replot, (int) (BTNPAD + cl_frame.width + BTNINTER + hd_frame.width + BTNINTER + ab_frame.width + BTNINTER + rw_frame.width + BTNINTER), BTNPAD); xtb_bt_new(new_window, "Deriv", der_func, (xtb_data) new_window, &dx_frame); new_info->deriv = dx_frame.win; XMoveWindow(disp, new_info->deriv, (int) (BTNPAD + cl_frame.width + BTNINTER + hd_frame.width + BTNINTER + ab_frame.width + BTNINTER + rw_frame.width + BTNINTER + rp_frame.width + BTNINTER), BTNPAD); #endif /* DO_DER */ new_info->flags = 0; } XSelectInput(disp, new_window, ExposureMask | KeyPressMask | ButtonPressMask); if (!theCursor) { theCursor = XCreateFontCursor(disp, XC_top_left_arrow); fg_color = PM_COLOR("Foreground"); bg_color = PM_COLOR("Background"); XRecolorCursor(disp, theCursor, &fg_color, &bg_color); } XDefineCursor(disp, new_window, theCursor); if (!win_context) { win_context = XUniqueContext(); } XSaveContext(disp, new_window, win_context, (caddr_t) new_info); XMapWindow(disp, new_window); return new_window; } else { return (Window) 0; } } else { new_info->dev_info.area_h = 1.0; new_info->dev_info.area_w = 1.0; return ((Window) new_info); } } DelWindow(win, win_info) Window win; /* Window */ LocalWin *win_info; /* Local Info */ /* * This routine actually deletes the specified window and * decrements the window count. */ { xtb_data info; XDeleteContext(disp, win, win_context); xtb_bt_del(win_info->close, &info); xtb_bt_del(win_info->hardcopy, &info); xtb_bt_del(win_info->about, &info); Free((char *) win_info); XDestroyWindow(disp, win); Num_Windows -= 1; } PrintWindow(win, win_info) Window win; /* Window */ LocalWin *win_info; /* Local Info */ /* * This routine posts a dialog asking about the hardcopy * options desired. If the user hits `OK', the hard * copy is performed. */ { ho_dialog(win, Prog_Name, (char *) win_info); } static XRectangle boxEcho; static GC echoGC = (GC) 0; #define DRAWBOX \ if (startX < curX) { \ boxEcho.x = startX; \ boxEcho.width = curX - startX; \ } else { \ boxEcho.x = curX; \ boxEcho.width = startX - curX; \ } \ if (startY < curY) { \ boxEcho.y = startY; \ boxEcho.height = curY - startY; \ } else { \ boxEcho.y = curY; \ boxEcho.height = startY - curY; \ } \ XDrawRectangles(disp, win, echoGC, &boxEcho, 1); #define TRANX(xval) \ (((double) ((xval) - wi->XOrgX)) * wi->XUnitsPerPixel + wi->UsrOrgX) #define TRANY(yval) \ (wi->UsrOppY - (((double) ((yval) - wi->XOrgY)) * wi->YUnitsPerPixel)) int HandleZoom(progname, evt, wi, cur) char *progname; XButtonPressedEvent *evt; LocalWin *wi; Cursor cur; { Window win, new_win; Window root_rtn, child_rtn; XEvent theEvent; int startX, startY, curX, curY, newX, newY, stopFlag, numwin = 0; int root_x, root_y; unsigned int mask_rtn; double loX, loY, hiX, hiY, asp; win = evt->window; if (XGrabPointer(disp, win, True, (unsigned int) (ButtonPressMask | ButtonReleaseMask | PointerMotionMask | PointerMotionHintMask), GrabModeAsync, GrabModeAsync, win, cur, CurrentTime) != GrabSuccess) { XBell(disp, 0); return 0; } if (echoGC == (GC) 0) { unsigned long gcmask; XGCValues gcvals; gcmask = GCForeground | GCFunction; gcvals.foreground = PM_PIXEL("ZeroColor") ^ PM_PIXEL("Background"); gcvals.function = GXxor; echoGC = XCreateGC(disp, win, gcmask, &gcvals); } startX = evt->x; startY = evt->y; XQueryPointer(disp, win, &root_rtn, &child_rtn, &root_x, &root_y, &curX, &curY, &mask_rtn); /* Draw first box */ DRAWBOX; stopFlag = 0; while (!stopFlag) { XNextEvent(disp, &theEvent); switch (theEvent.xany.type) { case MotionNotify: XQueryPointer(disp, win, &root_rtn, &child_rtn, &root_x, &root_y, &newX, &newY, &mask_rtn); /* Undraw the old one */ DRAWBOX; /* Draw the new one */ curX = newX; curY = newY; DRAWBOX; break; case ButtonRelease: DRAWBOX; XUngrabPointer(disp, CurrentTime); stopFlag = 1; if ((startX - curX != 0) && (startY - curY != 0)) { /* Figure out relative bounding box */ loX = TRANX(startX); loY = TRANY(startY); hiX = TRANX(curX); hiY = TRANY(curY); if (loX > hiX) { double temp; temp = hiX; hiX = loX; loX = temp; } if (loY > hiY) { double temp; temp = hiY; hiY = loY; loY = temp; } /* physical aspect ratio */ asp = ((double) ABS(startX - curX)) / ((double) ABS(startY - curY)); new_win = NewWindow(progname, loX, loY, hiX, hiY, asp, wi->DOrder); if (new_win) { numwin = 1; } else { numwin = 0; } } else { numwin = 0; } break; default: printf("unknown event: %d\n", theEvent.xany.type); break; } } return numwin; } #define RND(val) ((int) ((val) + 0.5)) /*ARGSUSED*/ void do_hardcopy(prog, info, init_fun, dev_spec, file_or_dev, maxdim, ti_fam, ti_size, ax_fam, ax_size, doc_p) char *prog; /* Program name for Xdefaults */ char *info; /* Some state information */ int (*init_fun) (); /* Hardcopy init function */ char *dev_spec; /* Device specification (if any) */ char *file_or_dev; /* Filename or device spec */ double maxdim; /* Maximum dimension in cm */ char *ti_fam, *ax_fam; /* Font family names */ double ti_size, ax_size; /* Font sizes in points */ int doc_p; /* Documentation predicate */ /* * This routine resets the function pointers to those specified * by `init_fun' and causes a screen redisplay. If `dev_spec' * is non-zero, it will be considered a sprintf string with * one %s which will be filled in with `file_or_dev' and fed * to popen(3) to obtain a stream. Otherwise, `file_or_dev' * is considered to be a file and is opened for writing. The * resulting stream is fed to the initialization routine for * the device. */ { LocalWin *curWin = (LocalWin *) info; LocalWin thisWin; FILE *out_stream; char buf[MAXBUFSIZE], err[MAXBUFSIZE], ierr[ERRBUFSIZE]; char tilde[MAXBUFSIZE * 10]; int final_w, final_h, flags; double ratio; if (dev_spec) { (void) sprintf(buf, dev_spec, file_or_dev); out_stream = popen(buf, "w"); if (!out_stream) { sprintf(err, "Unable to issue command:\n %s\n", buf); do_error(err); return; } } else { tildeExpand(tilde, file_or_dev); out_stream = fopen(tilde, "w"); if (!out_stream) { sprintf(err, "Unable to open file `%s'\n", tilde); do_error(err); return; } } if (curWin != (LocalWin *) 0) { thisWin = *curWin; ratio = ((double) thisWin.dev_info.area_w) / ((double) thisWin.dev_info.area_h); } else ratio = 1.0; if (thisWin.dev_info.area_w > thisWin.dev_info.area_h) { final_w = RND(maxdim * 10000.0 * PM_DBL("Scale")); final_h = RND(maxdim / ratio * 10000.0 * PM_DBL("Scale")); } else { final_w = RND(maxdim * ratio * 10000.0 * PM_DBL("Scale")); final_h = RND(maxdim * 10000.0 * PM_DBL("Scale")); } ierr[0] = '\0'; flags = 0; if (doc_p) flags |= D_DOCU; if ((*init_fun) (out_stream, final_w, final_h, ti_fam, ti_size, ax_fam, ax_size, flags, &(thisWin.dev_info), ierr)) { DrawWindow(&thisWin); if (thisWin.dev_info.xg_end) { thisWin.dev_info.xg_end(thisWin.dev_info.user_state); } } else { do_error(ierr); } if (dev_spec) { (void) pclose(out_stream); } else { (void) fclose(out_stream); } } static char * tildeExpand(out, in) char *out; /* Output space for expanded file name */ char *in; /* Filename with tilde */ /* * This routine expands out a file name passed in `in' and places * the expanded version in `out'. It returns `out'. */ { char username[50], *userPntr; struct passwd *userRecord; out[0] = '\0'; /* Skip over the white space in the initial path */ while ((*in == ' ') ||(*in == '\t')) in ++; /* Tilde? */ if (in[0] == TILDE) { /* Copy user name into 'username' */ in ++; userPntr = &(username[0]); while ((*in !='\0') &&(*in !='/')) { *(userPntr++) = *(in ++); } *(userPntr) = '\0'; /* See if we have to fill in the user name ourselves */ if (strlen(username) == 0) { userRecord = getpwuid(getuid()); } else { userRecord = getpwnam(username); } if (userRecord) { /* Found user in passwd file. Concatenate user directory */ strcat(out, userRecord->pw_dir); } } /* Concantenate remaining portion of file name */ strcat(out, in); return out; } #define ERR_MSG_SIZE 2048 /*ARGSUSED*/ static int XErrHandler(disp_ptr, evt) Display *disp_ptr; XErrorEvent *evt; /* * Displays a nicely formatted message and core dumps. */ { char err_buf[ERR_MSG_SIZE], mesg[ERR_MSG_SIZE], number[ERR_MSG_SIZE]; char *mtype = "XlibMessage"; XGetErrorText(disp_ptr, evt->error_code, err_buf, ERR_MSG_SIZE); (void) fprintf(stderr, "X Error: %s\n", err_buf); XGetErrorDatabaseText(disp_ptr, mtype, "MajorCode", "Request Major code %d", mesg, ERR_MSG_SIZE); (void) fprintf(stderr, mesg, evt->request_code); (void) sprintf(number, "%d", evt->request_code); XGetErrorDatabaseText(disp_ptr, "XRequest", number, "", err_buf, ERR_MSG_SIZE); (void) fprintf(stderr, " (%s)\n", err_buf); abort(); } xgraph-12.1.orig/xgraph.h0100775000175000000620000001257607360237512013777 0ustar bapstaff/* * Globally accessible information from xgraph */ #ifndef _XGRAPH_H_ #define _XGRAPH_H_ #include "autoconf.h" #include #include #include #include /* * Get definitions from headers. */ #include /* sprintf */ #ifdef HAVE_STRING_H #include /* str* */ #else #ifdef HAVE_STRINGS_H #include /* str* */ #else extern char *strcpy(); extern char *strcat(); extern char *rindex(); extern char *index(); #endif /* HAVE_STRINGS_H */ #endif /* HAVE_STRING_H */ #ifdef HAVE_UNISTD_H #include /* exit, abort */ #endif /* HAVE_UNISTD_H */ #ifdef HAVE_STDLIB_H #include /* atof */ #endif /* HAVE_STDLIB_H */ #include "xgout.h" #define VERSION_STRING "12.1 December 1999 " #define MAXKEYS 50 #define MAXATTR 8 #define MAXSETS 112 #define MAXBUFSIZE 120 #define MAXLS 50 #define STRDUP(xx) (strcpy(Malloc((unsigned) (strlen(xx)+1)), (xx))) #define SCREENX(ws, userX) \ (((int) (((userX) - ws->UsrOrgX)/ws->XUnitsPerPixel + 0.5)) + ws->XOrgX) #define SCREENY(ws, userY) \ (ws->XOppY - ((int) (((userY) - ws->UsrOrgY)/ws->YUnitsPerPixel + 0.5))) #define HARDCOPY_IN_PROGRESS 0x01 /* Portability */ /* try to get those constants */ #include #ifdef HAVE_LIMITS_H #include #endif /* HAVE_LIMITS */ #ifdef HAVE_FLOAT_H #include #endif /* HAVE_FLOAT_H */ #ifdef CRAY #undef MAXFLOAT #define MAXFLOAT 10.e300 #endif /* CRAY */ #ifndef MAXFLOAT #if defined(FLT_MAX) #define MAXFLOAT FLT_MAX #elif defined(HUGE) #define MAXFLOAT HUGE #endif #endif #ifndef BIGINT #if defined(INT_MAX) #define BIGINT INT_MAX #elif defined(MAXINT) #define BIGINT MAXINT #else #define BIGINT 0xffffffff #endif #endif #define GRIDPOWER 10 #define INITSIZE 128 #define CONTROL_D '\004' #define CONTROL_C '\003' #define TILDE '~' #define BTNPAD 1 #define BTNINTER 3 #ifndef MAX #define MAX(a,b) ((a) > (b) ? (a) : (b)) #endif #ifndef MIN #define MIN(a,b) ((a) < (b) ? (a) : (b)) #endif #ifndef ABS #define ABS(x) ((x) < 0 ? -(x) : (x)) #endif #define ZERO_THRES 1.0E-07 /* To get around an inaccurate log */ #define nlog10(x) (x == 0.0 ? 0.0 : log10(x) + 1e-15) #define ISCOLOR (wi->dev_info.dev_flags & D_COLOR) #define PIXVALUE(set) ((set) % MAXATTR) #define LINESTYLE(set) \ (ISCOLOR ? ((set)/MAXATTR) : ((set) % MAXATTR)) #define MARKSTYLE(set) \ (colorMark ? COLMARK(set) : BWMARK(set)) #define COLMARK(set) \ ((set) / MAXATTR) #define BWMARK(set) \ ((set) % MAXATTR) #define LOG_X 0x01 #define LOG_Y 0x02 #define STK 0x04 #define FITX 0x08 #define FITY 0x10 typedef unsigned long Pixel; /* Globally accessible values */ extern Display *disp; /* Open display */ extern Visual *vis; /* Standard visual */ extern Colormap cmap; /* Standard colormap */ extern int screen; /* Screen number */ extern int depth; /* Depth of screen */ extern void do_hardcopy(); /* Carries out hardcopy */ extern void ho_dialog(); /* Hardcopy dialog */ extern void set_X(); /* Initializes X device */ typedef struct point_list { int numPoints; /* Number of points in group */ int allocSize; /* Allocated size */ double *xvec; /* X values */ double *yvec; /* Y values */ struct point_list *next; /* Next set of points */ } PointList; typedef struct new_data_set { char *setName; /* Name of data set */ PointList *list; /* List of point arrays */ } NewDataSet; typedef struct local_win { double loX, loY, hiX, hiY; /* Local bounding box of window */ int XOrgX, XOrgY; /* Origin of bounding box on screen */ int XOppX, XOppY; /* Other point defining bounding box */ double UsrOrgX, UsrOrgY; /* Origin of bounding box in user space */ double UsrOppX, UsrOppY; /* Other point of bounding box */ double XUnitsPerPixel; /* X Axis scale factor */ double YUnitsPerPixel; /* Y Axis scale factor */ struct xg_out dev_info; /* Device information */ Window close, hardcopy; /* Buttons for closing and hardcopy */ Window about; /* Version information */ Window rewind; /* PW Added this, for animation. */ Window replot; /* PW Added this, for animation. */ Window deriv; /* PW Added this, for animation. */ int flags; /* Window flags */ int DOrder; /* Which order of Derivative is being set? */ } LocalWin; extern NewDataSet PlotData[MAXSETS], DataD1[MAXSETS], DataD2[MAXSETS]; extern XSegment *Xsegs[2]; /* Point space for X */ extern double llx, lly, urx, ury; /* Bounding box of all data */ extern int numFiles; /* Number of input files */ extern char *inFileNames[MAXSETS]; /* File names */ /* Total number of active windows */ extern int Num_Windows; extern char *Prog_Name; extern char *disp_name; /* To make lint happy */ extern char *Malloc(); extern char *Realloc(); extern void Free(); #ifndef _POSIX_SOURCE /* extern int sprintf(); ---conflicts with sunos */ extern void exit(); extern double atof(); extern void abort(); #endif /* _POSIX_SOURCE */ #endif /* _XGRAPH_H_ */ xgraph-12.1.orig/xgraph.man0100664000175000000620000003273107360237512014313 0ustar bapstaff.TH XGRAPH 1 "December, 1989" .SH NAME xgraph \- Draw a graph on an X11 Display .SH SYNOPSIS .B xgraph [ options ] [[-geometry |=]WxH+X+Y ] [ -display host:display.screen ] [ file ... ] .SH DESCRIPTION The .I xgraph program draws a graph on an X display given data read from either data files or from standard input if no files are specified. It can display up to 64 independent data sets using different colors and/or line styles for each set. It annotates the graph with a title, axis labels, grid lines or tick marks, grid labels, and a legend. There are options to control the appearance of most components of the graph. .PP The input format is similar to .I graph(1G) but differs slightly. The data consists of a number of .I "data sets." Data sets are separated by a blank line. A new data set is also assumed at the start of each input file. A data set consists of an ordered list of points of the form "{directive} X Y". The directive is either "draw" or "move" and can be omitted. If the directive is "draw", a line will be drawn between the previous point and the current point (if a line graph is chosen). Specifying a "move" directive tells xgraph not to draw a line between the points. If the directive is omitted, "draw" is assumed for all points in a data set except the first point where "move" is assumed. The "move" directive is used most often to allow discontinuous data in a data set. The name of a data set can be specified by enclosing the name in double quotes on a line by itself in the body of the data set. The trailing double quote is optional. Overall graphing options for the graph can be specified in data files by writing lines of the form "