static char sccsid
[] = "@(#)uuencode.c 5.1 (Berkeley) %G%";
* uuencode [input] output
* Encode a file so it can be mailed to a remote system.
/* ENC is the basic 1 character encoding function to make a char printing */
#define ENC(c) (((c) & 077) + ' ')
/* optional 1st argument */
if ((in
= fopen(argv
[1], "r")) == NULL
) {
printf("Usage: uuencode [infile] remotefile\n");
/* figure out the input file mode */
fstat(fileno(in
), &sbuf
);
mode
= sbuf
.st_mode
& 0777;
printf("begin %o %s\n", mode
, argv
[1]);
* copy from in to out, encoding as you go along.
/* 1 (up to) 45 character line */
* output one group of 3 bytes, pointed at by p, on file f.
c2
= (*p
<< 4) & 060 | (p
[1] >> 4) & 017;
c3
= (p
[1] << 2) & 074 | (p
[2] >> 6) & 03;
/* fr: like read but stdio */