From 51e93478079f490b13023d406782dd883bd817e2 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Mon, 2 Jun 2003 21:09:50 +0000 Subject: [project @ 2003-06-02 21:09:50 by jmb] Use Mimemap module to get mime types from file extensions svn path=/import/netsurf/; revision=151 --- riscos/plugin.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/riscos/plugin.c b/riscos/plugin.c index e6b3aabb8..1d395ade2 100644 --- a/riscos/plugin.c +++ b/riscos/plugin.c @@ -1,5 +1,5 @@ /** - * $Id: plugin.c,v 1.1 2003/05/31 18:47:00 jmb Exp $ + * $Id: plugin.c,v 1.2 2003/06/02 21:09:50 jmb Exp $ */ #include @@ -14,6 +14,8 @@ #include "netsurf/utils/log.h" #include "netsurf/utils/utils.h" +#include "oslib/mimemap.h" + char* create_mime_from_ext(char* data); void plugin_fetch(struct content* content, char* url, struct box* box, @@ -64,24 +66,17 @@ void plugin_fetch(struct content* content, char* url, struct box* box, char* create_mime_from_ext(char* data){ char* ret; + os_error *e; ret = strrchr(data, '.'); - LOG(("ret = %s", ++ret)); - - if ((stricmp(ret,"jpg")) == 0 || (stricmp(ret,"jpeg")) == 0) { - strcpy(ret,"image/jpeg"); - LOG(("jpeg image")); + LOG(("Extension = %s", ret)); - } else if ((stricmp(ret,"png")) == 0) { - strcpy(ret,"image/png"); - LOG(("png image")); + /* Let's make the mime map module do the work for us */ + e = xmimemaptranslate_extension_to_mime_type((const char*)ret, + ret); + LOG(("Mime Type = %s", ret)); - } /*else if ((stricmp(ret, "gif")) == 0) { - ret = "image/gif"; - }*/ else { - - ret = NULL; - } + if(e != NULL) ret = NULL; return ret; } -- cgit v1.2.3