/*---------------------------------------------------------------------*/ /* SSEN_MX.C : sendingg file via terminal line compatible to bruce carbreys sreceive/ssend System: MINIX R. Henze 01.04.91 last edit: 27.06.91 */ #include #include #include #include /*zeitumrechnungen*/ #include /*setzen file date and time*/ #include "/usr/include/sys/stat.h" #define bufsz 0x0200 #define max_retry 5 #define nak 0x15 #define ack 0x06 #define enq 0x05 #define esc 0x1b #define true 1 #define false 0 #define cr 0x0d #define lf 0x0a #define f1 0xbb unsigned char bcheck; unsigned char checksum; unsigned char retry; unsigned short blksz; unsigned short bnum; unsigned short blknum; unsigned char dummy; unsigned char chr; unsigned char buf[bufsz]; unsigned char outbuf[bufsz*2]; unsigned char ib; int file; unsigned short i; int input_fd = 0; unsigned char chr; unsigned char ib; struct sgttyb old_tty; struct sgttyb new_tty; time_t fdtime; /*long*/ struct stat filestat; int flag; /*---------------------------------*/ void quit() { close(file); exit(1); } /*---------------------------------*/ unsigned char get_com() { unsigned char chr; while (read(input_fd,&chr,1) == 0); ; return(chr); } /*---------------------------------*/ int send_com(chr) unsigned char chr; { if (write(input_fd, &chr, 1)) return (true); else return(false); } /*---------------------------------*/ void put_com(chr) unsigned char chr; { while (!send_com(chr)) ; } /*---------------------------------*/ void put_com_chk(chr) unsigned char chr; /* output byte, update checksum*/ { checksum = checksum ^ chr; put_com(chr); } /*---------------------------------*/ void wait(delay) int delay; { int k; int i; for (i=0;i 0) k=0; i=0; while (k>8) & 0x00ff); put_com_chk(ib); ib = (unsigned char) (blksz & 0x00ff); put_com_chk(ib); ib = (unsigned char) ((blksz>>8) & 0x00ff); put_com_chk(ib); if ( blksz > 0) for (i=0; i2) if (*(argv[2]) == 'a') flag = true; ioctl(input_fd,TIOCGETP,&old_tty); ioctl(input_fd,TIOCGETP,&new_tty); new_tty.sg_flags = new_tty.sg_flags | RAW; /* RAW */ new_tty.sg_flags = new_tty.sg_flags | BITS8; /* 8 bit */ new_tty.sg_flags = new_tty.sg_flags & (ECHO ^ 0xffff); /* no ECHO */ new_tty.sg_flags = new_tty.sg_flags & (CRMOD ^ 0xffff); /*no lf to crlf*/ new_tty.sg_flags = new_tty.sg_flags & (XTABS ^ 0xffff); /*no tab expansion*/ ioctl(input_fd,TIOCSETP,&new_tty); file = open(argv[1],0); if (file == -1) quit(); put_com(f1); do chr = get_com(); while(chr != ack); i = 0; do put_com(*(argv[1]+i)); i++; while (*(argv[1]+i-1) != 0); fstat(file, filestat); do chr = get_com(); while(chr != ack); putftimdat(); do chr = get_com(); while(chr != ack); blknum = 0; /* block sequence #*/ do blksz = read(file,buf,bufsz); blknum++; out_blk(); while (blksz != 0); printf("\nfile successfully transmitted!"); close(file); ioctl(input_fd,TIOCSETP,&old_tty); } /*---------------------- end of file ssen_mx.i -----------------------------*/