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

  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 8 of 9
  4. Message-ID: <1396@integow.uucp>
  5. Date: 28 Oct 90 03:58:19 GMT
  6.  
  7.  
  8.  
  9. #!/bin/sh
  10. # This is part 08 of a multipart archive
  11. if touch 2>&1 | fgrep '[-amc]' > /dev/null
  12.  then TOUCH=touch
  13.  else TOUCH=true
  14. fi
  15. # ============= herc/herc.h ==============
  16. echo "x - extracting herc/herc.h (Text)"
  17. sed 's/^X//' << 'SHAR_EOF' > herc/herc.h &&
  18. Xstatic char SCCS_HERCH[] = "%W% %G% %U%";
  19. X/* 
  20. X++++ 
  21. X    herc.h 
  22. X    PURPOSE : Hercules Graphics constants and macros
  23. X
  24. X    AUTHOR  : W. Hatch   
  25. X
  26. X    COMPANY    : Computational Engineering
  27. X          14504 Greenview Drive Suite 500
  28. X          Laurel, Maryland 20708
  29. X          301-470-3839
  30. X          usrnet: uunet!bts!bill
  31. X
  32. X    DATE    : 2/4/90
  33. X
  34. X    CREDITS : I got useful information from all of the following
  35. X          sources which I wish to acknowledge and thank.  
  36. X
  37. X        1.) David B. Dotty, "Programmers Guide To The Hercules
  38. X            Graphics Card", Addison-Wesley, 1988,
  39. X
  40. X        2.) Dan Schechter, "How To Access The Hercules Graphics
  41. X            Plane", The C Users Journal, August, 1988,
  42. X
  43. X        3.) geb, port (sample Hercules graphics driver)
  44. X            1988, Reynolds Metals Co., PO Box 1200,
  45. X            Sheffield, Al. 35660,  (205)-386-9657,
  46. X
  47. X        4.) David T. Lewis, mode.c from gnuplot, 7/13/87,
  48. X
  49. X        5.) Jeffery A. Turner, setmode.c, (Hercules mode set for
  50. X            Everix), 5/20/87,
  51. X
  52. X        6.) Janet I. Egan and Thomas J. Teixeira, "Writing a Unix
  53. X            Device Driver", Wiley, 1988,
  54. X
  55. X        7.) "Software Development System Volume I", Microport
  56. X            V386/3.0e,
  57. X
  58. X        8.) Microport Tech Support System V386 Dos Merge 386
  59. X            Version 1.1.1U, 12/15/88,
  60. X
  61. X        9.) Microport documentation on Display(7) forwarded
  62. X            by Bob Courtney, uunet!agc!courtney, August, 1989,
  63. X
  64. X        10.) Cliff Flint, sample Hercules driver code,
  65. X             uunet!ames!mailrus!umix!clif!clif, April, 1989,
  66. X
  67. X        11.) Machael Gordon and Colon Kelly, hercgraph.asm,
  68. X             Hercules graphics code for MS-DOS gnuplot,
  69. X             December, 1986.
  70. X
  71. X---*/ 
  72. X/*
  73. X------------------------------------------------------------------------
  74. X  MODIFICATIONS
  75. XDATE-PROGRAMMER    DESCRIPTION
  76. X------------------------------------------------------------------------
  77. X*/
  78. X#include <sys/types.h>
  79. X#include <sys/dir.h>
  80. X#include <sys/signal.h>
  81. X#include <sys/param.h>
  82. X#include <stdio.h>
  83. X#include <sys/user.h>
  84. X#include <fcntl.h>
  85. X#include <sys/file.h>
  86. X#include <sys/ioctl.h>
  87. X#ifndef IX386
  88. X#include <sys/io_op.h>
  89. X#endif
  90. X/*----------------------------------------------------------------------*/
  91. X/* values returned by driver functions                    */
  92. X/*----------------------------------------------------------------------*/
  93. X#define SUCCESS 0
  94. X#define FAILURE (-1)
  95. X
  96. X/*----------------------------------------------------------------------*/
  97. X/* system constants used by kernel functions                */
  98. X/*----------------------------------------------------------------------*/
  99. X#define IPC_FLAG    (IPC_CREAT|00666)
  100. X#define PG_P        0x00000001    /* page present bit    */
  101. X
  102. X/*----------------------------------------------------------------------*/
  103. X/* herc page physical base addresses and sizes in units of 4096 bytes    */
  104. X/*----------------------------------------------------------------------*/
  105. X#define HERC_TEXT_PAGE    176
  106. X#define    HERC_PAGE_0    176
  107. X#define HERC_PAGE_1    184
  108. X#define    HERC_SIZE    8
  109. X
  110. X/*----------------------------------------------------------------------*/
  111. X/* herc base addresses and sizes in bytes                */
  112. X/*----------------------------------------------------------------------*/
  113. X#define    HERC_TEXT_BUF    0xB000
  114. X#define HERC_P0_BUF    0xB000
  115. X#define HERC_P1_BUF    0xB800
  116. X
  117. X#define HERC_PAGE_BYTES    32768
  118. X
  119. X/*----------------------------------------------------------------------*/
  120. X/* error message macro                            */
  121. X/*----------------------------------------------------------------------*/
  122. X#define KERROR(a)    printf("ERROR herc: %s\n",a);
  123. X
  124. X/*----------------------------------------------------------------------*/
  125. X/* herc ioctl commands and data structure for ioctl(dev, cmd, arg)    */
  126. X/*----------------------------------------------------------------------*/
  127. X    /* cmd values */
  128. X#    define    SET_PIXEL    2
  129. X#    define    CLEAR_PIXEL    3
  130. X#    define    REVERSE_PIXEL    4
  131. X#    define    CLEAR_SCREEN_0    5
  132. X#    define    CLEAR_SCREEN_1    6
  133. X#    define    SWITCH_SCREEN_0    7
  134. X#    define    SWITCH_SCREEN_1    8
  135. X
  136. X    /* HERC arg (a data structure) */
  137. X    typedef struct s_hercio {
  138. X        int    cmd;
  139. X        int    phys_x;
  140. X        int    phys_y;
  141. X        } HERC;
  142. X#    define NO_HERC    (HERC *)0
  143. X#    define VALIDHERC(a)    ((a) != NO_HERC)
  144. X
  145. X/*----------------------------------------------------------------------*/
  146. X/* ports and byte values to put to ports                */
  147. X/*----------------------------------------------------------------------*/
  148. X#define CONFIG_SWITCH        0x3bf
  149. X#    define CF_TEXT_ONLY    0    /* default, prevents graphics    */
  150. X#    define CF_PAGE_0    01    /* enable page 0 only        */
  151. X#    define CF_PAGE_1    03    /* enable both pages        */
  152. X
  153. X#define    INDEX_REG_6845        0x3b4    /* 6845 index register        */
  154. X#define    DATA_REG_6845        0x3b5    /* 6845 data register        */
  155. X
  156. X#define    DMC_PORT        0x3b8    /* display mode control port    */
  157. X#    define    DMC_TEXT    00    /* default, text display mode    */
  158. X#    define    DMC_GRAPHICS    02    /* graphics display mode    */
  159. X#    define    DMC_OFF_SCREEN    000
  160. X#    define    DMC_ON_SCREEN    010
  161. X#    define    DMC_ON_BLINK    040
  162. X#    define    DMC_OFF_BLINK    000
  163. X#    define    DMC_PAGE_0    000    /* dmc show page 0        */
  164. X#    define    DMC_PAGE_1    0200    /* dmc show page 1        */
  165. X
  166. X/* text mode */
  167. X#    define    NORMAL        007
  168. X#    define INTENSITY    010
  169. X#    define    BLANK        000
  170. X#    define UNDERLINE    001
  171. X#    define REVERSE_VIDEO    0160
  172. X#    define BLINK        0200
  173. X
  174. X#define DS_PORT         0x3ba    /* display status port        */
  175. X#    define DS_RETRACE    0x80    /* retrace is when bit 7 is 0    */
  176. X/*----------------------------------------------------------------------*/
  177. X/* graphics memory byte location and bit manipulation            */
  178. X/*----------------------------------------------------------------------*/
  179. X    /* physical screen dimensions                    */
  180. X    /*--------------------------------------------------------------*/
  181. X#    define    PHYS_X_MIN    0
  182. X#    define    PHYS_X_MAX    719
  183. X#    define  PHYS_Y_MIN    0
  184. X#    define    PHYS_Y_MAX    347
  185. X    /*--------------------------------------------------------------*/
  186. X    /* given x, y coordinates, determine byte offset within screen    */
  187. X    /* memory                            */
  188. X    /*--------------------------------------------------------------*/
  189. X#    define    BYTE_OFFSET(x,y) (unsigned)(0x2000 * ((y)%4) + \
  190. X            90 * ((y)/4) + (x)/8)
  191. X
  192. X    /*--------------------------------------------------------------*/
  193. X    /* for given x coordinate, generate a byte with the correct     */
  194. X    /* bit set                            */
  195. X    /*--------------------------------------------------------------*/
  196. X#    define    X_BIT(x)    (1 << (7-((x)%8)))
  197. X
  198. X    /*--------------------------------------------------------------*/
  199. X    /* set, clear, reverse bit for given x within a given byte    */
  200. X    /*--------------------------------------------------------------*/
  201. X#    define    SET_BIT(byte,x)    ((byte) |= (X_BIT((x))))
  202. X#    define    CLEAR_BIT(byte,x) ((byte) &= (unsigned char)0xff ^ (X_BIT(x)))
  203. X#    define    REVERSE_BIT(byte,x) ((byte) ^= (X_BIT(x) ))
  204. SHAR_EOF
  205. $TOUCH -am 1014123490 herc/herc.h &&
  206. chmod 0644 herc/herc.h ||
  207. echo "restore of herc/herc.h failed"
  208. set `wc -c herc/herc.h`;Wc_c=$1
  209. if test "$Wc_c" != "6396"; then
  210.     echo original size 6396, current size $Wc_c
  211. fi
  212. # ============= herc/test.c ==============
  213. echo "x - extracting herc/test.c (Text)"
  214. sed 's/^X//' << 'SHAR_EOF' > herc/test.c &&
  215. X/*======================================================================*/
  216. X/* test - test features of herc driver                    */
  217. X/* W Hatch 2/17/90                            */
  218. X/*======================================================================*/
  219. X#include <stdio.h>
  220. X#include "herc.h"
  221. X#define delay sleep
  222. X
  223. Xint    hercfd;
  224. Xmain()
  225. X{
  226. X    int i;
  227. X    int j;
  228. X    HERC Herc;
  229. X    char buffer[4];
  230. X    if((hercfd = open("/dev/herc", O_WRONLY)) < 0)
  231. X    {
  232. X        perror("main: open /dev/herc failed");
  233. X        exit(2);
  234. X    }
  235. X    /*--------------------------------------------------------------*/
  236. X    /* test SET_PIXEL with a pattern                */
  237. X    /*--------------------------------------------------------------*/
  238. X    Herc.cmd = SET_PIXEL;
  239. X    pattern(&Herc);
  240. X    sleep(5);
  241. X    /*--------------------------------------------------------------*/
  242. X    /* test CLEAR_PIXEL by removing test pattern            */
  243. X    /*--------------------------------------------------------------*/
  244. X    Herc.cmd = CLEAR_PIXEL;
  245. X    pattern(&Herc);
  246. X    sleep(5);
  247. X    /*--------------------------------------------------------------*/
  248. X    /* test REVERSE_PIXEL with same pattern                */
  249. X    /*--------------------------------------------------------------*/
  250. X    Herc.cmd = REVERSE_PIXEL;
  251. X    pattern(&Herc);
  252. X    sleep(5);
  253. X    pattern(&Herc);
  254. X    sleep(5);
  255. X    close(hercfd);
  256. X    printf("hercfd: %d\n",hercfd);
  257. X    exit(0);
  258. X
  259. X}
  260. Xpattern(Herc)
  261. XHERC *Herc;
  262. X{
  263. X    int i,j;
  264. X    for(j=100; j< 200 ; j++)
  265. X    {
  266. X        for(i=100; i< 110; i++)
  267. X        {
  268. X            Herc->phys_x = j;
  269. X            Herc->phys_y = i;
  270. X            if(write(hercfd, Herc, sizeof(HERC)) < 0)
  271. X            {
  272. X                perror("main: write hercfd failed");
  273. X                exit(2);
  274. X            }
  275. X        }
  276. X        for(i=100; i< 110; i++)
  277. X        {
  278. X            Herc->phys_y = j;
  279. X            Herc->phys_x = i;
  280. X            if(write(hercfd, Herc, sizeof(HERC)) < 0)
  281. X            {
  282. X                perror("main: write hercfd failed");
  283. X                exit(2);
  284. X            }
  285. X        }
  286. X    }
  287. X}
  288. SHAR_EOF
  289. $TOUCH -am 1013182190 herc/test.c &&
  290. chmod 0644 herc/test.c ||
  291. echo "restore of herc/test.c failed"
  292. set `wc -c herc/test.c`;Wc_c=$1
  293. if test "$Wc_c" != "1690"; then
  294.     echo original size 1690, current size $Wc_c
  295. fi
  296. # ============= herc/ix386/n_herc ==============
  297. if test ! -d 'herc/ix386'; then
  298.     echo "x - creating directory herc/ix386"
  299.     mkdir 'herc/ix386'
  300. fi
  301. echo "x - extracting herc/ix386/n_herc (Text)"
  302. sed 's/^X//' << 'SHAR_EOF' > herc/ix386/n_herc &&
  303. Xherc    herc    c    0
  304. SHAR_EOF
  305. $TOUCH -am 1014120790 herc/ix386/n_herc &&
  306. chmod 0644 herc/ix386/n_herc ||
  307. echo "restore of herc/ix386/n_herc failed"
  308. set `wc -c herc/ix386/n_herc`;Wc_c=$1
  309. if test "$Wc_c" != "14"; then
  310.     echo original size 14, current size $Wc_c
  311. fi
  312. # ============= herc/ix386/s_herc ==============
  313. echo "x - extracting herc/ix386/s_herc (Text)"
  314. sed 's/^X//' << 'SHAR_EOF' > herc/ix386/s_herc &&
  315. Xherc    Y    1    0    0    0    0    0    0    0
  316. SHAR_EOF
  317. $TOUCH -am 1014123690 herc/ix386/s_herc &&
  318. chmod 0644 herc/ix386/s_herc ||
  319. echo "restore of herc/ix386/s_herc failed"
  320. set `wc -c herc/ix386/s_herc`;Wc_c=$1
  321. if test "$Wc_c" != "23"; then
  322.     echo original size 23, current size $Wc_c
  323. fi
  324. # ============= herc/ix386/mdevice ==============
  325. echo "x - extracting herc/ix386/mdevice (Text)"
  326. sed 's/^X//' << 'SHAR_EOF' > herc/ix386/mdevice &&
  327. X
  328. Xherc    ocrwi    iHcr    herc    0    15    1    1    -1
  329. X       you have to add the following line to the file /etc/conf/cf.d/mdevice:
  330. X
  331. X       herc    Iocrwi    iHct    herc    0    15    1    16    -1
  332. X
  333. SHAR_EOF
  334. $TOUCH -am 1014121390 herc/ix386/mdevice &&
  335. chmod 0644 herc/ix386/mdevice ||
  336. echo "restore of herc/ix386/mdevice failed"
  337. set `wc -c herc/ix386/mdevice`;Wc_c=$1
  338. if test "$Wc_c" != "156"; then
  339.     echo original size 156, current size $Wc_c
  340. fi
  341. # ============= herc/ix386/README ==============
  342. echo "x - extracting herc/ix386/README (Text)"
  343. sed 's/^X//' << 'SHAR_EOF' > herc/ix386/README &&
  344. Xcopy s_herc to /etc/conf/sdevice.d/herc
  345. Xcopy n_herc to /etc/conf/node.d/herc
  346. Xadd the first line in mdevice to /etc/conf/cf.d/mdevice
  347. Xcompile the source and copy it to /etc/conf/pack.d/herc/Driver.o
  348. Xof course you will have to create the directory first!
  349. SHAR_EOF
  350. $TOUCH -am 1014194190 herc/ix386/README &&
  351. chmod 0644 herc/ix386/README ||
  352. echo "restore of herc/ix386/README failed"
  353. set `wc -c herc/ix386/README`;Wc_c=$1
  354. if test "$Wc_c" != "253"; then
  355.     echo original size 253, current size $Wc_c
  356. fi
  357. # ============= README ==============
  358. echo "x - extracting README (Text)"
  359. sed 's/^X//' << 'SHAR_EOF' > README &&
  360. XThis directory tree contains a collection of PD graphic drivers.
  361. XAll of them support the plot(4) definition of ATT, well they support
  362. Xthem more or less. Most of the drivers don't have bit patterns,
  363. Xcircles and arcs built in. So if you have a lot of time here is 
  364. Xsomething to do!!!
  365. XAlso included is a driver programm for plot. So you can now install
  366. Xa runnable driver in /usr/lib add a line to your /usr/bin/tplot script
  367. Xand with sag -Therc  or any suitable name for the new driver you
  368. Xcan plot an activity graph on you screen or printer.
  369. XThe driver program was written by Wietse Venema and changed for
  370. X386 Unix 3.xxx by Bill Hatch, I made minor changes for the
  371. Xprinterdriver.
  372. XSomething like sag -Thplj could also immediately spool the output
  373. Xto lp if the line in /usr/bin/tplot is appropriate.
  374. XRemember most of this is a collection so other people wrote it,
  375. Xtheir names and e-mail/mail adresses can be found in the corresponding
  376. Xdirectories.
  377. XThe REGIS stuff and the adaption of the hpgl converter to a plot
  378. Xlibrary for (hplj,epson,ibm) is my work, also I optimized the
  379. Xhplj output with cursor adressing.
  380. XThe hpgl converter was posted by the Environmental Defense Fund in
  381. X1988, they have the copyright on this source but allowed me 
  382. Xto repost this!
  383. XOk I know it's a terrible hack, but it works.
  384. XAny changes or ideas or other PD plot librarys to hout@hot.mug.
  385. XAny PD applications that use plot (gnuplot/fchart I already 
  386. Xhave) are welcome too.
  387. XAlso I've build a plot interface for the CGI library of SCO.
  388. XIn the tplot entry you should not forget to set the
  389. Xenvironment variables for your outputdevices for the CGI library.
  390. XXenix doesnot have a tplot or sag programm it has no graphics but
  391. Xthe CGI and no system activity reports, as far as I know.
  392. XSCO Unix should have sag, tplot and system activity data 
  393. Xand the CGI library, but I don't have a SCO Unix yet.
  394. XAlso Included is the hercules driver posted to comp.unix.ix386 some
  395. Xweeks ago, originally it was a driver for uPort 386 unix, I added
  396. Xthe files for Interactive 386 V.3.2.0.2 but it should also work
  397. Xon 2.2.
  398. XThe guy who posted it was Bill Hatch, I didnot find any copyrights
  399. Xso I guess its alright if I repost this with my interactive 
  400. Xchanges.
  401. XAlso included is a plot library for sun 3 workstations from 
  402. XSjoerd Mullenders, Sjoerd has the copyright but it's allowed
  403. Xto redistribute this if you leave the copyright message in.
  404. XThen I have 2 other plotlibs for HPGL 7440 and for a DEC LN03 
  405. Xlaserprinter.
  406. XThe HPGL stuff was written by Dave Trueman and Henry Spencer
  407. Xfrom Toronto. 
  408. XThere was no copyright in the sources so I guess it's ok if I
  409. Xrepost this.
  410. XThe ln03 stuff was copyrighted by Nicolas Christopher from
  411. XColumbia University but it didnot say it was allowed to 
  412. Xredistribute this so it's not included.
  413. XAlso I have a hercules driver for uPort V.2.3 which was posted
  414. Xand copyrighted by Microport so this one is not included as well.
  415. XIf the people who have the rights on the uport and ln03 stuff
  416. Xcould mail me I that they would allow me to repost these 
  417. X2 parts. I would post them in a few weeks.
  418. X
  419. X
  420. SHAR_EOF
  421. $TOUCH -am 1026190890 README &&
  422. chmod 0644 README ||
  423. echo "restore of README failed"
  424. set `wc -c README`;Wc_c=$1
  425. if test "$Wc_c" != "3061"; then
  426.     echo original size 3061, current size $Wc_c
  427. fi
  428. # ============= plot.c ==============
  429. echo "x - extracting plot.c (Text)"
  430. sed 's/^X//' << 'SHAR_EOF' > plot.c &&
  431. X/*
  432. X * plot(1) clone. This filter implements the commands described in the 
  433. X * V7 UNIX manual pages, using the gl graphics library routines.
  434. X *
  435. X * Author: Wietse Venema (wietse@wzv.UUCP)
  436. X *
  437. X * Options: -Tdevice, where device is one of:
  438. X *
  439. X *    cga (CGA)    cga adapter, low (high) resolution
  440. X *    herc (HERC)    hercules adapter, page 0 (page 1)
  441. X *    ega        ega adapter
  442. X *    lp        matrix printer 
  443. X *    lj        laserjet printer
  444. X *
  445. X * The output device can also be specified with the GLMODE environment
  446. X * variable. See the gl graphics library documentation for details.
  447. X */
  448. X/* changes to provide compatibility with Microport V386 3.0e
  449. X * W Hatch  uunet!bts!bill
  450. X * 2/18/90
  451. X */
  452. X
  453. X#include <stdio.h>
  454. X/*#include <modes.h>*/
  455. X
  456. Xstatic void     confirm();
  457. X
  458. X/*
  459. X * If the output device is specified on the command line we pass it on to
  460. X * the gl library routines by setting the GLMODE environment variable...
  461. X */
  462. X
  463. Xstruct Modetab {
  464. X    char           *modename;
  465. X    int             modeval;
  466. X};
  467. X
  468. Xstruct Modetab  modetab[] = {
  469. X    "cga",    CGA_COLOR_MODE,        /* cga lo-res */
  470. X    "CGA",    CGA_HI_RES_MODE,    /* cga hi-res */
  471. X    "herc",    HERC_P0_MODE,        /* hercules page 0 */
  472. X    "HERC",    HERC_P1_MODE,        /* hercules page 1 */
  473. X    "ega",    EGA_COLOR_MODE,        /* ega */
  474. X    "lp",    IBM_PRINTER,        /* matrix printer */
  475. X    "lj",    LJ_PRINTER,        /* laserjet printer */
  476. X    0, 0,
  477. X};
  478. X
  479. X/* various shorthands */
  480. X#ifdef V386        /* 16 bit integers output by uport V386 graph(1) */
  481. X#define    READ(x)            fread((char *) &s_x, sizeof(s_x), 1, stdin);\
  482. X                    x=s_x
  483. X#else
  484. X#define    READ(x)            fread((char *) &x, sizeof(x), 1, stdin)
  485. X#endif
  486. X#define    READ2(a,b)        READ(a); READ(b)
  487. X#define    READ3(a,b,c)        READ2(a,b); READ(c)
  488. X#define    READ4(a,b,c,d)        READ2(a,b); READ2(c,d);
  489. X#define    READ6(a,b,c,d,e,f)    READ4(a,b,c,d); READ2(e,f);
  490. X
  491. X/* 
  492. X * Process the plotfile. The program terminates with a diagnostic
  493. X * in case of unrecognized data.
  494. X */
  495. X
  496. Xmain(argc, argv)
  497. Xint             argc;
  498. Xchar          **argv;
  499. X{
  500. X    register struct Modetab *mp;
  501. X    register int    c;
  502. X    char            buf[BUFSIZ];
  503. X    int             x, y, x0, y0, x1, y1, x2, y2, r, glmode;
  504. X#ifdef V386
  505. X    short int       s_x, s_y, s_x0, s_y0, s_x1, s_y1, s_x2, s_y2, s_r, s_glmode;
  506. X#endif
  507. X    static char     envstring[] = "GLMODE=xxxxxx";
  508. X
  509. X    /* process command-line arguments */
  510. X
  511. X    while (--argc && *++argv) {
  512. X    if (strncmp(*argv, "-T", 2) == 0) {
  513. X        for (mp = modetab; mp->modename; mp++) {
  514. X        if (strcmp(*argv + 2, mp->modename) == 0) {
  515. X            sprintf(envstring, "GLMODE=%d", glmode = mp->modeval);
  516. X            putenv(envstring);
  517. X        }
  518. X        }
  519. X    } else {
  520. X        fprintf(stderr, "bad argument: %s\n", *argv);
  521. X        exit(1);
  522. X    }
  523. X    }
  524. X
  525. X#ifndef    unix
  526. X    you may have to select binary mode for stdin
  527. X#endif
  528. X
  529. X    /* process the plotfile */
  530. X
  531. X    openpl();
  532. X
  533. X    while ((c = getchar()) != EOF) {
  534. X#ifdef DBUG
  535. X    fprintf(stderr, "c= %c, c(int)= %d\n",c,c);
  536. X    fflush(stderr);
  537. X#endif
  538. X    switch (c) {
  539. X    case 'm':                /* move */
  540. X        READ2(x, y);
  541. X#ifdef DBUG
  542. X        fprintf(stderr, "x: %d, y: %d\n", x, y);
  543. X        fflush(stderr);
  544. X#endif
  545. X        move(x, y);
  546. X        break;
  547. X    case 'n':                /* cont */
  548. X        READ2(x, y);
  549. X#ifdef DBUG
  550. X        fprintf(stderr, "x: %d, y: %d\n", x, y);
  551. X        fflush(stderr);
  552. X#endif
  553. X        cont(x, y);
  554. X        break;
  555. X    case 'p':                /* point */
  556. X        READ2(x, y);
  557. X#ifdef DBUG
  558. X        fprintf(stderr, "x: %d, y: %d\n", x, y);
  559. X        fflush(stderr);
  560. X#endif
  561. X        point(x, y);
  562. X        break;
  563. X    case 'l':                /* line */
  564. X        READ4(x1, y1, x2, y2);
  565. X#ifdef DBUG
  566. X        fprintf(stderr, "x1: %d, y1: %d, x2: %d, y2: %d\n", x1, y1,x2,y2);
  567. X        fflush(stderr);
  568. X#endif
  569. X        line(x1, y1, x2, y2);
  570. X        break;
  571. X    case 't':                /* label */
  572. X        {
  573. X        register char  *p = buf;
  574. X
  575. X        /********
  576. X        while ((c = getchar()) != EOF && c)
  577. X            *p++ = c;
  578. X        *p = '\0';
  579. X        weh  2/18/90  --- incoming string is newline terminated
  580. X        ********/
  581. X        gets(buf);
  582. X        label(buf);
  583. X        }
  584. X#ifdef DBUG
  585. X        fprintf(stderr, "label: %s\n", buf);
  586. X        fflush(stderr);
  587. X#endif
  588. X        break;
  589. X    case 'a':                /* arc */
  590. X        READ6(x, y, x0, y0, x1, y1);
  591. X        arc(x, y, x0, y0, x1, y1);
  592. X        break;
  593. X    case 'c':                /* circle */
  594. X        READ3(x, y, r);
  595. X        circle(x, y, r);
  596. X        break;
  597. X    case 'e':                /* erase */
  598. X        if (glmode <= MAXVIDEO)
  599. X        confirm();
  600. X        erase();
  601. X        break;
  602. X    case 'f':                /* linemod */
  603. X        gets(buf);
  604. X        linemod(buf);
  605. X        break;
  606. X    case 's':                /* space */
  607. X        READ4(x0, y0, x1, y1);
  608. X#ifdef DBUG
  609. X        fprintf(stderr, "x0: %d, y0: %d, x1: %d, y1: %d\n", x0, y0,x1,y1);
  610. X        fflush(stderr);
  611. X#endif
  612. X        space(x0, y0, x1, y1);
  613. X        break;
  614. X                /* corrupt */
  615. X    default:
  616. X        closepl();
  617. X        fprintf(stderr,"c= %c, %d corrupted plotfile -- giving up\n",c,c);
  618. X        fflush(stderr);
  619. X        exit(1);
  620. X    }; /* end switch */
  621. X    } /* end while */
  622. X
  623. X    if (glmode <= MAXVIDEO)
  624. X    confirm();
  625. X    closepl();
  626. X    exit(0);
  627. X    /* NOTREACHED */
  628. X}
  629. X
  630. X/* give them a chance before erase() or closepl() clobber the screen */
  631. X
  632. Xstatic void     confirm()
  633. X{
  634. X    FILE           *fp;
  635. X    int             c;
  636. X
  637. X    if (fp = fopen("/dev/tty", "r")) {
  638. X    while ((c = getc(fp)) != EOF && c != '\n');
  639. X    fclose(fp);
  640. X    }
  641. X}
  642. SHAR_EOF
  643. $TOUCH -am 1014123990 plot.c &&
  644. chmod 0644 plot.c ||
  645. echo "restore of plot.c failed"
  646. set `wc -c plot.c`;Wc_c=$1
  647. if test "$Wc_c" != "4963"; then
  648.     echo original size 4963, current size $Wc_c
  649. fi
  650. # ============= lpdriver.c ==============
  651. echo "x - extracting lpdriver.c (Text)"
  652. sed 's/^X//' << 'SHAR_EOF' > lpdriver.c &&
  653. X/*
  654. X * plot(1) clone. This filter implements the commands described in the 
  655. X * V7 UNIX manual pages, using the gl graphics library routines.
  656. X *
  657. X * Author: Wietse Venema (wietse@wzv.UUCP)
  658. X *
  659. X * Options: -Tdevice, where device is one of:
  660. X *
  661. X *    cga (CGA)    cga adapter, low (high) resolution
  662. X *    herc (HERC)    hercules adapter, page 0 (page 1)
  663. X *    ega        ega adapter
  664. X *    lp        matrix printer 
  665. X *    lj        laserjet printer
  666. X *
  667. X * The output device can also be specified with the GLMODE environment
  668. X * variable. See the gl graphics library documentation for details.
  669. X */
  670. X/* changes to provide compatibility with Microport V386 3.0e
  671. X * W Hatch  uunet!bts!bill
  672. X * 2/18/90
  673. X */
  674. X/*
  675. Xchanges to get it running on interactive 386
  676. XR.P. van Hout uunet!mcsun!hp4nl!integow!hot!hot
  677. X*/
  678. X
  679. X
  680. X#include "plotlpus.h"
  681. X#include <stdio.h>
  682. X/*#include <modes.h>*/
  683. X
  684. Xstatic void     confirm();
  685. X
  686. X/*
  687. X * If the output device is specified on the command line we pass it on to
  688. X * the gl library routines by setting the GLMODE environment variable...
  689. X */
  690. Xfloat deltx = 4095.0;
  691. Xfloat delty = 4095.0;
  692. X
  693. Xstruct Modetab {
  694. X    char           *modename;
  695. X    int             modeval;
  696. X};
  697. X
  698. Xstruct Modetab  modetab[] = {
  699. X#ifdef bla
  700. X    "cga",    CGA_COLOR_MODE,        /* cga lo-res */
  701. X    "CGA",    CGA_HI_RES_MODE,    /* cga hi-res */
  702. X    "herc",    HERC_P0_MODE,        /* hercules page 0 */
  703. X    "HERC",    HERC_P1_MODE,        /* hercules page 1 */
  704. X    "ega",    EGA_COLOR_MODE,        /* ega */
  705. X    "lp",    IBM_PRINTER,        /* matrix printer */
  706. X    "lj",    LJ_PRINTER,        /* laserjet printer */
  707. X#endif
  708. X    0, 0,
  709. X};
  710. X
  711. X/* various shorthands */
  712. X#ifdef V386        /* 16 bit integers output by uport V386 graph(1) */
  713. X#define    READ(x)            fread((char *) &s_x, sizeof(s_x), 1, stdin);\
  714. X                    x=s_x
  715. X#else
  716. X#define    READ(x)            fread((char *) &x, sizeof(x), 1, stdin)
  717. X#endif
  718. X#define    READ2(a,b)        READ(a); READ(b)
  719. X#define    READ3(a,b,c)        READ2(a,b); READ(c)
  720. X#define    READ4(a,b,c,d)        READ2(a,b); READ2(c,d);
  721. X#define    READ6(a,b,c,d,e,f)    READ4(a,b,c,d); READ2(e,f);
  722. X
  723. X/* 
  724. X * Process the plotfile. The program terminates with a diagnostic
  725. X * in case of unrecognized data.
  726. X */
  727. X
  728. Xmain(argc, argv)
  729. Xint             argc;
  730. Xchar          **argv;
  731. X{
  732. X    register struct Modetab *mp;
  733. X    register int    c;
  734. X    char            buf[BUFSIZ];
  735. X    int             x, y, x0, y0, x1, y1, x2, y2, r, glmode;
  736. X#ifdef V386
  737. X    short int       s_x, s_y, s_x0, s_y0, s_x1, s_y1, s_x2, s_y2, s_r, s_glmode;
  738. X#endif
  739. X    static char     envstring[] = "GLMODE=xxxxxx";
  740. X    int noconfirm;
  741. X    noconfirm = 0;
  742. X    /* process command-line arguments */
  743. X
  744. X    while(argc-- > 1) {
  745. X        if(*argv[1] == '-')
  746. X            switch(argv[1][1]) {
  747. X                case 'l':
  748. X                    deltx = atoi(&argv[1][2]) - 1;
  749. X                    break;
  750. X                case 'w':
  751. X                    delty = atoi(&argv[1][2]) - 1;
  752. X                    break;
  753. X                case 's':
  754. X                    printer=LASERLOW;
  755. X                    break;
  756. X                case 'm':
  757. X                    printer=LASERMED;
  758. X                    break;
  759. X                case 'h':
  760. X                    printer=LASERHIGH;
  761. X                    break;
  762. X                case 'i':
  763. X                    printer=IBM_PRO;
  764. X                    break;
  765. X                case 'e':
  766. X                    printer=EPSON;
  767. X                    break;
  768. X                }
  769. X
  770. X        argv++;
  771. X        }
  772. X
  773. X#ifndef    unix
  774. X    you may have to select binary mode for stdin
  775. X#endif
  776. X
  777. X    /* process the plotfile */
  778. X
  779. X    openpl();
  780. X
  781. X    while ((c = getchar()) != EOF) {
  782. X#ifdef DBUG
  783. X    fprintf(stderr, "c= %c, c(int)= %d\n",c,c);
  784. X    fflush(stderr);
  785. X#endif
  786. X    switch (c) {
  787. X    case 'm':                /* move */
  788. X        READ2(x, y);
  789. X#ifdef DBUG
  790. X        fprintf(stderr, "x: %d, y: %d\n", x, y);
  791. X        fflush(stderr);
  792. X#endif
  793. X        move(x, y);
  794. X        break;
  795. X    case 'n':                /* cont */
  796. X        READ2(x, y);
  797. X#ifdef DBUG
  798. X        fprintf(stderr, "x: %d, y: %d\n", x, y);
  799. X        fflush(stderr);
  800. X#endif
  801. X        cont(x, y);
  802. X        break;
  803. X    case 'p':                /* point */
  804. X        READ2(x, y);
  805. X#ifdef DBUG
  806. X        fprintf(stderr, "x: %d, y: %d\n", x, y);
  807. X        fflush(stderr);
  808. X#endif
  809. X        point(x, y);
  810. X        break;
  811. X    case 'l':                /* line */
  812. X        READ4(x1, y1, x2, y2);
  813. X#ifdef DBUG
  814. X        fprintf(stderr, "x1: %d, y1: %d, x2: %d, y2: %d\n", x1, y1,x2,y2);
  815. X        fflush(stderr);
  816. X#endif
  817. X        line(x1, y1, x2, y2);
  818. X        break;
  819. X    case 't':                /* label */
  820. X        {
  821. X        register char  *p = buf;
  822. X
  823. X        /********
  824. X        while ((c = getchar()) != EOF && c)
  825. X            *p++ = c;
  826. X        *p = '\0';
  827. X        weh  2/18/90  --- incoming string is newline terminated
  828. X        ********/
  829. X        gets(buf);
  830. X        label(buf);
  831. X        }
  832. X#ifdef DBUG
  833. X        fprintf(stderr, "label: %s\n", buf);
  834. X        fflush(stderr);
  835. X#endif
  836. X        break;
  837. X    case 'a':                /* arc */
  838. X        READ6(x, y, x0, y0, x1, y1);
  839. X        arc(x, y, x0, y0, x1, y1);
  840. X        break;
  841. X    case 'c':                /* circle */
  842. X        READ3(x, y, r);
  843. X        circle(x, y, r);
  844. X        break;
  845. X    case 'e':                /* erase */
  846. X/*        if (glmode <= MAXVIDEO)*/
  847. X        if (!noconfirm) confirm();
  848. X        erase();
  849. X        break;
  850. X    case 'f':                /* linemod */
  851. X        gets(buf);
  852. X        linemod(buf);
  853. X        break;
  854. X    case 's':                /* space */
  855. X        READ4(x0, y0, x1, y1);
  856. X#ifdef DBUG
  857. X        fprintf(stderr, "x0: %d, y0: %d, x1: %d, y1: %d\n", x0, y0,x1,y1);
  858. X        fflush(stderr);
  859. X#endif
  860. X        space(x0, y0, x1, y1);
  861. X        break;
  862. X                /* corrupt */
  863. X    default:
  864. X        closepl();
  865. X        fprintf(stderr,"c= %c, %d corrupted plotfile -- giving up\n",c,c);
  866. X        fflush(stderr);
  867. X        exit(1);
  868. X    }; /* end switch */
  869. X    } /* end while */
  870. X
  871. X/*    if (glmode <= MAXVIDEO)*/
  872. X    if (!noconfirm) confirm();
  873. X    else sleep(5);
  874. X    closepl();
  875. X    exit(0);
  876. X    /* NOTREACHED */
  877. X}
  878. X
  879. X/* give them a chance before erase() or closepl() clobber the screen */
  880. X
  881. Xstatic void     confirm()
  882. X{
  883. X    FILE           *fp;
  884. X    int             c;
  885. X
  886. X    if (fp = fopen("/dev/tty", "r")) {
  887. X    while ((c = getc(fp)) != EOF && c != '\n');
  888. X    fclose(fp);
  889. X    }
  890. X}
  891. SHAR_EOF
  892. $TOUCH -am 1014221490 lpdriver.c &&
  893. chmod 0644 lpdriver.c ||
  894. echo "restore of lpdriver.c failed"
  895. set `wc -c lpdriver.c`;Wc_c=$1
  896. if test "$Wc_c" != "5349"; then
  897.     echo original size 5349, current size $Wc_c
  898. fi
  899. # ============= makefile ==============
  900. echo "x - extracting makefile (Text)"
  901. sed 's/^X//' << 'SHAR_EOF' > makefile &&
  902. XCFLAGS=-O -DV386
  903. XCC=gcc
  904. X
  905. Xall: therc tplotlp tReGIS thpgl tsun tCGI
  906. X
  907. Xtherc:
  908. X    $(CC) $(CFLAGS) driver.c -o therc -lherc -lm
  909. X
  910. Xtplotlp:
  911. X    $(CC) $(CFLAGS) lpdriver.c -o tplotlp -lplotlp -lm
  912. X
  913. XtReGIS:
  914. X    $(CC) $(CFLAGS) driver.c -o tReGIS -lReGIS -lm
  915. X
  916. XtCGI:
  917. X    $(CC) $(CFLAGS) driver.c -o tCGI -lcgi -lm
  918. X
  919. Xthpgl:
  920. X    $(CC) $(CFLAGS) driver.c -o thpgl -lhpgl -lm
  921. X
  922. Xtsun:
  923. X    $(CC) $(CFLAGS) driver.c -o tsun -lsun -lm
  924. X
  925. Xinstall: therc tplotlp tReGIS tln03 tCGI thpgl tsun
  926. X    cp therc /usr/lib
  927. X    cp tplotlp /usr/lib
  928. X    cp tReGIS /usr/lib
  929. X    cp tln03 /usr/lib
  930. X    cp tCGI /usr/lib
  931. X    cp thpgl /usr/lib
  932. X    cp tsun /usr/lib
  933. X
  934. SHAR_EOF
  935. $TOUCH -am 1026194490 makefile &&
  936. chmod 0644 makefile ||
  937. echo "restore of makefile failed"
  938. set `wc -c makefile`;Wc_c=$1
  939. if test "$Wc_c" != "584"; then
  940.     echo original size 584, current size $Wc_c
  941. fi
  942. echo "End of part 8, continue with part 9"
  943. exit 0
  944.  
  945.  
  946.  
  947. -- 
  948. UUCP: ..!uunet!mcsun!hp4nl!integow!hot    or  hot@integow.UUCP or hot@hot.mug
  949. Roland van Hout, Sr. software engineer, Integrity software consultants, 
  950.          Pelmolenlaan 16, 3447 GW Woerden, Netherlands,
  951.             tel +31 3480-30131, fax +31 3480-30182
  952.