home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2012 < prev    next >
Encoding:
Internet Message Format  |  1990-12-28  |  9.0 KB

  1. From: hot@integow.uucp (Roland van Hout)
  2. Newsgroups: alt.sources
  3. Subject: PD plot(4) librarys (and hercules driver for interactive 386) part 9 of 9
  4. Message-ID: <1397@integow.uucp>
  5. Date: 28 Oct 90 03:58:59 GMT
  6.  
  7.  
  8.  
  9.  
  10. #!/bin/sh
  11. # This is part 09 of a multipart archive
  12. if touch 2>&1 | fgrep '[-amc]' > /dev/null
  13.  then TOUCH=touch
  14.  else TOUCH=true
  15. fi
  16. # ============= tplot.sh ==============
  17. echo "x - extracting tplot.sh (Text)"
  18. sed 's/^X//' << 'SHAR_EOF' > tplot.sh &&
  19. X#Add these lines to your tplot script in /usr/bin if you've
  20. X#installed /usr/lib/therc and the other drivers
  21. X
  22. Xcase $1 in
  23. X-T*)    t=$1
  24. X    shift ;;
  25. X*)    t=-T$TERM
  26. Xesac
  27. Xcase $t in
  28. X-T450)    exec /usr/lib/t450 $*;;            #standard AT&T no PD
  29. X-T300)    exec /usr/lib/t300 $*;;            #standard AT&T no PD
  30. X-T300S|-T300s)    exec /usr/lib/t300s $*;;    #standard AT&T no PD
  31. X-Tver)    exec /usr/lib/vplot $*;;        #standard AT&T no PD
  32. X-Ttek|-T4014)    exec /usr/lib/t4014 $* ;;    #standard AT&T no PD
  33. X-TReGIS|-Tvt330|-Tvt240|-Tvt340)    exec /usr/lib/tReGIS $* ;;
  34. X-Thpgl | -Thp74* | -Thp75*) exec /usr/lib/tplothpgl $*  ;; # | lp to plot
  35. X-Tlp | -Tplotlp | -Tlaser ) exec /usr/lib/tplotlp -h $* | lp -dlaser ;; # laser big picture
  36. X        # -m and -l give a medium and small size output
  37. X-Tepson) exec /usr/lib/tplotlp -e $* | lp -depson ;; # epson picture
  38. X-Tibm) exec /usr/lib/tplotlp -i $* | lp -dibm ;; # ibm picture
  39. X-Therc)    exec /usr/lib/therc $* ;;
  40. X-TCGI|-Tconsole|-Tansi)    CGIPATH=/usr/lib/cgi;export CGIPATH
  41. X            CGIDISP=vgabw;export CGIDISP;
  42. X            /usr/lib/tCGI $* 
  43. X            read a </dev/tty
  44. X            ;;
  45. X-Ttplot)    exec /bin/cat $* ;;
  46. X*)  echo terminal type not known 1>&2; exit 1
  47. Xesac
  48. SHAR_EOF
  49. $TOUCH -am 1026185890 tplot.sh &&
  50. chmod 0644 tplot.sh ||
  51. echo "restore of tplot.sh failed"
  52. set `wc -c tplot.sh`;Wc_c=$1
  53. if test "$Wc_c" != "1115"; then
  54.     echo original size 1115, current size $Wc_c
  55. fi
  56. # ============= plotlpus.h ==============
  57. echo "x - extracting plotlpus.h (Text)"
  58. sed 's/^X//' << 'SHAR_EOF' > plotlpus.h &&
  59. X/* 
  60. X    include  file to use the epson,ibm-proprinter and the laserjet
  61. X    with the plot(4) graphic library
  62. X    the switch is done via a variable printer this one must be defined
  63. X    in your main program
  64. X    these variables must be defined in the main-part of your programm
  65. X    extern int no_fill;
  66. X    int     to_printer; EPSON || IBM_PRO || LASERLOW || LASERMED || LASERHIGH
  67. X
  68. X*/
  69. X/*
  70. X * const.h
  71. X *
  72. X * Copyright (c) 1988 Environmental Defense Fund, Inc.
  73. X */
  74. X
  75. X#define TRUE 1
  76. X#define FALSE 0
  77. X
  78. X/* Printer model: values of global var 'printer' */
  79. X#define EPSON    1        /* Epson LQ 1500 */
  80. X#define LASERLOW 2        /* HP LaserJet Plus low sized 5" x 6" */
  81. X#define IBM_PRO  3        /* IBM Proprinter */
  82. X#define LASERMED 4        /* HP LaserJet Plus med sized 8" x 6" */
  83. X#define LASERHIGH 5        /* HP LaserJet Plus extra large 8" x 11"*/
  84. X
  85. X    int offx,offy;
  86. X    int to_printer=TRUE;
  87. X    int printer=LASERLOW;
  88. X    float gxscrunch,gyscrunch;
  89. X
  90. X
  91. SHAR_EOF
  92. $TOUCH -am 1014215790 plotlpus.h &&
  93. chmod 0644 plotlpus.h ||
  94. echo "restore of plotlpus.h failed"
  95. set `wc -c plotlpus.h`;Wc_c=$1
  96. if test "$Wc_c" != "885"; then
  97.     echo original size 885, current size $Wc_c
  98. fi
  99. # ============= driver.c ==============
  100. echo "x - extracting driver.c (Text)"
  101. sed 's/^X//' << 'SHAR_EOF' > driver.c &&
  102. X/*
  103. X * plot(1) clone. This filter implements the commands described in the 
  104. X * V7 UNIX manual pages, using the gl graphics library routines.
  105. X *
  106. X * Author: Wietse Venema (wietse@wzv.UUCP)
  107. X *
  108. X * Options: -Tdevice, where device is one of:
  109. X *
  110. X *    cga (CGA)    cga adapter, low (high) resolution
  111. X *    herc (HERC)    hercules adapter, page 0 (page 1)
  112. X *    ega        ega adapter
  113. X *    lp        matrix printer 
  114. X *    lj        laserjet printer
  115. X *
  116. X * The output device can also be specified with the GLMODE environment
  117. X * variable. See the gl graphics library documentation for details.
  118. X */
  119. X/* changes to provide compatibility with Microport V386 3.0e
  120. X * W Hatch  uunet!bts!bill
  121. X * 2/18/90
  122. X */
  123. X/*
  124. Xchanges to get it running on interactive 386
  125. XR.P. van Hout uunet!mcsun!hp4nl!integow!hot!hot
  126. X*/
  127. X
  128. X#include <stdio.h>
  129. X/*#include <modes.h>*/
  130. X
  131. Xstatic void     confirm();
  132. X
  133. X/*
  134. X * If the output device is specified on the command line we pass it on to
  135. X * the gl library routines by setting the GLMODE environment variable...
  136. X */
  137. X
  138. Xfloat deltx = 4095.0;
  139. Xfloat delty = 4095.0;
  140. X
  141. Xstruct Modetab {
  142. X    char           *modename;
  143. X    int             modeval;
  144. X};
  145. X
  146. Xstruct Modetab  modetab[] = {
  147. X#ifdef bla
  148. X    "cga",    CGA_COLOR_MODE,        /* cga lo-res */
  149. X    "CGA",    CGA_HI_RES_MODE,    /* cga hi-res */
  150. X    "herc",    HERC_P0_MODE,        /* hercules page 0 */
  151. X    "HERC",    HERC_P1_MODE,        /* hercules page 1 */
  152. X    "ega",    EGA_COLOR_MODE,        /* ega */
  153. X    "lp",    IBM_PRINTER,        /* matrix printer */
  154. X    "lj",    LJ_PRINTER,        /* laserjet printer */
  155. X#endif
  156. X    0, 0,
  157. X};
  158. X
  159. X/* various shorthands */
  160. X#ifdef V386        /* 16 bit integers output by uport V386 graph(1) */
  161. X#define    READ(x)            fread((char *) &s_x, sizeof(s_x), 1, stdin);\
  162. X                    x=s_x
  163. X#else
  164. X#define    READ(x)            fread((char *) &x, sizeof(x), 1, stdin)
  165. X#endif
  166. X#define    READ2(a,b)        READ(a); READ(b)
  167. X#define    READ3(a,b,c)        READ2(a,b); READ(c)
  168. X#define    READ4(a,b,c,d)        READ2(a,b); READ2(c,d);
  169. X#define    READ6(a,b,c,d,e,f)    READ4(a,b,c,d); READ2(e,f);
  170. X
  171. X/* 
  172. X * Process the plotfile. The program terminates with a diagnostic
  173. X * in case of unrecognized data.
  174. X */
  175. X
  176. Xmain(argc, argv)
  177. Xint             argc;
  178. Xchar          **argv;
  179. X{
  180. X    register struct Modetab *mp;
  181. X    register int    c;
  182. X    char            buf[BUFSIZ];
  183. X    int             x, y, x0, y0, x1, y1, x2, y2, r, glmode;
  184. X#ifdef V386
  185. X    short int       s_x, s_y, s_x0, s_y0, s_x1, s_y1, s_x2, s_y2, s_r, s_glmode;
  186. X#endif
  187. X    static char     envstring[] = "GLMODE=xxxxxx";
  188. X    int noconfirm;
  189. X    noconfirm = 0;
  190. X    /* process command-line arguments */
  191. X
  192. X    while (--argc && *++argv) {
  193. X#ifdef bla
  194. X    if (strncmp(*argv, "-T", 2) == 0) {
  195. X        for (mp = modetab; mp->modename; mp++) {
  196. X        if (strcmp(*argv + 2, mp->modename) == 0) {
  197. X            sprintf(envstring, "GLMODE=%d", glmode = mp->modeval);
  198. X            putenv(envstring);
  199. X        }
  200. X        }
  201. X    } else {
  202. X        fprintf(stderr, "bad argument: %s\n", *argv);
  203. X        exit(1);
  204. X    }
  205. X#endif
  206. X    if (strncmp(*argv, "-K", 2) == 0) noconfirm = 1;
  207. X    }
  208. X
  209. X#ifndef    unix
  210. X    you may have to select binary mode for stdin
  211. X#endif
  212. X
  213. X    /* process the plotfile */
  214. X
  215. X    openpl();
  216. X
  217. X    while ((c = getchar()) != EOF) {
  218. X#ifdef DBUG
  219. X    fprintf(stderr, "c= %c, c(int)= %d\n",c,c);
  220. X    fflush(stderr);
  221. X#endif
  222. X    switch (c) {
  223. X    case 'm':                /* move */
  224. X        READ2(x, y);
  225. X#ifdef DBUG
  226. X        fprintf(stderr, "x: %d, y: %d\n", x, y);
  227. X        fflush(stderr);
  228. X#endif
  229. X        move(x, y);
  230. X        break;
  231. X    case 'n':                /* cont */
  232. X        READ2(x, y);
  233. X#ifdef DBUG
  234. X        fprintf(stderr, "x: %d, y: %d\n", x, y);
  235. X        fflush(stderr);
  236. X#endif
  237. X        cont(x, y);
  238. X        break;
  239. X    case 'p':                /* point */
  240. X        READ2(x, y);
  241. X#ifdef DBUG
  242. X        fprintf(stderr, "x: %d, y: %d\n", x, y);
  243. X        fflush(stderr);
  244. X#endif
  245. X        point(x, y);
  246. X        break;
  247. X    case 'l':                /* line */
  248. X        READ4(x1, y1, x2, y2);
  249. X#ifdef DBUG
  250. X        fprintf(stderr, "x1: %d, y1: %d, x2: %d, y2: %d\n", x1, y1,x2,y2);
  251. X        fflush(stderr);
  252. X#endif
  253. X        line(x1, y1, x2, y2);
  254. X        break;
  255. X    case 't':                /* label */
  256. X        {
  257. X        register char  *p = buf;
  258. X
  259. X        /********
  260. X        while ((c = getchar()) != EOF && c)
  261. X            *p++ = c;
  262. X        *p = '\0';
  263. X        weh  2/18/90  --- incoming string is newline terminated
  264. X        ********/
  265. X        gets(buf);
  266. X        label(buf);
  267. X        }
  268. X#ifdef DBUG
  269. X        fprintf(stderr, "label: %s\n", buf);
  270. X        fflush(stderr);
  271. X#endif
  272. X        break;
  273. X    case 'a':                /* arc */
  274. X        READ6(x, y, x0, y0, x1, y1);
  275. X        arc(x, y, x0, y0, x1, y1);
  276. X        break;
  277. X    case 'c':                /* circle */
  278. X        READ3(x, y, r);
  279. X        circle(x, y, r);
  280. X        break;
  281. X    case 'e':                /* erase */
  282. X/*        if (glmode <= MAXVIDEO)*/
  283. X        if (!noconfirm) confirm();
  284. X        erase();
  285. X        break;
  286. X    case 'f':                /* linemod */
  287. X        gets(buf);
  288. X        linemod(buf);
  289. X        break;
  290. X    case 's':                /* space */
  291. X        READ4(x0, y0, x1, y1);
  292. X#ifdef DBUG
  293. X        fprintf(stderr, "x0: %d, y0: %d, x1: %d, y1: %d\n", x0, y0,x1,y1);
  294. X        fflush(stderr);
  295. X#endif
  296. X        space(x0, y0, x1, y1);
  297. X        break;
  298. X                /* corrupt */
  299. X    default:
  300. X        closepl();
  301. X        fprintf(stderr,"c= %c, %d corrupted plotfile -- giving up\n",c,c);
  302. X        fflush(stderr);
  303. X        exit(1);
  304. X    }; /* end switch */
  305. X    } /* end while */
  306. X
  307. X/*    if (glmode <= MAXVIDEO)*/
  308. X    if (!noconfirm) confirm();
  309. X    else sleep(5);
  310. X    closepl();
  311. X    exit(0);
  312. X    /* NOTREACHED */
  313. X}
  314. X
  315. X/* give them a chance before erase() or closepl() clobber the screen */
  316. X
  317. Xstatic void     confirm()
  318. X{
  319. X    FILE           *fp;
  320. X    int             c;
  321. X
  322. X    if (fp = fopen("/dev/tty", "r")) {
  323. X    while ((c = getc(fp)) != EOF && c != '\n');
  324. X    fclose(fp);
  325. X    }
  326. X}
  327. SHAR_EOF
  328. $TOUCH -am 1026194490 driver.c &&
  329. chmod 0644 driver.c ||
  330. echo "restore of driver.c failed"
  331. set `wc -c driver.c`;Wc_c=$1
  332. if test "$Wc_c" != "5283"; then
  333.     echo original size 5283, current size $Wc_c
  334. fi
  335. exit 0
  336.  
  337.  
  338. -- 
  339. UUCP: ..!uunet!mcsun!hp4nl!integow!hot    or  hot@integow.UUCP or hot@hot.mug
  340. Roland van Hout, Sr. software engineer, Integrity software consultants, 
  341.          Pelmolenlaan 16, 3447 GW Woerden, Netherlands,
  342.             tel +31 3480-30131, fax +31 3480-30182
  343.