/* c/zx-wsse-dec.c - WARNING: This file was automatically generated. DO NOT EDIT! * $Id$ */ /* Code generation design Copyright (c) 2006 Sampo Kellomaki (sampo@iki.fi), * All Rights Reserved. NO WARRANTY. See file COPYING for terms and conditions * of use. Some aspects of code generation were driven by schema * descriptions that were used as input and may be subject to their own copyright. * Code generation uses a template, whose copyright statement follows. */ /** dec-templ.c - XML decoder template, used in code generation ** Copyright (c) 2006-2007 Symlabs (symlabs@symlabs.com), All Rights Reserved. ** Author: Sampo Kellomaki (sampo@iki.fi) ** This is confidential unpublished proprietary source code of the author. ** NO WARRANTY, not even implied warranties. Contains trade secrets. ** Distribution prohibited unless authorized in writing. ** Licensed under Apache License 2.0, see file COPYING. ** Id: dec-templ.c,v 1.29 2007-10-11 04:54:25 sampo Exp $ ** ** 28.5.2006, created, Sampo Kellomaki (sampo@iki.fi) ** 8.8.2006, reworked namespace handling --Sampo ** 12.8.2006, added special scanning of xmlns to avoid backtracking elem recognition --Sampo ** 23.9.2006, added collection of WO information --Sampo ** 21.6.2007, improved handling of undeclared namespace prefixes --Sampo ** ** N.B: This template is meant to be processed by pd/xsd2sg.pl. Beware ** of special markers that xsd2sg.pl expects to find and understand. **/ #include "errmac.h" #include "zx.h" #include "c/zx-const.h" #include "c/zx-data.h" #include "c/zx-wsse-data.h" #define TPF zx_ #ifndef ZX_ATTR_DEC_EXT #define ZX_ATTR_DEC_EXT(ss) /* Extension point called just after decoding known attribute */ #endif #ifndef ZX_XMLNS_DEC_EXT #define ZX_XMLNS_DEC_EXT(ss) /* Extension point called just after decoding xmlns attribute */ #endif #ifndef ZX_UNKNOWN_ATTR_DEC_EXT #define ZX_UNKNOWN_ATTR_DEC_EXT(ss) /* Extension point called just after decoding unknown attr */ #endif #ifndef ZX_START_DEC_EXT #define ZX_START_DEC_EXT(x) /* Extension point called just after decoding element name and allocating struct, but before decoding any of the attributes. */ #endif #ifndef ZX_END_DEC_EXT #define ZX_END_DEC_EXT(x) /* Extension point called just after decoding the entire element. */ #endif #ifndef ZX_START_BODY_DEC_EXT #define ZX_START_BODY_DEC_EXT(x) /* Extension point called just after decoding element tag, including attributes, but before decoding the body of the element. */ #endif #ifndef ZX_PI_DEC_EXT #define ZX_PI_DEC_EXT(pi) /* Extension point called just after decoding processing instruction */ #endif #ifndef ZX_COMMENT_DEC_EXT #define ZX_COMMENT_DEC_EXT(comment) /* Extension point called just after decoding comment */ #endif #ifndef ZX_CONTENT_DEC #define ZX_CONTENT_DEC(ss) /* Extension point called just after decoding string content */ #endif #ifndef ZX_UNKNOWN_ELEM_DEC_EXT #define ZX_UNKNOWN_ELEM_DEC_EXT(elem) /* Extension point called just after decoding unknown element */ #endif /* FUNC(zx_DEC_wsse_BinarySecurityToken) */ #define EL_NAME wsse_BinarySecurityToken #define EL_STRUCT zx_wsse_BinarySecurityToken_s #define EL_NS wsse #define EL_TAG BinarySecurityToken /* Called by: */ struct zx_wsse_BinarySecurityToken_s* zx_DEC_wsse_BinarySecurityToken(struct zx_ctx* c, struct zx_ns_s* ns ) { int tok; struct zx_elem_s* iternode; struct zx_elem_s* el; struct zx_str* ss; struct zx_ns_s* pop_seen; char* name; char* data; struct zx_wsse_BinarySecurityToken_s* x = ZX_ZALLOC(c, struct zx_wsse_BinarySecurityToken_s); x->gg.g.tok = zx_wsse_BinarySecurityToken_ELEM; x->gg.g.ns = ns; ZX_START_DEC_EXT(x); #if 1 /* NORMALMODE */ ZX_DEC_TAG_NOT_YET_CLOSED(x->gg.g); /* The tag name has already been detected. Process attributes until '>' */ for (; c->p; ++c->p) { ZX_SKIP_WS(c,x); if (ONE_OF_2(*c->p, '>', '/')) break; if (!(data = zx_dec_attr_val(c, &name))) return 0; tok = zx_attr_lookup(c, name, data-2, &ns); switch (tok) { case zx_EncodingType_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->EncodingType->g; x->EncodingType = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_ValueType_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->ValueType->g; x->ValueType = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_wsu_Id_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->Id->g; x->Id = ss; ZX_ATTR_DEC_EXT(ss); break; case ZX_TOK_XMLNS: ZX_XMLNS_DEC_EXT(ss); DD("xmlns detected(%.*s)", data-2-name, name); goto next_attr; default: ss = zx_dec_unknown_attr(c, &x->gg, name, data, tok, x->gg.g.tok); } ss->g.ns = ns; ss->g.tok = tok; ss->g.err |= ZXERR_ATTR_FLAG; ss->len = c->p - data; ss->s = data; next_attr: continue; } if (c->p) { ++c->p; if (c->p[-1] == '/' && c->p[0] == '>') { /* Tag without content */ ++c->p; ZX_DEC_TAG_NOW_CLOSED(x->gg.g); goto out; } } #endif /* Process contents until 'p) { next_elem: /*ZX_SKIP_WS(c,x); DO NOT SQUASH WS! EXC-CANON NEEDS IT. */ if (*c->p == '<') { potential_tag: ++c->p; switch (*c->p) { case '?': /* processing instruction */ case '!': /* comment */ if (zx_scan_pi_or_comment(c)) break; goto next_elem; case '/': /* close tag */ ++c->p; name = c->p; ZX_LOOK_FOR(c,'>'); #if defined(DEC_WRONG_ELEM) if (c->p-name != namlen || memcmp(name, nam, namlen)) #else tok = zx_elem_lookup(c, name, c->p, &ns); if (tok != x->gg.g.tok) #endif { ERR("Mismatching close tag(%.*s) tok=%d context=%d", c->p-name, name, tok, x->gg.g.tok); zx_xml_parse_err(c, '-', __FUNCTION__, "Mismatching close tag"); ZX_DEC_TAG_MISMATCH_CLOSE(x->gg.g); ++c->p; return x; } /* Legitimate close tag. Normal exit from this function. */ ++c->p; ZX_DEC_TAG_NOW_CLOSED(x->gg.g); goto out; default: if (A_Z_a_z_(*c->p)) { name = c->p; for (++c->p; *c->p && !ONE_OF_6(*c->p, ' ', '>', '/', '\n', '\r', '\t'); ++c->p) ; if (!c->p) return 0; pop_seen = zx_scan_xmlns(c); /* Prescan namespaces so that token can be correctly recognized. */ tok = zx_elem_lookup(c, name, c->p, &ns); switch (tok) { default: el = zx_known_or_unknown_elem(c, tok, &x->gg, c->p - name, name, ns); tok = ZX_TOK_NOT_FOUND; break; } el->g.wo = &x->gg.kids->g; x->gg.kids = el; zx_pop_seen(pop_seen); goto next_elem; } } /* false alarm <, fall thru */ } if (!zx_scan_data(c, &x->gg)) return x; goto potential_tag; } out: iternode = x->gg.kids; REVERSE_LIST_NEXT(x->gg.kids, iternode, g.wo); ZX_END_DEC_EXT(x); return x; look_for_not_found: zx_xml_parse_err(c, '>', __FUNCTION__, "char not found"); return x; } #undef EL_NAME #undef EL_STRUCT #undef EL_NS #undef EL_TAG /* FUNC(zx_DEC_wsse_Embedded) */ #define EL_NAME wsse_Embedded #define EL_STRUCT zx_wsse_Embedded_s #define EL_NS wsse #define EL_TAG Embedded /* Called by: */ struct zx_wsse_Embedded_s* zx_DEC_wsse_Embedded(struct zx_ctx* c, struct zx_ns_s* ns ) { int tok; struct zx_elem_s* iternode; struct zx_elem_s* el; struct zx_str* ss; struct zx_ns_s* pop_seen; char* name; char* data; struct zx_wsse_Embedded_s* x = ZX_ZALLOC(c, struct zx_wsse_Embedded_s); x->gg.g.tok = zx_wsse_Embedded_ELEM; x->gg.g.ns = ns; ZX_START_DEC_EXT(x); #if 1 /* NORMALMODE */ ZX_DEC_TAG_NOT_YET_CLOSED(x->gg.g); /* The tag name has already been detected. Process attributes until '>' */ for (; c->p; ++c->p) { ZX_SKIP_WS(c,x); if (ONE_OF_2(*c->p, '>', '/')) break; if (!(data = zx_dec_attr_val(c, &name))) return 0; tok = zx_attr_lookup(c, name, data-2, &ns); switch (tok) { case zx_ValueType_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->ValueType->g; x->ValueType = ss; ZX_ATTR_DEC_EXT(ss); break; case ZX_TOK_XMLNS: ZX_XMLNS_DEC_EXT(ss); DD("xmlns detected(%.*s)", data-2-name, name); goto next_attr; default: ss = zx_dec_unknown_attr(c, &x->gg, name, data, tok, x->gg.g.tok); } ss->g.ns = ns; ss->g.tok = tok; ss->g.err |= ZXERR_ATTR_FLAG; ss->len = c->p - data; ss->s = data; next_attr: continue; } if (c->p) { ++c->p; if (c->p[-1] == '/' && c->p[0] == '>') { /* Tag without content */ ++c->p; ZX_DEC_TAG_NOW_CLOSED(x->gg.g); goto out; } } #endif /* Process contents until 'p) { next_elem: /*ZX_SKIP_WS(c,x); DO NOT SQUASH WS! EXC-CANON NEEDS IT. */ if (*c->p == '<') { potential_tag: ++c->p; switch (*c->p) { case '?': /* processing instruction */ case '!': /* comment */ if (zx_scan_pi_or_comment(c)) break; goto next_elem; case '/': /* close tag */ ++c->p; name = c->p; ZX_LOOK_FOR(c,'>'); #if defined(DEC_WRONG_ELEM) if (c->p-name != namlen || memcmp(name, nam, namlen)) #else tok = zx_elem_lookup(c, name, c->p, &ns); if (tok != x->gg.g.tok) #endif { ERR("Mismatching close tag(%.*s) tok=%d context=%d", c->p-name, name, tok, x->gg.g.tok); zx_xml_parse_err(c, '-', __FUNCTION__, "Mismatching close tag"); ZX_DEC_TAG_MISMATCH_CLOSE(x->gg.g); ++c->p; return x; } /* Legitimate close tag. Normal exit from this function. */ ++c->p; ZX_DEC_TAG_NOW_CLOSED(x->gg.g); goto out; default: if (A_Z_a_z_(*c->p)) { name = c->p; for (++c->p; *c->p && !ONE_OF_6(*c->p, ' ', '>', '/', '\n', '\r', '\t'); ++c->p) ; if (!c->p) return 0; pop_seen = zx_scan_xmlns(c); /* Prescan namespaces so that token can be correctly recognized. */ tok = zx_elem_lookup(c, name, c->p, &ns); switch (tok) { default: el = zx_known_or_unknown_elem(c, tok, &x->gg, c->p - name, name, ns); tok = ZX_TOK_NOT_FOUND; break; } el->g.wo = &x->gg.kids->g; x->gg.kids = el; zx_pop_seen(pop_seen); goto next_elem; } } /* false alarm <, fall thru */ } if (!zx_scan_data(c, &x->gg)) return x; goto potential_tag; } out: iternode = x->gg.kids; REVERSE_LIST_NEXT(x->gg.kids, iternode, g.wo); ZX_END_DEC_EXT(x); return x; look_for_not_found: zx_xml_parse_err(c, '>', __FUNCTION__, "char not found"); return x; } #undef EL_NAME #undef EL_STRUCT #undef EL_NS #undef EL_TAG /* FUNC(zx_DEC_wsse_KeyIdentifier) */ #define EL_NAME wsse_KeyIdentifier #define EL_STRUCT zx_wsse_KeyIdentifier_s #define EL_NS wsse #define EL_TAG KeyIdentifier /* Called by: */ struct zx_wsse_KeyIdentifier_s* zx_DEC_wsse_KeyIdentifier(struct zx_ctx* c, struct zx_ns_s* ns ) { int tok; struct zx_elem_s* iternode; struct zx_elem_s* el; struct zx_str* ss; struct zx_ns_s* pop_seen; char* name; char* data; struct zx_wsse_KeyIdentifier_s* x = ZX_ZALLOC(c, struct zx_wsse_KeyIdentifier_s); x->gg.g.tok = zx_wsse_KeyIdentifier_ELEM; x->gg.g.ns = ns; ZX_START_DEC_EXT(x); #if 1 /* NORMALMODE */ ZX_DEC_TAG_NOT_YET_CLOSED(x->gg.g); /* The tag name has already been detected. Process attributes until '>' */ for (; c->p; ++c->p) { ZX_SKIP_WS(c,x); if (ONE_OF_2(*c->p, '>', '/')) break; if (!(data = zx_dec_attr_val(c, &name))) return 0; tok = zx_attr_lookup(c, name, data-2, &ns); switch (tok) { case zx_EncodingType_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->EncodingType->g; x->EncodingType = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_ValueType_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->ValueType->g; x->ValueType = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_wsu_Id_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->Id->g; x->Id = ss; ZX_ATTR_DEC_EXT(ss); break; case ZX_TOK_XMLNS: ZX_XMLNS_DEC_EXT(ss); DD("xmlns detected(%.*s)", data-2-name, name); goto next_attr; default: ss = zx_dec_unknown_attr(c, &x->gg, name, data, tok, x->gg.g.tok); } ss->g.ns = ns; ss->g.tok = tok; ss->g.err |= ZXERR_ATTR_FLAG; ss->len = c->p - data; ss->s = data; next_attr: continue; } if (c->p) { ++c->p; if (c->p[-1] == '/' && c->p[0] == '>') { /* Tag without content */ ++c->p; ZX_DEC_TAG_NOW_CLOSED(x->gg.g); goto out; } } #endif /* Process contents until 'p) { next_elem: /*ZX_SKIP_WS(c,x); DO NOT SQUASH WS! EXC-CANON NEEDS IT. */ if (*c->p == '<') { potential_tag: ++c->p; switch (*c->p) { case '?': /* processing instruction */ case '!': /* comment */ if (zx_scan_pi_or_comment(c)) break; goto next_elem; case '/': /* close tag */ ++c->p; name = c->p; ZX_LOOK_FOR(c,'>'); #if defined(DEC_WRONG_ELEM) if (c->p-name != namlen || memcmp(name, nam, namlen)) #else tok = zx_elem_lookup(c, name, c->p, &ns); if (tok != x->gg.g.tok) #endif { ERR("Mismatching close tag(%.*s) tok=%d context=%d", c->p-name, name, tok, x->gg.g.tok); zx_xml_parse_err(c, '-', __FUNCTION__, "Mismatching close tag"); ZX_DEC_TAG_MISMATCH_CLOSE(x->gg.g); ++c->p; return x; } /* Legitimate close tag. Normal exit from this function. */ ++c->p; ZX_DEC_TAG_NOW_CLOSED(x->gg.g); goto out; default: if (A_Z_a_z_(*c->p)) { name = c->p; for (++c->p; *c->p && !ONE_OF_6(*c->p, ' ', '>', '/', '\n', '\r', '\t'); ++c->p) ; if (!c->p) return 0; pop_seen = zx_scan_xmlns(c); /* Prescan namespaces so that token can be correctly recognized. */ tok = zx_elem_lookup(c, name, c->p, &ns); switch (tok) { default: el = zx_known_or_unknown_elem(c, tok, &x->gg, c->p - name, name, ns); tok = ZX_TOK_NOT_FOUND; break; } el->g.wo = &x->gg.kids->g; x->gg.kids = el; zx_pop_seen(pop_seen); goto next_elem; } } /* false alarm <, fall thru */ } if (!zx_scan_data(c, &x->gg)) return x; goto potential_tag; } out: iternode = x->gg.kids; REVERSE_LIST_NEXT(x->gg.kids, iternode, g.wo); ZX_END_DEC_EXT(x); return x; look_for_not_found: zx_xml_parse_err(c, '>', __FUNCTION__, "char not found"); return x; } #undef EL_NAME #undef EL_STRUCT #undef EL_NS #undef EL_TAG /* FUNC(zx_DEC_wsse_Nonce) */ #define EL_NAME wsse_Nonce #define EL_STRUCT zx_wsse_Nonce_s #define EL_NS wsse #define EL_TAG Nonce /* Called by: */ struct zx_wsse_Nonce_s* zx_DEC_wsse_Nonce(struct zx_ctx* c, struct zx_ns_s* ns ) { int tok; struct zx_elem_s* iternode; struct zx_elem_s* el; struct zx_str* ss; struct zx_ns_s* pop_seen; char* name; char* data; struct zx_wsse_Nonce_s* x = ZX_ZALLOC(c, struct zx_wsse_Nonce_s); x->gg.g.tok = zx_wsse_Nonce_ELEM; x->gg.g.ns = ns; ZX_START_DEC_EXT(x); #if 1 /* NORMALMODE */ ZX_DEC_TAG_NOT_YET_CLOSED(x->gg.g); /* The tag name has already been detected. Process attributes until '>' */ for (; c->p; ++c->p) { ZX_SKIP_WS(c,x); if (ONE_OF_2(*c->p, '>', '/')) break; if (!(data = zx_dec_attr_val(c, &name))) return 0; tok = zx_attr_lookup(c, name, data-2, &ns); switch (tok) { case zx_EncodingType_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->EncodingType->g; x->EncodingType = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_wsu_Id_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->Id->g; x->Id = ss; ZX_ATTR_DEC_EXT(ss); break; case ZX_TOK_XMLNS: ZX_XMLNS_DEC_EXT(ss); DD("xmlns detected(%.*s)", data-2-name, name); goto next_attr; default: ss = zx_dec_unknown_attr(c, &x->gg, name, data, tok, x->gg.g.tok); } ss->g.ns = ns; ss->g.tok = tok; ss->g.err |= ZXERR_ATTR_FLAG; ss->len = c->p - data; ss->s = data; next_attr: continue; } if (c->p) { ++c->p; if (c->p[-1] == '/' && c->p[0] == '>') { /* Tag without content */ ++c->p; ZX_DEC_TAG_NOW_CLOSED(x->gg.g); goto out; } } #endif /* Process contents until 'p) { next_elem: /*ZX_SKIP_WS(c,x); DO NOT SQUASH WS! EXC-CANON NEEDS IT. */ if (*c->p == '<') { potential_tag: ++c->p; switch (*c->p) { case '?': /* processing instruction */ case '!': /* comment */ if (zx_scan_pi_or_comment(c)) break; goto next_elem; case '/': /* close tag */ ++c->p; name = c->p; ZX_LOOK_FOR(c,'>'); #if defined(DEC_WRONG_ELEM) if (c->p-name != namlen || memcmp(name, nam, namlen)) #else tok = zx_elem_lookup(c, name, c->p, &ns); if (tok != x->gg.g.tok) #endif { ERR("Mismatching close tag(%.*s) tok=%d context=%d", c->p-name, name, tok, x->gg.g.tok); zx_xml_parse_err(c, '-', __FUNCTION__, "Mismatching close tag"); ZX_DEC_TAG_MISMATCH_CLOSE(x->gg.g); ++c->p; return x; } /* Legitimate close tag. Normal exit from this function. */ ++c->p; ZX_DEC_TAG_NOW_CLOSED(x->gg.g); goto out; default: if (A_Z_a_z_(*c->p)) { name = c->p; for (++c->p; *c->p && !ONE_OF_6(*c->p, ' ', '>', '/', '\n', '\r', '\t'); ++c->p) ; if (!c->p) return 0; pop_seen = zx_scan_xmlns(c); /* Prescan namespaces so that token can be correctly recognized. */ tok = zx_elem_lookup(c, name, c->p, &ns); switch (tok) { default: el = zx_known_or_unknown_elem(c, tok, &x->gg, c->p - name, name, ns); tok = ZX_TOK_NOT_FOUND; break; } el->g.wo = &x->gg.kids->g; x->gg.kids = el; zx_pop_seen(pop_seen); goto next_elem; } } /* false alarm <, fall thru */ } if (!zx_scan_data(c, &x->gg)) return x; goto potential_tag; } out: iternode = x->gg.kids; REVERSE_LIST_NEXT(x->gg.kids, iternode, g.wo); ZX_END_DEC_EXT(x); return x; look_for_not_found: zx_xml_parse_err(c, '>', __FUNCTION__, "char not found"); return x; } #undef EL_NAME #undef EL_STRUCT #undef EL_NS #undef EL_TAG /* FUNC(zx_DEC_wsse_Password) */ #define EL_NAME wsse_Password #define EL_STRUCT zx_wsse_Password_s #define EL_NS wsse #define EL_TAG Password /* Called by: */ struct zx_wsse_Password_s* zx_DEC_wsse_Password(struct zx_ctx* c, struct zx_ns_s* ns ) { int tok; struct zx_elem_s* iternode; struct zx_elem_s* el; struct zx_str* ss; struct zx_ns_s* pop_seen; char* name; char* data; struct zx_wsse_Password_s* x = ZX_ZALLOC(c, struct zx_wsse_Password_s); x->gg.g.tok = zx_wsse_Password_ELEM; x->gg.g.ns = ns; ZX_START_DEC_EXT(x); #if 1 /* NORMALMODE */ ZX_DEC_TAG_NOT_YET_CLOSED(x->gg.g); /* The tag name has already been detected. Process attributes until '>' */ for (; c->p; ++c->p) { ZX_SKIP_WS(c,x); if (ONE_OF_2(*c->p, '>', '/')) break; if (!(data = zx_dec_attr_val(c, &name))) return 0; tok = zx_attr_lookup(c, name, data-2, &ns); switch (tok) { case zx_Type_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->Type->g; x->Type = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_wsu_Id_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->Id->g; x->Id = ss; ZX_ATTR_DEC_EXT(ss); break; case ZX_TOK_XMLNS: ZX_XMLNS_DEC_EXT(ss); DD("xmlns detected(%.*s)", data-2-name, name); goto next_attr; default: ss = zx_dec_unknown_attr(c, &x->gg, name, data, tok, x->gg.g.tok); } ss->g.ns = ns; ss->g.tok = tok; ss->g.err |= ZXERR_ATTR_FLAG; ss->len = c->p - data; ss->s = data; next_attr: continue; } if (c->p) { ++c->p; if (c->p[-1] == '/' && c->p[0] == '>') { /* Tag without content */ ++c->p; ZX_DEC_TAG_NOW_CLOSED(x->gg.g); goto out; } } #endif /* Process contents until 'p) { next_elem: /*ZX_SKIP_WS(c,x); DO NOT SQUASH WS! EXC-CANON NEEDS IT. */ if (*c->p == '<') { potential_tag: ++c->p; switch (*c->p) { case '?': /* processing instruction */ case '!': /* comment */ if (zx_scan_pi_or_comment(c)) break; goto next_elem; case '/': /* close tag */ ++c->p; name = c->p; ZX_LOOK_FOR(c,'>'); #if defined(DEC_WRONG_ELEM) if (c->p-name != namlen || memcmp(name, nam, namlen)) #else tok = zx_elem_lookup(c, name, c->p, &ns); if (tok != x->gg.g.tok) #endif { ERR("Mismatching close tag(%.*s) tok=%d context=%d", c->p-name, name, tok, x->gg.g.tok); zx_xml_parse_err(c, '-', __FUNCTION__, "Mismatching close tag"); ZX_DEC_TAG_MISMATCH_CLOSE(x->gg.g); ++c->p; return x; } /* Legitimate close tag. Normal exit from this function. */ ++c->p; ZX_DEC_TAG_NOW_CLOSED(x->gg.g); goto out; default: if (A_Z_a_z_(*c->p)) { name = c->p; for (++c->p; *c->p && !ONE_OF_6(*c->p, ' ', '>', '/', '\n', '\r', '\t'); ++c->p) ; if (!c->p) return 0; pop_seen = zx_scan_xmlns(c); /* Prescan namespaces so that token can be correctly recognized. */ tok = zx_elem_lookup(c, name, c->p, &ns); switch (tok) { default: el = zx_known_or_unknown_elem(c, tok, &x->gg, c->p - name, name, ns); tok = ZX_TOK_NOT_FOUND; break; } el->g.wo = &x->gg.kids->g; x->gg.kids = el; zx_pop_seen(pop_seen); goto next_elem; } } /* false alarm <, fall thru */ } if (!zx_scan_data(c, &x->gg)) return x; goto potential_tag; } out: iternode = x->gg.kids; REVERSE_LIST_NEXT(x->gg.kids, iternode, g.wo); ZX_END_DEC_EXT(x); return x; look_for_not_found: zx_xml_parse_err(c, '>', __FUNCTION__, "char not found"); return x; } #undef EL_NAME #undef EL_STRUCT #undef EL_NS #undef EL_TAG /* FUNC(zx_DEC_wsse_Reference) */ #define EL_NAME wsse_Reference #define EL_STRUCT zx_wsse_Reference_s #define EL_NS wsse #define EL_TAG Reference /* Called by: */ struct zx_wsse_Reference_s* zx_DEC_wsse_Reference(struct zx_ctx* c, struct zx_ns_s* ns ) { int tok; struct zx_elem_s* iternode; struct zx_elem_s* el; struct zx_str* ss; struct zx_ns_s* pop_seen; char* name; char* data; struct zx_wsse_Reference_s* x = ZX_ZALLOC(c, struct zx_wsse_Reference_s); x->gg.g.tok = zx_wsse_Reference_ELEM; x->gg.g.ns = ns; ZX_START_DEC_EXT(x); #if 1 /* NORMALMODE */ ZX_DEC_TAG_NOT_YET_CLOSED(x->gg.g); /* The tag name has already been detected. Process attributes until '>' */ for (; c->p; ++c->p) { ZX_SKIP_WS(c,x); if (ONE_OF_2(*c->p, '>', '/')) break; if (!(data = zx_dec_attr_val(c, &name))) return 0; tok = zx_attr_lookup(c, name, data-2, &ns); switch (tok) { case zx_URI_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->URI->g; x->URI = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_ValueType_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->ValueType->g; x->ValueType = ss; ZX_ATTR_DEC_EXT(ss); break; case ZX_TOK_XMLNS: ZX_XMLNS_DEC_EXT(ss); DD("xmlns detected(%.*s)", data-2-name, name); goto next_attr; default: ss = zx_dec_unknown_attr(c, &x->gg, name, data, tok, x->gg.g.tok); } ss->g.ns = ns; ss->g.tok = tok; ss->g.err |= ZXERR_ATTR_FLAG; ss->len = c->p - data; ss->s = data; next_attr: continue; } if (c->p) { ++c->p; if (c->p[-1] == '/' && c->p[0] == '>') { /* Tag without content */ ++c->p; ZX_DEC_TAG_NOW_CLOSED(x->gg.g); goto out; } } #endif /* Process contents until 'p) { next_elem: /*ZX_SKIP_WS(c,x); DO NOT SQUASH WS! EXC-CANON NEEDS IT. */ if (*c->p == '<') { potential_tag: ++c->p; switch (*c->p) { case '?': /* processing instruction */ case '!': /* comment */ if (zx_scan_pi_or_comment(c)) break; goto next_elem; case '/': /* close tag */ ++c->p; name = c->p; ZX_LOOK_FOR(c,'>'); #if defined(DEC_WRONG_ELEM) if (c->p-name != namlen || memcmp(name, nam, namlen)) #else tok = zx_elem_lookup(c, name, c->p, &ns); if (tok != x->gg.g.tok) #endif { ERR("Mismatching close tag(%.*s) tok=%d context=%d", c->p-name, name, tok, x->gg.g.tok); zx_xml_parse_err(c, '-', __FUNCTION__, "Mismatching close tag"); ZX_DEC_TAG_MISMATCH_CLOSE(x->gg.g); ++c->p; return x; } /* Legitimate close tag. Normal exit from this function. */ ++c->p; ZX_DEC_TAG_NOW_CLOSED(x->gg.g); goto out; default: if (A_Z_a_z_(*c->p)) { name = c->p; for (++c->p; *c->p && !ONE_OF_6(*c->p, ' ', '>', '/', '\n', '\r', '\t'); ++c->p) ; if (!c->p) return 0; pop_seen = zx_scan_xmlns(c); /* Prescan namespaces so that token can be correctly recognized. */ tok = zx_elem_lookup(c, name, c->p, &ns); switch (tok) { default: el = zx_known_or_unknown_elem(c, tok, &x->gg, c->p - name, name, ns); tok = ZX_TOK_NOT_FOUND; break; } el->g.wo = &x->gg.kids->g; x->gg.kids = el; zx_pop_seen(pop_seen); goto next_elem; } } /* false alarm <, fall thru */ } if (!zx_scan_data(c, &x->gg)) return x; goto potential_tag; } out: iternode = x->gg.kids; REVERSE_LIST_NEXT(x->gg.kids, iternode, g.wo); ZX_END_DEC_EXT(x); return x; look_for_not_found: zx_xml_parse_err(c, '>', __FUNCTION__, "char not found"); return x; } #undef EL_NAME #undef EL_STRUCT #undef EL_NS #undef EL_TAG /* FUNC(zx_DEC_wsse_Security) */ #define EL_NAME wsse_Security #define EL_STRUCT zx_wsse_Security_s #define EL_NS wsse #define EL_TAG Security /* Called by: */ struct zx_wsse_Security_s* zx_DEC_wsse_Security(struct zx_ctx* c, struct zx_ns_s* ns ) { int tok; struct zx_elem_s* iternode; struct zx_elem_s* el; struct zx_str* ss; struct zx_ns_s* pop_seen; char* name; char* data; struct zx_wsse_Security_s* x = ZX_ZALLOC(c, struct zx_wsse_Security_s); x->gg.g.tok = zx_wsse_Security_ELEM; x->gg.g.ns = ns; ZX_START_DEC_EXT(x); #if 1 /* NORMALMODE */ ZX_DEC_TAG_NOT_YET_CLOSED(x->gg.g); /* The tag name has already been detected. Process attributes until '>' */ for (; c->p; ++c->p) { ZX_SKIP_WS(c,x); if (ONE_OF_2(*c->p, '>', '/')) break; if (!(data = zx_dec_attr_val(c, &name))) return 0; tok = zx_attr_lookup(c, name, data-2, &ns); switch (tok) { case zx_wsu_Id_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->Id->g; x->Id = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_e_actor_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->actor->g; x->actor = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_e_mustUnderstand_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->mustUnderstand->g; x->mustUnderstand = ss; ZX_ATTR_DEC_EXT(ss); break; case ZX_TOK_XMLNS: ZX_XMLNS_DEC_EXT(ss); DD("xmlns detected(%.*s)", data-2-name, name); goto next_attr; default: ss = zx_dec_unknown_attr(c, &x->gg, name, data, tok, x->gg.g.tok); } ss->g.ns = ns; ss->g.tok = tok; ss->g.err |= ZXERR_ATTR_FLAG; ss->len = c->p - data; ss->s = data; next_attr: continue; } if (c->p) { ++c->p; if (c->p[-1] == '/' && c->p[0] == '>') { /* Tag without content */ ++c->p; ZX_DEC_TAG_NOW_CLOSED(x->gg.g); goto out; } } #endif /* Process contents until 'p) { next_elem: /*ZX_SKIP_WS(c,x); DO NOT SQUASH WS! EXC-CANON NEEDS IT. */ if (*c->p == '<') { potential_tag: ++c->p; switch (*c->p) { case '?': /* processing instruction */ case '!': /* comment */ if (zx_scan_pi_or_comment(c)) break; goto next_elem; case '/': /* close tag */ ++c->p; name = c->p; ZX_LOOK_FOR(c,'>'); #if defined(DEC_WRONG_ELEM) if (c->p-name != namlen || memcmp(name, nam, namlen)) #else tok = zx_elem_lookup(c, name, c->p, &ns); if (tok != x->gg.g.tok) #endif { ERR("Mismatching close tag(%.*s) tok=%d context=%d", c->p-name, name, tok, x->gg.g.tok); zx_xml_parse_err(c, '-', __FUNCTION__, "Mismatching close tag"); ZX_DEC_TAG_MISMATCH_CLOSE(x->gg.g); ++c->p; return x; } /* Legitimate close tag. Normal exit from this function. */ ++c->p; ZX_DEC_TAG_NOW_CLOSED(x->gg.g); goto out; default: if (A_Z_a_z_(*c->p)) { name = c->p; for (++c->p; *c->p && !ONE_OF_6(*c->p, ' ', '>', '/', '\n', '\r', '\t'); ++c->p) ; if (!c->p) return 0; pop_seen = zx_scan_xmlns(c); /* Prescan namespaces so that token can be correctly recognized. */ tok = zx_elem_lookup(c, name, c->p, &ns); switch (tok) { case zx_ds_Signature_ELEM: el = (struct zx_elem_s*)zx_DEC_ds_Signature(c, ns); el->g.n = &x->Signature->gg.g; x->Signature = (struct zx_ds_Signature_s*)el; break; case zx_sa_Assertion_ELEM: el = (struct zx_elem_s*)zx_DEC_sa_Assertion(c, ns); el->g.n = &x->Assertion->gg.g; x->Assertion = (struct zx_sa_Assertion_s*)el; break; case zx_sa11_Assertion_ELEM: el = (struct zx_elem_s*)zx_DEC_sa11_Assertion(c, ns); el->g.n = &x->sa11_Assertion->gg.g; x->sa11_Assertion = (struct zx_sa11_Assertion_s*)el; break; case zx_ff12_Assertion_ELEM: el = (struct zx_elem_s*)zx_DEC_ff12_Assertion(c, ns); el->g.n = &x->ff12_Assertion->gg.g; x->ff12_Assertion = (struct zx_ff12_Assertion_s*)el; break; case zx_wsse_BinarySecurityToken_ELEM: el = (struct zx_elem_s*)zx_DEC_wsse_BinarySecurityToken(c, ns); el->g.n = &x->BinarySecurityToken->gg.g; x->BinarySecurityToken = (struct zx_wsse_BinarySecurityToken_s*)el; break; case zx_wsse_SecurityTokenReference_ELEM: el = (struct zx_elem_s*)zx_DEC_wsse_SecurityTokenReference(c, ns); el->g.n = &x->SecurityTokenReference->gg.g; x->SecurityTokenReference = (struct zx_wsse_SecurityTokenReference_s*)el; break; case zx_wsu_Timestamp_ELEM: el = (struct zx_elem_s*)zx_DEC_wsu_Timestamp(c, ns); el->g.n = &x->Timestamp->gg.g; x->Timestamp = (struct zx_wsu_Timestamp_s*)el; break; default: el = zx_known_or_unknown_elem(c, tok, &x->gg, c->p - name, name, ns); tok = ZX_TOK_NOT_FOUND; break; } el->g.wo = &x->gg.kids->g; x->gg.kids = el; zx_pop_seen(pop_seen); goto next_elem; } } /* false alarm <, fall thru */ } if (!zx_scan_data(c, &x->gg)) return x; goto potential_tag; } out: iternode = x->gg.kids; REVERSE_LIST_NEXT(x->gg.kids, iternode, g.wo); ZX_END_DEC_EXT(x); return x; look_for_not_found: zx_xml_parse_err(c, '>', __FUNCTION__, "char not found"); return x; } #undef EL_NAME #undef EL_STRUCT #undef EL_NS #undef EL_TAG /* FUNC(zx_DEC_wsse_SecurityTokenReference) */ #define EL_NAME wsse_SecurityTokenReference #define EL_STRUCT zx_wsse_SecurityTokenReference_s #define EL_NS wsse #define EL_TAG SecurityTokenReference /* Called by: */ struct zx_wsse_SecurityTokenReference_s* zx_DEC_wsse_SecurityTokenReference(struct zx_ctx* c, struct zx_ns_s* ns ) { int tok; struct zx_elem_s* iternode; struct zx_elem_s* el; struct zx_str* ss; struct zx_ns_s* pop_seen; char* name; char* data; struct zx_wsse_SecurityTokenReference_s* x = ZX_ZALLOC(c, struct zx_wsse_SecurityTokenReference_s); x->gg.g.tok = zx_wsse_SecurityTokenReference_ELEM; x->gg.g.ns = ns; ZX_START_DEC_EXT(x); #if 1 /* NORMALMODE */ ZX_DEC_TAG_NOT_YET_CLOSED(x->gg.g); /* The tag name has already been detected. Process attributes until '>' */ for (; c->p; ++c->p) { ZX_SKIP_WS(c,x); if (ONE_OF_2(*c->p, '>', '/')) break; if (!(data = zx_dec_attr_val(c, &name))) return 0; tok = zx_attr_lookup(c, name, data-2, &ns); switch (tok) { case zx_wsse_Usage_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->Usage->g; x->Usage = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_wsu_Id_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->Id->g; x->Id = ss; ZX_ATTR_DEC_EXT(ss); break; case ZX_TOK_XMLNS: ZX_XMLNS_DEC_EXT(ss); DD("xmlns detected(%.*s)", data-2-name, name); goto next_attr; default: ss = zx_dec_unknown_attr(c, &x->gg, name, data, tok, x->gg.g.tok); } ss->g.ns = ns; ss->g.tok = tok; ss->g.err |= ZXERR_ATTR_FLAG; ss->len = c->p - data; ss->s = data; next_attr: continue; } if (c->p) { ++c->p; if (c->p[-1] == '/' && c->p[0] == '>') { /* Tag without content */ ++c->p; ZX_DEC_TAG_NOW_CLOSED(x->gg.g); goto out; } } #endif /* Process contents until 'p) { next_elem: /*ZX_SKIP_WS(c,x); DO NOT SQUASH WS! EXC-CANON NEEDS IT. */ if (*c->p == '<') { potential_tag: ++c->p; switch (*c->p) { case '?': /* processing instruction */ case '!': /* comment */ if (zx_scan_pi_or_comment(c)) break; goto next_elem; case '/': /* close tag */ ++c->p; name = c->p; ZX_LOOK_FOR(c,'>'); #if defined(DEC_WRONG_ELEM) if (c->p-name != namlen || memcmp(name, nam, namlen)) #else tok = zx_elem_lookup(c, name, c->p, &ns); if (tok != x->gg.g.tok) #endif { ERR("Mismatching close tag(%.*s) tok=%d context=%d", c->p-name, name, tok, x->gg.g.tok); zx_xml_parse_err(c, '-', __FUNCTION__, "Mismatching close tag"); ZX_DEC_TAG_MISMATCH_CLOSE(x->gg.g); ++c->p; return x; } /* Legitimate close tag. Normal exit from this function. */ ++c->p; ZX_DEC_TAG_NOW_CLOSED(x->gg.g); goto out; default: if (A_Z_a_z_(*c->p)) { name = c->p; for (++c->p; *c->p && !ONE_OF_6(*c->p, ' ', '>', '/', '\n', '\r', '\t'); ++c->p) ; if (!c->p) return 0; pop_seen = zx_scan_xmlns(c); /* Prescan namespaces so that token can be correctly recognized. */ tok = zx_elem_lookup(c, name, c->p, &ns); switch (tok) { case zx_wsse_KeyIdentifier_ELEM: el = (struct zx_elem_s*)zx_DEC_wsse_KeyIdentifier(c, ns); el->g.n = &x->KeyIdentifier->gg.g; x->KeyIdentifier = (struct zx_wsse_KeyIdentifier_s*)el; break; default: el = zx_known_or_unknown_elem(c, tok, &x->gg, c->p - name, name, ns); tok = ZX_TOK_NOT_FOUND; break; } el->g.wo = &x->gg.kids->g; x->gg.kids = el; zx_pop_seen(pop_seen); goto next_elem; } } /* false alarm <, fall thru */ } if (!zx_scan_data(c, &x->gg)) return x; goto potential_tag; } out: iternode = x->gg.kids; REVERSE_LIST_NEXT(x->gg.kids, iternode, g.wo); ZX_END_DEC_EXT(x); return x; look_for_not_found: zx_xml_parse_err(c, '>', __FUNCTION__, "char not found"); return x; } #undef EL_NAME #undef EL_STRUCT #undef EL_NS #undef EL_TAG /* FUNC(zx_DEC_wsse_TransformationParameters) */ #define EL_NAME wsse_TransformationParameters #define EL_STRUCT zx_wsse_TransformationParameters_s #define EL_NS wsse #define EL_TAG TransformationParameters /* Called by: */ struct zx_wsse_TransformationParameters_s* zx_DEC_wsse_TransformationParameters(struct zx_ctx* c, struct zx_ns_s* ns ) { int tok; struct zx_elem_s* iternode; struct zx_elem_s* el; struct zx_str* ss; struct zx_ns_s* pop_seen; char* name; char* data; struct zx_wsse_TransformationParameters_s* x = ZX_ZALLOC(c, struct zx_wsse_TransformationParameters_s); x->gg.g.tok = zx_wsse_TransformationParameters_ELEM; x->gg.g.ns = ns; ZX_START_DEC_EXT(x); #if 1 /* NORMALMODE */ ZX_DEC_TAG_NOT_YET_CLOSED(x->gg.g); /* The tag name has already been detected. Process attributes until '>' */ for (; c->p; ++c->p) { ZX_SKIP_WS(c,x); if (ONE_OF_2(*c->p, '>', '/')) break; if (!(data = zx_dec_attr_val(c, &name))) return 0; tok = zx_attr_lookup(c, name, data-2, &ns); switch (tok) { case ZX_TOK_XMLNS: ZX_XMLNS_DEC_EXT(ss); DD("xmlns detected(%.*s)", data-2-name, name); goto next_attr; default: ss = zx_dec_unknown_attr(c, &x->gg, name, data, tok, x->gg.g.tok); } ss->g.ns = ns; ss->g.tok = tok; ss->g.err |= ZXERR_ATTR_FLAG; ss->len = c->p - data; ss->s = data; next_attr: continue; } if (c->p) { ++c->p; if (c->p[-1] == '/' && c->p[0] == '>') { /* Tag without content */ ++c->p; ZX_DEC_TAG_NOW_CLOSED(x->gg.g); goto out; } } #endif /* Process contents until 'p) { next_elem: /*ZX_SKIP_WS(c,x); DO NOT SQUASH WS! EXC-CANON NEEDS IT. */ if (*c->p == '<') { potential_tag: ++c->p; switch (*c->p) { case '?': /* processing instruction */ case '!': /* comment */ if (zx_scan_pi_or_comment(c)) break; goto next_elem; case '/': /* close tag */ ++c->p; name = c->p; ZX_LOOK_FOR(c,'>'); #if defined(DEC_WRONG_ELEM) if (c->p-name != namlen || memcmp(name, nam, namlen)) #else tok = zx_elem_lookup(c, name, c->p, &ns); if (tok != x->gg.g.tok) #endif { ERR("Mismatching close tag(%.*s) tok=%d context=%d", c->p-name, name, tok, x->gg.g.tok); zx_xml_parse_err(c, '-', __FUNCTION__, "Mismatching close tag"); ZX_DEC_TAG_MISMATCH_CLOSE(x->gg.g); ++c->p; return x; } /* Legitimate close tag. Normal exit from this function. */ ++c->p; ZX_DEC_TAG_NOW_CLOSED(x->gg.g); goto out; default: if (A_Z_a_z_(*c->p)) { name = c->p; for (++c->p; *c->p && !ONE_OF_6(*c->p, ' ', '>', '/', '\n', '\r', '\t'); ++c->p) ; if (!c->p) return 0; pop_seen = zx_scan_xmlns(c); /* Prescan namespaces so that token can be correctly recognized. */ tok = zx_elem_lookup(c, name, c->p, &ns); switch (tok) { default: el = zx_known_or_unknown_elem(c, tok, &x->gg, c->p - name, name, ns); tok = ZX_TOK_NOT_FOUND; break; } el->g.wo = &x->gg.kids->g; x->gg.kids = el; zx_pop_seen(pop_seen); goto next_elem; } } /* false alarm <, fall thru */ } if (!zx_scan_data(c, &x->gg)) return x; goto potential_tag; } out: iternode = x->gg.kids; REVERSE_LIST_NEXT(x->gg.kids, iternode, g.wo); ZX_END_DEC_EXT(x); return x; look_for_not_found: zx_xml_parse_err(c, '>', __FUNCTION__, "char not found"); return x; } #undef EL_NAME #undef EL_STRUCT #undef EL_NS #undef EL_TAG /* FUNC(zx_DEC_wsse_Username) */ #define EL_NAME wsse_Username #define EL_STRUCT zx_wsse_Username_s #define EL_NS wsse #define EL_TAG Username /* Called by: */ struct zx_wsse_Username_s* zx_DEC_wsse_Username(struct zx_ctx* c, struct zx_ns_s* ns ) { int tok; struct zx_elem_s* iternode; struct zx_elem_s* el; struct zx_str* ss; struct zx_ns_s* pop_seen; char* name; char* data; struct zx_wsse_Username_s* x = ZX_ZALLOC(c, struct zx_wsse_Username_s); x->gg.g.tok = zx_wsse_Username_ELEM; x->gg.g.ns = ns; ZX_START_DEC_EXT(x); #if 1 /* NORMALMODE */ ZX_DEC_TAG_NOT_YET_CLOSED(x->gg.g); /* The tag name has already been detected. Process attributes until '>' */ for (; c->p; ++c->p) { ZX_SKIP_WS(c,x); if (ONE_OF_2(*c->p, '>', '/')) break; if (!(data = zx_dec_attr_val(c, &name))) return 0; tok = zx_attr_lookup(c, name, data-2, &ns); switch (tok) { case zx_wsu_Id_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->Id->g; x->Id = ss; ZX_ATTR_DEC_EXT(ss); break; case ZX_TOK_XMLNS: ZX_XMLNS_DEC_EXT(ss); DD("xmlns detected(%.*s)", data-2-name, name); goto next_attr; default: ss = zx_dec_unknown_attr(c, &x->gg, name, data, tok, x->gg.g.tok); } ss->g.ns = ns; ss->g.tok = tok; ss->g.err |= ZXERR_ATTR_FLAG; ss->len = c->p - data; ss->s = data; next_attr: continue; } if (c->p) { ++c->p; if (c->p[-1] == '/' && c->p[0] == '>') { /* Tag without content */ ++c->p; ZX_DEC_TAG_NOW_CLOSED(x->gg.g); goto out; } } #endif /* Process contents until 'p) { next_elem: /*ZX_SKIP_WS(c,x); DO NOT SQUASH WS! EXC-CANON NEEDS IT. */ if (*c->p == '<') { potential_tag: ++c->p; switch (*c->p) { case '?': /* processing instruction */ case '!': /* comment */ if (zx_scan_pi_or_comment(c)) break; goto next_elem; case '/': /* close tag */ ++c->p; name = c->p; ZX_LOOK_FOR(c,'>'); #if defined(DEC_WRONG_ELEM) if (c->p-name != namlen || memcmp(name, nam, namlen)) #else tok = zx_elem_lookup(c, name, c->p, &ns); if (tok != x->gg.g.tok) #endif { ERR("Mismatching close tag(%.*s) tok=%d context=%d", c->p-name, name, tok, x->gg.g.tok); zx_xml_parse_err(c, '-', __FUNCTION__, "Mismatching close tag"); ZX_DEC_TAG_MISMATCH_CLOSE(x->gg.g); ++c->p; return x; } /* Legitimate close tag. Normal exit from this function. */ ++c->p; ZX_DEC_TAG_NOW_CLOSED(x->gg.g); goto out; default: if (A_Z_a_z_(*c->p)) { name = c->p; for (++c->p; *c->p && !ONE_OF_6(*c->p, ' ', '>', '/', '\n', '\r', '\t'); ++c->p) ; if (!c->p) return 0; pop_seen = zx_scan_xmlns(c); /* Prescan namespaces so that token can be correctly recognized. */ tok = zx_elem_lookup(c, name, c->p, &ns); switch (tok) { default: el = zx_known_or_unknown_elem(c, tok, &x->gg, c->p - name, name, ns); tok = ZX_TOK_NOT_FOUND; break; } el->g.wo = &x->gg.kids->g; x->gg.kids = el; zx_pop_seen(pop_seen); goto next_elem; } } /* false alarm <, fall thru */ } if (!zx_scan_data(c, &x->gg)) return x; goto potential_tag; } out: iternode = x->gg.kids; REVERSE_LIST_NEXT(x->gg.kids, iternode, g.wo); ZX_END_DEC_EXT(x); return x; look_for_not_found: zx_xml_parse_err(c, '>', __FUNCTION__, "char not found"); return x; } #undef EL_NAME #undef EL_STRUCT #undef EL_NS #undef EL_TAG /* FUNC(zx_DEC_wsse_UsernameToken) */ #define EL_NAME wsse_UsernameToken #define EL_STRUCT zx_wsse_UsernameToken_s #define EL_NS wsse #define EL_TAG UsernameToken /* Called by: */ struct zx_wsse_UsernameToken_s* zx_DEC_wsse_UsernameToken(struct zx_ctx* c, struct zx_ns_s* ns ) { int tok; struct zx_elem_s* iternode; struct zx_elem_s* el; struct zx_str* ss; struct zx_ns_s* pop_seen; char* name; char* data; struct zx_wsse_UsernameToken_s* x = ZX_ZALLOC(c, struct zx_wsse_UsernameToken_s); x->gg.g.tok = zx_wsse_UsernameToken_ELEM; x->gg.g.ns = ns; ZX_START_DEC_EXT(x); #if 1 /* NORMALMODE */ ZX_DEC_TAG_NOT_YET_CLOSED(x->gg.g); /* The tag name has already been detected. Process attributes until '>' */ for (; c->p; ++c->p) { ZX_SKIP_WS(c,x); if (ONE_OF_2(*c->p, '>', '/')) break; if (!(data = zx_dec_attr_val(c, &name))) return 0; tok = zx_attr_lookup(c, name, data-2, &ns); switch (tok) { case zx_wsu_Id_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->Id->g; x->Id = ss; ZX_ATTR_DEC_EXT(ss); break; case ZX_TOK_XMLNS: ZX_XMLNS_DEC_EXT(ss); DD("xmlns detected(%.*s)", data-2-name, name); goto next_attr; default: ss = zx_dec_unknown_attr(c, &x->gg, name, data, tok, x->gg.g.tok); } ss->g.ns = ns; ss->g.tok = tok; ss->g.err |= ZXERR_ATTR_FLAG; ss->len = c->p - data; ss->s = data; next_attr: continue; } if (c->p) { ++c->p; if (c->p[-1] == '/' && c->p[0] == '>') { /* Tag without content */ ++c->p; ZX_DEC_TAG_NOW_CLOSED(x->gg.g); goto out; } } #endif /* Process contents until 'p) { next_elem: /*ZX_SKIP_WS(c,x); DO NOT SQUASH WS! EXC-CANON NEEDS IT. */ if (*c->p == '<') { potential_tag: ++c->p; switch (*c->p) { case '?': /* processing instruction */ case '!': /* comment */ if (zx_scan_pi_or_comment(c)) break; goto next_elem; case '/': /* close tag */ ++c->p; name = c->p; ZX_LOOK_FOR(c,'>'); #if defined(DEC_WRONG_ELEM) if (c->p-name != namlen || memcmp(name, nam, namlen)) #else tok = zx_elem_lookup(c, name, c->p, &ns); if (tok != x->gg.g.tok) #endif { ERR("Mismatching close tag(%.*s) tok=%d context=%d", c->p-name, name, tok, x->gg.g.tok); zx_xml_parse_err(c, '-', __FUNCTION__, "Mismatching close tag"); ZX_DEC_TAG_MISMATCH_CLOSE(x->gg.g); ++c->p; return x; } /* Legitimate close tag. Normal exit from this function. */ ++c->p; ZX_DEC_TAG_NOW_CLOSED(x->gg.g); goto out; default: if (A_Z_a_z_(*c->p)) { name = c->p; for (++c->p; *c->p && !ONE_OF_6(*c->p, ' ', '>', '/', '\n', '\r', '\t'); ++c->p) ; if (!c->p) return 0; pop_seen = zx_scan_xmlns(c); /* Prescan namespaces so that token can be correctly recognized. */ tok = zx_elem_lookup(c, name, c->p, &ns); switch (tok) { case zx_wsse_Username_ELEM: el = (struct zx_elem_s*)zx_DEC_wsse_Username(c, ns); el->g.n = &x->Username->gg.g; x->Username = (struct zx_wsse_Username_s*)el; break; default: el = zx_known_or_unknown_elem(c, tok, &x->gg, c->p - name, name, ns); tok = ZX_TOK_NOT_FOUND; break; } el->g.wo = &x->gg.kids->g; x->gg.kids = el; zx_pop_seen(pop_seen); goto next_elem; } } /* false alarm <, fall thru */ } if (!zx_scan_data(c, &x->gg)) return x; goto potential_tag; } out: iternode = x->gg.kids; REVERSE_LIST_NEXT(x->gg.kids, iternode, g.wo); ZX_END_DEC_EXT(x); return x; look_for_not_found: zx_xml_parse_err(c, '>', __FUNCTION__, "char not found"); return x; } #undef EL_NAME #undef EL_STRUCT #undef EL_NS #undef EL_TAG /* EOF -- c/zx-wsse-dec.c */