Make fetch_mimetype consider our internal mapping table

svn path=/trunk/netsurf/; revision=2894
This commit is contained in:
John Mark Bell 2006-08-25 22:46:38 +00:00
parent 978637a134
commit 358f20f4cd
1 changed files with 11 additions and 0 deletions

View File

@ -152,6 +152,7 @@ char *fetch_mimetype(const char *ro_path)
int objtype;
char *mime = calloc(BUF_SIZE, sizeof(char));
char *slash;
struct type_entry *t;
if (!mime) {
LOG(("Insufficient memory for calloc"));
@ -193,6 +194,16 @@ char *fetch_mimetype(const char *ro_path)
filetype = load;
}
/* search for MIME type in our internal table */
t = bsearch(&filetype, type_map, TYPE_MAP_COUNT,
sizeof(type_map[0]), cmp_type);
if (t) {
/* found, so return it */
strncpy(mime, t->mime_type, BUF_SIZE);
return mime;
}
/* not in internal table, so ask MimeMap */
e = xmimemaptranslate_filetype_to_mime_type(filetype, mime);
if (e) {
LOG(("xmimemaptranslate_filetype_to_mime_type: 0x%x: %s",