*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
X("norfc934mode", 0, NRFC934SW) \
X("verbose", 0, VERBSW) \
X("noverbose", 0, NVERBSW) \
X("norfc934mode", 0, NRFC934SW) \
X("verbose", 0, VERBSW) \
X("noverbose", 0, NVERBSW) \
X("rcache policy", 0, RCACHESW) \
X("wcache policy", 0, WCACHESW) \
X("contentid", 0, CONTENTIDSW) \
X("nocontentid", 0, NCONTENTIDSW) \
X("headerencoding encoding-algorithm", 0, HEADERENCSW) \
X("autoheaderencoding", 0, AUTOHEADERENCSW) \
X("rcache policy", 0, RCACHESW) \
X("wcache policy", 0, WCACHESW) \
X("contentid", 0, CONTENTIDSW) \
X("nocontentid", 0, NCONTENTIDSW) \
X("headerencoding encoding-algorithm", 0, HEADERENCSW) \
X("autoheaderencoding", 0, AUTOHEADERENCSW) \
X("version", 0, VERSIONSW) \
X("help", 0, HELPSW) \
X("debug", -5, DEBUGSW) \
X("version", 0, VERSIONSW) \
X("help", 0, HELPSW) \
X("debug", -5, DEBUGSW) \
#define X(sw, minchars, id) id,
DEFINE_SWITCH_ENUM(MHBUILD);
#define X(sw, minchars, id) id,
DEFINE_SWITCH_ENUM(MHBUILD);
#define MIMEENCODING_SWITCHES \
X("base64", 0, BASE64SW) \
X("quoted-printable", 0, QUOTEDPRINTSW) \
#define MIMEENCODING_SWITCHES \
X("base64", 0, BASE64SW) \
X("quoted-printable", 0, QUOTEDPRINTSW) \
#define X(sw, minchars, id) id,
DEFINE_SWITCH_ENUM(MIMEENCODING);
#define X(sw, minchars, id) id,
DEFINE_SWITCH_ENUM(MIMEENCODING);
-/* mhbuildsbr.c */
-int output_message (CT, char *);
-int output_message_fp (CT, FILE *, char*);
-
-/* mhlistsbr.c */
-int list_all_messages (CT *, int, int, int, int);
-
- int sizesw = 1, headsw = 1, directives = 1, autobuild = 0;
+ int sizesw = 1, headsw = 1, directives = 1, autobuild = 0, dist = 0;
+ int verbosw = 0, dispo = 0;
+ size_t maxunencoded = MAXTEXTPERLN;
arguments = getarguments (invo_name, argc, argv, 1);
argp = arguments;
arguments = getarguments (invo_name, argc, argv, 1);
argp = arguments;
do_cache: ;
if (!(cp = *argp++) || *cp == '-')
adios (NULL, "missing argument to %s", argp[-2]);
do_cache: ;
if (!(cp = *argp++) || *cp == '-')
adios (NULL, "missing argument to %s", argp[-2]);
+ case MAXUNENCSW:
+ if (!(cp = *argp++) || *cp == '-')
+ adios (NULL, "missing argument to %s", argp[-2]);
+ if ((maxunencoded = atoi(cp)) < 1)
+ adios (NULL, "Invalid argument for %s: %s", argp[-2], cp);
+ if (maxunencoded > 998)
+ adios (NULL, "limit of -maxunencoded is 998");
+ continue;
+
+ if ((cp = m_mktemp2(NULL, invo_name, NULL, &fp)) == NULL) {
+ adios(NULL, "unable to create temporary file in %s",
+ get_temp_dir());
+ }
+
+ /* save a copy of the name for later removal */
+ strncpy (infile, cp, sizeof(infile));
+ unlink_infile = 1;
+
- strncpy (infile, m_mktemp(invo_name, NULL, &fp), sizeof(infile));
- while (fgets (buffer, BUFSIZ, stdin))
- fputs (buffer, fp);
+ while ((n = fread(buffer, 1, sizeof(buffer), stdin)) > 0) {
+ if (fwrite(buffer, 1, n, fp) != n) {
+ adios (NULL, "error copying to temporary file");
+ }
+ }
- ct = build_mime (infile, autobuild, directives, header_encoding);
+ ct = build_mime (infile, autobuild, dist, directives, header_encoding,
+ maxunencoded, verbosw);
if (! (fp = fopen(infile, "r"))) {
adios(NULL, "Unable to open %s for reading", infile);
}
if (! (fp = fopen(infile, "r"))) {
adios(NULL, "Unable to open %s for reading", infile);
}
- while (fgets(buffer, BUFSIZ, fp))
- fputs(buffer, stdout);
+ while ((n = fread(buffer, 1, sizeof(buffer), fp)) > 0) {
+ if (fwrite(buffer, 1, n, stdout) != n) {
+ adios(NULL, "error copying %s to stdout", infile);
+ }
+ }
- ct = build_mime (compfile, autobuild, directives, header_encoding);
+ ct = build_mime (compfile, autobuild, dist, directives, header_encoding,
+ maxunencoded, verbosw);
- strncpy(outfile, m_mktemp2(compfile, invo_name, NULL, &fp_out),
- sizeof(outfile));
+ if ((cp = m_mktemp2(compfile, invo_name, NULL, &fp_out)) == NULL) {
+ adios(NULL, "unable to create temporary file in %s", get_temp_dir());
+ }
+ strncpy(outfile, cp, sizeof(outfile));
- list_all_messages (cts, headsw, sizesw, verbosw, debugsw);
+ list_all_messages (cts, headsw, sizesw, verbosw, debugsw, dispo);
/* Rename composition draft */
snprintf (buffer, sizeof(buffer), "%s.orig", m_backup (compfile));
/* Rename composition draft */
snprintf (buffer, sizeof(buffer), "%s.orig", m_backup (compfile));