/************************************************************************
 *
 *       HD6KER.H	Global definitions and function
 *			 prototypes for both HD6KER.C and HD6PRI.C.
 *
 ***********************************************************************/  
 
#define NULL 0
 
/* ---  library includes files  --- */
 
#include <sgtty.h>
#include <stdio.h>          /* Standard UNIX definitions   */
#include <ctype.h>          /* isascii definitions         */
#include <signal.h>         /* signal catcher definitions  */
 
/* ---  MOD400 wild card and file management stuff  --- */
 
#include <star_name.h>		/* wild card filename routines */
#define MOD4_NAME   12		/* maximum size of Honeywell file name */
#define SVQ	    1		/* sequential file; multi-volume set; ASCII */ 
#define SEQ	    2		/* reqular sequential file; ASCII */
#define S_R	    18		/* string_relative file; ASCII */
#define F_R	    13		/* fixed_relative file; BINARY */
#define ASCII       0           /* MOD400 SEQ, S_R, and SVQ file types */
#define BINARY      2           /* MOD400 F_R file type */
#define FOREIGN     1           /* MOD400 SEQ (DATA_CODE=BINARY) file type */ 
 
/* ---  symbol definitions  --- */
 
#define MAXPACKSIZ  2000    /* Maximum packet size */
#define MAXTIM      60      /* Maximum timeout interval */
#define MAXTRY      10      /* Times to retry a packet */
#define MINTIM      2       /* Minumum timeout interval */
 
#define MYEOL       13    /* End-Of-Line character I need */
#define MYPAD       0       /* Number of padding characters I will need */
#define MYPCHAR     0       /* Padding character I need (NULL) */
#define MYQUOTE     '#'     /* Quote character I will use */
#define MYTIME      10      /* Seconds after which I should be timed out */
 
#define TRUE        -1
#define FALSE       0
 
#define LF          10
#define CR          13      /* ASCII Carriage Return */
#define SUB         26      /* ASCII Sub character */
#define DEL         127     /* Delete (rubout) */
#define ESC         0x1b    /* real escape char        */
#define SOH         1       /* Start of header 'ack' */
#define SP          32      /* ASCII space */
#define _ioeof 0x20
#define TANDEM 0
 
 
/* ---  Macro Definitions  --- */
 
/*
 * tochar: converts a control character to a printable one by adding a space.
 * unchar: undoes tochar.
 * ctl:    converts between control characters and printable characters by
 *         toggling the control bit (ie. ^A becomes A and A becomes ^A).
 */
#define tochar(ch)  ((ch) + ' ')
#define unchar(ch)  ((ch) - ' ')
#define ctl(ch)     ((ch) ^ 64 )
 
#define forever     while(1)
 
/************************************************************************
 *
 *                     Definitions for HD6KER.C 
 *
 ***********************************************************************/  
 
#ifdef MAINDEF
 
/* ---  procedures passed as arguments etc.  --- */
 
char cread();
                       /* recv procs */
extern  char rinit(), rfile(), rdata();                   
                       /* send procs */
extern  char sinit(), sfile(), sattru(), sdata(), seof(), sbreak(); 
int     m4_errno, decfil(), syserr();
 
/* ---  procedures in other source files --- */
 
char   ascout(), ascedit(), filerr(), nextin();
int    flushinput(), cooktty(), rawtty();
int    get_time(), wildname(), timoset(), unbuffer();
 
/* ---  forward declarations  --- */
 
extern unsigned chk2();
extern unsigned fsize();
 
/* ---  global variables  --- */
 
int
          aflg, rflg, sflg,   /* flags for AUTO, RECEIVE, SEND */
          debug,              /* indicates level of debug output (0=none) */
          filnamcnv,          /* -1 means do file name case conversions */
          filecount,          /* Number of files left to send */
          image, oimage,      /* 0 = 7-bit, 1 = 8-bit mode, 2 = prefixing */
          fileimage, ofi,     /* 0 = open text file; 2 = open binary file */
          n,                  /* Packet number */
          oldt,               /* previous char in encode() */
          numtry,             /* Times this packet retried */
          oldtry,             /* Times previous packet retried */
          pad,                /* How much padding to send */
          qu8,
          rpt,
          rptflg,
          sz,
          size,               /* Size of present data */
          spsiz,              /* Maximum send packet size */
          sattrib,            /* Attribute packet indicator FRANK DREANO */
          senda,              /* Another attribute flag */
          slongp,             /* Extended packet indicators FRANK DREANO  */
          bctr = 3,           /* CRC type block-check requested */
          bctu = 1,           /* block-check used */
          sysint,
          addsub,
          timint = 10,        /* Timeout for foreign host on sends */
          lrsz_6 = 512,       /* Fixed-relative, BU, record size */
          cmdstat,            /* Return status for system commands */
          dlflag;             /* Flag to overwrite incoming files */
 
char
          c,                  /* dummy char               */
          *dname,             /* name of debug file DH+S   */
          *dt,                /* data-block code/decode   */
          eol = '\015',       /* End-Of-Line character to send */
          **filelist,         /* List of files to be sent */
          *filenames[99],
          *filnam,            /* Current file name */
          getfiles[MAXPACKSIZ],
          iflg = 0,           /* 8th-bit-mode set */
          packet[MAXPACKSIZ], /* Packet buffer */
          padchar,            /* Padding character to send */
          quote = '#',        /* Quote character in incoming data */
          recpkt[MAXPACKSIZ], /* Receive packet buffer */
          state,              /* Present state of the automaton */
          timflag,            /* timeout flag DH+S         */
          type,               /* received-packet type     */
          fo_name[56],        /* pathname for server commands */
          cmdstg[80],         /* String to hold system commands */
          cmdstring[80],      /* String to hold system commands */
          attrib[80];         /* String to hold file attributes */
          
char  amauto[]   = "%sI am in server mode!";
char  badpack[]  = "%sYour Kermit sent invalid packet, type \"%c\"!";
char  crlf[]     = "\r\n";
char  *eighths[] = {"7-bit character","binary-image-mode","8th-bit prefixed"};
char  goodbye[]  = "Returning to MOD400; goodbye.";
char  logout[] = "Logging off the host; goodbye.";
char  *logicval[]= {"OFF", "ON"};
char  noname[]   = "%sNo valid names in GET request";
char  xnull[]    = "";                        /* xnull string              */
char  onlyg[]    = "%sUnimplemented server command!";
char  prompt[]   = "Superkerm: ";
 
/*  The following MOD400 command causes the Superkermit server to log off
    the DPS-6 when done.  It causes a 'C' siqquit trap that isn't very pretty
    and could be avoided if a deferred 'BYE' task could be spawned. However
    the -DFR argument to the spawn task command (ST) is illegal in swappools, 
    so to keep it working in all environments the trap will be tolerated.  */
 
char  byenow[]   = ">SYSLIB2>BYE -BF";
char  buname[]   = ">SYSLIB2>EC";
char  hostok[]   = "Kermit server command EXECUTED!";
char  hostng[]   = "ERROR: Kermit server command NOT EXECUTED!";
 
FILE    *fp,                /* current disk file */
          *dfp;               /* debug file DH+S           */
 
struct  sgttyb  cookedmode, rawmode;          
 
/* ---  Identification string  --- */
 
char ident[] =
    "\033\140\nSuperKermit   09 Apr 91   (Ver 2.01)   Frank Dreano.\n";
 
/* ---  Old (and I mean OLD) setups for cooked and raw TTY...Dreano  --- */
/* 
char tset[] =
 ">>SYSLIB2>STTY -DEV VIP7801 -DSW1 8800 -DSW2 0800 -TERM 04 -IN A -OUT N";
char tclr[] =
 ">>SYSLIB2>STTY -DEV VIP7301 -RESET";
*/
 
/* ---  These cooked and raw TTY settings are for 3.1/4.0 op. system  --- */
 
char tset[] =
 ">SYSLIB2>STTY -DEV VIP7801 -LL 4096 -MODES ^CR,^EC,LF -IN A -OUT N";
char tclr[] =
 ">SYSLIB2>STTY -DEV VIP7808 -RESET";
 
#else
 
/************************************************************************
 *
 *                     Definitions for HD6PRI.C 
 *
 ***********************************************************************/  
 
/* ---  procedures passed as arguments etc.  --- */
 
extern  char cread();
                       /* recv procs */
char rinit(), rfile(), rdata();                   
                       /* send procs */
char sinit(), sfile(), sattru(), sdata(), seof(), sbreak(); 
extern  int   m4_errno, decfil();
 
/* ---  procedures in other source files --- */
 
extern char   ascout(), ascedit(), filerr(), nextin();
extern int    flushinput(), cooktty(), rawtty();
extern int    get_time(), wildname(), timoset(), unbuffer();
 
/* ---  forward declarations  --- */
 
unsigned chk2();
unsigned fsize();
 
/* ---  global variables  --- */
 
extern int
          aflg, rflg, sflg,   /* flags for AUTO, RECEIVE, SEND */
          debug,              /* level of debugging output (0=none) */
          filnamcnv,          /* -1 means do file name case conversions */
          filecount,          /* Number of files left to send */
          image, oimage,      /* 0 = 7-bit, 1 = 8-bit mode, 2 = prefixing */
          fileimage, ofi,     /* 0 = open text file; 1 = open binary file */
          n,                  /* Packet number */
          oldt,               /* previous char in encode()        */
          numtry,             /* Times this packet retried */
          oldtry,             /* Times previous packet retried */
          pad,                /* How much padding to send */
          qu8,
          rpt,
          rptflg,
          sz,
          size,              /* Size of present data */
          spsiz,             /* Maximum send packet size */
          sattrib,           /* Attribute packet indicator FRANK DREANO */
          senda,             /* Another attribute flag */
          slongp,            /* Extended packet indicators FRANK DREANO  */
          bctr,              /* block-check requested */
          bctu,              /* block-check used */
          sysint,
          addsub,
          timint,             /* Timeout for foreign host on sends */
          lrsz_6,             /* Fixed-relative, BU, record size */
          cmdstat,            /* Return status for system commands */
	      dlflag;             /* Flag to overwrite incoming files */
 
extern char
          c,                  /* dummy char               */
          *dname,             /* name of debug file DH+S   */
          *dt,                /* data-block code/decode   */
          eol,                /* End-Of-Line character to send */
          **filelist,         /* List of files to be sent */
          *filenames[],
          *filnam,            /* Current file name */
          getfiles[],
          iflg,               /* 8th-bit-mode set */
          packet[],           /* Packet buffer */
          padchar,            /* Padding character to send */
          quote,              /* Quote character in incoming data */
          recpkt[],           /* Receive packet buffer */
          state,              /* Present state of the automaton */
          timflag,            /* timeout flag DH+S         */
          type,               /* received-packet type     */
          fo_name[],          /* pathname for server commands */
          cmdstg[],           /* String to hold system commands */
          cmdstring[],      /* String to hold system commands */
          attrib[];           /* String to hold file attributes */
 
extern char  amauto[],
             badpack[],
             crlf[],
             *eighths[],
             goodbye[],
             logout[],
             *logicval[],
             noname[],
             xnull[],
             onlyg[],
             prompt[],
             byenow[],	
             buname[] ;
 
extern FILE    *fp,                /* current disk file */
               *dfp;               /* debug file DH+S           */
 
#endif
 
/********************   End of File  hd6ker.h *****************************/
