SOAP_FMAC3 int SOAP_FMAC4 soap_ignore_element(struct soap *soap) { if (!soap_peek_element(soap)) { int t; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unexpected element '%s' in input (level=%u, %d)\n", soap->tag, soap->level, soap->body)); if (soap->mustUnderstand && !soap->other) return soap->error = SOAP_MUSTUNDERSTAND; if (((soap->mode & SOAP_XML_STRICT) && soap->part != SOAP_IN_HEADER) || !soap_match_tag(soap, soap->tag, "SOAP-ENV:")) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "REJECTING element '%s'\n", soap->tag)); return soap->error = SOAP_TAG_MISMATCH; } if (!*soap->id || !soap_getelement(soap, &t)) { soap->peeked = 0; if (soap->fignore) soap->error = soap->fignore(soap, soap->tag); else soap->error = SOAP_OK; DBGLOG(TEST, if (!soap->error) SOAP_MESSAGE(fdebug, "IGNORING element '%s'\n", soap->tag)); if (!soap->error && soap->body) { soap->level++; while (!soap_ignore_element(soap)) ; if (soap->error == SOAP_NO_TAG) soap->error = soap_element_end_in(soap, NULL); } }
SOAP_FMAC3 void * SOAP_FMAC4 soap_getelement(struct soap *soap, int *type) { if (soap_peek_element(soap)) return NULL; if (!*soap->id || !(*type = soap_lookup_type(soap, soap->id))) *type = soap_lookup_type(soap, soap->href); switch (*type) { case SOAP_TYPE_byte: return soap_in_byte(soap, NULL, NULL, "xsd:byte"); case SOAP_TYPE_int: return soap_in_int(soap, NULL, NULL, "xsd:int"); case SOAP_TYPE_SOAP_ENV__Reason: return soap_in_SOAP_ENV__Reason(soap, NULL, NULL, "SOAP-ENV:Reason"); case SOAP_TYPE_PointerToSOAP_ENV__Reason: return soap_in_PointerToSOAP_ENV__Reason(soap, NULL, NULL, "SOAP-ENV:Reason"); case SOAP_TYPE__QName: { char **s; s = soap_in__QName(soap, NULL, NULL, "QName"); return s ? *s : NULL; } case SOAP_TYPE_string: { char **s; s = soap_in_string(soap, NULL, NULL, "xsd:string"); return s ? *s : NULL; } default: { const char *t = soap->type; if (!*t) t = soap->tag; if (!soap_match_tag(soap, t, "xsd:byte")) { *type = SOAP_TYPE_byte; return soap_in_byte(soap, NULL, NULL, NULL); } if (!soap_match_tag(soap, t, "xsd:int")) { *type = SOAP_TYPE_int; return soap_in_int(soap, NULL, NULL, NULL); } if (!soap_match_tag(soap, t, "SOAP-ENV:Reason")) { *type = SOAP_TYPE_SOAP_ENV__Reason; return soap_in_SOAP_ENV__Reason(soap, NULL, NULL, NULL); } if (!soap_match_tag(soap, t, "QName")) { char **s; *type = SOAP_TYPE__QName; s = soap_in__QName(soap, NULL, NULL, NULL); return s ? *s : NULL; } if (!soap_match_tag(soap, t, "xsd:string")) { char **s; *type = SOAP_TYPE_string; s = soap_in_string(soap, NULL, NULL, NULL); return s ? *s : NULL; } } } soap->error = SOAP_TAG_MISMATCH; return NULL; }
SOAP_FMAC3 void * SOAP_FMAC4 soap_getelement(struct soap *soap, int *type) { (void)type; if (soap_peek_element(soap)) return NULL; #ifndef WITH_NOIDREF if (!*soap->id || !(*type = soap_lookup_type(soap, soap->id))) *type = soap_lookup_type(soap, soap->href); switch (*type) { case SOAP_TYPE_byte: return soap_in_byte(soap, NULL, NULL, "xsd:byte"); case SOAP_TYPE_int: return soap_in_int(soap, NULL, NULL, "xsd:int"); case SOAP_TYPE__QName: { char **s; s = soap_in__QName(soap, NULL, NULL, "xsd:QName"); return s ? *s : NULL; } case SOAP_TYPE_string: { char **s; s = soap_in_string(soap, NULL, NULL, "xsd:string"); return s ? *s : NULL; } default: #else *type = 0; #endif { const char *t = soap->type; if (!*t) t = soap->tag; if (!soap_match_tag(soap, t, "xsd:byte")) { *type = SOAP_TYPE_byte; return soap_in_byte(soap, NULL, NULL, NULL); } if (!soap_match_tag(soap, t, "xsd:int")) { *type = SOAP_TYPE_int; return soap_in_int(soap, NULL, NULL, NULL); } if (!soap_match_tag(soap, t, "xsd:QName")) { char **s; *type = SOAP_TYPE__QName; s = soap_in__QName(soap, NULL, NULL, NULL); return s ? *s : NULL; } if (!soap_match_tag(soap, t, "xsd:string")) { char **s; *type = SOAP_TYPE_string; s = soap_in_string(soap, NULL, NULL, NULL); return s ? *s : NULL; } t = soap->tag; #ifndef WITH_NOIDREF } #endif } soap->error = SOAP_TAG_MISMATCH; return NULL; }
SOAP_FMAC1 int SOAP_FMAC2 soap_getindependent(struct soap *soap) { for (;;) { if (soap_peek_element(soap) || !*soap->id) break; switch (soap_lookup_type(soap, soap->id)) { case SOAP_byte: soap_in_byte(soap, NULL, NULL, ""); break; case SOAP_int: soap_in_int(soap, NULL, NULL, ""); break; case SOAP_float: soap_in_float(soap, NULL, NULL, ""); break; case SOAP_SOAP_ENV__Fault: soap_in_SOAP_ENV__Fault(soap, NULL, NULL, ""); break; case SOAP_SOAP_ENV__Header: soap_in_SOAP_ENV__Header(soap, NULL, NULL, ""); break; case SOAP_ns__getQuote: soap_in_ns__getQuote(soap, NULL, NULL, "ns:getQuote"); break; case SOAP_ns__getQuoteResponse: soap_in_ns__getQuoteResponse(soap, NULL, NULL, "ns:getQuoteResponse"); break; case SOAP_string: soap_in_string(soap, NULL, NULL, ""); break; default: soap_in_ns__getQuote(soap, NULL, NULL, "ns:getQuote"); if (soap->error == SOAP_TYPE_MISMATCH && soap->level == 2) soap_in_ns__getQuoteResponse(soap, NULL, NULL, "ns:getQuoteResponse"); if (soap->error) { soap->peeked = 1; soap_ignore_element(soap); } } if (soap->error) break; } if (soap->error == SOAP_NO_TAG) soap->error = SOAP_OK; return soap->error; }
SOAP_FMAC3 void * SOAP_FMAC4 soap_getelement(struct soap *soap, int *type) { if (soap_peek_element(soap)) return NULL; if (!*soap->id || !(*type = soap_lookup_type(soap, soap->id))) *type = soap_lookup_type(soap, soap->href); switch (*type) { case SOAP_TYPE_byte: return soap_in_byte(soap, NULL, NULL, "xsd:byte"); case SOAP_TYPE_xsd__int: return soap_in_xsd__int(soap, NULL, NULL, "xsd:int"); case SOAP_TYPE_int: return soap_in_int(soap, NULL, NULL, "xsd:int"); case SOAP_TYPE_ws__setTrafficShapeCfg: return soap_in_ws__setTrafficShapeCfg(soap, NULL, NULL, "ws:setTrafficShapeCfg"); case SOAP_TYPE_ws__setTrafficShapeCfgResponse: return soap_in_ws__setTrafficShapeCfgResponse(soap, NULL, NULL, "ws:setTrafficShapeCfgResponse"); case SOAP_TYPE_ws__getTrafficShapeCfg: return soap_in_ws__getTrafficShapeCfg(soap, NULL, NULL, "ws:getTrafficShapeCfg"); case SOAP_TYPE_ws__TrafficShapeCfgInfo: return soap_in_ws__TrafficShapeCfgInfo(soap, NULL, NULL, "ws:TrafficShapeCfgInfo"); case SOAP_TYPE_TrafficShapeCfgInfo: return soap_in_TrafficShapeCfgInfo(soap, NULL, NULL, "TrafficShapeCfgInfo"); case SOAP_TYPE_noop: return soap_in_noop(soap, NULL, NULL, "noop"); case SOAP_TYPE_PointerTows__TrafficShapeCfgInfo: return soap_in_PointerTows__TrafficShapeCfgInfo(soap, NULL, NULL, "ws:TrafficShapeCfgInfo"); case SOAP_TYPE_PointerToxsd__int: return soap_in_PointerToxsd__int(soap, NULL, NULL, "xsd:int"); case SOAP_TYPE_PointerToint: return soap_in_PointerToint(soap, NULL, NULL, "xsd:int"); case SOAP_TYPE_xsd__string: { char **s; s = soap_in_xsd__string(soap, NULL, NULL, "xsd:string"); return s ? *s : NULL; } case SOAP_TYPE_string: { char **s; s = soap_in_string(soap, NULL, NULL, "xsd:string"); return s ? *s : NULL; } default: { const char *t = soap->type; if (!*t) t = soap->tag; if (!soap_match_tag(soap, t, "xsd:byte")) { *type = SOAP_TYPE_byte; return soap_in_byte(soap, NULL, NULL, NULL); } if (!soap_match_tag(soap, t, "xsd:int")) { *type = SOAP_TYPE_xsd__int; return soap_in_xsd__int(soap, NULL, NULL, NULL); } if (!soap_match_tag(soap, t, "xsd:int")) { *type = SOAP_TYPE_int; return soap_in_int(soap, NULL, NULL, NULL); } if (!soap_match_tag(soap, t, "ws:setTrafficShapeCfg")) { *type = SOAP_TYPE_ws__setTrafficShapeCfg; return soap_in_ws__setTrafficShapeCfg(soap, NULL, NULL, NULL); } if (!soap_match_tag(soap, t, "ws:setTrafficShapeCfgResponse")) { *type = SOAP_TYPE_ws__setTrafficShapeCfgResponse; return soap_in_ws__setTrafficShapeCfgResponse(soap, NULL, NULL, NULL); } if (!soap_match_tag(soap, t, "ws:getTrafficShapeCfg")) { *type = SOAP_TYPE_ws__getTrafficShapeCfg; return soap_in_ws__getTrafficShapeCfg(soap, NULL, NULL, NULL); } if (!soap_match_tag(soap, t, "ws:TrafficShapeCfgInfo")) { *type = SOAP_TYPE_ws__TrafficShapeCfgInfo; return soap_in_ws__TrafficShapeCfgInfo(soap, NULL, NULL, NULL); } if (!soap_match_tag(soap, t, "TrafficShapeCfgInfo")) { *type = SOAP_TYPE_TrafficShapeCfgInfo; return soap_in_TrafficShapeCfgInfo(soap, NULL, NULL, NULL); } if (!soap_match_tag(soap, t, "noop")) { *type = SOAP_TYPE_noop; return soap_in_noop(soap, NULL, NULL, NULL); } if (!soap_match_tag(soap, t, "xsd:string")) { char **s; *type = SOAP_TYPE_xsd__string; s = soap_in_xsd__string(soap, NULL, NULL, NULL); return s ? *s : NULL; } if (!soap_match_tag(soap, t, "xsd:string")) { char **s; *type = SOAP_TYPE_string; s = soap_in_string(soap, NULL, NULL, NULL); return s ? *s : NULL; } t = soap->tag; if (!soap_match_tag(soap, t, "xsd:QName")) { char **s; *type = SOAP_TYPE__QName; s = soap_in__QName(soap, NULL, NULL, NULL); return s ? *s : NULL; } } } soap->error = SOAP_TAG_MISMATCH; return NULL; }
SOAP_FMAC2 soap_in_xsd__anyType(struct soap *soap, const char *tag, struct soap_dom_element *node, const char *type) { register struct soap_attribute *tp; register struct soap_dom_attribute **att; if (soap_peek_element(soap)) { if (soap->error != SOAP_NO_TAG) return NULL; if (!node) { if (!(node = (struct soap_dom_element*)soap_malloc(soap, sizeof(struct soap_dom_element)))) { soap->error = SOAP_EOM; return NULL; } } soap_default_xsd__anyType(soap, node); if (!(node->data = soap_string_in(soap, 1, -1, -1)) || !*node->data) return NULL; soap->error = SOAP_OK; return node; } if (!node) { if (!(node = (struct soap_dom_element*)soap_malloc(soap, sizeof(struct soap_dom_element)))) { soap->error = SOAP_EOM; return NULL; } } soap_default_xsd__anyType(soap, node); node->nstr = soap_current_namespace(soap, soap->tag); if ((soap->mode & SOAP_DOM_ASIS)) node->name = soap_strdup(soap, soap->tag); else { char *s = strchr(soap->tag, ':'); if (s) node->name = soap_strdup(soap, s+1); else node->name = soap_strdup(soap, soap->tag); } DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node '%s' parsed in namespace '%s'\n", node->name, node->nstr?node->nstr:"")); if ((soap->mode & SOAP_DOM_NODE) || (!(soap->mode & SOAP_DOM_TREE) && *soap->id)) { if ((node->node = soap_getelement(soap, &node->type))) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node contains type %d from xsi:type\n", node->type)); return node; } if (soap->error == SOAP_TAG_MISMATCH) soap->error = SOAP_OK; else return NULL; } att = &node->atts; for (tp = soap->attributes; tp; tp = tp->next) { if (tp->visible) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node attribute='%s' parsed\n", tp->name)); *att = (struct soap_dom_attribute*)soap_malloc(soap, sizeof(struct soap_dom_attribute)); if (!*att) { soap->error = SOAP_EOM; return NULL; } (*att)->next = NULL; (*att)->nstr = soap_current_namespace(soap, tp->name); if ((soap->mode & SOAP_DOM_ASIS) || !strncmp(tp->name, "xml", 3)) (*att)->name = soap_strdup(soap, tp->name); else { char *s = strchr(tp->name, ':'); if (s) (*att)->name = soap_strdup(soap, s+1); else (*att)->name = soap_strdup(soap, tp->name); } if (tp->visible == 2) (*att)->data = soap_strdup(soap, tp->value); else (*att)->data = NULL; (*att)->wide = NULL; (*att)->soap = soap; att = &(*att)->next; tp->visible = 0; } } soap_element_begin_in(soap, NULL, 1, NULL); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node '%s' pulled\n", node->name)); if (soap->body) { if (!soap_peek_element(soap)) { struct soap_dom_element **elt; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node '%s' has subelements\n", node->name)); elt = &node->elts; for (;;) { if (!(*elt = soap_in_xsd__anyType(soap, NULL, NULL, NULL))) { if (soap->error != SOAP_NO_TAG) return NULL; soap->error = SOAP_OK; break; } (*elt)->prnt = node; elt = &(*elt)->next; } } else if (soap->error == SOAP_NO_TAG) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node '%s' has cdata\n", node->name)); if ((soap->mode & SOAP_C_UTFSTRING) || (soap->mode & SOAP_C_MBSTRING)) { if (!(node->data = soap_string_in(soap, 1, -1, -1))) return NULL; } else if (!(node->wide = soap_wstring_in(soap, 1, -1, -1))) return NULL; } else return NULL; if (soap_element_end_in(soap, node->name)) return NULL; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of DOM node '%s'\n", node->name)); } return node; }
SOAP_FMAC3 void * SOAP_FMAC4 soap_getelement(struct soap *soap, int *type) { if (soap_peek_element(soap)) return NULL; if (!*soap->id || !(*type = soap_lookup_type(soap, soap->id))) *type = soap_lookup_type(soap, soap->href); switch (*type) { case SOAP_TYPE_byte: return soap_in_byte(soap, NULL, NULL, "xsd:byte"); case SOAP_TYPE_int: return soap_in_int(soap, NULL, NULL, "xsd:int"); case SOAP_TYPE_time: return soap_in_time(soap, NULL, NULL, "xsd:dateTime"); case SOAP_TYPE_ns__currentTime: return soap_in_ns__currentTime(soap, NULL, NULL, "ns:currentTime"); case SOAP_TYPE_ns__currentTimeResponse: return soap_in_ns__currentTimeResponse(soap, NULL, NULL, "ns:currentTimeResponse"); case SOAP_TYPE_PointerTotime: return soap_in_PointerTotime(soap, NULL, NULL, "xsd:dateTime"); case SOAP_TYPE_string: { char **s; s = soap_in_string(soap, NULL, NULL, "xsd:string"); return s ? *s : NULL; } default: { const char *t = soap->type; if (!*t) t = soap->tag; if (!soap_match_tag(soap, t, "xsd:byte")) { *type = SOAP_TYPE_byte; return soap_in_byte(soap, NULL, NULL, NULL); } if (!soap_match_tag(soap, t, "xsd:int")) { *type = SOAP_TYPE_int; return soap_in_int(soap, NULL, NULL, NULL); } if (!soap_match_tag(soap, t, "xsd:dateTime")) { *type = SOAP_TYPE_time; return soap_in_time(soap, NULL, NULL, NULL); } if (!soap_match_tag(soap, t, "ns:currentTime")) { *type = SOAP_TYPE_ns__currentTime; return soap_in_ns__currentTime(soap, NULL, NULL, NULL); } if (!soap_match_tag(soap, t, "ns:currentTimeResponse")) { *type = SOAP_TYPE_ns__currentTimeResponse; return soap_in_ns__currentTimeResponse(soap, NULL, NULL, NULL); } if (!soap_match_tag(soap, t, "xsd:string")) { char **s; *type = SOAP_TYPE_string; s = soap_in_string(soap, NULL, NULL, NULL); return s ? *s : NULL; } t = soap->tag; if (!soap_match_tag(soap, t, "xsd:QName")) { char **s; *type = SOAP_TYPE__QName; s = soap_in__QName(soap, NULL, NULL, NULL); return s ? *s : NULL; } } } soap->error = SOAP_TAG_MISMATCH; return NULL; }
SOAP_FMAC2 soap_in_xsd__anyType(struct soap *soap, const char *tag, struct soap_dom_element *node, const char *type) { register struct soap_attribute *tp; register struct soap_dom_attribute **att; register struct soap_nlist *np; register char *s; if (soap_peek_element(soap)) return NULL; if (!node) if (!(node = (struct soap_dom_element*)soap_malloc(soap, sizeof(struct soap_dom_element)))) { soap->error = SOAP_EOM; return NULL; } node->next = NULL; node->prnt = NULL; node->elts = NULL; node->atts = NULL; node->nstr = NULL; node->name = NULL; node->data = NULL; node->wide = NULL; node->node = NULL; node->type = 0; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node %s\n", soap->tag)); np = soap->nlist; if (!(s = strchr(soap->tag, ':'))) { while (np && *np->id) /* find default namespace, if present */ np = np->next; s = soap->tag; } else { while (np && (strncmp(np->id, soap->tag, s - soap->tag) || np->id[s - soap->tag])) np = np->next; s++; if (!np) { soap->error = SOAP_NAMESPACE; return NULL; } } if (np) { if (np->index >= 0) node->nstr = soap->namespaces[np->index].ns; else if (np->ns) node->nstr = soap_strdup(soap, np->ns); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node namespace='%s'\n", node->nstr?node->nstr:"")); } node->name = soap_strdup(soap, soap->tag); if ((soap->mode & SOAP_DOM_NODE) || (!(soap->mode & SOAP_DOM_TREE) && *soap->id)) { if ((node->node = soap_getelement(soap, &node->type))) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node contains type %d from xsi:type\n", node->type)); return node; } if (soap->error == SOAP_TAG_MISMATCH) soap->error = SOAP_OK; else return NULL; } att = &node->atts; for (tp = soap->attributes; tp; tp = tp->next) if (tp->visible) { np = soap->nlist; if (!(s = strchr(tp->name, ':'))) { while (np && *np->id) /* find default namespace, if present */ np = np->next; s = tp->name; } else { while (np && (strncmp(np->id, tp->name, s - tp->name) || np->id[s - tp->name])) np = np->next; s++; if (!np) { soap->error = SOAP_NAMESPACE; return NULL; } } DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node attribute='%s'\n", tp->name)); *att = (struct soap_dom_attribute*)soap_malloc(soap, sizeof(struct soap_dom_attribute)); if (!*att) { soap->error = SOAP_EOM; return NULL; } (*att)->next = NULL; (*att)->nstr = NULL; if (np) { if (np->index >= 0) (*att)->nstr = soap->namespaces[np->index].ns; else if (np->ns) (*att)->nstr = soap_strdup(soap, np->ns); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM attribute namespace='%s'\n", (*att)->nstr?(*att)->nstr:"")); } (*att)->name = soap_strdup(soap, s); if (tp->visible == 2) (*att)->data = soap_strdup(soap, tp->value); else (*att)->data = NULL; (*att)->wide = NULL; att = &(*att)->next; tp->visible = 0; } soap_element_begin_in(soap, NULL, 1); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node '%s' accepted\n", node->name)); if (soap->body) { wchar c; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node '%s' has content\n", node->name)); do c = soap_getchar(soap); while (c > 0 && c <= 32); if (c == EOF) { soap->error = SOAP_EOF; return NULL; } soap_unget(soap, c); if (c == '<') { struct soap_dom_element **elt; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node '%s' has subelements\n", node->name)); elt = &node->elts; for (;;) { if (!(*elt = soap_in_xsd__anyType(soap, NULL, NULL, NULL))) { if (soap->error == SOAP_NO_TAG) soap->error = SOAP_OK; else return NULL; break; } (*elt)->prnt = node; elt = &(*elt)->next; } } else { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node '%s' has cdata\n", node->name)); if ((soap->mode & SOAP_C_UTFSTRING) || (soap->mode & SOAP_C_MBSTRING)) { if (!(node->data = soap_string_in(soap, 1, -1, -1))) return NULL; } else if (!(node->wide = soap_wstring_in(soap, 1, -1, -1))) return NULL; } if (soap_element_end_in(soap, node->name)) return NULL; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of DOM node '%s'\n", node->name)); } return node; }