From 51ee42fc080293aba2bcde9c85e06282530b8ab6 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 31 May 2003 18:47:00 +0000 Subject: [project @ 2003-05-31 18:47:00 by jmb] Begin support for , and tags. NB: this doesn't work yet svn path=/import/netsurf/; revision=137 --- riscos/plugin.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 riscos/plugin.c (limited to 'riscos/plugin.c') diff --git a/riscos/plugin.c b/riscos/plugin.c new file mode 100644 index 000000000..e6b3aabb8 --- /dev/null +++ b/riscos/plugin.c @@ -0,0 +1,87 @@ +/** + * $Id: plugin.c,v 1.1 2003/05/31 18:47:00 jmb Exp $ + */ + +#include +#include +#include +#include +#include + +#include "netsurf/content/content.h" +#include "netsurf/render/html.h" +#include "netsurf/riscos/plugin.h" +#include "netsurf/utils/log.h" +#include "netsurf/utils/utils.h" + +char* create_mime_from_ext(char* data); + +void plugin_fetch(struct content* content, char* url, struct box* box, + struct plugin_object* po) { + + + content_type mime_type; + + if (po->data != NULL) { + + if (po->type != NULL) { + + mime_type = content_lookup((const char*)po->type); + } + else { + + po->type = create_mime_from_ext(po->data); + + if (po->type != NULL) + mime_type = content_lookup((const char*)po->type); + + } + + /* OK, we have an image. Let's make the image handler + deal with it */ + if (mime_type == CONTENT_JPEG || mime_type == CONTENT_PNG) { + + xfree(po); + LOG(("sending data to image handler")); + /* TODO - stop segfault when redrawing window */ + /*html_fetch_image(content, url, box);*/ + } + } + else { + + + } + /* TODO - this function.*/ + +} + +/** + * create_mime_from_ext + * attempts to create a mime type from the filename extension. + * returns NULL if it fails. + */ + +char* create_mime_from_ext(char* data){ + + char* ret; + + ret = strrchr(data, '.'); + LOG(("ret = %s", ++ret)); + + if ((stricmp(ret,"jpg")) == 0 || (stricmp(ret,"jpeg")) == 0) { + strcpy(ret,"image/jpeg"); + LOG(("jpeg image")); + + } else if ((stricmp(ret,"png")) == 0) { + strcpy(ret,"image/png"); + LOG(("png image")); + + } /*else if ((stricmp(ret, "gif")) == 0) { + ret = "image/gif"; + }*/ else { + + ret = NULL; + } + + return ret; +} -- cgit v1.2.3