#include <h/fmt_scan.h>
#include <h/mime.h>
#include <h/mhparse.h>
+#include "h/done.h"
#include <h/utils.h>
#include <h/signals.h>
#include "sbr/m_maildir.h"
fx.lf_line_endings = 0;
fx.textcharset = NULL;
- if (nmh_init(argv[0], 2)) { return 1; }
+ if (nmh_init(argv[0], true, false)) { return 1; }
arguments = getarguments (invo_name, argc, argv, 1);
argp = arguments;
ambigsw (cp, switches);
done (1);
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ die("-%s unknown", cp);
case HELPSW:
snprintf (buf, sizeof buf, "%s [+folder] [msgs] [switches]",
case DECODETEXTSW:
if (! (cp = *argp++) || *cp == '-') {
- adios (NULL, "missing argument to %s", argp[-2]);
+ die("missing argument to %s", argp[-2]);
}
if (! strcasecmp (cp, "8bit")) {
fx.decodetext = CE_8BIT;
} else if (! strcasecmp (cp, "binary")) {
fx.decodetext = CE_BINARY;
} else {
- adios (NULL, "invalid argument to %s", argp[-2]);
+ die("invalid argument to %s", argp[-2]);
}
continue;
case NDECODETEXTSW:
continue;
case DECODETYPESW:
if (! (cp = *argp++) || *cp == '-') {
- adios (NULL, "missing argument to %s", argp[-2]);
+ die("missing argument to %s", argp[-2]);
}
fx.decodetypes = cp;
continue;
continue;
case TEXTCHARSETSW:
if (! (cp = *argp++) || (*cp == '-' && cp[1])) {
- adios (NULL, "missing argument to %s", argp[-2]);
+ die("missing argument to %s", argp[-2]);
}
fx.textcharset = cp;
continue;
continue;
case FIXTYPESW:
if (! (cp = *argp++) || (*cp == '-' && cp[1])) {
- adios (NULL, "missing argument to %s", argp[-2]);
+ die("missing argument to %s", argp[-2]);
}
if (! strncasecmp (cp, "multipart/", 10) ||
! strncasecmp (cp, "message/", 8))
- adios (NULL, "-fixtype %s not allowed", cp);
+ die("-fixtype %s not allowed", cp);
if (! strchr (cp, '/'))
- adios (NULL, "-fixtype requires type/subtype");
+ die("-fixtype requires type/subtype");
if (fx.fixtypes == NULL) { fx.fixtypes = svector_create (10); }
svector_push_back (fx.fixtypes, cp);
continue;
continue;
case FILESW:
if (! (cp = *argp++) || (*cp == '-' && cp[1])) {
- adios (NULL, "missing argument to %s", argp[-2]);
+ die("missing argument to %s", argp[-2]);
}
file = *cp == '-' ? mh_xstrdup (cp) : path (cp, TFILE);
continue;
case OUTFILESW:
if (! (cp = *argp++) || (*cp == '-' && cp[1])) {
- adios (NULL, "missing argument to %s", argp[-2]);
+ die("missing argument to %s", argp[-2]);
}
outfile = *cp == '-' ? mh_xstrdup (cp) : path (cp, TFILE);
continue;
case RPROCSW:
if (!(rmmproc = *argp++) || *rmmproc == '-') {
- adios (NULL, "missing argument to %s", argp[-2]);
+ die("missing argument to %s", argp[-2]);
}
continue;
case NRPRCSW:
}
if (*cp == '+' || *cp == '@') {
if (folder)
- adios (NULL, "only one folder at a time!");
+ die("only one folder at a time!");
folder = pluspath (cp);
} else {
if (*cp == '/') {
}
if (file && msgs.size) {
- adios (NULL, "cannot specify msg and file at same time!");
+ die("cannot specify msg and file at same time!");
}
if (outfile) {
using_stdin = 1;
if ((cp = m_mktemp2 (NULL, invo_name, &fd, NULL)) == NULL) {
- adios (NULL, "unable to create temporary file in %s",
+ die("unable to create temporary file in %s",
get_temp_dir());
} else {
free (file);
if (close (fd)) {
(void) m_unlink (file);
- adios (NULL, "failed to write temporary file");
+ die("failed to write temporary file");
}
}
/* read folder and create message structure */
if (! (mp = folder_read (folder, 1))) {
- adios (NULL, "unable to read folder %s", folder);
+ die("unable to read folder %s", folder);
}
/* check for empty folder */
if (mp->nummsg == 0) {
- adios (NULL, "no messages in %s", folder);
+ die("no messages in %s", folder);
}
/* parse all the message ranges/sequences and set SELECTED */
/* outfp will be closed by the caller */
if ((tempfile = m_mktemp2 (NULL, invo_name, NULL, outfp)) ==
NULL) {
- adios (NULL, "unable to create temporary file in %s",
+ die("unable to create temporary file in %s",
get_temp_dir());
}
outfile = mh_xstrdup (tempfile);
} else {
- adios (NULL, "missing both input and output filenames\n");
+ die("missing both input and output filenames\n");
}
} /* else *outfp was defined by caller */
char *tempfile;
if ((tempfile = m_mktemp2 (NULL, invo_name, NULL, &file)) == NULL) {
- adios (NULL, "unable to create temporary file in %s", get_temp_dir());
+ die("unable to create temporary file in %s", get_temp_dir());
}
tmp_decoded = mh_xstrdup (tempfile);
/* The following call will load ct->c_cefile.ce_file with the tmp
char *tempfile = m_mktemp2 (NULL, invo_name, &fd, NULL);
if (tempfile == NULL) {
- adios (NULL, "unable to create temporary file in %s",
+ die("unable to create temporary file in %s",
get_temp_dir());
}
stripped_content_file = mh_xstrdup (tempfile);
inform("unable to write temporary file %s, continuing...",
stripped_content_file);
(void) m_unlink (stripped_content_file);
+ free(stripped_content_file);
status = NOTOK;
} else {
/* Replace the decoded file with the converted one. */