/* xup.c Xmodem upload program */ #include #include #include #define Auxis() Bconstat(BC_AUX) #define Auxos() Bcostat(BC_AUX) #define Auxin() ((unsigned char) Bconin(BC_AUX)) #define Auxout(c) Bconout(BC_AUX,c) #define SOH 0x01 #define EOT 0x04 #define ACK 0x06 #define NAK 0x15 #define CAN 0x18 #define NULL (char *)0 #define SIZE 128 #define PACKETMAX 65000 #define FALSE 0 #define TRUE 1 extern char *itoa(); unsigned char get_char(); char packet[SIZE+1]; main(argc,argv) int argc; char *argv[]; { char *name; int fp,n,i; unsigned int ec,bytes, packets,xpackets; unsigned char chr,checksum; if (argc!=2) fatal("Usage: xup file"); name=argv[1]; ec=10; Cconws("\r\nxup v1.0 by Jason Blochowiak\r\n"); if ((fp=open(name,1))==-1) fatal("Unable to open source file"); flush(); do { if (((chr=get_char(60))==-1) || ((chr!=NAK) && (ec--==0))) fatal("Initial timeout"); } while (chr!=NAK); Cconws("\n\aReciever present, sending...\n"); bytes=0; for (packets=1;;) { Cconws("\rS#"); Cconws(itoa(packets)); for (i=0;i0)); if (close(fp)==-1) fatal("Unable to close file."); Cconws("xup: successful send.\n"); Cconin(); exit(0); } fatal(s) char *s; { send_char(EOT); Cconws("\r\nxup: "); Cconws(s); Cconws(".\r\n\a"); exit(1); } read_packet(size,check) unsigned int size; unsigned char *check; { register int i; unsigned char cs; i=0; while ( (i