Category : System Diagnostics for your computer
Archive   : ATBENCH.ZIP
Filename : XR.C

 
Output of file : XR.C contained in archive : ATBENCH.ZIP
/* xr.c - remote xmodem functions for xenix/unix
* copyright 1986 Maple Lawn Farm, Inc.
* usage: xr|xt [-ct] [-d errfile] file
* -c crc (instead of checksum), -t text mode (CR-NL <-> NL)
* compile: cc -i -O -s xr.c xmodem.c -o xr
* ln xr xt
* To avoid overwriting existing files, received file with same name
* as an existing file is stored as fname~. */

#include
#include
#include
#include
#include
#include
#include

#define DEBUG 01
#define LF 02
#define CRC 04
#define BSIZE 128
#define errx(m,f) printf("%s: ", pname), \
printf(m, f), \
printf("\n"), \
exit(1)

FILE *errf;

struct termio old,
new;

hangup()
{
resetline();
exit(1);
}

main(ac, av)
int ac;
char **av;
{
char *pname,
trans = (av[0][strlen(av[0]) -1] == 't'),
*fname;
int c, opts = 0;
struct stat stbuf;
extern int optind;
extern char *optarg;
FILE *fp;

pname = *av;
while ((c = getopt(ac, av, "ctd:?")) != EOF)
switch (c) {
case 't' :
opts |= LF;
break;
case 'c' :
opts |= CRC;
break;
case 'd' :
opts |= DEBUG;
if (!(errf = fopen(optarg, "w")))
errx("can't open %s", optarg);
setbuf(errf, NULL);
break;
case '?' :
printf("usage: %s [-ct] [-d errfile] file\n", pname);
exit(1);
}
if (ac == 1 || ac == optind)
errx("need file name", NULL);
fname = av[optind];
if (trans && !(fp = fopen(fname, "r")))
errx("can't open %s", fname);
if (!trans) {
if (!access(fname, 0))
strcat(fname, "~");
if (!(fp = fopen(fname, "w")))
errx("can't write %s", fname);
}

printf("Ready to %s %s\n", (trans) ? "send":"receive", fname);
if (trans) {
stat(fname, &stbuf);
printf("%d blocks (128 bytes/block)\n",
stbuf.st_size/BSIZE+1);
}
printf("Ctrl-X to abort transfer\n");

signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
signal(SIGHUP, hangup);

ioctl(1, TCGETA, &old);
ioctl(1, TCGETA, &new);
fflush(stdin);
new.c_iflag = IGNBRK|IGNPAR;
new.c_oflag = 0;
new.c_lflag = 0;
new.c_cc[4] = 1;
new.c_cflag &= ~PARENB;
new.c_cflag |= CS8;
ioctl(1, TCSETAW, &new);

(trans) ? xput(fp, opts) : xget(fp, opts);
}


resetline()
{
ioctl(1, TCSETA, &old);
}



  3 Responses to “Category : System Diagnostics for your computer
Archive   : ATBENCH.ZIP
Filename : XR.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/