From 59bdda3549b13cbe97ce49fdb541f8bad006f08e Mon Sep 17 00:00:00 2001 From: Frederic Peters Date: Wed, 17 Nov 2004 23:04:57 +0000 Subject: use same "xmlsnippets" (name will probably change) to build xml nodes --- lasso/xml/lib_authn_response_envelope.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'lasso/xml/lib_authn_response_envelope.c') diff --git a/lasso/xml/lib_authn_response_envelope.c b/lasso/xml/lib_authn_response_envelope.c index 126fbcb8..ecef55bb 100644 --- a/lasso/xml/lib_authn_response_envelope.c +++ b/lasso/xml/lib_authn_response_envelope.c @@ -31,24 +31,27 @@ /* private methods */ /*****************************************************************************/ +#define snippets() \ + LassoLibAuthnResponseEnvelope *env = LASSO_LIB_AUTHN_RESPONSE_ENVELOPE(node); \ + struct XmlSnippet snippets[] = { \ + /* Extension */ \ + { "AuthnResponse", 'n', (void**)&(env->AuthnResponse) }, \ + { "AssertionConsumerServiceURL", 'c', \ + (void**)&(env->AssertionConsumerServiceURL) }, \ + { NULL, 0, NULL} \ + }; + static LassoNodeClass *parent_class = NULL; static xmlNode* get_xmlNode(LassoNode *node) { xmlNode *xmlnode; - LassoLibAuthnResponseEnvelope *env = LASSO_LIB_AUTHN_RESPONSE_ENVELOPE(node); + snippets(); xmlnode = xmlNewNode(NULL, "AuthnResponseEnvelope"); xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX)); - - if (env->Extension) - xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(env->Extension))); - if (env->AuthnResponse) - xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(env->AuthnResponse))); - if (env->AssertionConsumerServiceURL) - xmlNewTextChild(xmlnode, NULL, "AssertionConsumerServiceURL", - env->AssertionConsumerServiceURL); + lasso_node_build_xml_with_snippets(xmlnode, snippets); return xmlnode; } @@ -56,13 +59,7 @@ get_xmlNode(LassoNode *node) static int init_from_xml(LassoNode *node, xmlNode *xmlnode) { - LassoLibAuthnResponseEnvelope *env = LASSO_LIB_AUTHN_RESPONSE_ENVELOPE(node); - struct XmlSnippet snippets[] = { - /* Extension */ - { "AuthnResponse", 'n', (void**)&(env->AuthnResponse) }, - { "AssertionConsumerServiceURL", 'c', (void**)&(env->AssertionConsumerServiceURL) }, - { NULL, 0, NULL} - }; + snippets(); if (parent_class->init_from_xml(node, xmlnode)) return 1; -- cgit