summaryrefslogtreecommitdiff
path: root/src/util/dom-str.c
blob: 03fdd9e1bcf46c5356bcd20297abd4eab92ca9b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
 * 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_node_removed;
dom_string *nsl_dom_str_subtree_modified;
dom_string *nsl_dom_str_attr_modified;
dom_string *nsl_dom_str_characterdata_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 *)"DOMNodeRemoved",
			SLEN("DOMNodeRemoved"),
			&nsl_dom_str_node_removed);
	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;
	}
	exc = dom_string_create((const uint8_t *)"DOMAttrModified",
			SLEN("DOMAttrModified"),
			&nsl_dom_str_attr_modified);
	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 *)"DOMCharacterDataModified",
			SLEN("DOMCharacterDataModified"),
			&nsl_dom_str_characterdata_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;
}