unit kermglob;

interface
 
{Change log:
13 May 89, V1.1: Added COMMENT vocab. & Eliminated "int_bool_rec"   RTC
30 Apr 89, V1.1: Added vocabulary for SET INTERFACE command   RTC
26 Apr 89, V1.1: minor cleanups   RTC
16 Apr 89, V1.1: Added BYE & FINISH commands       RTC
13 Apr 89, V1.1: Added Version message      RTC
14 Aug 88: Added LOG, CLOSE, and SET SYSTEM commands    RTC
31 Jul 88: Added variable system_id string for REMUNIT    RTC
31 Jul 88: Added attributes packets & exact size bin. xfrs    RTC
10 Jul 88: Removed screen command definitions    RTC
30 Jun 88: Modified for binary files, "take", ^X & ^Z   RTC
}
 
   const
         blksize = 512;
         oport = 8;          (* output port # *)
         inport = 7;
         keyport = 2;
         bell = 7;           (* ASCII bell *)
         maxpack = 93;       (* maximum packet size minus 1 *)
         soh = 1;            (* start of header *)
         sp = 32;            (* ASCII space *)
         cr = 13;            (* ASCII CR *)
         lf = 10;            (* ASCII line feed *)
         del = 127;          (* delete *)
         can_cur = 24;       { cancel current file char ^X }
         can_all = 26;       { cancel all files char    ^Z }
         my_esc = 29;        (* default esc char for connect (^]) *)
         maxtry = 5;         (* number of times to retry sending packet *)
         my_quote = '#';     (* quote character I'll use *)
         my_qbin = '&';      { 8th bit quote character I want }
         my_pad = 0;         (* number of padding chars I need *)
         my_pchar = 0;       (* padding character I need *)
         my_eol = 13;        (* end of line character i need *)
         my_time = 5;        (* seconds after which I should be timed out *)
         maxtim = 20;        (* maximum timeout interval *)
         mintim = 2;         (* minimum time out interval *)
         at_eof = -1;        (* value to return if at eof *)
         at_badblk = -2;     { value to return if at bad block }
         {rqsize = 5000;      (* input queue size *)
         qsize1 = 5001;      (* qsize + 1 *)}
         eoln_sym = 13;      (* pascal eoln sym *)
         back_space = 8;     (* pascal backspace sym *)
         defaultbaud = 1200; (* default baud rate *)

   (* screen control information *)
     (* console line on which to put specified info *)
         menu_line = 0;
         title_line = 2;
         statusline = 3;
         packet_line = 4;
         retry_line = 5;
         file_line = 6;
         error_line = 7;
         debug_line = 8;
         prompt_line = 9;
     (* position on line to put info *)
         statuspos = 60;
         packet_pos = 19;
         retry_pos = 17;
         file_pos = 11;

   type packettype = packed array[0..maxpack] of char;
        parity_type = (evenpar, oddpar, markpar, spacepar, nopar);

        string255 = string[255];


        statustype = (null, at_eol, unconfirmed, parm_expected, ambiguous,
                      unrec, fn_expected, ch_expected, num_expected);
        vocab = (nullsym, allsym, baudsym, binsym, byesym, closesym, comsym,
                 consym, convsym, debugsym, emulatesym, escsym, evensym,
                 exitsym, filenamsym, filetypesym, filewarnsym, finsym,
                 getsym, helpsym, ibmsym, intsym, kermitsym, litsym,
                 localsym, logsym, marksym, nonesym, oddsym, offsym, onsym,
                 paritysym, putsym, quitsym, recsym, sendsym, setsym,
                 showsym, spacesym, systemsym, takesym, textsym, ucsdsym,
                 versionsym);

    var noun, verb, adj: vocab;
        status: statustype;
        vocablist: array[vocab] of string[13];
        xfilename, line: string255;
        newescchar: char;
        expected: set of vocab;
        newbaud: integer;

        currstate: char; (* current state *)
        xeol, quote, qbin, esc_char: char;
        lit_names, f_is_binary, fwarn, ibm, half_duplex,
        en_attr, en_qbin, debug: boolean;
        i, size, rpsiz, spsiz, pad, n, num_try, oldtry, timint: integer;
        recpkt, packet: packettype;
        padchar, ch: char;
        s: string255;
        debf: text; (* file for debug output *)
        parity: parity_type;
        xon: char;
        filebuf: packed array[1..blksize] of char;
        bufpos, bufend: integer;
        parity_array: packed array[char] of char;
        ctlset: set of char;
        rec_ok, send_ok: boolean;
        baud: integer;
        emulating: boolean;
        last_blksize : integer;  {size of last block of boolean file}
        t_file : text   {file for text file transfers};
        b_file : file   {file for binary file transfers};
        cmd_file : text {file of "take" commands};
        ker_version,            { version id for other units }
        system_id : string      {id string for REMUNIT};

   procedure gbl_version;

implementation
 
   const
     my_version = '   Kermglob Unit V1.1, 13 May 89';

   procedure gbl_version;
 
     begin
       writeln(my_version)
     end {gbl_version};

end. { kermglob }
