/*---------------------------------------------------------------------*/ /* SSEN_UX.C : sendingg file via terminal line compatible to bruce carbreys sreceive/ssend and sft for msdos systems System: MINIX, Coherent; ibm-aix, sun R. Henze 01.04.91 last edit: 15.07.92 */ #define rest 0 //#define minix 1 #define aix 2 //system festlegen: #define systm aix #include #include #include #if (systm == aix) #include /*tty*/ #endif #include /*zeitumrechnungen*/ #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; #if (systm == aix) struct termio old_tmio; struct termio new_tmio; #endif time_t fdtime; /*long*/ struct stat filestat; int flag; /*---------------------------------*/ void quit() { close(file); exit(1); } /*---------------------------------*/ unsigned char get_com() { unsigned char chr; read(input_fd,&chr,1); 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 out_blk() /* output block number blknum to port*/ /* buf holds data*/ /* blksz is size of block, 0 for eof*/ { unsigned char ib; unsigned short k; if ( blksz > 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 */ #ifdef minix new_tty.sg_flags = new_tty.sg_flags | BITS8; /* 8 bit */ #endif 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); #if (systm == aix) ioctl(input_fd,TCGETA,&old_tmio); ioctl(input_fd,TCGETA,&new_tmio); new_tmio.c_oflag = new_tmio.c_oflag & (ONLCR ^ 0xffff); /* no Outp-NLCR-mapping*/ new_tmio.c_iflag = new_tmio.c_iflag & (ICRNL ^ 0xffff); /* no Input-CRNL-mapping*/ ioctl(input_fd,TCSETA,&new_tmio); #endif 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); 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); #if (systm == aix) ioctl(input_fd,TCSETA,&old_tmio); #endif ioctl(input_fd,TIOCSETP,&old_tty); } /*---------------------- end of file ssen_mx.i -----------------------------*/