diff --git a/usr.bin/bintrans/Makefile b/usr.bin/bintrans/Makefile --- a/usr.bin/bintrans/Makefile +++ b/usr.bin/bintrans/Makefile @@ -4,7 +4,7 @@ .include PROG= bintrans -SRCS= bintrans.c uuencode.c uudecode.c +SRCS= bintrans.c uuencode.c uudecode.c quoted-printable.c MAN= bintrans.1 uuencode.format.5 LINKS+= ${BINDIR}/bintrans ${BINDIR}/uuencode LINKS+= ${BINDIR}/bintrans ${BINDIR}/b64encode diff --git a/usr.bin/bintrans/bintrans.1 b/usr.bin/bintrans/bintrans.1 --- a/usr.bin/bintrans/bintrans.1 +++ b/usr.bin/bintrans/bintrans.1 @@ -225,6 +225,19 @@ .Nm is a generic utility that can run any of the aforementioned encoders and decoders. +It can also run algorithms that are not available +through a dedicated program: +.Pp +.Nm qp +is a quoted-printable converter +and accepts the following options: +.Bl -tag -width ident +.It Fl u +Decode. +.It Fl o Ar output_file +Output to +.Ar output_file +instead of standard output. .Sh EXAMPLES The following example packages up a source tree, compresses it, uuencodes it and mails it to a user on another system. diff --git a/usr.bin/bintrans/bintrans.c b/usr.bin/bintrans/bintrans.c --- a/usr.bin/bintrans/bintrans.c +++ b/usr.bin/bintrans/bintrans.c @@ -38,6 +38,7 @@ extern int main_encode(int, char *[]); extern int main_base64_decode(const char *); extern int main_base64_encode(const char *, const char *); +extern int main_quotedprintable(int, char*[]); static int search(const char *const); static void usage_base64(bool); @@ -45,7 +46,7 @@ static void base64_encode_or_decode(int, char *[]); enum coders { - uuencode, uudecode, b64encode, b64decode, base64 + uuencode, uudecode, b64encode, b64decode, base64, qp }; int @@ -71,11 +72,15 @@ case base64: base64_encode_or_decode(argc, argv); break; + case qp: + main_quotedprintable(argc, argv); + break; default: (void)fprintf(stderr, "usage: %1$s ...\n" " %1$s ...\n" - " %1$s ...\n", + " %1$s ...\n" + " %1$s ...\n", progname); exit(EX_USAGE); } @@ -90,7 +95,8 @@ DESIGNATE(uudecode), DESIGNATE(b64encode), DESIGNATE(b64decode), - DESIGNATE(base64) + DESIGNATE(base64), + DESIGNATE(qp) }; for (size_t i = 0; i < nitems(known); i++) diff --git a/usr.bin/bintrans/mmencode.c b/usr.bin/bintrans/quoted-printable.c rename from usr.bin/bintrans/mmencode.c rename to usr.bin/bintrans/quoted-printable.c --- a/usr.bin/bintrans/mmencode.c +++ b/usr.bin/bintrans/quoted-printable.c @@ -18,6 +18,8 @@ #include #include +extern int main_quotedprintable(int, char *[]); + static int PendingBoundary(char *s, char **Boundaries, int *BoundaryCt) { @@ -211,8 +213,15 @@ } } +static void +usage(void) +{ + fprintf(stderr, + "usage: bintrans qp [-u] [-o outputfile] [file name]\n"); +} + int -main(int argc, char *argv[]) +main_quotedprintable(int argc, char *argv[]) { int i; bool encode = true; @@ -224,7 +233,7 @@ switch (argv[i][1]) { case 'o': if (++i >= argc) { - fprintf(stderr, "mimencode: -o requires a file name.\n"); + fprintf(stderr, "qp: -o requires a file name.\n"); exit(EXIT_FAILURE); } fpo = fopen(argv[i], "w"); @@ -237,8 +246,7 @@ encode = false; break; default: - fprintf(stderr, - "Usage: mmencode [-u] [-o outputfile] [file name]\n"); + usage(); exit(EXIT_FAILURE); } } else {