// ********************* START OF ZMODEM.H ********************* // // This header file has the class definitions needed for an // application program to perform Zmodem file transfers. // The Zmodem class is derived from the virtual base class // FileTransfer. The public interface to the Zmodem class // consists of just three functions: a constructor, and // functions to send and receive files. #ifndef _ZMODEM_DOT_H #define _ZMODEM_DOT_H class FileTransfer { protected : virtual void error( char *fmt, ... ); virtual void status( char *fmt, ... ); RS232 *port; FILE *file; long file_length; long byte_count; int file_count; char file_name[ 128 ]; char buffer[ 1025 ]; public : virtual int Send( char *files[] ) = 0; virtual int Receive( char *file ) = 0; }; const int ZMAXHLEN = 16; // Max header information length const int ZATTNLEN = 32; // Max length of attention string class Zmodem : public FileTransfer { private : int WakeUpSender( void ); int ReceiveFiles( void ); int ReceiveSingleFile( void ); void SendHexHeader( int len, int type, char *hdr ); void SendBinaryHeader( int length, int type, char * header ); int ReadHeader( char *header ); int ReadDataFrame( char *buf, int length ); int ReadDataFrameCRC32( char *buf, int length ); int ReadDataFrameCRC16( char *buf, int length ); void SendAttentionString( void ); void AckZFIN( void ); int OpenInputFile( char *data ); void PackLongIntoHeader( long header_data ); long UnpackHeaderIntoLong( char *header ); void SendHexEncodedChar( int c ); void SendEncodedChar( int c ); void SendChar( int c ) { port->Write( (char) c, 30000L ); } void SendZFIN( void ); int ReadHexHeaderCRC16( char *header ); int ReadBinaryHeaderCRC16( char *header ); int ReadBinaryHeaderCRC32( char *header ); int ReadEncodedByte( void ); int ReadUnencodedByte( void ); int ReadHexByte( void ); int ReadChar( long timeout ); int GetRinitHeader( void ); int SendSingleFile( char *name ); int SendFileContents( void ); void SendDataFrame( char *buffer, int length, int frameend ); int SyncWithReceiver( int flag ); int receiver_wants_crc32; int current_frame_uses_crc32; long received_file_position; long transmitted_file_position; long last_sync_position; long last_reported_position; unsigned int receiver_buffer_length; int file_at_eof; int wake_up_sender_header_type; int Rxcount; char received_header[ ZMAXHLEN ]; char transmitted_header[ ZMAXHLEN ]; char attention_string[ ZATTNLEN + 1 ]; int last_char_sent; public : Zmodem( RS232 *rs232_port ); int Send( char *files[] ); int Receive( char *file ); }; #endif // #ifdef _ZMODEM_DOT_H // ******************* END OF ZMODEM.H *******************