return (0);
}
+void mutt_check_lookup_list (BODY *b, char *type, int len)
+{
+ LIST *t = MimeLookupList;
+ int i;
+
+ 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) {
+
+ BODY tmp = {0};
+ int n;
+ if ((n = mutt_lookup_mime_type (&tmp, b->filename)) != TYPEOTHER) {
+ snprintf (type, len, "%s/%s",
+ n == TYPEAUDIO ? "audio" :
+ n == TYPEAPPLICATION ? "application" :
+ n == TYPEIMAGE ? "image" :
+ n == TYPEMESSAGE ? "message" :
+ n == TYPEMODEL ? "model" :
+ n == TYPEMULTIPART ? "multipart" :
+ n == TYPETEXT ? "text" :
+ n == TYPEVIDEO ? "video" : "other",
+ tmp.subtype);
+ dprint(1, (debugfile, "mutt_check_lookup_list: \"%s\" -> %s\n",
+ b->filename, type));
+ }
+ if (tmp.subtype)
+ safe_free ((void **) &tmp.subtype);
+ if (tmp.xtype)
+ safe_free ((void **) &tmp.xtype);
+ }
+ }
+}
+
int mutt_is_autoview (BODY *b, const char *type)
{
LIST *t = AutoViewList;
int i;
if (!type)
- {
snprintf (_type, sizeof (_type), "%s/%s", TYPE (b), b->subtype);
- type = _type;
- }
+ else
+ strncpy (_type, type, sizeof(_type));
+
+ mutt_check_lookup_list (b, _type, sizeof(_type));
+ type = _type;
if (mutt_needs_mailcap (b))
{
return 1;
}
- for (; t; t = t->next)
- {
+ 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) ||
that, Mutt will look for any text type. As a last attempt, mutt will
look for any type it knows how to handle.
+<sect1>MIME Lookup<label id="mime_lookup">
+<p>
+Mutt's mime_lookup list specifies a list of mime-types that should not
+be treated according to their mailcap entry. This option is designed to
+deal with binary types such as application/octet-stream. When an attachment's
+mime-type is listed in mime_lookup, then the extension of the filename will
+be compared to the list of extensions in the mime.types file. The mime-type
+associated with this extension will then be used to process the attachment
+according to the rules in the mailcap file and according to any other configuration
+options (such as auto_view) specified. Common usage would be:
+<tscreen><verb>
+mime-lookup application/octet-stream application/X-Lotus-Manuscript
+</verb></tscreen>
+
+In addition, the unmime_lookup command may be used to disable this feature
+for any particular mime-type if it had been set, for example, in a global
+muttrc.
+
<sect>Reference
<sect1>Command line options<label id="commandline">
<p>
<item>
<tt><ref id="message-hook" name="message-hook"></tt> <em/pattern/ <em/command/
<item>
+<tt><ref id="mime_lookup" name="mime_lookup"></tt> <em/mimetype/ [ <em/mimetype/ ... ]
+<item>
+<tt><ref id="mime_lookup" name="unmime_lookup"></tt> <em/mimetype/ [ <em/mimetype/ ... ]
+<item>
<tt><ref id="color" name="mono"></tt> <em/object attribute/ [ <em/regexp/ ]
<item>
<tt><ref id="color" name="unmono"></tt> <em/index/ <em/pattern/ [ <em/pattern/ ... ]
.B copiousoutput
flag set. A subtype of \(lq\fB*\fP\(rq
matches any subtype, as does an empty subtype.
+.PP
+.nf
+\fBmime_lookup\fP \fItype\fP[\fB/\fP\fIsubtype\fP] [ ... ]
+\fBunmime_lookup\fP \fItype\fP[\fB/\fP\fIsubtype\fP] [ ... ]
+This command permits you to define a list of "data" MIME content
+types for which mutt will try to determine the actual file type from
+the file name, and not use a
+.BR mailcap (5)
+entry given for the original MIME type. For instance, you may add
+the \fBapplication/octet-stream\fP MIME type to this list.
.TP
\fBbind\fP \fImap\fP \fIkey\fP \fIfunction\fP
This command binds the given \fIkey\fP for the given \fImap\fP to
WHERE LIST *AlternativeOrderList INITVAL(0);
WHERE LIST *HeaderOrderList INITVAL(0);
WHERE LIST *Ignore INITVAL(0);
+WHERE LIST *MimeLookupList INITVAL(0);
WHERE LIST *UnIgnore INITVAL(0);
WHERE LIST *MailLists INITVAL(0);
WHERE LIST *SubscribedLists INITVAL(0);
{ "mailboxes", mutt_parse_mailboxes, 0 },
{ "message-hook", mutt_parse_hook, M_MESSAGEHOOK },
{ "mbox-hook", mutt_parse_hook, M_MBOXHOOK },
+ { "mime_lookup", parse_list, UL &MimeLookupList },
+ { "unmime_lookup", parse_unlist, UL &MimeLookupList },
{ "mono", mutt_parse_mono, 0 },
{ "my_hdr", parse_my_hdr, 0 },
#ifdef HAVE_PGP
void mutt_generate_header (char *, size_t, HEADER *, int);
void mutt_help (int);
void mutt_draw_tree (CONTEXT *);
+void mutt_check_lookup_list (BODY *, char *, int);
void mutt_make_attribution (CONTEXT *ctx, HEADER *cur, FILE *out);
void mutt_make_forward_subject (ENVELOPE *env, CONTEXT *ctx, HEADER *cur);
void mutt_make_help (char *, size_t, char *, int, int);
int mutt_is_subscribed_list (ADDRESS *);
int mutt_is_text_type (int, char *);
int mutt_is_valid_mailbox (const char *);
+int mutt_lookup_mime_type (BODY *, const char *);
int mutt_messages_in_thread (CONTEXT *, HEADER *, int);
int mutt_multi_choice (char *prompt, char *letters);
int mutt_needs_mailcap (BODY *);
return 0;
}
+ mutt_check_lookup_list (a, type, SHORT_STRING);
+
while (!found && *curr)
{
x = 0;
* exists.
*/
-static int lookup_mime_type (BODY *att, const char *path)
+int mutt_lookup_mime_type (BODY *att, const char *path)
{
FILE *f;
char *p, *q, *ct;
strfcpy (buf, PKGDATADIR"/mime.types", sizeof (buf));
break;
default:
- dprint (1, (debugfile, "lookup_mime_type: Internal error, count = %d.\n", count));
+ dprint (1, (debugfile, "mutt_lookup_mime_type: Internal error, count = %d.\n", count));
goto bye; /* shouldn't happen */
}
#if 0
- if ((n = lookup_mime_type (buf, sizeof (buf), xbuf, sizeof (xbuf), path)) != TYPEOTHER
+ if ((n = mutt_lookup_mime_type (buf, sizeof (buf), xbuf, sizeof (xbuf), path)) != TYPEOTHER
|| *xbuf != '\0')
{
att->type = n;
#else
- lookup_mime_type (att, path);
+ mutt_lookup_mime_type (att, path);
#endif