From nobody Sun Apr 24 06:24:25 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id DC9441996C86; Sun, 24 Apr 2022 06:24:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KmJ5P2jnyz3CYw; Sun, 24 Apr 2022 06:24:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650781465; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=bmCd3MdOuICAsHJfoH5tVC+kEBpukpd2wQ/3ygyXACw=; b=d50e+XZOJEEgcw/h90lFHEgXSFYCF1RsMw0KbETZrfZ2jH189TE/a13ULANSnvx08lJtXX S3VtdtDSl7imgSxrdGaeLTfCyPotm76NNSvu79vlDU+3JFapaq5w6LJNKXRXZq2sjpTMYw CxmViNrbRbOFx6mRHIsvyb3YFIw8kMeS9t20AAPxG1Y8oAOJRRwBfi7oD6W7fNWJMJCgWQ g5YZ0Y1m2tVFqwgw/82nlN+0KQoTejOSjAElVn2K7u3vm86zeuHw6mTknqser8qOIe8au8 gB3u0dW46mfQSADyQOC06G/red52/DqLHdYmIVSR60EKVxwJaFDpH8bxbIH7Gw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 338AE20BCF; Sun, 24 Apr 2022 06:24:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 23O6OPZ5043436; Sun, 24 Apr 2022 06:24:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23O6OPxc043435; Sun, 24 Apr 2022 06:24:25 GMT (envelope-from git) Date: Sun, 24 Apr 2022 06:24:25 GMT Message-Id: <202204240624.23O6OPxc043435@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: aad4fd549589 - main - Add a quoted-printable encoder/decoder List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: aad4fd5495895bf1aa501037bb1e5df4e116a018 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650781465; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=bmCd3MdOuICAsHJfoH5tVC+kEBpukpd2wQ/3ygyXACw=; b=VbEa75XVx0Fnftg4ADHX56l4Nx6ghLbydEKNhllTlO+J7d+BId2Cjr7zi1JWxAuldE2Fni P86DHz2QQC0FSupsp0chEBN0IzCA04ITYF1X9ffNZM3W5rPt+ZwNN8+sCWcgQKdVLfAOaQ +C7TjVdLmlLYLSQFY0y2U4AroV4QN4AUtmogG0po2TS4sGV1RcSPyt6OFpY+D590Z/j5d+ cHb6BiagS8W3weOUNIgAJJFzrsdZEbHU6j+wPWEhMI7viEg+0JaSA84qTLJBp7fGm0PQZv 8HSRdqOKAbAPQTig41KhOZUT0zkLPpDOsno6ZWRHNpSuGBJCM9A1Kf1jop0fZg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1650781465; a=rsa-sha256; cv=none; b=mpy8Tv/5tS8XIKK6kFpY+skDcjbhPALZqlis3XGeBZZ1TEt++MOKTaee3TUk41SGjmVcWa 2jawh5EeS8AqFYakcEP/idW/G7KdGmEyGtLW5dNngIE6eElRiWfDQXb23xCx8BdC67QaPD dPL52KQVhMffPKjYZs9lnbuW2RzVP85omcWQmFX19lMz48zcRNV3UfbUOKDoCEGGwRsQeS 1f5c6DOzox24Mmbjhh7BXzr1A3M+QndPZ2cwIkNNhxUfqxjI9h7SVts0ORxsYq+dYqkSHT A7Dc+f/QfpZnqjAPjzI3JRaMqAj0n0T7/VIL31tCrAlG2QabCocjFn1ZRHNA6Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=aad4fd5495895bf1aa501037bb1e5df4e116a018 commit aad4fd5495895bf1aa501037bb1e5df4e116a018 Author: Piotr Pawel Stefaniak AuthorDate: 2022-04-15 13:25:30 +0000 Commit: Piotr Pawel Stefaniak 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 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 ...\n" " %1$s ...\n" - " %1$s ...\n", + " %1$s ...\n" + " %1$s ...\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 #include +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 {