diff options
author | Frederic Peters <fpeters@entrouvert.com> | 2004-12-15 16:00:23 +0000 |
---|---|---|
committer | Frederic Peters <fpeters@entrouvert.com> | 2004-12-15 16:00:23 +0000 |
commit | e63eb6ed71f66ec6fd3c8681b72965221213e659 (patch) | |
tree | 610364a94891c96af1bbc3d24d12a70dad261264 /lasso/xml | |
parent | 22d04e57d896975bc5be3bad33adf5cdfb76325f (diff) | |
download | lasso-e63eb6ed71f66ec6fd3c8681b72965221213e659.tar.gz lasso-e63eb6ed71f66ec6fd3c8681b72965221213e659.tar.xz lasso-e63eb6ed71f66ec6fd3c8681b72965221213e659.zip |
no longer play fool mixing pointers and integers; they are not always the same
size and this bites quite hard on AMD-64 (shame on me).
Diffstat (limited to 'lasso/xml')
-rw-r--r-- | lasso/xml/xml.c | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c index 93decebf..de321842 100644 --- a/lasso/xml/xml.c +++ b/lasso/xml/xml.c @@ -502,6 +502,7 @@ lasso_node_impl_init_from_xml(LassoNode *node, xmlNode *xmlnode) for (snippet = class->node_data->snippets; snippet && snippet->name; snippet++) { + void *tmp = NULL; type = snippet->type & 0xff; value = G_STRUCT_MEMBER_P(node, snippet->offset); @@ -509,19 +510,17 @@ lasso_node_impl_init_from_xml(LassoNode *node, xmlNode *xmlnode) continue; if (type == SNIPPET_NODE) { - (*(LassoNode**)value) = lasso_node_new_from_xmlNode(t); + tmp = lasso_node_new_from_xmlNode(t); } else if (type == SNIPPET_NODE_IN_CHILD) { xmlNode *t2 = t->children; while (t2 && t2->type != XML_ELEMENT_NODE) t2 = t2->next; if (t2) - (*(LassoNode**)value) = - lasso_node_new_from_xmlNode(t2); + tmp = lasso_node_new_from_xmlNode(t2); } else if (type == SNIPPET_CONTENT) - (*(char**)value) = xmlNodeGetContent(t); + tmp = xmlNodeGetContent(t); else if (type == SNIPPET_NAME_IDENTIFIER) - (*(LassoSamlNameIdentifier**)value) = - lasso_saml_name_identifier_new_from_xmlNode(t); + tmp = lasso_saml_name_identifier_new_from_xmlNode(t); else if (type == SNIPPET_LIST_NODES) { GList **location = value; LassoNode *n = lasso_node_new_from_xmlNode(t); @@ -531,35 +530,49 @@ lasso_node_impl_init_from_xml(LassoNode *node, xmlNode *xmlnode) xmlChar *s = xmlNodeGetContent(t); *location = g_list_append(*location, s); } + + if (tmp == NULL) + break; + + if (snippet->type & SNIPPET_INTEGER) { + int val = atoi(tmp); + (*(int*)value) = val; + xmlFree(tmp); + } else if (snippet->type & SNIPPET_BOOLEAN) { + int val = (strcmp((char*)tmp, "true") == 0); + (*(int*)value) = val; + xmlFree(tmp); + } else { + (*(void**)value) = tmp; + } + break; } } for (snippet = class->node_data->snippets; snippet && snippet->name; snippet++) { + void *tmp = NULL; type = snippet->type & 0xff; value = G_STRUCT_MEMBER_P(node, snippet->offset); if (type == SNIPPET_ATTRIBUTE) - (*(char**)value) = xmlGetProp(xmlnode, snippet->name); + tmp = xmlGetProp(xmlnode, snippet->name); if (type == SNIPPET_TEXT_CHILD) - (*(char**)value) = xmlNodeGetContent(xmlnode); - } + tmp = xmlNodeGetContent(xmlnode); + if (tmp == NULL) + continue; - /* last turn; fixup types */ - for (snippet = class->node_data->snippets; snippet && snippet->name; snippet++) { - value = G_STRUCT_MEMBER_P(node, snippet->offset); if (snippet->type & SNIPPET_INTEGER) { - char *s = *(char**)value; - int val = atoi(s); - xmlFree(s); - (*(void**)value) = GINT_TO_POINTER(val); + int val = atoi(tmp); + (*(int*)value) = val; + xmlFree(tmp); + } else if (snippet->type & SNIPPET_BOOLEAN) { + int val = (strcmp((char*)tmp, "true") == 0); + (*(int*)value) = val; + xmlFree(tmp); + } else { + (*(char**)value) = tmp; } - if (snippet->type & SNIPPET_BOOLEAN) { - char *s = *(char**)value; - int val = (strcmp(s, "true") == 0); - (*(void**)value) = GINT_TO_POINTER(val); - xmlFree(s); - } } class = g_type_class_peek_parent(class); |