summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorgahr <gahr@FreeBSD.org>2016-04-14 11:45:52 +0000
committergahr <gahr@FreeBSD.org>2016-04-14 11:45:52 +0000
commit7f331c8ab2ec2a9d2d462dd7410e2e2a0fd6b342 (patch)
tree1f5383b266fcc5e5afa1af94f934b21344c16673 /usr.bin
parent5a7f6237bc082bbf0f2201c869dd48aa735e30b1 (diff)
downloadFreeBSD-src-7f331c8ab2ec2a9d2d462dd7410e2e2a0fd6b342.zip
FreeBSD-src-7f331c8ab2ec2a9d2d462dd7410e2e2a0fd6b342.tar.gz
MFC 297678: 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
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/uuencode/uuencode.14
-rw-r--r--usr.bin/uuencode/uuencode.c18
2 files changed, 17 insertions, 5 deletions
diff --git a/usr.bin/uuencode/uuencode.1 b/usr.bin/uuencode/uuencode.1
index 2c31bdc..9ce7e05 100644
--- a/usr.bin/uuencode/uuencode.1
+++ b/usr.bin/uuencode/uuencode.1
@@ -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
diff --git a/usr.bin/uuencode/uuencode.c b/usr.bin/uuencode/uuencode.c
index def8bcc..500dcd3 100644
--- a/usr.bin/uuencode/uuencode.c
+++ b/usr.bin/uuencode/uuencode.c
@@ -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
OpenPOWER on IntegriCloud