summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Peters <fpeters@entrouvert.com>2004-11-25 21:44:11 +0000
committerFrederic Peters <fpeters@entrouvert.com>2004-11-25 21:44:11 +0000
commit5cb4a00762f0368f83a033318193fc8e01dbd71f (patch)
tree496ea88cc9ee8cbcad5b0b45c74e266f3c00005b
parent2093557306e93b300339ca29c352aa9cebdb2380 (diff)
downloadlasso-5cb4a00762f0368f83a033318193fc8e01dbd71f.tar.gz
lasso-5cb4a00762f0368f83a033318193fc8e01dbd71f.tar.xz
lasso-5cb4a00762f0368f83a033318193fc8e01dbd71f.zip
cut down on line length; removed unnecessary cast, implemented 't' snippet
handling.
-rw-r--r--lasso/xml/xml.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c
index dc2c1e65..7e1034af 100644
--- a/lasso/xml/xml.c
+++ b/lasso/xml/xml.c
@@ -725,8 +725,7 @@ lasso_node_init_from_message(LassoNode *node, const char *message)
void
lasso_node_init_xml_with_snippets(xmlNode *node, struct XmlSnippet *snippets)
{
- xmlNode *t, *ts;
- GList *s;
+ xmlNode *t;
int i;
for (i = 0; snippets[i].name; i++) {
@@ -750,14 +749,25 @@ lasso_node_init_xml_with_snippets(xmlNode *node, struct XmlSnippet *snippets)
*(snippets[i].value) = (void*)
lasso_saml_name_identifier_new_from_xmlNode(t);
if (snippets[i].type == 's') { /* sequence of complex elements */
+ xmlNode *ts;
+ GList *s = NULL;
for (ts = t->children; ts; ts = ts->next) {
if (ts->type != XML_ELEMENT_NODE)
continue;
- g_list_append(s, (gpointer)lasso_node_new_from_xmlNode(ts));
+ g_list_append(s, lasso_node_new_from_xmlNode(ts));
}
- *(snippets[i].value) = (void*) s;
+ *(snippets[i].value) = s;
+ }
+ if (snippets[i].type == 't') { /* sequence of simple elements */
+ xmlNode *ts;
+ GList *s = NULL;
+ for (ts = t->children; ts; ts = ts->next) {
+ if (ts->type != XML_ELEMENT_NODE)
+ continue;
+ g_list_append(s, xmlNodeGetContent(ts));
+ }
+ *(snippets[i].value) = s;
}
- /* TODO: type 't' sequence of simple elements */
break;
}
}
@@ -767,7 +777,6 @@ void
lasso_node_build_xml_with_snippets(xmlNode *node, struct XmlSnippet *snippets)
{
int i;
- GList *next = NULL;
for (i = 0; snippets[i].name; i++) {
if (*(snippets[i].value) == NULL)
@@ -791,20 +800,20 @@ lasso_node_build_xml_with_snippets(xmlNode *node, struct XmlSnippet *snippets)
xmlSetNs(t, xmlns);
}
if (snippets[i].type == 's') { /* sequence of complex elements */
- next = (GList *)(*(snippets[i].value));
- while (next) {
- xmlAddChild(node, lasso_node_get_xmlNode(
- LASSO_NODE(next->data)));
- next = g_list_next(next);
+ GList *elem = (GList *)(*(snippets[i].value));
+ while (elem) {
+ xmlAddChild(node, lasso_node_get_xmlNode(LASSO_NODE(elem->data)));
+ elem = g_list_next(elem);
}
}
- if (snippets[i].type == 't') { /* sequence of simple elements (no children, no attrs, just content) */
- next = (GList *)(*(snippets[i].value));
- while (next) {
- xmlNewTextChild(node, NULL, snippets[i].name,
- (char*)(next->data));
- next = g_list_next(next);
+ if (snippets[i].type == 't') {
+ /* sequence of simple elements (no children, no attrs, just content) */
+ GList *elem = (GList *)(*(snippets[i].value));
+ while (elem) {
+ xmlNewTextChild(node, NULL, snippets[i].name, (char*)(elem->data));
+ elem = g_list_next(elem);
}
}
}
}
+