diff -ur mutt-1.4.orig/PATCHES mutt-1.4.mime_lookup/PATCHES --- mutt-1.4.orig/PATCHES Tue Apr 2 20:48:58 2002 +++ mutt-1.4.mime_lookup/PATCHES Sat Jun 8 12:38:22 2002 @@ -0,0 +1 @@ +patch-1.4.bf+uen.mime_lookup.2 diff -ur mutt-1.4.orig/attach.c mutt-1.4.mime_lookup/attach.c --- mutt-1.4.orig/attach.c Mon Jan 7 19:09:34 2002 +++ mutt-1.4.mime_lookup/attach.c Sat Jun 8 12:36:48 2002 @@ -325,6 +325,41 @@ 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; @@ -332,10 +367,12 @@ 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)) { @@ -346,8 +383,7 @@ 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) || diff -ur mutt-1.4.orig/globals.h mutt-1.4.mime_lookup/globals.h --- mutt-1.4.orig/globals.h Thu Jan 3 20:57:20 2002 +++ mutt-1.4.mime_lookup/globals.h Sat Jun 8 12:36:51 2002 @@ -118,6 +118,7 @@ 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); diff -ur mutt-1.4.orig/init.h mutt-1.4.mime_lookup/init.h --- mutt-1.4.orig/init.h Thu Apr 25 15:26:38 2002 +++ mutt-1.4.mime_lookup/init.h Sat Jun 8 12:36:51 2002 @@ -2478,6 +2478,8 @@ { "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 diff -ur mutt-1.4.orig/protos.h mutt-1.4.mime_lookup/protos.h --- mutt-1.4.orig/protos.h Mon Apr 29 19:12:12 2002 +++ mutt-1.4.mime_lookup/protos.h Sat Jun 8 12:36:51 2002 @@ -185,6 +185,7 @@ 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); @@ -283,6 +284,7 @@ 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 *); diff -ur mutt-1.4.orig/rfc1524.c mutt-1.4.mime_lookup/rfc1524.c --- mutt-1.4.orig/rfc1524.c Tue May 15 09:23:50 2001 +++ mutt-1.4.mime_lookup/rfc1524.c Sat Jun 8 12:36:51 2002 @@ -392,6 +392,8 @@ return 0; } + mutt_check_lookup_list (a, type, SHORT_STRING); + while (!found && *curr) { x = 0; diff -ur mutt-1.4.orig/sendlib.c mutt-1.4.mime_lookup/sendlib.c --- mutt-1.4.orig/sendlib.c Sat Apr 20 09:25:50 2002 +++ mutt-1.4.mime_lookup/sendlib.c Sat Jun 8 12:36:51 2002 @@ -963,7 +963,7 @@ * 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; @@ -998,7 +998,7 @@ 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 */ } @@ -1380,7 +1380,7 @@ #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; @@ -1390,7 +1390,7 @@ #else - lookup_mime_type (att, path); + mutt_lookup_mime_type (att, path); #endif