$!............................................................................. $! VAX/VMS archive file created by VMS_SHARE V06.03 20-Oct-1988. $! $! VMS_SHARE was written by James Gray (Gray:OSBUSouth@Xerox.COM) from $! VMS_SHAR by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au). $! $! To unpack, simply save, concatinate all parts into one file and $! execute (@) that file. $! $! This archive was created by user GJC $! on 20-FEB-1990 14:36:01.51. $! $! It contains the following 12 files: $! CAT.C $! CLR.C $! GETOPT.C $! PLOTX_LIB.C $! PLOTX_MAIN.C $! XTEK.C $! XTEKX.C $! XTEK_MBX.C $! XTEK.H $! XTEK.PRO $! BUILD.COM $! READ.ME $! $!============================================================================== $ SET SYMBOL/SCOPE=( NOLOCAL, NOGLOBAL ) $ VERSION = F$GETSYI( "VERSION" ) $ IF VERSION .GES "V4.4" THEN GOTO VERSION_OK $ WRITE SYS$OUTPUT "You are running VMS ''VERSION'; ", - "VMS_SHARE V06.03 20-Oct-1988 requires VMS V4.4 or higher." $ EXIT 44 $VERSION_OK: $ GOTO START $ $UNPACK_FILE: $ WRITE SYS$OUTPUT "Creating ''FILE_IS'" $ DEFINE/USER_MODE SYS$OUTPUT NL: $ EDIT/TPU/COMMAND=SYS$INPUT/NODISPLAY/OUTPUT='FILE_IS'/NOSECTION - VMS_SHARE_DUMMY.DUMMY b_part := CREATE_BUFFER( "{Part}", GET_INFO( COMMAND_LINE, "file_name" ) ); s_file_spec := GET_INFO( COMMAND_LINE, "output_file" );SET( OUTPUT_FILE, b_part , s_file_spec ); b_errors := CREATE_BUFFER( "{Errors}" );i_errors := 0; pat_beg_1 := ANCHOR & "-+-+-+ Beginning"; pat_beg_2 := LINE_BEGIN & "+-+-+-+ Beginning"; pat_end := ANCHOR & "+-+-+-+-+ End"; pat_trail := " " & LINE_END;POSITION( BEGINNING_OF( b_part ) ); LOOP b := SEARCH( pat_trail, FORWARD); EXITIF b=0; POSITION( END_OF( b ) ) ; LOOP MOVE_HORIZONTAL( -1 ); EXITIF CURRENT_CHARACTER <> ' '; ERASE_CHARACTER ( 1 ); EXITIF CURRENT_OFFSET=0; ENDLOOP; ENDLOOP; POSITION( BEGINNING_OF ( b_part ) ); i_append_line := 0; LOOP EXITIF MARK( NONE ) = END_OF( b_part ) ; s_x := ERASE_CHARACTER( 1 ); IF s_x = "+" THEN r_skip := SEARCH( pat_beg_1, FORWARD, EXACT ); IF r_skip < > 0 THEN s_x := ""; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ERASE_LINE; ENDIF; ENDIF; IF s_x = "-" THEN r_skip := SEARCH( pat_end, FORWARD, EXACT ); IF r_skip < > 0 THEN s_x := ""; MOVE_HORIZONTAL( -CURRENT_OFFSET ); m_skip := MARK( NONE ) ; r_skip := SEARCH( pat_beg_2, FORWARD, EXACT ); IF r_skip <> 0 THEN POSITION ( END_OF( r_skip ) ); MOVE_HORIZONTAL( -CURRENT_OFFSET ); MOVE_VERTICAL( 1 ) ; MOVE_HORIZONTAL( -1 ); ELSE POSITION( END_OF( b_part ) ); ENDIF; ERASE ( CREATE_RANGE( m_skip, MARK( NONE ), NONE ) ); ENDIF; ENDIF; IF s_x = "V" THEN s_x := ""; IF i_append_line <> 0 THEN APPEND_LINE; MOVE_HORIZONTAL ( -CURRENT_OFFSET ); ENDIF; i_append_line := 1; MOVE_VERTICAL( 1 ); ENDIF; IF s_x = "X" THEN s_x := ""; IF i_append_line <> 0 THEN APPEND_LINE; MOVE_HORIZONTAL ( -CURRENT_OFFSET ); ENDIF; i_append_line := 0; MOVE_VERTICAL( 1 ); ENDIF; IF s_x <> "" THEN i_errors := i_errors + 1; s_text := CURRENT_LINE; POSITION ( b_errors ); COPY_TEXT( "The following line could not be unpacked properly:" ) ; SPLIT_LINE; COPY_TEXT( s_x ); COPY_TEXT( s_text ); POSITION( b_part ) ; MOVE_VERTICAL( 1 ); ENDIF; ENDLOOP; POSITION( BEGINNING_OF( b_part ) ); LOOP r_x := SEARCH( "`", FORWARD, EXACT ); EXITIF r_x = 0; POSITION( r_x ) ; ERASE_CHARACTER( 1 ); IF CURRENT_CHARACTER = "`" THEN MOVE_HORIZONTAL( 1 ); ELSE COPY_TEXT( ASCII ( INT( ERASE_CHARACTER( 3 ) ) ) ); ENDIF; ENDLOOP; IF i_errors = 0 THEN SET ( NO_WRITE, b_errors, ON ); ELSE POSITION( BEGINNING_OF( b_errors ) ); COPY_TEXT( FAO( "The following !UL errors were detected while unpacking !AS" , i_errors, s_file_spec ) ); SPLIT_LINE; SET( OUTPUT_FILE, b_errors, "SYS$COMMAND" );ENDIF; EXIT; $ DELETE VMS_SHARE_DUMMY.DUMMY;* $ CHECKSUM 'FILE_IS $ WRITE SYS$OUTPUT " CHECKSUM ", - F$ELEMENT( CHECKSUM_IS .EQ. CHECKSUM$CHECKSUM, ",", "failed!,passed." ) $ RETURN $ $START: $ FILE_IS = "CAT.C" $ CHECKSUM_IS = 1584101362 $ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY X#include X#include X X/* this is needed to be able to copy arbitrary tektronics files X to a mailbox device. the vms copy command can get into trouble X with record sizes. X*/ X Xmain(argc,argv) X int argc; char **argv; X`123int c; X FILE *in,*out; X if (argc != 3) X `123fprintf(stderr,"cat \n"); X exit(44);`125 X if (!(in = fopen(argv[1],"r"))) X `123perror(argv[1]); X exit(vaxc$errno);`125 X if (!(out = fopen(argv[2],"w"))) X `123perror(argv[2]); X exit(vaxc$errno);`125 X while((c = getc(in)) != EOF) putc(c,out); X fclose(in); X fclose(out);`125 X `032 X `032 $ GOSUB UNPACK_FILE $ FILE_IS = "CLR.C" $ CHECKSUM_IS = 708453035 $ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY X#include X#include X X#include "xtek.h" X X/* use this to send a clear screen to the mailbox */ X Xmain(argc,argv) X int argc; char **argv; X`123char codes[3]; X FILE *out; X if (argc != 2) X `123fprintf(stderr,"cat \n"); X exit(44);`125 X if (!(out = fopen(argv[1],"w"))) X `123perror(argv[1]); X exit(vaxc$errno);`125 X codes[0] = ESC; X codes[1] = FF; X codes[2] = 0; X fputs(codes,out); X fclose(out);`125 $ GOSUB UNPACK_FILE $ FILE_IS = "GETOPT.C" $ CHECKSUM_IS = 1462706301 $ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY X#include X X#ifdef VMS X#include X#define index strchr X#endif X X/* X * get option letter from argument vector X */ Xint`009opterr = 1,`009`009/* useless, never set or used */ X`009optind = 1,`009`009/* index into parent argv vector */ X`009optopt;`009`009`009/* character checked for validity */ Xchar`009*optarg;`009`009/* argument associated with option */ X X#define BADCH`009(int)'?' X#define EMSG`009"" X#define tell(s)`009fputs(*nargv,stderr);fputs(s,stderr); \ X`009`009fputc(optopt,stderr);fputc('\n',stderr);return(BADCH); X Xgetopt(nargc,nargv,ostr) Xint`009nargc; Xchar`009**nargv, X`009*ostr; X`123 X`009static char`009*place = EMSG;`009/* option letter processing */ X`009register char`009*oli;`009`009/* option letter list index */ X`009char`009*index(); X X`009if(!*place) `123`009`009`009/* update scanning pointer */ V`009`009if(optind >= nargc `124`124 *(place = nargv[optind]) != '-' `124`124 !* X++place) return(EOF); X`009`009if (*place == '-') `123`009/* found "--" */ X`009`009`009++optind; X`009`009`009return(EOF); X`009`009`125 X`009`125`009`009`009`009/* option letter okay? */ V`009if ((optopt = (int)*place++) == (int)':' `124`124 !(oli = index(ostr,optopt X))) `123 X`009`009if(!*place) ++optind; X`009`009tell(": illegal option -- "); X`009`125 X`009if (*++oli != ':') `123`009`009/* don't need argument */ X`009`009optarg = NULL; X`009`009if (!*place) ++optind; X`009`125 X`009else `123`009`009`009`009/* need an argument */ X`009`009if (*place) optarg = place;`009/* no white space */ X`009`009else if (nargc <= ++optind) `123`009/* no arg */ X`009`009`009place = EMSG; X`009`009`009tell(": option requires an argument -- "); X`009`009`125 X`009 `009else optarg = nargv[optind];`009/* white space */ X`009`009place = EMSG; X`009`009++optind; X`009`125 X`009return(optopt);`009`009`009/* dump back option letter */ X`125 X X X $ GOSUB UNPACK_FILE $ FILE_IS = "PLOTX_LIB.C" $ CHECKSUM_IS = 1031221730 $ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY X/* COPYRIGHT (c) 1989 BY * X * PARADIGM ASSOCIATES INCORPORATED, CAMBRIDGE, MASSACHUSETTS. * X *`009`009`009 ALL RIGHTS RESERVED * X XPermission to use, copy, modify, and distribute this software and its Xdocumentation for any purpose and without fee is hereby granted, Xprovided that the above copyright notice appear in all copies and that Xboth that copyright notice and this permission notice appear in Xsupporting documentation, and that the name of Paradigm Associates Inc Xnot be used in advertising or publicity pertaining to distribution of Xthe software without specific, written prior permission. X XPARADIGM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL XPARADIGM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS XSOFTWARE. X X*/ X X/* Under VMS these routines are called directly from VAXLISP. X No event polling loop is required. Under Unix these routines X are called from a subprocess which gets its input from a pipe. X*/ X X X#include X#ifdef VMS X#include X#include X#include X#else X#include X#include X#include X#endif X X#ifndef NULL X#define NULL 0 X#endif X#ifndef TRUE X#define TRUE 1 X#endif X#ifndef FALSE X#define FALSE 0 X#endif X#ifndef max X#define max(a,b) (((a) > (b)) ? (a) : (b)) X#endif X Xint errdbg = 0; Xint syncmode = 0; X X X#ifdef VMS Xvoid event_ast_handler(); X#endif X X X/* X * Basic screen object types X */ X#define POINT 1 X#define LINE 2 X#define LABEL 3 X Xstruct point `123 X short x,y; X`125; X Xstruct line `123 X short x1, y1, x2, y2; X`125; X Xstruct label `123 X short x,y; X short len; X char *value; X`125; X X/* X * So we can re-display (eg. after an exposure event) we keep X * all drawn objects on a linked list with head obp and tail lastobj X */ Xstruct object `123 X struct object *next; X int type; X union `123 X struct point point; X struct line line; X struct label label; X `125 obj; X`125 *obp, *lastobj; X X/* X * syntactic shortcuts X */ X#define PTx obj.point.x X#define PTy obj.point.y X#define LNx1 obj.line.x1 X#define LNx2 obj.line.x2 X#define LNy1 obj.line.y1 X#define LNy2 obj.line.y2 X#define LBx obj.label.x X#define LBy obj.label.y X#define LBval obj.label.value X#define LBlen obj.label.len X Xchar *wname = "XTEK"; X Xint Wheight, Wwidth; Xint Wxpos, Wypos; X XDisplay *Wdpy; X Xint dpyht, dpywd; X Xlong Wscr; XVisual *Wvis; XGC Wgc; X XXGCValues Wgcv = `123 X GXcopy, X AllPlanes, X 1, X 0, X 1, X LineSolid, X CapButt, X JoinMiter, X FillSolid, X EvenOddRule, X ArcPieSlice, X NULL, X NULL, X 0, X 0, X NULL, X ClipByChildren, X TRUE, X 0, X 0, X NULL, X 0, X '\0' X`125; X Xunsigned long Wgcvmask = X GCFunction`124 X GCPlaneMask`124 X GCForeground`124 X GCBackground`124 X GCLineWidth`124 X GCLineStyle`124 X GCFillStyle`124 X GCFillRule`124 X GCFont`124 X GCSubwindowMode`124 X GCGraphicsExposures; X X XXSetWindowAttributes Wxswa = `123 X None,`009`009`009`009`009/* background pixmap +`009`009*/ X 0,`009`009`009`009`009/* background pixel +`009`009*/ X None,`009`009`009`009`009/* border pixmap +`009`009*/ X 0,`009`009`009`009`009/* border pixel +`009`009*/ X ForgetGravity,`009`009`009/* bit gravity`009`009`009*/ X ForgetGravity,`009`009`009/* window gravity`009`009*/ X NotUseful,`009`009`009`009/* backing store`009`009*/ X 0,`009`009`009`009`009/* backing planes +`009`009*/ X 0,`009`009`009`009`009/* backing pixel +`009`009*/ X FALSE,`009`009`009`009/* save under`009`009`009*/ X 0,`009`009`009`009`009/* event mask (to be saved)`009*/ X 0,`009`009`009`009`009/* do not propagate mask`009*/ X FALSE,`009`009`009`009/* override redirect`009`009*/ X NULL,`009`009`009`009`009/* color map`009`009`009*/ X NULL,`009`009`009`009`009/* cursor`009`009`009*/ X`125; X Xunsigned long Wxswamask = CWBackPixel`124CWBorderPixel; X X XXWMHints Wxshints = `123 X InputHint, /* specified-p mask */ X 0 /* Nay, do not give us the input focus */ X `125; X`009`009`009 `032 Xint Wborder = 1; Xint Wvmask; Xint Wclass = InputOutput; Xint Wfg, Wbg, Wdepth; XXID Wroot; X Xchar *Wfontname = "fixed"; XFont Wfont; XXFontStruct *Wfontp; Xint Wchar_height, Wchar_width; XXID w; X Xint plotx_setflags(syncmode_flag,errdbg_flag) X int syncmode_flag,errdbg_flag; X`123syncmode = syncmode_flag; X errdbg = errdbg_flag; X return(1);`125 X Xplotx_init() X`123if ((Wdpy = XOpenDisplay(NULL)) == 0) X `123if (errdbg) perror("cannot open X display"); X return(0);`125 X if (syncmode == 1) XSynchronize(Wdpy,1); X Wscr = DefaultScreen(Wdpy); X`032 X dpyht = DisplayHeight(Wdpy,Wscr); X dpywd = DisplayWidth(Wdpy,Wscr); X X Wheight = dpyht/2; X Wwidth = dpywd/2; X X Wxpos = dpywd/4; X Wypos = dpyht/4; X`032 X Wroot = RootWindow(Wdpy,Wscr); X Wvis = DefaultVisual(Wdpy,Wscr); X Wfg = BlackPixel(Wdpy,Wscr); X Wbg = WhitePixel(Wdpy,Wscr); X Wgcv.foreground = Wfg; X Wgcv.background = Wbg; X Wxswa.border_pixel = Wfg; X Wxswa.background_pixel = Wbg; X Wdepth = DefaultDepth(Wdpy,Wscr); X X Wfont = XLoadFont(Wdpy,Wfontname); X Wgcv.font = Wfont; X Wfontp = XQueryFont(Wdpy,Wfont); X Wchar_height = Wfontp->max_bounds.width; X Wchar_width = Wfontp->ascent+Wfontp->descent; X X Wxswa.border_pixel = Wfg; X Wxswa.background_pixel = Wbg; X X w = XCreateWindow(Wdpy,Wroot, X`009`009 Wxpos,Wypos,Wwidth,Wheight,Wborder,Wdepth, X`009`009 Wclass, X`009`009 Wvis,Wxswamask,&Wxswa); X X Wgc = XCreateGC(Wdpy,w,Wgcvmask,&Wgcv); X XChangeProperty(Wdpy,w,XA_WM_NAME,XA_STRING,8,PropModeReplace, X`009`009 wname,strlen(wname)); X XSetWMHints(Wdpy,w,&Wxshints); X XMapWindow(Wdpy,w); X X#ifdef VMS X XSelectAsyncInput(Wdpy,w,ExposureMask`124StructureNotifyMask, X`009`009 event_ast_handler,0); X#endif X X XSelectInput(Wdpy,w,ExposureMask`124StructureNotifyMask); X X XFlush(Wdpy); X fprintf(stdout, X "XTEK - Copyright (c) 1989 Paradigm Associates Inc. All Rights Reserved.\n"); X`032 X return(1);`125 X X Xplotx_width() X`123return(Wwidth);`125 X Xplotx_height() X`123return(Wheight);`125 X Xplotx_char_width() X`123return(Wchar_width);`125 X Xplotx_char_height() X`123return(Wchar_height);`125 X Xchar *stralloc(s) char *s; X`123char *p; X p = (char *)malloc(strlen(s)+1); X strcpy(p,s); X return(p);`125 X Xstruct object *NewObj(type) int type; X`123register struct object *p; X X p = (struct object *)malloc(sizeof(*p)); X#ifdef VMS X memset(p,0,sizeof(*p)); X#else X bzero(p,sizeof(*p)); X#endif X p->type = type; X return(p);`125 X XFreeObj() X`123register struct object *tp; X X while(obp != NULL) X `123tp = obp->next; X if(obp->type == LABEL) X free(obp->LBval); X free(obp); X obp = tp;`125 X lastobj = obp = NULL;`125 X X XAddObj(p) X struct object *p; X`123 X if(obp == NULL) X obp = p; X else X lastobj->next = p; X lastobj = p;`125 X Xplotx_point(x,y) X int x,y; X`123register struct object *p; X X p = NewObj(POINT); X p->PTx = x; X p->PTy = y; X AddObj(p); X XDrawPoint(Wdpy,w,Wgc,p->PTx,p->PTy); X return(1);`125 X Xplotx_line(x1,y1,x2,y2) X int x1, y1, x2, y2; X`123register struct object *p; X X p = NewObj(LINE); X p->LNx1 = x1; X p->LNx2 = x2; X p->LNy1 = y1; X p->LNy2 = y2; X AddObj(p); X XDrawLine(Wdpy,w,Wgc,p->LNx1,p->LNy1,p->LNx2,p->LNy2); X return(1);`125 X Xplotx_label(x,y,val) X int x,y; char *val; X`123register struct object *p; X X p = NewObj(LABEL); X p->LBx = x; X p->LBy = y; X p->LBval = stralloc(val); X p->LBlen = strlen(val); X AddObj(p); X XDrawString(Wdpy,w,Wgc,p->LBx,p->LBy,p->LBval,p->LBlen); X return(1);`125 X Xplotx_char(x,y,val) X int x,y,val; X`123char buffer[2]; X buffer[0] = val; X buffer[1] = 0; X plotx_label(x,y,buffer); X return(1);`125 X `032 Xredraw_contents() X`123register struct object *p; X X for(p=obp; p != NULL; p = p->next) X switch(p->type) X `123case POINT: X`009XDrawPoint(Wdpy,w,Wgc,p->PTx,p->PTy); X`009break; X X case LINE: X`009XDrawLine(Wdpy,w,Wgc,p->LNx1,p->LNy1,p->LNx2,p->LNy2); X`009break; X X case LABEL: X`009XDrawString(Wdpy,w,Wgc,p->LBx,p->LBy,p->LBval,p->LBlen); X`009break; X X default: X`009break;`125`125 X Xonexpose(ep) XExposeEvent *ep; X`123if (errdbg == 1) fprintf(stderr,"Expose Event\n"); X redraw_contents();`125 X Xonstructurenotify(ep) X XAnyEvent *ep; X`123XConfigureEvent *p; X X switch(ep->type) X `123case ConfigureNotify: X if (errdbg == 1) fprintf(stderr,"ConfigureNotify Event\n"); X p = (XConfigureEvent *) ep; X Wwidth = p->width; X Wheight = p->height; X Wxpos = p->x; X Wypos = p->y; X break; X default: X break;`125`125 X Xplotx_clear() X`123FreeObj(); X XClearWindow(Wdpy,w); X return(1);`125 X Xchar *decode_event_number(); X X#ifdef VMS X Xvoid event_ast_handler(astarg) X int astarg; X`123XEvent event; X XAnyEvent *ep; X ep = &event; X while(XPending(Wdpy) > 0) X `123XNextEvent(Wdpy,ep); X switch(ep->type) X `123case Expose: X`009 onexpose(ep); X`009 break; X case ConfigureNotify: X`009 onstructurenotify(ep); X`009 break; X default: X`009 if (errdbg == 1) X`009 fprintf(stderr,"Ignored Event %d %s\n",ep->type, X`009`009 decode_event_number(ep->type));`125`125`125 X#endif X Xchar *decode_event_number(x) X int x; X`123switch (x) X `123case KeyPress: X return("KeyPress"); X case KeyRelease: X return("KeyRelease"); X case ButtonPress: X return("ButtonPress"); X case ButtonRelease: X return("ButtonRelease"); X case MotionNotify: X return("MotionNotify"); X case EnterNotify: X return("EnterNotify"); X case LeaveNotify: X return("LeaveNotify"); X case FocusIn: X return("FocusIn"); X case FocusOut: X return("FocusOut"); X case KeymapNotify: X return("KeymapNotify"); X case Expose: X return("Expose"); X case GraphicsExpose: X return("GraphicsExpose"); X case NoExpose: X return("NoExpose"); X case VisibilityNotify: X return("VisibilityNotify"); X case CreateNotify: X return("CreateNotify"); X case DestroyNotify: X return("DestroyNotify"); X case UnmapNotify: X return("UnmapNotify"); X case MapNotify: X return("MapNotify"); X case MapRequest: X return("MapRequest"); X case ReparentNotify: X return("ReparentNotify"); X case ConfigureNotify: X return("ConfigureNotify"); X case ConfigureRequest: X return("ConfigureRequest"); X case GravityNotify: X return("GravityNotify"); X case ResizeRequest: X return("ResizeRequest"); X case CirculateNotify: X return("CirculateNotify"); X case CirculateRequest: X return("CirculateRequest"); X case PropertyNotify: X return("PropertyNotify"); X case SelectionClear: X return("SelectionClear"); X case SelectionRequest: X return("SelectionRequest"); X case SelectionNotify: X return("SelectionNotify"); X case ColormapNotify: X return("ColormapNotify"); X case ClientMessage: X return("ClientMessage"); X case MappingNotify: X return("MappingNotify"); X default: X return("*UNDEFINED?*");`125`125 X Xplotx_bell() X`123XBell(Wdpy,50); X XFlush(Wdpy); X return(1);`125 X Xplotx_refresh() X`123XClearWindow(Wdpy,w); X redraw_contents(); X return(1);`125 X Xplotx_force_output() X`123XFlush(Wdpy); X return(1);`125 X $ GOSUB UNPACK_FILE $ FILE_IS = "PLOTX_MAIN.C" $ CHECKSUM_IS = 2018017260 $ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY X/* XWindows Interface for DOE-MACSYMA PLOT2 package */ X/* (C) Copyright 1989, Paradigm Associates Inc. X All Rights Reserved X */ X X/* This "main" program is needed in Unix environments to provide X a main loop to dispatch on X events. X*/ X X#include X XFILE *logf = NULL; X X#ifdef UNIX X X#define fmore(p) ((p)->_cnt > 0) X X X#include X#include X#include X X X X/* X * X11 window interface for Macsyma/Plot running under Franz Lisp X * This runs as a separate process and is spoken to via text commands X * over a pipe (*process inport outport). X * X * The commands thus far are (all in text, on a line with a newline) X *`009p x y`009`009`009Draw a point X *`009l x1 y1 x2 y2`009`009Draw a line X *`009t x y text`009`009Put text at x,y X *`009w`009`009`009Put window width/height X *`009`009`009`009and char width/height to stdout X *`009c`009`009`009Clear X *`009b`009`009`009beep the bell X * X * Terminates on EOF. X * X * Barry Shein, Boston University X George Carrette, Paradigm Associates Inc. For XR11 and VMS. X */ X X/* X * If you can't come up with an fmore(stream) macro which returns X * whether or not there's more in the input buffer you'd better make X * stdin unbuffered, otherwise things will get hung when usiong a pipe X * as input as select() won't know there's more to read already in the X * buffer. X */ X Xplotx_main() X`123XEvent event; X XAnyEvent *ep; X int dpymask, stdinmask, nfound, readfds, nfds; X char buf[BUFSIZ]; X X /* X * We are unfortunately slave to two asynchronous channels, messages X * from the process doing the drawing and messages from the X server. X * We'll use select to poll both and find out who is talking. X */ X dpymask = 1 << Wdpy->fd; X stdinmask = 1 << fileno(stdin); X nfds = max(Wdpy->fd,fileno(stdin)) + 1; X X /* X * Not really necessary but maybe slightly better in term's of X * user's perceptions. Flush all pending X server requests such X * as window creation (it might be a while till macsyma sends something) X */ X XFlush(Wdpy); X for(ep = (XAnyEvent *) &event;;) X `123/* X * Always clear the queue and anything pending as the X server might X * bundle up multiple responses X */ X if((QLength(Wdpy) == 0) && (XPending(Wdpy) == 0)) X `123for(;;) X`009 `123readfds = dpymask `124 stdinmask; X`009 if(select(nfds,&readfds,0,0,0) > 0)`009/* some interrupts force ret */ X`009 break;`125`125 X else X readfds = dpymask; X X /* X * Handle X server request X */ X if(readfds & dpymask) X `123XNextEvent(Wdpy,ep); X switch(ep->type) X`009`123case Expose: X`009 onexpose(ep); X`009 break; X X`009 case ConfigureNotify: X`009 onstructurenotify(ep); X`009 break; X X`009 default: X`009 if (errdbg == 1) fprintf(stderr,"Ignored Event %d %s\n", X`009`009`009`009 ep->type X`009`009`009`009 decode_event_number(ep->type)); X`009 break;`125`125 X /* X * Handle user request X */ X if(readfds & stdinmask) X `123 X#ifdef fmore X`009do `123 X#endif X`009 if(fgets(buf,BUFSIZ,stdin) != NULL) `123 X`009 if(logf != NULL) X`009 fputs(buf,logf); X`009 docommand(buf); X`009 `125 X`009 else done(0); X#ifdef fmore X`009`125 while(fmore(stdin)); X#endif X `125`125`125 X X#endif X X#ifdef VMS X/* Under VMS dealing with the async nature of this application is easier */ Xplotx_main() X`123char buf[BUFSIZ]; X plotx_force_output(); X while(fgets(buf,BUFSIZ,stdin) != NULL) X `123if(logf != NULL) fputs(buf,logf); X docommand(buf);`125 X done(1);`125 X X#endif X X Xdone(code) int code; X`123fprintf(stderr,"DONE.\n"); X exit(code);`125 X X/* X * Handle a user request which should be a single text line X * with a single request. X */ X Xdocommand(bp) register char *bp; X`123int x1,y1,x2,y2; X static char label[BUFSIZ]; X X switch(*bp) X `123case 'p': X case 'P': X if(sscanf(bp+1,"%d %d",&x1,&y1) == 2) X`009plotx_point(x1,y1); X break; X X case 'l': X case 'L': X if(sscanf(bp+1,"%d %d %d %d",&x1,&y1,&x2,&y2) == 4) X`009plotx_line(x1,y1,x2,y2); X break; X X case 't': X case 'T': X if(sscanf(bp+1,"%d %d %[`094\n]",&x1,&y1,label) == 3) X`009plotx_label(x1,y1,label); X break; X X case 'w': X case 'W': X printf("%d %d %d %d\n", X`009 plotx_width(), X`009 plotx_height(), X`009 plotx_char_width(), X`009 plotx_char_height()); X break; X X case 'c': X case 'C': X plotx_clear(); X break; X X case 'b': X case 'B': X plotx_bell(); X break; X X /* other commands added for use during debugging */ X case 'f': X case 'F': X plotx_force_output(); X break; X X case 'r': X case 'R': X plotx_refresh(); X break; X X default: X break;`125`125 X Xmain(argc,argv) X int argc; char **argv; X`123int j,syncmode_flag,errdbg_flag; X char *xmlog, *arg,*val, *getenv(); X xmlog = 0; X syncmode_flag = 0; X errdbg_flag = 0; X for(j=1;(j + 1) X#include X#include "xtek.h" X X#ifdef VMS X#include X#endif X Xextern char`009*optarg; Xextern int`009optind; Xextern double`009atof(); X Xint tv_mode = 0; Xint mbx_mode = 0; X X X/* output filter for tektronics 4010-graphics files to generate postscript X * files. This does a simple-minded byte by byte translation to predefined X * PS routines, contained in a prolog file. X * Defaults: X * input:`009stdin X * output:`009stdout X * prolog:`009`126msf/tek2ps/pstek.pro X X modified for VMS, added -o option. George Carrette 8-30-88 X modified for X-windows. (or other graphics driver) if -o filename is x X then sets tv_mode to true, ignores prolog file, and calls xtek_init instead. X xtek_* routines dispatch on tv_mode. George Carrette 15-SEP-89 X */ X X Xmain(argc, argv) X`009int`009argc; X`009char`009*argv[]; X`123 X#ifndef lint V`009static char`009sccsid[]=" @(#)t2p.c`0091.10 tek2ps (Copyright) M. Fischbein V Commercial reproduction prohibited; non-profit reproduction and distribution X encouraged."; X#endif X`009static char`009def_pro[]="TEK2PS_PRO"; X`009char`009`009*pro_fn = def_pro; X`009FILE`009`009*pro_fp, *infile = stdin; X`009int`009`009c, mode=ALPHA, tsizex=CHUGEX, tsizey=CHUGEY, oldmode; X`009int`009`009cx=0, cy=YDIM-CHUGEY, leftmargin=0; X`009int`009`009used_large=FALSE, used_med=FALSE, used_small=FALSE; X`009int`009`009dark_vector, HiX=0, HiY=0, LoY=0, LoX=0, BX=0, BY=0; X`009int`009`009gotLoY=FALSE, debug=FALSE, beamon, pr_on_er=FALSE; X`009double`009`009scale_factor=1.0; X X X`009/* first, parse command line */ X`009while ((c = getopt (argc, argv, "s:p:deo:")) != EOF) `123 X`009`009switch (c) `123 X`009`009case 'p' :`009/* use custom prolog */ X`009`009`009pro_fn = optarg; X`009`009`009break; X X`009`009case 'd' :`009/* toggle debugging */ X`009`009`009if (debug) `123 X`009`009`009`009debug = FALSE; X`009`009`009`125 else `123 X`009`009`009`009debug = TRUE; X`009`009`009`125 X`009`009`009break; X X`009`009case 'e':`009/* turn on print-before-erase */ X`009`009`009`009/* and erase-after-print */ X`009`009`009pr_on_er = TRUE; X`009`009`009break; X X`009`009case 's':`009/* set scale option */ X`009`009`009scale_factor = atof(optarg)/100.; X`009`009`009break; X`009`009case 'o' :`009/* open output file */ X`009`009 if(strcmp(optarg,"x") == 0) X`009`009`009 tv_mode = 1; X`009`009`009else if(!(stdout = fopen(optarg,"w"))) X`009`009`009 `123perror(optarg);exit(1);`125 X`009`009`009break; X`009`009default: V`009`009`009fprintf(stderr, "Usage: %s [-p prologfile] [-de] [input]\n", argv[0 X]); X`009`009`009 X`009`009`125 X`009`125 X X`009if(!tv_mode) X`009 `123/* next, copy the prolog file */ X`009 if( (pro_fp = fopen(pro_fn, "r")) == NULL) `123 X`009 fprintf(stderr, "Can't open prolog file %s\n", pro_fn); X`009 exit(1); X`009 `125 X`009 while ((c = getc(pro_fp)) != EOF) `123 X`009 putc((char) c, stdout); X`009 `125 X`009 fclose(pro_fp);`125 X`009else X`009 xtek_init(); X X`009if ((optind < argc) X`009 && X`009 (strncmp(argv[optind],"xtek_mail_box",13) == 0)) X`009 `123mbx_mode = 1; X`009 infile = open_xtek_mail_box(argv[optind]);`125 X X`009/* check for named file (loop if more than one) */ X`009do `123`009/* should indent here */ X`009if ((optind < argc) && !mbx_mode) `123 X`009`009if ((infile = fopen( argv[optind], "r")) == NULL) `123 X`009`009`009fprintf(stderr, "Can't open input file %s\n", argv[optind]); X`009`009`009exit(1); X`009`009`125 X`009`125 X`009/* check for scale factor */ X`009if (scale_factor != 1.0) `123`009/* I know floating pt equality is X`009`009`009`009`009 * a bad idea, but if the option is not X`009`009`009`009`009 * present I explicity initialize to X`009`009`009`009`009 * 1.0, so the bit pattern should be X`009`009`009`009`009 * identical portably X`009`009`009`009`009 */ X`009 xtek_scale(scale_factor); X`009`125 X X`009/* Now, read a byte and figure out what to do about it */ X`009while ((c = getc(infile)) != EOF) `123 /* should indent below */ X`009switch (mode) `123 X`009case ALPHA: X`009`009if ( isgraph((char) c) ) `123`009/* normal printing char */ X`009`009`009/* put char at current position */ X`009`009 xtek_char(c,cx,cy); X X`009`009`009/* increment current postion, wrt type size */ X`009`009`009if ((cx += tsizex) > XDIM) `123 X`009`009`009`009/* new line or margin */ X`009`009`009`009if((cy -= tsizey) < 0) `123 X`009`009`009`009`009cy = YDIM - tsizey; X`009`009`009`009`009leftmargin = leftmargin ? 0 : XDIM/2; X`009`009`009`009`125 X`009`009`009`009cx = leftmargin; X`009`009`009`125 X`009`009`125 else `123 /* isn't normal printing character */ X`009`009switch (c) `123 X`009`009case ( HT ): X`009`009case ( SPACE ): X`009`009`009if ((cx += tsizex) > XDIM) `123 X`009`009`009`009/* new line or margin */ X`009`009`009`009if((cy -= tsizey) < 0) `123 X`009`009`009`009`009cy = YDIM - tsizey; X`009`009`009`009`009leftmargin = leftmargin ? 0 : XDIM/2; X`009`009`009`009`125 X`009`009`009`009cx = leftmargin; X`009`009`009`125 X`009`009`009break; X X`009`009case ( CR ): X`009`009case ( LF ): X`009`009`009if ((cy -= tsizey) < 0) `123 X`009`009`009`009cy = YDIM - tsizey; X`009`009`009`009leftmargin = leftmargin ? 0 : XDIM/2; X`009`009`009`125 X`009`009`009cx = leftmargin; X`009`009`009break; X X`009`009case ( BS ): X`009`009`009if ((cx -= tsizex) < 0) `123 X`009`009`009`009cx = XDIM; X`009`009`009`125 X`009`009`009break; X X`009`009case ( VT ): X`009`009`009if ((cy += tsizey) > YDIM) `123 X`009`009`009`009cy = 0; X`009`009`009`125 X`009`009`009break; X X`009`009case ( GS ): X`009`009`009mode = GRAPH; X`009`009`009dark_vector = TRUE; X`009`009`009break; X X`009`009case ( RS ): X`009`009`009mode = INCRE; X`009`009`009break; X`009`009 X`009`009case ( FS ): X`009`009`009mode = PTPLT; X`009`009`009break; X X`009`009case ( US ):`009/* put in ALPHA mode, already there */ X`009`009case ( BEL ): X`009`009case ( SYN ):`009/* padding character, ignore*/ X`009`009case ( NUL ):`009/* padding character, ignore*/ X`009`009`009break; X X`009`009case ( ESC ): X`009`009`009oldmode = ALPHA; X`009`009`009mode = LCEMD; X`009`009`009break; X X`009`009default : V`009`009`009if (debug) fprintf(stderr, "Unknown ALPHA mode character 0x%02x\n", X c); X`009`009`009break; X`009`009`125`009/* end of switch on non-printing char in ALPHA mode */ X`009`009`125`009/* end of printing vs non-printing char in ALPHA mode */ X`009break;`009/* end of ALPHA mode */ X X`009case PTPLT: X`009case GRAPH: X`009`009if ( (char) c > US ) `123`009/* first, handle vector case */ X`009`009`009if( (char) c < '@') `123 /* High byte */ X`009`009`009`009if (gotLoY) `123`009/* must be HiX */ X`009`009`009`009`009HiX = ((char) c & 0x1f) << 7; X`009`009`009`009`125 else `123`009/* must be HiY */ X`009`009`009`009`009HiY = ((char) c & 0x1f) << 7; X`009`009`009`009`125 X`009`009`009`125 else if ( (char) c < '``') `123`009/* Lo X: plot */ X`009`009`009`009gotLoY = FALSE; X`009`009`009`009LoX = (c & 0x1f) << 2; X`009`009`009`009/* now actually do a plot */ X`009`009`009`009if (dark_vector) `123 X`009`009`009`009`009dark_vector = FALSE; X`009`009`009`009`009cx = HiX + LoX + BX; X`009`009`009`009`009cy = HiY + LoY + BY; X`009`009`009`009`009xtek_moveto(cx,cy); X`009`009`009`009`125 else `123 /* draw the line */ X`009`009`009`009`009cx = HiX + LoX + BX; X`009`009`009`009`009cy = HiY + LoY + BY; X`009`009`009`009`009if (mode == GRAPH) `123 X`009`009`009`009`009 xtek_ltsm(cx,cy); X X`009`009`009`009`009`125 else `123`009/* mode == PTPLT */ X`009`009`009`009`009 xtek_mtarc(cx,cy); X`009`009`009`009`009`125 X`009`009`009`009`125 X`009`009`009`125 else `123`009/* Lo Y or extra byte */ X`009`009`009`009if (gotLoY) `123`009/* previous LoY => extra byte */ X`009`009`009`009`009BX = (LoY & 0x0c) >> 2; X`009`009`009`009`009BY = (LoY & 0x30) >> 4; X`009`009`009`009`009LoY = (c & 0x1f) << 2; X`009`009`009`009`009/* gotLoY stays TRUE */ X`009`009`009`009`125 else `123`009/* assume is LoY */ X`009`009`009`009`009LoY = (c & 0x1f) << 2; X`009`009`009`009`009gotLoY = TRUE; X`009`009`009`009`125 X`009`009`009`125 X`009`009`125 else /* end of GRAPH mode vector address parsing*/ X`009`009/* so, it isn't a vector address */ X`009`009switch ( c ) `123 X`009`009case ( NUL ): /* padding */ X`009`009case ( SYN ): /* padding */ X`009`009case ( BEL ): /* ignore */ X`009`009`009break; X X`009`009case ( LF ): X`009`009`009cy -= tsizey; X`009`009`009xtek_moveto(cx,cy); X`009`009`009break; X X`009`009case ( CR ): X`009`009`009mode = ALPHA; X`009`009`009leftmargin = 0; X`009`009`009break; X X`009`009case ( RS ): X`009`009`009mode = INCRE; X`009`009`009break; X X`009`009case ( FS ): X`009`009`009fprintf(stderr,"special point plot not implemented\n"); X`009`009`009break; X X`009`009case ( GS ): X`009`009`009dark_vector = TRUE; X`009`009`009break; X X`009`009case ( US ): X`009`009`009mode = ALPHA; X`009`009`009break; X X`009`009case ( ESC ): X`009`009`009oldmode = GRAPH; X`009`009`009mode = LCEMD; X`009`009`009break; X X`009`009default : V`009`009`009if (debug) fprintf(stderr, "Unknown GRAPH mode character 0x%02x\n", X c); X`009`009`009break; X`009`009`125`009/* end of switch on non-vector char in GRAPH mode */ X`009break;`009/* end of GRAPH mode */ X X`009case INCRE: X`009`009/* could do with bit masking and check for control, */ X`009`009/* but this is is simpler. (Let the compiler work). */ X`009`009switch ( c ) `123 X`009`009case ( 32 ): X`009`009 xtek_smt(cx,cy); X`009`009`009beamon = FALSE; X`009`009`009break; X X`009`009case ( 80 ): X`009`009 xtek_moveto(cx,cy); X`009`009`009beamon = TRUE; X`009`009`009break; X X`009`009case ( 68 ):`009/* N */ X`009`009`009if (++cy > YDIM) cy = YDIM; X`009`009`009if (beamon) xtek_lineto(cx,cy); X`009`009`009break; X`009`009`009 X`009`009case ( 69 ):`009/* NE */ X`009`009`009if (++cy > YDIM) cy = YDIM; X`009`009`009if (++cx > XDIM) cx = XDIM; X`009`009`009if (beamon) xtek_lineto(cx,cy); X`009`009`009break; X X`009`009case ( 65 ):`009/* E */ X`009`009`009if (++cx > XDIM) cx = XDIM; X`009`009`009if (beamon) xtek_lineto(cx,cy); X`009`009`009break; X X`009`009case ( 73 ):`009/* SE */ X`009`009`009if (--cy < 0) cy = 0; X`009`009`009if (++cx > XDIM) cx = XDIM; X`009`009`009if (beamon) xtek_lineto(cx,cy); X`009`009`009break; X X`009`009case ( 72 ):`009/* S */ X`009`009`009if (--cy < 0) cy = 0; X`009`009`009if (beamon) xtek_lineto(cx,cy); X`009`009`009break; X X`009`009case ( 74 ):`009/* SW */ X`009`009`009if (--cy < 0) cy = 0; X`009`009`009if (--cx < 0) cx = 0; X`009`009`009if (beamon) xtek_lineto(cx,cy); X`009`009`009break; X X`009`009case ( 66 ):`009/* W */ X`009`009`009if (--cx < 0) cx = 0; X`009`009`009if (beamon) xtek_lineto(cx,cy); X`009`009`009break; X X`009`009case ( 70 ):`009/* NW */ X`009`009`009if (++cy > YDIM) cy = YDIM; X`009`009`009if (--cx < 0) cx = 0; X`009`009`009if (beamon) xtek_lineto(cx,cy); X`009`009`009break; X X`009`009case ( ESC ): X`009`009`009if (beamon) xtek_smt(cx,cy); X`009`009`009oldmode = INCRE; X`009`009`009mode = LCEMD; X`009`009`009break; X X`009`009case ( FS ): X`009`009`009if (beamon) xtek_smt(cx,cy); X`009`009`009mode = PTPLT; X`009`009`009break; X X`009`009case ( GS ): X`009`009`009if (beamon) xtek_smt(cx,cy); X`009`009`009mode = GRAPH; X`009`009`009dark_vector = TRUE; X`009`009`009break; X X`009`009case ( RS ): X`009`009`009break; X X`009`009case ( US ): X`009`009`009if (beamon) xtek_smt(cx,cy); X`009`009`009mode = ALPHA; X`009`009`009break; X X`009`009default: V`009`009`009if (debug) fprintf(stderr,"Unknown incremental mode character 0x%02 Xx\n", c); X`009`009`009break; X`009`009`125`009/* end of INCR switch on c */ X`009break;`009/* end of INCREmental mode */ X X`009case LCEMD: X`009`009if ((c > 95) && (c < 117)) `123 X`009`009`009/* set Z axis */ X`009`009`009if ((char) c & 0x08) `123 X`009`009`009`009xtek_DZ(); X`009`009`009`125 else `123 X`009`009`009`009xtek_FZ(); X`009`009`009`125 X`009`009`009/* set vector type */ X`009`009`009switch ((char) c & 0x07) `123 X`009`009`009case 0:`009/* normal vectors */ X X`009`009`009`009xtek_NV(); X`009`009`009`009break; X X`009`009`009case 1:`009/* dotted vectors */ X`009`009`009`009xtek_DV(); X`009`009`009`009break; X X`009`009`009case 2:`009/* dot-dash vectors */ X`009`009`009`009xtek_DDV(); X`009`009`009`009break; X X`009`009`009case 3:`009/* short-dash vectors */ X`009`009`009`009xtek_SDV(); X`009`009`009`009break; X X`009`009`009case 4:`009/* long-dash vectors */ X`009`009`009`009xtek_LDV(); X`009`009`009`009break; X X`009`009`009default:`009/* error */ V`009`009`009`009if (debug) fprintf(stderr,"Unknown beam selector 0x%02x\n", (ch Xar) c); X`009`009`009`009break; X`009`009`009`125 X`009`009`125 else `123 X`009`009`009switch ( c ) `123 X`009`009`009case ( FF ):`009/* erase */ X`009`009`009`009if (pr_on_er) `123 X`009`009`009`009`009xtek_showpage_NP(); X`009`009`009`009`009if (scale_factor != 1.0) `123 X`009`009`009`009`009 xtek_scale(scale_factor); X`009`009`009`009`009`125 X`009`009`009`009`125 X`009`009`009`009xtek_DP(tsizey); X`009`009`009`009cx = 0; cy = YDIM - tsizey; X`009`009`009`009break; X X`009`009`009case ( '8' ): X`009`009`009`009/* default size */ X`009`009`009`009xtek_FntH_setfont(); X`009`009`009`009tsizex = CHUGEX; tsizey = CHUGEY; X`009`009`009`009break; X X`009`009`009case ( '9' ): X`009`009`009`009if (! used_large ) `123 X`009`009`009`009`009used_large = TRUE; X`009`009`009`009`009xtek_DFntL(); X`009`009`009`009`125 X`009`009`009`009xtek_FntL_setfont(); X`009`009`009`009tsizex = CLARGEX; tsizey = CLARGEY; X`009`009`009`009break; X X`009`009`009case ( ':' ): X`009`009`009`009tsizex = CMEDX; tsizey = CMEDY; X`009`009`009`009if (! used_med ) `123 X`009`009`009`009`009used_med = TRUE; X`009`009`009`009`009xtek_DFntM(); X`009`009`009`009`125 X`009`009`009`009xtek_FntM_setfont(); X`009`009`009`009break; X X`009`009`009case ( ';' ): X`009`009`009`009tsizex = CSMALLX; tsizey = CSMALLY; X`009`009`009`009if (! used_small ) `123 X`009`009`009`009`009used_small = TRUE; X`009`009`009`009`009xtek_DFntS(); X`009`009`009`009`125 X`009`009`009`009xtek_FntS_setfont(); X`009`009`009`009break; X X`009`009`009case ( BS ): X`009`009`009`009if ((cx -= tsizex) < 0) `123 X`009`009`009`009`009cx = XDIM; X`009`009`009`009`125 X`009`009`009`009break; X X`009`009`009case ( HT ): X`009`009`009case ( SPACE ): X`009`009`009`009if ((cx += tsizex) > XDIM) `123 X`009`009`009`009`009/* new line or margin */ X`009`009`009`009`009if((cy -= tsizey) < 0) `123 X`009`009`009`009`009`009cy = YDIM - tsizey; X`009`009`009`009`009`009leftmargin = leftmargin ? 0 : XDIM/2; X`009`009`009`009`009`125 X`009`009`009`009`009cx = leftmargin; X`009`009`009`009`125 X`009`009`009`009break; X X`009`009`009case ( VT ): X`009`009`009`009if ((cy += tsizey) > YDIM) `123 X`009`009`009`009`009cy = 0; X`009`009`009`009`125 X`009`009`009`009break; X X`009`009`009case ( GS ): X`009`009`009`009mode = GRAPH; X`009`009`009`009dark_vector = TRUE; X`009`009`009`009break; X X`009`009`009case ( LF ): X`009`009`009case ( CR ): X`009`009`009case ( DEL ): X`009`009`009case ( NUL ): X`009`009`009case ( ESC ): X`009`009`009case ( BEL ): X`009`009`009case ( SYN ): X`009`009`009`009ungetc( (char) ESC, infile); X`009`009`009`009break; X X`009`009`009case ( ETB ):`009/* make copy: print & start new page */ X`009`009`009`009if (pr_on_er) `123 X`009`009`009`009`009xtek_showpage_NP(); X`009`009`009`009`009if (scale_factor != 1.0) `123 X`009`009`009`009`009 xtek_scale(scale_factor); X`009`009`009`009`009`125 X`009`009`009`009`009cx = 0; cy = YDIM - tsizey; X`009`009`009`009`125 else `123 X`009`009`009`009`009xtek_copypage(); X`009`009`009`009`125 X`009`009`009`009break; X X`009`009`009case ( SO ): X`009`009`009case ( SI ): V`009`009`009`009if (debug) fprintf(stderr, "No alternate character set implemen Xted\n"); X`009`009`009`009break; X X`009`009`009case ( CAN ): X`009`009`009case ( SUB ): X`009`009`009case ( ENQ ): V`009`009`009`009if (debug) fprintf(stderr, "GIN and BYPASS modes not implement Xed\n"); X`009`009`009`009break; X X`009`009`009case ( '?' ): X`009`009`009`009ungetc( (char) DEL, infile); X`009`009`009`009break; X X`009`009`009default : V`009`009`009`009if (debug) fprintf(stderr, "Unknown LCE mode character 0x%02x i Xgnored\n", c); X`009`009`009`009break; X`009`009`009`125`009/* end of LCE mode switch */ X`009`009`125 X`009mode = oldmode; X`009break; X X`009default: X`009`009if (debug) fprintf(stderr, "Unknown major mode %d\n", mode); X`009`009break; X`009`125 /* end of mode switch */ X`009`125 /* end of main input loop */ X`009xtek_showpage(); X`009if (!mbx_mode) fclose(infile); X`009`125 while ((mbx_mode == 1) `124`124 (++optind < argc) ); X`125 X $ GOSUB UNPACK_FILE $ FILE_IS = "XTEKX.C" $ CHECKSUM_IS = 322132719 $ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY X/* COPYRIGHT (c) 1989 BY * X * PARADIGM ASSOCIATES INCORPORATED, CAMBRIDGE, MASSACHUSETTS. * X *`009`009`009 ALL RIGHTS RESERVED * X XPermission to use, copy, modify, and distribute this software and its Xdocumentation for any purpose and without fee is hereby granted, Xprovided that the above copyright notice appear in all copies and that Xboth that copyright notice and this permission notice appear in Xsupporting documentation, and that the name of Paradigm Associates Inc Xnot be used in advertising or publicity pertaining to distribution of Xthe software without specific, written prior permission. X XPARADIGM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL XPARADIGM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS XSOFTWARE. X X*/ X X X X#include X X#include "xtek.h" X Xextern int tv_mode; Xextern int mbx_mode; X Xint tv_simulate_transform(xa,xb,ya,yb,x) X int xa,xb,ya,yb,x; X`123return((((xa-x)*yb)+((x-xb)*ya))/(xa-xb));`125 X X Xint tv_border = 10; X X#define tv_height() plotx_height() X#define tv_width() plotx_width() X Xxtek_init() X`123if(!plotx_init()) X `123fprintf(stderr,"can't open x-display\n"); X exit(1);`125`125 X Xint tv_transform_x (x) X int x; X`123return(tv_simulate_transform(0,XDIM,tv_border,tv_width()-tv_border,x));`125 X Xint tv_transform_y (y) X int y; V`123return(tv_simulate_transform(0,YDIM,tv_height()-tv_border,tv_border,y));`12 X5 X Xxtek_scale(scale_factor) X double scale_factor; X`123if (tv_mode) X fprintf(stderr,"xtek_scale?\n"); X else X fprintf(stdout,"%f %f scale\n", scale_factor, scale_factor);`125 X `032 X Xxtek_char(c,cx,cy) X int c,cx,cy; X`123if (tv_mode) X plotx_char(tv_transform_x(cx),tv_transform_y(cy),c); X else X fprintf(stdout,"(%c) %d %d PR\n", (char) c, cx, cy);`125 X Xint tv_x,tv_y; X Xxtek_moveto(cx,cy) X int cx,cy; X`123if (tv_mode) X `123tv_x = cx; X tv_y = cy;`125 X else X fprintf(stdout,"%d %d moveto\n",cx, cy);`125 X X Xxtek_ltsm(cx,cy) X int cx,cy; X`123if (tv_mode) X `123plotx_line(tv_transform_x(tv_x), X`009 tv_transform_y(tv_y), X`009 tv_transform_x(cx), X`009 tv_transform_y(cy)); X tv_x = cx; X tv_y = cy;`125 X else X fprintf(stdout,"%d %d lineto stroke %d %d moveto\n", cx, cy, cx, cy);`125 X Xxtek_mtarc(cx,cy) X int cx,cy; X`123if (tv_mode) X fprintf(stderr,"xtek_moveto?\n"); X else X fprintf(stdout,"%d %d moveto %d %d 1 0 360 arc\n", cx, cy, cx, cy);`125 X `032 Xxtek_smt(cx,cy) X int cx,cy; X`123if (tv_mode) X `123tv_x = cx; X tv_y = cy;`125 X else X fprintf(stdout,"stroke %d %d moveto\n", cx, cy);`125 X `032 Xxtek_lineto(cx,cy) X int cx,cy; X`123if (tv_mode) X `123plotx_line(tv_transform_x(tv_x), X`009 tv_transform_y(tv_y), X`009 tv_transform_x(cx), X`009 tv_transform_y(cy)); X tv_x = cx; X tv_y = cy;`125 X else X fprintf(stdout,"%d %d lineto\n", cx, cy);`125 X X `032 Xxtek_DP(tsizey) X int tsizey; X`123if (tv_mode) X `123`125 X else X fprintf(stdout, "%d DP\n", tsizey);`125 X X Xxtek_copypage() X`123if (tv_mode) X `123`125 X else X fprintf(stdout, "copypage\n");`125 X Xxtek_DDV() X`123if (tv_mode) X `123`125 X else X fprintf(stdout,"DDV\n");`125 X Xxtek_DFntL() X`123if (tv_mode) X `123`125 X else X fprintf(stdout,"DFntL\n");`125 X Xxtek_DFntM() X`123if (tv_mode) X `123`125 X else X fprintf(stdout,"DFntM\n");`125 X Xxtek_DFntS() X`123if (tv_mode) X `123`125 X else X fprintf(stdout,"DFntS\n");`125 X Xxtek_DV() X`123if (tv_mode) X `123`125 X else X fprintf(stdout,"DV\n");`125 X Xxtek_DZ() X`123if (tv_mode) X `123`125 X else X fprintf(stdout,"DZ\n");`125 X Xxtek_FntH_setfont() X`123if (tv_mode) X `123`125 X else X fprintf(stdout,"FntH setfont\n");`125 X Xxtek_FntL_setfont() X`123if (tv_mode) X `123`125 X else X fprintf(stdout,"FntL setfont\n");`125 X Xxtek_FntM_setfont() X`123if (tv_mode) X `123`125 X else X fprintf(stdout,"FntM setfont\n");`125 X Xxtek_FntS_setfont() X`123if (tv_mode) X `123`125 X else X fprintf(stdout,"FntS setfont\n");`125 X Xxtek_FZ() X`123if (tv_mode) X `123`125 X else X fprintf(stdout,"FZ\n");`125 X Xxtek_LDV() X`123if (tv_mode) X `123`125 X else X fprintf(stdout,"LDV\n");`125 X Xxtek_NV() X`123if (tv_mode) X `123`125 X else X fprintf(stdout,"NV\n");`125 X Xxtek_SDV() X`123if (tv_mode) X `123`125 X else X fprintf(stdout,"SDV\n");`125 X X Xxtek_showpage() X`123if (tv_mode) X `123if (mbx_mode) X plotx_force_output(); X else X `123char buffer[512]; X plotx_bell(); X fgets(buffer,sizeof(buffer),stdin);`125`125 X else X fprintf(stdout,"showpage\n");`125 X`032 Xxtek_showpage_NP() X`123if (tv_mode) X `123xtek_showpage(); X if (mbx_mode) plotx_clear();`125 X else X fprintf(stdout,"showpage\nNP\n");`125 X X $ GOSUB UNPACK_FILE $ FILE_IS = "XTEK_MBX.C" $ CHECKSUM_IS = 695680215 $ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY X/* COPYRIGHT (c) 1990 BY * X * MITECH CORPORATION, CONCORD, MASSACHUSETTS. * X *`009`009`009 ALL RIGHTS RESERVED * X XPermission to use, copy, modify, and distribute this software and its Xdocumentation for any purpose and without fee is hereby granted, Xprovided that the above copyright notice appear in all copies and that Xboth that copyright notice and this permission notice appear in Xsupporting documentation, and that the name of MITECH Corporation Xnot be used in advertising or publicity pertaining to distribution of Xthe software without specific, written prior permission. X XMITECH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL XMITECH BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS XSOFTWARE. X X*/ X X#include X#include X#include X#include X#include X Xvoid err_exit(x) X int x; X`123exit(x);`125 X XFILE *open_xtek_mail_box(mbx_name) X char *mbx_name; X`123char tmp[512]; X int j,n; X FILE *f; X n = strlen(mbx_name); X for(j=0;j - prints character X`123`009moveto show `125 def X X/NP`009% - -> - new page X% change default scale and orentation to match tek's X`123`009572 40 translate`009% leave a border X`00990 rotate X`009% .71707 .692308 scale`009% 0-1023X, 0-780Y X`009.1730769 .17626953 scale`009%0-4096X, 0-3120Y X`125 def X X/DP`009% tsizey -> - erase and home X`123`009clippath 1 setgray fill X`0090 setgray X`0090 exch moveto X`125 def X XFntH setfont X XNP X $ GOSUB UNPACK_FILE $ FILE_IS = "BUILD.COM" $ CHECKSUM_IS = 1735030414 $ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY X$ CALL CC_IF_NEEDED XTEKX X$ CALL CC_IF_NEEDED XTEK X$ CALL CC_IF_NEEDED PLOTX_LIB X$ CALL CC_IF_NEEDED GETOPT X$ CALL CC_IF_NEEDED XTEK_MBX X$! X$LINK: X$ LINK XTEK.OBJ,XTEKX.OBJ,PLOTX_LIB.OBJ,GETOPT.OBJ,XTEK_MBX.OBJ,SYS$INPUT:/OPT XSYS$LIBRARY:DECW$XLIBSHR/SHARE XSYS$LIBRARY:VAXCRTL/SHARE X$ XTEK == "$" + F$ENV("DEFAULT") + "XTEK" X$ DEFINE TEK2PS_PRO 'F$ENV("DEFAULT")'XTEK.PRO X$ XTEKW :== SPAWN/NOWAIT/IN=NL: XTEK -o x -e XTEK_MAIL_BOX_1 X$EXIT X$CC_IF_NEEDED: SUBROUTINE X$ C_FILE = P1 + ".C" X$ O_FILE = P1 + ".OBJ" X$ IF F$SEARCH(O_FILE) .EQS. "" THEN GOTO DO_CC X$ IF f$cvtime(f$file(C_FILE,"RDT")) .gts. f$cvtime(f$file(o_file,"RDT")) then - X goto do_cc X$ goto no_cc X$do_cc: X$ write sys$output "cc ''p1'" X$ cc 'p1' X$no_cc: X$endsubroutine $ GOSUB UNPACK_FILE $ FILE_IS = "READ.ME" $ CHECKSUM_IS = 828859222 $ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY X29-SEP-89 -GJC (GJC@PARADIGM.COM or GJC@MITECH.COM) X20-FEB-90 -GJC, updated to support XTEK_MAIL_BOX input filename hack. X XA Tektronix file to Postscript or X-Window plot converter. XCurrently VMS specific in implementation because it depends on X X XSelectAsyncInput(Wdpy,w,ExposureMask`124StructureNotifyMask, X`009`009 event_ast_handler,0); X Xfor event handling. If you need to run it under Unix you can Xadd an event handling loop in the function xtek_showpage() from Xthe file "XTEKX.C". X X XThe XTEK.C program is a modified version of a program from the Xcomp.sources.unix archive. X X @(#)t2p.c 1.10 tek2ps (Copyright) M. Fischbein X Commercial reproduction prohibited; non-profit reproduction and`032 X distribution encouraged. X XXTEK.PRO and XTEK.H are unmodified from TEK2PS. X XGETOPT.C was probably gotten from comp.sources.unix also, and modified for VMS. X XXTEKX.C and PLOTX_LIB.C are new files that do very basic plotting Xusing XLIB. X XDefine a logical name TEK2PS_PRO to point to XTEK.PRO if you are using Xthe post-script feature. X XTo produce X-WINDOW plots use an output filename of "x". X X $ XTEK -o x `032 X XTo have a mail box created, which can be used as a substitute for Xa TEK TERMINAL emulator. X X $ SPAWN/NOWAIT/IN=NL: XTEK -o x -e XTEK_MAIL_BOX_1 X XThen use the device XTEK_MAIL_BOX instead of TT to give plot routines. X XTo build under VMS use BUILD.COM X XThe file CLR.C gives a command to clear the window. XThe file CAT.C gives a command to copy a tektronics file to the mailbox Xdevice without getting into record-size problems. X XGeorge Carrette, XParadigm Associates Inc Xgjc@paradigm.com X $ GOSUB UNPACK_FILE $ EXIT