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)
This commit is contained in:
parent
ff2b1ffbb0
commit
aad4fd5495
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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++)
|
||||
|
@ -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 {
|
Loading…
Reference in New Issue
Block a user