#include <h/fmt_scan.h>
#include <h/mime.h>
#include <h/mhparse.h>
+#include "h/done.h"
#include <h/utils.h>
-#include "../sbr/m_mktemp.h"
-#include "../sbr/message_id.h"
-#include "../sbr/mime_type.h"
+#include "h/mhcachesbr.h"
+#include "mhmisc.h"
+#include "sbr/m_mktemp.h"
+#include "sbr/message_id.h"
+#include "sbr/mime_type.h"
#include "mhfree.h"
#include "mhshowsbr.h"
} convert_list;
-/* mhmisc.c */
-void content_error (char *, CT, char *, ...);
-
-/* mhcachesbr.c */
-int find_cache (CT, int, int *, char *, char *, int);
-
/*
* static prototypes
*/
attach_head = attach_tail = entry;
}
} else if (strncasecmp(MHBUILD_FILE_PSEUDOHEADER, np,
- strlen (MHBUILD_FILE_PSEUDOHEADER)) == 0) {
+ LEN(MHBUILD_FILE_PSEUDOHEADER)) == 0) {
/* E.g.,
* Nmh-mhbuild-file-text/calendar: /home/user/Mail/inbox/9
*/
- char *type = np + strlen (MHBUILD_FILE_PSEUDOHEADER);
+ char *type = np + LEN(MHBUILD_FILE_PSEUDOHEADER);
char *filename = vp;
/* vp should begin with a space because m_getfld2()
free (vp);
free (np);
} else if (strncasecmp(MHBUILD_ARGS_PSEUDOHEADER, np,
- strlen (MHBUILD_ARGS_PSEUDOHEADER)) == 0) {
+ LEN(MHBUILD_ARGS_PSEUDOHEADER)) == 0) {
/* E.g.,
* Nmh-mhbuild-args-text/calendar: -reply accept
*/
- char *type = np + strlen (MHBUILD_ARGS_PSEUDOHEADER);
+ char *type = np + LEN(MHBUILD_ARGS_PSEUDOHEADER);
char *argstring = vp;
/* vp should begin with a space because m_getfld2()
CT *ctp;
convert_list *next;
- done = freects_done;
+ set_done(freects_done);
/* In case there are multiple calls that land here, prevent leak. */
for (ctp = cts; ctp && *ctp; ++ctp) { free_content (*ctp); }
ct->c_ceclosefnx = close_encoding;
ct->c_cesizefnx = NULL; /* since unencoded */
ct->c_encoding = CE_7BIT; /* Seems like a reasonable default */
- ct->c_file = add(filename, NULL);
+ ct->c_file = mh_xstrdup(FENDNULL(filename));
return OK;
}
int i;
if (headers >= 0 && do_direct() && uprf (buffer, DESCR_FIELD)
- && buffer[i = strlen (DESCR_FIELD)] == ':') {
+ && buffer[i = LEN(DESCR_FIELD)] == ':') {
headers = 1;
again_descr:
}
if (headers >= 0 && do_direct() && uprf (buffer, DISPO_FIELD)
- && buffer[i = strlen (DISPO_FIELD)] == ':') {
+ && buffer[i = LEN(DISPO_FIELD)] == ':') {
headers = 1;
again_dispo:
default:
if (!ce->ce_file) {
pid_t child_id;
- int i, xstdout, len, buflen;
+ int xstdout, len, buflen;
char *bp, *cp;
char *vec[4], buffer[BUFSIZ];
FILE *out;
if ((out = fopen (ce->ce_file, "w")) == NULL)
adios (ce->ce_file, "unable to open for writing");
- for (i = 0; (child_id = fork()) == NOTOK && i > 5; i++)
- sleep (5);
+ child_id = fork();
switch (child_id) {
case NOTOK:
adios ("fork", "unable to fork");
execvp ("/bin/sh", vec);
fprintf (stderr, "unable to exec ");
perror ("/bin/sh");
- _exit (-1);
+ _exit(1);
/* NOTREACHED */
default:
}
}
- return (boundaryclash ? NOTOK : OK);
+ return boundaryclash ? NOTOK : OK;
}
vp = concat (" ", ci->ci_type, "/", ci->ci_subtype, NULL);
/* keep track of length of line */
- len = strlen (TYPE_FIELD) + strlen (ci->ci_type)
+ len = LEN(TYPE_FIELD) + strlen (ci->ci_type)
+ strlen (ci->ci_subtype) + 3;
extbody = ct->c_type == CT_MESSAGE && ct->c_subtype == MESSAGE_EXTERNAL;
add_header (ct, np, vp);
} else if (ct->c_dispo_type) {
vp = concat (" ", ct->c_dispo_type, NULL);
- len = strlen(DISPO_FIELD) + strlen(vp) + 1;
+ len = LEN(DISPO_FIELD) + strlen(vp) + 1;
np = output_params(len, ct->c_dispo_first, NULL, 0);
vp = add(np, vp);
vp = add("\n", vp);
- mh_xfree(np);
+ free(np);
add_header (ct, mh_xstrdup(DISPO_FIELD), vp);
}
for (pm = ct->c_ctinfo.ci_first_pm; pm; pm = pm->pm_next) {
if (strcasecmp(pm->pm_name, "name") == 0) {
- mh_xfree(pm->pm_value);
+ free(pm->pm_value);
pm->pm_value = mh_xstrdup(simplename);
break;
}
init_decoded_content (reply_ct, infile);
if (extract_headers (reply_ct, reply_file, &reply_fp) == NOTOK) {
- free (reply_file);
inform("failed to extract headers from convert output in %s, "
"continuing...", reply_file);
+ free(reply_file);
return;
}
buffer[statbuf.st_size] = '\0';
/* Look for a header in the convert reply. */
- if (strncasecmp (buffer, TYPE_FIELD, strlen (TYPE_FIELD)) == 0 &&
- buffer[strlen (TYPE_FIELD)] == ':') {
+ if (strncasecmp (buffer, TYPE_FIELD, LEN(TYPE_FIELD)) == 0 &&
+ buffer[LEN(TYPE_FIELD)] == ':') {
if ((end_of_header = strstr (buffer, "\r\n\r\n"))) {
end_of_header += 2;
found_header = 1;
CT tmp_ct;
char *tmp_file;
FILE *tmp_f;
- size_t n;
+ size_t n, written;
/* Truncate buffer to just the C-T. */
*end_of_header = '\0';
/* Hack. Use parse_mime() to detect the type/subtype of the
reply, which we'll use below. */
tmp_file = getcpy (m_mktemp2 (NULL, invo_name, NULL, NULL));
- if ((tmp_f = fopen (tmp_file, "w")) &&
- fwrite (buffer, 1, n, tmp_f) == n) {
- fclose (tmp_f);
- } else {
+ tmp_f = fopen(tmp_file, "w");
+ if (!tmp_f)
+ goto failed_to_extract_ct;
+ written = fwrite(buffer, 1, n, tmp_f);
+ fclose(tmp_f);
+ if (written != n)
goto failed_to_extract_ct;
- }
- tmp_ct = parse_mime (tmp_file);
+ tmp_ct = parse_mime (tmp_file);
if (tmp_ct) {
/* The type and subtype were detected from the reply
using parse_mime() above. */