From: hot@integow.uucp (Roland van Hout) Newsgroups: alt.sources Subject: PD plot(4) librarys (and hercules driver for interactive 386) part 9 of 9 Message-ID: <1397@integow.uucp> Date: 28 Oct 90 03:58:59 GMT #!/bin/sh # This is part 09 of a multipart archive if touch 2>&1 | fgrep '[-amc]' > /dev/null then TOUCH=touch else TOUCH=true fi # ============= tplot.sh ============== echo "x - extracting tplot.sh (Text)" sed 's/^X//' << 'SHAR_EOF' > tplot.sh && X#Add these lines to your tplot script in /usr/bin if you've X#installed /usr/lib/therc and the other drivers X Xcase $1 in X-T*) t=$1 X shift ;; X*) t=-T$TERM Xesac Xcase $t in X-T450) exec /usr/lib/t450 $*;; #standard AT&T no PD X-T300) exec /usr/lib/t300 $*;; #standard AT&T no PD X-T300S|-T300s) exec /usr/lib/t300s $*;; #standard AT&T no PD X-Tver) exec /usr/lib/vplot $*;; #standard AT&T no PD X-Ttek|-T4014) exec /usr/lib/t4014 $* ;; #standard AT&T no PD X-TReGIS|-Tvt330|-Tvt240|-Tvt340) exec /usr/lib/tReGIS $* ;; X-Thpgl | -Thp74* | -Thp75*) exec /usr/lib/tplothpgl $* ;; # | lp to plot X-Tlp | -Tplotlp | -Tlaser ) exec /usr/lib/tplotlp -h $* | lp -dlaser ;; # laser big picture X # -m and -l give a medium and small size output X-Tepson) exec /usr/lib/tplotlp -e $* | lp -depson ;; # epson picture X-Tibm) exec /usr/lib/tplotlp -i $* | lp -dibm ;; # ibm picture X-Therc) exec /usr/lib/therc $* ;; X-TCGI|-Tconsole|-Tansi) CGIPATH=/usr/lib/cgi;export CGIPATH X CGIDISP=vgabw;export CGIDISP; X /usr/lib/tCGI $* X read a &2; exit 1 Xesac SHAR_EOF $TOUCH -am 1026185890 tplot.sh && chmod 0644 tplot.sh || echo "restore of tplot.sh failed" set `wc -c tplot.sh`;Wc_c=$1 if test "$Wc_c" != "1115"; then echo original size 1115, current size $Wc_c fi # ============= plotlpus.h ============== echo "x - extracting plotlpus.h (Text)" sed 's/^X//' << 'SHAR_EOF' > plotlpus.h && X/* X include file to use the epson,ibm-proprinter and the laserjet X with the plot(4) graphic library X the switch is done via a variable printer this one must be defined X in your main program X these variables must be defined in the main-part of your programm X extern int no_fill; X int to_printer; EPSON || IBM_PRO || LASERLOW || LASERMED || LASERHIGH X X*/ X/* X * const.h X * X * Copyright (c) 1988 Environmental Defense Fund, Inc. X */ X X#define TRUE 1 X#define FALSE 0 X X/* Printer model: values of global var 'printer' */ X#define EPSON 1 /* Epson LQ 1500 */ X#define LASERLOW 2 /* HP LaserJet Plus low sized 5" x 6" */ X#define IBM_PRO 3 /* IBM Proprinter */ X#define LASERMED 4 /* HP LaserJet Plus med sized 8" x 6" */ X#define LASERHIGH 5 /* HP LaserJet Plus extra large 8" x 11"*/ X X int offx,offy; X int to_printer=TRUE; X int printer=LASERLOW; X float gxscrunch,gyscrunch; X X SHAR_EOF $TOUCH -am 1014215790 plotlpus.h && chmod 0644 plotlpus.h || echo "restore of plotlpus.h failed" set `wc -c plotlpus.h`;Wc_c=$1 if test "$Wc_c" != "885"; then echo original size 885, current size $Wc_c fi # ============= driver.c ============== echo "x - extracting driver.c (Text)" sed 's/^X//' << 'SHAR_EOF' > driver.c && X/* X * plot(1) clone. This filter implements the commands described in the X * V7 UNIX manual pages, using the gl graphics library routines. X * X * Author: Wietse Venema (wietse@wzv.UUCP) X * X * Options: -Tdevice, where device is one of: X * X * cga (CGA) cga adapter, low (high) resolution X * herc (HERC) hercules adapter, page 0 (page 1) X * ega ega adapter X * lp matrix printer X * lj laserjet printer X * X * The output device can also be specified with the GLMODE environment X * variable. See the gl graphics library documentation for details. X */ X/* changes to provide compatibility with Microport V386 3.0e X * W Hatch uunet!bts!bill X * 2/18/90 X */ X/* Xchanges to get it running on interactive 386 XR.P. van Hout uunet!mcsun!hp4nl!integow!hot!hot X*/ X X#include X/*#include */ X Xstatic void confirm(); X X/* X * If the output device is specified on the command line we pass it on to X * the gl library routines by setting the GLMODE environment variable... X */ X Xfloat deltx = 4095.0; Xfloat delty = 4095.0; X Xstruct Modetab { X char *modename; X int modeval; X}; X Xstruct Modetab modetab[] = { X#ifdef bla X "cga", CGA_COLOR_MODE, /* cga lo-res */ X "CGA", CGA_HI_RES_MODE, /* cga hi-res */ X "herc", HERC_P0_MODE, /* hercules page 0 */ X "HERC", HERC_P1_MODE, /* hercules page 1 */ X "ega", EGA_COLOR_MODE, /* ega */ X "lp", IBM_PRINTER, /* matrix printer */ X "lj", LJ_PRINTER, /* laserjet printer */ X#endif X 0, 0, X}; X X/* various shorthands */ X#ifdef V386 /* 16 bit integers output by uport V386 graph(1) */ X#define READ(x) fread((char *) &s_x, sizeof(s_x), 1, stdin);\ X x=s_x X#else X#define READ(x) fread((char *) &x, sizeof(x), 1, stdin) X#endif X#define READ2(a,b) READ(a); READ(b) X#define READ3(a,b,c) READ2(a,b); READ(c) X#define READ4(a,b,c,d) READ2(a,b); READ2(c,d); X#define READ6(a,b,c,d,e,f) READ4(a,b,c,d); READ2(e,f); X X/* X * Process the plotfile. The program terminates with a diagnostic X * in case of unrecognized data. X */ X Xmain(argc, argv) Xint argc; Xchar **argv; X{ X register struct Modetab *mp; X register int c; X char buf[BUFSIZ]; X int x, y, x0, y0, x1, y1, x2, y2, r, glmode; X#ifdef V386 X short int s_x, s_y, s_x0, s_y0, s_x1, s_y1, s_x2, s_y2, s_r, s_glmode; X#endif X static char envstring[] = "GLMODE=xxxxxx"; X int noconfirm; X noconfirm = 0; X /* process command-line arguments */ X X while (--argc && *++argv) { X#ifdef bla X if (strncmp(*argv, "-T", 2) == 0) { X for (mp = modetab; mp->modename; mp++) { X if (strcmp(*argv + 2, mp->modename) == 0) { X sprintf(envstring, "GLMODE=%d", glmode = mp->modeval); X putenv(envstring); X } X } X } else { X fprintf(stderr, "bad argument: %s\n", *argv); X exit(1); X } X#endif X if (strncmp(*argv, "-K", 2) == 0) noconfirm = 1; X } X X#ifndef unix X you may have to select binary mode for stdin X#endif X X /* process the plotfile */ X X openpl(); X X while ((c = getchar()) != EOF) { X#ifdef DBUG X fprintf(stderr, "c= %c, c(int)= %d\n",c,c); X fflush(stderr); X#endif X switch (c) { X case 'm': /* move */ X READ2(x, y); X#ifdef DBUG X fprintf(stderr, "x: %d, y: %d\n", x, y); X fflush(stderr); X#endif X move(x, y); X break; X case 'n': /* cont */ X READ2(x, y); X#ifdef DBUG X fprintf(stderr, "x: %d, y: %d\n", x, y); X fflush(stderr); X#endif X cont(x, y); X break; X case 'p': /* point */ X READ2(x, y); X#ifdef DBUG X fprintf(stderr, "x: %d, y: %d\n", x, y); X fflush(stderr); X#endif X point(x, y); X break; X case 'l': /* line */ X READ4(x1, y1, x2, y2); X#ifdef DBUG X fprintf(stderr, "x1: %d, y1: %d, x2: %d, y2: %d\n", x1, y1,x2,y2); X fflush(stderr); X#endif X line(x1, y1, x2, y2); X break; X case 't': /* label */ X { X register char *p = buf; X X /******** X while ((c = getchar()) != EOF && c) X *p++ = c; X *p = '\0'; X weh 2/18/90 --- incoming string is newline terminated X ********/ X gets(buf); X label(buf); X } X#ifdef DBUG X fprintf(stderr, "label: %s\n", buf); X fflush(stderr); X#endif X break; X case 'a': /* arc */ X READ6(x, y, x0, y0, x1, y1); X arc(x, y, x0, y0, x1, y1); X break; X case 'c': /* circle */ X READ3(x, y, r); X circle(x, y, r); X break; X case 'e': /* erase */ X/* if (glmode <= MAXVIDEO)*/ X if (!noconfirm) confirm(); X erase(); X break; X case 'f': /* linemod */ X gets(buf); X linemod(buf); X break; X case 's': /* space */ X READ4(x0, y0, x1, y1); X#ifdef DBUG X fprintf(stderr, "x0: %d, y0: %d, x1: %d, y1: %d\n", x0, y0,x1,y1); X fflush(stderr); X#endif X space(x0, y0, x1, y1); X break; X /* corrupt */ X default: X closepl(); X fprintf(stderr,"c= %c, %d corrupted plotfile -- giving up\n",c,c); X fflush(stderr); X exit(1); X }; /* end switch */ X } /* end while */ X X/* if (glmode <= MAXVIDEO)*/ X if (!noconfirm) confirm(); X else sleep(5); X closepl(); X exit(0); X /* NOTREACHED */ X} X X/* give them a chance before erase() or closepl() clobber the screen */ X Xstatic void confirm() X{ X FILE *fp; X int c; X X if (fp = fopen("/dev/tty", "r")) { X while ((c = getc(fp)) != EOF && c != '\n'); X fclose(fp); X } X} SHAR_EOF $TOUCH -am 1026194490 driver.c && chmod 0644 driver.c || echo "restore of driver.c failed" set `wc -c driver.c`;Wc_c=$1 if test "$Wc_c" != "5283"; then echo original size 5283, current size $Wc_c fi exit 0 -- UUCP: ..!uunet!mcsun!hp4nl!integow!hot or hot@integow.UUCP or hot@hot.mug Roland van Hout, Sr. software engineer, Integrity software consultants, Pelmolenlaan 16, 3447 GW Woerden, Netherlands, tel +31 3480-30131, fax +31 3480-30182