/* c/zx-xa-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-xa-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_xa_Action) */ #define EL_NAME xa_Action #define EL_STRUCT zx_xa_Action_s #define EL_NS xa #define EL_TAG Action /* Called by: */ struct zx_xa_Action_s* zx_DEC_xa_Action(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_xa_Action_s* x = ZX_ZALLOC(c, struct zx_xa_Action_s); x->gg.g.tok = zx_xa_Action_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) { case zx_xa_ActionMatch_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_ActionMatch(c, ns); el->g.n = &x->ActionMatch->gg.g; x->ActionMatch = (struct zx_xa_ActionMatch_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_xa_ActionAttributeDesignator) */ #define EL_NAME xa_ActionAttributeDesignator #define EL_STRUCT zx_xa_ActionAttributeDesignator_s #define EL_NS xa #define EL_TAG ActionAttributeDesignator /* Called by: */ struct zx_xa_ActionAttributeDesignator_s* zx_DEC_xa_ActionAttributeDesignator(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_xa_ActionAttributeDesignator_s* x = ZX_ZALLOC(c, struct zx_xa_ActionAttributeDesignator_s); x->gg.g.tok = zx_xa_ActionAttributeDesignator_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_AttributeId_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->AttributeId->g; x->AttributeId = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_DataType_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->DataType->g; x->DataType = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_Issuer_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->Issuer->g; x->Issuer = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_MustBePresent_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->MustBePresent->g; x->MustBePresent = 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_xa_ActionMatch) */ #define EL_NAME xa_ActionMatch #define EL_STRUCT zx_xa_ActionMatch_s #define EL_NS xa #define EL_TAG ActionMatch /* Called by: */ struct zx_xa_ActionMatch_s* zx_DEC_xa_ActionMatch(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_xa_ActionMatch_s* x = ZX_ZALLOC(c, struct zx_xa_ActionMatch_s); x->gg.g.tok = zx_xa_ActionMatch_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_MatchId_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->MatchId->g; x->MatchId = 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_xa_AttributeValue_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_AttributeValue(c, ns); el->g.n = &x->AttributeValue->gg.g; x->AttributeValue = (struct zx_xa_AttributeValue_s*)el; break; case zx_xa_ActionAttributeDesignator_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_ActionAttributeDesignator(c, ns); el->g.n = &x->ActionAttributeDesignator->gg.g; x->ActionAttributeDesignator = (struct zx_xa_ActionAttributeDesignator_s*)el; break; case zx_xa_AttributeSelector_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_AttributeSelector(c, ns); el->g.n = &x->AttributeSelector->gg.g; x->AttributeSelector = (struct zx_xa_AttributeSelector_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_xa_Actions) */ #define EL_NAME xa_Actions #define EL_STRUCT zx_xa_Actions_s #define EL_NS xa #define EL_TAG Actions /* Called by: */ struct zx_xa_Actions_s* zx_DEC_xa_Actions(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_xa_Actions_s* x = ZX_ZALLOC(c, struct zx_xa_Actions_s); x->gg.g.tok = zx_xa_Actions_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) { case zx_xa_Action_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_Action(c, ns); el->g.n = &x->Action->gg.g; x->Action = (struct zx_xa_Action_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_xa_Apply) */ #define EL_NAME xa_Apply #define EL_STRUCT zx_xa_Apply_s #define EL_NS xa #define EL_TAG Apply /* Called by: */ struct zx_xa_Apply_s* zx_DEC_xa_Apply(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_xa_Apply_s* x = ZX_ZALLOC(c, struct zx_xa_Apply_s); x->gg.g.tok = zx_xa_Apply_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_FunctionId_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->FunctionId->g; x->FunctionId = 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_xa_Expression_ELEM: el = zx_DEC_simple_elem(c, ns, tok); el->g.n = &x->Expression->g; x->Expression = 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_xa_AttributeAssignment) */ #define EL_NAME xa_AttributeAssignment #define EL_STRUCT zx_xa_AttributeAssignment_s #define EL_NS xa #define EL_TAG AttributeAssignment /* Called by: */ struct zx_xa_AttributeAssignment_s* zx_DEC_xa_AttributeAssignment(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_xa_AttributeAssignment_s* x = ZX_ZALLOC(c, struct zx_xa_AttributeAssignment_s); x->gg.g.tok = zx_xa_AttributeAssignment_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_AttributeId_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->AttributeId->g; x->AttributeId = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_DataType_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->DataType->g; x->DataType = 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_xa_AttributeSelector) */ #define EL_NAME xa_AttributeSelector #define EL_STRUCT zx_xa_AttributeSelector_s #define EL_NS xa #define EL_TAG AttributeSelector /* Called by: */ struct zx_xa_AttributeSelector_s* zx_DEC_xa_AttributeSelector(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_xa_AttributeSelector_s* x = ZX_ZALLOC(c, struct zx_xa_AttributeSelector_s); x->gg.g.tok = zx_xa_AttributeSelector_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_DataType_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->DataType->g; x->DataType = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_MustBePresent_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->MustBePresent->g; x->MustBePresent = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_RequestContextPath_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->RequestContextPath->g; x->RequestContextPath = 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_xa_AttributeValue) */ #define EL_NAME xa_AttributeValue #define EL_STRUCT zx_xa_AttributeValue_s #define EL_NS xa #define EL_TAG AttributeValue /* Called by: */ struct zx_xa_AttributeValue_s* zx_DEC_xa_AttributeValue(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_xa_AttributeValue_s* x = ZX_ZALLOC(c, struct zx_xa_AttributeValue_s); x->gg.g.tok = zx_xa_AttributeValue_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_DataType_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->DataType->g; x->DataType = 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_xa_CombinerParameter) */ #define EL_NAME xa_CombinerParameter #define EL_STRUCT zx_xa_CombinerParameter_s #define EL_NS xa #define EL_TAG CombinerParameter /* Called by: */ struct zx_xa_CombinerParameter_s* zx_DEC_xa_CombinerParameter(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_xa_CombinerParameter_s* x = ZX_ZALLOC(c, struct zx_xa_CombinerParameter_s); x->gg.g.tok = zx_xa_CombinerParameter_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_ParameterName_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->ParameterName->g; x->ParameterName = 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_xa_AttributeValue_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_AttributeValue(c, ns); el->g.n = &x->AttributeValue->gg.g; x->AttributeValue = (struct zx_xa_AttributeValue_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_xa_CombinerParameters) */ #define EL_NAME xa_CombinerParameters #define EL_STRUCT zx_xa_CombinerParameters_s #define EL_NS xa #define EL_TAG CombinerParameters /* Called by: */ struct zx_xa_CombinerParameters_s* zx_DEC_xa_CombinerParameters(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_xa_CombinerParameters_s* x = ZX_ZALLOC(c, struct zx_xa_CombinerParameters_s); x->gg.g.tok = zx_xa_CombinerParameters_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) { case zx_xa_CombinerParameter_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_CombinerParameter(c, ns); el->g.n = &x->CombinerParameter->gg.g; x->CombinerParameter = (struct zx_xa_CombinerParameter_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_xa_Condition) */ #define EL_NAME xa_Condition #define EL_STRUCT zx_xa_Condition_s #define EL_NS xa #define EL_TAG Condition /* Called by: */ struct zx_xa_Condition_s* zx_DEC_xa_Condition(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_xa_Condition_s* x = ZX_ZALLOC(c, struct zx_xa_Condition_s); x->gg.g.tok = zx_xa_Condition_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) { case zx_xa_Expression_ELEM: el = zx_DEC_simple_elem(c, ns, tok); el->g.n = &x->Expression->g; x->Expression = 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_xa_Environment) */ #define EL_NAME xa_Environment #define EL_STRUCT zx_xa_Environment_s #define EL_NS xa #define EL_TAG Environment /* Called by: */ struct zx_xa_Environment_s* zx_DEC_xa_Environment(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_xa_Environment_s* x = ZX_ZALLOC(c, struct zx_xa_Environment_s); x->gg.g.tok = zx_xa_Environment_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) { case zx_xa_EnvironmentMatch_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_EnvironmentMatch(c, ns); el->g.n = &x->EnvironmentMatch->gg.g; x->EnvironmentMatch = (struct zx_xa_EnvironmentMatch_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_xa_EnvironmentAttributeDesignator) */ #define EL_NAME xa_EnvironmentAttributeDesignator #define EL_STRUCT zx_xa_EnvironmentAttributeDesignator_s #define EL_NS xa #define EL_TAG EnvironmentAttributeDesignator /* Called by: */ struct zx_xa_EnvironmentAttributeDesignator_s* zx_DEC_xa_EnvironmentAttributeDesignator(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_xa_EnvironmentAttributeDesignator_s* x = ZX_ZALLOC(c, struct zx_xa_EnvironmentAttributeDesignator_s); x->gg.g.tok = zx_xa_EnvironmentAttributeDesignator_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_AttributeId_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->AttributeId->g; x->AttributeId = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_DataType_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->DataType->g; x->DataType = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_Issuer_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->Issuer->g; x->Issuer = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_MustBePresent_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->MustBePresent->g; x->MustBePresent = 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_xa_EnvironmentMatch) */ #define EL_NAME xa_EnvironmentMatch #define EL_STRUCT zx_xa_EnvironmentMatch_s #define EL_NS xa #define EL_TAG EnvironmentMatch /* Called by: */ struct zx_xa_EnvironmentMatch_s* zx_DEC_xa_EnvironmentMatch(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_xa_EnvironmentMatch_s* x = ZX_ZALLOC(c, struct zx_xa_EnvironmentMatch_s); x->gg.g.tok = zx_xa_EnvironmentMatch_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_MatchId_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->MatchId->g; x->MatchId = 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_xa_AttributeValue_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_AttributeValue(c, ns); el->g.n = &x->AttributeValue->gg.g; x->AttributeValue = (struct zx_xa_AttributeValue_s*)el; break; case zx_xa_EnvironmentAttributeDesignator_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_EnvironmentAttributeDesignator(c, ns); el->g.n = &x->EnvironmentAttributeDesignator->gg.g; x->EnvironmentAttributeDesignator = (struct zx_xa_EnvironmentAttributeDesignator_s*)el; break; case zx_xa_AttributeSelector_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_AttributeSelector(c, ns); el->g.n = &x->AttributeSelector->gg.g; x->AttributeSelector = (struct zx_xa_AttributeSelector_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_xa_Environments) */ #define EL_NAME xa_Environments #define EL_STRUCT zx_xa_Environments_s #define EL_NS xa #define EL_TAG Environments /* Called by: */ struct zx_xa_Environments_s* zx_DEC_xa_Environments(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_xa_Environments_s* x = ZX_ZALLOC(c, struct zx_xa_Environments_s); x->gg.g.tok = zx_xa_Environments_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) { case zx_xa_Environment_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_Environment(c, ns); el->g.n = &x->Environment->gg.g; x->Environment = (struct zx_xa_Environment_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_xa_Function) */ #define EL_NAME xa_Function #define EL_STRUCT zx_xa_Function_s #define EL_NS xa #define EL_TAG Function /* Called by: */ struct zx_xa_Function_s* zx_DEC_xa_Function(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_xa_Function_s* x = ZX_ZALLOC(c, struct zx_xa_Function_s); x->gg.g.tok = zx_xa_Function_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_FunctionId_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->FunctionId->g; x->FunctionId = 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_xa_Obligation) */ #define EL_NAME xa_Obligation #define EL_STRUCT zx_xa_Obligation_s #define EL_NS xa #define EL_TAG Obligation /* Called by: */ struct zx_xa_Obligation_s* zx_DEC_xa_Obligation(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_xa_Obligation_s* x = ZX_ZALLOC(c, struct zx_xa_Obligation_s); x->gg.g.tok = zx_xa_Obligation_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_FulfillOn_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->FulfillOn->g; x->FulfillOn = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_ObligationId_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->ObligationId->g; x->ObligationId = 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_xa_AttributeAssignment_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_AttributeAssignment(c, ns); el->g.n = &x->AttributeAssignment->gg.g; x->AttributeAssignment = (struct zx_xa_AttributeAssignment_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_xa_Obligations) */ #define EL_NAME xa_Obligations #define EL_STRUCT zx_xa_Obligations_s #define EL_NS xa #define EL_TAG Obligations /* Called by: */ struct zx_xa_Obligations_s* zx_DEC_xa_Obligations(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_xa_Obligations_s* x = ZX_ZALLOC(c, struct zx_xa_Obligations_s); x->gg.g.tok = zx_xa_Obligations_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) { case zx_xa_Obligation_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_Obligation(c, ns); el->g.n = &x->Obligation->gg.g; x->Obligation = (struct zx_xa_Obligation_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_xa_Policy) */ #define EL_NAME xa_Policy #define EL_STRUCT zx_xa_Policy_s #define EL_NS xa #define EL_TAG Policy /* Called by: */ struct zx_xa_Policy_s* zx_DEC_xa_Policy(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_xa_Policy_s* x = ZX_ZALLOC(c, struct zx_xa_Policy_s); x->gg.g.tok = zx_xa_Policy_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_PolicyId_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->PolicyId->g; x->PolicyId = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_RuleCombiningAlgId_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->RuleCombiningAlgId->g; x->RuleCombiningAlgId = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_Version_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->Version->g; x->Version = 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_xa_Description_ELEM: el = zx_DEC_simple_elem(c, ns, tok); el->g.n = &x->Description->g; x->Description = el; break; case zx_xa_PolicyDefaults_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_PolicyDefaults(c, ns); el->g.n = &x->PolicyDefaults->gg.g; x->PolicyDefaults = (struct zx_xa_PolicyDefaults_s*)el; break; case zx_xa_Target_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_Target(c, ns); el->g.n = &x->Target->gg.g; x->Target = (struct zx_xa_Target_s*)el; break; case zx_xa_CombinerParameters_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_CombinerParameters(c, ns); el->g.n = &x->CombinerParameters->gg.g; x->CombinerParameters = (struct zx_xa_CombinerParameters_s*)el; break; case zx_xa_RuleCombinerParameters_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_RuleCombinerParameters(c, ns); el->g.n = &x->RuleCombinerParameters->gg.g; x->RuleCombinerParameters = (struct zx_xa_RuleCombinerParameters_s*)el; break; case zx_xa_VariableDefinition_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_VariableDefinition(c, ns); el->g.n = &x->VariableDefinition->gg.g; x->VariableDefinition = (struct zx_xa_VariableDefinition_s*)el; break; case zx_xa_Rule_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_Rule(c, ns); el->g.n = &x->Rule->gg.g; x->Rule = (struct zx_xa_Rule_s*)el; break; case zx_xa_Obligations_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_Obligations(c, ns); el->g.n = &x->Obligations->gg.g; x->Obligations = (struct zx_xa_Obligations_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_xa_PolicyCombinerParameters) */ #define EL_NAME xa_PolicyCombinerParameters #define EL_STRUCT zx_xa_PolicyCombinerParameters_s #define EL_NS xa #define EL_TAG PolicyCombinerParameters /* Called by: */ struct zx_xa_PolicyCombinerParameters_s* zx_DEC_xa_PolicyCombinerParameters(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_xa_PolicyCombinerParameters_s* x = ZX_ZALLOC(c, struct zx_xa_PolicyCombinerParameters_s); x->gg.g.tok = zx_xa_PolicyCombinerParameters_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_PolicyIdRef_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->PolicyIdRef->g; x->PolicyIdRef = 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_xa_CombinerParameter_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_CombinerParameter(c, ns); el->g.n = &x->CombinerParameter->gg.g; x->CombinerParameter = (struct zx_xa_CombinerParameter_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_xa_PolicyDefaults) */ #define EL_NAME xa_PolicyDefaults #define EL_STRUCT zx_xa_PolicyDefaults_s #define EL_NS xa #define EL_TAG PolicyDefaults /* Called by: */ struct zx_xa_PolicyDefaults_s* zx_DEC_xa_PolicyDefaults(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_xa_PolicyDefaults_s* x = ZX_ZALLOC(c, struct zx_xa_PolicyDefaults_s); x->gg.g.tok = zx_xa_PolicyDefaults_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) { case zx_xa_XPathVersion_ELEM: el = zx_DEC_simple_elem(c, ns, tok); el->g.n = &x->XPathVersion->g; x->XPathVersion = 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_xa_PolicyIdReference) */ #define EL_NAME xa_PolicyIdReference #define EL_STRUCT zx_xa_PolicyIdReference_s #define EL_NS xa #define EL_TAG PolicyIdReference /* Called by: */ struct zx_xa_PolicyIdReference_s* zx_DEC_xa_PolicyIdReference(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_xa_PolicyIdReference_s* x = ZX_ZALLOC(c, struct zx_xa_PolicyIdReference_s); x->gg.g.tok = zx_xa_PolicyIdReference_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_EarliestVersion_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->EarliestVersion->g; x->EarliestVersion = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_LatestVersion_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->LatestVersion->g; x->LatestVersion = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_Version_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->Version->g; x->Version = 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_xa_PolicySet) */ #define EL_NAME xa_PolicySet #define EL_STRUCT zx_xa_PolicySet_s #define EL_NS xa #define EL_TAG PolicySet /* Called by: */ struct zx_xa_PolicySet_s* zx_DEC_xa_PolicySet(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_xa_PolicySet_s* x = ZX_ZALLOC(c, struct zx_xa_PolicySet_s); x->gg.g.tok = zx_xa_PolicySet_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_PolicyCombiningAlgId_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->PolicyCombiningAlgId->g; x->PolicyCombiningAlgId = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_PolicySetId_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->PolicySetId->g; x->PolicySetId = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_Version_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->Version->g; x->Version = 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_xa_Description_ELEM: el = zx_DEC_simple_elem(c, ns, tok); el->g.n = &x->Description->g; x->Description = el; break; case zx_xa_PolicySetDefaults_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_PolicySetDefaults(c, ns); el->g.n = &x->PolicySetDefaults->gg.g; x->PolicySetDefaults = (struct zx_xa_PolicySetDefaults_s*)el; break; case zx_xa_Target_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_Target(c, ns); el->g.n = &x->Target->gg.g; x->Target = (struct zx_xa_Target_s*)el; break; case zx_xa_PolicySet_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_PolicySet(c, ns); el->g.n = &x->PolicySet->gg.g; x->PolicySet = (struct zx_xa_PolicySet_s*)el; break; case zx_xa_Policy_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_Policy(c, ns); el->g.n = &x->Policy->gg.g; x->Policy = (struct zx_xa_Policy_s*)el; break; case zx_xa_PolicySetIdReference_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_PolicySetIdReference(c, ns); el->g.n = &x->PolicySetIdReference->gg.g; x->PolicySetIdReference = (struct zx_xa_PolicySetIdReference_s*)el; break; case zx_xa_PolicyIdReference_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_PolicyIdReference(c, ns); el->g.n = &x->PolicyIdReference->gg.g; x->PolicyIdReference = (struct zx_xa_PolicyIdReference_s*)el; break; case zx_xa_CombinerParameters_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_CombinerParameters(c, ns); el->g.n = &x->CombinerParameters->gg.g; x->CombinerParameters = (struct zx_xa_CombinerParameters_s*)el; break; case zx_xa_PolicyCombinerParameters_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_PolicyCombinerParameters(c, ns); el->g.n = &x->PolicyCombinerParameters->gg.g; x->PolicyCombinerParameters = (struct zx_xa_PolicyCombinerParameters_s*)el; break; case zx_xa_PolicySetCombinerParameters_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_PolicySetCombinerParameters(c, ns); el->g.n = &x->PolicySetCombinerParameters->gg.g; x->PolicySetCombinerParameters = (struct zx_xa_PolicySetCombinerParameters_s*)el; break; case zx_xa_Obligations_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_Obligations(c, ns); el->g.n = &x->Obligations->gg.g; x->Obligations = (struct zx_xa_Obligations_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_xa_PolicySetCombinerParameters) */ #define EL_NAME xa_PolicySetCombinerParameters #define EL_STRUCT zx_xa_PolicySetCombinerParameters_s #define EL_NS xa #define EL_TAG PolicySetCombinerParameters /* Called by: */ struct zx_xa_PolicySetCombinerParameters_s* zx_DEC_xa_PolicySetCombinerParameters(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_xa_PolicySetCombinerParameters_s* x = ZX_ZALLOC(c, struct zx_xa_PolicySetCombinerParameters_s); x->gg.g.tok = zx_xa_PolicySetCombinerParameters_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_PolicySetIdRef_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->PolicySetIdRef->g; x->PolicySetIdRef = 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_xa_CombinerParameter_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_CombinerParameter(c, ns); el->g.n = &x->CombinerParameter->gg.g; x->CombinerParameter = (struct zx_xa_CombinerParameter_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_xa_PolicySetDefaults) */ #define EL_NAME xa_PolicySetDefaults #define EL_STRUCT zx_xa_PolicySetDefaults_s #define EL_NS xa #define EL_TAG PolicySetDefaults /* Called by: */ struct zx_xa_PolicySetDefaults_s* zx_DEC_xa_PolicySetDefaults(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_xa_PolicySetDefaults_s* x = ZX_ZALLOC(c, struct zx_xa_PolicySetDefaults_s); x->gg.g.tok = zx_xa_PolicySetDefaults_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) { case zx_xa_XPathVersion_ELEM: el = zx_DEC_simple_elem(c, ns, tok); el->g.n = &x->XPathVersion->g; x->XPathVersion = 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_xa_PolicySetIdReference) */ #define EL_NAME xa_PolicySetIdReference #define EL_STRUCT zx_xa_PolicySetIdReference_s #define EL_NS xa #define EL_TAG PolicySetIdReference /* Called by: */ struct zx_xa_PolicySetIdReference_s* zx_DEC_xa_PolicySetIdReference(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_xa_PolicySetIdReference_s* x = ZX_ZALLOC(c, struct zx_xa_PolicySetIdReference_s); x->gg.g.tok = zx_xa_PolicySetIdReference_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_EarliestVersion_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->EarliestVersion->g; x->EarliestVersion = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_LatestVersion_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->LatestVersion->g; x->LatestVersion = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_Version_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->Version->g; x->Version = 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_xa_Resource) */ #define EL_NAME xa_Resource #define EL_STRUCT zx_xa_Resource_s #define EL_NS xa #define EL_TAG Resource /* Called by: */ struct zx_xa_Resource_s* zx_DEC_xa_Resource(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_xa_Resource_s* x = ZX_ZALLOC(c, struct zx_xa_Resource_s); x->gg.g.tok = zx_xa_Resource_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) { case zx_xa_ResourceMatch_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_ResourceMatch(c, ns); el->g.n = &x->ResourceMatch->gg.g; x->ResourceMatch = (struct zx_xa_ResourceMatch_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_xa_ResourceAttributeDesignator) */ #define EL_NAME xa_ResourceAttributeDesignator #define EL_STRUCT zx_xa_ResourceAttributeDesignator_s #define EL_NS xa #define EL_TAG ResourceAttributeDesignator /* Called by: */ struct zx_xa_ResourceAttributeDesignator_s* zx_DEC_xa_ResourceAttributeDesignator(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_xa_ResourceAttributeDesignator_s* x = ZX_ZALLOC(c, struct zx_xa_ResourceAttributeDesignator_s); x->gg.g.tok = zx_xa_ResourceAttributeDesignator_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_AttributeId_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->AttributeId->g; x->AttributeId = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_DataType_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->DataType->g; x->DataType = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_Issuer_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->Issuer->g; x->Issuer = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_MustBePresent_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->MustBePresent->g; x->MustBePresent = 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_xa_ResourceMatch) */ #define EL_NAME xa_ResourceMatch #define EL_STRUCT zx_xa_ResourceMatch_s #define EL_NS xa #define EL_TAG ResourceMatch /* Called by: */ struct zx_xa_ResourceMatch_s* zx_DEC_xa_ResourceMatch(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_xa_ResourceMatch_s* x = ZX_ZALLOC(c, struct zx_xa_ResourceMatch_s); x->gg.g.tok = zx_xa_ResourceMatch_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_MatchId_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->MatchId->g; x->MatchId = 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_xa_AttributeValue_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_AttributeValue(c, ns); el->g.n = &x->AttributeValue->gg.g; x->AttributeValue = (struct zx_xa_AttributeValue_s*)el; break; case zx_xa_ResourceAttributeDesignator_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_ResourceAttributeDesignator(c, ns); el->g.n = &x->ResourceAttributeDesignator->gg.g; x->ResourceAttributeDesignator = (struct zx_xa_ResourceAttributeDesignator_s*)el; break; case zx_xa_AttributeSelector_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_AttributeSelector(c, ns); el->g.n = &x->AttributeSelector->gg.g; x->AttributeSelector = (struct zx_xa_AttributeSelector_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_xa_Resources) */ #define EL_NAME xa_Resources #define EL_STRUCT zx_xa_Resources_s #define EL_NS xa #define EL_TAG Resources /* Called by: */ struct zx_xa_Resources_s* zx_DEC_xa_Resources(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_xa_Resources_s* x = ZX_ZALLOC(c, struct zx_xa_Resources_s); x->gg.g.tok = zx_xa_Resources_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) { case zx_xa_Resource_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_Resource(c, ns); el->g.n = &x->Resource->gg.g; x->Resource = (struct zx_xa_Resource_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_xa_Rule) */ #define EL_NAME xa_Rule #define EL_STRUCT zx_xa_Rule_s #define EL_NS xa #define EL_TAG Rule /* Called by: */ struct zx_xa_Rule_s* zx_DEC_xa_Rule(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_xa_Rule_s* x = ZX_ZALLOC(c, struct zx_xa_Rule_s); x->gg.g.tok = zx_xa_Rule_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_Effect_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->Effect->g; x->Effect = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_RuleId_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->RuleId->g; x->RuleId = 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_xa_Description_ELEM: el = zx_DEC_simple_elem(c, ns, tok); el->g.n = &x->Description->g; x->Description = el; break; case zx_xa_Target_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_Target(c, ns); el->g.n = &x->Target->gg.g; x->Target = (struct zx_xa_Target_s*)el; break; case zx_xa_Condition_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_Condition(c, ns); el->g.n = &x->Condition->gg.g; x->Condition = (struct zx_xa_Condition_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_xa_RuleCombinerParameters) */ #define EL_NAME xa_RuleCombinerParameters #define EL_STRUCT zx_xa_RuleCombinerParameters_s #define EL_NS xa #define EL_TAG RuleCombinerParameters /* Called by: */ struct zx_xa_RuleCombinerParameters_s* zx_DEC_xa_RuleCombinerParameters(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_xa_RuleCombinerParameters_s* x = ZX_ZALLOC(c, struct zx_xa_RuleCombinerParameters_s); x->gg.g.tok = zx_xa_RuleCombinerParameters_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_RuleIdRef_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->RuleIdRef->g; x->RuleIdRef = 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_xa_CombinerParameter_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_CombinerParameter(c, ns); el->g.n = &x->CombinerParameter->gg.g; x->CombinerParameter = (struct zx_xa_CombinerParameter_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_xa_Subject) */ #define EL_NAME xa_Subject #define EL_STRUCT zx_xa_Subject_s #define EL_NS xa #define EL_TAG Subject /* Called by: */ struct zx_xa_Subject_s* zx_DEC_xa_Subject(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_xa_Subject_s* x = ZX_ZALLOC(c, struct zx_xa_Subject_s); x->gg.g.tok = zx_xa_Subject_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) { case zx_xa_SubjectMatch_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_SubjectMatch(c, ns); el->g.n = &x->SubjectMatch->gg.g; x->SubjectMatch = (struct zx_xa_SubjectMatch_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_xa_SubjectAttributeDesignator) */ #define EL_NAME xa_SubjectAttributeDesignator #define EL_STRUCT zx_xa_SubjectAttributeDesignator_s #define EL_NS xa #define EL_TAG SubjectAttributeDesignator /* Called by: */ struct zx_xa_SubjectAttributeDesignator_s* zx_DEC_xa_SubjectAttributeDesignator(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_xa_SubjectAttributeDesignator_s* x = ZX_ZALLOC(c, struct zx_xa_SubjectAttributeDesignator_s); x->gg.g.tok = zx_xa_SubjectAttributeDesignator_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_AttributeId_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->AttributeId->g; x->AttributeId = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_DataType_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->DataType->g; x->DataType = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_Issuer_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->Issuer->g; x->Issuer = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_MustBePresent_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->MustBePresent->g; x->MustBePresent = ss; ZX_ATTR_DEC_EXT(ss); break; case zx_SubjectCategory_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->SubjectCategory->g; x->SubjectCategory = 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_xa_SubjectMatch) */ #define EL_NAME xa_SubjectMatch #define EL_STRUCT zx_xa_SubjectMatch_s #define EL_NS xa #define EL_TAG SubjectMatch /* Called by: */ struct zx_xa_SubjectMatch_s* zx_DEC_xa_SubjectMatch(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_xa_SubjectMatch_s* x = ZX_ZALLOC(c, struct zx_xa_SubjectMatch_s); x->gg.g.tok = zx_xa_SubjectMatch_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_MatchId_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->MatchId->g; x->MatchId = 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_xa_AttributeValue_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_AttributeValue(c, ns); el->g.n = &x->AttributeValue->gg.g; x->AttributeValue = (struct zx_xa_AttributeValue_s*)el; break; case zx_xa_SubjectAttributeDesignator_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_SubjectAttributeDesignator(c, ns); el->g.n = &x->SubjectAttributeDesignator->gg.g; x->SubjectAttributeDesignator = (struct zx_xa_SubjectAttributeDesignator_s*)el; break; case zx_xa_AttributeSelector_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_AttributeSelector(c, ns); el->g.n = &x->AttributeSelector->gg.g; x->AttributeSelector = (struct zx_xa_AttributeSelector_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_xa_Subjects) */ #define EL_NAME xa_Subjects #define EL_STRUCT zx_xa_Subjects_s #define EL_NS xa #define EL_TAG Subjects /* Called by: */ struct zx_xa_Subjects_s* zx_DEC_xa_Subjects(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_xa_Subjects_s* x = ZX_ZALLOC(c, struct zx_xa_Subjects_s); x->gg.g.tok = zx_xa_Subjects_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) { case zx_xa_Subject_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_Subject(c, ns); el->g.n = &x->Subject->gg.g; x->Subject = (struct zx_xa_Subject_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_xa_Target) */ #define EL_NAME xa_Target #define EL_STRUCT zx_xa_Target_s #define EL_NS xa #define EL_TAG Target /* Called by: */ struct zx_xa_Target_s* zx_DEC_xa_Target(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_xa_Target_s* x = ZX_ZALLOC(c, struct zx_xa_Target_s); x->gg.g.tok = zx_xa_Target_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) { case zx_xa_Subjects_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_Subjects(c, ns); el->g.n = &x->Subjects->gg.g; x->Subjects = (struct zx_xa_Subjects_s*)el; break; case zx_xa_Resources_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_Resources(c, ns); el->g.n = &x->Resources->gg.g; x->Resources = (struct zx_xa_Resources_s*)el; break; case zx_xa_Actions_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_Actions(c, ns); el->g.n = &x->Actions->gg.g; x->Actions = (struct zx_xa_Actions_s*)el; break; case zx_xa_Environments_ELEM: el = (struct zx_elem_s*)zx_DEC_xa_Environments(c, ns); el->g.n = &x->Environments->gg.g; x->Environments = (struct zx_xa_Environments_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_xa_VariableDefinition) */ #define EL_NAME xa_VariableDefinition #define EL_STRUCT zx_xa_VariableDefinition_s #define EL_NS xa #define EL_TAG VariableDefinition /* Called by: */ struct zx_xa_VariableDefinition_s* zx_DEC_xa_VariableDefinition(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_xa_VariableDefinition_s* x = ZX_ZALLOC(c, struct zx_xa_VariableDefinition_s); x->gg.g.tok = zx_xa_VariableDefinition_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_VariableId_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->VariableId->g; x->VariableId = 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_xa_Expression_ELEM: el = zx_DEC_simple_elem(c, ns, tok); el->g.n = &x->Expression->g; x->Expression = 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_xa_VariableReference) */ #define EL_NAME xa_VariableReference #define EL_STRUCT zx_xa_VariableReference_s #define EL_NS xa #define EL_TAG VariableReference /* Called by: */ struct zx_xa_VariableReference_s* zx_DEC_xa_VariableReference(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_xa_VariableReference_s* x = ZX_ZALLOC(c, struct zx_xa_VariableReference_s); x->gg.g.tok = zx_xa_VariableReference_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_VariableId_ATTR: ss = ZX_ZALLOC(c, struct zx_str); ss->g.n = &x->VariableId->g; x->VariableId = 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 /* EOF -- c/zx-xa-dec.c */