jdc@naucse.UUCP (John Campbell) (09/04/89)
#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 5 (of 7)." # Contents: ./internal.c ./pc.trm ./term.c # Wrapped by jdc@naucse on Mon Sep 4 09:22:35 1989 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f './internal.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'./internal.c'\" else echo shar: Extracting \"'./internal.c'\" \(13596 characters\) sed "s/^X//" >'./internal.c' <<'END_OF_FILE' X/* X * X * G N U P L O T -- internal.c X * X * Copyright (C) 1986, 1987 Colin Kelley, Thomas Williams X * X * You may use this code as you wish if credit is given and this message X * is retained. X * X * Please e-mail any useful additions to vu-vlsi!plot so they may be X * included in later releases. X * X * This file should be edited with 4-column tabs! (:set ts=4 sw=4 in vi) X */ X X#include <math.h> X#include <stdio.h> X#include "plot.h" X Xextern BOOLEAN undefined; X Xchar *strcpy(); X Xstruct value *pop(), *complex(), *integer(); Xdouble magnitude(), angle(), real(); X Xstruct value stack[STACK_DEPTH]; X Xint s_p = -1; /* stack pointer */ X X X/* X * System V and MSC 4.0 call this when they wants to print an error message. X * Don't! X */ Xmatherr() X{ X return (undefined = TRUE); /* don't print error message */ X} X X Xreset_stack() X{ X s_p = -1; X} X X Xcheck_stack() /* make sure stack's empty */ X{ X if (s_p != -1) X fprintf(stderr,"\nwarning: internal error--stack not empty!\n"); X} X X Xstruct value *pop(x) Xstruct value *x; X{ X if (s_p < 0 ) X int_error("stack underflow",NO_CARET); X *x = stack[s_p--]; X return(x); X} X X Xpush(x) Xstruct value *x; X{ X if (s_p == STACK_DEPTH - 1) X int_error("stack overflow",NO_CARET); X stack[++s_p] = *x; X} X X X#define ERR_VAR "undefined variable: " X Xf_push(x) Xunion argument *x; /* contains pointer to value to push; */ X{ Xstatic char err_str[sizeof(ERR_VAR) + MAX_ID_LEN] = ERR_VAR; Xstruct udvt_entry *udv; X X udv = x->udv_arg; X if (udv->udv_undef) { /* undefined */ X (void) strcpy(&err_str[sizeof(ERR_VAR) - 1], udv->udv_name); X int_error(err_str,NO_CARET); X } X push(&(udv->udv_value)); X} X X Xf_pushc(x) Xunion argument *x; X{ X push(&(x->v_arg)); X} X X Xf_pushd(x) Xunion argument *x; X{ X push(&(x->udf_arg->dummy_value)); X} X X X#define ERR_FUN "undefined function: " X Xf_call(x) /* execute a udf */ Xunion argument *x; X{ Xstatic char err_str[sizeof(ERR_FUN) + MAX_ID_LEN] = ERR_FUN; Xregister struct udft_entry *udf; X X udf = x->udf_arg; X if (!udf->at) { /* undefined */ X (void) strcpy(&err_str[sizeof(ERR_FUN) - 1], X udf->udf_name); X int_error(err_str,NO_CARET); X } X (void) pop(&(udf->dummy_value)); X X execute_at(udf->at); X} X X Xstatic int_check(v) Xstruct value *v; X{ X if (v->type != INT) X int_error("non-integer passed to boolean operator",NO_CARET); X} X X Xf_lnot() X{ Xstruct value a; X int_check(pop(&a)); X push(integer(&a,!a.v.int_val) ); X} X X Xf_bnot() X{ Xstruct value a; X int_check(pop(&a)); X push( integer(&a,~a.v.int_val) ); X} X X Xf_bool() X{ /* converts top-of-stack to boolean */ X int_check(&top_of_stack); X top_of_stack.v.int_val = !!top_of_stack.v.int_val; X} X X Xf_lor() X{ Xstruct value a,b; X int_check(pop(&b)); X int_check(pop(&a)); X push( integer(&a,a.v.int_val || b.v.int_val) ); X} X Xf_land() X{ Xstruct value a,b; X int_check(pop(&b)); X int_check(pop(&a)); X push( integer(&a,a.v.int_val && b.v.int_val) ); X} X X Xf_bor() X{ Xstruct value a,b; X int_check(pop(&b)); X int_check(pop(&a)); X push( integer(&a,a.v.int_val | b.v.int_val) ); X} X X Xf_xor() X{ Xstruct value a,b; X int_check(pop(&b)); X int_check(pop(&a)); X push( integer(&a,a.v.int_val ^ b.v.int_val) ); X} X X Xf_band() X{ Xstruct value a,b; X int_check(pop(&b)); X int_check(pop(&a)); X push( integer(&a,a.v.int_val & b.v.int_val) ); X} X X Xf_uminus() X{ Xstruct value a; X (void) pop(&a); X switch(a.type) { X case INT: X a.v.int_val = -a.v.int_val; X break; X case CMPLX: X a.v.cmplx_val.real = X -a.v.cmplx_val.real; X a.v.cmplx_val.imag = X -a.v.cmplx_val.imag; X } X push(&a); X} X X Xf_eq() /* note: floating point equality is rare because of roundoff error! */ X{ Xstruct value a, b; X register int result; X (void) pop(&b); X (void) pop(&a); X switch(a.type) { X case INT: X switch (b.type) { X case INT: X result = (a.v.int_val == X b.v.int_val); X break; X case CMPLX: X result = (a.v.int_val == X b.v.cmplx_val.real && X b.v.cmplx_val.imag == 0.0); X } X break; X case CMPLX: X switch (b.type) { X case INT: X result = (b.v.int_val == a.v.cmplx_val.real && X a.v.cmplx_val.imag == 0.0); X break; X case CMPLX: X result = (a.v.cmplx_val.real== X b.v.cmplx_val.real && X a.v.cmplx_val.imag== X b.v.cmplx_val.imag); X } X } X push(integer(&a,result)); X} X X Xf_ne() X{ Xstruct value a, b; X register int result; X (void) pop(&b); X (void) pop(&a); X switch(a.type) { X case INT: X switch (b.type) { X case INT: X result = (a.v.int_val != X b.v.int_val); X break; X case CMPLX: X result = (a.v.int_val != X b.v.cmplx_val.real || X b.v.cmplx_val.imag != 0.0); X } X break; X case CMPLX: X switch (b.type) { X case INT: X result = (b.v.int_val != X a.v.cmplx_val.real || X a.v.cmplx_val.imag != 0.0); X break; X case CMPLX: X result = (a.v.cmplx_val.real != X b.v.cmplx_val.real || X a.v.cmplx_val.imag != X b.v.cmplx_val.imag); X } X } X push(integer(&a,result)); X} X X Xf_gt() X{ Xstruct value a, b; X register int result; X (void) pop(&b); X (void) pop(&a); X switch(a.type) { X case INT: X switch (b.type) { X case INT: X result = (a.v.int_val > X b.v.int_val); X break; X case CMPLX: X result = (a.v.int_val > X b.v.cmplx_val.real); X } X break; X case CMPLX: X switch (b.type) { X case INT: X result = (a.v.cmplx_val.real > X b.v.int_val); X break; X case CMPLX: X result = (a.v.cmplx_val.real > X b.v.cmplx_val.real); X } X } X push(integer(&a,result)); X} X X Xf_lt() X{ Xstruct value a, b; X register int result; X (void) pop(&b); X (void) pop(&a); X switch(a.type) { X case INT: X switch (b.type) { X case INT: X result = (a.v.int_val < X b.v.int_val); X break; X case CMPLX: X result = (a.v.int_val < X b.v.cmplx_val.real); X } X break; X case CMPLX: X switch (b.type) { X case INT: X result = (a.v.cmplx_val.real < X b.v.int_val); X break; X case CMPLX: X result = (a.v.cmplx_val.real < X b.v.cmplx_val.real); X } X } X push(integer(&a,result)); X} X X Xf_ge() X{ Xstruct value a, b; X register int result; X (void) pop(&b); X (void) pop(&a); X switch(a.type) { X case INT: X switch (b.type) { X case INT: X result = (a.v.int_val >= X b.v.int_val); X break; X case CMPLX: X result = (a.v.int_val >= X b.v.cmplx_val.real); X } X break; X case CMPLX: X switch (b.type) { X case INT: X result = (a.v.cmplx_val.real >= X b.v.int_val); X break; X case CMPLX: X result = (a.v.cmplx_val.real >= X b.v.cmplx_val.real); X } X } X push(integer(&a,result)); X} X X Xf_le() X{ Xstruct value a, b; X register int result; X (void) pop(&b); X (void) pop(&a); X switch(a.type) { X case INT: X switch (b.type) { X case INT: X result = (a.v.int_val <= X b.v.int_val); X break; X case CMPLX: X result = (a.v.int_val <= X b.v.cmplx_val.real); X } X break; X case CMPLX: X switch (b.type) { X case INT: X result = (a.v.cmplx_val.real <= X b.v.int_val); X break; X case CMPLX: X result = (a.v.cmplx_val.real <= X b.v.cmplx_val.real); X } X } X push(integer(&a,result)); X} X X Xf_plus() X{ Xstruct value a, b, result; X (void) pop(&b); X (void) pop(&a); X switch(a.type) { X case INT: X switch (b.type) { X case INT: X (void) integer(&result,a.v.int_val + X b.v.int_val); X break; X case CMPLX: X (void) complex(&result,a.v.int_val + X b.v.cmplx_val.real, X b.v.cmplx_val.imag); X } X break; X case CMPLX: X switch (b.type) { X case INT: X (void) complex(&result,b.v.int_val + X a.v.cmplx_val.real, X a.v.cmplx_val.imag); X break; X case CMPLX: X (void) complex(&result,a.v.cmplx_val.real+ X b.v.cmplx_val.real, X a.v.cmplx_val.imag+ X b.v.cmplx_val.imag); X } X } X push(&result); X} X X Xf_minus() X{ Xstruct value a, b, result; X (void) pop(&b); X (void) pop(&a); /* now do a - b */ X switch(a.type) { X case INT: X switch (b.type) { X case INT: X (void) integer(&result,a.v.int_val - X b.v.int_val); X break; X case CMPLX: X (void) complex(&result,a.v.int_val - X b.v.cmplx_val.real, X -b.v.cmplx_val.imag); X } X break; X case CMPLX: X switch (b.type) { X case INT: X (void) complex(&result,a.v.cmplx_val.real - X b.v.int_val, X a.v.cmplx_val.imag); X break; X case CMPLX: X (void) complex(&result,a.v.cmplx_val.real- X b.v.cmplx_val.real, X a.v.cmplx_val.imag- X b.v.cmplx_val.imag); X } X } X push(&result); X} X X Xf_mult() X{ Xstruct value a, b, result; X (void) pop(&b); X (void) pop(&a); /* now do a*b */ X X switch(a.type) { X case INT: X switch (b.type) { X case INT: X (void) integer(&result,a.v.int_val * X b.v.int_val); X break; X case CMPLX: X (void) complex(&result,a.v.int_val * X b.v.cmplx_val.real, X a.v.int_val * X b.v.cmplx_val.imag); X } X break; X case CMPLX: X switch (b.type) { X case INT: X (void) complex(&result,b.v.int_val * X a.v.cmplx_val.real, X b.v.int_val * X a.v.cmplx_val.imag); X break; X case CMPLX: X (void) complex(&result,a.v.cmplx_val.real* X b.v.cmplx_val.real- X a.v.cmplx_val.imag* X b.v.cmplx_val.imag, X a.v.cmplx_val.real* X b.v.cmplx_val.imag+ X a.v.cmplx_val.imag* X b.v.cmplx_val.real); X } X } X push(&result); X} X X Xf_div() X{ Xstruct value a, b, result; Xregister double square; X (void) pop(&b); X (void) pop(&a); /* now do a/b */ X X switch(a.type) { X case INT: X switch (b.type) { X case INT: X if (b.v.int_val) X (void) integer(&result,a.v.int_val / X b.v.int_val); X else { X (void) integer(&result,0); X undefined = TRUE; X } X break; X case CMPLX: X square = b.v.cmplx_val.real* X b.v.cmplx_val.real + X b.v.cmplx_val.imag* X b.v.cmplx_val.imag; X if (square) X (void) complex(&result,a.v.int_val* X b.v.cmplx_val.real/square, X -a.v.int_val* X b.v.cmplx_val.imag/square); X else { X (void) complex(&result,0.0,0.0); X undefined = TRUE; X } X } X break; X case CMPLX: X switch (b.type) { X case INT: X if (b.v.int_val) X X (void) complex(&result,a.v.cmplx_val.real/ X b.v.int_val, X a.v.cmplx_val.imag/ X b.v.int_val); X else { X (void) complex(&result,0.0,0.0); X undefined = TRUE; X } X break; X case CMPLX: X square = b.v.cmplx_val.real* X b.v.cmplx_val.real + X b.v.cmplx_val.imag* X b.v.cmplx_val.imag; X if (square) X (void) complex(&result,(a.v.cmplx_val.real* X b.v.cmplx_val.real+ X a.v.cmplx_val.imag* X b.v.cmplx_val.imag)/square, X (a.v.cmplx_val.imag* X b.v.cmplx_val.real- X a.v.cmplx_val.real* X b.v.cmplx_val.imag)/ X square); X else { X (void) complex(&result,0.0,0.0); X undefined = TRUE; X } X } X } X push(&result); X} X X Xf_mod() X{ Xstruct value a, b; X (void) pop(&b); X (void) pop(&a); /* now do a%b */ X X if (a.type != INT || b.type != INT) X int_error("can only mod ints",NO_CARET); X if (b.v.int_val) X push(integer(&a,a.v.int_val % b.v.int_val)); X else { X push(integer(&a,0)); X undefined = TRUE; X } X} X X Xf_power() X{ Xstruct value a, b, result; Xregister int i, t, count; Xregister double mag, ang; X (void) pop(&b); X (void) pop(&a); /* now find a**b */ X X switch(a.type) { X case INT: X switch (b.type) { X case INT: X count = abs(b.v.int_val); X t = 1; X for(i = 0; i < count; i++) X t *= a.v.int_val; X if (b.v.int_val >= 0) X (void) integer(&result,t); X else X (void) complex(&result,1.0/t,0.0); X break; X case CMPLX: X mag = X pow(magnitude(&a),fabs(b.v.cmplx_val.real)); X if (b.v.cmplx_val.real < 0.0) X mag = 1.0/mag; X ang = angle(&a)*b.v.cmplx_val.real+ X b.v.cmplx_val.imag; X (void) complex(&result,mag*cos(ang), X mag*sin(ang)); X } X break; X case CMPLX: X switch (b.type) { X case INT: X if (a.v.cmplx_val.imag == 0.0) { X mag = pow(a.v.cmplx_val.real,(double)abs(b.v.int_val)); X if (b.v.int_val < 0) X mag = 1.0/mag; X (void) complex(&result,mag,0.0); X } X else { X /* not so good, but...! */ X mag = pow(magnitude(&a),(double)abs(b.v.int_val)); X if (b.v.int_val < 0) X mag = 1.0/mag; X ang = angle(&a)*b.v.int_val; X (void) complex(&result,mag*cos(ang), X mag*sin(ang)); X } X break; X case CMPLX: X mag = pow(magnitude(&a),fabs(b.v.cmplx_val.real)); X if (b.v.cmplx_val.real < 0.0) X mag = 1.0/mag; X ang = angle(&a)*b.v.cmplx_val.real+ b.v.cmplx_val.imag; X (void) complex(&result,mag*cos(ang), X mag*sin(ang)); X } X } X push(&result); X} X X Xf_factorial() X{ Xstruct value a; Xregister int i; Xregister double val; X X (void) pop(&a); /* find a! (factorial) */ X X switch (a.type) { X case INT: X val = 1.0; X for (i = a.v.int_val; i > 1; i--) /*fpe's should catch overflows*/ X val *= i; X break; X default: X int_error("factorial (!) argument must be an integer", X NO_CARET); X } X X push(complex(&a,val,0.0)); X X} X X Xint Xf_jump(x) Xunion argument *x; X{ X return(x->j_arg); X} X X Xint Xf_jumpz(x) Xunion argument *x; X{ Xstruct value a; X int_check(&top_of_stack); X if (top_of_stack.v.int_val) { /* non-zero */ X (void) pop(&a); X return 1; /* no jump */ X } X else X return(x->j_arg); /* leave the argument on TOS */ X} X X Xint Xf_jumpnz(x) Xunion argument *x; X{ Xstruct value a; X int_check(&top_of_stack); X if (top_of_stack.v.int_val) /* non-zero */ X return(x->j_arg); /* leave the argument on TOS */ X else { X (void) pop(&a); X return 1; /* no jump */ X } X} X X Xint Xf_jtern(x) Xunion argument *x; X{ Xstruct value a; X X int_check(pop(&a)); X if (a.v.int_val) X return(1); /* no jump; fall through to TRUE code */ X else X return(x->j_arg); /* go jump to FALSE code */ X} END_OF_FILE if test 13596 -ne `wc -c <'./internal.c'`; then echo shar: \"'./internal.c'\" unpacked with wrong size! fi # end of './internal.c' fi if test -f './pc.trm' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'./pc.trm'\" else echo shar: Extracting \"'./pc.trm'\" \(15550 characters\) sed "s/^X//" >'./pc.trm' <<'END_OF_FILE' X#ifdef __TURBOC__ X#include <graphics.h> X#include <dos.h> X#include <string.h> X int g_driver, g_mode, g_error; X char far *path; X char *pathp, path_s[128]; X Xget_path() X{ X path=getenv("BGI"); X if (path==NULL) { X strcpy(path_s,_argv[0]); X pathp=strrchr(path_s,'\\'); X *pathp=0x00; X path=path_s; X } X} X X#endif X X/* all of the Turbo C routines for the different graphics devices go here */ X X#define EGALIB_XMAX 640 X#define EGALIB_YMAX 350 X X#define EGALIB_XLAST (EGA_XMAX - 1) X#define EGALIB_YLAST (EGA_YMAX - 1) X X#define EGALIB_VCHAR 14 X#define EGALIB_HCHAR 8 X#define EGALIB_VTIC 4 X#define EGALIB_HTIC 5 X Xstatic int ega64color[] = {1,1,5,4,3,5,4,3, 5, 4, 3, 5, 4, 3,5}; Xstatic int ega256color[] = {1,8,2,3,4,5,9,14,12,15,13,10,11,7,6}; X Xstatic int *egacolor; X Xstatic char near buf[80]; /* kludge since EGA.LIB is compiled SMALL */ X Xstatic int pattern[] = {0xffff, 0x0f0f, 0xffff, 0xaaaa, 0x3333, 0x3f3f, 0x0f0f}; X Xstatic int graphics_on = FALSE; Xint startx, starty; X Xpause() /* press any key to continue... */ X{ X while (kbhit()) X (void) getch(); /* flush the keyboard buffer */ X while (!kbhit()) X ; X} X X XPC_lrput_text(row,str) Xint row; Xchar str[]; X{ X#ifdef __TURBOC__ X gotoxy(78-strlen(str),24-row); X puts(str); X#else X PC_curloc(24-row,78-strlen(str)); X PC_puts(str); X#endif X} X XPC_ulput_text(row,str) Xint row; Xchar str[]; X{ X#ifdef __TURBOC__ X gotoxy(2,row+1); X puts(str); X#else X PC_curloc(row+1,2); X PC_puts(str); X#endif X} X XPC_text() X{ X if (graphics_on) { X graphics_on = FALSE; X pause(); X } X#ifdef __TURBOC__ X closegraph(); X#else X Vmode(3); X#endif X} X XPC_reset() X{ X#ifdef __TURBOC__ X closegraph(); X#endif X} X X X#ifdef __TURBOC__ X X#define VGA_XMAX 640 X#define VGA_YMAX 480 X X#define VGA_XLAST (VGA_XMAX - 1) X#define VGA_YLAST (VGA_YMAX - 1) X X#define VGA_VCHAR 14 X#define VGA_HCHAR 8 X#define VGA_VTIC 4 X#define VGA_HTIC 5 X Xstatic int vga256color[] = {1,8,2,3,4,5,9,14,12,15,13,10,11,7,6}; X Xstatic int *vgacolor; X XVGA_init() X{ X g_driver=VGA; X g_mode=2; X initgraph(&g_driver,&g_mode,path); X if(g_driver!=9){ X term=0; X switch (g_driver){ X case -2: fprintf(stderr,"Graphics card not detected.\n"); X break; X case -3: fprintf(stderr,"BGI driver file cannot be found.\n"); X break; X case -4: fprintf(stderr,"Invalid BGI driver file.\n"); X break; X case -5: fprintf(stderr,"Insufficient memory to load ", X "graphics driver."); X break; X } X X/* int_error("color EGA board not found",NO_CARET);*/ X } X if(g_driver==VGA) vgacolor=vga256color; X} X XVGA_graphics() X{ g_driver=VGA; X g_mode=2; X graphics_on = TRUE; X initgraph(&g_driver,&g_mode,path); X} X XVGA_linetype(linetype) X{ X if (linetype >= 13) X linetype %= 13; X setcolor(vgacolor[linetype+2]); X} X XVGA_lrput_text(row,str) Xint row; Xchar str[]; X{ X strcpy((char far *)buf,str); X outtextxy(630-(strlen(str)*8),450-row*16,buf); X} X X#define VGA_reset EGALIB_reset X#define VGA_text EGALIB_text X#define VGA_move EGALIB_move X#define VGA_vector EGALIB_vector X#define VGA_ulput_text EGALIB_ulput_text X XVGAMONO_linetype(linetype) X{ X if (linetype >= 5) X linetype %= 5; X setlinestyle(4,pattern[linetype+2],1); X} X X#define MCGA_XMAX 640 X#define MCGA_YMAX 480 X X#define MCGA_XLAST (MCGA_XMAX - 1) X#define MCGA_YLAST (MCGA_YMAX - 1) X X#define MCGA_VCHAR 14 X#define MCGA_HCHAR 8 X#define MCGA_VTIC 4 X#define MCGA_HTIC 5 X Xstatic int *MCGAcolor; X XMCGA_init() X{ X g_driver=MCGA; X g_mode=5; X initgraph(&g_driver,&g_mode,path); X if(g_driver!=2){ X term=0; X switch (g_driver){ X case -2: fprintf(stderr,"Graphics card not detected.\n"); X break; X case -3: fprintf(stderr,"BGI driver file cannot be found.\n"); X break; X case -4: fprintf(stderr,"Invalid BGI driver file.\n"); X break; X case -5: fprintf(stderr,"Insufficient memory to load ", X "graphics driver."); X break; X } X X } X} X XMCGA_graphics() X{ g_driver=MCGA; X g_mode=5; X graphics_on = TRUE; X initgraph(&g_driver,&g_mode,path); X} X X XMCGA_lrput_text(row,str) Xint row; Xchar str[]; X{ X strcpy((char far *)buf,str); X outtextxy(630-(strlen(str)*8),450-row*16,buf); X} X X#define MCGA_reset EGALIB_reset X#define MCGA_text EGALIB_text X#define MCGA_move EGALIB_move X#define MCGA_vector EGALIB_vector X#define MCGA_ulput_text EGALIB_ulput_text X XMCGA_linetype(linetype) X{ X if (linetype >= 5) X linetype %= 5; X setlinestyle(4,pattern[linetype+2],1); X} X X XEGALIB_init() X{ X g_driver=EGA; X g_mode=1; X initgraph(&g_driver,&g_mode,path); X if(g_driver<3 || g_driver>4){ X term=0; X switch (g_driver){ X case -2: fprintf(stderr,"Graphics card not detected.\n"); X break; X case -3: fprintf(stderr,"BGI driver file cannot be found.\n"); X break; X case -4: fprintf(stderr,"Invalid BGI driver file.\n"); X break; X case -5: fprintf(stderr,"Insufficient memory to load ", X "graphics driver."); X break; X } X X/* int_error("color EGA board not found",NO_CARET);*/ X } X if(g_driver==EGA) egacolor=ega256color; X if(g_driver==EGA64) egacolor=ega64color; X} X XEGALIB_graphics() X{ X graphics_on = TRUE; X initgraph(&g_driver,&g_mode,path); X} X XEGALIB_text() X{ X if (graphics_on) { X graphics_on = FALSE; X pause(); X } X closegraph(); X} X XEGALIB_linetype(linetype) X{ X if (linetype >= 13) X linetype %= 13; X setcolor(egacolor[linetype+2]); X} X XEGALIB_move(x,y) X{ X moveto(x,getmaxy()-y); X} X X XEGALIB_vector(x,y) X{ X lineto(x,getmaxy()-y); X} X X XEGALIB_lrput_text(row,str) Xint row; Xchar str[]; X{ X strcpy((char far *)buf,str); X outtextxy(630-(strlen(str)*8),320-row*16,buf); X} X XEGALIB_ulput_text(row,str) Xint row; Xchar str[]; X{ X strcpy((char far *)buf,str); X outtextxy(10,row*16+16,buf); X} X XEGALIB_reset() X{ X closegraph(); X} X X#define CGA_XMAX 640 X#define CGA_YMAX 200 X X#define CGA_XLAST (CGA_XMAX - 1) X#define CGA_YLAST (CGA_YMAX - 1) X X#define CGA_VCHAR 8 X#define CGA_HCHAR 8 X#define CGA_VTIC 2 X#define CGA_HTIC 3 X XCGA_init() X{ X g_driver=CGA; X g_mode=4; X initgraph(&g_driver,&g_mode,path); X switch (g_driver){ X case -2: fprintf(stderr,"Graphics card not detected.\n"); X break; X case -3: fprintf(stderr,"BGI driver file cannot be found.\n"); X break; X case -4: fprintf(stderr,"Invalid BGI driver file.\n"); X break; X case -5: fprintf(stderr,"Insufficient memory to load ", X "graphics driver."); X break; X } X/* PC_color(1); monochrome */ X X} X XCGA_graphics() X{ X graphics_on = TRUE; X g_driver=CGA; X g_mode=4; X initgraph(&g_driver,&g_mode,path); X /* Vmode(6);*/ X} X X#define CGA_text PC_text X XCGA_linetype(linetype) X{ X if (linetype >= 5) X linetype %= 5; X/* PC_mask(pattern[linetype+2]); */ X setlinestyle(4,pattern[linetype+2],1); X} X XCGA_move(x,y) X{ X moveto(x,y); X} X X XCGA_vector(x,y) X{ X lineto(x,y); X} X X#define CGA_lrput_text PC_lrput_text X#define CGA_ulput_text PC_ulput_text X X X#define CGA_reset PC_reset X X#define HERC_XMAX 720 X#define HERC_YMAX 348 X X#define HERC_XLAST (HERC_XMAX - 1) X#define HERC_YLAST (HERC_YMAX - 1) X X#define HERC_VCHAR 8 X#define HERC_HCHAR 8 X#define HERC_VTIC 4 X#define HERC_HTIC 4 X XHERC_init() X{ X g_driver=HERCMONO; X g_mode=0; X initgraph(&g_driver,&g_mode,path); X switch (g_driver){ X case -2: fprintf(stderr,"Graphics card not detected.\n"); X break; X case -3: fprintf(stderr,"BGI driver file cannot be found.\n"); X break; X case -4: fprintf(stderr,"Invalid BGI driver file.\n"); X break; X case -5: fprintf(stderr,"Insufficient memory to load ", X "graphics driver."); X break; X } X} X XHERC_graphics() X{ X g_driver=HERCMONO; X g_mode=0; X initgraph(&g_driver,&g_mode,path); X graphics_on = TRUE; X} X XHERC_text() X{ X if (graphics_on) { X graphics_on = FALSE; X pause(); X } X closegraph(); X} X XHERC_linetype(linetype) X{ X if (linetype >= 5) X linetype %= 5; X X setlinestyle(linetype,0,1); X} X XHERC_move(x,y) X{ X if (x < 0) X x = 0; X else if (x > HERC_XLAST) X x = HERC_XLAST; X X if (y < 0) X y = 0; X else if (y > HERC_YLAST) X y = HERC_YLAST; X moveto(x,y); X} X XHERC_vector(x,y) X{ X if (x < 0) X x = 0; X else if (x > HERC_XLAST) X x = HERC_XLAST; X if (y < 0) X y = 0; X else if (y > HERC_YLAST) X y = HERC_YLAST; X X lineto(x,y); X} X X/* X Thanks to James Dugal (jpd@usl.edu) for patching these two HERC X routines. (We need to remove the OLD (probably bad) code someday.) X*/ X XHERC_lrput_text(row,str) Xint row; Xchar str[]; X{ X#ifdef OLDHERC X gotoxy(79-strlen(str),24-row); X puts(str); X#else X strcpy((char far *)buf,str); X outtextxy(710-(strlen(str)*8),318-row*10,buf); X#endif X} X XHERC_ulput_text(row,str) Xint row; Xchar str[]; X{ X#ifdef OLDHERC X gotoxy(2,row+1); X puts(str); X#else X strcpy((char far *)buf,str); X outtextxy(10,row*10+10,buf); X#endif X} X X#define HERC_reset PC_reset X X X#else X Xpause() /* press any key to continue... */ X{ X while (kbhit()) X (void) getch(); /* flush the keyboard buffer */ X while (!kbhit()) X ; X} X X XPC_lrput_text(row,str) Xint row; Xchar str[]; X{ X PC_curloc(24-row,78-strlen(str)); X PC_puts(str); X} X XPC_ulput_text(row,str) Xint row; Xchar str[]; X{ X PC_curloc(row+1,2); X PC_puts(str); X} X XPC_text() X{ X if (graphics_on) { X graphics_on = FALSE; X pause(); X } X Vmode(3); X} X XPC_reset() X{ X} X#define CGA_XMAX 640 X#define CGA_YMAX 200 X X#define CGA_XLAST (CGA_XMAX - 1) X#define CGA_YLAST (CGA_YMAX - 1) X X#define CGA_VCHAR 8 X#define CGA_HCHAR 8 X#define CGA_VTIC 2 X#define CGA_HTIC 3 X XCGA_init() X{ X PC_color(1); /* monochrome */ X} X XCGA_graphics() X{ X graphics_on = TRUE; X Vmode(6); X} X X#define CGA_text PC_text X XCGA_linetype(linetype) X{ X if (linetype >= 5) X linetype %= 5; X PC_mask(pattern[linetype+2]); X} X XCGA_move(x,y) X{ X startx = x; X starty = y; X} X X XCGA_vector(x,y) X{ X PC_line(startx,CGA_YLAST-starty,x,CGA_YLAST-y); X startx = x; X starty = y; X} X X#define CGA_lrput_text PC_lrput_text X#define CGA_ulput_text PC_ulput_text X X X#define CGA_reset PC_reset X X X#define EGA_XMAX 640 X#define EGA_YMAX 350 X X#define EGA_XLAST (EGA_XMAX - 1) X#define EGA_YLAST (EGA_YMAX - 1) X X#define EGA_VCHAR 14 X#define EGA_HCHAR 8 X#define EGA_VTIC 5 X#define EGA_HTIC 5 X Xstatic int ega64color[] = {1,1,5,4,3,5,4,3, 5, 4, 3, 5, 4, 3,5}; Xstatic int ega256color[] = {1,8,2,3,4,5,9,14,12,15,13,10,11,7,6}; X Xstatic int *egacolor; X X XEGA_init() X{ X PC_mask(0xffff); X egacolor = ega256color; /* should be smarter */ X} X XEGA_graphics() X{ X graphics_on = TRUE; X Vmode(16); X} X X#define EGA_text PC_text X XEGA_linetype(linetype) X{ X if (linetype >= 13) X linetype %= 13; X PC_color(egacolor[linetype+2]); X} X XEGA_move(x,y) X{ X startx = x; X starty = y; X} X XEGA_vector(x,y) X{ X PC_line(startx,EGA_YLAST-starty,x,EGA_YLAST-y); X startx = x; X starty = y; X} X X#define EGA_lrput_text PC_lrput_text X#define EGA_ulput_text PC_ulput_text X X X#define EGA_reset PC_reset X X X X#ifdef EGALIB X X#define EGALIB_XMAX 640 X#define EGALIB_YMAX 350 X X#define EGALIB_XLAST (EGA_XMAX - 1) X#define EGALIB_YLAST (EGA_YMAX - 1) X X#define EGALIB_VCHAR 14 X#define EGALIB_HCHAR 8 X#define EGALIB_VTIC 4 X#define EGALIB_HTIC 5 X X#include "mcega.h" X XEGALIB_init() X{ X GPPARMS(); X if (GDTYPE != 5) { X term = 0; X int_error("color EGA board not found",NO_CARET); X } X egacolor = (GDMEMORY < 256) ? ega64color : ega256color; X} X XEGALIB_graphics() X{ X graphics_on = TRUE; X GPINIT(); X} X XEGALIB_text() X{ X if (graphics_on) { X graphics_on = FALSE; X pause(); X } X GPTERM(); X} X XEGALIB_linetype(linetype) X{ X if (linetype >= 13) X linetype %= 13; X GPCOLOR(egacolor[linetype+2]); X} X XEGALIB_move(x,y) X{ X GPMOVE(x,GDMAXROW-y); X} X X XEGALIB_vector(x,y) X{ X GPLINE(x,GDMAXROW-y); X} X X XEGALIB_lrput_text(row,str) Xint row; Xchar str[]; X{ X strcpy((char far *)buf,str); X GotoXY(78-strlen(str),24-row); X gprintf(buf); X} X XEGALIB_ulput_text(row,str) Xint row; Xchar str[]; X{ X strcpy((char far *)buf,str); X GotoXY(2,row+1); X gprintf(buf); X} X X#define EGALIB_reset PC_reset X X#endif /* EGALIB */ X X X#ifdef HERCULES X X#define HERC_XMAX 720 X#define HERC_YMAX 348 X X#define HERC_XLAST (HERC_XMAX - 1) X#define HERC_YLAST (HERC_YMAX - 1) X X#define HERC_VCHAR 8 X#define HERC_HCHAR 8 X#define HERC_VTIC 4 X#define HERC_HTIC 4 X X XHERC_init() X{ X} X XHERC_graphics() X{ X HVmode(1); X graphics_on = TRUE; X} X XHERC_text() X{ X if (graphics_on) { X graphics_on = FALSE; X pause(); X } X HVmode(0); X} X XHERC_linetype(linetype) X{ X if (linetype >= 5) X linetype %= 5; X H_mask(pattern[linetype+2]); X} X XHERC_move(x,y) X{ X if (x < 0) X startx = 0; X else if (x > HERC_XLAST) X startx = HERC_XLAST; X else X startx = x; X X if (y < 0) X starty = 0; X else if (y > HERC_YLAST) X starty = HERC_YLAST; X else X starty = y; X} X XHERC_vector(x,y) X{ X if (x < 0) X x = 0; X else if (x > HERC_XLAST) X x = HERC_XLAST; X if (y < 0) X y = 0; X else if (y > HERC_YLAST) X y = HERC_YLAST; X X H_line(startx,HERC_YLAST-starty,x,HERC_YLAST-y); X startx = x; X starty = y; X} X XHERC_lrput_text(row,str) Xint row; Xchar str[]; X{ X H_puts(str, 41-row, 87-strlen(str)); X} X XHERC_ulput_text(row,str) Xint row; Xchar str[]; X{ X H_puts(str, row+1, 2); X} X X#define HERC_reset PC_reset X X#endif /* HERCULES */ X X X/* thanks to sask!macphed (Geoff Coleman and Ian Macphedran) for the X ATT 6300 driver */ X X X#ifdef ATT6300 X X#define ATT_XMAX 640 X#define ATT_YMAX 400 X X#define ATT_XLAST (ATT_XMAX - 1) X#define ATT_YLAST (ATT_YMAX - 1) X X#define ATT_VCHAR 8 X#define ATT_HCHAR 8 X#define ATT_VTIC 3 X#define ATT_HTIC 3 X X#define ATT_init CGA_init X XATT_graphics() X{ X graphics_on = TRUE; X Vmode(0x40); /* 40H is the magic number for the AT&T driver */ X} X X#define ATT_text CGA_text X X#define ATT_linetype CGA_linetype X X#define ATT_move CGA_move X XATT_vector(x,y) X{ X PC_line(startx,ATT_YLAST-starty,x,ATT_YLAST-y); X startx = x; X starty = y; X} X X#define ATT_lrput_text PC_lrput_text X#define ATT_ulput_text PC_ulput_text X X X#define ATT_reset CGA_reset X X#endif /* ATT6300 */ X X X#ifdef CORONA X X#define COR_XMAX 640 X#define COR_YMAX 325 X X#define COR_XLAST (COR_XMAX - 1) X#define COR_YLAST (COR_YMAX - 1) X X#define COR_VCHAR 13 X#define COR_HCHAR 8 X#define COR_VTIC 4 X#define COR_HTIC 4 X X Xstatic int corscreen; /* screen number, 0 - 7 */ X XCOR_init() X{ Xregister char *p; X if (!(p = getenv("CORSCREEN"))) X int_error("must run CORPLOT for Corona graphics",NO_CARET); X corscreen = *p - '0'; X} X XCOR_graphics() X{ X graphics_on = TRUE; X Vmode(3); /* clear text screen */ X grinit(corscreen); X grandtx(); X} X XCOR_text() X{ X if (graphics_on) { X graphics_on = FALSE; X pause(); X } X grreset(); X txonly(); X Vmode(3); X} X XCOR_linetype(linetype) X{ X if (linetype >= 5) X linetype %= 5; X Cor_mask(pattern[linetype+2]); X} X XCOR_move(x,y) X{ X if (x < 0) X startx = 0; X else if (x > COR_XLAST) X startx = COR_XLAST; X else X startx = x; X X if (y < 0) X starty = 0; X else if (y > COR_YLAST) X starty = COR_YLAST; X else X starty = y; X} X XCOR_vector(x,y) X{ X if (x < 0) X x = 0; X else if (x > COR_XLAST) X x = COR_XLAST; X if (y < 0) X y = 0; X else if (y > COR_YLAST) X y = COR_YLAST; X X Cor_line(startx,COR_YLAST-starty,x,COR_YLAST-y); X startx = x; X starty = y; X} X X#define COR_lrput_text PC_lrput_text X#define COR_ulput_text PC_ulput_text X X#define COR_reset PC_reset X X#endif /* CORONA */ X X#endif /* __TURBOC__ */ X END_OF_FILE if test 15550 -ne `wc -c <'./pc.trm'`; then echo shar: \"'./pc.trm'\" unpacked with wrong size! fi # end of './pc.trm' fi if test -f './term.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'./term.c'\" else echo shar: Extracting \"'./term.c'\" \(19496 characters\) sed "s/^X//" >'./term.c' <<'END_OF_FILE' X/* X * X * G N U P L O T -- term.c X * X * Copyright (C) 1986, 1987 Colin Kelley, Thomas Williams X * X * You may use this code as you wish if credit is given and this message X * is retained. X * X * Please e-mail any useful additions to vu-vlsi!plot so they may be X * included in later releases. X * X * This file should be edited with 4-column tabs! (:set ts=4 sw=4 in vi) X */ X X#include <stdio.h> X#include "plot.h" X Xchar *getenv(); X Xextern FILE *outfile; Xextern BOOLEAN term_init; Xextern int term; X Xextern char input_line[]; Xextern struct lexical_unit token[]; Xextern struct termentry term_tbl[]; X X/* This is needed because the unixplot library only writes to stdout. */ XFILE save_stdout; Xint unixplot=0; X X#define NICE_LINE 0 X#define POINT_TYPES 6 X X Xdo_point(x,y,number) Xint x,y; Xint number; X{ Xregister int htic,vtic; Xregister struct termentry *t; X X number %= POINT_TYPES; X t = &term_tbl[term]; X htic = (t->h_tic/2); /* should be in term_tbl[] in later version */ X vtic = (t->v_tic/2); X X if ( x < t->h_tic || y < t->v_tic || x >= t->xmax-t->h_tic || X y >= t->ymax-t->v_tic ) X return; /* add clipping in later version maybe */ X X switch(number) { X case 0: /* do diamond */ X (*t->move)(x-htic,y); X (*t->vector)(x,y-vtic); X (*t->vector)(x+htic,y); X (*t->vector)(x,y+vtic); X (*t->vector)(x-htic,y); X (*t->move)(x,y); X (*t->vector)(x,y); X break; X case 1: /* do plus */ X (*t->move)(x-htic,y); X (*t->vector)(x-htic,y); X (*t->vector)(x+htic,y); X (*t->move)(x,y-vtic); X (*t->vector)(x,y-vtic); X (*t->vector)(x,y+vtic); X break; X case 2: /* do box */ X (*t->move)(x-htic,y-vtic); X (*t->vector)(x+htic,y-vtic); X (*t->vector)(x+htic,y+vtic); X (*t->vector)(x-htic,y+vtic); X (*t->vector)(x-htic,y-vtic); X (*t->move)(x,y); X (*t->vector)(x,y); X break; X case 3: /* do X */ X (*t->move)(x-htic,y-vtic); X (*t->vector)(x-htic,y-vtic); X (*t->vector)(x+htic,y+vtic); X (*t->move)(x-htic,y+vtic); X (*t->vector)(x-htic,y+vtic); X (*t->vector)(x+htic,y-vtic); X break; X case 4: /* do triangle */ X (*t->move)(x,y+(4*vtic/3)); X (*t->vector)(x-(4*htic/3),y-(2*vtic/3)); X (*t->vector)(x+(4*htic/3),y-(2*vtic/3)); X (*t->vector)(x,y+(4*vtic/3)); X (*t->move)(x,y); X (*t->vector)(x,y); X break; X case 5: /* do star */ X (*t->move)(x-htic,y); X (*t->vector)(x-htic,y); X (*t->vector)(x+htic,y); X (*t->move)(x,y-vtic); X (*t->vector)(x,y-vtic); X (*t->vector)(x,y+vtic); X (*t->move)(x-htic,y-vtic); X (*t->vector)(x-htic,y-vtic); X (*t->vector)(x+htic,y+vtic); X (*t->move)(x-htic,y+vtic); X (*t->vector)(x-htic,y+vtic); X (*t->vector)(x+htic,y-vtic); X break; X } X} X X X/* X * general point routine X */ Xline_and_point(x,y,number) Xint x,y,number; X{ X /* temporary(?) kludge to allow terminals with bad linetypes X to make nice marks */ X X (*term_tbl[term].linetype)(NICE_LINE); X do_point(x,y,number); X} X X X#ifdef HPLJET X#define RASTER X#endif /* HPLJET */ X X#ifdef RASTER X/* X** General raster plotting routines. X** Raster routines written and copyrighted 1987 by X** Jyrki Yli-Nokari (jty@intrin.UUCP) X** Intrinsic, Ltd. X** X** You may use this code for anything you like as long as X** you are not selling it and the credit is given and X** this message retained. X** X** The plotting area is defined as a huge raster. X** The raster is stored in a dynamically allocated pixel array r_p X** X** The raster is allocated (and initialized to zero) with X** r_makeraster(xsize, ysize) X** and freed with r_freeraster() X** X** Valid (unsigned) coordinates range from zero to (xsize-1,ysize-1) X** X** Plotting is done via r_move(x, y) and r_draw(x, y, value) functions, X** where the point (x,y) is the target to go from the current point X** and value is the value (of type pixel) to be stored in every pixel. X** X** Internally all plotting goes through r_setpixel(x, y, val). X** If you want different plotting styles (like OR, XOR...), use "value" X** in r_draw() to mark different styles and change r_setpixel() accordingly. X*/ X X#define IN(i,size) ((unsigned)i < (unsigned)size) Xtypedef char pixel; /* the type of one pixel in raster */ Xtypedef pixel *raster[]; /* the raster */ X Xstatic raster *r_p; /* global pointer to raster */ Xstatic unsigned r_currx, r_curry; /* the current coordinates */ Xstatic unsigned r_xsize, r_ysize; /* the size of the raster */ X Xchar *calloc(); Xvoid free(); X X/* X** set pixel (x, y, val) to value val (this can be 1/0 or a color number). X*/ Xvoid Xr_setpixel(x, y, val) Xunsigned x, y; Xpixel val; X{ X if (IN(x, r_xsize) && IN(y, r_ysize)) { X *(((*r_p)[y]) + x) = val; X } X#ifdef RASTERDEBUG X else { X fprintf(stderr, "Warning: setpixel(%d, %d, %d) out of bounds\n", x, y, val); X } X#endif X} X X/* X** get pixel (x,y) value X*/ Xpixel Xr_getpixel(x, y) Xunsigned x, y; X{ X if (IN(x, r_xsize) && IN(y, r_ysize)) { X return *(((*r_p)[y]) + x); X } else { X#ifdef RASTERDEBUG X fprintf(stderr, "Warning: getpixel(%d,%d) out of bounds\n", x, y); X#endif X return 0; X } X} X X/* X** allocate the raster X*/ Xvoid Xr_makeraster(x, y) Xunsigned x, y; X{ X register unsigned j; X X /* allocate row pointers */ X if ((r_p = (raster *)calloc(y, sizeof(pixel *))) == (raster *)0) { X fprintf(stderr, "Raster buffer allocation failure\n"); X exit(1); X } X for (j = 0; j < y; j++) { X if (((*r_p)[j] = (pixel *)calloc(x, sizeof(pixel))) == (pixel *)0) { X fprintf(stderr, "Raster buffer allocation failure\n"); X exit(1); X } X } X r_xsize = x; r_ysize = y; X r_currx = r_curry = 0; X} X X/* X** plot a line from (x0,y0) to (x1,y1) with color val. X*/ Xvoid Xr_plot(x0, y0, x1, y1, val) Xunsigned x0, y0, x1, y1; Xpixel val; X{ X unsigned hx, hy, i; X int e, dx, dy; X X hx = abs((int)(x1 - x0)); X hy = abs((int)(y1 - y0)); X dx = (x1 > x0) ? 1 : -1; X dy = (y1 > y0) ? 1 : -1; X X if (hx > hy) { X /* X ** loop over x-axis X */ X e = hy + hy - hx; X for (i = 0; i <= hx; i++) { X r_setpixel(x0, y0, val); X if (e > 0) { X y0 += dy; X e += hy + hy - hx - hx; X } else { X e += hy + hy; X } X x0 += dx; X } X } else { X /* X ** loop over y-axis X */ X e = hx + hx - hy; X for (i = 0; i <= hy; i++) { X r_setpixel(x0, y0, val); X if (e > 0) { X x0 += dx; X e += hx + hx - hy - hy; X } else { X e += hx + hx; X } X y0 += dy; X } X } X} X X/* X** move to (x,y) X*/ Xvoid Xr_move(x, y) Xunsigned x, y; X{ X r_currx = x; X r_curry = y; X} X X/* X** draw to (x,y) with color val X** (move pen down) X*/ Xvoid Xr_draw(x, y, val) Xunsigned x, y; Xpixel val; X{ X r_plot(r_currx, r_curry, x, y, val); X r_currx = x; X r_curry = y; X} X X/* X** free the allocated raster X*/ Xvoid Xr_freeraster() X{ X int y; X X for (y = 0; y < r_ysize; y++) { X free((char *)(*r_p)[y]); X } X free((char *)r_p); X} X#endif /* RASTER */ X X#ifdef HPLJET X#include "hpljet.trm" X#endif /* HPLJET */ X X#ifdef PC X#include "pc.trm" X#endif /* PC */ X X#ifdef AED X#include "aed.trm" X#endif /* AED */ X X#ifdef BITGRAPH X#include "bitgraph.trm" X#endif /* BITGRAPH */ X X#ifdef HP26 X#include "hp26.trm" X#endif /* HP26 */ X X#ifdef HP75 X#include "hp75.trm" X#endif /* HP75 */ X X#ifdef IRIS4D X#include "iris4d.trm" X#endif /* IRIS4D */ X X#ifdef POSTSCRIPT X#include "postscpt.trm" X#endif /* POSTSCRIPT */ X X X#ifdef QMS X#include "qms.trm" X#endif /* QMS */ X X X#ifdef REGIS X#include "regis.trm" X#endif /* REGIS */ X X X#ifdef SELANAR X#include "selanar.trm" X#endif /* SELANAR */ X X X#ifdef TEK X#include "tek.trm" X#endif /* TEK */ X X X#ifdef V384 X#include "v384.trm" X#endif /* V384 */ X X X#ifdef UNIXPLOT X/* X Unixplot library writes to stdout. A fix was put in place by X ..!arizona!naucse!jdc to let set term and set output redirect X stdout. All other terminals write to outfile. X*/ X#include "unixplot.trm" X#endif /* UNIXPLOT */ X X#ifdef UNIXPC /* unix-PC ATT 7300 or 3b1 machine */ X#include "unixpc.trm" X#endif /* UNIXPC */ X X XUNKNOWN_null() X{ X} X X X/* X * term_tbl[] contains an entry for each terminal. "unknown" must be the X * first, since term is initialized to 0. X */ Xstruct termentry term_tbl[] = { X {"unknown", 100, 100, 1, 1, 1, 1, UNKNOWN_null, UNKNOWN_null, UNKNOWN_null, X UNKNOWN_null, UNKNOWN_null, UNKNOWN_null, UNKNOWN_null, UNKNOWN_null, X UNKNOWN_null, UNKNOWN_null} X#ifdef HPLJET X ,{"laserjet1",HPLJETXMAX,HPLJETYMAX,HPLJET1VCHAR, HPLJET1HCHAR, HPLJETVTIC, X HPLJETHTIC, HPLJET1init,HPLJETreset, HPLJETtext, HPLJETgraphics, X HPLJETmove, HPLJETvector,HPLJETlinetype,HPLJETlrput_text, X HPLJETulput_text, line_and_point} X ,{"laserjet2",HPLJETXMAX,HPLJETYMAX,HPLJET2VCHAR, HPLJET2HCHAR, HPLJETVTIC, X HPLJETHTIC, HPLJET2init,HPLJETreset, HPLJETtext, HPLJETgraphics, X HPLJETmove, HPLJETvector,HPLJETlinetype,HPLJETlrput_text, X HPLJETulput_text, line_and_point} X ,{"laserjet3",HPLJETXMAX,HPLJETYMAX,HPLJET3VCHAR, HPLJET3HCHAR, HPLJETVTIC, X HPLJETHTIC, HPLJET3init,HPLJETreset, HPLJETtext, HPLJETgraphics, X HPLJETmove, HPLJETvector,HPLJETlinetype,HPLJETlrput_text, X HPLJETulput_text, line_and_point} X#endif X X#ifdef PC X#ifdef __TURBOC__ X X ,{"egalib", EGALIB_XMAX, EGALIB_YMAX, EGALIB_VCHAR, EGALIB_HCHAR, X EGALIB_VTIC, EGALIB_HTIC, EGALIB_init, EGALIB_reset, X EGALIB_text, EGALIB_graphics, EGALIB_move, EGALIB_vector, X EGALIB_linetype, EGALIB_lrput_text, EGALIB_ulput_text, line_and_point} X X ,{"vgalib", VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR, X VGA_VTIC, VGA_HTIC, VGA_init, VGA_reset, X VGA_text, VGA_graphics, VGA_move, VGA_vector, X VGA_linetype, VGA_lrput_text, VGA_ulput_text, line_and_point} X X ,{"vgamono", VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR, X VGA_VTIC, VGA_HTIC, VGA_init, VGA_reset, X VGA_text, VGA_graphics, VGA_move, VGA_vector, X VGAMONO_linetype, VGA_lrput_text, VGA_ulput_text, line_and_point} X X ,{"mcga", MCGA_XMAX, MCGA_YMAX, MCGA_VCHAR, MCGA_HCHAR, X MCGA_VTIC, MCGA_HTIC, MCGA_init, MCGA_reset, X MCGA_text, MCGA_graphics, MCGA_move, MCGA_vector, X MCGA_linetype, MCGA_lrput_text, MCGA_ulput_text, line_and_point} X X ,{"cga", CGA_XMAX, CGA_YMAX, CGA_VCHAR, CGA_HCHAR, X CGA_VTIC, CGA_HTIC, CGA_init, CGA_reset, X CGA_text, CGA_graphics, CGA_move, CGA_vector, X CGA_linetype, CGA_lrput_text, CGA_ulput_text, line_and_point} X X ,{"hercules", HERC_XMAX, HERC_YMAX, HERC_VCHAR, HERC_HCHAR, X HERC_VTIC, HERC_HTIC, HERC_init, HERC_reset, X HERC_text, HERC_graphics, HERC_move, HERC_vector, X HERC_linetype, HERC_lrput_text, HERC_ulput_text, line_and_point} X X#else X ,{"cga", CGA_XMAX, CGA_YMAX, CGA_VCHAR, CGA_HCHAR, X CGA_VTIC, CGA_HTIC, CGA_init, CGA_reset, X CGA_text, CGA_graphics, CGA_move, CGA_vector, X CGA_linetype, CGA_lrput_text, CGA_ulput_text, line_and_point} X X ,{"egabios", EGA_XMAX, EGA_YMAX, EGA_VCHAR, EGA_HCHAR, X EGA_VTIC, EGA_HTIC, EGA_init, EGA_reset, X EGA_text, EGA_graphics, EGA_move, EGA_vector, X EGA_linetype, EGA_lrput_text, EGA_ulput_text, do_point} X X#ifdef EGALIB X ,{"egalib", EGALIB_XMAX, EGALIB_YMAX, EGALIB_VCHAR, EGALIB_HCHAR, X EGALIB_VTIC, EGALIB_HTIC, EGALIB_init, EGALIB_reset, X EGALIB_text, EGALIB_graphics, EGALIB_move, EGALIB_vector, X EGALIB_linetype, EGALIB_lrput_text, EGALIB_ulput_text, do_point} X#endif X X#ifdef HERCULES X ,{"hercules", HERC_XMAX, HERC_YMAX, HERC_VCHAR, HERC_HCHAR, X HERC_VTIC, HERC_HTIC, HERC_init, HERC_reset, X HERC_text, HERC_graphics, HERC_move, HERC_vector, X HERC_linetype, HERC_lrput_text, HERC_ulput_text, line_and_point} X#endif /* HERCULES */ X X#ifdef ATT6300 X ,{"att", ATT_XMAX, ATT_YMAX, ATT_VCHAR, ATT_HCHAR, X ATT_VTIC, ATT_HTIC, ATT_init, ATT_reset, X ATT_text, ATT_graphics, ATT_move, ATT_vector, X ATT_linetype, ATT_lrput_text, ATT_ulput_text, line_and_point} X#endif X X#ifdef CORONA X ,{"corona325", COR_XMAX, COR_YMAX, COR_VCHAR, COR_HCHAR, X COR_VTIC, COR_HTIC, COR_init, COR_reset, X COR_text, COR_graphics, COR_move, COR_vector, X COR_linetype, COR_lrput_text, COR_ulput_text, line_and_point} X#endif /* CORONA */ X#endif /* TURBOC */ X#endif /* PC */ X X#ifdef AED X ,{"aed512", AED5_XMAX, AED_YMAX, AED_VCHAR, AED_HCHAR, X AED_VTIC, AED_HTIC, AED_init, AED_reset, X AED_text, AED_graphics, AED_move, AED_vector, X AED_linetype, AED5_lrput_text, AED_ulput_text, do_point} X ,{"aed767", AED_XMAX, AED_YMAX, AED_VCHAR, AED_HCHAR, X AED_VTIC, AED_HTIC, AED_init, AED_reset, X AED_text, AED_graphics, AED_move, AED_vector, X AED_linetype, AED_lrput_text, AED_ulput_text, do_point} X#endif X X#ifdef UNIXPC X ,{"unixpc",uPC_XMAX,uPC_YMAX,uPC_VCHAR, uPC_HCHAR, uPC_VTIC, X uPC_HTIC, uPC_init,uPC_reset, uPC_text, uPC_graphics, X uPC_move, uPC_vector,uPC_linetype,uPC_lrput_text, X uPC_ulput_text, line_and_point} X#endif X X#ifdef BITGRAPH X ,{"bitgraph",BG_XMAX,BG_YMAX,BG_VCHAR, BG_HCHAR, BG_VTIC, X BG_HTIC, BG_init,BG_reset, BG_text, BG_graphics, X BG_move, BG_vector,BG_linetype,BG_lrput_text, X BG_ulput_text, line_and_point} X#endif X X#ifdef HP26 X ,{"hp2623A",HP26_XMAX,HP26_YMAX, HP26_VCHAR, HP26_HCHAR,HP26_VTIC,HP26_HTIC, X HP26_init,HP26_reset,HP26_text, HP26_graphics, HP26_move, HP26_vector, X HP26_linetype, HP26_lrput_text, HP26_ulput_text, line_and_point} X#endif X X#ifdef HP75 X ,{"hp7580B",HP75_XMAX,HP75_YMAX, HP75_VCHAR, HP75_HCHAR,HP75_VTIC,HP75_HTIC, X HP75_init,HP75_reset,HP75_text, HP75_graphics, HP75_move, HP75_vector, X HP75_linetype, HP75_lrput_text, HP75_ulput_text, do_point} X#endif X X#ifdef IRIS4D X ,{"iris4d", IRIS4D_XMAX, IRIS4D_YMAX, IRIS4D_VCHAR, X IRIS4D_HCHAR, IRIS4D_VTIC, IRIS4D_HTIC, X IRIS4D_init, IRIS4D_reset, IRIS4D_text, X IRIS4D_graphics, IRIS4D_move, IRIS4D_vector, X IRIS4D_linetype, IRIS4D_lrput_text, IRIS4D_ulput_text, X do_point} X#endif X X#ifdef POSTSCRIPT X ,{"postscript", PS_XMAX, PS_YMAX, PS_VCHAR, PS_HCHAR, PS_VTIC, PS_HTIC, X PS_init, PS_reset, PS_text, PS_graphics, PS_move, PS_vector, X PS_linetype, PS_lrput_text, PS_ulput_text, line_and_point} X#endif X X#ifdef QMS X ,{"qms",QMS_XMAX,QMS_YMAX, QMS_VCHAR, QMS_HCHAR, QMS_VTIC, QMS_HTIC, X QMS_init,QMS_reset, QMS_text, QMS_graphics, QMS_move, QMS_vector, X QMS_linetype,QMS_lrput_text,QMS_ulput_text,line_and_point} X#endif X X#ifdef REGIS X ,{"regis", REGISXMAX, REGISYMAX, REGISVCHAR, REGISHCHAR, REGISVTIC, X REGISHTIC, REGISinit, REGISreset, REGIStext, REGISgraphics, X REGISmove,REGISvector,REGISlinetype, REGISlrput_text, REGISulput_text, X line_and_point} X#endif X X X#ifdef SELANAR X ,{"selanar",TEK40XMAX,TEK40YMAX,TEK40VCHAR, TEK40HCHAR, TEK40VTIC, X TEK40HTIC, SEL_init, SEL_reset, SEL_text, SEL_graphics, X TEK40move, TEK40vector, TEK40linetype, TEK40lrput_text, X TEK40ulput_text, line_and_point} X#endif X X#ifdef TEK X ,{"tek40xx",TEK40XMAX,TEK40YMAX,TEK40VCHAR, TEK40HCHAR, TEK40VTIC, X TEK40HTIC, TEK40init, TEK40reset, TEK40text, TEK40graphics, X TEK40move, TEK40vector, TEK40linetype, TEK40lrput_text, X TEK40ulput_text, line_and_point} X#endif X X#ifdef UNIXPLOT X ,{"unixplot", UP_XMAX, UP_YMAX, UP_VCHAR, UP_HCHAR, UP_VTIC, UP_HTIC, X UP_init, UP_reset, UP_text, UP_graphics, UP_move, UP_vector, X UP_linetype, UP_lrput_text, UP_ulput_text, line_and_point} X#endif X X#ifdef V384 X ,{"vx384", V384_XMAX, V384_YMAX, V384_VCHAR, V384_HCHAR, V384_VTIC, X V384_HTIC, V384_init, V384_reset, V384_text, V384_graphics, X V384_move, V384_vector, V384_linetype, V384_lrput_text, X V384_ulput_text, do_point} X#endif X }; X X#define TERMCOUNT (sizeof(term_tbl)/sizeof(struct termentry)) X X Xlist_terms() X{ Xregister int i; X X fprintf(stderr,"\navailable terminals types:\n"); X for (i = 0; i < TERMCOUNT; i++) X fprintf(stderr,"\t%s\n",term_tbl[i].name); X (void) putc('\n',stderr); X} X X Xset_term(c_token) Xint c_token; X{ Xregister int i,t; X X if (!token[c_token].is_token) X int_error("terminal name expected",c_token); X t = -1; X X for (i = 0; i < TERMCOUNT; i++) { X if (!strncmp(input_line + token[c_token].start_index,term_tbl[i].name, X token[c_token].length)) { X if (t != -1) X int_error("ambiguous terminal name",c_token); X t = i; X } X } X if (t == -1) X int_error("unknown terminal type; type just 'set terminal' for a list", X c_token); X else if (!strncmp("unixplot",term_tbl[t].name,sizeof(unixplot))) { X UP_redirect (2); /* Redirect actual stdout for unixplots */ X } X else if (unixplot) { X UP_redirect (3); /* Put stdout back together again. */ X } X term_init = FALSE; X return(t); X} X X X/* X Routine to detect what terminal is being used (or do anything else X that would be nice). One anticipated (or allowed for) side effect X is that the global ``term'' may be set. X*/ Xinit() X{ Xchar *term_name = NULL; Xint t = -1, i; X#ifdef __TURBOC__ X int g_driver,g_mode; X char far *c1,*c2; X X/* Some of this code including BGI drivers is copyright Borland Intl. */ X g_driver=DETECT; X get_path(); X initgraph(&g_driver,&g_mode,path); X c1=getdrivername(); X c2=getmodename(g_mode); X switch (g_driver){ X case -2: fprintf(stderr,"Graphics card not detected.\n"); X break; X case -3: fprintf(stderr,"BGI driver file cannot be found.\n"); X break; X case -4: fprintf(stderr,"Invalid BGI driver file.\n"); X break; X case -5: fprintf(stderr,"Insufficient memory to load ", X "graphics driver."); X break; X } X closegraph(); X fprintf(stderr,"\tTC Graphics, driver %s mode %s\n",c1,c2); X#endif X#ifdef VMS X/* X Determine if we have a regis terminal. If not use TERM X (tek40xx) as default. X*/ X#include <descrip> X#include <dvidef> X Xextern int term; Xchar *term_str="tt:"; Xtypedef struct X { X short cond_value; X short count; X int info; X } status_block; Xtypedef struct X { X short buffer_len; X short item_code; X int buffer_addr; X int ret_len_addr; X } item_desc; Xstruct { X item_desc dev_type; X int terminator; X } dvi_list; X int status, dev_type, zero=0; X char buffer[255]; X $DESCRIPTOR(term_desc, term_str); X X/* set up dvi item list */ X dvi_list.dev_type.buffer_len = 4; X dvi_list.dev_type.item_code = DVI$_TT_REGIS; X dvi_list.dev_type.buffer_addr = &dev_type; X dvi_list.dev_type.ret_len_addr = 0; X X dvi_list.terminator = 0; X X/* See what type of terminal we have. */ X status = SYS$GETDVIW (0, 0, &term_desc, &dvi_list, 0, 0, 0, 0); X if ((status & 1) && dev_type) { X term_name = "regis"; X } X#endif X if (term_name != NULL) { X /* We have a name to set! */ X for (i = 0; i < TERMCOUNT; i++) { X if (!strncmp("regis",term_tbl[i].name,5)) { X t = i; X } X } X if (t != -1) X term = t; X } X} X X X/* X This is always defined so we don't have to have command.c know if it X is there or not. X*/ X#ifndef UNIXPLOT XUP_redirect(caller) int caller; {} X#else XUP_redirect (caller) Xint caller; X/* X Unixplot can't really write to outfile--it wants to write to stdout. X This is normally ok, but the original design of gnuplot gives us X little choice. Originally users of unixplot had to anticipate X their needs and redirect all I/O to a file... Not very gnuplot-like. X X caller: 1 - called from SET OUTPUT "FOO.OUT" X 2 - called from SET TERM UNIXPLOT X 3 - called from SET TERM other X 4 - called from SET OUTPUT X*/ X{ X switch (caller) { X case 1: X /* Don't save, just replace stdout w/outfile (save was already done). */ X if (unixplot) X *(stdout) = *(outfile); /* Copy FILE structure */ X break; X case 2: X if (!unixplot) { X fflush(stdout); X save_stdout = *(stdout); X *(stdout) = *(outfile); /* Copy FILE structure */ X unixplot = 1; X } X break; X case 3: X /* New terminal in use--put stdout back to original. */ X closepl(); X fflush(stdout); X *(stdout) = save_stdout; /* Copy FILE structure */ X unixplot = 0; X break; X case 4: X /* User really wants to go to normal output... */ X if (unixplot) { X fflush(stdout); X *(stdout) = save_stdout; /* Copy FILE structure */ X } X break; X } X} X#endif END_OF_FILE if test 19496 -ne `wc -c <'./term.c'`; then echo shar: \"'./term.c'\" unpacked with wrong size! fi # end of './term.c' fi echo shar: End of archive 5 \(of 7\). cp /dev/null ark5isdone MISSING="" for I in 1 2 3 4 5 6 7 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 7 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 -- John Campbell ...!arizona!naucse!jdc CAMPBELL@NAUVAX.bitnet unix? Sure send me a dozen, all different colors.