summaryrefslogtreecommitdiff
path: root/content/content_factory.h
diff options
context:
space:
mode:
authorVincent Sanders <vince@netsurf-browser.org>2011-08-27 08:43:51 +0000
committerVincent Sanders <vince@netsurf-browser.org>2011-08-27 08:43:51 +0000
commit81c52ad4947c2b658473f8f87e244660a72c002a (patch)
tree1ba7dbb26a64ce5d1970c94b128790d9a674824a /content/content_factory.h
parent5f311d08ef77b809a6319caab1a83a932af2bc63 (diff)
downloadnetsurf-81c52ad4947c2b658473f8f87e244660a72c002a.tar.gz
netsurf-81c52ad4947c2b658473f8f87e244660a72c002a.tar.bz2
Initial image content handler refactor
svn path=/trunk/netsurf/; revision=12671
Diffstat (limited to 'content/content_factory.h')
-rw-r--r--content/content_factory.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/content/content_factory.h b/content/content_factory.h
index f6ea3ce49..777e314f0 100644
--- a/content/content_factory.h
+++ b/content/content_factory.h
@@ -26,6 +26,51 @@
#include "content/content_type.h"
#include "utils/errors.h"
+#define CONTENT_FACTORY_REGISTER_TYPES(HNAME, HTYPELIST, HHANDLER) \
+ \
+static lwc_string *HNAME##_mime_types[NOF_ELEMENTS(HTYPELIST)]; \
+ \
+nserror HNAME##_init(void) \
+{ \
+ uint32_t i; \
+ lwc_error lerror; \
+ nserror error; \
+ \
+ for (i = 0; i < NOF_ELEMENTS(HNAME##_mime_types); i++) { \
+ lerror = lwc_intern_string(HTYPELIST[i], \
+ strlen(HTYPELIST[i]), \
+ &HNAME##_mime_types[i]); \
+ if (lerror != lwc_error_ok) { \
+ error = NSERROR_NOMEM; \
+ goto error; \
+ } \
+ \
+ error = content_factory_register_handler( \
+ HNAME##_mime_types[i], \
+ &HHANDLER); \
+ if (error != NSERROR_OK) \
+ goto error; \
+ } \
+ \
+ return NSERROR_OK; \
+ \
+error: \
+ HNAME##_fini(); \
+ \
+ return error; \
+} \
+ \
+void HNAME##_fini(void) \
+{ \
+ uint32_t i; \
+ \
+ for (i = 0; i < NOF_ELEMENTS(HNAME##_mime_types); i++) { \
+ if (HNAME##_mime_types[i] != NULL) { \
+ lwc_string_unref(HNAME##_mime_types[i]); \
+ } \
+ } \
+}
+
struct content;
struct llcache_handle;