package NETWORK_PROTOCOLS is -- -- Purpose: Provide the ability to transfer a "file" using a file -- transfer protocol -- -- Use: The user instantiates the generic package that uses the -- protocol of his choice, providing I/O and housekeeping -- routines suitable for his application. After initializing -- the I/O routines, he will call SEND or RECEIVE. After the -- transfer has completed (when SEND or RECEIVE returns), he -- will close the I/O routines. -- -- This package was produced by Westinghouse Electric Corporation, -- as part of the STARS Foundation Ada Software procurement effort. -- -- Each generic package supporting a protocol has the following -- profile: -- -- generic -- type BYTE is (<>) ; -- -- BYTE must support "values" in 0..255; i.e., -- -- BYTE'POS(BYTE'FIRST) <= 0 and 255 <= BYTE'POS(BYTE'LAST) -- with procedure F_READ ( C : out BYTE ; -- EOFILE : out BOOLEAN ) ; -- -- F_READ "reads" the next byte to be transmitted; -- -- returns EOFILE = TRUE if there are no more bytes to be -- -- transmitted -- with procedure F_WRITE ( C : BYTE ) ; -- with procedure RS_READ ( C : out BYTE ; -- GOT_ONE : out BOOLEAN ; -- RETURN_AFTER : DURATION := 0.0 ) ; -- -- RS_READ finds out if a byte is available from the RS-232 port -- -- and, if so, returns it -- -- When a byte is not immediately available, RS_READ is to wait -- -- no longer than RETURN_AFTER before giving up and -- -- returning with GOT_ONE = TRUE -- -- It is not critical that RS_READ wait the full RETURN_AFTER -- -- before giving up. It will be acceptable if RS_READ -- -- always returns immediately. The option of waiting a -- -- specified time is provided for those implementations -- -- that are able to improve the performance of either the -- -- calling program itself or the host system by -- -- "suspending" while waiting for a byte to show up. -- -- What IS critical is that RS_READ not wait (appreciably) -- -- longer than the stipulated time before returning. -- with procedure RS_WRITE ( C : BYTE ) ; -- with procedure RS_WRITE_FLUSH ; -- -- RS_WRITE_FLUSH is to ensure that all bytes passed thus far to -- -- RS_WRITE have actually been transmitted; if bytes passed -- -- to RS_WRITE are not buffered, RS_WRITE_FLUSH will do -- -- nothing -- with procedure SERVICE ( ABORT_TRANSFER : out BOOLEAN ) ; -- -- SERVICE will be called "periodically" during the file -- -- transfer (the definition of "periodically" being a -- -- function of the particular protocol) to allow the -- -- "parent" program to perform housekeeping functions and, -- -- at its discretion, abort the file transfer -- with function NAME_OF_FILE_BEING_TRANSFERRED return STRING ; -- package GENERIC_PROTOCOL is -- FILE_TRANSFER_ERROR : exception ; -- procedure RECEIVE ; -- procedure SEND ; -- end GENERIC_PROTOCOL ; generic type BYTE is (<>) ; with procedure F_READ ( C : out BYTE ; EOFILE : out BOOLEAN ) ; with procedure F_WRITE ( C : BYTE ) ; with procedure RS_READ ( C : out BYTE ; GOT_ONE : out BOOLEAN ; RETURN_AFTER : DURATION := 0.0 ) ; with procedure RS_WRITE ( C : BYTE ) ; with procedure RS_WRITE_FLUSH ; with procedure SERVICE ( ABORT_TRANSFER : out BOOLEAN ) ; with function NAME_OF_FILE_BEING_TRANSFERRED return STRING ; package KERMIT_PROTOCOL is FILE_TRANSFER_ERROR : exception ; procedure RECEIVE ; procedure SEND ; end KERMIT_PROTOCOL ; generic type BYTE is (<>) ; with procedure F_READ ( C : out BYTE ; EOFILE : out BOOLEAN ) ; with procedure F_WRITE ( C : BYTE ) ; with procedure RS_READ ( C : out BYTE ; GOT_ONE : out BOOLEAN ; RETURN_AFTER : DURATION := 0.0 ) ; with procedure RS_WRITE ( C : BYTE ) ; with procedure RS_WRITE_FLUSH ; with procedure SERVICE ( ABORT_TRANSFER : out BOOLEAN ) ; with function NAME_OF_FILE_BEING_TRANSFERRED return STRING ; package XMODEM_PROTOCOL is FILE_TRANSFER_ERROR : exception ; procedure RECEIVE ; procedure SEND ; end XMODEM_PROTOCOL ; generic type BYTE is (<>) ; package GENERIC_TEXT_FILE_IO is -- supplied to provide the entry points needed to instantiate one -- of the generic protocol packages to transmit or receive a -- "standard" text file, i.e., a file produced using TEXT_IO. -- Performance with respect to host source files will vary from -- implementation to implementation. -- TEXT_IO will be used to access the designated file -- exceptions raised by TEXT_IO will be propagated unchanged procedure F_READ ( C : out BYTE ; EOFILE : out BOOLEAN ) ; procedure F_WRITE ( C : BYTE ) ; procedure OPEN_READ ( NAME : STRING ; FORM : STRING := "" ) ; -- NAME & FORM will be passed to TEXT_IO.OPEN procedure CLOSE_READ ; procedure OPEN_WRITE ( NAME : STRING ; FORM : STRING := "" ) ; -- NAME & FORM will be passed to TEXT_IO.CREATE procedure CLOSE_WRITE ; function NAME_OF_FILE_BEING_TRANSFERRED return STRING ; end GENERIC_TEXT_FILE_IO ; end NETWORK_PROTOCOLS ;