home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / pub / uniflex / ufkerm.uue / ufkerm.arc / UFK.H < prev    next >
C/C++ Source or Header  |  1989-01-09  |  13KB  |  261 lines

  1. /*
  2.  * KERMIT09 - UniFLEX version header file
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <ctype.h>
  7.  
  8. #define VERSION      "V 1.4"
  9.  
  10. /* Also modify VERSION in ufkerm.c !! */
  11.  
  12. #define IDENT        "UniFLEX KERMIT 6809 version "
  13. #define DEFPROMPT    "UF-Kermit>"
  14. #define INITFILE     "kermit.ini"
  15. #define HELPDIR      "/gen/kermit"
  16. #define PRIVTASK     "/bin/kermit_support"
  17.  
  18. /* Symbol Definitions */
  19.  
  20. #define SOH          1                    /* Start of header */
  21. #define BELL         7                    /* ASCII Bell */
  22. #define BS           8                    /* ASCII Backspace */
  23. #define TAB          9                    /* ASCII Tab */
  24. #define LF           10                   /* ASCII Linefeed */
  25. #define CR           13                   /* ASCII Carriage Return */
  26. #define ESC          27                   /* ASCII Escape */
  27. #define SP           32                   /* ASCII space */
  28. #define DEL          127                  /* Delete (rubout) */
  29. #define XON          17                   /* Start output */
  30. #define XOFF         19                   /* Stop output */
  31. #define ESCCHR       '^'                  /* Default escape char for CONNECT */
  32. #define PANIC        '\\' - 64            /* Panic abort exit */
  33. #define TOGDBG       'D' - 64             /* Toggle debug on/off */
  34. #define ABORTX       'X' - 64             /* Ctrl-X to abort transfer */
  35. #define ABORTZ       'Z' - 64             /* Ctrl-Z to abort transfer */
  36. #define COMMENT      '!'                  /* Command line comment character */
  37.  
  38. #define TRUE         1
  39. #define FALSE        0
  40. #define ERROR        (-1)
  41. #define TYPERROR     (-2)
  42. #define IN           0
  43. #define OUT          1
  44. #define SEND         0
  45. #define RECEIVE      1
  46. #define READ         0
  47. #define WRITE        1
  48. #define BIG_SIZE     2048 + 8             /* Maximum = (95*94+94+8) */
  49. #define SMALL_SIZE   (94+5)
  50.  
  51. #define TABSIZE      8                    /* Tabstop every eight places */
  52.  
  53. #define I_MYPACKSTART      SOH            /* Start of packet character */
  54. #define I_MAXPACKSIZ       94             /* Maximum packet size */
  55. #define I_MYPACKSIZE       80             /* Default value if no 'S' packet */
  56. #define I_MAXTRY           10             /* Times to retry a packet */
  57. #define I_MYQUOTE          '#'            /* Quote character I will use */
  58. #define I_MYPAD            0              /* Number of padding char's I need */
  59. #define I_MYPCHAR          0              /* Padding character I need (NULL) */
  60. #define I_MYEOL            '\r'           /* End-Of-Line character I need */
  61. #define I_MYTIME           5              /* My timeout in seconds */
  62. #define I_MYRPTQUOTE       '~'            /* Repeat quote character */
  63. #define I_MYEIGHTQUOTE     '&'            /* Eight_bit quote character */
  64. #define I_BLOCKCHECKTYPE   1              /* Initial checksum type */
  65. #define I_SEND_DELAY       5              /* Delay time before sending */
  66. #define I_DEFLONGSIZE      500            /* Default size for long packets */
  67.  
  68. #define MAXPRM       100          /* Max. number of command line parameters */
  69.  
  70. #define TIMEOUT      1            /* Internal codes */
  71. #define REMOTE      -1
  72.  
  73. /*
  74.   UniFLEX kermit error definitions
  75. */
  76.  
  77. #define ER_POPNERR      0       /* Communication port open error */
  78. #define ER_NOPARAM      1       /* No parameter specified */
  79. #define ER_TOOMPRM      2       /* Too many command parameters */
  80. #define ER_NOMEM        3       /* No memory available */
  81. #define ER_NOLINE       4       /* No line to connect to */
  82. #define ER_LOGWRTER     5       /* Log file write error */
  83. #define ER_DIROPN       6       /* Directory open error */
  84. #define ER_NOHELP       7       /* No help available */
  85. #define ER_NOTOPIC      8       /* No such topic */
  86. #define ER_AMBIG        9       /* Ambiguous command */
  87. #define ER_UNKNOWN      10      /* Unknown command */
  88. #define ER_ONENAME      11      /* Only one name allowed */
  89. #define ER_FSPCREQ      12      /* Filespec required */
  90. #define ER_NOFILSEL     13      /* No files selected */
  91. #define ER_ILLREMOT     14      /* Not allowed if remote */
  92. #define ER_AMBIGSET     15      /* Ambiguous 'set' command */
  93. #define ER_UNKNWSET     16      /* Unknown 'set' command */
  94. #define ER_FILEOPEN     17      /* File already open */
  95. #define ER_OPENERR      18      /* File open error */
  96. #define ER_INVDEV       19      /* Invalid device or no permission */
  97. #define ER_NOREMBD      20      /* Can't set baudrate for remote line */
  98. #define ER_NOBAUD       21      /* Unable to set baudrate */
  99. #define ER_INVBAUD      22      /* Invalid baudrate specified */
  100. #define ER_ILLVALUE     23      /* Illegal value specified */
  101. #define ER_CHRINUSE     24      /* Character already in use */
  102. #define ER_INVLENG      25      /* Invalid length specified */
  103. #define ER_VALOUTRN     26      /* Value out of range */
  104. #define ER_EOLDIF       27      /* Eol must be different of start of packet */
  105. #define ER_STRTDIF      28      /* Start of packet must be different of eol */
  106. #define ER_INVCHK       29      /* Invalid block check type */
  107. #define ER_INVCHAR      30      /* Invalid character */
  108. #define ER_AMBIGSHW     31      /* Ambiguous 'show' command */
  109. #define ER_UNKNWSHW     32      /* Unknown 'show' command */
  110. #define ER_GETPWDID     33      /* Get password id error */
  111. #define ER_INVDIR       34      /* Invalid directory specified */
  112. #define ER_SYNERR       35      /* Syntax error */
  113. #define ER_PRIVSERVER   36      /* Privileged support task error */
  114. #define ER_PERMS        37      /* Error setting file permissions */
  115. #define ER_SPAWN        38      /* Can't spawn 'shell' */
  116.  
  117. /* Internal error packet error definitions */
  118.  
  119. #define PER_ABORTED     0       /* Aborted command */
  120. #define PER_UNIMPL      1       /* Unimplemented server function */
  121. #define PER_PACKET      2       /* Packet error */
  122. #define PER_DEVFULL     3       /* Device full */
  123. #define PER_WRITE       4       /* File write error */
  124. #define PER_CREATE      5       /* File create error */
  125. #define PER_OPEN        6       /* File open error */
  126.  
  127. #define ERR_PARAM       4       /* Errors > ERR_PARAM have parameters */
  128.  
  129. /* Macro Definitions */
  130.  
  131. /*
  132.  * tochar: converts a control character to a printable one by adding a space.
  133.  *
  134.  * unchar: undoes tochar.
  135.  *
  136.  * ctl:    converts between control characters and printable characters by
  137.  *         toggling the control bit (ie. ^A becomes A and A becomes ^A).
  138.  */
  139. #define tochar(ch)   ((ch) + ' ')
  140. #define unchar(ch)   ((ch) - ' ')
  141. #define ctl(ch)      ((ch) ^ 64 )
  142.  
  143. /*
  144.   pread: read from pipe
  145.   pwrite: write to pipe
  146. */
  147. #define pread(adr,cnt)  read(pd1[READ],(adr),(cnt))
  148. #define pwrite(adr,cnt) write(pd2[WRITE],(adr),(cnt))
  149.  
  150. /* Global Variables */
  151.  
  152. /* Structure used by command parser */
  153.  
  154. typedef struct table_point
  155. {
  156.    char *string;                          /* Command name */
  157.    int funcadr;                           /* Function address */
  158. } TABLE;
  159.  
  160. int   send_delay,             /* Start sending delay time */
  161.       ttyfd,                  /* I/O port address */
  162.       speed,                  /* line speed */
  163.       tabsleft,               /* Tab counter */
  164.       size,                   /* Size of present data */
  165.       spsiz,                  /* Maximum send packet size */
  166.       maxpacksiz,             /* Maximum packet size */
  167.       nak_sent,               /* nak's sent */
  168.       pack_sent,              /* packets sent */
  169.       nak_rec,                /* nak's received */
  170.       pack_rec,               /* packets received */
  171.       data_rate,              /* effective data rate */
  172.       t_nak_sent,             /* total naks sent */
  173.       t_pack_sent,            /* total packets sent */
  174.       t_nak_rec,              /* total nak's received */
  175.       t_pack_rec,             /* total packets received */
  176.       t_data_rate,            /* total effective data rate */
  177.       pd1[2],                 /* pipe decriptors for support task */
  178.       pd2[2];
  179.  
  180. long int chr_sent,            /* characters sent */
  181.          dchr_sent,           /* data characters sent */
  182.          chr_rec,             /* characters received */
  183.          dchr_rec,            /* data characters received */
  184.          t_chr_sent,          /* total characters sent */
  185.          t_dchr_sent,         /* total data characters sent */
  186.          t_chr_rec,           /* total characters received */
  187.          t_dchr_rec,          /* total data characters received */
  188.          transmit_chr_count,  /* Character count for data size calculation */
  189.          file_size;           /* Size of current file in bytes */
  190.  
  191. char  state,                  /* Present state of the automaton */
  192.       padchar,                /* Padding character to send */
  193.       eol,                    /* End-Of-Line character to send */
  194.       escchr,                 /* Connect command escape character */
  195.       quote,                  /* Quote character in incoming data */
  196.       block_check_type,       /* Checksum type */
  197.       eight_quote,            /* eight_bit quote character */
  198.       repeat_quote,           /* repeat quote character */
  199.       timint,                 /* Timeout for foreign host on sends */
  200.       pad,                    /* How much padding to send */
  201.       allowattr,              /* allow or disallow attribute packets */
  202.       attribute,              /* TRUE if attribute packets are used */
  203.       n,                      /* Packet number */
  204.       numtry,                 /* Times this packet retried */
  205.       oldtry,                 /* Times previous packet retried */
  206.       image,                  /* TRUE means 8-bit mode selected with 'set' */
  207.       binfil,                 /* 8-bit mode at runtime with attr packet */
  208.       warning,                /* File conflict warning flag */
  209.       mapping,                /* Filename case mapping flag */
  210.       auto_recover,           /* Auto recovery with extended packet length */
  211.       debug,                  /* indicates debugging output done (0=none) */
  212.       fulldup,                /* TRUE means full duples in connect */
  213.       logfileopen,            /* TRUE means log file open */
  214.       logging,                /* TRUE means logging active */
  215.       dstop,                  /* stop character for remote */
  216.       dstart,                 /* start character for remote */
  217.       filecount,              /* Number of files left to send */
  218.       filenum,                /* current filenumber */
  219.       config,                 /* initialize value */
  220.       numprm,                 /* number of command parameters */
  221.       aborted,                /* TRUE means we're aborted */
  222.       port_open,              /* TRUE means port is open */
  223.       save_file,              /* keep/discard file on abort */
  224.       sflg,                   /* send active flag */
  225.       rflg,                   /* receive active flag */
  226.       cflg,                   /* connect active flag */
  227.       *filnam,                /* Current file name */
  228.       call_baud,              /* Flag if baudrate should be set */
  229.       prvsetdone,             /* privileged task setup done */
  230.       screen,                 /* screen setup can be used */
  231.       nooutput,               /* no output if called with options */
  232.       remote,                 /* Remote line in use */
  233.       bg,                     /* Running in the background */
  234.       *params[MAXPRM],        /* parameter list */
  235.       prompt[21],             /* prompt string */
  236.       logfile[50],            /* filename for logfile */
  237.       rec_filnam[128],        /* forced receive filename */
  238.       *recpkt,                /* Receive packet buffer pointer */
  239.       *sndpkt,                /* Transmit packet buffer pointer */
  240.       dbgfname[50],           /* Filename for debug file */
  241.       tty_descr[20],          /* Terminal line in use */
  242.       mypackstart,            /* Start of packet character */
  243.       maxtry,                 /* Times to retry a packet */
  244.       myquote,                /* Quote character I will use */
  245.       mypad,                  /* Number of padding characters I will need */
  246.       mypchar,                /* Padding character I need (NULL) */
  247.       myeol,                  /* End-Of-Line character I need */
  248.       mytime,                 /* Seconds after which I should be timed out */
  249.       myrptquote,             /* Repeat quote character */
  250.       myeightquote,           /* Eight_bit quote character */
  251.       myblock_check_type;     /* My checksum type */
  252.  
  253. FILE  *fp,                    /* File pointer for current disk file */
  254.       *lfp,                   /* File pointer for log file */
  255.       *dbgfil;                /* File pointer for debug file output */
  256.  
  257. long  time(),
  258.       get_free(),
  259.       start_time,
  260.       end_time;
  261.