* Copyright (c) 1983 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted provided
* that: (1) source distributions retain this entire copyright notice and
* comment, and (2) distributions including binaries display the following
* acknowledgement: ``This product includes software developed by the
* University of California, Berkeley and its contributors'' in the
* documentation or other materials provided with the distribution and in
* all advertising materials mentioning features or use of this software.
* Neither the name of the University nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
static char sccsid
[] = "@(#)uuencode.c 5.9 (Berkeley) 6/1/90";
* uuencode [input] output
* Encode a file so it can be mailed to a remote system.
while (getopt(argc
, argv
, "") != EOF
)
case 2: /* optional first argument is input file */
if (!freopen(*argv
, "r", stdin
) || fstat(fileno(stdin
), &sb
)) {
(void)fprintf(stderr
, "uuencode: %s: %s.\n",
#define RWX (S_IRWXU|S_IRWXG|S_IRWXO)
#define RW (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
(void)printf("begin %o %s\n", mode
, *argv
);
(void)fprintf(stderr
, "uuencode: write error.\n");
/* ENC is the basic 1 character encoding function to make a char printing */
#define ENC(c) ((c) ? ((c) & 077) + ' ': '`')
* copy from in to out, encoding as you go along.
while (n
= fread(buf
, 1, 45, stdin
)) {
for (p
= buf
; n
> 0; n
-= 3, p
+= 3) {
ch
= (*p
<< 4) & 060 | (p
[1] >> 4) & 017;
ch
= (p
[1] << 2) & 074 | (p
[2] >> 6) & 03;
if (putchar('\n') == EOF
)
(void)fprintf(stderr
, "uuencode: read error.\n");
(void)fprintf(stderr
,"usage: uuencode [infile] remotefile\n");