diff options
| author | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2010-09-01 12:43:49 +0200 |
|---|---|---|
| committer | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2010-09-03 19:02:41 +0200 |
| commit | 5f5942a4dd209a6c608aa67f3af4b62c2be9bdf0 (patch) | |
| tree | 8ae4244e4bdf871b4a6106f5cc261757dd469300 | |
| parent | c3985f6f6dae132088d2541d798be1ed17714288 (diff) | |
| download | lasso-5f5942a4dd209a6c608aa67f3af4b62c2be9bdf0.tar.gz lasso-5f5942a4dd209a6c608aa67f3af4b62c2be9bdf0.tar.xz lasso-5f5942a4dd209a6c608aa67f3af4b62c2be9bdf0.zip | |
[Core] add private function to read an integer attribute
This function does integer parsing and range checks, it returns TRUE if
all goes well.
| -rw-r--r-- | lasso/xml/xml.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c index f5339721..6fbe700e 100644 --- a/lasso/xml/xml.c +++ b/lasso/xml/xml.c @@ -1129,6 +1129,27 @@ _lasso_node_collect_namespaces(GHashTable **namespaces, xmlNode *node) } } +gboolean +lasso_get_integer_attribute(xmlNode *node, xmlChar *attribute_name, xmlChar *ns_href, int *integer, long int low, long int high) { + xmlChar *content = NULL; + gboolean rc = FALSE; + long int what; + + g_assert (integer); + content = xmlGetNsProp(node, attribute_name, ns_href); + if (! content) + goto cleanup; + if (! lasso_string_to_xsd_integer((char*)content, &what)) + goto cleanup; + if (*integer < low || *integer >= high) + goto cleanup; + *integer = what; + rc = TRUE; +cleanup: + lasso_release_xml_string(content); + return rc; +} + /** FIXME: return a real error code */ static int lasso_node_impl_init_from_xml(LassoNode *node, xmlNode *xmlnode) |
