Date: Sun, 24 Apr 2022 06:24:25 GMT From: Piotr Pawel Stefaniak <pstef@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: aad4fd549589 - main - Add a quoted-printable encoder/decoder Message-ID: <202204240624.23O6OPxc043435@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=aad4fd5495895bf1aa501037bb1e5df4e116a018 commit aad4fd5495895bf1aa501037bb1e5df4e116a018 Author: Piotr Pawel Stefaniak <pstef@FreeBSD.org> AuthorDate: 2022-04-15 13:25:30 +0000 Commit: Piotr Pawel Stefaniak <pstef@FreeBSD.org> CommitDate: 2022-04-24 06:20:27 +0000 Add a quoted-printable encoder/decoder As an example: printf 'We don=27t know what to do with other=20worlds.=0D=0A' \ | bintrans qp -u Differential Revision: https://reviews.freebsd.org/D34933 Reviewed by: debdrup (manpage) --- usr.bin/bintrans/Makefile | 2 +- usr.bin/bintrans/bintrans.1 | 13 +++++++++++++ usr.bin/bintrans/bintrans.c | 12 +++++++++--- usr.bin/bintrans/{mmencode.c => quoted-printable.c} | 16 ++++++++++++---- 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/usr.bin/bintrans/Makefile b/usr.bin/bintrans/Makefile index 49acec470d76..a83c820bd660 100644 --- a/usr.bin/bintrans/Makefile +++ b/usr.bin/bintrans/Makefile @@ -4,7 +4,7 @@ .include <src.opts.mk> 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 index f489eb6fc258..24ce553d94e7 100644 --- a/usr.bin/bintrans/bintrans.1 +++ b/usr.bin/bintrans/bintrans.1 @@ -225,6 +225,19 @@ Wrap encoded output after .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 index 435f982ac520..04b3b10d84c8 100644 --- a/usr.bin/bintrans/bintrans.c +++ b/usr.bin/bintrans/bintrans.c @@ -38,6 +38,7 @@ extern int main_decode(int, char *[]); 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 version_base64(void); 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 @@ main(int argc, char *argv[]) case base64: base64_encode_or_decode(argc, argv); break; + case qp: + main_quotedprintable(argc, argv); + break; default: (void)fprintf(stderr, "usage: %1$s <uuencode | uudecode> ...\n" " %1$s <b64encode | b64decode> ...\n" - " %1$s <base64> ...\n", + " %1$s <base64> ...\n" + " %1$s <qp> ...\n", progname); exit(EX_USAGE); } @@ -90,7 +95,8 @@ search(const char *const progname) 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 similarity index 95% rename from usr.bin/bintrans/mmencode.c rename to usr.bin/bintrans/quoted-printable.c index a391f4d7e1d4..b0e35509a2d9 100644 --- a/usr.bin/bintrans/mmencode.c +++ b/usr.bin/bintrans/quoted-printable.c @@ -18,6 +18,8 @@ WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. #include <string.h> #include <ctype.h> +extern int main_quotedprintable(int, char *[]); + static int PendingBoundary(char *s, char **Boundaries, int *BoundaryCt) { @@ -211,8 +213,15 @@ fromqp(FILE *infile, FILE *outfile, char **boundaries, int *boundaryct) } } +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 @@ main(int argc, char *argv[]) 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 @@ main(int argc, char *argv[]) encode = false; break; default: - fprintf(stderr, - "Usage: mmencode [-u] [-o outputfile] [file name]\n"); + usage(); exit(EXIT_FAILURE); } } else {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202204240624.23O6OPxc043435>