diff options
| author | Philippe Charnier <charnier@FreeBSD.org> | 1997-08-22 06:53:00 +0000 |
|---|---|---|
| committer | Philippe Charnier <charnier@FreeBSD.org> | 1997-08-22 06:53:00 +0000 |
| commit | f296f8ebb4cf68865b9e5eee9784ebedb3c0e96d (patch) | |
| tree | b9adcc667843399845cac5250489390cf3372f6d /usr.bin/uuencode | |
| parent | 474cc7fe23175a68255ed28ca5fcb74b0ac2b076 (diff) | |
Notes
Diffstat (limited to 'usr.bin/uuencode')
| -rw-r--r-- | usr.bin/uuencode/uuencode.1 | 10 | ||||
| -rw-r--r-- | usr.bin/uuencode/uuencode.c | 37 |
2 files changed, 25 insertions, 22 deletions
diff --git a/usr.bin/uuencode/uuencode.1 b/usr.bin/uuencode/uuencode.1 index 3dd1e680b65cb..fd194aa2558cc 100644 --- a/usr.bin/uuencode/uuencode.1 +++ b/usr.bin/uuencode/uuencode.1 @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)uuencode.1 8.1 (Berkeley) 6/6/93 -.\" $Id$ +.\" $Id: uuencode.1,v 1.5 1997/02/22 19:57:36 peter Exp $ .\" .Dd June 6, 1993 .Dt UUENCODE 1 @@ -45,7 +45,7 @@ .Ar name .Nm uudecode .Op Fl cp -.Op Ar file ... +.Op Ar .Sh DESCRIPTION .Nm Uuencode and @@ -127,6 +127,8 @@ The encoded form of the file is expanded by 35% (3 bytes become 4 plus control information). .Sh HISTORY The -.Nm -command appeared in +.Nm uudecode +and +.Nm uuencode +utilities appeared in .Bx 4.0 . diff --git a/usr.bin/uuencode/uuencode.c b/usr.bin/uuencode/uuencode.c index 858062457ae6c..b10a524a19002 100644 --- a/usr.bin/uuencode/uuencode.c +++ b/usr.bin/uuencode/uuencode.c @@ -32,13 +32,17 @@ */ #ifndef lint -char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1983, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint +#if 0 static char sccsid[] = "@(#)uuencode.c 8.2 (Berkeley) 4/2/94"; +#endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ /* @@ -49,18 +53,20 @@ static char sccsid[] = "@(#)uuencode.c 8.2 (Berkeley) 4/2/94"; #include <sys/types.h> #include <sys/stat.h> +#include <err.h> #include <stdio.h> +#include <unistd.h> + +void encode __P((void)); +static void usage __P((void)); 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, "") != -1) usage(); @@ -69,11 +75,8 @@ main(argc, argv) 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); - } + if (!freopen(*argv, "r", stdin) || fstat(fileno(stdin), &sb)) + err(1, "%s", *argv); #define RWX (S_IRWXU|S_IRWXG|S_IRWXO) mode = sb.st_mode & RWX; ++argv; @@ -90,10 +93,8 @@ main(argc, argv) (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); - } + if (ferror(stdout)) + errx(1, "write error"); exit(0); } @@ -103,13 +104,14 @@ main(argc, argv) /* * copy from in to out, encoding as you go along. */ +void encode() { register int ch, n; register char *p; char buf[80]; - while (n = fread(buf, 1, 45, stdin)) { + while ((n = fread(buf, 1, 45, stdin))) { ch = ENC(n); if (putchar(ch) == EOF) break; @@ -134,15 +136,14 @@ encode() if (putchar('\n') == EOF) break; } - if (ferror(stdin)) { - (void)fprintf(stderr, "uuencode: read error.\n"); - exit(1); - } + if (ferror(stdin)) + errx(1, "read error"); ch = ENC('\0'); (void)putchar(ch); (void)putchar('\n'); } +static void usage() { (void)fprintf(stderr,"usage: uuencode [infile] remotefile\n"); |
