Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!deimos!uxc!tank!mimsy!haven!adm!smoke!w8sdz
From: w8sdz@smoke.BRL.MIL (Keith B. Petersen )
Newsgroups: comp.binaries.ibm.pc.d
Subject: Re: A unix unpacking script
Summary: uuencode for Unix
Keywords: uuencode,unix
Message-ID: <9067@smoke.BRL.MIL>
Date: 5 Dec 88 06:42:57 GMT
References: <371@oucsace.cs.OHIOU.EDU> <1997@hoqax.UUCP>
Reply-To: w8sdz@brl.arpa (Keith Petersen)
Organization: Ballistic Research Lab (BRL), APG, MD.
Lines: 111
Here is the latest PD uuencode for Unix, from the current Berkeley
distribution. It substitutes the accent grave (`) for the space
character to get around problems of some mailers stripping trailing
blanks. Note that this uuencode's output defaults to stdout. You
must redirect it to make a file. I use the following shell script
which I named "uue":
uuencode $1 $1 > $1.uue
It is envoked like this: uue my.arc
and produces my.arc.uue as its output.
--cut-here--
#ifndef lint
static char sccsid[] = "@(#)uuencode.c 5.5 (Berkeley) 2/24/88";
#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) ? ((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) {
fprintf(stderr,"Usage: uuencode [infile] remotefile\n");
exit(2);
}
/* figure out the input file mode */
if (fstat(fileno(in), &sbuf) < 0 || !isatty(fileno(in)))
mode = 0666 & ~umask(0666);
else
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)
register FILE *in;
register FILE *out;
{
char buf[80];
register int i, n;
for (;;) {
/* 1 (up to) 45 character line */
n = fread(buf, 1, 45, in);
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);
}
--
Keith Petersen
Maintainer of the CP/M & MSDOS archives at WSMR-SIMTEL20.ARMY.MIL [26.0.0.74]
Arpa: W8SDZ@WSMR-SIMTEL20.ARMY.MIL
Uucp: {ames,decwrl,harvard,rutgers,ucbvax,uunet}!wsmr-simtel20.army.mil!w8sdz