X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-mime%2Frfc1524.c;h=422a82d23e2e5647adfa6d3812382a9c2a1db704;hp=8705ace47650fc5543f2b4cc49a047eee550b257;hb=cfd5f411041c7ef44087b032751792fadc74586d;hpb=f3cbb9f51357972f6e74244494236a41dc4d84cd diff --git a/lib-mime/rfc1524.c b/lib-mime/rfc1524.c index 8705ace..422a82d 100644 --- a/lib-mime/rfc1524.c +++ b/lib-mime/rfc1524.c @@ -58,8 +58,6 @@ void rfc1524_entry_wipe(rfc1524_entry *p) /* 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: @@ -69,15 +67,17 @@ int rfc1524_mailcap_isneeded(BODY * m) 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: @@ -103,7 +103,7 @@ int rfc1524_expand_command(BODY *a, const char *filename, const char *mtype, 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)) { @@ -128,7 +128,7 @@ int rfc1524_expand_command(BODY *a, const char *filename, const char *mtype, 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); @@ -346,60 +346,46 @@ rfc1524_mailcap_parse(BODY *a, const char *filename, const char *type, } -/************** 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.