diff options
Diffstat (limited to 'usr.bin/uuencode')
-rw-r--r-- | usr.bin/uuencode/Makefile | 8 | ||||
-rw-r--r-- | usr.bin/uuencode/uuencode.1 | 105 | ||||
-rw-r--r-- | usr.bin/uuencode/uuencode.c | 150 | ||||
-rw-r--r-- | usr.bin/uuencode/uuencode.format.5 | 102 |
4 files changed, 365 insertions, 0 deletions
diff --git a/usr.bin/uuencode/Makefile b/usr.bin/uuencode/Makefile new file mode 100644 index 0000000..051a6fe --- /dev/null +++ b/usr.bin/uuencode/Makefile @@ -0,0 +1,8 @@ +# @(#)Makefile 8.1 (Berkeley) 6/6/93 + +PROG= uuencode +MAN1= uuencode.0 +MAN5= uuencode.format.0 +MLINKS= uuencode.1 uudecode.1 + +.include <bsd.prog.mk> diff --git a/usr.bin/uuencode/uuencode.1 b/usr.bin/uuencode/uuencode.1 new file mode 100644 index 0000000..df1ebf2 --- /dev/null +++ b/usr.bin/uuencode/uuencode.1 @@ -0,0 +1,105 @@ +.\" Copyright (c) 1980, 1990, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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 BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)uuencode.1 8.1 (Berkeley) 6/6/93 +.\" +.Dd June 6, 1993 +.Dt UUENCODE 1 +.Os BSD 4 +.Sh NAME +.Nm uuencode , +.Nm uudecode +.Nd encode/decode a binary file +.Sh SYNOPSIS +.Nm uuencode +.Op Ar file +.Ar name +.Nm uudecode +.Op Ar file ... +.Sh DESCRIPTION +.Nm Uuencode +and +.Nm uudecode +are used to transmit binary files over transmission mediums +that do not support other than simple +.Tn ASCII +data. +.Pp +.Nm Uuencode +reads +.Ar file +(or by default the standard input) and writes an encoded version +to the standard output. +The encoding uses only printing +.Tn ASCII +characters and includes the +mode of the file and the operand +.Ar name +for use by +.Nm uudecode . +.Pp +.Nm Uudecode +transforms +.Em uuencoded +files (or by default, the standard input) into the original form. +The resulting file is named +.Ar name +and will have the mode of the original file except that setuid +and execute bits are not retained. +.Nm Uudecode +ignores any leading and trailing lines. +.Sh EXAMPLES +The following example packages up a source tree, compresses it, +uuencodes it and mails it to a user on another system. +When +.Nm uudecode +is run on the target system, the file ``src_tree.tar.Z'' will be +created which may then be uncompressed and extracted into the original +tree. +.Pp +.Bd -literal -offset indent -compact +tar cf \- src_tree \&| compress \&| +uuencode src_tree.tar.Z \&| mail sys1!sys2!user +.Ed +.Sh SEE ALSO +.Xr compress 1 , +.Xr mail 1 , +.Xr uucp 1 , +.Xr uuencode 5 , +.Xr format 5 +.Sh BUGS +The encoded form of the file is expanded by 35% (3 bytes become 4 plus +control information). +.Sh HISTORY +The +.Nm +command appeared in +.Bx 4.0 . diff --git a/usr.bin/uuencode/uuencode.c b/usr.bin/uuencode/uuencode.c new file mode 100644 index 0000000..774cee9 --- /dev/null +++ b/usr.bin/uuencode/uuencode.c @@ -0,0 +1,150 @@ +/*- + * Copyright (c) 1983, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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 BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +char copyright[] = +"@(#) Copyright (c) 1983, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; +#endif /* not lint */ + +#ifndef lint +static char sccsid[] = "@(#)uuencode.c 8.2 (Berkeley) 4/2/94"; +#endif /* not lint */ + +/* + * uuencode [input] output + * + * Encode a file so it can be mailed to a remote system. + */ +#include <sys/types.h> +#include <sys/stat.h> + +#include <stdio.h> + +int +main(argc, argv) + int argc; + char *argv[]; +{ + extern int optind; + extern int errno; + struct stat sb; + int mode; + char *strerror(); + + while (getopt(argc, argv, "") != EOF) + usage(); + argv += optind; + argc -= optind; + + switch(argc) { + case 2: /* optional first argument is input file */ + if (!freopen(*argv, "r", stdin) || fstat(fileno(stdin), &sb)) { + (void)fprintf(stderr, "uuencode: %s: %s.\n", + *argv, strerror(errno)); + exit(1); + } +#define RWX (S_IRWXU|S_IRWXG|S_IRWXO) + mode = sb.st_mode & RWX; + ++argv; + break; + case 1: +#define RW (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) + mode = RW & ~umask(RW); + break; + case 0: + default: + usage(); + } + + (void)printf("begin %o %s\n", mode, *argv); + encode(); + (void)printf("end\n"); + if (ferror(stdout)) { + (void)fprintf(stderr, "uuencode: write error.\n"); + exit(1); + } + exit(0); +} + +/* 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. + */ +encode() +{ + register int ch, n; + register char *p; + char buf[80]; + + while (n = fread(buf, 1, 45, stdin)) { + ch = ENC(n); + if (putchar(ch) == EOF) + break; + for (p = buf; n > 0; n -= 3, p += 3) { + ch = *p >> 2; + ch = ENC(ch); + if (putchar(ch) == EOF) + break; + ch = (*p << 4) & 060 | (p[1] >> 4) & 017; + ch = ENC(ch); + if (putchar(ch) == EOF) + break; + ch = (p[1] << 2) & 074 | (p[2] >> 6) & 03; + ch = ENC(ch); + if (putchar(ch) == EOF) + break; + ch = p[2] & 077; + ch = ENC(ch); + if (putchar(ch) == EOF) + break; + } + if (putchar('\n') == EOF) + break; + } + if (ferror(stdin)) { + (void)fprintf(stderr, "uuencode: read error.\n"); + exit(1); + } + ch = ENC('\0'); + (void)putchar(ch); + (void)putchar('\n'); +} + +usage() +{ + (void)fprintf(stderr,"usage: uuencode [infile] remotefile\n"); + exit(1); +} diff --git a/usr.bin/uuencode/uuencode.format.5 b/usr.bin/uuencode/uuencode.format.5 new file mode 100644 index 0000000..81591b8 --- /dev/null +++ b/usr.bin/uuencode/uuencode.format.5 @@ -0,0 +1,102 @@ +.\" Copyright (c) 1989, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. 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 BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)uuencode.format.5 8.2 (Berkeley) 1/12/94 +.\" +.Dd January 12, 1994 +.Dt UUENCODE 5 +.Os BSD 4 +.Sh NAME +.Nm uuencode +.Nd format of an encoded uuencode file +.Sh DESCRIPTION +Files output by +.Xr uuencode 1 +consist of a header line, +followed by a number of body lines, +and a trailer line. +The +.Xr uudecode 1 +command +will ignore any lines preceding the header or +following the trailer. +Lines preceding a header must not, of course, +look like a header. +.Pp +The header line is distinguished by having the first +6 characters +.Dq begin\ \& +(note the trailing space). +The word +.Em begin +is followed by a mode (in octal), +and a string which names the remote file. +A space separates the three items in the header line. +.Pp +The body consists of a number of lines, each at most 62 characters +long (including the trailing newline). +These consist of a character count, +followed by encoded characters, +followed by a newline. +The character count is a single printing character, +and represents an integer, the number of bytes +the rest of the line represents. +Such integers are always in the range from 0 to 63 and can +be determined by subtracting the character space (octal 40) +from the character. +.Pp +Groups of 3 bytes are stored in 4 characters, 6 bits per character. +All are offset by a space to make the characters printing. +The last line may be shorter than the normal 45 bytes. +If the size is not a multiple of 3, this fact can be determined +by the value of the count on the last line. +Extra garbage will be included to make the character count a multiple +of 4. +The body is terminated by a line with a count of zero. +This line consists of one +.Tn ASCII +space. +.Pp +The trailer line consists of +.Dq end +on a line by itself. +.Sh SEE ALSO +.Xr uuencode 1 , +.Xr uudecode 1 , +.Xr uusend 1 , +.Xr uucp 1 , +.Xr mail 1 +.Sh HISTORY +The +.Nm uuencode +file format appeared in +.Bx 4.0 . +.\" It was named uuencode.5 prior to 4.3 |