summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/Makefile11
-rw-r--r--src/util/dom-str.c54
-rw-r--r--src/util/dom-str.h33
-rw-r--r--src/util/util.h22
4 files changed, 120 insertions, 0 deletions
diff --git a/src/util/Makefile b/src/util/Makefile
new file mode 100644
index 0000000..4f95e74
--- /dev/null
+++ b/src/util/Makefile
@@ -0,0 +1,11 @@
+#
+# Makefile for libnslayout
+#
+# Copyright 2015 Michael Drake <tlsa@netsurf-browser.org>
+#
+# Released under the ISC License (see COPYING file)
+
+# Sources
+DIR_SOURCES := dom-str.c
+
+include $(NSBUILD)/Makefile.subdir
diff --git a/src/util/dom-str.c b/src/util/dom-str.c
new file mode 100644
index 0000000..b959afe
--- /dev/null
+++ b/src/util/dom-str.c
@@ -0,0 +1,54 @@
+/*
+ * This file is part of LibNSLayout
+ * Licensed under the ISC License, http://opensource.org/licenses/ISC
+ * Copyright 2015 Michael Drake <tlsa@netsurf-browser.org>
+ */
+
+/** \file src/util/dom-str.c
+ * Layout object handling
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "util/dom-str.h"
+#include "util/util.h"
+
+dom_string *nsl_dom_str_node_inserted;
+dom_string *nsl_dom_str_subtree_modified;
+
+
+/* Exported function, documented in src/util/dom-str.h */
+nslayout_error nsl_dom_str_init(void)
+{
+ dom_exception exc;
+
+ exc = dom_string_create((const uint8_t *)"DOMNodeInserted",
+ SLEN("DOMNodeInserted"),
+ &nsl_dom_str_node_inserted);
+ if (exc != DOM_NO_ERR) {
+ /* TODO: free stuff, return value */
+ printf("Failed to create string!\n");
+ return NSLAYOUT_NO_MEM;
+ }
+ exc = dom_string_create((const uint8_t *)"DOMSubtreeModified",
+ SLEN("DOMSubtreeModified"),
+ &nsl_dom_str_subtree_modified);
+ if (exc != DOM_NO_ERR) {
+ /* TODO: free stuff, return value */
+ printf("Failed to create string!\n");
+ return NSLAYOUT_NO_MEM;
+ }
+
+ return NSLAYOUT_OK;
+}
+
+
+/* Exported function, documented in src/util/dom-str.h */
+nslayout_error nsl_dom_str_fini(void)
+{
+ dom_string_unref(nsl_dom_str_node_inserted);
+ dom_string_unref(nsl_dom_str_subtree_modified);
+
+ return NSLAYOUT_OK;
+}
diff --git a/src/util/dom-str.h b/src/util/dom-str.h
new file mode 100644
index 0000000..9a51ad5
--- /dev/null
+++ b/src/util/dom-str.h
@@ -0,0 +1,33 @@
+/*
+ * This file is part of LibNSLayout
+ * Licensed under the ISC License, http://opensource.org/licenses/ISC
+ * Copyright 2015 Michael Drake <tlsa@netsurf-browser.org>
+ */
+
+/** \file src/util/dom-str.h
+ * Layout object handling
+ */
+
+#ifndef nslayout_util_dom_str_h_
+#define nslayout_util_dom_str_h_
+
+#include <libnslayout/nslayout.h>
+
+extern dom_string *nsl_dom_str_node_inserted;
+extern dom_string *nsl_dom_str_subtree_modified;
+
+/**
+ * Create the internal DOM strings
+ *
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+nslayout_error nsl_dom_str_init(void);
+
+/**
+ * Unref the internal DOM strings
+ *
+ * \return NSLAYOUT_OK on success, appropriate error otherwise.
+ */
+nslayout_error nsl_dom_str_fini(void);
+
+#endif
diff --git a/src/util/util.h b/src/util/util.h
new file mode 100644
index 0000000..c03691b
--- /dev/null
+++ b/src/util/util.h
@@ -0,0 +1,22 @@
+/*
+ * This file is part of LibNSLayout
+ * Licensed under the ISC License, http://opensource.org/licenses/ISC
+ * Copyright 2015 Michael Drake <tlsa@netsurf-browser.org>
+ */
+
+/** \file src/util/util.h
+ * Layout object handling
+ */
+
+#ifndef nslayout_util_util_h_
+#define nslayout_util_util_h_
+
+#ifndef UNUSED
+#define UNUSED(x) (void)(x)
+#endif
+
+#ifndef SLEN
+#define SLEN(x) (sizeof((x)) - 1)
+#endif
+
+#endif