Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbatt!cbuxc!cblpe!jrm From: jrm@cblpe.UUCP (John Miller) Newsgroups: net.sources Subject: UUENCODE C source, if you need UUENCODE - here it is!!!! Message-ID: <281@cblpe.UUCP> Date: Tue, 4-Nov-86 14:33:59 EST Article-I.D.: cblpe.281 Posted: Tue Nov 4 14:33:59 1986 Date-Received: Wed, 5-Nov-86 05:32:13 EST Distribution: net Organization: AT&T Bell Laboratories - Columbus Lines: 129 I have had trouble returning mail to some of you (no I didn't ignore your request) and there have been too many requests to handle. Therefore, here is the UUencode source file. Here is the source for uuencode: John Miller, Columbus Bell Labs ihnp4!cblpe!jrm ==================================cut here=================================== #ifndef lint static char sccsid[] = "@(#)uuencode.c 5.1 (Berkeley) 7/2/83"; #endif /* * uuencode [input] output * * Encode a file so it can be mailed to a remote system. */ #include #include #include /* ENC is the basic 1 character encoding function to make a char printing */ #define ENC(c) (((c) & 077) + ' ') main(argc, argv) char **argv; { FILE *in; struct stat sbuf; int mode; /* optional 1st argument */ if (argc > 2) { if ((in = fopen(argv[1], "r")) == NULL) { perror(argv[1]); exit(1); } argv++; argc--; } else in = stdin; if (argc != 2) { printf("Usage: uuencode [infile] remotefile\n"); exit(2); } /* figure out the input file mode */ fstat(fileno(in), &sbuf); mode = sbuf.st_mode & 0777; printf("begin %o %s\n", mode, argv[1]); encode(in, stdout); printf("end\n"); exit(0); } /* * copy from in to out, encoding as you go along. */ encode(in, out) FILE *in; FILE *out; { char buf[80]; int i, n; for (;;) { /* 1 (up to) 45 character line */ n = fr(in, buf, 45); putc(ENC(n), out); for (i=0; i> 2; c2 = (*p << 4) & 060 | (p[1] >> 4) & 017; c3 = (p[1] << 2) & 074 | (p[2] >> 6) & 03; c4 = p[2] & 077; putc(ENC(c1), f); putc(ENC(c2), f); putc(ENC(c3), f); putc(ENC(c4), f); } /* fr: like read but stdio */ int fr(fd, buf, cnt) FILE *fd; char *buf; int cnt; { int c, i; for (i=0; i