* mhparse.c -- routines to parse the contents of MIME messages
*
* $Id$
+ *
+ * This code is Copyright (c) 2002, by the authors of nmh. See the
+ * COPYRIGHT file in the root directory of the nmh distribution for
+ * complete copyright information.
*/
#include <h/mh.h>
#include <errno.h>
#include <setjmp.h>
#include <signal.h>
-#include <zotnet/mts/mts.h>
-#include <zotnet/tws/tws.h>
+#include <h/mts.h>
+#include <h/tws.h>
#include <h/mime.h>
#include <h/mhparse.h>
+#include <h/utils.h>
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif
-extern int errno;
extern int debugsw;
extern int endian; /* mhmisc.c */
{ "quoted-printable", CE_QUOTED, InitQuoted },
{ "8bit", CE_8BIT, Init7Bit },
{ "7bit", CE_7BIT, Init7Bit },
- { "binary", CE_BINARY, NULL },
+ { "binary", CE_BINARY, Init7Bit },
{ NULL, CE_EXTENSION, NULL }, /* these two must be last! */
{ NULL, CE_UNKNOWN, NULL },
};
if (!(ct = get_content (fp, file, 1))) {
if (is_stdin)
unlink (file);
- fclose (fp);
advise (NULL, "unable to decode %s", file);
return NULL;
}
* toplevel = 0 # we are inside message type or multipart type
* # other than multipart/digest
* toplevel = -1 # we are inside multipart/digest
+ * NB: on failure we will fclose(in)!
*/
static CT
HF hp;
/* allocate header field structure */
- if (!(hp = malloc (sizeof(*hp))))
- adios (NULL, "out of memory");
+ hp = mh_xmalloc (sizeof(*hp));
/* link data into header structure */
hp->name = name;
* Check for "boundary" parameter, which is
* required for multipart messages.
*/
+ bp = 0;
for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) {
if (!strcasecmp (*ap, "boundary")) {
bp = *ep;
if (!(p = get_content (fp, ct->c_file,
ct->c_subtype == MULTI_DIGEST ? -1 : 0))) {
- fclose (ct->c_fp);
ct->c_fp = NULL;
return NOTOK;
}
fseek (fp = ct->c_fp, ct->c_begin, SEEK_SET);
if (!(p = get_content (fp, ct->c_file, 0))) {
- fclose (ct->c_fp);
ct->c_fp = NULL;
return NOTOK;
}
goto no_body;
}
- if ((e->eb_body = bp = malloc ((unsigned) size)) == NULL)
- adios (NULL, "out of memory");
+ e->eb_body = bp = mh_xmalloc ((unsigned) size);
fseek (p->c_fp, p->c_begin, SEEK_SET);
while (size > 0)
switch (cc = fread (bp, sizeof(*bp), size, p->c_fp)) {
unsigned long bits;
unsigned char value, *b, *b1, *b2, *b3;
char *cp, *ep, buffer[BUFSIZ];
+ /* sbeck -- handle prefixes */
+ CI ci;
CE ce;
MD5_CTX mdContext;
ce->ce_unlink = 0;
}
+ /* sbeck@cise.ufl.edu -- handle suffixes */
+ ci = &ct->c_ctinfo;
+ snprintf (buffer, sizeof(buffer), "%s-suffix-%s/%s",
+ invo_name, ci->ci_type, ci->ci_subtype);
+ cp = context_find (buffer);
+ if (cp == NULL || *cp == '\0') {
+ snprintf (buffer, sizeof(buffer), "%s-suffix-%s", invo_name,
+ ci->ci_type);
+ cp = context_find (buffer);
+ }
+ if (cp != NULL && *cp != '\0')
+ ce->ce_file = add (cp, ce->ce_file);
+
if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) {
content_error (ce->ce_file, ct, "unable to fopen for reading/writing");
return NOTOK;
char buffer[BUFSIZ];
unsigned char mask;
CE ce;
+ /* sbeck -- handle prefixes */
+ CI ci;
MD5_CTX mdContext;
ce = ct->c_cefile;
ce->ce_unlink = 0;
}
+ /* sbeck@cise.ufl.edu -- handle suffixes */
+ ci = &ct->c_ctinfo;
+ snprintf (buffer, sizeof(buffer), "%s-suffix-%s/%s",
+ invo_name, ci->ci_type, ci->ci_subtype);
+ cp = context_find (buffer);
+ if (cp == NULL || *cp == '\0') {
+ snprintf (buffer, sizeof(buffer), "%s-suffix-%s", invo_name,
+ ci->ci_type);
+ cp = context_find (buffer);
+ }
+ if (cp != NULL && *cp != '\0')
+ ce->ce_file = add (cp, ce->ce_file);
+
+ if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) {
+ content_error (ce->ce_file, ct, "unable to fopen for reading/writing");
+ return NOTOK;
+ }
+
if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) {
content_error (ce->ce_file, ct, "unable to fopen for reading/writing");
return NOTOK;
{
int cc, fd, len;
char buffer[BUFSIZ];
+ /* sbeck -- handle prefixes */
+ char *cp;
+ CI ci;
CE ce;
ce = ct->c_cefile;
ce->ce_unlink = 0;
}
+ /* sbeck@cise.ufl.edu -- handle suffixes */
+ ci = &ct->c_ctinfo;
+ snprintf (buffer, sizeof(buffer), "%s-suffix-%s/%s",
+ invo_name, ci->ci_type, ci->ci_subtype);
+ cp = context_find (buffer);
+ if (cp == NULL || *cp == '\0') {
+ snprintf (buffer, sizeof(buffer), "%s-suffix-%s", invo_name,
+ ci->ci_type);
+ cp = context_find (buffer);
+ }
+ if (cp != NULL && *cp != '\0')
+ ce->ce_file = add (cp, ce->ce_file);
+
if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) {
content_error (ce->ce_file, ct, "unable to fopen for reading/writing");
return NOTOK;