home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************/
- /* FILE JMODEM.H */
- /* Created 11-JAN-1990 Richard B. Johnson */
- /* 405 Broughton Drive */
- /* Beverly, Massachusetts 01915 */
- /* BBS (508) 922-3166 */
- /* */
- /* This program requires about 67k of free RAM to execute properly. */
- /* If you have 66k or less, it will execute, but the screens will */
- /* not be written or replaced properly. If you have only 64k, the */
- /* program will exit with an error message. */
- /* */
- /* Revision History: */
- /* V3.00 Beta test 11-FEB-1990 Richard B. Johnson */
- /* V3.01 First release 18-FEB-1990 Richard B. Johnson */
- /* V3.02 Revised 19-FEB-1990 Richard B. Johnson */
- /* */
- /* (1) A bug in MicroSoft _calloc() allocates overlapping */
- /* buffers so data files were getting corrupted. I had */
- /* used both _calloc() and _malloc() at the same time and */
- /* they didn't like it. I changed the memory allocation */
- /* to _malloc() only and it seems to work okay. */
- /* */
- /* (2) While debugging, I found some structures I didn't need and */
- /* removed them. Changed some code to accommodate. */
- /* */
- /* (3) Added a file-size during downloads. */
- /* */
- /* (4) Changed code in the data encoding (compression) routine */
- /* in an attempt to speed it up. */
- /* */
- /* V3.03 Revised 20-FEB-1990 Richard B. Johnson */
- /* */
- /* (5) Fixed bug in compression routine where the loop wasn't */
- /* terminating properly, adding random characters. Bug was */
- /* created during V3.02 change. */
- /* */
- /* V3.04 Revised 27-FEB-1990 Richard B. Johnson */
- /* */
- /* (1) Modified the block-size routine and the receive-block */
- /* routine in an attempt to improve the noise immunity. */
- /* Does not abort even if you whistle into the telephone */
- /* during uploads and downloads. Waits 5 seconds to clear */
- /* the interrupt buffer when a bad block-size is received. */
- /* */
- /* (2) Added a 1/2 second wait for modem status when opening */
- /* channel. This might accommodate slow modems response to */
- /* RTS. */
- /* */
- /* V3.05 Revised 22-MAR-1990 Richard B. Johnson */
- /* */
- /* (1) Removed _sprintf() runtime library calls to shorten */
- /* the code. Saved about 4k. */
- /* */
- /* (2) Removed extra spaces in the signon-logo to shorten */
- /* the program size. */
- /* */
- /* (3) Changed the method of creating a fixed-length string */
- /* for both the block size and cps numbers which saved about */
- /* 800 bytes of program size. */
- /* */
- /* (4) Changed numerous array indexes in JMODEM_F.C to pointers */
- /* to reduce code size. Saved a few hundred bytes and should */
- /* improve speed of screen output. */
- /* */
- /* (5) Created a local _puts() routine which saved over 6k from the */
- /* MicroSoft C runtime library version. (JMODEM_F.C) */
- /* */
- /* */
- /****************************************************************************/
- /* Parameters that are specific to JMODEM */
- /****************************************************************************/
- #define VERS "Version 3.05" /* Version number */
- #define _8K 0x2000 /* 4096 bytes */
- #define BLK_SIZ 0x200 /* Starting block size */
- #define OVRHD 0x06 /* Private, JMODEM overhead */
- #define DAT_LEN _8K + 1024 /* Data buffer length */
- #define DAT_MAX _8K /* Max block length */
- #define OPEN_READ 0x01 /* Private OPEN file function */
- #define CREATE 0x02 /* Private CREATE file function */
- #define WRITE 0x03 /* Private WRITE file function */
- #define CLOSE 0x04 /* Private CLOSE file function */
- #define DELETE 0x05 /* Private DELETE file function */
- #define READ 0x06 /* Private READ file function */
- #define GET_CRC 0x00 /* Private Get CRC function */
- #define SET_CRC 0x01 /* Private Set CRC function */
- #define NORM 0x01 /* Private, show normal data */
- #define COMP 0x02 /* Private, show compressed */
- #define EOF_ 0x04 /* Private, show end of file */
- #define TIMOUT 0x5A /* Timeout (ticks) for read */
- #define EOT 0x04 /* "D" - 64 */
- #define ACK 0x06 /* "F" - 64 */
- #define NAK 0x15 /* "U" - 64 */
- #define SYN 0x16 /* "V" - 64 */
- #define CAN 0x18 /* "X" - 64 */
- #define SCR_SGN 0x01 /* Signon screen */
- #define SCR_BOX 0x02 /* Write box on the screen */
- #define SCR_TXT 0x03 /* Write text to x/y address */
- #define SCR_STA 0x04 /* Write status box */
- #define SCR_FIL 0x05 /* Write open file box */
- #define SCR_FOK 0x06 /* File open okay */
- #define SCR_FNF 0x07 /* File not found */
- #define SCR_FCR 0x08 /* Can't create the file */
- #define SCR_FRN 0x09 /* Renamed the file */
- #define SCR_SYS 0x0A /* Show system parameters */
- #define SCR_SYT 0x0B /* Show trans synchronization */
- #define SCR_SYR 0x0C /* Show Receive synchronization */
- #define SCR_END 0x0D /* Exit all screens */
- #define JM_NRM 0x00 /* Normal exit */
- #define JM_FNF 0x01 /* File not found */
- #define JM_REN 0x02 /* Can't rename the file */
- #define JM_CRE 0x03 /* Can't create the file */
- #define JM_MEM 0x04 /* No memory available */
- #define JM_CAR 0x05 /* Modem carrier failed */
- #define JM_SYN 0x06 /* Can't synchronize */
- #define JM_ABT 0x07 /* Aborted */
- #define JM_CMD 0x08 /* Command-line error */
- #define JM_TIM 0x09 /* Time-out */
- #define JM_FAT 0x0A /* Fatal error */
- #define JM_MAX 0xFFFF /* Maximum buffer space exceeded*/
-
- /****************************************************************************/
- /* Structures and templates */
- /****************************************************************************/
- typedef struct
- { /* Structure for JMODEM status */
- unsigned short s_blk; /* Block being sent / received */
- unsigned short s_len; /* Length of the block */
- unsigned long s_byt; /* Bytes so far */
- unsigned short s_cps; /* Speed, characters / second */
- unsigned char *s_sta; /* Pointer to current status */
- } SYS;
-
- typedef struct /* JMODEM block header structure */
- {
- unsigned short len; /* Block length */
- unsigned char blk_typ; /* Kind of block EOF, COMP, etc */
- unsigned char blk_num; /* Block number (starts at 1 ) */
- unsigned char blk_dat; /* First data character */
- } JBUF;
-
- /****************************************************************************/
- /* External function prototypes */
- /****************************************************************************/
- extern short screen(
- short, /* Function (in SCREEN.H) */
- SYS *, /* Pointer to status block */
- char * ); /* Text */
- extern unsigned short
- open_chan(unsigned short); /* Open communications channel */
- extern unsigned short
- close_chan(unsigned short); /* Close communications channel */
- extern unsigned short
- read_chan(unsigned short,
- unsigned char *); /* Write communications channel */
- extern unsigned short
- write_chan(unsigned short,
- unsigned char *); /* Read communications channel */
- extern unsigned short
- send_blk(unsigned short,
- SYS *,
- unsigned char *); /* Send JMODEM block */
- extern unsigned short
- recv_blk(unsigned short *,
- unsigned char *); /* Receive JMODEM block */
- extern unsigned short
- encode(unsigned short,
- unsigned char *,
- unsigned char *); /* Data compression routine */
- extern unsigned short
- decode(unsigned short,
- unsigned char *,
- unsigned char *); /* Data expansion routine */
- extern unsigned short
- calc_crc(unsigned short,
- unsigned short,
- unsigned char *); /* Calculate CRC */
- extern unsigned short
- file_io(unsigned short,
- short *,
- unsigned char *,
- unsigned short); /* File I/O */
- extern char
- *get_inp(unsigned short, /* Get input file-name */
- char **);
- extern char get_fun(unsigned short, /* Get function (S or R) */
- char **);
- extern char get_prt(unsigned short,
- char **); /* Get port (1 - 4) */
- extern void
- disp(void); /* Display 'usage' message */
- extern unsigned short
- get_port(char); /* Convert port number */
- extern unsigned char
- *allocate_memory(unsigned short); /* Allocate memory */
- extern void flush (void); /* Flush the interrupt buffer */
- extern unsigned short tx_sync(void); /* Synchronize during transmit */
- extern unsigned short rx_sync(void); /* Synchronize during receive */
- extern unsigned short port; /* Port number */
- extern unsigned short timer; /* Global timer */
- extern SYS syst; /* In JMODEM_A.C */
- #ifdef NOENV /* If a compiler command */
- void _setenvp(void); /* Dummy routine prototype */
- void _setenvp() /* Dummy routine */
- {}
- #endif
-
- #pragma intrinsic (inp, outp) /* Generate in-line code here */
- #pragma intrinsic (_disable, _enable)
- #pragma intrinsic (memcpy, _rotl)
- #pragma check_stack(off) /* No checking between functions */
-
- /****************************************************************************/
- /*********************** E N D OF M O D U L E *****************************/