From owner-svn-src-all@freebsd.org Thu Apr 7 16:12:40 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 339BFB07278; Thu, 7 Apr 2016 16:12:40 +0000 (UTC) (envelope-from gahr@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E8F0516E6; Thu, 7 Apr 2016 16:12:39 +0000 (UTC) (envelope-from gahr@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u37GCdl4037315; Thu, 7 Apr 2016 16:12:39 GMT (envelope-from gahr@FreeBSD.org) Received: (from gahr@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u37GCdn1037313; Thu, 7 Apr 2016 16:12:39 GMT (envelope-from gahr@FreeBSD.org) Message-Id: <201604071612.u37GCdn1037313@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gahr set sender to gahr@FreeBSD.org using -f From: Pietro Cerutti Date: Thu, 7 Apr 2016 16:12:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r297678 - head/usr.bin/uuencode X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Apr 2016 16:12:40 -0000 Author: gahr (ports committer) Date: Thu Apr 7 16:12:38 2016 New Revision: 297678 URL: https://svnweb.freebsd.org/changeset/base/297678 Log: Enhance uuencode with a -r option to produce raw output. This matches with uudecode's -r option to decode raw data without initial and final framing lines. $ echo Test | uuencode -mr - | uudecode -mr Test Approved by: cognet MFC after: 1 week Modified: head/usr.bin/uuencode/uuencode.1 head/usr.bin/uuencode/uuencode.c Modified: head/usr.bin/uuencode/uuencode.1 ============================================================================== --- head/usr.bin/uuencode/uuencode.1 Thu Apr 7 15:26:12 2016 (r297677) +++ head/usr.bin/uuencode/uuencode.1 Thu Apr 7 16:12:38 2016 (r297678) @@ -40,6 +40,7 @@ .Sh SYNOPSIS .Nm .Op Fl m +.Op Fl r .Op Fl o Ar output_file .Op Ar file .Ar name @@ -50,6 +51,7 @@ .Op Fl i .Fl o Ar output_file .Nm b64encode +.Op Fl r .Op Fl o Ar output_file .Op Ar file .Ar name @@ -123,6 +125,8 @@ The following options are available for Use the Base64 method of encoding, rather than the traditional .Nm algorithm. +.It Fl r +Produce raw output by excluding the initial and final framing lines. .It Fl o Ar output_file Output to .Ar output_file Modified: head/usr.bin/uuencode/uuencode.c ============================================================================== --- head/usr.bin/uuencode/uuencode.c Thu Apr 7 15:26:12 2016 (r297677) +++ head/usr.bin/uuencode/uuencode.c Thu Apr 7 16:12:38 2016 (r297678) @@ -66,6 +66,7 @@ static void usage(void); static FILE *output; static int mode; +static char raw = 0; static char **av; int @@ -82,7 +83,7 @@ main(int argc, char *argv[]) if (strcmp(basename(argv[0]), "b64encode") == 0) base64 = 1; - while ((ch = getopt(argc, argv, "mo:")) != -1) { + while ((ch = getopt(argc, argv, "mo:r")) != -1) { switch (ch) { case 'm': base64 = 1; @@ -90,6 +91,9 @@ main(int argc, char *argv[]) case 'o': outfile = optarg; break; + case 'r': + raw = 1; + break; case '?': default: usage(); @@ -152,7 +156,8 @@ base64_encode(void) sequence = 0; - fprintf(output, "begin-base64 %o %s\n", mode, *av); + if (!raw) + fprintf(output, "begin-base64 %o %s\n", mode, *av); while ((n = fread(buf, 1, sizeof(buf), stdin))) { ++sequence; rv = b64_ntop(buf, n, buf2, (sizeof(buf2) / sizeof(buf2[0]))); @@ -162,7 +167,8 @@ base64_encode(void) } if (sequence % GROUPS) fprintf(output, "\n"); - fprintf(output, "====\n"); + if (!raw) + fprintf(output, "====\n"); } /* @@ -175,7 +181,8 @@ encode(void) register char *p; char buf[80]; - (void)fprintf(output, "begin %o %s\n", mode, *av); + if (!raw) + (void)fprintf(output, "begin %o %s\n", mode, *av); while ((n = fread(buf, 1, 45, stdin))) { ch = ENC(n); if (fputc(ch, output) == EOF) @@ -209,7 +216,8 @@ encode(void) } if (ferror(stdin)) errx(1, "read error"); - (void)fprintf(output, "%c\nend\n", ENC('\0')); + if (!raw) + (void)fprintf(output, "%c\nend\n", ENC('\0')); } static void