🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: mod.amiga.sources
Article #47

VT100 (V2.2 861012 DBW) Part 2 of 3

#47
From: doc
Date: Tue, 14 Oct 1986 18:02
1992 lines
52708 bytes
#	This is a shell archive.
#	Remove everything above and including the cut line.
#	Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar:	Shell Archiver
#	Run the following text with /bin/sh to create:
#	expand.c
#	remote.c
#	script.c
#	vt100.c
#	vt100.h
# This archive created: Tue Oct 14 12:58:12 1986
# By:	Craig Norborg (Purdue University Computing Center)
cat << \SHAR_EOF > expand.c
/*************************************************************
 * vt100 terminal emulator - Wild card and Directory support
 *
 *	v2.2 861012 DBW - more of the same
 *	v2.1 860915 DBW	- new features (see README)
 *           860830 Steve Drew Added Wild card support, features(expand.c)
 *	v2.0 860809 DBW - Major rewrite
 *	v1.1 860720 DBW	- Switches, 80 cols, colors, bug fixes
 *	v1.0 860712 DBW	- First version released
 *
 *      Much of the code from this module extracted from
 *      Matt Dillons Shell program. (Thanxs Matt.)
 *************************************************************/

#define MODULE_EXPAND 1
#include "vt100.h"

struct DPTR {                    /* Format of directory fetch pointer */
   struct FileLock *lock;        /* lock on directory   */
   struct FileInfoBlock *fib;    /* mod'd fib for entry */
};

/*
 * Disk directory routines
 *
 *
 * dopen() returns a struct DPTR, or NULL if the given file does not
 * exist.  stat will be set to 1 if the file is a directory.  If the
 * name is "", then the current directory is openned.
 *
 * dnext() returns 1 until there are no more entries.  The **name and
 * *stat are set.  *stat = 1 if the file is a directory.
 *
 * dclose() closes a directory channel.
 *
 */

struct DPTR *
dopen(name, stat)
char *name;
int *stat;
{
   struct DPTR *dp;
   int namelen, endslash = 0;
   struct FileLock *MyLock;
   
   MyLock = (struct FileLock *)( (ULONG) ((struct Process *)
                                 (FindTask(NULL)))->pr_CurrentDir);
   namelen = strlen(name);
   if (namelen && name[namelen - 1] == '/') {
      name[namelen - 1] = '\0';
      endslash = 1;
   }
   *stat = 0;
   dp = (struct DPTR *)malloc(sizeof(struct DPTR));
   if (*name == '\0') 
      dp->lock = (struct FileLock *)DupLock (MyLock);
   else
      dp->lock = (struct FileLock *)Lock (name, ACCESS_READ);
   if (endslash)
      name[namelen - 1] = '/';
   if (dp->lock == NULL) {
      free (dp);
      return (NULL);
   }
   dp->fib = (struct FileInfoBlock *)
         AllocMem((long)sizeof(struct FileInfoBlock), MEMF_PUBLIC);
   if (!Examine (dp->lock, dp->fib)) {
      dclose (dp);
      return (NULL);
   }
   if (dp->fib->fib_DirEntryType >= 0)
      *stat = 1;
   return (dp);
}

dnext(dp, pname, stat)
struct DPTR *dp;
char **pname;
int *stat;
{
   if (dp == NULL)
      return (0);
   if (ExNext (dp->lock, dp->fib)) {
      *stat = (dp->fib->fib_DirEntryType < 0) ? 0 : 1;
      *pname = dp->fib->fib_FileName;
      return (1);
   }
   return (0);
}


dclose(dp)
struct DPTR *dp;
{
   if (dp == NULL)
      return (1);
   if (dp->fib)
      FreeMem (dp->fib, (long)sizeof(*dp->fib));
   if (dp->lock)
      UnLock (dp->lock);
   free (dp);
   return (1);
}

free_expand(av)
char **av;
{
   char **base = av;

   if (av) {
      while (*av) {
         free (*av);
         ++av;
      }
      free (base);
   }
}

/*
 * EXPAND(wild_name, pac)
 *    wild_name      - char * (example: "df0:*.c")
 *    pac            - int  *  will be set to # of arguments.
 *
 */


char **
expand(base, pac)
char *base;
int *pac;
{
   char **eav = (char **)malloc (sizeof(char *));
   int  eleft, eac;

   char *ptr, *name;
   char *bname, *ename, *tail;
   int stat, scr;
   struct DPTR *dp;

   *pac = eleft = eac = 0;
   base = strcpy(malloc(strlen(base)+1), base);
   for (ptr = base; *ptr && *ptr != '?' && *ptr != '*'; ++ptr);
   for (; ptr >= base && !(*ptr == '/' || *ptr == ':'); --ptr);
   if (ptr < base) {
      bname = strcpy (malloc(1), "");
   } else {
      scr = ptr[1];
      ptr[1] = '\0';
      bname = strcpy (malloc(strlen(base)+1), base);
      ptr[1] = scr;
   }
   ename = ptr + 1;
   for (ptr = ename; *ptr && *ptr != '/'; ++ptr);
   scr = *ptr;
   *ptr = '\0';
   tail = (scr) ? ptr + 1 : NULL;

   if ((dp = dopen (bname, &stat)) == NULL  ||  stat == 0) {
      free (bname);
      free (base);
      free (eav);
      emits ("Could not open directory");
      return (NULL);
   }
   while (dnext (dp, &name, &stat)) {
      if (compare_ok(ename, name)) {
         if (tail) {
            int alt_ac;
            char *search, **alt_av, **scrav;
            struct FileLock *lock;

            if (!stat)           /* expect more dirs, but this not a dir */
               continue;
            lock = (struct FileLock *)CurrentDir (dp->lock);
            search = malloc(strlen(name)+strlen(tail)+2);
            strcpy (search, name);
            strcat (search, "/");
            strcat (search, tail);
            scrav = alt_av = expand (search, &alt_ac);
            CurrentDir (lock);
            if (scrav) {
               while (*scrav) {
                  if (eleft < 2) {
                     char **scrav = (char **)malloc(sizeof(char *) * (eac + 10));
                     movmem (eav, scrav, sizeof(char *) * (eac + 1));
                     free (eav);
                     eav = scrav;
                     eleft = 10;
                  }
                  eav[eac] = malloc(strlen(bname)+strlen(*scrav)+1);
                  strcpy(eav[eac], bname);
                  strcat(eav[eac], *scrav);
                  free (*scrav);
                  ++scrav;
                  --eleft, ++eac;
               }
               free (alt_av);
            }
         } else {
            if (eleft < 2) {
               char **scrav = (char **)malloc(sizeof(char *) * (eac + 10));
               movmem (eav, scrav, sizeof(char *) * (eac + 1));
               free (eav);
               eav = scrav;
               eleft = 10;
            }
            eav[eac] = malloc (strlen(bname)+strlen(name)+1);
            eav[eac] = strcpy(eav[eac], bname);
            strcat(eav[eac], name);
            --eleft, ++eac;
         }
      }
   }
   dclose (dp);
   *pac = eac;
   eav[eac] = NULL;
   free (bname);
   free (base);
   if (eac)
      return (eav);
   free (eav);
   return (NULL);
}

/*
 * Compare a wild card name with a normal name
 */

#define MAXB   8

compare_ok(wild, name)
char *wild, *name;
{
   char *w = wild;
   char *n = name;
   char *back[MAXB][2];
   int  bi = 0;

   while (*n || *w) {
      switch (*w) {
      case '*':
         if (bi == MAXB) {
            emits ("Too many levels of '*'");
            return (0);
         }
         back[bi][0] = w;
         back[bi][1] = n;
         ++bi;
         ++w;
         continue;
goback:
         --bi;
         while (bi >= 0 && *back[bi][1] == '\0')
            --bi;
         if (bi < 0)
            return (0);
         w = back[bi][0] + 1;
         n = ++back[bi][1];
         ++bi;
         continue;
      case '?':
         if (!*n) {
            if (bi)
               goto goback;
            return (0);
         }
         break;
      default:
         if (toupper(*n) != toupper(*w)) {
            if (bi)
               goto goback;
            return (0);
         }
         break;
      }
      if (*n)  ++n;
      if (*w)  ++w;
   }
   return (1);
}

set_dir(new)
char *new;
{
   register 	char 		*s;
   int   			i;
   struct 	FileLock 	*lock;
   char 			temp[60];
   struct       FileInfoBlock   fib;
  
   if (*new != '\000') {
      strcpy(temp, MyDir);
      s = new;
      if (*s == '/') {
         s++;
         for (i=strlen(MyDir);
              MyDir[i] != '/' && MyDir[i] != ':';
              i--);
         MyDir[i+1] = '\0';
           strcat(MyDir, s);
         }
      else if (exists(s, ':') == 0) {
         if (MyDir[strlen(MyDir)-1] != ':')
            strcat(MyDir, "/");
         strcat(MyDir, s);
         }
      else
         strcpy(MyDir, s);

      if ((lock = (struct FileLock *)Lock(MyDir)) == 0) {
         emits("Directory not found\n");
         strcpy(MyDir, temp);
         }
      else {
      	 if (Examine(lock, &fib)) {
      	    if (fib.fib_DirEntryType > 0) {
               if (lock = (struct FileLock *)CurrentDir(lock))
                  UnLock(lock);
               if (MyDir[strlen(MyDir)-1] == '/')
                  MyDir[strlen(MyDir)-1] = '\0';
               }
            else {
            	emits("Not a Directory\n");               
            	strcpy(MyDir,temp);
               }
            }
         }
      }
}

exists(s,c)
char *s,c;
    {
    while (*s != '\000')
	if (*s++ == c) return(1);
    return(0);
    }
SHAR_EOF
cat << \SHAR_EOF > remote.c
/****************************************************
 * vt100 emulator - remote character interpretation
 *
 *	v2.2 861012 DBW - more of the same
 *	v2.1 860915 DBW - new features (see README)
 *	     860823 DBW - Integrated and rewrote lots of code
 *	v2.0 860803 DRB - Rewrote the control sequence parser
 *	v1.1 860720 DBW	- Switches, 80 cols, colors, bug fixes
 *	v1.0 860712 DBW	- First version released
 *
 ****************************************************/

#define MODULE_REMOTE 1
#include "vt100.h"

static int    p[10];
static int    numpar;
static char   escseq[40];

void doctrl();
void doesc();				/* force correct denomination */
void doerase();
void doindex();

/************************************************
*  function to handle remote characters
*************************************************/
void doremote(c)
char c;
    {
    if (c == 24) { inesc = 0; inctrl = 0; return; }
    if (c == 27 || (inesc >= 0 && c >= ' ')) { doesc(c); return; }
    if (inctrl >= 0 && c >= ' ') { doctrl(c); return; }
    if (c == 10 || c == 11 || c == 12) {
	if (nlmode) doindex('E'); else doindex('D');
	return;
	}
    if (c == 13) {
	if (!nlmode) emit(c);
	return;
	}
    if (c == 15) { alt = 0; return; }
    if (c == 14) { alt = 1; return; }
    if (a[alt] && c > 94 && c < 127) { doalt(c); return; }
    emit(c);
    }

void doesc(c)
char c;
{
    if (inesc < 0) { inesc = 0; return; }
    if (c == 27 || c == 24) { inesc = -1; return; }
    if (c < ' ' || c == 127) return;		  /* Ignore control chars */
    if (c < '0') {escseq[inesc++] = c; return; }  /* Collect intermediates */

    /* by process of elimination, we have a final character.  Put it in
       the buffer, and dispatch on the first character in the buffer */

    escseq[inesc] = c;
    inesc = -1;				/* No longer collecting a sequence */
    switch (escseq[0])			/* Dispatch on the first received */
    {
      case '[':				/* Control sequence introducer */
	numpar = 0;			/* No parameters yet */
	private = 0;			/* Not a private sequence (yet?) */
	badseq = 0;			/* Good until proven bad */
	p[0] = p[1] = 0;		/* But default the first parameter */
	inctrl = 0;			/* We are in a control sequence */
	return;				/* All done for now ... */

      case 'D': case 'E': case 'M':	/* Some kind of index */
	doindex (c);			/* Do the index */
	return;				/* Return */

      case '7':				/* Save cursor position */
	savx = x; savy = y; savmode = curmode; savalt = alt;
	sa[0] = a[0]; sa[1] = a[1];
	return;

      case '8':				/* Restore cursor position */
	x = savx; y = savy; alt = savalt; curmode = savmode;
	a[0] = sa[0]; a[1] = sa[1];
	return;

      case 'c':				/* Reset */
	top = MINY; bot = MAXY; savx = MINX; savy = MINY;
	curmode = FS_NORMAL; keyapp = FALSE;
	inesc = -1;
	a[0] = 0; a[1] = 0; sa[0] = 0; sa[1] = 0;
	emit(12);
	return;

      case '(':				/* Change character set */
	if (c == '0' || c == '2') a[0] = 1; else a[0] = 0;
	return;

      case ')':				/* Change the other character set */
	if (c == '0' || c == '2') a[1] = 1; else a[1] = 0;
	return;

      case '=':				/* set keypad application mode */
        keyapp = TRUE;
        return;
        
      case '>':				/* reset application mode */
        keyapp = FALSE;
        return;
        
      case 'Z':
	sendchar(27); sendstring("[?1;7c"); return;

      /* If we didn't match anything, we can just return, happy in the
	 knowledge that we've at least eaten the whole sequence */

    }					/* End of switch */
    return;
}

void doctrl(c)
char c;
{
    int	    i;

    if (c == 27 || c == 24) { inctrl = -1; return; }
    if (c < ' ' || c == 127) return;		  /* Ignore control chars */

    /* First, look for some parameter characters.  If the very first
       parameter character isn't a digit, then we have a private sequence */

    if (c >= '0' && c < '@')
    {
	/* can't have parameters after intermediates */
	if (inctrl > 0) {badseq++ ; return; }
	switch (c)
	{
	  case '0': case '1': case '2': case '3': case '4':
	  case '5': case '6': case '7': case '8': case '9':
	    p[numpar] = p[numpar] * 10 + (c - '0');
	    return;

	  case ';':
	    p[++numpar] = 0;		/* Start a new parameter */
	    return;

	  case '<': case '=': case '>': case '?': /* Can only mean private */
	    if (inctrl == 0) private = c; /* Only allowed BEFORE parameters */
	    return;

	/* if we come here, it's a bad sequence */
	}
	badseq++;			/* Flag the bad sequence */
    }

    if (c < '0')			/* Intermediate character */
    {
	escseq[inctrl++] = c;		/* Save the intermediate character */
	return;
    }

    /* if we get here, we have the final character.  Put it in the 
       escape sequence buffer, then dispatch the control sequence */

    numpar++;				/* Reflect the real number of parameters */
    escseq[inctrl++] = c;		/* Store the final character */
    escseq[inctrl] = '\000';		/* Tie off the buffer */
    inctrl = -1;			/* End of the control sequence scan */

    /* Don't know how to do most private sequences right now, so just punt
       them */

    if ((private != 0 && private != '?') || badseq != 0) return;
    if (private == '?' && escseq[0] != 'h' && escseq[0] != 'l') return;

    switch (escseq[0])			/* Dispatch on first intermediate or final */
    {
      case 'A': if (p[0]<=0) p[0] = 1;
		y -= 8*p[0]; if (y<top)  y = top;  return;
      case 'B': if (p[0]<=0) p[0] = 1;
		y += 8*p[0]; if (y>bot)  y = bot;  return;
      case 'C': if (p[0]<=0) p[0] = 1;
		x += 8*p[0]; if (x>MAXX) x = MAXX; return;
      case 'D': if (p[0]<=0) p[0] = 1;  
		x -= 8*p[0]; if (x<MINX) x = MINX; return;

      case 'H': case 'f':		/* Cursor position */
	if (p[0] <= 0) p[0] = 1;
	if (p[1] <= 0) p[1] = 1;
	y = (--p[0]*8)+MINY; x = (--p[1]*8)+MINX;
	if (y > MAXY) y = MAXY;
	if (x > MAXX) x = MAXX;
	if (y < MINY) y = MINY;
	if (x < MINX) x = MINX;
	return;

      case 'r':				/* Set scroll region */
	if (p[0] <= 0) p[0] = 1;
	if (p[1] <= 0) p[1] = p_lines;
	top = (--p[0]*8)+MINY; bot = (--p[1]*8)+MINY;
	if (top < MINY) top = MINY;
	if (bot > MAXY) bot = MAXY;
	if (top > bot) { top = MINY; bot = MAXY; }
	x = MINX; y = MINY;
	return;

      case 'm':				/* Set graphic rendition */
	for (i=0;i<numpar;i++) {
	    if (p[i] < 0) p[i] = 0;
	    switch (p[i]) {
		case 0:
		curmode  = FS_NORMAL;
		break;

		case 1:
		curmode |= FSF_BOLD;
		break;

		case 4:
		curmode |= FSF_UNDERLINED;
		break;

		case 5:
		curmode |= FSF_ITALIC;
		break;

		default:
		curmode |= FSF_REVERSE;
		break;
		}
	    }
	return;

      case 'K':				/* Erase in line */
	doerase();
	return;

      case 'J':				/* Erase in display */
	if (p[0] < 0) p[0] = 0;
	SetAPen(mywindow->RPort,0L);
	if (p[0] == 0) {
	    if (y < MAXY) RectFill(mywindow->RPort,
		(long)MINX,(long)(y+2),(long)(MAXX+7),(long)(MAXY+1));
	    }
	else if (p[0] == 1) {
	    if (y > MINY) RectFill(mywindow->RPort,
		(long)MINX,(long)(MINY-6),(long)(MAXX+7),(long)(y-7));
	    }
	else RectFill(mywindow->RPort,
	    (long)MINX,(long)(MINY-6),(long)(MAXX+7),(long)(MAXY+1));
	SetAPen(mywindow->RPort,1L);
	doerase(); return;

      case 'h':				/* Set parameter */
	if (private == 0 && p[0] == 20)		nlmode = 1;
	else if (private == '?' && p[0] == 7)	p_wrap = 1;
	return;

      case 'l':				/* Reset parameter */
	if (private == 0 && p[0] == 20)		nlmode = 0;
	else if (private == '?' && p[0] == 7)	p_wrap = 0;
	return;

      case 'x':
	sendchar(27); sendstring("[3;1;8;64;64;1;0x"); return;

      case 'n':
	if (p[0] == 6) {
	    sendchar(27);
	    sprintf(escseq,"[%d;%dR",((y-MINY)/8)+1,((x-MINX)/8)+1);
	    sendstring(escseq); return;
	    }
	sendchar(27); sendstring("[0n"); return;

      case 'c':
	sendchar(27); sendstring("[?1;7c"); return;
    }

    /* Don't know how to do this one, so punt it */
}

void doindex(c)
char c;
    {
    if (c != 'M') {
	if (c == 'E') x = MINX;
	if (y > bot) if (y < MAXY) y += 8;
	if (y == bot)
	    ScrollRaster(mywindow->RPort,0L,8L,(long)MINX,(long)(top-6),
		(long)(MAXX+7),(long)(bot+1));
	if (y < bot) y += 8;
	}
    else {
	if (y < top) if (y > MINY) y -= 8;
	if (y == top)
	    ScrollRaster(mywindow->RPort,0L,-8L,(long)MINX,(long)(top-6),
		(long)(MAXX+7),(long)(bot+1));
	if (y > top) y -= 8;
	}
    return;
    }

doalt(c)
char c;
    {
    int oldx,newx;
    inesc = -1;
    oldx = x; emit(' '); newx = x;
    x = oldx;
    SetAPen(mywindow->RPort,1L);
    switch (c) {
	case 'a':
	doline(0,-6,8,1);
	break;

	case 'j':
	case 'm':
	case 'v':   doline(4,-6,4,-2);
	if      (c=='j')  doline(0,-2,4,-2);
	else if (c=='m')  doline(4,-2,8,-2);
	else              doline(0,-2,8,-2);
	break;

	case 'k':
	case 'l':
	case 'w': doline(4,-2,4,1);
	if      (c=='k')  doline(0,-2,4,-2);
	else if (c=='l')  doline(4,-2,8,-2);
	else              doline(0,-2,8,-2);
	break;

	case 'n':
	case 'q': doline(0,-2,8,-2);
	if      (c=='n')  doline(4,-6,4,2);
	break;

	case 't':
	case 'u':
	case 'x':   doline(4,-6,4,1);
	if      (c=='t')  doline(4,-2,8,-2);
	else if (c=='u')  doline(0,-2,4,-2);
	break;
	}
    x = newx;
    }

doline(x1,y1,x2,y2) {
    RectFill(mywindow->RPort,(long)(x+x1),(long)(y+y1),
	(long)(x+x2),(long)(y+y2));
    }

void doerase()
    {
    if (p[0] < 0) p[0] = 0;
    SetAPen(mywindow->RPort,0L);
    if (p[0] == 0) RectFill(mywindow->RPort,(long)x,(long)(y-6),
	(long)(MAXX+7),(long)(y+1));
    else if (p[0] == 1) RectFill(mywindow->RPort,
	(long)MINX,(long)(y-6),(long)(x+7),(long)(y+1));
    else RectFill(mywindow->RPort,
	(long)MINX,(long)(y-6),(long)(MAXX+7),(long)(y+1));
    SetAPen(mywindow->RPort,1L);
    return;
    }

SHAR_EOF
cat << \SHAR_EOF > script.c
/*************************************************************
 * vt100 terminal emulator - Script file support
 *
 *	v2.2 861012 DBW - more of the same
 *	v2.1 860915 DBW - new features (see README)
 *	     860901 ACS - Added BAUD, PARITY and WORD commands & handling
 *	     860823 DBW - Integrated and rewrote lots of code
 *	     860815 Steve Drew: Initial version written of SCRIPT.C
 *	v2.0 860809 DBW - Major rewrite
 *	v1.1 860720 DBW	- Switches, 80 cols, colors, bug fixes
 *	v1.0 860712 DBW	- First version released
 *
 *************************************************************/

#define MODULE_SCRIPT 1

#include "vt100.h"

struct COMMAND {
    void (*func)();
    char *cname;
    };

struct LABEL  {
    struct LABEL *next;
    char *name;
    long pos;
    };

extern long atol();

/****************  globals  needed  ******************/

char		on_string[20];       /* string to match on for on cmd    */
char 		wait_string[20];     /* string to match of for wait cmd  */
char 		golabel[20];         /* label we are looking for in goto */
char 		on_cmd[20];          /* command to execute when on matchs*/
int 		onsize;		     /* size of on_string                */
int 		waitsize;            /* size of wait_string              */
int 		onpos;               /* position in on string for search */
int 		waitpos;             /* pos in wait_string for search    */
int 		on_match;            /* flag set while doing on_cmd      */
FILE 		*sf;                 /* file pointer for script file     */
struct LABEL 	*lbase = NULL;       /* will point to first label        */
struct LABEL 	*labels;             /* current label pointer            */

void cmd_send(), cmd_wait(), cmd_on(), cmd_goto(), cmd_delay(), cmd_done(),
     cmd_ks(), cmd_kg(), cmd_kr(), cmd_xs(), cmd_xr(), cmd_cap(), cmd_as(),
     cmd_null(), cmd_kb(), cmd_cd(), cmd_sb(), cmd_baud(), cmd_word(),
     cmd_parity(), cmd_bt(), cmd_tm();

char *next_wrd(), *tostring();


/********************** command table **********************************/

static struct COMMAND commands[]= {
    cmd_send,   "send",         /* send string to host      */
    cmd_wait,   "wait",         /* wait for a string from host */
    cmd_on,     "on", 		/* on a 'string' do a cmd   */
    cmd_goto,   "goto",         /* goto label               */
    cmd_delay,  "delay",        /* delay amount of seconds  */
    cmd_done,   "exit",         /* exit script file         */
    cmd_ks,     "ks",           /* kermit send file         */
    cmd_kr,     "kr",           /* kermit receive file      */
    cmd_kg,     "kg",           /* kermit get file          */
    cmd_kb,	"kb",		/* kermit bye (for server)  */
    cmd_xs,     "xs",           /* xmodem send file         */
    cmd_xr,     "xr",           /* xmodem receive file      */
    cmd_cap,    "capture",      /* ascii capture on/off     */
    cmd_as,     "ascii_send",   /* ascii send               */
    cmd_cd,     "cd",		/* change directory	    */
    cmd_sb,     "sb",		/* Send a break		    */
    cmd_baud,   "baud",		/* Set Baud Rate            */
    cmd_parity, "parity",	/* Set Parity		    */
    cmd_bt,     "bt",		/* Set Break Time	    */
    cmd_tm,     "tm",		/* Set KERMIT transfer mode */
    cmd_null,   NULL		/* mark the end of the list */
    };

/********************************************************************/
/* checks char to see if match with on string or wait_string        */
/* if on string match oncmd gets executed imediately,               */
/* if wait_string match script_wait is set.                         */
/********************************************************************/

chk_script(c)
char c;
    {
    if (on_string[0] != '\0') {
        if (on_string[onpos] == c) {
            onpos++;
            if (onpos == onsize) {
                on_match = TRUE;
                do_script_cmd(ONCOMMAND); 
                on_match = FALSE;
                return(0);
		}
	    }
        else onpos = 0;
	}
    if (wait_string[0] != '\0') {
       if (wait_string[waitpos] != c) {
            waitpos = 0;
            return(0);
	    }
        waitpos++;
        if (waitpos != waitsize) return(0);
        wait_string[0] = '\0';
        script_wait = FALSE;
	}
    }

script_start(file)
char *file;
    {
    if ((sf = fopen(file, "r")) == NULL) {
        emits("Can't open script file\n");
        return(0);
	}
    script_on = TRUE;
    script_wait = FALSE;
    wait_string[0] = '\0';
    on_string[0] = '\0';
    on_match = FALSE;
    lbase = NULL;
    }

/* return pointer to next word. set l to size of the word */

char *next_wrd(s,l)
char *s;
int *l;
    {
    char *p;
    while(*s && (*s == ' ' || *s == 9)) s++;
    p = s;
    while(*s && (*s != ' ' && *s != 9)) s++;
    *l = s-p;
    return(p);
    }

exe_cmd(p,l)
char *p;
int l;
    {
    int i;

    /* downcase the command */
    for (i=0; i<l; i++) p[i] |= ' ';    

    /* now search for it */
    for (i=0; commands[i].func != cmd_null; ++i) 
        if (strncmp(p, commands[i].cname, l) == 0) {
            (*commands[i].func)(next_wrd(p+l, &l));
            return(TRUE);
	    }
    emits ("\nScript - unknown command: ");
    emits (p);
    emits ("\n"); 
    return(FALSE);
    }

struct LABEL *find_label(lname)
char *lname;
    {
    struct LABEL *label;
  
    label = lbase;
    while(label != NULL) {
	if (strcmp(label->name, lname) == 0) return (label);
	label = label->next;
	}
    return(NULL);
    }

do_script_cmd(stat)
int stat;
    {
    int len,l;
    char line[256];
    char *p;

    if (stat == ONCOMMAND) {    /* if ON command is matched and we were     */
        strcpy(line,on_cmd);    /* doing a DELAY then abort the delay timer,*/
        p = next_wrd(line,&l);  /* except if on_cmd was just a SEND.        */
	if (*p != 'S' && script_wait == WAIT_TIMER)  {
            AbortIO((char *) &Script_Timer);
            Wait (1L << Script_Timer_Port->mp_SigBit);
            script_wait = FALSE; /* script will proceed after on command    */
	    }
	exe_cmd(p,l);
        return(0);
	}
    script_wait = FALSE;
    while(fgets(line,256,sf) != NULL) {
       len = strlen(line);
       line[--len] = '\0';
       p = next_wrd(&line[0], &l);
       if (*(p + l - 1) == ':') {       	/* its a label */
           *(p + l - 1) = '\0';
           if (find_label(p) == NULL) {   	/* it's a new label */
		if (lbase == NULL)  {  		/* it's the first label */
		    labels = lbase = (struct LABEL *) malloc (sizeof (struct LABEL));
		    }
		else {
		    labels->next = 
                           (struct LABEL *) malloc (sizeof (struct LABEL));
		    labels = labels->next;
		    }
		labels->pos  = ftell(sf);
		labels->name = malloc(l);
		labels->next = NULL;
		strcpy(labels->name, p);
		if (stat == GOTOLABEL && strcmp(p, golabel) == 0) 
                      stat = NEXTCOMMAND;
		}
	    p = next_wrd(p+l+1, &l);
	    } 	/* end of it's a label */
	if (stat == GOTOLABEL || *p == '#') continue;
	if (*p) exe_cmd(p,l);
	return(0);
	} 		/* end of while */
    if (stat == GOTOLABEL) {
        emits("\nScript - label not found: ");
        emits(golabel);
        emits("\n");
	}         
    exit_script();
    }

exit_script()
    {
    if (script_wait == WAIT_TIMER)      /* timer not done yet */
       AbortIO((char *) &Script_Timer); /* so abort it */
    emits("\nScript - terminated\n");    
    script_on = FALSE;
    script_wait = TRUE;
    fclose(sf);
    }

/* remove quotes terminate string & return pointer to start */

char *tostring(ptr)
char *ptr;
    {
    char *s1,*s2;

    s1 = ptr;
    if (*ptr == '"') {
        while(*ptr++  && *ptr != '"') ;
        if (*ptr == '"') {
            *ptr = '\0';  
            ptr = s2 = ++s1;
            while(*s2) {
		if	(*s2 != '^')	 *s1++ = *s2;
		else if (*(s2+1) == '^') *s1++ = *s2++;
		else			 *s1++ = ((*++s2)|' ')-96;
		s2++;
		}
	    *s1 = '\0';
            return(ptr);
	    }
	}
    if (*s1 == '^') {
        *s1 = (*(s1+1)|' ')-96;
        *(s1+1) = '\0';
        return(s1);
        }
    *(s1+1) = '\0';
    return(s1);
    }   
        
/***************************** SCRIPT COMMANDS ***********************/

void cmd_goto(lname)
char *lname;
    {
    struct LABEL *label;
   	                    /* if on_cmd was a goto kill wait state */
    if (on_match) { wait_string[0] = '\0'; script_wait = FALSE; }
    if ((label = find_label(lname)) == NULL) {  /* is it forward */
        strcpy(golabel,lname);
        do_script_cmd(GOTOLABEL);
	}
    else {
        fseek(sf,(long)(label->pos),0);
	}
    }

void cmd_send(str)
char *str;
    {
    sendstring(tostring(str));
    }

void cmd_wait(str)
char *str;
    {
    str = tostring(str);
    *(str+20) = '\0';         /* 20 characters max */
    strcpy(wait_string, str);
    waitsize = strlen(str);
    script_wait = WAIT_STRING;
    }

void cmd_on(str)
char *str;
    {
   char *p;

    p = tostring(str);
    strcpy(on_string, p);
    onsize = strlen(p);
    *(p+onsize+2+20) = '\0';        /* 20 characters max */
    strcpy(on_cmd,p+onsize+2);
    }

void cmd_delay(seconds)
char *seconds;
    {
    script_wait = WAIT_TIMER;
    Script_Timer.tr_time.tv_secs = atoi(seconds);
    Script_Timer.tr_time.tv_micro = 0;
    SendIO((char *) &Script_Timer.tr_node);
    }

void cmd_done(option)
char *option;
    {
    char *p;
    int  l;

    if (*option) {
	p = next_wrd(option,&l);
	*(p+l) = '\000';
	if  (strcmp(p,"vt100") == 0 || strcmp(p,"VT100") == 0)
	    cleanup("Exit vt100 from script",0);
	exit_script();
	script_start(p);
	}
    }

void cmd_ks(file)
char *file;
    {
    multi_xfer(file, doksend, 1);
    }

void cmd_kr(file)
char *file;
    {
    multi_xfer(file, dokreceive, 0);
    }

void cmd_kg(file)
char *file;
    {
    server = TRUE;
    multi_xfer(file, dokreceive, 0);
    }

void cmd_kb()
    {
    saybye();
    }

void cmd_xs(file)
char *file;
    {
    multi_xfer(file, XMODEM_Send_File, 1);
    }

void cmd_xr(file)
char *file;
    {
    multi_xfer(file, XMODEM_Read_File, 1);
    }

void cmd_cap(file)
char *file;
    {
    do_capture(file);
    }

void cmd_as(file)
char *file;
    {
    do_send(file);
    }

void cmd_cd(name)
char *name;
    {
    set_dir(name);
    }

void cmd_sb(str)
char *str;
    {
    sendbreak();
    }

void cmd_baud(rate)
char *rate;
    {
    int i = atoi(rate);

    switch( i )
	{
	case  300:
	case 1200:
	case 2400:
	case 4800:
	case 9600:
	setserbaud(i, TRUE);
	break;

	default:
	emits("\nScript - invalid baud rate: ");
	emits(rate);
	emits("\n");
	break;
	}
    }

void cmd_parity(par)
char *par;
    {
    int i;

    switch( *par|' ' )
	{
	case 'n': i =  0; break;
	case 'm': i =  1; break;
	case 's': i =  2; break;
	case 'e': i =  3; break;
	case 'o': i =  4; break;

	default:
	emits("\nScript - invalid parity: ");
	emits(par);
	emits("\n");
	return;
	}
    p_parity = i;
    ClearMenuStrip( mywindow );         /* Remove old menu */
    InitCommItems();                    /* Re-do comm menu   */
    SetMenuStrip(mywindow,&menu[0]);    /* Re-display the menu */	
    }

void cmd_bt(breaklength)
char *breaklength;
    {
    long i = atol(breaklength);
    AbortIO(Read_Request);
    Read_Request->io_BrkTime = Write_Request->io_BrkTime = i;
    setparams();
    }

void cmd_tm(tmode)
char *tmode;
    {
    switch (*tmode|' ') {
	case 'i':
	p_mode = 0;
	break;

	case 'c':
	p_mode = 1;
	break;

	default:
	emits("\nScript - invalid transfer mode: ");
	emits(tmode);
	emits("\n");
	return;
	}

    ClearMenuStrip(mywindow);
    InitCommItems();                    /* Re-do comm menu   */
    SetMenuStrip(mywindow,&menu[0]);
    }

void cmd_null(file)
char *file;
    {
    }
SHAR_EOF
cat << \SHAR_EOF > vt100.c
/************************************************************************
 *  vt100 terminal emulator with xmodem transfer capability
 *
 *	v2.2 861012 DBW - more of the same
 *	v2.1 860915 DBW - new features (see README)
 *	     860901 ACS - Added Parity and Word Length and support code
 *	     860823 DBW - Integrated and rewrote lots of code
 *	v2.0 860809 DBW - Major rewrite
 *	v1.1 860720 DBW	- Switches, 80 cols, colors, bug fixes
 *	v1.0 860712 DBW	- First version released
 *
 *  use <esc> to abort xmodem or kermit transfers
 *
 *  written by Michael Mounier
 *  new version by Dave Wecker
 ************************************************************************/

/*  all includes defines and globals */
#define MODULE_MAIN 1
#include "vt100.h"

/******************************************************/
/*                   Main Program                     */
/*                                                    */
/*      This is the main body of the program.         */
/******************************************************/

char lookahead[80];
FILE *tranr = NULL;
FILE *trans = NULL;
int capture,send;
char name[80];
struct MsgPort *mySerPort;

main(argc,argv)
int	argc;
char	**argv;
    {
    ULONG class;
    unsigned int code;
    int KeepGoing,i,la,dola,actual;
    char c,*ptr;

    ptr = InitDefaults(argc,argv);
    InitDevs();
    InitFileItems();
    InitCommItems();
    InitScriptItems();
    InitUtilItems();
    InitMenu();
    SetMenuStrip(mywindow,&menu[0]);

    MyDir[0]  =	    '\000';
    KeepGoing =	    TRUE;
    capture   =	    FALSE;
    send      =	    FALSE;
    maxcol    =	    MAXX / 8;
    la	      =	    0;
    x	      =	    MINX ; 
    y	      =	    MINY; 
    curmode   =	    FS_NORMAL;
    keyapp    =	    0;
    script_on =     FALSE;
    script_wait=    TRUE;
    SetAPen(mywindow->RPort,1L);
    cursoron();
    cursoroff();    
    emit(12);
    mySerPort = Read_Request->IOSer.io_Message.mn_ReplyPort;
    SendIO(Read_Request);

    /* see if we had a startup script */
    if (ptr != NULL) script_start(ptr);

    while( KeepGoing )
	    {
	    /* wait for window message or serial port message */
	    cursoron();
	    if (script_wait)	/* if script ready dont wait here */
		Wait(
		 (1L << mySerPort->mp_SigBit) |
		 (1L << mywindow->UserPort->mp_SigBit) |
		 (1L << Script_Timer_Port->mp_SigBit));
	    cursoroff();
	    
	    /* do ascii file send */
	    if (send)
		{
		if ((c=getc(trans)) != EOF) {
		    if (c == '\n') c = '\r';
		    sendchar(c);
		    }
		else {
		    fclose(trans);
		    emits("\nFile Sent\n");
		    send=FALSE;
		    }
		}

	    /* see if there are any characters from the host */
	    if (CheckIO(Read_Request)) {
		WaitIO(Read_Request);
		c = rs_in[0] & 0x7F;
		doremote(c);
		if (script_on) chk_script(c);
	        if (capture && c != 10) {
	      	    if (c == 13) c = 10;
		    putc(c , tranr);
		    }
		Read_Request->IOSer.io_Command = SDCMD_QUERY;
		DoIO(Read_Request);
		Read_Request->IOSer.io_Command = CMD_READ;
		actual = (int)Read_Request->IOSer.io_Actual;
		if (actual > 0) {
		    if (inesc   <  0 &&
			inctrl  <  0 &&
			a[alt]  == 0 &&
			capture == FALSE) dola = 1;
		    else dola = 0;
		    Read_Request->IOSer.io_Length =
			Read_Request->IOSer.io_Actual;
		    DoIO(Read_Request);
		    Read_Request->IOSer.io_Length = 1;

		    for (i = 0; i < actual; i++) {
			c=rs_in[i] & 0x7f;
			if (script_on) chk_script(c);

			if (dola == 1) {
			    if (c >= ' ' && c <= '~' && la < 80)
				lookahead[la++] = c;
			    else {
				if (la > 0) {
				    emitbatch(la,lookahead);
				    la = 0;
				    }
				doremote(c);
				dola = 0;
				}
			    }
			else {
			    doremote(c);
			    if (inesc   <  0 &&
				inctrl  <  0 &&
				a[alt]  == 0 &&
				capture == FALSE) dola = 1;
			    if (capture && c != 10) {
				if (c == 13) c = 10;
				putc(c , tranr);
				}
			    }
			}

		    /* dump anything left in the lookahead buffer */
		    if (la > 0) {
			emitbatch(la,lookahead);
			la = 0;
			}
		    }
		SendIO(Read_Request);
		}

	    while((NewMessage = 
		    (struct IntuiMessage *)GetMsg(mywindow->UserPort))
			!= FALSE) {
		class = NewMessage->Class;
		code = NewMessage->Code;
		ReplyMsg( NewMessage );
		switch( class )
		    {
		    case CLOSEWINDOW:
		    KeepGoing = FALSE;
		    break;

		    case RAWKEY:
		    c = toasc(code,0);
		    break;

		    case NEWSIZE:
		    emit(12);
		    break;

		    case MENUPICK:
		    handle_menupick(class,code);
		    break;				    
		    }   /* end of switch (class) */
		}   /* end of while ( newmessage )*/

            if (!script_wait || 
                 (CheckIO(&Script_Timer) && script_wait == WAIT_TIMER))
		do_script_cmd(NEXTCOMMAND);
	    }  /* end while ( keepgoing ) */
		
    /*   It must be time to quit, so we have to clean
    *   up and exit.
    */

    cleanup("",0);

    } /* end of main */

/* cleanup code */

cleanup(reason, fault)
char *reason;
int fault;
    {
    switch(fault) {
	case 0:		/* quitting close everything */
	ClearMenuStrip( mywindow ); 
	CloseDevice(&Audio_Request);

	case 8:		/* error opening audio */
	DeletePort(Audio_Port);
	FreeMem(BeepWave,BEEPSIZE);
	CloseDevice(&Timer);

	case 7:		/* error opening timer */
	DeletePort(Timer_Port);  
	CloseDevice(&Script_Timer);
	DeletePort(Script_Timer_Port);

	case 6:		/* error opening write device */
	DeletePort(Write_Request->IOSer.io_Message.mn_ReplyPort);
	FreeMem(Write_Request,(long)sizeof(*Write_Request));
	CloseDevice(Read_Request);

	case 5:		/* error opening read device */
	DeletePort(Read_Request->IOSer.io_Message.mn_ReplyPort);
	FreeMem(Read_Request,(long)sizeof(*Read_Request));
	CloseWindow( mywindow );

	case 4:		/* error opening window */
	if (p_screen != 0) CloseScreen( myscreen );

	case 3:		/* error opening screen */
	case 2:		/* error opening graphics library */
	case 1:		/* error opening intuition */
	default:
	if (*reason) puts (reason);
	}
    exit(fault);
    } 

do_capture(file)
char *file;
    {
    if (capture == TRUE)
        {
        capture=FALSE;
        fclose(tranr);
        emits("\nEnd File Capture\n");
        }
    else
        {
        if (file == NULL) {
            emits("\nAscii Capture:");
            filename(name);
	    } 
	else strcpy(name, file);
        if ((tranr=fopen(name,"w")) == 0) {
	    capture=FALSE;
	    emits("\nError Opening File\n");
	    return(FALSE);
	    }
	capture=TRUE;
        }
    }

do_send(file)
char *file;
    {
    if (send == TRUE)
	{ 
        send=FALSE;
        fclose(trans);
        emits("\nFile Send Cancelled\n");
        }
    else
        {
        if (file == NULL) {
            emits("\nAscii Send:");
            filename(name);
            }
	else strcpy(name, file);
        if ((trans=fopen(name,"r")) == 0) {
   	    send=FALSE;
	    emits("\nError Opening File\n");
	    return(FALSE);
	    }
	send=TRUE;
	}
    }

void setparams()
    {
    Read_Request->IOSer.io_Command = 
	Write_Request->IOSer.io_Command = 
	    SDCMD_SETPARAMS;
    DoIO(Read_Request); DoIO(Write_Request);
    Read_Request->IOSer.io_Command = CMD_READ;
    SendIO(Read_Request);
    Write_Request->IOSer.io_Command = CMD_WRITE;
    }

void hangup ()
    {
    AbortIO(Read_Request);
    CloseDevice (Read_Request);
    Timer.tr_time.tv_secs=0L;
    Timer.tr_time.tv_micro=750000L;
    DoIO((char *) &Timer.tr_node);
    OpenDevice (SERIALNAME,NULL,Read_Request,NULL);
    setparams();
    }

void setserbaud(baud, redomenu)
int baud;
LONG redomenu;
    {
    AbortIO(Read_Request);
    Write_Request->io_Baud = Read_Request->io_Baud = baud;
    setparams();
    p_baud = baud;
    if (redomenu) {
	ClearMenuStrip( mywindow );         /* Remove old menu */
	InitCommItems();                    /* Re-do comm menu   */
	SetMenuStrip(mywindow,&menu[0]);    /* Re-display the menu */	
	}
    }

void handle_menupick(class, code)
ULONG class;
unsigned int code;
    {
    unsigned int menunum, itemnum, subnum;

    if (code == MENUNULL) return;

    menunum = MENUNUM( code );
    itemnum = ITEMNUM( code );
    subnum  = SUBNUM( code );
    switch( menunum ) {
	case 0:
	switch( itemnum ) {
	    case 0:
	    do_capture(NULL);
	    break;

	    case 1:
	    do_send(NULL);
	    break;

	    case 2:
	    if (p_parity > 0) {
		emits("\nParity setting prevents this\n");
		break;
		}
	    emits("\nXmodem Receive:");
	    filename(name);
	    multi_xfer(name,XMODEM_Read_File,0);
	    break;

	    case 3:
	    if (p_parity > 0) {
		emits("\nParity setting prevents this\n");
		break;
		}
	    emits("\nXmodem Send:");
	    filename(name);
	    multi_xfer(name,XMODEM_Send_File,1);
	    break;

	    case 4:
	    server = TRUE;
	    emits("\nKermit GET remote file(s):");
	    filename(name);
	    multi_xfer(name,dokreceive,0);
            break;

	    case 5:
	    multi_xfer("",dokreceive,0);
	    break;

	    case 6:
	    server = TRUE;
	    emits("\nKermit Send local name:");
	    filename(name);
	    multi_xfer(name,doksend,1);
	    break;

	    case 7:
	    saybye();
	    break;
	    }
	break;

	case 1:
	switch( itemnum ) {
	    case 0:
	    switch( subnum ) {
		case 0:
		setserbaud(300, FALSE);
		break;

		case 1:
		setserbaud(1200, FALSE);
		break;

		case 2:
		setserbaud(2400, FALSE);
		break;

		case 3:
		setserbaud(4800, FALSE);
		break;

		case 4:
		setserbaud(9600, FALSE);
		break;
		}
	    break;	    

	    case 1:
	    /* Set  Parity */
	    p_parity = subnum;
	    break;

	    case 2:
	    /* set transfer mode */
	    p_mode = subnum;
	    break;
	    }
	break;

	case 2:
	if (!itemnum && !script_on) {
	    emits("Script file name: ");
	    filename(name);
	    script_start(name);
	    }
	if (itemnum && script_on) exit_script();
	break;

	case 3:
	switch( itemnum ) {
	    case 0:
	    sendbreak();
	    break;

	    case 1:
	    hangup();
	    break;

	    case 2:
	    emits("\nDirectory [");
	    emits(MyDir);
	    emits("]: ");
	    filename(name);
	    set_dir(name);
	    break;
	    }

	break;
	} /* end of switch ( menunum ) */
    }

SHAR_EOF
cat << \SHAR_EOF > vt100.h
/*********************************************************************
 *  a terminal program that has ascii and xmodem transfer capability
 *
 *	v2.2 861012 DBW - more of the same
 *	v2.1 860915 DBW - new features (see README)
 *	     860823 DBW - Integrated and rewrote lots of code
 *	v2.0 860809 DBW	- Major release.. LOTS of changes
 *	v1.1 860720 DBW	- Switches, 80 cols, colors, bug fixes
 *	v1.0 860712 DBW	- First version released
 *
 *  use esc to abort xmodem transfer
 *
 *  written by Michael Mounier
 *  new version by Dave Wecker 860621
 ************************************************************************/

/* ########  define the compiler type here ######## */
#define	LATTICE	0
#define MANX	1

/*  compiler diretives to fetch the necessary header files */
#include <exec/types.h>
#include <exec/exec.h>
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include <graphics/gfxbase.h>
#include <graphics/gfx.h>
#include <graphics/text.h>
#include <graphics/regions.h>
#include <graphics/copper.h>
#include <graphics/gels.h>
#include <devices/serial.h>
#include <devices/keymap.h>
#include <devices/audio.h>
#include <hardware/blit.h>
#include <stdio.h>
#include <ctype.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <devices/timer.h>

#if MANX
#include <functions.h>
#undef NULL
#define   NULL   ((void *)0)
#endif

#define INTUITION_REV 1L
#define GRAPHICS_REV  1L

/* things for xmodem send and recieve */
#define GOODREAD    0
#define TIMEOUT	    1
#define USERABORT   2
#define SECSIZ   0x80
#define TTIME_SHORT 5        /* number of seconds for short timeout */
#define TTIME_LONG  50	     /* number of seconds for long  timeout */
#define TTIME_KERMIT 10	     /* number of seconds for KERMIT timeout */
#define BufSize  0x200       /* Text buffer for XMODEM */
#define ERRORMAX 10          /* Max errors before abort */
#define RETRYMAX 10          /* Maximum retrys before abort */
#define SOH      1           /* Start of sector char */
#define EOT      4           /* end of transmission char */
#define ACK      6           /* acknowledge sector transmission */
#define NAK      21          /* error in transmission detected */

#define FILEMAX 8    /* number of file menu items */
#define COMMAX 3     /* number of communication sub menus */
#define RSMAX 5      /* speed menu items */
#define PARMAX 5     /* parity items */
#define XFMAX 2      /* transfer mode items */
#define SCRIPTMAX 2  /* script menu items */
#define UTILMAX 3    /* utility menu */
#define MAXMENU 4    /* total number of menu entries */

#define FSF_REVERSE 256	/* fake font style to flag INVERSVID mode */

/* things for script support */

#define GOTOLABEL   1
#define	NEXTCOMMAND 0
#define ONCOMMAND   2

#define	WAIT_TIMER  2
#define WAIT_STRING 1

/* things for 'beep' support */
#define BEEPSIZE    10L
#define BEEPFREQ    1000L
#define COLORCLOCK  3579545L

extern struct MsgPort *CreatePort();
extern char *malloc(),*strcpy(),*fgets();
extern long ftell();

#ifdef MODULE_MAIN
char    bufr[BufSize];
int     fd, timeout = FALSE, ttime;
int	multi = FALSE, server;
long    bytes_xferred;
char	MyDir[60];
struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;

struct NewScreen NewScreen = {
   0L,197L,640L,205L,1L,       /* left, top, width, height, depth */
   0,1,HIRES,    /* DetailPen, BlockPen, ViewModes */
   CUSTOMSCREEN,NULL,   /* Type, Font */
   (UBYTE *)"VT100", /* Title */
   NULL,NULL };         /* Gadgets, Bitmap */

struct NewWindow NewWindow = {
   0,3L,640L,200L,     /* left, top, width, height */
   0,1,              /* detailpen, blockpen */
   MENUPICK | CLOSEWINDOW | RAWKEY | NEWSIZE,
   SMART_REFRESH | ACTIVATE | BORDERLESS |
   WINDOWCLOSE | WINDOWDEPTH | WINDOWDRAG, /* Flags */
   NULL,NULL,        /* FirstGadget, CheckMark */
   (UBYTE *)
   "VT100 (v2.2 861012 DBW) Terminal Window                                ",
   NULL,             /* set screen after open screen */
   NULL,             /* bitmap */
   640L, 200L, 640L, 200L,/* minw, minh, maxw, maxh */
   CUSTOMSCREEN      /* Type */
};

struct Screen *myscreen;            /* ptr to applications screen */
struct Window *mywindow;            /* ptr to applications window */
struct ViewPort *myviewport;
struct IntuiMessage *NewMessage;    /* msg structure for GetMsg() */
struct Preferences  *Prefs;	    /* preferences from GetPrefs() */

struct MenuItem FileItem[FILEMAX];
struct IntuiText FileText[FILEMAX];
struct MenuItem CommItem[COMMAX];
struct IntuiText CommText[COMMAX];
struct MenuItem RSItem[RSMAX];
struct IntuiText RSText[RSMAX];
struct MenuItem ParItem[PARMAX];
struct IntuiText ParText[PARMAX];
struct MenuItem XFItem[XFMAX];
struct IntuiText XFText[XFMAX];
struct MenuItem ScriptItem[SCRIPTMAX];
struct IntuiText ScriptText[SCRIPTMAX];
struct MenuItem UtilItem[UTILMAX];
struct IntuiText UtilText[UTILMAX];
struct Menu menu[MAXMENU];
struct IOExtSer *Read_Request;
char *rs_in;
struct IOExtSer *Write_Request;
char rs_out[2];
struct timerequest Timer;
struct MsgPort *Timer_Port = NULL;
struct timerequest Script_Timer;
struct MsgPort *Script_Timer_Port = NULL;
struct IOAudio Audio_Request;
struct MsgPort *Audio_Port = NULL;
UBYTE  *BeepWave;
UBYTE  Audio_AllocMap[4] = { 1, 8, 2, 4 };
int want_message;
int x,y,curmode,keyapp;
int MINX	= 0;
int MAXX	= 632;
int MINY	= 14;
int MAXY	= 198;
int top		= 14;
int bot		= 198;
int savx	= 0;
int savy	= 14;
int savmode	= 0;
int nlmode	= 0;
int alt		= 0;
int savalt	= 0;
int a[2]	= { 0, 0 };
int sa[2]	= { 0, 0 };
int  inesc	= -1;
int  inctrl	= -1;
int  private	= 0;
int  badseq	= 0;
char *blanks	= "                                                      ";
int  maxcol	= 79;

/*************************** defaults ***********************************/
int	p_baud	     = 2400;	    /* baud rate */
int	p_screen     = 1;	    /* 0 = WORKBENCH,	    1 = CUSTOM */
int	p_interlace  = 1;	    /* 0 = no interlace,    1 = interlace */
int	p_depth	     = 1;	    /* number of bit planes (1 or 2) */
int	p_foreground = 0x950;	    /* default foreground RGB color */
int	p_background = 0x000;	    /* default background RGB color */
int	p_bold	     = 0xa00;	    /* default BOLD       RGB color */
int	p_cursor     = 0x00a;	    /* default Cursor	  RGB color */
int	p_lines	     = 48;	    /* number of lines on the screen */
int	p_mode	     = 1;	    /* 0 = image, 1 = CRLF (for kermit) */
int	p_buffer     = 512;	    /* read buffer size (>= 512 bytes) */
int     p_parity     = 0;	    /* 0=none,1=mark,2=space,3=even,4=odd */
long	p_break	     = 750000;	    /* break time (in micro seconds) */
int	p_volume     = 64;	    /* beep volume (0 = DisplayBeep) */
int	p_wrap	     = 0;	    /* 0 = truncate, 1 = wrap long lines */
char	p_keyscript  = 0x7E;	    /* function key script introducer = ~ */
char	*p_f[10]     = {	    /* function key defaults */
    "\033OP","\033OQ","\033OR","\033OS",
    "f5","f6","f7","f8","f9","f10" };

char	*p_F[10]     = {	    /* shifted function key defaults */
    "F1","F2","F3","F4","F5",
    "F6","F7","F8","F9","F10"};

/* for script file */
int script_on;
int script_wait;
void setserbaud(), setparams(), handle_menupick();

#else /* not MODULE_MAIN */

extern int     multi;		    /* flags multi file transfers */
extern int     server;
extern int     want_message;
extern char    bufr[BufSize];
extern int     fd, timeout, ttime;
extern long    bytes_xferred;
extern char    MyDir[60];

extern struct IntuitionBase *IntuitionBase;
extern struct GfxBase *GfxBase;

extern struct NewScreen NewScreen;
extern struct NewWindow NewWindow;
extern struct Screen *myscreen;
extern struct Window *mywindow;
extern struct ViewPort *myviewport;
extern struct IntuiMessage *NewMessage;
extern struct Preferences  *Prefs;
extern struct MenuItem FileItem[FILEMAX];
extern struct IntuiText FileText[FILEMAX];
extern struct MenuItem CommItem[COMMAX];
extern struct IntuiText CommText[COMMAX];
extern struct MenuItem RSItem[RSMAX];
extern struct IntuiText RSText[RSMAX];
extern struct MenuItem ParItem[PARMAX];
extern struct IntuiText ParText[PARMAX];
extern struct MenuItem XFItem[XFMAX];
extern struct IntuiText XFText[XFMAX];
extern struct MenuItem ScriptItem[SCRIPTMAX];
extern struct IntuiText ScriptText[SCRIPTMAX];
extern struct MenuItem UtilItem[UTILMAX];
extern struct IntuiText UtilText[UTILMAX];
extern struct Menu menu[MAXMENU];
extern struct timerequest Timer, Script_Timer;
extern struct MsgPort *Timer_Port, *Script_Timer_Port;
extern struct IOExtSer *Read_Request;
extern char *rs_in;
extern struct IOExtSer *Write_Request;
extern char rs_out[2];
extern int x,y,curmode,keyapp;
extern int MINX,MAXX,MINY,MAXY,top,bot,savx,savy;
extern int savmode,nlmode,alt,savalt,a[2],sa[2];
extern int inesc,inctrl,private,badseq,maxcol;
extern char *blanks;
extern struct IOAudio Audio_Request;
extern struct MsgPort *Audio_Port;
extern UBYTE  *BeepWave;
extern UBYTE  Audio_AllocMap[];

extern int p_baud,p_screen,p_interlace,p_depth,p_buffer;
extern int p_foreground,p_background,p_bold,p_cursor,p_lines,p_mode;
extern int p_parity,p_volume,p_wrap,p_keyscript;
extern long p_break;
extern char *p_f[10],*p_F[10];
extern int script_on;
extern int script_wait;

extern int do_send(),do_capture(),cleanup();
extern void setserpar(), setserbaud(), setparams(),
	handle_menupick();

#endif /* not MODULE_MAIN */

#ifndef MODULE_INIT
extern void InitDevs(),InitFileItems(),InitCommItems(),
	 InitScriptItems(),InitUtilItems(),InitMenu();
extern char *InitDefaults();
#endif

#ifndef MODULE_WINDOW
extern	void filename(),emits(),emit(),emitbatch(),cursoroff(),cursoron();
extern	int  toasc();
#endif

#ifndef MODULE_XMODEM
extern	void sendchar(),sendstring(),sendbreak();
extern	int  readchar(),XMODEM_Read_File(),XMODEM_Send_File();
#endif

#ifndef MODULE_REMOTE
extern	void doremote(),doindex();
#endif

#ifndef MODULE_KERMIT
extern	int  doksend(),dokreceive(), multi_xfer(), saybye();
#endif

#ifndef MODULE_SCRIPT
extern int script_start(), chk_script(), exit_script(), do_script_cmd();
#endif

#ifndef MODULE_EXPAND
extern char **expand();
extern int  set_dir(), free_expand();
#endif

SHAR_EOF
#	End of shell archive
exit 0
Technical Details
Message-ID: <2292@j.cc.purdue.edu>
Path: arc1-ca.pugleaf.net!utzoo!decvax!ucbvax!ucbcad!nike!lll-crg!lll-lcc!qantel!ihnp4!inuxc!pur-ee!j.cc.purdue.edu!doc

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!decvax!ucbvax!ucbcad!nike!lll-crg!lll-lcc!qantel!ihnp4!inuxc!pur-ee!j.cc.purdue.edu!doc
From: doc@j.cc.purdue.edu
Newsgroups: mod.amiga.sources
Subject: VT100 (V2.2 861012 DBW) Part 2 of 3
Message-ID: <2292@j.cc.purdue.edu>
Date: Tue, 14-Oct-86 14:02:52 EDT
Article-I.D.: j.2292
Posted: Tue Oct 14 14:02:52 1986
Date-Received: Thu, 16-Oct-86 08:29:39 EDT
Sender: doc@j.cc.purdue.edu
Organization: Purdue University Computing Center
Lines: 1992
Approved: doc@j.cc.purdue.edu