From c69fe3b51d7d17095a844febf593cab057966960 Mon Sep 17 00:00:00 2001 From: Kiyoshi Aman Date: Sat, 22 Jun 2019 02:50:44 -0500 Subject: usr.bin/uuencode: make buildable with libbsd, drop non-POSIX base64 support --- usr.bin/uuencode/uuencode.c | 73 ++++----------------------------------------- 1 file changed, 6 insertions(+), 67 deletions(-) diff --git a/usr.bin/uuencode/uuencode.c b/usr.bin/uuencode/uuencode.c index 50b7051..ac104cd 100644 --- a/usr.bin/uuencode/uuencode.c +++ b/usr.bin/uuencode/uuencode.c @@ -29,20 +29,6 @@ * SUCH DAMAGE. */ -#include -#ifndef lint -__COPYRIGHT("@(#) Copyright (c) 1983, 1993\ - The Regents of the University of California. All rights reserved."); -#endif /* not lint */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)uuencode.c 8.2 (Berkeley) 4/2/94"; -#else -__RCSID("$NetBSD: uuencode.c,v 1.16 2014/09/06 18:58:35 dholland Exp $"); -#endif -#endif /* not lint */ - /* * uuencode [input] output * @@ -56,13 +42,12 @@ __RCSID("$NetBSD: uuencode.c,v 1.16 2014/09/06 18:58:35 dholland Exp $"); #include #include #include -#include +#include #include #include static void encode(void); -static void base64_encode(void); -__dead static void usage(void); +static void usage(void); int main(int argc, char *argv[]) @@ -75,18 +60,6 @@ main(int argc, char *argv[]) setlocale(LC_ALL, ""); setprogname(argv[0]); - while ((ch = getopt(argc, argv, "m")) != -1) { - switch(ch) { - case 'm': - base64 = 1; - break; - default: - usage(); - } - } - argv += optind; - argc -= optind; - switch(argc) { case 2: /* optional first argument is input file */ if (!freopen(*argv, "r", stdin) || fstat(fileno(stdin), &sb)) @@ -104,15 +77,9 @@ main(int argc, char *argv[]) usage(); } - if (base64) { - (void)printf("begin-base64 %o %s\n", mode, *argv); - base64_encode(); - (void)printf("====\n"); - } else { - (void)printf("begin %o %s\n", mode, *argv); - encode(); - (void)printf("end\n"); - } + (void)printf("begin %o %s\n", mode, *argv); + encode(); + (void)printf("end\n"); if (ferror(stdout)) err(1, "write error"); @@ -122,34 +89,6 @@ main(int argc, char *argv[]) /* 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 in base64 as you go along. - */ -static void -base64_encode(void) -{ - /* - * Output must fit into 80 columns, chunks come in 4, leave 1. - */ -#define GROUPS ((70 / 4) - 1) - unsigned char buf[3]; - char buf2[sizeof(buf) * 2 + 1]; - size_t n; - int rv, sequence; - - sequence = 0; - - while ((n = fread(buf, 1, sizeof(buf), stdin))) { - ++sequence; - rv = b64_ntop(buf, n, buf2, (sizeof(buf2) / sizeof(buf2[0]))); - if (rv == -1) - errx(1, "b64_ntop: error encoding base64"); - printf("%s%s", buf2, (sequence % GROUPS) ? "" : "\n"); - } - if (sequence % GROUPS) - printf("\n"); -} - /* * copy from in to out, encoding as you go along. */ @@ -196,7 +135,7 @@ static void usage(void) { (void)fprintf(stderr, - "usage: %s [-m] [inputfile] headername > encodedfile\n", + "usage: %s [inputfile] headername > encodedfile\n", getprogname()); exit(1); } -- cgit v1.2.3-60-g2f50