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_request_authn_context.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'lasso/xml/lib_request_authn_context.c') diff --git a/lasso/xml/lib_request_authn_context.c b/lasso/xml/lib_request_authn_context.c index 5263fa7d..4a72216f 100644 --- a/lasso/xml/lib_request_authn_context.c +++ b/lasso/xml/lib_request_authn_context.c @@ -48,27 +48,28 @@ Schema fragment (liberty-idff-protocols-schema-v1.2.xsd): /* private methods */ /*****************************************************************************/ +#define snippets() \ + LassoLibRequestAuthnContext *context = LASSO_LIB_REQUEST_AUTHN_CONTEXT(node); \ + struct XmlSnippet snippets[] = { \ + { "AuthnContextClassRef", 'c', (void**)&(context->AuthnContextClassRef) }, \ + { "AuthnContextStatementRef", 'c', (void**)&(context->AuthnContextStatementRef) }, \ + { "AuthnContextComparisonType", 'c', \ + (void**)&(context->AuthnContextComparisonType) }, \ + { NULL, 0, NULL} \ + }; + static LassoNodeClass *parent_class = NULL; static xmlNode* get_xmlNode(LassoNode *node) { xmlNode *xmlnode; - LassoLibRequestAuthnContext *context = LASSO_LIB_REQUEST_AUTHN_CONTEXT(node); + snippets(); xmlnode = parent_class->get_xmlNode(node); xmlNodeSetName(xmlnode, "RequestAuthnContext"); xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX)); - - if (context->AuthnContextClassRef) - xmlNewTextChild(xmlnode, NULL, - "AuthnContextClassRef", context->AuthnContextClassRef); - if (context->AuthnContextStatementRef) - xmlNewTextChild(xmlnode, NULL, - "AuthnContextStatementRef", context->AuthnContextStatementRef); - if (context->AuthnContextComparisonType) - xmlNewTextChild(xmlnode, NULL, - "AuthnContextComparisonType", context->AuthnContextComparisonType); + lasso_node_build_xml_with_snippets(xmlnode, snippets); return xmlnode; } @@ -76,14 +77,7 @@ get_xmlNode(LassoNode *node) static int init_from_xml(LassoNode *node, xmlNode *xmlnode) { - LassoLibRequestAuthnContext *context = LASSO_LIB_REQUEST_AUTHN_CONTEXT(node); - struct XmlSnippet snippets[] = { - { "AuthnContextClassRef", 'c', (void**)&(context->AuthnContextClassRef) }, - { "AuthnContextStatementRef", 'c', (void**)&(context->AuthnContextStatementRef) }, - { "AuthnContextComparisonType", 'c', - (void**)&(context->AuthnContextComparisonType) }, - { NULL, 0, NULL} - }; + snippets(); if (parent_class->init_from_xml(node, xmlnode)) return -1; -- cgit