summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2011-03-13 09:24:03 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2011-03-13 09:24:03 +0000
commitfc18fccd5ed2050a05cad53714f429a529253711 (patch)
tree659c5ee8e912fd70546cd7578551701346b7fb61
parentc21a5d244101c695d59feaf5e333c194a33cc029 (diff)
downloadlibcss-fc18fccd5ed2050a05cad53714f429a529253711.tar.gz
libcss-fc18fccd5ed2050a05cad53714f429a529253711.tar.bz2
Add structure versioning for client input
svn path=/trunk/libcss/; revision=12007
-rw-r--r--include/libcss/select.h7
-rw-r--r--include/libcss/stylesheet.h7
-rw-r--r--src/select/select.c4
-rw-r--r--src/stylesheet.c4
-rw-r--r--test/css21.c1
-rw-r--r--test/parse-auto.c1
-rw-r--r--test/parse2-auto.c1
-rw-r--r--test/select-auto.c3
8 files changed, 26 insertions, 2 deletions
diff --git a/include/libcss/select.h b/include/libcss/select.h
index bdc16ac..b6f9475 100644
--- a/include/libcss/select.h
+++ b/include/libcss/select.h
@@ -46,7 +46,14 @@ typedef struct css_select_results {
css_computed_style *styles[CSS_PSEUDO_ELEMENT_COUNT];
} css_select_results;
+typedef enum css_select_handler_version {
+ CSS_SELECT_HANDLER_VERSION_1 = 1
+} css_select_handler_version;
+
typedef struct css_select_handler {
+ /** ABI version of this structure */
+ uint32_t handler_version;
+
css_error (*node_name)(void *pw, void *node,
css_qname *qname);
css_error (*node_classes)(void *pw, void *node,
diff --git a/include/libcss/stylesheet.h b/include/libcss/stylesheet.h
index 29049c9..8ef530e 100644
--- a/include/libcss/stylesheet.h
+++ b/include/libcss/stylesheet.h
@@ -89,10 +89,17 @@ typedef struct css_system_font {
typedef css_error (*css_font_resolution_fn)(void *pw,
lwc_string *name, css_system_font *system_font);
+typedef enum css_stylesheet_params_version {
+ CSS_STYLESHEET_PARAMS_VERSION_1 = 1
+} css_stylesheet_params_version;
+
/**
* Parameter block for css_stylesheet_create()
*/
typedef struct css_stylesheet_params {
+ /** ABI version of this structure */
+ uint32_t params_version;
+
/** The language level of the stylesheet */
css_language_level level;
diff --git a/src/select/select.c b/src/select/select.c
index e2b55ee..ca50107 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -300,7 +300,9 @@ css_error css_select_style(css_select_ctx *ctx, void *node,
css_select_state state;
void *parent = NULL;
- if (ctx == NULL || node == NULL || result == NULL || handler == NULL)
+ if (ctx == NULL || node == NULL || result == NULL || handler == NULL ||
+ handler->handler_version !=
+ CSS_SELECT_HANDLER_VERSION_1)
return CSS_BADPARM;
/* Set up the selection state */
diff --git a/src/stylesheet.c b/src/stylesheet.c
index 604d824..6b4bf77 100644
--- a/src/stylesheet.c
+++ b/src/stylesheet.c
@@ -129,7 +129,9 @@ css_error css_stylesheet_create(css_stylesheet_params *params,
css_stylesheet *sheet;
size_t len;
- if (params == NULL || params->url == NULL || alloc == NULL ||
+ if (params == NULL || params->params_version !=
+ CSS_STYLESHEET_PARAMS_VERSION_1 ||
+ params->url == NULL || alloc == NULL ||
params->resolve == NULL || stylesheet == NULL)
return CSS_BADPARM;
diff --git a/test/css21.c b/test/css21.c
index ea655f7..ddc629c 100644
--- a/test/css21.c
+++ b/test/css21.c
@@ -48,6 +48,7 @@ int main(int argc, char **argv)
return 1;
}
+ params.params_version = CSS_STYLESHEET_PARAMS_VERSION_1;
params.level = CSS_LEVEL_21;
params.charset = "UTF-8";
params.url = argv[1];
diff --git a/test/parse-auto.c b/test/parse-auto.c
index e9fd2e3..156c38d 100644
--- a/test/parse-auto.c
+++ b/test/parse-auto.c
@@ -371,6 +371,7 @@ void run_test(const uint8_t *data, size_t len, exp_entry *exp, size_t explen)
static int testnum;
bool failed;
+ params.params_version = CSS_STYLESHEET_PARAMS_VERSION_1;
params.level = CSS_LEVEL_21;
params.charset = "UTF-8";
params.url = "foo";
diff --git a/test/parse2-auto.c b/test/parse2-auto.c
index 8999026..2ae7cae 100644
--- a/test/parse2-auto.c
+++ b/test/parse2-auto.c
@@ -196,6 +196,7 @@ void run_test(const uint8_t *data, size_t len, const char *exp, size_t explen)
}
buflen = 2 * explen;
+ params.params_version = CSS_STYLESHEET_PARAMS_VERSION_1;
params.level = CSS_LEVEL_21;
params.charset = "UTF-8";
params.url = "foo";
diff --git a/test/select-auto.c b/test/select-auto.c
index 196bd5a..0ec57ae 100644
--- a/test/select-auto.c
+++ b/test/select-auto.c
@@ -154,6 +154,8 @@ static css_error compute_font_size(void *pw, const css_hint *parent,
css_hint *size);
static css_select_handler select_handler = {
+ CSS_SELECT_HANDLER_VERSION_1,
+
node_name,
node_classes,
node_id,
@@ -521,6 +523,7 @@ void css__parse_sheet(line_ctx *ctx, const char *data, size_t len)
css__parse_media_list(&p, &ignored, &media);
}
+ params.params_version = CSS_STYLESHEET_PARAMS_VERSION_1;
params.level = CSS_LEVEL_21;
params.charset = "UTF-8";
params.url = "foo";