/* returns 1 if Mutt can't display this type of data, 0 otherwise */
int rfc1524_mailcap_isneeded(BODY * m)
{
- int tok;
-
switch (m->type) {
case TYPEMULTIPART:
case TYPEMESSAGE:
return !(mutt_is_application_pgp(m) || mutt_is_application_smime(m));
case TYPETEXT:
- tok = mime_which_token(m->subtype, -1);
- if (tok == MIME_PLAIN
- || tok == MIME_RFC822_HEADERS
- || tok == MIME_ENRICHED)
+ switch (mime_which_token(m->subtype, -1)) {
+ case MIME_PLAIN:
+ case MIME_RFC822_HEADERS:
+ case MIME_ENRICHED:
return 0;
- break;
+ default:
+ return 1;
+ }
+ default:
+ return 1;
}
-
- return 1;
}
/* The command semantics include the following:
m_strcpy(type, sizeof(type), mtype);
- if (option(OPTMAILCAPSANITIZE))
+ if (mod_mime.mailcap_sanitize)
mutt_sanitize_filename(type, 0);
while (command[x] && x < clen && y < ssizeof(buf)) {
m_strcpy(pval, sizeof(pval),
parameter_getval(a->parameter, param));
- if (option(OPTMAILCAPSANITIZE))
+ if (mod_mime.mailcap_sanitize)
mutt_sanitize_filename(pval, 0);
y += mutt_quote_filename(buf + y, sizeof(buf) - y, pval);
ssize_t len = m_strlen(value) + STRING;
char *testcmd = p_new(char, len);
- strcpy(testcmd, value);
+ m_strcpy(testcmd, len, value);
rfc1524_expand_command(a, a->filename, type, testcmd, len);
found = !mutt_system(testcmd);
p_delete(&testcmd);
rfc1524_entry_init(entry);
}
} /* while (!found && (buf = mutt_read_line ())) */
- fclose (fp);
+ m_fclose(&fp);
error:
p_delete(&buf);
}
-/************** READ MARK **********************/
-
/*
* rfc1524_mailcap_lookup attempts to find the given type in the
* list of mailcap files. On success, this returns the entry information
* in *entry, and returns 1. On failure (not found), returns 0.
* If entry == NULL just return 1 if the given type is found.
*/
-int rfc1524_mailcap_lookup (BODY * a, char *type, rfc1524_entry * entry,
- int opt)
+int rfc1524_mailcap_lookup(BODY *a, char *type, rfc1524_entry *entry, int opt)
{
- char path[_POSIX_PATH_MAX];
- int x;
- int found = FALSE;
- char *curr = MailcapPath;
-
- /* rfc1524 specifies that a path of mailcap files should be searched.
- * joy. They say
- * $HOME/.mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap, etc
- * and overriden by the MAILCAPS environment variable, and, just to be nice,
- * we'll make it specifiable in .muttrc
- */
- if (!curr || !*curr) {
- mutt_error _("No mailcap path specified");
+ const char *p = mod_mime.mailcap_path;
- return 0;
- }
+ mutt_check_lookup_list(a, type, STRING);
- mutt_check_lookup_list (a, type, SHORT_STRING);
+ for (;;) {
+ const char *q;
+ char path[_POSIX_PATH_MAX];
- while (!found && *curr) {
- x = 0;
- while (*curr && *curr != ':' && x < ssizeof (path) - 1) {
- path[x++] = *curr;
- curr++;
- }
- if (*curr)
- curr++;
+ while (*p == ':')
+ p++;
- if (!x)
- continue;
+ if (!*p)
+ break;
- path[x] = '\0';
- mutt_expand_path (path, sizeof (path));
+ q = strchrnul(p, ':');
+ m_strncpy(path, sizeof(path), p, q - p);
+ mutt_expand_path(path, sizeof(path));
- found = rfc1524_mailcap_parse (a, path, type, entry, opt);
- }
+ if (rfc1524_mailcap_parse(a, path, type, entry, opt))
+ return 1;
- if (entry && !found)
- mutt_error (_("mailcap entry for type %s not found"), type);
+ p = q;
+ }
+
+ if (entry)
+ mutt_error(_("mailcap entry for type %s not found"), type);
- return found;
+ return 0;
}
+/************** READ MARK **********************/
+
/* This routine will create a _temporary_ filename matching the
* name template given if this needs to be done.
m_strcpy(newfile, nflen, oldfile);
}
else if (!oldfile) {
- m_snsubst(newfile, nflen, nametemplate, "mutt");
+ m_file_fmt(newfile, nflen, nametemplate, "mutt");
} else { /* oldfile && nametemplate */