summaryrefslogtreecommitdiffstats
path: root/usr.bin/uuencode
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>1997-08-22 06:53:00 +0000
committercharnier <charnier@FreeBSD.org>1997-08-22 06:53:00 +0000
commit40cf595fb5675823958d29e99fee92778d3a7f2d (patch)
tree5415ac54c30e751297987f524b4bc6e51ecb3a1e /usr.bin/uuencode
parenteaef13799223de597ae84443bde1bd6a34701550 (diff)
downloadFreeBSD-src-40cf595fb5675823958d29e99fee92778d3a7f2d.zip
FreeBSD-src-40cf595fb5675823958d29e99fee92778d3a7f2d.tar.gz
Use err(3).
Diffstat (limited to 'usr.bin/uuencode')
-rw-r--r--usr.bin/uuencode/uuencode.110
-rw-r--r--usr.bin/uuencode/uuencode.c37
2 files changed, 25 insertions, 22 deletions
diff --git a/usr.bin/uuencode/uuencode.1 b/usr.bin/uuencode/uuencode.1
index 3dd1e68..fd194aa 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 8580624..b10a524 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");
OpenPOWER on IntegriCloud