int mutt_is_autoview (BODY *b, const char *type) { LIST *t = AutoViewList; char _type[SHORT_STRING]; int i; if (!type) snprintf (_type, sizeof (_type), "%s/%s", TYPE (b), b->subtype); else strncpy (_type, type, sizeof(_type)); mutt_check_lookup_list (b, _type, sizeof(_type)); type = _type; if (mutt_needs_mailcap (b)) { if (option (OPTIMPLICITAUTOVIEW)) return 1; if (is_mmnoask (type)) return 1; } for (; t; t = t->next) { i = mutt_strlen (t->data) - 1; if ((i > 0 && t->data[i-1] == '/' && t->data[i] == '*' && ascii_strncasecmp (type, t->data, i) == 0) || ascii_strcasecmp (type, t->data) == 0) return 1; } return 0; }
/* * 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) { 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 overridden 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"); return 0; } mutt_check_lookup_list (a, type, SHORT_STRING); while (!found && *curr) { x = 0; while (*curr && *curr != ':' && x < sizeof (path) - 1) { path[x++] = *curr; curr++; } if (*curr) curr++; if (!x) continue; path[x] = '\0'; mutt_expand_path (path, sizeof (path)); dprint(2,(debugfile,"Checking mailcap file: %s\n",path)); found = rfc1524_mailcap_parse (a, path, type, entry, opt); } if (entry && !found) mutt_error (_("mailcap entry for type %s not found"), type); return found; }