type string1 = string[1]; string3 = string[3]; string80 = string[80]; string15 = string[15]; string100 = string[150]; state_vars = (send_init, send_file_header, send_file, send_eof, send_break, receive_init, receive_header, receive_file, send_bye, get_file); state_type = array[state_vars] of string[30]; file_param = (ascii, binary); file_type = array[file_param] of string[10]; parity_param = (no_parity, mark_parity, space_parity, even_parity, odd_parity); parity_type = array[parity_param] of string[10]; packet_param = (break_pack, data_pack, error_pack, header_pack, nak_pack, send_pack, reserved_pack, ack_pack, end_pack, unknown); f_modes = (read_open, write_open); character = char; const version = 1.1; (* current version number *) buffersize = 128; (* program is not set up for any other size right now *) file_str : file_type = ('ASCII', 'Binary'); parity_str : parity_type = ('None', 'Mark', 'Space', 'Even', 'Odd'); state_str : state_type = ('send init', 'send file header', 'send file', 'send eof', 'send break', 'receive init', 'receive header', 'receive file', 'send bye', 'get file'); escape_char = $1c; (* ^\ control-backslash *) bell = ^G; init_packet_size = 40; (* use a small packet for testing *) var option, bs, cr, lf : char; count : integer; (* general purpose count variable *) line_command, arg1, arg2, arg3 : string[25]; (* more space for filename *) line_buffer : string[80]; done : boolean; (* dummy variable for main proc loop *) file_type_var : file_param; parity_type_var : parity_param; packet_type : packet_param; state : state_vars; (* state variable for state switchers *) packet_size, timeout, npad, end_of_line : integer; pad, quote_char, quote_8, chk_type, repeat_char : char; packet_buffer, packet_buffer_data, rec_packet : string[150]; packet_ok, ack_ok, open_ok, file_done, abort : boolean; packet_num, rec_packet_num, packets_sent, packets_bad : integer; outfile : file; (* untyped file for read or write *) file_open : boolean; file_mode : f_modes; received_data : string[100]; quoting : boolean; repeating : boolean; printing : boolean; print_mode : string[3]; my_pad_char, his_ctl_quote, his_quote_char : char; my_pad_num, send_eol : integer; debug : boolean; debug_mode : string[3]; retry : boolean; (* if you want to force a retry on send or receive packet *) maxtry : integer; fcb : array[1..36] of byte; (* fcb for dir command *) dma : array[1..128] of byte; (* dma buffer for dir command *) filebuffer : array[1..buffersize] of char; (* file record read *) file_records : integer; (* number of 128 byte records in disk file *) filepointer : integer; (* where we are in the record *) buffer_num : integer; (* how many 128 byte records have we read or written *) receive_done : boolean; (* signals the end of receive command *) function tab(spaces : integer) : string80; (* This function generates a string of spaces for formatting printing *) var count : integer; temp : string[80]; begin (* tab *) temp := ''; for count := 1 to spaces do temp := temp + ' '; tab := temp; end; (* tab *) function ctl(character : char) : char; (* This function transforms a character to/from a control character *) begin ctl := chr(ord(character) xor $40); end; function char40(number : integer) : char; (* add 40 octal to a number for conversion to printable character *) begin char40 := chr(number + 32); end; function unchar(character : char) : integer; (* subtract 40 octal from character for conversion back to a number *) begin unchar := ord(character) - 32; end; procedure ltrim(var line : string80); (* removes leading spaces from a line for parsing the command line *) begin (* ltrim *) while line[1] = ' ' do delete(line,1,1); end; (* ltrim *) procedure rtrim(var line: string80); (* removes trailing spaces from a string to parse the command line *) begin (* rtrim *) while line[length(line)] = ' ' do delete(line,length(line),1); end; (* rtrim *)