home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 500-599 / ff552.lzh / GNUPlot / gnuplot3.lzh / gnuplot / term.c < prev    next >
C/C++ Source or Header  |  1991-09-05  |  51KB  |  1,652 lines

  1. /* GNUPLOT - term.c */
  2. /*
  3.  * Copyright (C) 1986, 1987, 1990, 1991   Thomas Williams, Colin Kelley
  4.  *
  5.  * Permission to use, copy, and distribute this software and its
  6.  * documentation for any purpose with or without fee is hereby granted, 
  7.  * provided that the above copyright notice appear in all copies and 
  8.  * that both that copyright notice and this permission notice appear 
  9.  * in supporting documentation.
  10.  *
  11.  * Permission to modify the software is granted, but not the right to
  12.  * distribute the modified code.  Modifications are to be distributed 
  13.  * as patches to released version.
  14.  *  
  15.  * This software is provided "as is" without express or implied warranty.
  16.  * 
  17.  *
  18.  * AUTHORS
  19.  * 
  20.  *   Original Software:
  21.  *     Thomas Williams,  Colin Kelley.
  22.  * 
  23.  *   Gnuplot 2.0 additions:
  24.  *       Russell Lang, Dave Kotz, John Campbell.
  25.  *
  26.  *   Gnuplot 3.0 additions:
  27.  *       Gershon Elber and many others.
  28.  * 
  29.  * Send your comments or suggestions to 
  30.  *  pixar!info-gnuplot@sun.com.
  31.  * This is a mailing list; to join it send a note to 
  32.  *  pixar!info-gnuplot-request@sun.com.  
  33.  * Send bug reports to
  34.  *  pixar!bug-gnuplot@sun.com.
  35.  */
  36.  
  37. #include <stdio.h>
  38. #include "plot.h"
  39. #include "setshow.h"
  40. #include "term.h"
  41. #include "bitmap.h"
  42.  
  43. /* for use by all drivers */
  44. #define sign(x) ((x) >= 0 ? 1 : -1)
  45. #define abs(x) ((x) >= 0 ? (x) : -(x))
  46. #define max(a,b) ((a) > (b) ? (a) : (b))
  47. #define min(a,b) ((a) < (b) ? (a) : (b))
  48.  
  49. BOOLEAN term_init;            /* true if terminal has been initialized */
  50.  
  51. extern FILE *outfile;
  52. extern char outstr[];
  53. extern BOOLEAN term_init;
  54. extern int term;
  55. extern float xsize, ysize;
  56.  
  57. extern char input_line[];
  58. extern struct lexical_unit token[];
  59. extern int num_tokens, c_token;
  60. extern struct value *const_express();
  61.  
  62. extern BOOLEAN interactive;
  63.  
  64. /*
  65.  * instead of <strings.h>
  66.  */
  67. extern char *strcpy();
  68. extern int strlen(), strcmp(), strncmp();
  69. #ifndef AMIGA_AC_5
  70. extern double sqrt();
  71. #endif
  72.  
  73. char *getenv();
  74.  
  75. #ifdef __TURBOC__
  76. char *turboc_init();
  77. #endif
  78. #ifdef PC
  79. void reopen_binary();
  80. #endif
  81. #ifdef vms
  82. char *vms_init();
  83. void vms_reset();
  84. void term_mode_tek();
  85. void term_mode_native();
  86. void term_pasthru();
  87. void term_nopasthru();
  88. void reopen_binary();
  89. void fflush_binary();
  90. #endif
  91.  
  92. /* This is needed because the unixplot library only writes to stdout. */
  93. #ifdef UNIXPLOT
  94. FILE save_stdout;
  95. #endif
  96. int unixplot=0;
  97.  
  98. #define NICE_LINE        0
  99. #define POINT_TYPES        6
  100.  
  101.  
  102. do_point(x,y,number)
  103. int x,y;
  104. int number;
  105. {
  106. register int htic,vtic;
  107. register struct termentry *t = &term_tbl[term];
  108.  
  109.      if (number < 0) {        /* do dot */
  110.         (*t->move)(x,y);
  111.         (*t->vector)(x,y);
  112.         return;
  113.     }
  114.  
  115.     number %= POINT_TYPES;
  116.     htic = (t->h_tic/2);    /* should be in term_tbl[] in later version */
  117.     vtic = (t->v_tic/2);    
  118.  
  119.     switch(number) {
  120.         case 0: /* do diamond */ 
  121.                 (*t->move)(x-htic,y);
  122.                 (*t->vector)(x,y-vtic);
  123.                 (*t->vector)(x+htic,y);
  124.                 (*t->vector)(x,y+vtic);
  125.                 (*t->vector)(x-htic,y);
  126.                 (*t->move)(x,y);
  127.                 (*t->vector)(x,y);
  128.                 break;
  129.         case 1: /* do plus */ 
  130.                 (*t->move)(x-htic,y);
  131.                 (*t->vector)(x-htic,y);
  132.                 (*t->vector)(x+htic,y);
  133.                 (*t->move)(x,y-vtic);
  134.                 (*t->vector)(x,y-vtic);
  135.                 (*t->vector)(x,y+vtic);
  136.                 break;
  137.         case 2: /* do box */ 
  138.                 (*t->move)(x-htic,y-vtic);
  139.                 (*t->vector)(x-htic,y-vtic);
  140.                 (*t->vector)(x+htic,y-vtic);
  141.                 (*t->vector)(x+htic,y+vtic);
  142.                 (*t->vector)(x-htic,y+vtic);
  143.                 (*t->vector)(x-htic,y-vtic);
  144.                 (*t->move)(x,y);
  145.                 (*t->vector)(x,y);
  146.                 break;
  147.         case 3: /* do X */ 
  148.                 (*t->move)(x-htic,y-vtic);
  149.                 (*t->vector)(x-htic,y-vtic);
  150.                 (*t->vector)(x+htic,y+vtic);
  151.                 (*t->move)(x-htic,y+vtic);
  152.                 (*t->vector)(x-htic,y+vtic);
  153.                 (*t->vector)(x+htic,y-vtic);
  154.                 break;
  155.         case 4: /* do triangle */ 
  156.                 (*t->move)(x,y+(4*vtic/3));
  157.                 (*t->vector)(x-(4*htic/3),y-(2*vtic/3));
  158.                 (*t->vector)(x+(4*htic/3),y-(2*vtic/3));
  159.                 (*t->vector)(x,y+(4*vtic/3));
  160.                 (*t->move)(x,y);
  161.                 (*t->vector)(x,y);
  162.                 break;
  163.         case 5: /* do star */ 
  164.                 (*t->move)(x-htic,y);
  165.                 (*t->vector)(x-htic,y);
  166.                 (*t->vector)(x+htic,y);
  167.                 (*t->move)(x,y-vtic);
  168.                 (*t->vector)(x,y-vtic);
  169.                 (*t->vector)(x,y+vtic);
  170.                 (*t->move)(x-htic,y-vtic);
  171.                 (*t->vector)(x-htic,y-vtic);
  172.                 (*t->vector)(x+htic,y+vtic);
  173.                 (*t->move)(x-htic,y+vtic);
  174.                 (*t->vector)(x-htic,y+vtic);
  175.                 (*t->vector)(x+htic,y-vtic);
  176.                 break;
  177.     }
  178. }
  179.  
  180.  
  181. /*
  182.  * general point routine
  183.  */
  184. line_and_point(x,y,number)
  185. int x,y,number;
  186. {
  187.     /* temporary(?) kludge to allow terminals with bad linetypes 
  188.         to make nice marks */
  189.  
  190.     (*term_tbl[term].linetype)(NICE_LINE);
  191.     do_point(x,y,number);
  192. }
  193.  
  194. /* 
  195.  * general arrow routine
  196.  */
  197. #define ROOT2 (1.41421)        /* sqrt of 2 */
  198.  
  199. do_arrow(sx, sy, ex, ey, head)
  200.     int sx,sy;            /* start point */
  201.     int ex, ey;            /* end point (point of arrowhead) */
  202.     BOOLEAN head;
  203. {
  204.     register struct termentry *t = &term_tbl[term];
  205.     int len = (t->h_tic + t->v_tic)/2; /* arrowhead size = avg of tic sizes */
  206.  
  207.     /* draw the line for the arrow. That's easy. */
  208.     (*t->move)(sx, sy);
  209.     (*t->vector)(ex, ey);
  210.  
  211.     if (head) {
  212.     /* now draw the arrow head. */
  213.     /* we put the arrowhead marks at 45 degrees to line */
  214.        if (sx == ex) {
  215.        /* vertical line, special case */
  216.           int delta = ((float)len / ROOT2 + 0.5);
  217.           if (sy < ey)
  218.               delta = -delta;    /* up arrow goes the other way */
  219.           (*t->move)(ex - delta, ey + delta);
  220.           (*t->vector)(ex,ey);
  221.           (*t->vector)(ex + delta, ey + delta);
  222.        } else {
  223.           int dx = sx - ex;
  224.           int dy = sy - ey;
  225.           double coeff = len / sqrt(2.0*((double)dx*(double)dx 
  226.                    + (double)dy*(double)dy));
  227.           int x,y;            /* one endpoint */
  228.  
  229.           x = (int)( ex + (dx + dy) * coeff );
  230.           y = (int)( ey + (dy - dx) * coeff );
  231.           (*t->move)(x,y);
  232.           (*t->vector)(ex,ey);
  233.  
  234.           x = (int)( ex + (dx - dy) * coeff );
  235.           y = (int)( ey + (dy + dx) * coeff );
  236.           (*t->vector)(x,y);
  237.        }
  238.     }
  239. }
  240.  
  241. #ifdef DUMB                    /* paper or glass dumb terminal */
  242. #include "term/dumb.trm"
  243. #endif
  244.  
  245.  
  246. #ifdef PC            /* all PC types */
  247. #include "term/pc.trm"
  248. #endif
  249.  
  250. /*
  251.    all TEK types (TEK,BITGRAPH,KERMIT,VTTEK,SELANAR) are ifdef'd in tek.trm,
  252.    but most require various TEK routines.  Hence TEK must be defined for
  253.    the others to compile.
  254. */
  255. #ifdef BITGRAPH
  256. # ifndef TEK
  257. #  define TEK
  258. # endif
  259. #endif
  260.  
  261. #ifdef SELENAR
  262. # ifndef TEK
  263. #  define TEK
  264. # endif
  265. #endif
  266.  
  267. #ifdef KERMIT
  268. # ifndef TEK
  269. #  define TEK
  270. # endif
  271. #endif
  272.  
  273. #ifdef LN03P
  274. # ifndef TEK
  275. #  define TEK
  276. # endif
  277. #endif
  278.  
  279. #ifdef VTTEK
  280. # ifndef TEK
  281. #  define TEK
  282. # endif
  283. #endif
  284.  
  285. #ifdef T410X        /* Tektronix 4106, 4107, 4109 and 420x terminals */
  286. #include "term/t410x.trm"
  287. #endif
  288.  
  289. #ifdef TEK            /* all TEK types, TEK, BBN, SELANAR, KERMIT, VTTEK */
  290. #include "term/tek.trm"
  291. #endif
  292.  
  293. #ifdef EPSONP    /* bit map types, EPSON, NEC, PROPRINTER, STAR Color */
  294. #include "term/epson.trm"
  295. #endif
  296.  
  297. #ifdef HPLJII        /* HP LaserJet II */
  298. #include "term/hpljii.trm"
  299. #endif
  300.  
  301. #ifdef HPLJII /* HP LaserJet III in HPGL mode */
  302. #  ifndef HPGL
  303. #    define HPGL
  304. #  endif
  305. #endif
  306.  
  307. #ifdef FIG                /* Fig 1.4FS Interactive graphics program */
  308. #include "term/fig.trm"
  309. #include "term/bigfig.trm"
  310. #endif
  311.   
  312. #ifdef GPR              /* Apollo Graphics Primitive Resource (fixed-size window) */
  313. #include "term/gpr.trm"
  314. #endif /* GPR */
  315.  
  316. #ifdef APOLLO           /* Apollo Graphics Primitive Resource (resizable window) */
  317. #include "term/apollo.trm"
  318. #endif /* APOLLO */
  319.  
  320. #ifdef IMAGEN        /* IMAGEN printer */
  321. #include "term/imagen.trm"
  322. #endif
  323.  
  324. #ifdef EEPIC        /* EEPIC (LATEX) type */
  325. #include "term/eepic.trm"
  326. # ifndef LATEX
  327. #  define LATEX
  328. # endif
  329. #endif
  330.  
  331. #ifdef EMTEX        /* EMTEX (LATEX for PC) type */
  332. # ifndef LATEX
  333. #  define LATEX
  334. # endif
  335. #endif
  336.  
  337. #ifdef LATEX        /* LATEX type */
  338. #include "term/latex.trm"
  339. #endif
  340.  
  341. #ifdef POSTSCRIPT    /* POSTSCRIPT type */
  342. #include "term/post.trm"
  343. #endif
  344.  
  345. #ifdef PRESCRIBE    /* PRESCRIBE type */
  346. #include "term/kyo.trm"
  347. #endif
  348.  
  349. #ifdef UNIXPC     /* unix-PC  ATT 7300 or 3b1 machine */
  350. #include "term/unixpc.trm"
  351. #endif /* UNIXPC */
  352.  
  353. #ifdef AED
  354. #include "term/aed.trm"
  355. #endif /* AED */
  356.  
  357. #ifdef CGI
  358. #include "term/cgi.trm"
  359. #endif /* CGI */
  360.  
  361. #ifdef HP2648
  362. /* also works for HP2647 */
  363. #include "term/hp2648.trm"
  364. #endif /* HP2648 */
  365.  
  366. #ifdef HP26
  367. #include "term/hp26.trm"
  368. #endif /* HP26 */
  369.  
  370. #ifdef HP75
  371. #ifndef HPGL
  372. #define HPGL
  373. #endif
  374. #endif
  375.  
  376. /* HPGL - includes HP75 and HPLJIII in HPGL mode */
  377. #ifdef HPGL
  378. #include "term/hpgl.trm"
  379. #endif /* HPGL */
  380.  
  381. /* Roland DXY800A plotter driver by Martin Yii, eln557h@monu3.OZ 
  382.     and Russell Lang, rjl@monu1.cc.monash.oz */
  383. #ifdef DXY800A
  384. #include "term/dxy.trm"
  385. #endif /* DXY800A */
  386.  
  387. #ifdef IRIS4D
  388. #include "term/iris4d.trm"
  389. #endif /* IRIS4D */
  390.  
  391. #ifdef QMS
  392. #include "term/qms.trm"
  393. #endif /* QMS */
  394.  
  395. #ifdef REGIS
  396. #include "term/regis.trm"
  397. #endif /* REGIS */
  398.  
  399. #ifdef SUN
  400. #include "term/sun.trm"
  401. #endif /* SUN */
  402.  
  403. #ifdef VWS
  404. #include "term/vws.trm"
  405. #endif /* VWS */
  406.  
  407. #ifdef V384
  408. #include "term/v384.trm"
  409. #endif /* V384 */
  410.  
  411. #ifdef UNIXPLOT
  412. #include "term/unixplot.trm"
  413. #endif /* UNIXPLOT */
  414.  
  415. #ifdef X11
  416. #include "term/x11.trm"
  417. #endif /* X11 */
  418.  
  419. #ifdef DXF
  420. #include "term/dxf.trm"
  421. #endif /* DXF */
  422.   
  423. #ifdef AMIGASCREEN
  424. #include "term/amiga.trm"
  425. #endif
  426.  
  427.  
  428. /* Dummy functions for unavailable features */
  429.  
  430. /* change angle of text.  0 is horizontal left to right.
  431. * 1 is vertical bottom to top (90 deg rotate)  
  432. */
  433. static int null_text_angle()
  434. {
  435. return FALSE ;    /* can't be done */
  436. }
  437.  
  438. /* change justification of text.  
  439.  * modes are LEFT (flush left), CENTRE (centred), RIGHT (flush right)
  440.  */
  441. static int null_justify_text()
  442. {
  443. return FALSE ;    /* can't be done */
  444. }
  445.  
  446.  
  447. /* Change scale of plot.
  448.  * Parameters are x,y scaling factors for this plot.
  449.  * Some terminals (eg latex) need to do scaling themselves.
  450.  */
  451. static int null_scale()
  452. {
  453. return FALSE ;    /* can't be done */
  454. }
  455.  
  456. static int do_scale()
  457. {
  458. return TRUE ;    /* can be done */
  459. }
  460.  
  461. options_null()
  462. {
  463.     term_options[0] = '\0';    /* we have no options */
  464. }
  465.  
  466. static UNKNOWN_null()
  467. {
  468. }
  469.  
  470. /*
  471.  * term_tbl[] contains an entry for each terminal.  "unknown" must be the
  472.  *   first, since term is initialized to 0.
  473.  */
  474. struct termentry term_tbl[] = {
  475.     {"unknown", "Unknown terminal type - not a plotting device",
  476.       100, 100, 1, 1,
  477.       1, 1, options_null, UNKNOWN_null, UNKNOWN_null, 
  478.       UNKNOWN_null, null_scale, UNKNOWN_null, UNKNOWN_null, UNKNOWN_null, 
  479.       UNKNOWN_null, UNKNOWN_null, null_text_angle, 
  480.       null_justify_text, UNKNOWN_null, UNKNOWN_null}
  481.  
  482. #ifdef AMIGASCREEN
  483.     ,{"amiga", "Amiga Custom Screen",
  484.        AMIGA_XMAX, AMIGA_YMAX, AMIGA_VCHAR, AMIGA_HCHAR, 
  485.        AMIGA_VTIC, AMIGA_HTIC, options_null, AMIGA_init, AMIGA_reset, 
  486.        AMIGA_text, null_scale, AMIGA_graphics, AMIGA_move, AMIGA_vector,
  487.        AMIGA_linetype, AMIGA_put_text, null_text_angle, 
  488.        AMIGA_justify_text, do_point, do_arrow}
  489. #endif
  490.  
  491. #ifdef DUMB
  492.     ,{"dumb", "printer or glass dumb terminal",
  493.          DUMB_XMAX, DUMB_YMAX, 1, 1,
  494.          1, 1, DUMB_options, DUMB_init, DUMB_reset,
  495.          DUMB_text, null_scale, DUMB_graphics, DUMB_move, DUMB_vector,
  496.          DUMB_linetype, DUMB_put_text, null_text_angle,
  497.          null_justify_text, DUMB_point, DUMB_arrow}
  498. #endif
  499.  
  500. #ifdef PC
  501. #ifdef __TURBOC__
  502.  
  503.     ,{"egalib", "IBM PC/Clone with EGA graphics board",
  504.        EGALIB_XMAX, EGALIB_YMAX, EGALIB_VCHAR, EGALIB_HCHAR,
  505.        EGALIB_VTIC, EGALIB_HTIC, options_null, EGALIB_init, EGALIB_reset,
  506.        EGALIB_text, null_scale, EGALIB_graphics, EGALIB_move, EGALIB_vector,
  507.        EGALIB_linetype, EGALIB_put_text, EGALIB_text_angle, 
  508.        EGALIB_justify_text, do_point, do_arrow}
  509.  
  510.     ,{"vgalib", "IBM PC/Clone with VGA graphics board",
  511.        VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
  512.        VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset,
  513.        VGA_text, null_scale, VGA_graphics, VGA_move, VGA_vector,
  514.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  515.        VGA_justify_text, do_point, do_arrow}
  516.  
  517.     ,{"vgamono", "IBM PC/Clone with VGA Monochrome graphics board",
  518.        VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
  519.        VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset,
  520.        VGA_text, null_scale, VGA_graphics, VGA_move, VGA_vector,
  521.        VGAMONO_linetype, VGA_put_text, VGA_text_angle, 
  522.        VGA_justify_text, line_and_point, do_arrow}
  523.  
  524.     ,{"svga", "IBM PC/Clone with Super VGA graphics board",
  525.        SVGA_XMAX, SVGA_YMAX, SVGA_VCHAR, SVGA_HCHAR,
  526.        SVGA_VTIC, SVGA_HTIC, options_null, SVGA_init, SVGA_reset,
  527.        SVGA_text, null_scale, SVGA_graphics, SVGA_move, SVGA_vector,
  528.        SVGA_linetype, SVGA_put_text, SVGA_text_angle, 
  529.        SVGA_justify_text, do_point, do_arrow}
  530.  
  531.     ,{"mcga", "IBM PC/Clone with MCGA graphics board",
  532.        MCGA_XMAX, MCGA_YMAX, MCGA_VCHAR, MCGA_HCHAR,
  533.        MCGA_VTIC, MCGA_HTIC, options_null, MCGA_init, MCGA_reset,
  534.        MCGA_text, null_scale, MCGA_graphics, MCGA_move, MCGA_vector,
  535.        MCGA_linetype, MCGA_put_text, MCGA_text_angle, 
  536.        MCGA_justify_text, line_and_point, do_arrow}
  537.  
  538.     ,{"cga", "IBM PC/Clone with CGA graphics board",
  539.        CGA_XMAX, CGA_YMAX, CGA_VCHAR, CGA_HCHAR,
  540.        CGA_VTIC, CGA_HTIC, options_null, CGA_init, CGA_reset,
  541.        CGA_text, null_scale, CGA_graphics, CGA_move, CGA_vector,
  542.        CGA_linetype, CGA_put_text, MCGA_text_angle, 
  543.        CGA_justify_text, line_and_point, do_arrow}
  544.  
  545.     ,{"hercules", "IBM PC/Clone with Hercules graphics board",
  546.        HERC_XMAX, HERC_YMAX, HERC_VCHAR, HERC_HCHAR,
  547.        HERC_VTIC, HERC_HTIC, options_null, HERC_init, HERC_reset,
  548.        HERC_text, null_scale, HERC_graphics, HERC_move, HERC_vector,
  549.        HERC_linetype, HERC_put_text, MCGA_text_angle, 
  550.        HERC_justify_text, line_and_point, do_arrow}
  551. #ifdef ATT6300
  552.     ,{"att", "IBM PC/Clone with AT&T 6300 graphics board",
  553.        ATT_XMAX, ATT_YMAX, ATT_VCHAR, ATT_HCHAR,
  554.        ATT_VTIC, ATT_HTIC, options_null, ATT_init, ATT_reset,
  555.        ATT_text, null_scale, ATT_graphics, ATT_move, ATT_vector,
  556.        ATT_linetype, ATT_put_text, ATT_text_angle, 
  557.        ATT_justify_text, line_and_point, do_arrow}
  558. #endif
  559. #else                    /* TURBO */
  560.  
  561.     ,{"cga", "IBM PC/Clone with CGA graphics board",
  562.        CGA_XMAX, CGA_YMAX, CGA_VCHAR, CGA_HCHAR,
  563.        CGA_VTIC, CGA_HTIC, options_null, CGA_init, CGA_reset,
  564.        CGA_text, null_scale, CGA_graphics, CGA_move, CGA_vector,
  565.        CGA_linetype, CGA_put_text, CGA_text_angle, 
  566.        null_justify_text, line_and_point, do_arrow}
  567.  
  568.     ,{"egabios", "IBM PC/Clone with EGA graphics board (BIOS)",
  569.        EGA_XMAX, EGA_YMAX, EGA_VCHAR, EGA_HCHAR,
  570.        EGA_VTIC, EGA_HTIC, options_null, EGA_init, EGA_reset,
  571.        EGA_text, null_scale, EGA_graphics, EGA_move, EGA_vector,
  572.        EGA_linetype, EGA_put_text, EGA_text_angle, 
  573.        null_justify_text, do_point, do_arrow}
  574.  
  575.     ,{"vgabios", "IBM PC/Clone with VGA graphics board (BIOS)",
  576.        VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
  577.        VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset,
  578.        VGA_text, null_scale, VGA_graphics, VGA_move, VGA_vector,
  579.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  580.        null_justify_text, do_point, do_arrow}
  581.  
  582. #ifdef EGALIB
  583.     ,{"egalib", "IBM PC/Clone with EGA graphics board (LIB)",
  584.        EGALIB_XMAX, EGALIB_YMAX, EGALIB_VCHAR, EGALIB_HCHAR,
  585.        EGALIB_VTIC, EGALIB_HTIC, options_null, EGALIB_init, EGALIB_reset,
  586.        EGALIB_text, null_scale, EGALIB_graphics, EGALIB_move, EGALIB_vector,
  587.        EGALIB_linetype, EGALIB_put_text, null_text_angle, 
  588.        null_justify_text, do_point, do_arrow}
  589. #endif
  590.  
  591. #ifdef HERCULES
  592.     ,{"hercules", "IBM PC/Clone with Hercules graphics board",
  593.        HERC_XMAX, HERC_YMAX, HERC_VCHAR, HERC_HCHAR,
  594.        HERC_VTIC, HERC_HTIC, options_null, HERC_init, HERC_reset,
  595.        HERC_text, null_scale, HERC_graphics, HERC_move, HERC_vector,
  596.        HERC_linetype, HERC_put_text, HERC_text_angle, 
  597.        null_justify_text, line_and_point, do_arrow}
  598. #endif                    /* HERCULES */
  599.  
  600. #ifdef ATT6300
  601.     ,{"att", "AT&T PC/6300 graphics",
  602.        ATT_XMAX, ATT_YMAX, ATT_VCHAR, ATT_HCHAR,
  603.        ATT_VTIC, ATT_HTIC, options_null, ATT_init, ATT_reset,
  604.        ATT_text, null_scale, ATT_graphics, ATT_move, ATT_vector,
  605.        ATT_linetype, ATT_put_text, ATT_text_angle, 
  606.        null_justify_text, line_and_point, do_arrow}
  607. #endif
  608.  
  609. #ifdef CORONA
  610.     ,{"corona325", "Corona graphics ???",
  611.        COR_XMAX, COR_YMAX, COR_VCHAR, COR_HCHAR,
  612.        COR_VTIC, COR_HTIC, options_null, COR_init, COR_reset,
  613.        COR_text, null_scale, COR_graphics, COR_move, COR_vector,
  614.        COR_linetype, COR_put_text, COR_text_angle, 
  615.        null_justify_text, line_and_point, do_arrow}
  616. #endif                    /* CORONA */
  617. #endif                    /* TURBO */
  618. #endif                    /* PC */
  619.  
  620. #ifdef AED
  621.     ,{"aed512", "AED 512 Terminal",
  622.        AED5_XMAX, AED_YMAX, AED_VCHAR, AED_HCHAR,
  623.        AED_VTIC, AED_HTIC, options_null, AED_init, AED_reset, 
  624.        AED_text, null_scale, AED_graphics, AED_move, AED_vector, 
  625.        AED_linetype, AED_put_text, null_text_angle, 
  626.        null_justify_text, do_point, do_arrow}
  627.     ,{"aed767", "AED 767 Terminal",
  628.        AED_XMAX, AED_YMAX, AED_VCHAR, AED_HCHAR,
  629.        AED_VTIC, AED_HTIC, options_null, AED_init, AED_reset, 
  630.        AED_text, null_scale, AED_graphics, AED_move, AED_vector, 
  631.        AED_linetype, AED_put_text, null_text_angle, 
  632.        null_justify_text, do_point, do_arrow}
  633. #endif
  634.  
  635. #ifdef APOLLO
  636.        ,{"apollo", "Apollo Graphics Primitive Resource, rescaling of subsequent plots after window resizing",
  637.        0, 0, 0, 0, /* APOLLO_XMAX, APOLLO_YMAX, APOLLO_VCHAR, APOLLO_HCHAR, are filled in at run-time */
  638.        APOLLO_VTIC, APOLLO_HTIC, options_null, APOLLO_init, APOLLO_reset,
  639.        APOLLO_text, null_scale, APOLLO_graphics, APOLLO_move, APOLLO_vector,
  640.        APOLLO_linetype, APOLLO_put_text, APOLLO_text_angle,
  641.        APOLLO_justify_text, line_and_point, do_arrow}
  642. #endif
  643.  
  644. #ifdef GPR
  645.        ,{"gpr", "Apollo Graphics Primitive Resource, fixed-size window",
  646.        GPR_XMAX, GPR_YMAX, GPR_VCHAR, GPR_HCHAR,
  647.        GPR_VTIC, GPR_HTIC, options_null, GPR_init, GPR_reset,
  648.        GPR_text, null_scale, GPR_graphics, GPR_move, GPR_vector,
  649.        GPR_linetype, GPR_put_text, GPR_text_angle,
  650.        GPR_justify_text, line_and_point, do_arrow}
  651. #endif
  652.  
  653. #ifdef BITGRAPH
  654.     ,{"bitgraph", "BBN Bitgraph Terminal",
  655.        BG_XMAX,BG_YMAX,BG_VCHAR, BG_HCHAR, 
  656.        BG_VTIC, BG_HTIC, options_null, BG_init, BG_reset, 
  657.        BG_text, null_scale, BG_graphics, BG_move, BG_vector,
  658.        BG_linetype, BG_put_text, null_text_angle, 
  659.        null_justify_text, line_and_point, do_arrow}
  660. #endif
  661.  
  662. #ifdef CGI
  663.     ,{"cgi", "SCO CGI drivers (requires CGIDISP or CGIPRNT env variable)",
  664.        CGI_XMAX, CGI_YMAX, 0, 0, 
  665.        CGI_VTIC, 0, options_null, CGI_init, CGI_reset, 
  666.        CGI_text, null_scale, CGI_graphics, CGI_move, CGI_vector, 
  667.        CGI_linetype, CGI_put_text, CGI_text_angle, 
  668.        CGI_justify_text, CGI_point, do_arrow}
  669.  
  670.     ,{"hcgi", "SCO CGI drivers (hardcopy, requires CGIPRNT env variable)",
  671.        CGI_XMAX, CGI_YMAX, 0, 0, 
  672.        CGI_VTIC, 0, options_null, HCGI_init, CGI_reset, 
  673.        CGI_text, null_scale, CGI_graphics, CGI_move, CGI_vector, 
  674.        CGI_linetype, CGI_put_text, CGI_text_angle, 
  675.        CGI_justify_text, CGI_point, do_arrow}
  676. #endif
  677.  
  678. #ifdef DXF
  679.     ,{"dxf", "dxf-file for AutoCad (default size 120x80)",
  680.        DXF_XMAX,DXF_YMAX,DXF_VCHAR, DXF_HCHAR,
  681.        DXF_VTIC, DXF_HTIC, options_null,DXF_init, DXF_reset,
  682.        DXF_text, null_scale, DXF_graphics, DXF_move, DXF_vector,
  683.        DXF_linetype, DXF_put_text, DXF_text_angle,
  684.        DXF_justify_text, do_point, do_arrow}
  685. #endif
  686.  
  687. #ifdef DXY800A
  688.     ,{"dxy800a", "Roland DXY800A plotter",
  689.        DXY_XMAX, DXY_YMAX, DXY_VCHAR, DXY_HCHAR,
  690.        DXY_VTIC, DXY_HTIC, options_null, DXY_init, DXY_reset,
  691.        DXY_text, null_scale, DXY_graphics, DXY_move, DXY_vector,
  692.        DXY_linetype, DXY_put_text, DXY_text_angle, 
  693.        null_justify_text, do_point, do_arrow}
  694. #endif
  695.  
  696. #ifdef EEPIC
  697.     ,{"eepic", "EEPIC -- extended LaTeX picture environment",
  698.        EEPIC_XMAX, EEPIC_YMAX, EEPIC_VCHAR, EEPIC_HCHAR, 
  699.        EEPIC_VTIC, EEPIC_HTIC, options_null, EEPIC_init, EEPIC_reset, 
  700.        EEPIC_text, EEPIC_scale, EEPIC_graphics, EEPIC_move, EEPIC_vector, 
  701.        EEPIC_linetype, EEPIC_put_text, EEPIC_text_angle, 
  702.        EEPIC_justify_text, EEPIC_point, EEPIC_arrow}
  703. #endif
  704.  
  705. #ifdef EMTEX
  706.    
  707.     ,{"emtex", "LATEX picture environment with emTeX specials",
  708.        LATEX_XMAX, LATEX_YMAX, LATEX_VCHAR, LATEX_HCHAR, 
  709.        LATEX_VTIC, LATEX_HTIC, options_null, EMTEX_init, EMTEX_reset, 
  710.        EMTEX_text, LATEX_scale, LATEX_graphics, LATEX_move, LATEX_vector, 
  711.        LATEX_linetype, LATEX_put_text, LATEX_text_angle, 
  712.        LATEX_justify_text, LATEX_point, LATEX_arrow}
  713. #endif
  714.  
  715. #ifdef EPS60
  716.     ,{"epson_60dpi", "Epson-style 60-dot per inch printers",
  717.        EPS60XMAX, EPS60YMAX, EPSONVCHAR, EPSONHCHAR,
  718.        EPSONVTIC, EPSONHTIC, options_null, EPSONinit, EPSONreset,
  719.        EPS60text, null_scale, EPS60graphics, EPSONmove, EPSONvector,
  720.        EPSONlinetype, EPSONput_text, EPSON_text_angle,
  721.        null_justify_text, do_point, do_arrow}
  722. #endif
  723.  
  724. #ifdef EPSONP
  725.     ,{"epson_lx800", "Epson LX-800, Star NL-10, NX-1000, PROPRINTER ...",
  726.        EPSONXMAX, EPSONYMAX, EPSONVCHAR, EPSONHCHAR, 
  727.        EPSONVTIC, EPSONHTIC, options_null, EPSONinit, EPSONreset, 
  728.        EPSONtext, null_scale, EPSONgraphics, EPSONmove, EPSONvector, 
  729.        EPSONlinetype, EPSONput_text, EPSON_text_angle, 
  730.        null_justify_text, line_and_point, do_arrow}
  731. #endif
  732.  
  733. #ifdef FIG
  734.     ,{"fig", "FIG graphics language: SunView or X graphics editor",
  735.        FIG_XMAX, FIG_YMAX, FIG_VCHAR, FIG_HCHAR, 
  736.        FIG_VTIC, FIG_HTIC, options_null, FIG_init, FIG_reset, 
  737.        FIG_text, null_scale, FIG_graphics, FIG_move, FIG_vector, 
  738.        FIG_linetype, FIG_put_text, FIG_text_angle, 
  739.        FIG_justify_text, do_point, FIG_arrow}
  740.     ,{"bfig", "FIG graphics language: SunView or X graphics editor. Large Graph",
  741.        BFIG_XMAX, BFIG_YMAX, BFIG_VCHAR, BFIG_HCHAR, 
  742.        BFIG_VTIC, BFIG_HTIC, options_null, FIG_init, FIG_reset, 
  743.        FIG_text, null_scale, FIG_graphics, FIG_move, BFIG_vector, 
  744.        FIG_linetype, BFIG_put_text, FIG_text_angle, 
  745.        FIG_justify_text, do_point, BFIG_arrow}
  746. #endif
  747.  
  748. #ifdef HP26
  749.     ,{"hp2623A", "HP2623A and maybe others",
  750.        HP26_XMAX, HP26_YMAX, HP26_VCHAR, HP26_HCHAR,
  751.        HP26_VTIC, HP26_HTIC, options_null, HP26_init, HP26_reset,
  752.        HP26_text, null_scale, HP26_graphics, HP26_move, HP26_vector,
  753.        HP26_linetype, HP26_put_text, null_text_angle, 
  754.        null_justify_text, line_and_point, do_arrow}
  755. #endif
  756.  
  757. #ifdef HP2648
  758.     ,{"hp2648", "HP2648 and HP2647",
  759.        HP2648XMAX, HP2648YMAX, HP2648VCHAR, HP2648HCHAR, 
  760.        HP2648VTIC, HP2648HTIC, options_null, HP2648init, HP2648reset, 
  761.        HP2648text, null_scale, HP2648graphics, HP2648move, HP2648vector, 
  762.        HP2648linetype, HP2648put_text, HP2648_text_angle, 
  763.        null_justify_text, line_and_point, do_arrow}
  764. #endif
  765.  
  766. #ifdef HP75
  767.     ,{"hp7580B", "HP7580, and probably other HPs (4 pens)",
  768.        HPGL_XMAX, HPGL_YMAX, HPGL_VCHAR, HPGL_HCHAR,
  769.        HPGL_VTIC, HPGL_HTIC, options_null, HPGL_init, HPGL_reset,
  770.        HPGL_text, null_scale, HPGL_graphics, HPGL_move, HPGL_vector,
  771.        HP75_linetype, HPGL_put_text, HPGL_text_angle, 
  772.        null_justify_text, do_point, do_arrow}
  773. #endif
  774.  
  775. #ifdef HPGL
  776.     ,{"hpgl", "HP7475 and (hopefully) lots of others (6 pens)",
  777.        HPGL_XMAX, HPGL_YMAX, HPGL_VCHAR, HPGL_HCHAR,
  778.        HPGL_VTIC, HPGL_HTIC, options_null, HPGL_init, HPGL_reset,
  779.        HPGL_text, null_scale, HPGL_graphics, HPGL_move, HPGL_vector,
  780.        HPGL_linetype, HPGL_put_text, HPGL_text_angle, 
  781.        null_justify_text, do_point, do_arrow}
  782. #endif
  783.  
  784. #ifdef HPLJII
  785.     ,{"hpljii", "HP Laserjet series II, [75 100 150 300]",
  786.        HPLJII_75PPI_XMAX, HPLJII_75PPI_YMAX, HPLJII_75PPI_VCHAR,
  787.        HPLJII_75PPI_HCHAR, HPLJII_75PPI_VTIC, HPLJII_75PPI_HTIC, HPLJIIoptions,
  788.        HPLJIIinit, HPLJIIreset, HPLJIItext, null_scale,
  789.        HPLJIIgraphics, HPLJIImove, HPLJIIvector, HPLJIIlinetype,
  790.        HPLJIIput_text, HPLJIItext_angle, null_justify_text, line_and_point,
  791.        do_arrow}
  792.     ,{"hpdj", "HP DeskJet 500, [75 100 150 300]",
  793.        HPLJII_75PPI_XMAX, HPLJII_75PPI_YMAX, HPLJII_75PPI_VCHAR,
  794.        HPLJII_75PPI_HCHAR, HPLJII_75PPI_VTIC, HPLJII_75PPI_HTIC, HPLJIIoptions,
  795.        HPLJIIinit, HPLJIIreset, HPDJtext, null_scale,
  796.        HPDJgraphics, HPLJIImove, HPLJIIvector, HPLJIIlinetype,
  797.        HPDJput_text, HPDJtext_angle, null_justify_text, line_and_point,
  798.        do_arrow}
  799. #endif
  800.  
  801. #ifdef HPLJIII
  802.     ,{"hpljiii_port", "HP laserjet iii (using HPGL plot vectors), portrait mode",
  803.     HPGL_XMAX, HPGL_YMAX, HPGL_VCHAR, HPGL_HCHAR,
  804.     HPGL_VTIC, HPGL_HTIC, options_null, HPLJIII_PORT_init, HPLJIII_reset,
  805.     HPGL_text, null_scale, HPGL_graphics, HPGL_move, HPGL_vector,
  806.     HPGL_linetype, HPGL_put_text, HPGL_text_angle,
  807.     null_justify_text, do_point, do_arrow}
  808.      ,{"hpljiii_land", "HP laserjet iii (using HPGL plot vectors), landscape mode",
  809.     HPGL_XMAX, HPGL_YMAX, HPGL_VCHAR, HPGL_HCHAR,
  810.     HPGL_VTIC, HPGL_HTIC, options_null, HPLJIII_LAND_init, HPLJIII_reset,
  811.     HPGL_text, null_scale, HPGL_graphics, HPGL_move, HPGL_vector,
  812.     HPGL_linetype, HPGL_put_text, HPGL_text_angle,
  813.     null_justify_text, do_point, do_arrow}
  814. #endif
  815.  
  816. #ifdef IMAGEN
  817.     ,{"imagen", "Imagen laser printer",
  818.        IMAGEN_XMAX, IMAGEN_YMAX, IMAGEN_VCHAR, IMAGEN_HCHAR, 
  819.        IMAGEN_VTIC, IMAGEN_HTIC, options_null, IMAGEN_init, IMAGEN_reset, 
  820.        IMAGEN_text, null_scale, IMAGEN_graphics, IMAGEN_move, 
  821.        IMAGEN_vector, IMAGEN_linetype, IMAGEN_put_text, IMAGEN_text_angle,
  822.        IMAGEN_justify_text, line_and_point, do_arrow}
  823. #endif
  824.  
  825. #ifdef IRIS4D
  826.     ,{"iris4d", "Silicon Graphics IRIS 4D Series Computer",
  827.        IRIS4D_XMAX, IRIS4D_YMAX, IRIS4D_VCHAR, IRIS4D_HCHAR, 
  828.        IRIS4D_VTIC, IRIS4D_HTIC, IRIS4D_options, IRIS4D_init, IRIS4D_reset, 
  829.        IRIS4D_text, null_scale, IRIS4D_graphics, IRIS4D_move, IRIS4D_vector,
  830.        IRIS4D_linetype, IRIS4D_put_text, null_text_angle, 
  831.        null_justify_text, do_point, do_arrow}
  832. #endif
  833.  
  834. #ifdef KERMIT
  835.     ,{"kc_tek40xx", "Kermit-MS tek40xx terminal emulator - color",
  836.        TEK40XMAX,TEK40YMAX,TEK40VCHAR, KTEK40HCHAR, 
  837.        TEK40VTIC, TEK40HTIC, options_null, TEK40init, KTEK40reset, 
  838.        KTEK40Ctext, null_scale, KTEK40graphics, TEK40move, TEK40vector, 
  839.        KTEK40Clinetype, TEK40put_text, null_text_angle, 
  840.        null_justify_text, do_point, do_arrow}
  841.     ,{"km_tek40xx", "Kermit-MS tek40xx terminal emulator - monochrome",
  842.        TEK40XMAX,TEK40YMAX,TEK40VCHAR, KTEK40HCHAR, 
  843.        TEK40VTIC, TEK40HTIC, options_null, TEK40init, KTEK40reset, 
  844.        TEK40text, null_scale, KTEK40graphics, TEK40move, TEK40vector, 
  845.        KTEK40Mlinetype, TEK40put_text, null_text_angle, 
  846.        null_justify_text, line_and_point, do_arrow}
  847. #endif
  848.  
  849. #ifdef LATEX
  850.     ,{"latex", "LaTeX picture environment",
  851.        LATEX_XMAX, LATEX_YMAX, LATEX_VCHAR, LATEX_HCHAR, 
  852.        LATEX_VTIC, LATEX_HTIC, options_null, LATEX_init, LATEX_reset, 
  853.        LATEX_text, LATEX_scale, LATEX_graphics, LATEX_move, LATEX_vector, 
  854.        LATEX_linetype, LATEX_put_text, LATEX_text_angle, 
  855.        LATEX_justify_text, LATEX_point, LATEX_arrow}
  856. #endif
  857.  
  858. #ifdef LN03P
  859.      ,{"ln03", "LN03-plus laser printer in tektronix mode",
  860.     TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR,
  861.     TEK40VTIC, TEK40HTIC, options_null, LN03Pinit, LN03Preset,
  862.     TEK40text, null_scale, TEK40graphics, TEK40move, TEK40vector,
  863.     TEK40linetype, TEK40put_text, null_text_angle,
  864.     null_justify_text, line_and_point, do_arrow}
  865. #endif
  866.  
  867. #ifdef NEC
  868.     ,{"nec_cp6m", "NEC printer CP6, Epson LQ-800 Monochrome",
  869.        NECXMAX, NECYMAX, NECVCHAR, NECHCHAR, 
  870.        NECVTIC, NECHTIC, options_null, NECinit, NECreset, 
  871.        NECtext, null_scale, NECMgraphics, NECmove, NECvector, 
  872.        NECMlinetype, NECput_text, NEC_text_angle, 
  873.        null_justify_text, line_and_point, do_arrow}
  874.     ,{"nec_cp6c", "NEC printer CP6 Color",
  875.        NECXMAX, NECYMAX, NECVCHAR, NECHCHAR, 
  876.        NECVTIC, NECHTIC, options_null, NECinit, NECreset, 
  877.        NECtext, null_scale, NECCgraphics, NECmove, NECvector, 
  878.        NECClinetype, NECput_text, NEC_text_angle, 
  879.        null_justify_text, do_point, do_arrow}
  880.     ,{"nec_cp6d", "NEC printer CP6, Epson LQ-800 Draft monochrome",
  881.        NECXMAX, NECYMAX, NECVCHAR, NECHCHAR, 
  882.        NECVTIC, NECHTIC, options_null, NECinit, NECreset, 
  883.        NECdraft_text, null_scale, NECMgraphics, NECmove, NECvector, 
  884.        NECMlinetype, NECput_text, NEC_text_angle, 
  885.        null_justify_text, line_and_point, do_arrow}
  886. #endif
  887.  
  888. #ifdef POSTSCRIPT
  889.     ,{"postscript", "PostScript graphics language [mode \042fontname\042 font_size]",
  890.        PS_XMAX, PS_YMAX, PS_VCHAR, PS_HCHAR, 
  891.        PS_VTIC, PS_HTIC, PS_options, PS_init, PS_reset, 
  892.        PS_text, do_scale, PS_graphics, PS_move, PS_vector, 
  893.        PS_linetype, PS_put_text, PS_text_angle, 
  894.        PS_justify_text, PS_point, do_arrow}
  895. #endif
  896.  
  897. #ifdef PRESCRIBE
  898.     ,{"prescribe", "Prescribe - for the Kyocera Laser Printer",
  899.     PRE_XMAX, PRE_YMAX, PRE_VCHAR, PRE_HCHAR, 
  900.     PRE_VTIC, PRE_HTIC, options_null, PRE_init, PRE_reset, 
  901.     PRE_text, null_scale, PRE_graphics, PRE_move, PRE_vector, 
  902.     PRE_linetype, PRE_put_text, null_text_angle, 
  903.     PRE_justify_text, line_and_point, do_arrow}
  904.     ,{"kyo", "Kyocera Laser Printer with Courier font",
  905.     PRE_XMAX, PRE_YMAX, KYO_VCHAR, KYO_HCHAR, 
  906.     PRE_VTIC, PRE_HTIC, options_null, KYO_init, PRE_reset, 
  907.     PRE_text, null_scale, PRE_graphics, PRE_move, PRE_vector, 
  908.     PRE_linetype, PRE_put_text, null_text_angle, 
  909.     PRE_justify_text, line_and_point, do_arrow}
  910. #endif /* PRESCRIBE */
  911.  
  912. #ifdef QMS
  913.     ,{"qms", "QMS/QUIC Laser printer (also Talaris 1200 and others)",
  914.        QMS_XMAX,QMS_YMAX, QMS_VCHAR, QMS_HCHAR, 
  915.        QMS_VTIC, QMS_HTIC, options_null, QMS_init,QMS_reset, 
  916.        QMS_text, null_scale, QMS_graphics, QMS_move, QMS_vector,
  917.        QMS_linetype,QMS_put_text, null_text_angle, 
  918.        null_justify_text, line_and_point, do_arrow}
  919. #endif
  920.  
  921. #ifdef REGIS
  922.     ,{"regis", "REGIS graphics language",
  923.        REGISXMAX, REGISYMAX, REGISVCHAR, REGISHCHAR, 
  924.        REGISVTIC, REGISHTIC, options_null, REGISinit, REGISreset, 
  925.        REGIStext, null_scale, REGISgraphics, REGISmove, REGISvector,
  926.        REGISlinetype, REGISput_text, REGIStext_angle, 
  927.        null_justify_text, line_and_point, do_arrow}
  928. #endif
  929.  
  930.  
  931. #ifdef SELANAR
  932.     ,{"selanar", "Selanar",
  933.        TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR, 
  934.        TEK40VTIC, TEK40HTIC, options_null, SEL_init, SEL_reset, 
  935.        SEL_text, null_scale, SEL_graphics, TEK40move, TEK40vector, 
  936.        TEK40linetype, TEK40put_text, null_text_angle, 
  937.        null_justify_text, line_and_point, do_arrow}
  938. #endif
  939.  
  940. #ifdef STARC
  941.     ,{"starc", "Star Color Printer",
  942.        STARCXMAX, STARCYMAX, STARCVCHAR, STARCHCHAR, 
  943.        STARCVTIC, STARCHTIC, options_null, STARCinit, STARCreset, 
  944.        STARCtext, null_scale, STARCgraphics, STARCmove, STARCvector, 
  945.        STARClinetype, STARCput_text, STARC_text_angle, 
  946.        null_justify_text, line_and_point, do_arrow}
  947. #endif
  948.  
  949. #ifdef SUN
  950.     ,{"sun", "SunView window system",
  951.        SUN_XMAX, SUN_YMAX, SUN_VCHAR, SUN_HCHAR, 
  952.        SUN_VTIC, SUN_HTIC, options_null, SUN_init, SUN_reset, 
  953.        SUN_text, null_scale, SUN_graphics, SUN_move, SUN_vector,
  954.        SUN_linetype, SUN_put_text, null_text_angle, 
  955.        SUN_justify_text, line_and_point, do_arrow}
  956. #endif
  957.  
  958. #ifdef VWS
  959.     ,{"VWS", "VAX Windowing System (UIS)",
  960.            VWS_XMAX, VWS_YMAX, VWS_VCHAR, VWS_HCHAR,
  961.            VWS_VTIC, VWS_HTIC, options_null, VWS_init, VWS_reset,
  962.            VWS_text, null_scale, VWS_graphics, VWS_move, VWS_vector,
  963.            VWS_linetype, VWS_put_text, VWS_text_angle,
  964.            VWS_justify_text, do_point, do_arrow}
  965. #endif
  966.  
  967. #ifdef TANDY60
  968.     ,{"tandy_60dpi", "Tandy DMP-130 series 60-dot per inch graphics",
  969.        EPS60XMAX, EPS60YMAX, EPSONVCHAR, EPSONHCHAR,
  970.        EPSONVTIC, EPSONHTIC, options_null, EPSONinit, EPSONreset,
  971.        TANDY60text, null_scale, EPS60graphics, EPSONmove, EPSONvector,
  972.        EPSONlinetype, EPSONput_text, EPSON_text_angle,
  973.        null_justify_text, do_point, do_arrow}
  974. #endif
  975.  
  976. #ifdef T410X
  977.     ,{"tek410x", "Tektronix 4106, 4107, 4109 and 420X terminals",
  978.        T410XXMAX, T410XYMAX, T410XVCHAR, T410XHCHAR, 
  979.        T410XVTIC, T410XHTIC, options_null, T410X_init, T410X_reset, 
  980.        T410X_text, null_scale, T410X_graphics, T410X_move, T410X_vector, 
  981.        T410X_linetype, T410X_put_text, T410X_text_angle, 
  982.        null_justify_text, T410X_point, do_arrow}
  983. #endif
  984.  
  985. #ifdef TEK
  986.     ,{"tek40xx", "Tektronix 4010 and others; most TEK emulators",
  987.        TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR, 
  988.        TEK40VTIC, TEK40HTIC, options_null, TEK40init, TEK40reset, 
  989.        TEK40text, null_scale, TEK40graphics, TEK40move, TEK40vector, 
  990.        TEK40linetype, TEK40put_text, null_text_angle, 
  991.        null_justify_text, line_and_point, do_arrow}
  992. #endif
  993.  
  994. #ifdef UNIXPLOT
  995.     ,{"unixplot", "Unix plotting standard (see plot(1))",
  996.        UP_XMAX, UP_YMAX, UP_VCHAR, UP_HCHAR, 
  997.        UP_VTIC, UP_HTIC, options_null, UP_init, UP_reset, 
  998.        UP_text, null_scale, UP_graphics, UP_move, UP_vector, 
  999.        UP_linetype, UP_put_text, null_text_angle, 
  1000.        null_justify_text, line_and_point, do_arrow}
  1001. #endif
  1002.     
  1003. #ifdef UNIXPC
  1004.     ,{"unixpc", "AT&T 3b1 or AT&T 7300 Unix PC",
  1005.        uPC_XMAX, uPC_YMAX, uPC_VCHAR, uPC_HCHAR, 
  1006.        uPC_VTIC, uPC_HTIC, options_null, uPC_init, uPC_reset, 
  1007.        uPC_text, null_scale, uPC_graphics, uPC_move, uPC_vector,
  1008.        uPC_linetype, uPC_put_text, uPC_text_angle, 
  1009.        null_justify_text, line_and_point, do_arrow}
  1010. #endif
  1011.  
  1012. #ifdef V384
  1013.     ,{"vx384", "Vectrix 384 and Tandy color printer",
  1014.        V384_XMAX, V384_YMAX, V384_VCHAR, V384_HCHAR, 
  1015.        V384_VTIC, V384_HTIC, options_null, V384_init, V384_reset, 
  1016.        V384_text, null_scale, V384_graphics, V384_move, V384_vector, 
  1017.        V384_linetype, V384_put_text, null_text_angle, 
  1018.        null_justify_text, do_point, do_arrow}
  1019. #endif
  1020.  
  1021. #ifdef VTTEK
  1022.     ,{"vttek", "VT-like tek40xx terminal emulator",
  1023.        TEK40XMAX,TEK40YMAX,TEK40VCHAR, TEK40HCHAR,
  1024.        TEK40VTIC, TEK40HTIC, options_null, VTTEK40init, VTTEK40reset,
  1025.        TEK40text, null_scale, TEK40graphics, TEK40move, TEK40vector,
  1026.        VTTEK40linetype, VTTEK40put_text, null_text_angle,
  1027.        null_justify_text, line_and_point, do_arrow}
  1028. #endif
  1029.  
  1030. #ifdef X11
  1031.     ,{"x11", "X11 Window System",
  1032.        X11_XMAX, X11_YMAX, X11_VCHAR, X11_HCHAR, 
  1033.        X11_VTIC, X11_HTIC, options_null, X11_init, X11_reset, 
  1034.        X11_text, null_scale, X11_graphics, X11_move, X11_vector, 
  1035.        X11_linetype, X11_put_text, null_text_angle, 
  1036.        X11_justify_text, line_and_point, do_arrow}
  1037.     ,{"X11", "X11 Window System - multi-color points",
  1038.        X11_XMAX, X11_YMAX, X11_VCHAR, X11_HCHAR, 
  1039.        X11_VTIC, X11_HTIC, options_null, X11_init, X11_reset, 
  1040.        X11_text, null_scale, X11_graphics, X11_move, X11_vector, 
  1041.        X11_linetype, X11_put_text, null_text_angle, 
  1042.        X11_justify_text, do_point, do_arrow}
  1043. #endif
  1044. };
  1045.  
  1046. #define TERMCOUNT (sizeof(term_tbl)/sizeof(struct termentry))
  1047.  
  1048.  
  1049. list_terms()
  1050. {
  1051. register int i;
  1052.  
  1053.     fprintf(stderr,"\nAvailable terminal types:\n");
  1054.     for (i = 0; i < TERMCOUNT; i++)
  1055.         fprintf(stderr,"  %15s  %s\n",
  1056.                term_tbl[i].name, term_tbl[i].description);
  1057.     (void) putc('\n',stderr);
  1058. }
  1059.  
  1060.  
  1061. /* set_term: get terminal number from name on command line */
  1062. /* will change 'term' variable if successful */
  1063. int                        /* term number */
  1064. set_term(c_token)
  1065. int c_token;
  1066. {
  1067.     register int t;
  1068.     char *input_name;
  1069.  
  1070.     if (!token[c_token].is_token)
  1071.      int_error("terminal name expected",c_token);
  1072.     t = -1;
  1073.     input_name = input_line + token[c_token].start_index;
  1074.     t = change_term(input_name, token[c_token].length);
  1075.     if (t == -1)
  1076.      int_error("unknown terminal type; type just 'set terminal' for a list",
  1077.              c_token);
  1078.     if (t == -2)
  1079.      int_error("ambiguous terminal name; type just 'set terminal' for a list",
  1080.              c_token);
  1081.  
  1082.     /* otherwise the type was changed */
  1083.  
  1084.     return(t);
  1085. }
  1086.  
  1087. /* change_term: get terminal number from name and set terminal type */
  1088. /* returns -1 if unknown, -2 if ambiguous, >=0 is terminal number */
  1089. int
  1090. change_term(name, length)
  1091.     char *name;
  1092.     int length;
  1093. {
  1094.     int i, t = -1;
  1095.  
  1096.     for (i = 0; i < TERMCOUNT; i++) {
  1097.        if (!strncmp(name,term_tbl[i].name,length)) {
  1098.           if (t != -1)
  1099.             return(-2);    /* ambiguous */
  1100.           t = i;
  1101.        }
  1102.     }
  1103.  
  1104.     if (t == -1)            /* unknown */
  1105.      return(t);
  1106.  
  1107.     /* Success: set terminal type now */
  1108.  
  1109.     term = t;
  1110.     term_init = FALSE;
  1111.     name = term_tbl[term].name;
  1112.  
  1113.     /* Special handling for unixplot term type */
  1114.     if (!strncmp("unixplot",name,8)) {
  1115.        UP_redirect (2);  /* Redirect actual stdout for unixplots */
  1116.     } else if (unixplot) {
  1117.        UP_redirect (3);  /* Put stdout back together again. */
  1118.     }
  1119.  
  1120.     if (interactive)
  1121.      fprintf(stderr, "Terminal type set to '%s'\n", name);
  1122.  
  1123.     return(t);
  1124. }
  1125.  
  1126. /*
  1127.    Routine to detect what terminal is being used (or do anything else
  1128.    that would be nice).  One anticipated (or allowed for) side effect
  1129.    is that the global ``term'' may be set. 
  1130.    The environment variable GNUTERM is checked first; if that does
  1131.    not exist, then the terminal hardware is checked, if possible, 
  1132.    and finally, we can check $TERM for some kinds of terminals.
  1133. */
  1134. /* thanks to osupyr!alden (Dave Alden) for the original GNUTERM code */
  1135. init_terminal()
  1136. {
  1137.     char *term_name = NULL;
  1138.     int t;
  1139.     char *term = NULL;        /* from TERM environment var */
  1140. #ifdef X11
  1141.     char *display = NULL;
  1142. #endif
  1143.     char *gnuterm = NULL;
  1144.  
  1145.     /* GNUTERM environment variable is primary */
  1146.     gnuterm = getenv("GNUTERM");
  1147.     if (gnuterm != (char *)NULL)
  1148.      term_name = gnuterm;
  1149.     else {
  1150. #ifdef __TURBOC__
  1151.        term_name = turboc_init();
  1152.        term = (char *)NULL; /* shut up turbo C */
  1153. #endif
  1154.        
  1155. #ifdef vms
  1156.        term_name = vms_init();
  1157. #endif
  1158.        
  1159. #ifdef SUN
  1160.        term = getenv("TERM");    /* try $TERM */
  1161.        if (term_name == (char *)NULL
  1162.           && term != (char *)NULL && strcmp(term, "sun") == 0)
  1163.         term_name = "sun";
  1164. #endif /* sun */
  1165.  
  1166. #ifdef GPR
  1167.    if (gpr_isa_pad()) term_name = "gpr";       /* find out whether stdout is a DM pad. See term/gpr.trm */
  1168. #else
  1169. #ifdef APOLLO
  1170.    if (apollo_isa_pad()) term_name = "apollo"; /* find out whether stdout is a DM pad. See term/apollo.trm */
  1171. #endif /* APOLLO */
  1172. #endif /* GPR    */
  1173.  
  1174. #ifdef X11
  1175.        term = getenv("TERM");    /* try $TERM */
  1176.        if (term_name == (char *)NULL
  1177.           && term != (char *)NULL && strcmp(term, "xterm") == 0)
  1178.         term_name = "x11";
  1179.        display = getenv("DISPLAY");
  1180.        if (term_name == (char *)NULL && display != (char *)NULL)
  1181.         term_name = "x11";
  1182. #endif /* x11 */
  1183.  
  1184. #ifdef AMIGASCREEN
  1185.        term_name = "amiga";
  1186. #endif
  1187.  
  1188. #ifdef UNIXPC
  1189.            if (iswind() == 0) {
  1190.               term_name = "unixpc";
  1191.            }
  1192. #endif /* unixpc */
  1193.  
  1194. #ifdef CGI
  1195.        if (getenv("CGIDISP") || getenv("CGIPRNT"))
  1196.          term_name = "cgi";
  1197. #endif /*CGI */
  1198.     }
  1199.  
  1200.     /* We have a name, try to set term type */
  1201.     if (term_name != NULL && *term_name != '\0') {
  1202.        t = change_term(term_name, strlen(term_name));
  1203.        if (t == -1)
  1204.         fprintf(stderr, "Unknown terminal name '%s'\n", term_name);
  1205.        else if (t == -2)
  1206.         fprintf(stderr, "Ambiguous terminal name '%s'\n", term_name);
  1207.        else                /* successful */
  1208.         ;
  1209.     }
  1210. }
  1211.  
  1212.  
  1213. #ifdef __TURBOC__
  1214. char *
  1215. turboc_init()
  1216. {
  1217.   int g_driver,g_mode;
  1218.   char far *c1,*c2;
  1219.   char *term_name = NULL;
  1220.   struct text_info tinfo;       /* So we can restore starting text mode. */
  1221.  
  1222. /* Some of this code including BGI drivers is copyright Borland Intl. */
  1223.     g_driver=DETECT;
  1224.           get_path();
  1225.     gettextinfo(&tinfo);
  1226.         initgraph(&g_driver,&g_mode,path);
  1227.         c1=getdrivername();
  1228.         c2=getmodename(g_mode);
  1229.           switch (g_driver){
  1230.             case -2: fprintf(stderr,"Graphics card not detected.\n");
  1231.                      break;
  1232.             case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1233.                      break;
  1234.             case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1235.                      break;
  1236.             case -5: fprintf(stderr,"Insufficient memory to load ",
  1237.                              "graphics driver.");
  1238.                      break;
  1239.             case 1 : term_name = "cga";
  1240.                      break;
  1241.             case 2 : term_name = "mcga";
  1242.                      break;
  1243.             case 3 : 
  1244.             case 4 : term_name = "egalib";
  1245.                      break;
  1246.             case 7 : term_name = "hercules";
  1247.                      break;
  1248.             case 8 : term_name = "att";
  1249.                      break;
  1250.             case 9 : term_name = "vgalib";
  1251.                      break;
  1252.             }
  1253.         closegraph();
  1254.         textmode(tinfo.currmode);
  1255.     clrscr();
  1256.     fprintf(stderr,"\tTC Graphics, driver %s  mode %s\n",c1,c2);
  1257.   return(term_name);
  1258. }
  1259. #endif /* __TURBOC__ */
  1260.  
  1261. /*
  1262.     This is always defined so we don't have to have command.c know if it
  1263.     is there or not.
  1264. */
  1265. #ifndef UNIXPLOT
  1266. UP_redirect(caller) int caller; 
  1267. {
  1268.     caller = caller;    /* to stop Turbo C complaining 
  1269.                          * about caller not being used */
  1270. }
  1271. #else
  1272. UP_redirect (caller)
  1273. int caller;
  1274. /*
  1275.     Unixplot can't really write to outfile--it wants to write to stdout.
  1276.     This is normally ok, but the original design of gnuplot gives us
  1277.     little choice.  Originally users of unixplot had to anticipate
  1278.     their needs and redirect all I/O to a file...  Not very gnuplot-like.
  1279.  
  1280.     caller:  1 - called from SET OUTPUT "FOO.OUT"
  1281.              2 - called from SET TERM UNIXPLOT
  1282.              3 - called from SET TERM other
  1283.              4 - called from SET OUTPUT
  1284. */
  1285. {
  1286.     switch (caller) {
  1287.     case 1:
  1288.     /* Don't save, just replace stdout w/outfile (save was already done). */
  1289.         if (unixplot)
  1290.             *(stdout) = *(outfile);  /* Copy FILE structure */
  1291.     break;
  1292.     case 2:
  1293.         if (!unixplot) {
  1294.             fflush(stdout);
  1295.             save_stdout = *(stdout);
  1296.             *(stdout) = *(outfile);  /* Copy FILE structure */
  1297.             unixplot = 1;
  1298.         }
  1299.     break;
  1300.     case 3:
  1301.     /* New terminal in use--put stdout back to original. */
  1302.         closepl();
  1303.         fflush(stdout);
  1304.         *(stdout) = save_stdout;  /* Copy FILE structure */
  1305.         unixplot = 0;
  1306.     break;
  1307.     case 4:
  1308.     /*  User really wants to go to normal output... */
  1309.         if (unixplot) {
  1310.             fflush(stdout);
  1311.             *(stdout) = save_stdout;  /* Copy FILE structure */
  1312.         }
  1313.     break;
  1314.     }
  1315. }
  1316. #endif
  1317.  
  1318.  
  1319. /* test terminal by drawing border and text */
  1320. /* called from command test */
  1321. test_term()
  1322. {
  1323.     register struct termentry *t = &term_tbl[term];
  1324.     char *str;
  1325.     int x,y, xl,yl, i;
  1326.     unsigned int xmax, ymax;
  1327.     char label[MAX_ID_LEN];
  1328.     int scaling;
  1329.  
  1330.     if (!term_init) {
  1331.        (*t->init)();
  1332.        term_init = TRUE;
  1333.     }
  1334.     screen_ok = FALSE;
  1335.     scaling = (*t->scale)(xsize, ysize);
  1336.     xmax = (unsigned int)(t->xmax * (scaling ? 1 : xsize));
  1337.     ymax = (unsigned int)(t->ymax * (scaling ? 1 : ysize));
  1338.     (*t->graphics)();
  1339.     /* border linetype */
  1340.     (*t->linetype)(-2);
  1341.     (*t->move)(0,0);
  1342.     (*t->vector)(xmax-1,0);
  1343.     (*t->vector)(xmax-1,ymax-1);
  1344.     (*t->vector)(0,ymax-1);
  1345.     (*t->vector)(0,0);
  1346.     (void) (*t->justify_text)(LEFT);
  1347.     (*t->put_text)(t->h_char*5,ymax-t->v_char*3,"Terminal Test");
  1348.     /* axis linetype */
  1349.     (*t->linetype)(-1);
  1350.     (*t->move)(xmax/2,0);
  1351.     (*t->vector)(xmax/2,ymax-1);
  1352.     (*t->move)(0,ymax/2);
  1353.     (*t->vector)(xmax-1,ymax/2);
  1354.     /* test width and height of characters */
  1355.     (*t->linetype)(-2);
  1356.     (*t->move)(  xmax/2-t->h_char*10,ymax/2+t->v_char/2);
  1357.     (*t->vector)(xmax/2+t->h_char*10,ymax/2+t->v_char/2);
  1358.     (*t->vector)(xmax/2+t->h_char*10,ymax/2-t->v_char/2);
  1359.     (*t->vector)(xmax/2-t->h_char*10,ymax/2-t->v_char/2);
  1360.     (*t->vector)(xmax/2-t->h_char*10,ymax/2+t->v_char/2);
  1361.     (*t->put_text)(xmax/2-t->h_char*10,ymax/2,
  1362.         "12345678901234567890");
  1363.     /* test justification */
  1364.     (void) (*t->justify_text)(LEFT);
  1365.     (*t->put_text)(xmax/2,ymax/2+t->v_char*6,"left justified");
  1366.     str = "centre+d text";
  1367.     if ((*t->justify_text)(CENTRE))
  1368.         (*t->put_text)(xmax/2,
  1369.                 ymax/2+t->v_char*5,str);
  1370.     else
  1371.         (*t->put_text)(xmax/2-strlen(str)*t->h_char/2,
  1372.                 ymax/2+t->v_char*5,str);
  1373.     str = "right justified";
  1374.     if ((*t->justify_text)(RIGHT))
  1375.         (*t->put_text)(xmax/2,
  1376.                 ymax/2+t->v_char*4,str);
  1377.     else
  1378.         (*t->put_text)(xmax/2-strlen(str)*t->h_char,
  1379.                 ymax/2+t->v_char*4,str);
  1380.     /* test text angle */
  1381.     str = "rotated ce+ntred text";
  1382.     if ((*t->text_angle)(1)) {
  1383.         if ((*t->justify_text)(CENTRE))
  1384.             (*t->put_text)(t->v_char,
  1385.                 ymax/2,str);
  1386.         else
  1387.             (*t->put_text)(t->v_char,
  1388.                 ymax/2-strlen(str)*t->h_char/2,str);
  1389.     }
  1390.     else {
  1391.         (void) (*t->justify_text)(LEFT);
  1392.         (*t->put_text)(t->h_char*2,ymax/2-t->v_char*2,"Can't rotate text");
  1393.     }
  1394.     (void) (*t->justify_text)(LEFT);
  1395.     (void) (*t->text_angle)(0);
  1396.     /* test tic size */
  1397.     (*t->move)(xmax/2+t->h_tic*2,0);
  1398.     (*t->vector)(xmax/2+t->h_tic*2,t->v_tic);
  1399.     (*t->move)(xmax/2,t->v_tic*2);
  1400.     (*t->vector)(xmax/2+t->h_tic,t->v_tic*2);
  1401.     (*t->put_text)(xmax/2+t->h_tic*2,t->v_tic*2+t->v_char/2,"test tics");
  1402.     /* test line and point types */
  1403.     x = xmax - t->h_char*4 - t->h_tic*4;
  1404.     y = ymax - t->v_char;
  1405.     for ( i = -2; y > t->v_char; i++ ) {
  1406.         (*t->linetype)(i);
  1407.         (void) sprintf(label,"%d",i);
  1408.         if ((*t->justify_text)(RIGHT))
  1409.             (*t->put_text)(x,y,label);
  1410.         else
  1411.             (*t->put_text)(x-strlen(label)*t->h_char,y,label);
  1412.         (*t->move)(x+t->h_char,y);
  1413.         (*t->vector)(x+t->h_char*4,y);
  1414.         if ( i >= -1 )
  1415.             (*t->point)(x+t->h_char*4+t->h_tic*2,y,i);
  1416.         y -= t->v_char;
  1417.     }
  1418.     /* test some arrows */
  1419.     (*t->linetype)(0);
  1420.     x = xmax/4;
  1421.     y = ymax/4;
  1422.     xl = t->h_tic*5;
  1423.     yl = t->v_tic*5;
  1424.     (*t->arrow)(x,y,x+xl,y,TRUE);
  1425.     (*t->arrow)(x,y,x+xl/2,y+yl,TRUE);
  1426.     (*t->arrow)(x,y,x,y+yl,TRUE);
  1427.     (*t->arrow)(x,y,x-xl/2,y+yl,FALSE);
  1428.     (*t->arrow)(x,y,x-xl,y,TRUE);
  1429.     (*t->arrow)(x,y,x-xl,y-yl,TRUE);
  1430.     (*t->arrow)(x,y,x,y-yl,TRUE);
  1431.     (*t->arrow)(x,y,x+xl,y-yl,TRUE);
  1432.     /* and back into text mode */
  1433.     (*t->text)();
  1434. }
  1435.  
  1436.  
  1437. #ifdef PC
  1438. /* output for some terminal types must be binary to stop non Unix computers
  1439.    changing \n to \r\n. 
  1440.    If the output is not STDOUT, the following code reopens outfile 
  1441.    with binary mode. */
  1442. void
  1443. reopen_binary()
  1444. {
  1445. char filename[MAX_ID_LEN+1];
  1446.  
  1447.     if (strcmp(outstr,"STDOUT")) {
  1448.         (void) fclose(outfile);
  1449.         (void) strcpy(filename,outstr+1);    /* remove quotes */
  1450.         filename[strlen(filename)-1] = '\0';
  1451.         if ( (outfile = fopen(filename,"wb")) == (FILE *)NULL ) {
  1452.             if ( (outfile = fopen(filename,"w")) == (FILE *)NULL ) {
  1453.                 os_error("cannot reopen file with binary type; output unknown",
  1454.                     NO_CARET);
  1455.             } 
  1456.             else {
  1457.     os_error("cannot reopen file with binary type; output reset to ascii", 
  1458.                     NO_CARET);
  1459.             }
  1460.         }
  1461.     }
  1462. }
  1463. #endif
  1464.  
  1465. #ifdef vms
  1466. /* these are needed to modify terminal characteristics */
  1467. #include <descrip.h>
  1468. #include <iodef.h>
  1469. #include <ttdef.h>
  1470. #include <tt2def.h>
  1471. #include <dcdef.h>
  1472. #include <ssdef.h>
  1473. #include <stat.h>
  1474. #include <fab.h>
  1475. static unsigned short   chan;
  1476. static int  old_char_buf[3], cur_char_buf[3];
  1477. $DESCRIPTOR(sysoutput_desc,"SYS$OUTPUT");
  1478.  
  1479. char *vms_init()
  1480. /*
  1481.  * Determine if we have a regis terminal
  1482.  * and save terminal characteristics
  1483. */
  1484. {
  1485.    /* Save terminal characteristics in old_char_buf and
  1486.    initialise cur_char_buf to current settings. */
  1487.    int i;
  1488.    sys$assign(&sysoutput_desc,&chan,0,0);
  1489.    sys$qiow(0,chan,IO$_SENSEMODE,0,0,0,old_char_buf,12,0,0,0,0);
  1490.    for (i = 0 ; i < 3 ; ++i) cur_char_buf[i] = old_char_buf[i];
  1491.    sys$dassgn(chan);
  1492.  
  1493.    /* Test if terminal is regis */
  1494.    if ((cur_char_buf[2] & TT2$M_REGIS) == TT2$M_REGIS) return("regis");
  1495.    return(NULL);
  1496. }
  1497.  
  1498. void
  1499. vms_reset()
  1500. /* set terminal to original state */
  1501. {
  1502.    int i;
  1503.    sys$assign(&sysoutput_desc,&chan,0,0);
  1504.    sys$qiow(0,chan,IO$_SETMODE,0,0,0,old_char_buf,12,0,0,0,0);
  1505.    for (i = 0 ; i < 3 ; ++i) cur_char_buf[i] = old_char_buf[i];
  1506.    sys$dassgn(chan);
  1507. }
  1508.  
  1509. void
  1510. term_mode_tek()
  1511. /* set terminal mode to tektronix */
  1512. {
  1513.    long status;
  1514.    if (outfile != stdout) return; /* don't modify if not stdout */
  1515.    sys$assign(&sysoutput_desc,&chan,0,0);
  1516.    cur_char_buf[0] = 0x004A0000 | DC$_TERM | (TT$_TEK401X<<8);
  1517.    cur_char_buf[1] = (cur_char_buf[1] & 0x00FFFFFF) | 0x18000000;
  1518.  
  1519.    cur_char_buf[1] &= ~TT$M_CRFILL;
  1520.    cur_char_buf[1] &= ~TT$M_ESCAPE;
  1521.    cur_char_buf[1] &= ~TT$M_HALFDUP;
  1522.    cur_char_buf[1] &= ~TT$M_LFFILL;
  1523.    cur_char_buf[1] &= ~TT$M_MECHFORM;
  1524.    cur_char_buf[1] &= ~TT$M_NOBRDCST;
  1525.    cur_char_buf[1] &= ~TT$M_NOECHO;
  1526.    cur_char_buf[1] &= ~TT$M_READSYNC;
  1527.    cur_char_buf[1] &= ~TT$M_REMOTE;
  1528.    cur_char_buf[1] |= TT$M_LOWER;
  1529.    cur_char_buf[1] |= TT$M_TTSYNC;
  1530.    cur_char_buf[1] |= TT$M_WRAP;
  1531.    cur_char_buf[1] &= ~TT$M_EIGHTBIT;
  1532.    cur_char_buf[1] &= ~TT$M_MECHTAB;
  1533.    cur_char_buf[1] &= ~TT$M_SCOPE;
  1534.    cur_char_buf[1] |= TT$M_HOSTSYNC;
  1535.  
  1536.    cur_char_buf[2] &= ~TT2$M_APP_KEYPAD;
  1537.    cur_char_buf[2] &= ~TT2$M_BLOCK;
  1538.    cur_char_buf[2] &= ~TT2$M_DECCRT3;
  1539.    cur_char_buf[2] &= ~TT2$M_LOCALECHO;
  1540.    cur_char_buf[2] &= ~TT2$M_PASTHRU;
  1541.    cur_char_buf[2] &= ~TT2$M_REGIS;
  1542.    cur_char_buf[2] &= ~TT2$M_SIXEL;
  1543.    cur_char_buf[2] |= TT2$M_BRDCSTMBX;
  1544.    cur_char_buf[2] |= TT2$M_EDITING;
  1545.    cur_char_buf[2] |= TT2$M_INSERT;
  1546.    cur_char_buf[2] |= TT2$M_PRINTER;
  1547.    cur_char_buf[2] &= ~TT2$M_ANSICRT;
  1548.    cur_char_buf[2] &= ~TT2$M_AVO;
  1549.    cur_char_buf[2] &= ~TT2$M_DECCRT;
  1550.    cur_char_buf[2] &= ~TT2$M_DECCRT2;
  1551.    cur_char_buf[2] &= ~TT2$M_DRCS;
  1552.    cur_char_buf[2] &= ~TT2$M_EDIT;
  1553.    cur_char_buf[2] |= TT2$M_FALLBACK;
  1554.  
  1555.    status = sys$qiow(0,chan,IO$_SETMODE,0,0,0,cur_char_buf,12,0,0,0,0);
  1556.    if (status == SS$_BADPARAM) {
  1557.       /* terminal fallback utility not installed on system */
  1558.       cur_char_buf[2] &= ~TT2$M_FALLBACK;
  1559.       sys$qiow(0,chan,IO$_SETMODE,0,0,0,cur_char_buf,12,0,0,0,0);
  1560.    }
  1561.    else {
  1562.       if (status != SS$_NORMAL)
  1563.          lib$signal(status,0,0);
  1564.    }
  1565.    sys$dassgn(chan);
  1566. }
  1567.  
  1568. void
  1569. term_mode_native()
  1570. /* set terminal mode back to native */
  1571. {
  1572.    int i;
  1573.    if (outfile != stdout) return; /* don't modify if not stdout */
  1574.    sys$assign(&sysoutput_desc,&chan,0,0);
  1575.    sys$qiow(0,chan,IO$_SETMODE,0,0,0,old_char_buf,12,0,0,0,0);
  1576.    for (i = 0 ; i < 3 ; ++i) cur_char_buf[i] = old_char_buf[i];
  1577.    sys$dassgn(chan);
  1578. }
  1579.  
  1580. void
  1581. term_pasthru()
  1582. /* set terminal mode pasthru */
  1583. {
  1584.    if (outfile != stdout) return; /* don't modify if not stdout */
  1585.    sys$assign(&sysoutput_desc,&chan,0,0);
  1586.    cur_char_buf[2] |= TT2$M_PASTHRU;
  1587.    sys$qiow(0,chan,IO$_SETMODE,0,0,0,cur_char_buf,12,0,0,0,0);
  1588.    sys$dassgn(chan);
  1589. }
  1590.  
  1591. void
  1592. term_nopasthru()
  1593. /* set terminal mode nopasthru */
  1594. {
  1595.    if (outfile != stdout) return; /* don't modify if not stdout */
  1596.    sys$assign(&sysoutput_desc,&chan,0,0);
  1597.    cur_char_buf[2] &= ~TT2$M_PASTHRU;
  1598.    sys$qiow(0,chan,IO$_SETMODE,0,0,0,cur_char_buf,12,0,0,0,0);
  1599.    sys$dassgn(chan);
  1600. }
  1601.  
  1602. void
  1603. reopen_binary()
  1604. /* close the file outfile outfile and reopen it with binary type
  1605.    if not already done or outfile == stdout */
  1606. {
  1607.    stat_t stat_buf;
  1608.    char filename[MAX_ID_LEN+1];
  1609.    if (outfile != stdout) { /* don't modify if not stdout */
  1610.       if (!fstat(fileno(outfile),&stat_buf)) {
  1611.          if (stat_buf.st_fab_rfm != FAB$C_FIX) {
  1612.             /* modify only if not already done */
  1613.             (void) fclose(outfile);
  1614.             (void) strcpy(filename,outstr+1);   /* remove quotes */
  1615.             filename[strlen(filename)-1] = '\0';
  1616.             (void) delete(filename);
  1617.             if ((outfile = fopen(filename,"wb","rfm=fix","bls=512","mrs=512"))
  1618.                 == (FILE *)NULL ) {
  1619.                if ( (outfile = fopen(filename,"w")) == (FILE *)NULL ) {
  1620.                  os_error("cannot reopen file with binary type; output unknown",
  1621.                            NO_CARET);
  1622.                }
  1623.                else {
  1624.           os_error("cannot reopen file with binary type; output reset to ascii",
  1625.                            NO_CARET);
  1626.                }
  1627.             }
  1628.          }
  1629.       }
  1630.       else{
  1631.          os_error("cannot reopen file with binary type; output remains ascii",
  1632.                   NO_CARET);
  1633.       }
  1634.    }
  1635. }
  1636.  
  1637. void
  1638. fflush_binary()
  1639. {
  1640.    typedef short int INT16;     /* signed 16-bit integers */
  1641.    register INT16 k;            /* loop index */
  1642.    if (outfile != stdout) {
  1643.        /* Stupid VMS fflush() raises error and loses last data block
  1644.           unless it is full for a fixed-length record binary file.
  1645.           Pad it here with NULL characters. */
  1646.        for (k = (INT16)((*outfile)->_cnt); k > 0; --k)
  1647.           putc('\0',outfile);
  1648.        fflush(outfile);
  1649.    }
  1650. }
  1651. #endif
  1652.