/*
 * K E R M I T
 */

#include        stdio
#include        fab
#include        nam
#include        descrip
#define debug           0       /* enable/disable debugging */

#define MAXPACK         94      /* Maximum packet size */
#define SOH             1       /* Start of header */
#define SP              32      /* ASCII space */
#define DEL             127     /* Delete (rubout) */

#define MAXTRY          5       /* Times to retry a packet */

#define MYQUOTE         '#'     /* Quote character I will use */
#define MYPAD           0       /* Number of padding characters I will need */
#define MYPCHAR         0       /* Padding character I need */
#define MYEOL           '\r'    /* End-Of-Line character I need */
#define MYTIME          10      /* Seconds after which I should be timed out */

#define TRUE            -1
#define FALSE           0
#define EOF             -1

/*
 * Declarations of global variables
 */

int     size,                   /* Size of present data */
        n,                      /* Message number */
        rpsiz,                  /* Maximum receive packet size */
        spsiz,                  /* Maximum send packet size */
        pad,                    /* How much padding to send */
        timint,                 /* Timeout for foreign host on sends */
        numtry,                 /* Times this packet retried */
        oldtry,                 /* Times previous packet retried */
        fd,                     /* file pointer of file to read/write */
        remfd;                  /* file pointer of the host's tty */

char    state,                  /* Present state of the automaton */
        padchar = '\0',         /* Padding character to send */
        eol = '\n',             /* End-Of-Line character to send */
        quote = '#',            /* Quote character in incoming data */
        filnam[80],             /* The file name */
        filestr[80],            /* Resultant file name in null terminated */
				/* string */
        recpkt[MAXPACK],        /* Receive packet buffer */
        packet[MAXPACK],        /* Packet buffer */
/* declare the neccesary variables to handle wildcarding */
        namestr[10],            /* first portion of filename */
        extstr[5];              /* file type portion of filename */
struct  FAB *fabp;              /* pointer to a FAB block */
struct  NAM *namp;              /* pointer to a NAM block */
struct  dsc$descriptor_s file_name;
struct  dsc$descriptor_s result_name;
