diff options
Diffstat (limited to 'dep/gsoap')
-rw-r--r-- | dep/gsoap/soapC.cpp | 754 | ||||
-rw-r--r-- | dep/gsoap/soapH.h | 701 | ||||
-rw-r--r-- | dep/gsoap/soapServer.cpp | 19 | ||||
-rw-r--r-- | dep/gsoap/soapStub.h | 337 | ||||
-rw-r--r-- | dep/gsoap/stdsoap2.cpp | 7262 | ||||
-rw-r--r-- | dep/gsoap/stdsoap2.h | 1708 | ||||
-rw-r--r-- | dep/gsoap/tc_upgrades.txt | 3 |
7 files changed, 6854 insertions, 3930 deletions
diff --git a/dep/gsoap/soapC.cpp b/dep/gsoap/soapC.cpp index 321cae0299b..cc332c4854b 100644 --- a/dep/gsoap/soapC.cpp +++ b/dep/gsoap/soapC.cpp @@ -1,11 +1,14 @@ /* soapC.cpp - Generated by gSOAP 2.8.17r from gsoap.stub + Generated by gSOAP 2.8.33 for gsoap.stub -Copyright(C) 2000-2013, Robert van Engelen, Genivia Inc. All Rights Reserved. -The generated code is released under one of the following licenses: -GPL or Genivia's license for commercial use. +gSOAP XML Web services tools +Copyright (C) 2000-2016, Robert van Engelen, Genivia Inc. All Rights Reserved. +The soapcpp2 tool and its generated software are released under the GPL. This program is released under the GPL with the additional exemption that compiling, linking, and/or using OpenSSL is allowed. +-------------------------------------------------------------------------------- +A commercial use license is available from Genivia Inc., contact@genivia.com +-------------------------------------------------------------------------------- */ #if defined(__BORLANDC__) @@ -15,7 +18,7 @@ compiling, linking, and/or using OpenSSL is allowed. #include "soapH.h" -SOAP_SOURCE_STAMP("@(#) soapC.cpp ver 2.8.17r 2014-06-21 21:43:17 GMT") +SOAP_SOURCE_STAMP("@(#) soapC.cpp ver 2.8.33 2016-07-29 05:51:35 GMT") #ifndef WITH_NOGLOBAL @@ -32,7 +35,7 @@ SOAP_FMAC3 int SOAP_FMAC4 soap_putheader(struct soap *soap) { if (soap->version && soap->header) { soap->part = SOAP_IN_HEADER; - if (soap_out_SOAP_ENV__Header(soap, "SOAP-ENV:Header", 0, soap->header, NULL)) + if (soap_out_SOAP_ENV__Header(soap, "SOAP-ENV:Header", 0, soap->header, "")) return soap->error; soap->part = SOAP_END_HEADER; } @@ -48,7 +51,7 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_serializeheader(struct soap *soap) SOAP_FMAC3 void SOAP_FMAC4 soap_header(struct soap *soap) { if (soap->header == NULL) - { if ((soap->header = soap_new_SOAP_ENV__Header(soap, -1))) + { if ((soap->header = soap_new_SOAP_ENV__Header(soap))) soap_default_SOAP_ENV__Header(soap, soap->header); } } @@ -56,17 +59,17 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_header(struct soap *soap) SOAP_FMAC3 void SOAP_FMAC4 soap_fault(struct soap *soap) { if (soap->fault == NULL) - { soap->fault = soap_new_SOAP_ENV__Fault(soap, -1); + { soap->fault = soap_new_SOAP_ENV__Fault(soap); if (soap->fault == NULL) return; soap_default_SOAP_ENV__Fault(soap, soap->fault); } if (soap->version == 2 && !soap->fault->SOAP_ENV__Code) - { soap->fault->SOAP_ENV__Code = soap_new_SOAP_ENV__Code(soap, -1); + { soap->fault->SOAP_ENV__Code = soap_new_SOAP_ENV__Code(soap); soap_default_SOAP_ENV__Code(soap, soap->fault->SOAP_ENV__Code); } if (soap->version == 2 && !soap->fault->SOAP_ENV__Reason) - { soap->fault->SOAP_ENV__Reason = soap_new_SOAP_ENV__Reason(soap, -1); + { soap->fault->SOAP_ENV__Reason = soap_new_SOAP_ENV__Reason(soap); soap_default_SOAP_ENV__Reason(soap, soap->fault->SOAP_ENV__Reason); } } @@ -81,7 +84,7 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_serializefault(struct soap *soap) SOAP_FMAC3 int SOAP_FMAC4 soap_putfault(struct soap *soap) { if (soap->fault) - return soap_put_SOAP_ENV__Fault(soap, soap->fault, "SOAP-ENV:Fault", NULL); + return soap_put_SOAP_ENV__Fault(soap, soap->fault, "SOAP-ENV:Fault", ""); return SOAP_OK; } @@ -94,8 +97,8 @@ SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultcode(struct soap *soap) { soap_fault(soap); if (soap->version == 2 && soap->fault->SOAP_ENV__Code) - return (const char**)&soap->fault->SOAP_ENV__Code->SOAP_ENV__Value; - return (const char**)&soap->fault->faultcode; + return (const char**)(void*)&soap->fault->SOAP_ENV__Code->SOAP_ENV__Value; + return (const char**)(void*)&soap->fault->faultcode; } SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultsubcode(struct soap *soap) @@ -103,19 +106,19 @@ SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultsubcode(struct soap *soap) soap_fault(soap); if (soap->version == 2) { if (soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode == NULL) - { soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode = soap_new_SOAP_ENV__Code(soap, -1); + { soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode = soap_new_SOAP_ENV__Code(soap); soap_default_SOAP_ENV__Code(soap, soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode); } - return (const char**)&soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode->SOAP_ENV__Value; + return (const char**)(void*)&soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode->SOAP_ENV__Value; } - return (const char**)&soap->fault->faultcode; + return (const char**)(void*)&soap->fault->faultcode; } SOAP_FMAC3 const char * SOAP_FMAC4 soap_check_faultsubcode(struct soap *soap) { soap_fault(soap); if (soap->version == 2) - { if (soap->fault->SOAP_ENV__Code && soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode && soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode) + { if (soap->fault->SOAP_ENV__Code && soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode) return soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode->SOAP_ENV__Value; return NULL; } @@ -126,8 +129,8 @@ SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultstring(struct soap *soap) { soap_fault(soap); if (soap->version == 2) - return (const char**)&soap->fault->SOAP_ENV__Reason->SOAP_ENV__Text; - return (const char**)&soap->fault->faultstring; + return (const char**)(void*)&soap->fault->SOAP_ENV__Reason->SOAP_ENV__Text; + return (const char**)(void*)&soap->fault->faultstring; } SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultdetail(struct soap *soap) @@ -135,16 +138,16 @@ SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultdetail(struct soap *soap) soap_fault(soap); if (soap->version == 2) { if (soap->fault->SOAP_ENV__Detail == NULL) - { soap->fault->SOAP_ENV__Detail = soap_new_SOAP_ENV__Detail(soap, -1); + { soap->fault->SOAP_ENV__Detail = soap_new_SOAP_ENV__Detail(soap); soap_default_SOAP_ENV__Detail(soap, soap->fault->SOAP_ENV__Detail); } - return (const char**)&soap->fault->SOAP_ENV__Detail->__any; + return (const char**)(void*)&soap->fault->SOAP_ENV__Detail->__any; } if (soap->fault->detail == NULL) - { soap->fault->detail = soap_new_SOAP_ENV__Detail(soap, -1); + { soap->fault->detail = soap_new_SOAP_ENV__Detail(soap); soap_default_SOAP_ENV__Detail(soap, soap->fault->detail); } - return (const char**)&soap->fault->detail->__any; + return (const char**)(void*)&soap->fault->detail->__any; } SOAP_FMAC3 const char * SOAP_FMAC4 soap_check_faultdetail(struct soap *soap) @@ -166,7 +169,7 @@ SOAP_FMAC3 int SOAP_FMAC4 soap_getindependent(struct soap *soap) if (soap->version == 1) { for (;;) { if (!soap_getelement(soap, &t)) - if (soap->error || soap_ignore_element(soap)) + if ((soap->error && soap->error != SOAP_TAG_MISMATCH) || soap_ignore_element(soap)) break; } } @@ -260,8 +263,8 @@ 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) + 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 && !soap->fignore) 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)); @@ -276,10 +279,8 @@ SOAP_FMAC3 int SOAP_FMAC4 soap_ignore_element(struct soap *soap) 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); + if (soap_ignore(soap) || soap_element_end_in(soap, NULL)) + return soap->error; } } } @@ -295,7 +296,7 @@ SOAP_FMAC3 int SOAP_FMAC4 soap_putindependent(struct soap *soap) for (i = 0; i < SOAP_PTRHASH; i++) for (pp = soap->pht[i]; pp; pp = pp->next) if (pp->mark1 == 2 || pp->mark2 == 2) - if (soap_putelement(soap, pp->ptr, "id", pp->id, pp->type)) + if (soap_putelement(soap, pp->ptr, SOAP_MULTIREFTAG, pp->id, pp->type)) return soap->error; return SOAP_OK; } @@ -319,13 +320,12 @@ SOAP_FMAC3 int SOAP_FMAC4 soap_putelement(struct soap *soap, const void *ptr, co case SOAP_TYPE_PointerTostring: return soap_out_PointerTostring(soap, tag, id, (char **const*)ptr, "xsd:string"); case SOAP_TYPE__QName: - return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:QName"); + return soap_out_string(soap, tag, id, (char*const*)(void*)&ptr, "xsd:QName"); case SOAP_TYPE_string: - return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:string"); + return soap_out_string(soap, tag, id, (char*const*)(void*)&ptr, "xsd:string"); } return SOAP_OK; } - #ifdef __cplusplus } #endif @@ -350,14 +350,13 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_markelement(struct soap *soap, const void *ptr, soap_serialize_PointerTostring(soap, (char **const*)ptr); break; case SOAP_TYPE__QName: - soap_serialize_string(soap, (char*const*)&ptr); + soap_serialize_string(soap, (char*const*)(void*)&ptr); break; case SOAP_TYPE_string: - soap_serialize_string(soap, (char*const*)&ptr); + soap_serialize_string(soap, (char*const*)(void*)&ptr); break; } } - #ifdef __cplusplus } #endif @@ -400,64 +399,139 @@ SOAP_FMAC3 int SOAP_FMAC4 soap_fdelete(struct soap_clist *p) { case SOAP_TYPE_ns1__executeCommandResponse: if (p->size < 0) - SOAP_DELETE((struct ns1__executeCommandResponse*)p->ptr); + SOAP_DELETE(static_cast<struct ns1__executeCommandResponse*>(p->ptr)); else - SOAP_DELETE_ARRAY((struct ns1__executeCommandResponse*)p->ptr); + SOAP_DELETE_ARRAY(static_cast<struct ns1__executeCommandResponse*>(p->ptr)); break; case SOAP_TYPE_ns1__executeCommand: if (p->size < 0) - SOAP_DELETE((struct ns1__executeCommand*)p->ptr); + SOAP_DELETE(static_cast<struct ns1__executeCommand*>(p->ptr)); else - SOAP_DELETE_ARRAY((struct ns1__executeCommand*)p->ptr); + SOAP_DELETE_ARRAY(static_cast<struct ns1__executeCommand*>(p->ptr)); break; #ifndef WITH_NOGLOBAL case SOAP_TYPE_SOAP_ENV__Header: if (p->size < 0) - SOAP_DELETE((struct SOAP_ENV__Header*)p->ptr); + SOAP_DELETE(static_cast<struct SOAP_ENV__Header*>(p->ptr)); else - SOAP_DELETE_ARRAY((struct SOAP_ENV__Header*)p->ptr); + SOAP_DELETE_ARRAY(static_cast<struct SOAP_ENV__Header*>(p->ptr)); break; #endif #ifndef WITH_NOGLOBAL case SOAP_TYPE_SOAP_ENV__Code: if (p->size < 0) - SOAP_DELETE((struct SOAP_ENV__Code*)p->ptr); + SOAP_DELETE(static_cast<struct SOAP_ENV__Code*>(p->ptr)); else - SOAP_DELETE_ARRAY((struct SOAP_ENV__Code*)p->ptr); + SOAP_DELETE_ARRAY(static_cast<struct SOAP_ENV__Code*>(p->ptr)); break; #endif #ifndef WITH_NOGLOBAL case SOAP_TYPE_SOAP_ENV__Detail: if (p->size < 0) - SOAP_DELETE((struct SOAP_ENV__Detail*)p->ptr); + SOAP_DELETE(static_cast<struct SOAP_ENV__Detail*>(p->ptr)); else - SOAP_DELETE_ARRAY((struct SOAP_ENV__Detail*)p->ptr); + SOAP_DELETE_ARRAY(static_cast<struct SOAP_ENV__Detail*>(p->ptr)); break; #endif #ifndef WITH_NOGLOBAL case SOAP_TYPE_SOAP_ENV__Reason: if (p->size < 0) - SOAP_DELETE((struct SOAP_ENV__Reason*)p->ptr); + SOAP_DELETE(static_cast<struct SOAP_ENV__Reason*>(p->ptr)); else - SOAP_DELETE_ARRAY((struct SOAP_ENV__Reason*)p->ptr); + SOAP_DELETE_ARRAY(static_cast<struct SOAP_ENV__Reason*>(p->ptr)); break; #endif #ifndef WITH_NOGLOBAL case SOAP_TYPE_SOAP_ENV__Fault: if (p->size < 0) - SOAP_DELETE((struct SOAP_ENV__Fault*)p->ptr); + SOAP_DELETE(static_cast<struct SOAP_ENV__Fault*>(p->ptr)); else - SOAP_DELETE_ARRAY((struct SOAP_ENV__Fault*)p->ptr); + SOAP_DELETE_ARRAY(static_cast<struct SOAP_ENV__Fault*>(p->ptr)); break; #endif - default: return SOAP_ERR; + default: + return SOAP_ERR; } return SOAP_OK; } -SOAP_FMAC3 void* SOAP_FMAC4 soap_class_id_enter(struct soap *soap, const char *id, void *p, int t, size_t n, const char *type, const char *arrayType) -{ return soap_id_enter(soap, id, p, t, n, 0, type, arrayType, soap_instantiate); +#ifdef WIN32 +#pragma warning(push) +// do not warn on switch w/o cases +#pragma warning(disable:4065) +#endif +SOAP_FMAC3 int SOAP_FMAC4 soap_fbase(int t, int b) +{ + do + { switch (t) + { + default: return 0; + } + } + while (t != b); + return 1; +} +#ifdef WIN32 +#pragma warning(pop) +#endif + +#ifndef WITH_NOIDREF +#ifdef WIN32 +#pragma warning(push) +// do not warn on switch w/o cases +#pragma warning(disable:4065) +#endif +SOAP_FMAC3 void SOAP_FMAC4 soap_finsert(struct soap *soap, int t, int tt, void *p, size_t index, const void *q, void **x) +{ + (void)soap; (void)t; (void)p; (void)index; (void)q; (void)x; /* appease -Wall -Werror */ + switch (tt) + { + case SOAP_TYPE_ns1__executeCommandResponse: + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy struct ns1__executeCommandResponse type=%d location=%p object=%p\n", t, p, q)); + *(struct ns1__executeCommandResponse*)p = *(struct ns1__executeCommandResponse*)q; + break; + case SOAP_TYPE_ns1__executeCommand: + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy struct ns1__executeCommand type=%d location=%p object=%p\n", t, p, q)); + *(struct ns1__executeCommand*)p = *(struct ns1__executeCommand*)q; + break; +#ifndef WITH_NOGLOBAL + case SOAP_TYPE_SOAP_ENV__Header: + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy struct SOAP_ENV__Header type=%d location=%p object=%p\n", t, p, q)); + *(struct SOAP_ENV__Header*)p = *(struct SOAP_ENV__Header*)q; + break; +#endif +#ifndef WITH_NOGLOBAL + case SOAP_TYPE_SOAP_ENV__Code: + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy struct SOAP_ENV__Code type=%d location=%p object=%p\n", t, p, q)); + *(struct SOAP_ENV__Code*)p = *(struct SOAP_ENV__Code*)q; + break; +#endif +#ifndef WITH_NOGLOBAL + case SOAP_TYPE_SOAP_ENV__Detail: + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy struct SOAP_ENV__Detail type=%d location=%p object=%p\n", t, p, q)); + *(struct SOAP_ENV__Detail*)p = *(struct SOAP_ENV__Detail*)q; + break; +#endif +#ifndef WITH_NOGLOBAL + case SOAP_TYPE_SOAP_ENV__Reason: + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy struct SOAP_ENV__Reason type=%d location=%p object=%p\n", t, p, q)); + *(struct SOAP_ENV__Reason*)p = *(struct SOAP_ENV__Reason*)q; + break; +#endif +#ifndef WITH_NOGLOBAL + case SOAP_TYPE_SOAP_ENV__Fault: + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy struct SOAP_ENV__Fault type=%d location=%p object=%p\n", t, p, q)); + *(struct SOAP_ENV__Fault*)p = *(struct SOAP_ENV__Fault*)q; + break; +#endif + default: + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not insert type = %d in %d\n", t, tt)); + } } +#ifdef WIN32 +#pragma warning(pop) +#endif +#endif SOAP_FMAC3 void SOAP_FMAC4 soap_default_byte(struct soap *soap, char *a) { @@ -470,20 +544,19 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_default_byte(struct soap *soap, char *a) } SOAP_FMAC3 int SOAP_FMAC4 soap_out_byte(struct soap *soap, const char *tag, int id, const char *a, const char *type) -{ (void)soap; (void)type; (void)tag; (void)id; +{ return soap_outbyte(soap, tag, id, a, type, SOAP_TYPE_byte); } SOAP_FMAC3 char * SOAP_FMAC4 soap_in_byte(struct soap *soap, const char *tag, char *a, const char *type) -{ char *p; - p = soap_inbyte(soap, tag, a, type, SOAP_TYPE_byte); - return p; +{ + a = soap_inbyte(soap, tag, a, type, SOAP_TYPE_byte); + return a; } SOAP_FMAC3 int SOAP_FMAC4 soap_put_byte(struct soap *soap, const char *a, const char *tag, const char *type) { - register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_byte); - if (soap_out_byte(soap, tag?tag:"byte", id, a, type)) + if (soap_out_byte(soap, tag?tag:"byte", -2, a, type)) return soap->error; return soap_putindependent(soap); } @@ -507,20 +580,19 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_default_int(struct soap *soap, int *a) } SOAP_FMAC3 int SOAP_FMAC4 soap_out_int(struct soap *soap, const char *tag, int id, const int *a, const char *type) -{ (void)soap; (void)type; (void)tag; (void)id; +{ return soap_outint(soap, tag, id, a, type, SOAP_TYPE_int); } SOAP_FMAC3 int * SOAP_FMAC4 soap_in_int(struct soap *soap, const char *tag, int *a, const char *type) -{ int *p; - p = soap_inint(soap, tag, a, type, SOAP_TYPE_int); - return p; +{ + a = soap_inint(soap, tag, a, type, SOAP_TYPE_int); + return a; } SOAP_FMAC3 int SOAP_FMAC4 soap_put_int(struct soap *soap, const int *a, const char *tag, const char *type) { - register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_int); - if (soap_out_int(soap, tag?tag:"int", id, a, type)) + if (soap_out_int(soap, tag?tag:"int", -2, a, type)) return soap->error; return soap_putindependent(soap); } @@ -551,16 +623,16 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Fault(struct soap *soap, struc SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Fault(struct soap *soap, const struct SOAP_ENV__Fault *a) { -#ifndef WITH_NOIDREF (void)soap; (void)a; /* appease -Wall -Werror */ - soap_serialize__QName(soap, &a->faultcode); - soap_serialize_string(soap, &a->faultstring); - soap_serialize_string(soap, &a->faultactor); +#ifndef WITH_NOIDREF + soap_serialize__QName(soap, (char*const*)&a->faultcode); + soap_serialize_string(soap, (char*const*)&a->faultstring); + soap_serialize_string(soap, (char*const*)&a->faultactor); soap_serialize_PointerToSOAP_ENV__Detail(soap, &a->detail); soap_serialize_PointerToSOAP_ENV__Code(soap, &a->SOAP_ENV__Code); soap_serialize_PointerToSOAP_ENV__Reason(soap, &a->SOAP_ENV__Reason); - soap_serialize_string(soap, &a->SOAP_ENV__Node); - soap_serialize_string(soap, &a->SOAP_ENV__Role); + soap_serialize_string(soap, (char*const*)&a->SOAP_ENV__Node); + soap_serialize_string(soap, (char*const*)&a->SOAP_ENV__Role); soap_serialize_PointerToSOAP_ENV__Detail(soap, &a->SOAP_ENV__Detail); #endif } @@ -568,14 +640,14 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Fault(struct soap *soap, con SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Fault(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Fault *a, const char *type) { const char *soap_tmp_faultcode = soap_QName2s(soap, a->faultcode); - (void)soap; (void)tag; (void)id; (void)type; + (void)soap; (void)tag; (void)id; (void)a; (void)type; /* appease -Wall -Werror */ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_SOAP_ENV__Fault), type)) return soap->error; - if (soap_out__QName(soap, "faultcode", -1, (char*const*)&soap_tmp_faultcode, "")) + if (soap_out__QName(soap, "faultcode", -1, (char*const*)(void*)&soap_tmp_faultcode, "")) return soap->error; - if (soap_out_string(soap, "faultstring", -1, &a->faultstring, "")) + if (soap_out_string(soap, "faultstring", -1, (char*const*)&a->faultstring, "")) return soap->error; - if (soap_out_string(soap, "faultactor", -1, &a->faultactor, "")) + if (soap_out_string(soap, "faultactor", -1, (char*const*)&a->faultactor, "")) return soap->error; if (soap_out_PointerToSOAP_ENV__Detail(soap, "detail", -1, &a->detail, "")) return soap->error; @@ -583,9 +655,9 @@ SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Fault(struct soap *soap, const char return soap->error; if (soap_out_PointerToSOAP_ENV__Reason(soap, "SOAP-ENV:Reason", -1, &a->SOAP_ENV__Reason, "")) return soap->error; - if (soap_out_string(soap, "SOAP-ENV:Node", -1, &a->SOAP_ENV__Node, "")) + if (soap_out_string(soap, "SOAP-ENV:Node", -1, (char*const*)&a->SOAP_ENV__Node, "")) return soap->error; - if (soap_out_string(soap, "SOAP-ENV:Role", -1, &a->SOAP_ENV__Role, "")) + if (soap_out_string(soap, "SOAP-ENV:Role", -1, (char*const*)&a->SOAP_ENV__Role, "")) return soap->error; if (soap_out_PointerToSOAP_ENV__Detail(soap, "SOAP-ENV:Detail", -1, &a->SOAP_ENV__Detail, "")) return soap->error; @@ -605,7 +677,7 @@ SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_in_SOAP_ENV__Fault(struct so size_t soap_flag_SOAP_ENV__Detail = 1; if (soap_element_begin_in(soap, tag, 0, type)) return NULL; - a = (struct SOAP_ENV__Fault *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_SOAP_ENV__Fault, sizeof(struct SOAP_ENV__Fault), 0, NULL, NULL, NULL); + a = (struct SOAP_ENV__Fault *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_SOAP_ENV__Fault, sizeof(struct SOAP_ENV__Fault), NULL, NULL, NULL, NULL); if (!a) return NULL; soap_default_SOAP_ENV__Fault(soap, a); @@ -614,17 +686,17 @@ SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_in_SOAP_ENV__Fault(struct so for (;;) { soap->error = SOAP_TAG_MISMATCH; if (soap_flag_faultcode && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG)) - if (soap_in__QName(soap, "faultcode", &a->faultcode, "")) + if (soap_in__QName(soap, "faultcode", (char**)&a->faultcode, "xsd:QName")) { soap_flag_faultcode--; continue; } if (soap_flag_faultstring && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG)) - if (soap_in_string(soap, "faultstring", &a->faultstring, "xsd:string")) + if (soap_in_string(soap, "faultstring", (char**)&a->faultstring, "xsd:string")) { soap_flag_faultstring--; continue; } if (soap_flag_faultactor && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG)) - if (soap_in_string(soap, "faultactor", &a->faultactor, "xsd:string")) + if (soap_in_string(soap, "faultactor", (char**)&a->faultactor, "xsd:string")) { soap_flag_faultactor--; continue; } @@ -644,12 +716,12 @@ SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_in_SOAP_ENV__Fault(struct so continue; } if (soap_flag_SOAP_ENV__Node && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG)) - if (soap_in_string(soap, "SOAP-ENV:Node", &a->SOAP_ENV__Node, "xsd:string")) + if (soap_in_string(soap, "SOAP-ENV:Node", (char**)&a->SOAP_ENV__Node, "xsd:string")) { soap_flag_SOAP_ENV__Node--; continue; } if (soap_flag_SOAP_ENV__Role && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG)) - if (soap_in_string(soap, "SOAP-ENV:Role", &a->SOAP_ENV__Role, "xsd:string")) + if (soap_in_string(soap, "SOAP-ENV:Role", (char**)&a->SOAP_ENV__Role, "xsd:string")) { soap_flag_SOAP_ENV__Role--; continue; } @@ -669,17 +741,36 @@ SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_in_SOAP_ENV__Fault(struct so return NULL; } else - { a = (struct SOAP_ENV__Fault *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_SOAP_ENV__Fault, 0, sizeof(struct SOAP_ENV__Fault), 0, NULL); + { a = (struct SOAP_ENV__Fault *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_SOAP_ENV__Fault, SOAP_TYPE_SOAP_ENV__Fault, sizeof(struct SOAP_ENV__Fault), 0, soap_finsert, NULL); if (soap->body && soap_element_end_in(soap, tag)) return NULL; } return a; } +SOAP_FMAC1 struct SOAP_ENV__Fault * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Fault(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size) +{ + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Fault(%p, %d, %s, %s)\n", soap, n, type?type:"", arrayType?arrayType:"")); + (void)type; (void)arrayType; /* appease -Wall -Werror */ + struct SOAP_ENV__Fault *p; + size_t k = sizeof(struct SOAP_ENV__Fault); + if (n < 0) + { p = SOAP_NEW(struct SOAP_ENV__Fault); + } + else + { p = SOAP_NEW_ARRAY(struct SOAP_ENV__Fault, n); + k *= n; + } + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated struct SOAP_ENV__Fault location=%p n=%d\n", p, n)); + soap_link(soap, p, SOAP_TYPE_SOAP_ENV__Fault, n, soap_fdelete); + if (size) + *size = k; + return p; +} + SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Fault(struct soap *soap, const struct SOAP_ENV__Fault *a, const char *tag, const char *type) { - register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_SOAP_ENV__Fault); - if (soap_out_SOAP_ENV__Fault(soap, tag?tag:"SOAP-ENV:Fault", id, a, type)) + if (soap_out_SOAP_ENV__Fault(soap, tag?tag:"SOAP-ENV:Fault", -2, a, type)) return soap->error; return soap_putindependent(soap); } @@ -692,36 +783,6 @@ SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_get_SOAP_ENV__Fault(struct s return p; } -SOAP_FMAC1 struct SOAP_ENV__Fault * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Fault(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size) -{ - (void)type; (void)arrayType; /* appease -Wall -Werror */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Fault(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:"")); - struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_SOAP_ENV__Fault, n, soap_fdelete); - if (!cp) - return NULL; - if (n < 0) - { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Fault); - if (size) - *size = sizeof(struct SOAP_ENV__Fault); - } - else - { cp->ptr = (void*)SOAP_NEW_ARRAY(struct SOAP_ENV__Fault, n); - if (size) - *size = n * sizeof(struct SOAP_ENV__Fault); - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr)); - if (!cp->ptr) - soap->error = SOAP_EOM; - return (struct SOAP_ENV__Fault*)cp->ptr; -} - -SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Fault(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n) -{ - (void)soap; (void)tt; (void)st; (void)len; (void)n; /* appease -Wall -Werror */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Fault %p -> %p\n", q, p)); - *(struct SOAP_ENV__Fault*)p = *(struct SOAP_ENV__Fault*)q; -} - #endif #ifndef WITH_NOGLOBAL @@ -734,20 +795,20 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Reason(struct soap *soap, stru SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Reason(struct soap *soap, const struct SOAP_ENV__Reason *a) { -#ifndef WITH_NOIDREF (void)soap; (void)a; /* appease -Wall -Werror */ - soap_serialize_string(soap, &a->SOAP_ENV__Text); +#ifndef WITH_NOIDREF + soap_serialize_string(soap, (char*const*)&a->SOAP_ENV__Text); #endif } SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Reason(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Reason *a, const char *type) { - (void)soap; (void)tag; (void)id; (void)type; + (void)soap; (void)tag; (void)id; (void)a; (void)type; /* appease -Wall -Werror */ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_SOAP_ENV__Reason), type)) return soap->error; if (soap->lang) soap_set_attr(soap, "xml:lang", soap->lang, 1); - if (soap_out_string(soap, "SOAP-ENV:Text", -1, &a->SOAP_ENV__Text, "")) + if (soap_out_string(soap, "SOAP-ENV:Text", -1, (char*const*)&a->SOAP_ENV__Text, "")) return soap->error; return soap_element_end_out(soap, tag); } @@ -757,7 +818,7 @@ SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_in_SOAP_ENV__Reason(struct size_t soap_flag_SOAP_ENV__Text = 1; if (soap_element_begin_in(soap, tag, 0, type)) return NULL; - a = (struct SOAP_ENV__Reason *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_SOAP_ENV__Reason, sizeof(struct SOAP_ENV__Reason), 0, NULL, NULL, NULL); + a = (struct SOAP_ENV__Reason *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_SOAP_ENV__Reason, sizeof(struct SOAP_ENV__Reason), NULL, NULL, NULL, NULL); if (!a) return NULL; soap_default_SOAP_ENV__Reason(soap, a); @@ -766,7 +827,7 @@ SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_in_SOAP_ENV__Reason(struct for (;;) { soap->error = SOAP_TAG_MISMATCH; if (soap_flag_SOAP_ENV__Text && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG)) - if (soap_in_string(soap, "SOAP-ENV:Text", &a->SOAP_ENV__Text, "xsd:string")) + if (soap_in_string(soap, "SOAP-ENV:Text", (char**)&a->SOAP_ENV__Text, "xsd:string")) { soap_flag_SOAP_ENV__Text--; continue; } @@ -781,17 +842,36 @@ SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_in_SOAP_ENV__Reason(struct return NULL; } else - { a = (struct SOAP_ENV__Reason *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_SOAP_ENV__Reason, 0, sizeof(struct SOAP_ENV__Reason), 0, NULL); + { a = (struct SOAP_ENV__Reason *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_SOAP_ENV__Reason, SOAP_TYPE_SOAP_ENV__Reason, sizeof(struct SOAP_ENV__Reason), 0, soap_finsert, NULL); if (soap->body && soap_element_end_in(soap, tag)) return NULL; } return a; } +SOAP_FMAC1 struct SOAP_ENV__Reason * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Reason(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size) +{ + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Reason(%p, %d, %s, %s)\n", soap, n, type?type:"", arrayType?arrayType:"")); + (void)type; (void)arrayType; /* appease -Wall -Werror */ + struct SOAP_ENV__Reason *p; + size_t k = sizeof(struct SOAP_ENV__Reason); + if (n < 0) + { p = SOAP_NEW(struct SOAP_ENV__Reason); + } + else + { p = SOAP_NEW_ARRAY(struct SOAP_ENV__Reason, n); + k *= n; + } + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated struct SOAP_ENV__Reason location=%p n=%d\n", p, n)); + soap_link(soap, p, SOAP_TYPE_SOAP_ENV__Reason, n, soap_fdelete); + if (size) + *size = k; + return p; +} + SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Reason(struct soap *soap, const struct SOAP_ENV__Reason *a, const char *tag, const char *type) { - register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_SOAP_ENV__Reason); - if (soap_out_SOAP_ENV__Reason(soap, tag?tag:"SOAP-ENV:Reason", id, a, type)) + if (soap_out_SOAP_ENV__Reason(soap, tag?tag:"SOAP-ENV:Reason", -2, a, type)) return soap->error; return soap_putindependent(soap); } @@ -804,36 +884,6 @@ SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_get_SOAP_ENV__Reason(struct return p; } -SOAP_FMAC1 struct SOAP_ENV__Reason * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Reason(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size) -{ - (void)type; (void)arrayType; /* appease -Wall -Werror */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Reason(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:"")); - struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_SOAP_ENV__Reason, n, soap_fdelete); - if (!cp) - return NULL; - if (n < 0) - { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Reason); - if (size) - *size = sizeof(struct SOAP_ENV__Reason); - } - else - { cp->ptr = (void*)SOAP_NEW_ARRAY(struct SOAP_ENV__Reason, n); - if (size) - *size = n * sizeof(struct SOAP_ENV__Reason); - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr)); - if (!cp->ptr) - soap->error = SOAP_EOM; - return (struct SOAP_ENV__Reason*)cp->ptr; -} - -SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Reason(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n) -{ - (void)soap; (void)tt; (void)st; (void)len; (void)n; /* appease -Wall -Werror */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Reason %p -> %p\n", q, p)); - *(struct SOAP_ENV__Reason*)p = *(struct SOAP_ENV__Reason*)q; -} - #endif #ifndef WITH_NOGLOBAL @@ -848,18 +898,18 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Detail(struct soap *soap, stru SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Detail(struct soap *soap, const struct SOAP_ENV__Detail *a) { -#ifndef WITH_NOIDREF (void)soap; (void)a; /* appease -Wall -Werror */ +#ifndef WITH_NOIDREF soap_markelement(soap, a->fault, a->__type); #endif } SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Detail(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Detail *a, const char *type) { - (void)soap; (void)tag; (void)id; (void)type; + (void)soap; (void)tag; (void)id; (void)a; (void)type; /* appease -Wall -Werror */ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_SOAP_ENV__Detail), type)) return soap->error; - soap_outliteral(soap, "-any", &a->__any, NULL); + soap_outliteral(soap, "-any", (char*const*)&a->__any, NULL); if (soap_putelement(soap, a->fault, "fault", -1, a->__type)) return soap->error; return soap_element_end_out(soap, tag); @@ -871,7 +921,7 @@ SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_in_SOAP_ENV__Detail(struct size_t soap_flag_fault = 1; if (soap_element_begin_in(soap, tag, 0, type)) return NULL; - a = (struct SOAP_ENV__Detail *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_SOAP_ENV__Detail, sizeof(struct SOAP_ENV__Detail), 0, NULL, NULL, NULL); + a = (struct SOAP_ENV__Detail *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_SOAP_ENV__Detail, sizeof(struct SOAP_ENV__Detail), NULL, NULL, NULL, NULL); if (!a) return NULL; soap_default_SOAP_ENV__Detail(soap, a); @@ -885,7 +935,7 @@ SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_in_SOAP_ENV__Detail(struct continue; } if (soap_flag___any && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG)) - if (soap_inliteral(soap, "-any", &a->__any)) + if (soap_inliteral(soap, "-any", (char**)&a->__any)) { soap_flag___any--; continue; } @@ -900,17 +950,36 @@ SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_in_SOAP_ENV__Detail(struct return NULL; } else - { a = (struct SOAP_ENV__Detail *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_SOAP_ENV__Detail, 0, sizeof(struct SOAP_ENV__Detail), 0, NULL); + { a = (struct SOAP_ENV__Detail *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_SOAP_ENV__Detail, SOAP_TYPE_SOAP_ENV__Detail, sizeof(struct SOAP_ENV__Detail), 0, soap_finsert, NULL); if (soap->body && soap_element_end_in(soap, tag)) return NULL; } return a; } +SOAP_FMAC1 struct SOAP_ENV__Detail * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Detail(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size) +{ + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Detail(%p, %d, %s, %s)\n", soap, n, type?type:"", arrayType?arrayType:"")); + (void)type; (void)arrayType; /* appease -Wall -Werror */ + struct SOAP_ENV__Detail *p; + size_t k = sizeof(struct SOAP_ENV__Detail); + if (n < 0) + { p = SOAP_NEW(struct SOAP_ENV__Detail); + } + else + { p = SOAP_NEW_ARRAY(struct SOAP_ENV__Detail, n); + k *= n; + } + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated struct SOAP_ENV__Detail location=%p n=%d\n", p, n)); + soap_link(soap, p, SOAP_TYPE_SOAP_ENV__Detail, n, soap_fdelete); + if (size) + *size = k; + return p; +} + SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Detail(struct soap *soap, const struct SOAP_ENV__Detail *a, const char *tag, const char *type) { - register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_SOAP_ENV__Detail); - if (soap_out_SOAP_ENV__Detail(soap, tag?tag:"SOAP-ENV:Detail", id, a, type)) + if (soap_out_SOAP_ENV__Detail(soap, tag?tag:"SOAP-ENV:Detail", -2, a, type)) return soap->error; return soap_putindependent(soap); } @@ -923,36 +992,6 @@ SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_get_SOAP_ENV__Detail(struct return p; } -SOAP_FMAC1 struct SOAP_ENV__Detail * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Detail(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size) -{ - (void)type; (void)arrayType; /* appease -Wall -Werror */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Detail(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:"")); - struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_SOAP_ENV__Detail, n, soap_fdelete); - if (!cp) - return NULL; - if (n < 0) - { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Detail); - if (size) - *size = sizeof(struct SOAP_ENV__Detail); - } - else - { cp->ptr = (void*)SOAP_NEW_ARRAY(struct SOAP_ENV__Detail, n); - if (size) - *size = n * sizeof(struct SOAP_ENV__Detail); - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr)); - if (!cp->ptr) - soap->error = SOAP_EOM; - return (struct SOAP_ENV__Detail*)cp->ptr; -} - -SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Detail(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n) -{ - (void)soap; (void)tt; (void)st; (void)len; (void)n; /* appease -Wall -Werror */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Detail %p -> %p\n", q, p)); - *(struct SOAP_ENV__Detail*)p = *(struct SOAP_ENV__Detail*)q; -} - #endif #ifndef WITH_NOGLOBAL @@ -966,9 +1005,9 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Code(struct soap *soap, struct SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Code(struct soap *soap, const struct SOAP_ENV__Code *a) { -#ifndef WITH_NOIDREF (void)soap; (void)a; /* appease -Wall -Werror */ - soap_serialize__QName(soap, &a->SOAP_ENV__Value); +#ifndef WITH_NOIDREF + soap_serialize__QName(soap, (char*const*)&a->SOAP_ENV__Value); soap_serialize_PointerToSOAP_ENV__Code(soap, &a->SOAP_ENV__Subcode); #endif } @@ -976,10 +1015,10 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Code(struct soap *soap, cons SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Code(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Code *a, const char *type) { const char *soap_tmp_SOAP_ENV__Value = soap_QName2s(soap, a->SOAP_ENV__Value); - (void)soap; (void)tag; (void)id; (void)type; + (void)soap; (void)tag; (void)id; (void)a; (void)type; /* appease -Wall -Werror */ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_SOAP_ENV__Code), type)) return soap->error; - if (soap_out__QName(soap, "SOAP-ENV:Value", -1, (char*const*)&soap_tmp_SOAP_ENV__Value, "")) + if (soap_out__QName(soap, "SOAP-ENV:Value", -1, (char*const*)(void*)&soap_tmp_SOAP_ENV__Value, "")) return soap->error; if (soap_out_PointerToSOAP_ENV__Code(soap, "SOAP-ENV:Subcode", -1, &a->SOAP_ENV__Subcode, "")) return soap->error; @@ -992,7 +1031,7 @@ SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_in_SOAP_ENV__Code(struct soap size_t soap_flag_SOAP_ENV__Subcode = 1; if (soap_element_begin_in(soap, tag, 0, type)) return NULL; - a = (struct SOAP_ENV__Code *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_SOAP_ENV__Code, sizeof(struct SOAP_ENV__Code), 0, NULL, NULL, NULL); + a = (struct SOAP_ENV__Code *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_SOAP_ENV__Code, sizeof(struct SOAP_ENV__Code), NULL, NULL, NULL, NULL); if (!a) return NULL; soap_default_SOAP_ENV__Code(soap, a); @@ -1001,7 +1040,7 @@ SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_in_SOAP_ENV__Code(struct soap for (;;) { soap->error = SOAP_TAG_MISMATCH; if (soap_flag_SOAP_ENV__Value && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG)) - if (soap_in__QName(soap, "SOAP-ENV:Value", &a->SOAP_ENV__Value, "")) + if (soap_in__QName(soap, "SOAP-ENV:Value", (char**)&a->SOAP_ENV__Value, "xsd:QName")) { soap_flag_SOAP_ENV__Value--; continue; } @@ -1021,17 +1060,36 @@ SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_in_SOAP_ENV__Code(struct soap return NULL; } else - { a = (struct SOAP_ENV__Code *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_SOAP_ENV__Code, 0, sizeof(struct SOAP_ENV__Code), 0, NULL); + { a = (struct SOAP_ENV__Code *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_SOAP_ENV__Code, SOAP_TYPE_SOAP_ENV__Code, sizeof(struct SOAP_ENV__Code), 0, soap_finsert, NULL); if (soap->body && soap_element_end_in(soap, tag)) return NULL; } return a; } +SOAP_FMAC1 struct SOAP_ENV__Code * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Code(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size) +{ + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Code(%p, %d, %s, %s)\n", soap, n, type?type:"", arrayType?arrayType:"")); + (void)type; (void)arrayType; /* appease -Wall -Werror */ + struct SOAP_ENV__Code *p; + size_t k = sizeof(struct SOAP_ENV__Code); + if (n < 0) + { p = SOAP_NEW(struct SOAP_ENV__Code); + } + else + { p = SOAP_NEW_ARRAY(struct SOAP_ENV__Code, n); + k *= n; + } + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated struct SOAP_ENV__Code location=%p n=%d\n", p, n)); + soap_link(soap, p, SOAP_TYPE_SOAP_ENV__Code, n, soap_fdelete); + if (size) + *size = k; + return p; +} + SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Code(struct soap *soap, const struct SOAP_ENV__Code *a, const char *tag, const char *type) { - register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_SOAP_ENV__Code); - if (soap_out_SOAP_ENV__Code(soap, tag?tag:"SOAP-ENV:Code", id, a, type)) + if (soap_out_SOAP_ENV__Code(soap, tag?tag:"SOAP-ENV:Code", -2, a, type)) return soap->error; return soap_putindependent(soap); } @@ -1044,36 +1102,6 @@ SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_get_SOAP_ENV__Code(struct soa return p; } -SOAP_FMAC1 struct SOAP_ENV__Code * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Code(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size) -{ - (void)type; (void)arrayType; /* appease -Wall -Werror */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Code(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:"")); - struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_SOAP_ENV__Code, n, soap_fdelete); - if (!cp) - return NULL; - if (n < 0) - { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Code); - if (size) - *size = sizeof(struct SOAP_ENV__Code); - } - else - { cp->ptr = (void*)SOAP_NEW_ARRAY(struct SOAP_ENV__Code, n); - if (size) - *size = n * sizeof(struct SOAP_ENV__Code); - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr)); - if (!cp->ptr) - soap->error = SOAP_EOM; - return (struct SOAP_ENV__Code*)cp->ptr; -} - -SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Code(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n) -{ - (void)soap; (void)tt; (void)st; (void)len; (void)n; /* appease -Wall -Werror */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Code %p -> %p\n", q, p)); - *(struct SOAP_ENV__Code*)p = *(struct SOAP_ENV__Code*)q; -} - #endif #ifndef WITH_NOGLOBAL @@ -1085,14 +1113,14 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Header(struct soap *soap, stru SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Header(struct soap *soap, const struct SOAP_ENV__Header *a) { -#ifndef WITH_NOIDREF (void)soap; (void)a; /* appease -Wall -Werror */ +#ifndef WITH_NOIDREF #endif } SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Header(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Header *a, const char *type) { - (void)soap; (void)tag; (void)id; (void)type; + (void)soap; (void)tag; (void)id; (void)a; (void)type; /* appease -Wall -Werror */ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_SOAP_ENV__Header), type)) return soap->error; return soap_element_end_out(soap, tag); @@ -1102,7 +1130,7 @@ SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_in_SOAP_ENV__Header(struct { if (soap_element_begin_in(soap, tag, 0, type)) return NULL; - a = (struct SOAP_ENV__Header *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_SOAP_ENV__Header, sizeof(struct SOAP_ENV__Header), 0, NULL, NULL, NULL); + a = (struct SOAP_ENV__Header *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_SOAP_ENV__Header, sizeof(struct SOAP_ENV__Header), NULL, NULL, NULL, NULL); if (!a) return NULL; soap_default_SOAP_ENV__Header(soap, a); @@ -1121,17 +1149,36 @@ SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_in_SOAP_ENV__Header(struct return NULL; } else - { a = (struct SOAP_ENV__Header *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_SOAP_ENV__Header, 0, sizeof(struct SOAP_ENV__Header), 0, NULL); + { a = (struct SOAP_ENV__Header *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_SOAP_ENV__Header, SOAP_TYPE_SOAP_ENV__Header, sizeof(struct SOAP_ENV__Header), 0, soap_finsert, NULL); if (soap->body && soap_element_end_in(soap, tag)) return NULL; } return a; } +SOAP_FMAC1 struct SOAP_ENV__Header * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Header(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size) +{ + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Header(%p, %d, %s, %s)\n", soap, n, type?type:"", arrayType?arrayType:"")); + (void)type; (void)arrayType; /* appease -Wall -Werror */ + struct SOAP_ENV__Header *p; + size_t k = sizeof(struct SOAP_ENV__Header); + if (n < 0) + { p = SOAP_NEW(struct SOAP_ENV__Header); + } + else + { p = SOAP_NEW_ARRAY(struct SOAP_ENV__Header, n); + k *= n; + } + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated struct SOAP_ENV__Header location=%p n=%d\n", p, n)); + soap_link(soap, p, SOAP_TYPE_SOAP_ENV__Header, n, soap_fdelete); + if (size) + *size = k; + return p; +} + SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Header(struct soap *soap, const struct SOAP_ENV__Header *a, const char *tag, const char *type) { - register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_SOAP_ENV__Header); - if (soap_out_SOAP_ENV__Header(soap, tag?tag:"SOAP-ENV:Header", id, a, type)) + if (soap_out_SOAP_ENV__Header(soap, tag?tag:"SOAP-ENV:Header", -2, a, type)) return soap->error; return soap_putindependent(soap); } @@ -1144,36 +1191,6 @@ SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_get_SOAP_ENV__Header(struct return p; } -SOAP_FMAC1 struct SOAP_ENV__Header * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Header(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size) -{ - (void)type; (void)arrayType; /* appease -Wall -Werror */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Header(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:"")); - struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_SOAP_ENV__Header, n, soap_fdelete); - if (!cp) - return NULL; - if (n < 0) - { cp->ptr = (void*)SOAP_NEW(struct SOAP_ENV__Header); - if (size) - *size = sizeof(struct SOAP_ENV__Header); - } - else - { cp->ptr = (void*)SOAP_NEW_ARRAY(struct SOAP_ENV__Header, n); - if (size) - *size = n * sizeof(struct SOAP_ENV__Header); - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr)); - if (!cp->ptr) - soap->error = SOAP_EOM; - return (struct SOAP_ENV__Header*)cp->ptr; -} - -SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Header(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n) -{ - (void)soap; (void)tt; (void)st; (void)len; (void)n; /* appease -Wall -Werror */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct SOAP_ENV__Header %p -> %p\n", q, p)); - *(struct SOAP_ENV__Header*)p = *(struct SOAP_ENV__Header*)q; -} - #endif SOAP_FMAC3 void SOAP_FMAC4 soap_default_ns1__executeCommand(struct soap *soap, struct ns1__executeCommand *a) @@ -1184,18 +1201,18 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_default_ns1__executeCommand(struct soap *soap, s SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_ns1__executeCommand(struct soap *soap, const struct ns1__executeCommand *a) { -#ifndef WITH_NOIDREF (void)soap; (void)a; /* appease -Wall -Werror */ - soap_serialize_string(soap, &a->command); +#ifndef WITH_NOIDREF + soap_serialize_string(soap, (char*const*)&a->command); #endif } SOAP_FMAC3 int SOAP_FMAC4 soap_out_ns1__executeCommand(struct soap *soap, const char *tag, int id, const struct ns1__executeCommand *a, const char *type) { - (void)soap; (void)tag; (void)id; (void)type; + (void)soap; (void)tag; (void)id; (void)a; (void)type; /* appease -Wall -Werror */ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_ns1__executeCommand), type)) return soap->error; - if (soap_out_string(soap, "command", -1, &a->command, "")) + if (soap_out_string(soap, "command", -1, (char*const*)&a->command, "")) return soap->error; return soap_element_end_out(soap, tag); } @@ -1205,7 +1222,7 @@ SOAP_FMAC3 struct ns1__executeCommand * SOAP_FMAC4 soap_in_ns1__executeCommand(s size_t soap_flag_command = 1; if (soap_element_begin_in(soap, tag, 0, type)) return NULL; - a = (struct ns1__executeCommand *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_ns1__executeCommand, sizeof(struct ns1__executeCommand), 0, NULL, NULL, NULL); + a = (struct ns1__executeCommand *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_ns1__executeCommand, sizeof(struct ns1__executeCommand), NULL, NULL, NULL, NULL); if (!a) return NULL; soap_default_ns1__executeCommand(soap, a); @@ -1214,7 +1231,7 @@ SOAP_FMAC3 struct ns1__executeCommand * SOAP_FMAC4 soap_in_ns1__executeCommand(s for (;;) { soap->error = SOAP_TAG_MISMATCH; if (soap_flag_command && (soap->error == SOAP_TAG_MISMATCH || soap->error == SOAP_NO_TAG)) - if (soap_in_string(soap, "command", &a->command, "xsd:string")) + if (soap_in_string(soap, "command", (char**)&a->command, "xsd:string")) { soap_flag_command--; continue; } @@ -1229,17 +1246,36 @@ SOAP_FMAC3 struct ns1__executeCommand * SOAP_FMAC4 soap_in_ns1__executeCommand(s return NULL; } else - { a = (struct ns1__executeCommand *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_ns1__executeCommand, 0, sizeof(struct ns1__executeCommand), 0, NULL); + { a = (struct ns1__executeCommand *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_ns1__executeCommand, SOAP_TYPE_ns1__executeCommand, sizeof(struct ns1__executeCommand), 0, soap_finsert, NULL); if (soap->body && soap_element_end_in(soap, tag)) return NULL; } return a; } +SOAP_FMAC1 struct ns1__executeCommand * SOAP_FMAC2 soap_instantiate_ns1__executeCommand(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size) +{ + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_ns1__executeCommand(%p, %d, %s, %s)\n", soap, n, type?type:"", arrayType?arrayType:"")); + (void)type; (void)arrayType; /* appease -Wall -Werror */ + struct ns1__executeCommand *p; + size_t k = sizeof(struct ns1__executeCommand); + if (n < 0) + { p = SOAP_NEW(struct ns1__executeCommand); + } + else + { p = SOAP_NEW_ARRAY(struct ns1__executeCommand, n); + k *= n; + } + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated struct ns1__executeCommand location=%p n=%d\n", p, n)); + soap_link(soap, p, SOAP_TYPE_ns1__executeCommand, n, soap_fdelete); + if (size) + *size = k; + return p; +} + SOAP_FMAC3 int SOAP_FMAC4 soap_put_ns1__executeCommand(struct soap *soap, const struct ns1__executeCommand *a, const char *tag, const char *type) { - register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_ns1__executeCommand); - if (soap_out_ns1__executeCommand(soap, tag?tag:"ns1:executeCommand", id, a, type)) + if (soap_out_ns1__executeCommand(soap, tag?tag:"ns1:executeCommand", -2, a, type)) return soap->error; return soap_putindependent(soap); } @@ -1252,36 +1288,6 @@ SOAP_FMAC3 struct ns1__executeCommand * SOAP_FMAC4 soap_get_ns1__executeCommand( return p; } -SOAP_FMAC1 struct ns1__executeCommand * SOAP_FMAC2 soap_instantiate_ns1__executeCommand(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size) -{ - (void)type; (void)arrayType; /* appease -Wall -Werror */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_ns1__executeCommand(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:"")); - struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_ns1__executeCommand, n, soap_fdelete); - if (!cp) - return NULL; - if (n < 0) - { cp->ptr = (void*)SOAP_NEW(struct ns1__executeCommand); - if (size) - *size = sizeof(struct ns1__executeCommand); - } - else - { cp->ptr = (void*)SOAP_NEW_ARRAY(struct ns1__executeCommand, n); - if (size) - *size = n * sizeof(struct ns1__executeCommand); - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr)); - if (!cp->ptr) - soap->error = SOAP_EOM; - return (struct ns1__executeCommand*)cp->ptr; -} - -SOAP_FMAC3 void SOAP_FMAC4 soap_copy_ns1__executeCommand(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n) -{ - (void)soap; (void)tt; (void)st; (void)len; (void)n; /* appease -Wall -Werror */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct ns1__executeCommand %p -> %p\n", q, p)); - *(struct ns1__executeCommand*)p = *(struct ns1__executeCommand*)q; -} - SOAP_FMAC3 void SOAP_FMAC4 soap_default_ns1__executeCommandResponse(struct soap *soap, struct ns1__executeCommandResponse *a) { (void)soap; (void)a; /* appease -Wall -Werror */ @@ -1290,15 +1296,15 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_default_ns1__executeCommandResponse(struct soap SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_ns1__executeCommandResponse(struct soap *soap, const struct ns1__executeCommandResponse *a) { -#ifndef WITH_NOIDREF (void)soap; (void)a; /* appease -Wall -Werror */ +#ifndef WITH_NOIDREF soap_serialize_PointerTostring(soap, &a->result); #endif } SOAP_FMAC3 int SOAP_FMAC4 soap_out_ns1__executeCommandResponse(struct soap *soap, const char *tag, int id, const struct ns1__executeCommandResponse *a, const char *type) { - (void)soap; (void)tag; (void)id; (void)type; + (void)soap; (void)tag; (void)id; (void)a; (void)type; /* appease -Wall -Werror */ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_ns1__executeCommandResponse), type)) return soap->error; if (soap_out_PointerTostring(soap, "result", -1, &a->result, "")) @@ -1311,7 +1317,7 @@ SOAP_FMAC3 struct ns1__executeCommandResponse * SOAP_FMAC4 soap_in_ns1__executeC size_t soap_flag_result = 1; if (soap_element_begin_in(soap, tag, 0, type)) return NULL; - a = (struct ns1__executeCommandResponse *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_ns1__executeCommandResponse, sizeof(struct ns1__executeCommandResponse), 0, NULL, NULL, NULL); + a = (struct ns1__executeCommandResponse *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_ns1__executeCommandResponse, sizeof(struct ns1__executeCommandResponse), NULL, NULL, NULL, NULL); if (!a) return NULL; soap_default_ns1__executeCommandResponse(soap, a); @@ -1335,17 +1341,36 @@ SOAP_FMAC3 struct ns1__executeCommandResponse * SOAP_FMAC4 soap_in_ns1__executeC return NULL; } else - { a = (struct ns1__executeCommandResponse *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_ns1__executeCommandResponse, 0, sizeof(struct ns1__executeCommandResponse), 0, NULL); + { a = (struct ns1__executeCommandResponse *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_ns1__executeCommandResponse, SOAP_TYPE_ns1__executeCommandResponse, sizeof(struct ns1__executeCommandResponse), 0, soap_finsert, NULL); if (soap->body && soap_element_end_in(soap, tag)) return NULL; } return a; } +SOAP_FMAC1 struct ns1__executeCommandResponse * SOAP_FMAC2 soap_instantiate_ns1__executeCommandResponse(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size) +{ + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_ns1__executeCommandResponse(%p, %d, %s, %s)\n", soap, n, type?type:"", arrayType?arrayType:"")); + (void)type; (void)arrayType; /* appease -Wall -Werror */ + struct ns1__executeCommandResponse *p; + size_t k = sizeof(struct ns1__executeCommandResponse); + if (n < 0) + { p = SOAP_NEW(struct ns1__executeCommandResponse); + } + else + { p = SOAP_NEW_ARRAY(struct ns1__executeCommandResponse, n); + k *= n; + } + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated struct ns1__executeCommandResponse location=%p n=%d\n", p, n)); + soap_link(soap, p, SOAP_TYPE_ns1__executeCommandResponse, n, soap_fdelete); + if (size) + *size = k; + return p; +} + SOAP_FMAC3 int SOAP_FMAC4 soap_put_ns1__executeCommandResponse(struct soap *soap, const struct ns1__executeCommandResponse *a, const char *tag, const char *type) { - register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_ns1__executeCommandResponse); - if (soap_out_ns1__executeCommandResponse(soap, tag?tag:"ns1:executeCommandResponse", id, a, type)) + if (soap_out_ns1__executeCommandResponse(soap, tag?tag:"ns1:executeCommandResponse", -2, a, type)) return soap->error; return soap_putindependent(soap); } @@ -1358,40 +1383,11 @@ SOAP_FMAC3 struct ns1__executeCommandResponse * SOAP_FMAC4 soap_get_ns1__execute return p; } -SOAP_FMAC1 struct ns1__executeCommandResponse * SOAP_FMAC2 soap_instantiate_ns1__executeCommandResponse(struct soap *soap, int n, const char *type, const char *arrayType, size_t *size) -{ - (void)type; (void)arrayType; /* appease -Wall -Werror */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_ns1__executeCommandResponse(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:"")); - struct soap_clist *cp = soap_link(soap, NULL, SOAP_TYPE_ns1__executeCommandResponse, n, soap_fdelete); - if (!cp) - return NULL; - if (n < 0) - { cp->ptr = (void*)SOAP_NEW(struct ns1__executeCommandResponse); - if (size) - *size = sizeof(struct ns1__executeCommandResponse); - } - else - { cp->ptr = (void*)SOAP_NEW_ARRAY(struct ns1__executeCommandResponse, n); - if (size) - *size = n * sizeof(struct ns1__executeCommandResponse); - } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Instantiated location=%p\n", cp->ptr)); - if (!cp->ptr) - soap->error = SOAP_EOM; - return (struct ns1__executeCommandResponse*)cp->ptr; -} - -SOAP_FMAC3 void SOAP_FMAC4 soap_copy_ns1__executeCommandResponse(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n) -{ - (void)soap; (void)tt; (void)st; (void)len; (void)n; /* appease -Wall -Werror */ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying struct ns1__executeCommandResponse %p -> %p\n", q, p)); - *(struct ns1__executeCommandResponse*)p = *(struct ns1__executeCommandResponse*)q; -} - #ifndef WITH_NOGLOBAL SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason *const*a) { + (void)soap; (void)a; /* appease -Wall -Werror */ #ifndef WITH_NOIDREF if (!soap_reference(soap, *a, SOAP_TYPE_SOAP_ENV__Reason)) soap_serialize_SOAP_ENV__Reason(soap, *a); @@ -1400,7 +1396,7 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Reason(struct soap SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Reason(struct soap *soap, const char *tag, int id, struct SOAP_ENV__Reason *const*a, const char *type) { - id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_SOAP_ENV__Reason); + id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_SOAP_ENV__Reason, NULL); if (id < 0) return soap->error; return soap_out_SOAP_ENV__Reason(soap, tag, id, *a, type); @@ -1408,6 +1404,7 @@ SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Reason(struct soap *soap, SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Reason(struct soap *soap, const char *tag, struct SOAP_ENV__Reason **a, const char *type) { + (void)type; /* appease -Wall -Werror */ if (soap_element_begin_in(soap, tag, 1, NULL)) return NULL; if (!a) @@ -1420,7 +1417,7 @@ SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Reas return NULL; } else - { a = (struct SOAP_ENV__Reason **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_SOAP_ENV__Reason, sizeof(struct SOAP_ENV__Reason), 0); + { a = (struct SOAP_ENV__Reason **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_SOAP_ENV__Reason, sizeof(struct SOAP_ENV__Reason), 0, NULL); if (soap->body && soap_element_end_in(soap, tag)) return NULL; } @@ -1429,8 +1426,7 @@ SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Reas SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason *const*a, const char *tag, const char *type) { - register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_PointerToSOAP_ENV__Reason); - if (soap_out_PointerToSOAP_ENV__Reason(soap, tag?tag:"SOAP-ENV:Reason", id, a, type)) + if (soap_out_PointerToSOAP_ENV__Reason(soap, tag?tag:"SOAP-ENV:Reason", -2, a, type)) return soap->error; return soap_putindependent(soap); } @@ -1449,6 +1445,7 @@ SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Rea SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail *const*a) { + (void)soap; (void)a; /* appease -Wall -Werror */ #ifndef WITH_NOIDREF if (!soap_reference(soap, *a, SOAP_TYPE_SOAP_ENV__Detail)) soap_serialize_SOAP_ENV__Detail(soap, *a); @@ -1457,7 +1454,7 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Detail(struct soap SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Detail(struct soap *soap, const char *tag, int id, struct SOAP_ENV__Detail *const*a, const char *type) { - id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_SOAP_ENV__Detail); + id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_SOAP_ENV__Detail, NULL); if (id < 0) return soap->error; return soap_out_SOAP_ENV__Detail(soap, tag, id, *a, type); @@ -1465,6 +1462,7 @@ SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Detail(struct soap *soap, SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Detail(struct soap *soap, const char *tag, struct SOAP_ENV__Detail **a, const char *type) { + (void)type; /* appease -Wall -Werror */ if (soap_element_begin_in(soap, tag, 1, NULL)) return NULL; if (!a) @@ -1477,7 +1475,7 @@ SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Deta return NULL; } else - { a = (struct SOAP_ENV__Detail **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_SOAP_ENV__Detail, sizeof(struct SOAP_ENV__Detail), 0); + { a = (struct SOAP_ENV__Detail **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_SOAP_ENV__Detail, sizeof(struct SOAP_ENV__Detail), 0, NULL); if (soap->body && soap_element_end_in(soap, tag)) return NULL; } @@ -1486,8 +1484,7 @@ SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Deta SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail *const*a, const char *tag, const char *type) { - register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_PointerToSOAP_ENV__Detail); - if (soap_out_PointerToSOAP_ENV__Detail(soap, tag?tag:"SOAP-ENV:Detail", id, a, type)) + if (soap_out_PointerToSOAP_ENV__Detail(soap, tag?tag:"SOAP-ENV:Detail", -2, a, type)) return soap->error; return soap_putindependent(soap); } @@ -1506,6 +1503,7 @@ SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Det SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code *const*a) { + (void)soap; (void)a; /* appease -Wall -Werror */ #ifndef WITH_NOIDREF if (!soap_reference(soap, *a, SOAP_TYPE_SOAP_ENV__Code)) soap_serialize_SOAP_ENV__Code(soap, *a); @@ -1514,14 +1512,18 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Code(struct soap *s SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Code(struct soap *soap, const char *tag, int id, struct SOAP_ENV__Code *const*a, const char *type) { - id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_SOAP_ENV__Code); + char *mark; + id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_SOAP_ENV__Code, &mark); if (id < 0) return soap->error; - return soap_out_SOAP_ENV__Code(soap, tag, id, *a, type); + soap_out_SOAP_ENV__Code(soap, tag, id, *a, type); + soap_unmark(soap, mark); + return soap->error; } SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Code(struct soap *soap, const char *tag, struct SOAP_ENV__Code **a, const char *type) { + (void)type; /* appease -Wall -Werror */ if (soap_element_begin_in(soap, tag, 1, NULL)) return NULL; if (!a) @@ -1534,7 +1536,7 @@ SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Code(s return NULL; } else - { a = (struct SOAP_ENV__Code **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_SOAP_ENV__Code, sizeof(struct SOAP_ENV__Code), 0); + { a = (struct SOAP_ENV__Code **)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_SOAP_ENV__Code, sizeof(struct SOAP_ENV__Code), 0, NULL); if (soap->body && soap_element_end_in(soap, tag)) return NULL; } @@ -1543,8 +1545,7 @@ SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Code(s SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code *const*a, const char *tag, const char *type) { - register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_PointerToSOAP_ENV__Code); - if (soap_out_PointerToSOAP_ENV__Code(soap, tag?tag:"SOAP-ENV:Code", id, a, type)) + if (soap_out_PointerToSOAP_ENV__Code(soap, tag?tag:"SOAP-ENV:Code", -2, a, type)) return soap->error; return soap_putindependent(soap); } @@ -1561,6 +1562,7 @@ SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Code( SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTostring(struct soap *soap, char **const*a) { + (void)soap; (void)a; /* appease -Wall -Werror */ #ifndef WITH_NOIDREF if (!soap_reference(soap, *a, SOAP_TYPE_string)) soap_serialize_string(soap, *a); @@ -1569,7 +1571,7 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTostring(struct soap *soap, cha SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTostring(struct soap *soap, const char *tag, int id, char **const*a, const char *type) { - id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_string); + id = soap_element_id(soap, tag, id, *a, NULL, 0, type, SOAP_TYPE_string, NULL); if (id < 0) return soap->error; return soap_out_string(soap, tag, id, *a, type); @@ -1577,6 +1579,7 @@ SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTostring(struct soap *soap, const char SOAP_FMAC3 char *** SOAP_FMAC4 soap_in_PointerTostring(struct soap *soap, const char *tag, char ***a, const char *type) { + (void)type; /* appease -Wall -Werror */ if (soap_element_begin_in(soap, tag, 1, NULL)) return NULL; if (!a) @@ -1589,7 +1592,7 @@ SOAP_FMAC3 char *** SOAP_FMAC4 soap_in_PointerTostring(struct soap *soap, const return NULL; } else - { a = (char ***)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_string, sizeof(char *), 1); + { a = (char ***)soap_id_lookup(soap, soap->href, (void**)a, SOAP_TYPE_string, sizeof(char *), 1, NULL); if (soap->body && soap_element_end_in(soap, tag)) return NULL; } @@ -1598,8 +1601,7 @@ SOAP_FMAC3 char *** SOAP_FMAC4 soap_in_PointerTostring(struct soap *soap, const SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTostring(struct soap *soap, char **const*a, const char *tag, const char *type) { - register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_PointerTostring); - if (soap_out_PointerTostring(soap, tag?tag:"byte", id, a, type)) + if (soap_out_PointerTostring(soap, tag?tag:"string", -2, a, type)) return soap->error; return soap_putindependent(soap); } @@ -1612,8 +1614,19 @@ SOAP_FMAC3 char *** SOAP_FMAC4 soap_get_PointerTostring(struct soap *soap, char return p; } +SOAP_FMAC3 void SOAP_FMAC4 soap_default__QName(struct soap *soap, char **a) +{ + (void)soap; /* appease -Wall -Werror */ +#ifdef SOAP_DEFAULT__QName + *a = SOAP_DEFAULT__QName; +#else + *a = (char *)0; +#endif +} + SOAP_FMAC3 void SOAP_FMAC4 soap_serialize__QName(struct soap *soap, char *const*a) { + (void)soap; (void)a; /* appease -Wall -Werror */ #ifndef WITH_NOIDREF soap_reference(soap, *a, SOAP_TYPE__QName); #endif @@ -1625,15 +1638,14 @@ SOAP_FMAC3 int SOAP_FMAC4 soap_out__QName(struct soap *soap, const char *tag, in } SOAP_FMAC3 char * * SOAP_FMAC4 soap_in__QName(struct soap *soap, const char *tag, char **a, const char *type) -{ char **p; - p = soap_instring(soap, tag, a, type, SOAP_TYPE__QName, 2, 0, -1); - return p; +{ + a = soap_instring(soap, tag, a, type, SOAP_TYPE__QName, 2, 0, -1, NULL); + return a; } SOAP_FMAC3 int SOAP_FMAC4 soap_put__QName(struct soap *soap, char *const*a, const char *tag, const char *type) { - register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE__QName); - if (soap_out__QName(soap, tag?tag:"byte", id, a, type)) + if (soap_out__QName(soap, tag?tag:"QName", -2, a, type)) return soap->error; return soap_putindependent(soap); } @@ -1658,6 +1670,7 @@ SOAP_FMAC3 void SOAP_FMAC4 soap_default_string(struct soap *soap, char **a) SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_string(struct soap *soap, char *const*a) { + (void)soap; (void)a; /* appease -Wall -Werror */ #ifndef WITH_NOIDREF soap_reference(soap, *a, SOAP_TYPE_string); #endif @@ -1669,15 +1682,14 @@ SOAP_FMAC3 int SOAP_FMAC4 soap_out_string(struct soap *soap, const char *tag, in } SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_string(struct soap *soap, const char *tag, char **a, const char *type) -{ char **p; - p = soap_instring(soap, tag, a, type, SOAP_TYPE_string, 1, 0, -1); - return p; +{ + a = soap_instring(soap, tag, a, type, SOAP_TYPE_string, 1, 0, -1, NULL); + return a; } SOAP_FMAC3 int SOAP_FMAC4 soap_put_string(struct soap *soap, char *const*a, const char *tag, const char *type) { - register int id = soap_embed(soap, (void*)a, NULL, 0, tag, SOAP_TYPE_string); - if (soap_out_string(soap, tag?tag:"byte", id, a, type)) + if (soap_out_string(soap, tag?tag:"string", -2, a, type)) return soap->error; return soap_putindependent(soap); } diff --git a/dep/gsoap/soapH.h b/dep/gsoap/soapH.h index a73b369fe90..f3def95426a 100644 --- a/dep/gsoap/soapH.h +++ b/dep/gsoap/soapH.h @@ -1,11 +1,14 @@ /* soapH.h - Generated by gSOAP 2.8.17r from gsoap.stub + Generated by gSOAP 2.8.33 for gsoap.stub -Copyright(C) 2000-2013, Robert van Engelen, Genivia Inc. All Rights Reserved. -The generated code is released under one of the following licenses: -GPL or Genivia's license for commercial use. +gSOAP XML Web services tools +Copyright (C) 2000-2016, Robert van Engelen, Genivia Inc. All Rights Reserved. +The soapcpp2 tool and its generated software are released under the GPL. This program is released under the GPL with the additional exemption that compiling, linking, and/or using OpenSSL is allowed. +-------------------------------------------------------------------------------- +A commercial use license is available from Genivia Inc., contact@genivia.com +-------------------------------------------------------------------------------- */ #ifndef soapH_H @@ -37,425 +40,635 @@ SOAP_FMAC3 int SOAP_FMAC4 soap_putelement(struct soap*, const void*, const char* SOAP_FMAC3 int SOAP_FMAC4 soap_ignore_element(struct soap*); SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultcode(struct soap *soap); - SOAP_FMAC3 void * SOAP_FMAC4 soap_instantiate(struct soap*, int, const char*, const char*, size_t*); SOAP_FMAC3 int SOAP_FMAC4 soap_fdelete(struct soap_clist*); -SOAP_FMAC3 void* SOAP_FMAC4 soap_class_id_enter(struct soap*, const char*, void*, int, size_t, const char*, const char*); +SOAP_FMAC3 int SOAP_FMAC4 soap_fbase(int, int); +SOAP_FMAC3 void SOAP_FMAC4 soap_finsert(struct soap*, int, int, void*, size_t, const void*, void**); -#ifndef SOAP_TYPE_byte -#define SOAP_TYPE_byte (3) -#endif +#ifndef SOAP_TYPE_byte_DEFINED +#define SOAP_TYPE_byte_DEFINED SOAP_FMAC3 void SOAP_FMAC4 soap_default_byte(struct soap*, char *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_byte(struct soap*, const char*, int, const char *, const char*); SOAP_FMAC3 char * SOAP_FMAC4 soap_in_byte(struct soap*, const char*, char *, const char*); - SOAP_FMAC3 int SOAP_FMAC4 soap_put_byte(struct soap*, const char *, const char*, const char*); -#ifndef soap_write_byte -#define soap_write_byte(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || (soap_serialize_byte(soap, data),0) || soap_put_byte(soap, data, "byte", NULL) || soap_end_send(soap), (soap)->error ) -#endif - +inline int soap_write_byte(struct soap *soap, char const*p) +{ + soap_free_temp(soap); + if (p) + { if (soap_begin_send(soap) || soap_put_byte(soap, p, "byte", "") || soap_end_send(soap)) + return soap->error; + } + return SOAP_OK; +} SOAP_FMAC3 char * SOAP_FMAC4 soap_get_byte(struct soap*, char *, const char*, const char*); -#ifndef soap_read_byte -#define soap_read_byte(soap, data) ( soap_begin_recv(soap) || !soap_get_byte(soap, data, NULL, NULL) || soap_end_recv(soap), (soap)->error ) +inline int soap_read_byte(struct soap *soap, char *p) +{ + if (p) + { if (soap_begin_recv(soap) || soap_get_byte(soap, p, NULL, NULL) == NULL || soap_end_recv(soap)) + return soap->error; + } + return SOAP_OK; +} #endif - -#ifndef SOAP_TYPE_int -#define SOAP_TYPE_int (1) -#endif +#ifndef SOAP_TYPE_int_DEFINED +#define SOAP_TYPE_int_DEFINED SOAP_FMAC3 void SOAP_FMAC4 soap_default_int(struct soap*, int *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_int(struct soap*, const char*, int, const int *, const char*); SOAP_FMAC3 int * SOAP_FMAC4 soap_in_int(struct soap*, const char*, int *, const char*); - SOAP_FMAC3 int SOAP_FMAC4 soap_put_int(struct soap*, const int *, const char*, const char*); -#ifndef soap_write_int -#define soap_write_int(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || (soap_serialize_int(soap, data),0) || soap_put_int(soap, data, "int", NULL) || soap_end_send(soap), (soap)->error ) -#endif - +inline int soap_write_int(struct soap *soap, int const*p) +{ + soap_free_temp(soap); + if (p) + { if (soap_begin_send(soap) || soap_put_int(soap, p, "int", "") || soap_end_send(soap)) + return soap->error; + } + return SOAP_OK; +} SOAP_FMAC3 int * SOAP_FMAC4 soap_get_int(struct soap*, int *, const char*, const char*); -#ifndef soap_read_int -#define soap_read_int(soap, data) ( soap_begin_recv(soap) || !soap_get_int(soap, data, NULL, NULL) || soap_end_recv(soap), (soap)->error ) +inline int soap_read_int(struct soap *soap, int *p) +{ + if (p) + { if (soap_begin_recv(soap) || soap_get_int(soap, p, NULL, NULL) == NULL || soap_end_recv(soap)) + return soap->error; + } + return SOAP_OK; +} #endif - #ifndef WITH_NOGLOBAL -#ifndef SOAP_TYPE_SOAP_ENV__Fault -#define SOAP_TYPE_SOAP_ENV__Fault (18) -#endif +#ifndef SOAP_TYPE_SOAP_ENV__Fault_DEFINED +#define SOAP_TYPE_SOAP_ENV__Fault_DEFINED SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Fault(struct soap*, struct SOAP_ENV__Fault *); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Fault(struct soap*, const struct SOAP_ENV__Fault *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Fault(struct soap*, const char*, int, const struct SOAP_ENV__Fault *, const char*); SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_in_SOAP_ENV__Fault(struct soap*, const char*, struct SOAP_ENV__Fault *, const char*); - -SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Fault(struct soap*, const struct SOAP_ENV__Fault *, const char*, const char*); - -#ifndef soap_write_SOAP_ENV__Fault -#define soap_write_SOAP_ENV__Fault(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Fault(soap, data),0) || soap_put_SOAP_ENV__Fault(soap, data, "SOAP-ENV:Fault", NULL) || soap_end_send(soap), (soap)->error ) -#endif - -SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_get_SOAP_ENV__Fault(struct soap*, struct SOAP_ENV__Fault *, const char*, const char*); - -#ifndef soap_read_SOAP_ENV__Fault -#define soap_read_SOAP_ENV__Fault(soap, data) ( soap_begin_recv(soap) || !soap_get_SOAP_ENV__Fault(soap, data, NULL, NULL) || soap_end_recv(soap), (soap)->error ) -#endif - SOAP_FMAC1 struct SOAP_ENV__Fault * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Fault(struct soap*, int, const char*, const char*, size_t*); -inline struct SOAP_ENV__Fault * soap_new_SOAP_ENV__Fault(struct soap *soap, int n = -1) { return soap_instantiate_SOAP_ENV__Fault(soap, n, NULL, NULL, NULL); } +inline struct SOAP_ENV__Fault * soap_new_SOAP_ENV__Fault(struct soap *soap, int n = -1) +{ + return soap_instantiate_SOAP_ENV__Fault(soap, n, NULL, NULL, NULL); +} -inline struct SOAP_ENV__Fault * soap_new_req_SOAP_ENV__Fault(struct soap *soap) { struct SOAP_ENV__Fault *_p = soap_instantiate_SOAP_ENV__Fault(soap, -1, NULL, NULL, NULL); if (_p) { soap_default_SOAP_ENV__Fault(soap, _p); } return _p; } +inline struct SOAP_ENV__Fault * soap_new_req_SOAP_ENV__Fault( + struct soap *soap) +{ + struct SOAP_ENV__Fault *_p = soap_new_SOAP_ENV__Fault(soap); + if (_p) + { soap_default_SOAP_ENV__Fault(soap, _p); + } + return _p; +} -inline struct SOAP_ENV__Fault * soap_new_set_SOAP_ENV__Fault(struct soap *soap, char *faultcode, char *faultstring, char *faultactor, struct SOAP_ENV__Detail *detail, struct SOAP_ENV__Code *SOAP_ENV__Code, struct SOAP_ENV__Reason *SOAP_ENV__Reason, char *SOAP_ENV__Node, char *SOAP_ENV__Role, struct SOAP_ENV__Detail *SOAP_ENV__Detail) { struct SOAP_ENV__Fault *_p = soap_instantiate_SOAP_ENV__Fault(soap, -1, NULL, NULL, NULL); if (_p) { soap_default_SOAP_ENV__Fault(soap, _p); _p->faultcode = faultcode; _p->faultstring = faultstring; _p->faultactor = faultactor; _p->detail = detail; _p->SOAP_ENV__Code = SOAP_ENV__Code; _p->SOAP_ENV__Reason = SOAP_ENV__Reason; _p->SOAP_ENV__Node = SOAP_ENV__Node; _p->SOAP_ENV__Role = SOAP_ENV__Role; _p->SOAP_ENV__Detail = SOAP_ENV__Detail; } return _p; } +inline struct SOAP_ENV__Fault * soap_new_set_SOAP_ENV__Fault( + struct soap *soap, + char *faultcode, + char *faultstring, + char *faultactor, + struct SOAP_ENV__Detail *detail, + struct SOAP_ENV__Code *SOAP_ENV__Code, + struct SOAP_ENV__Reason *SOAP_ENV__Reason, + char *SOAP_ENV__Node, + char *SOAP_ENV__Role, + struct SOAP_ENV__Detail *SOAP_ENV__Detail) +{ + struct SOAP_ENV__Fault *_p = soap_new_SOAP_ENV__Fault(soap); + if (_p) + { soap_default_SOAP_ENV__Fault(soap, _p); + _p->faultcode = faultcode; + _p->faultstring = faultstring; + _p->faultactor = faultactor; + _p->detail = detail; + _p->SOAP_ENV__Code = SOAP_ENV__Code; + _p->SOAP_ENV__Reason = SOAP_ENV__Reason; + _p->SOAP_ENV__Node = SOAP_ENV__Node; + _p->SOAP_ENV__Role = SOAP_ENV__Role; + _p->SOAP_ENV__Detail = SOAP_ENV__Detail; + } + return _p; +} +SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Fault(struct soap*, const struct SOAP_ENV__Fault *, const char*, const char*); -inline void soap_delete_SOAP_ENV__Fault(struct soap *soap, struct SOAP_ENV__Fault *p) { soap_delete(soap, p); } +inline int soap_write_SOAP_ENV__Fault(struct soap *soap, struct SOAP_ENV__Fault const*p) +{ + soap_free_temp(soap); + if (p) + { if (soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Fault(soap, p), 0) || soap_put_SOAP_ENV__Fault(soap, p, "SOAP-ENV:Fault", "") || soap_end_send(soap)) + return soap->error; + } + return SOAP_OK; +} +SOAP_FMAC3 struct SOAP_ENV__Fault * SOAP_FMAC4 soap_get_SOAP_ENV__Fault(struct soap*, struct SOAP_ENV__Fault *, const char*, const char*); -SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Fault(struct soap*, int, int, void*, size_t, const void*, size_t); +inline int soap_read_SOAP_ENV__Fault(struct soap *soap, struct SOAP_ENV__Fault *p) +{ + if (p) + { soap_default_SOAP_ENV__Fault(soap, p); + if (soap_begin_recv(soap) || soap_get_SOAP_ENV__Fault(soap, p, NULL, NULL) == NULL || soap_end_recv(soap)) + return soap->error; + } + return SOAP_OK; +} +#endif #endif #ifndef WITH_NOGLOBAL -#ifndef SOAP_TYPE_SOAP_ENV__Reason -#define SOAP_TYPE_SOAP_ENV__Reason (17) -#endif +#ifndef SOAP_TYPE_SOAP_ENV__Reason_DEFINED +#define SOAP_TYPE_SOAP_ENV__Reason_DEFINED SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Reason(struct soap*, const struct SOAP_ENV__Reason *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Reason(struct soap*, const char*, int, const struct SOAP_ENV__Reason *, const char*); SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_in_SOAP_ENV__Reason(struct soap*, const char*, struct SOAP_ENV__Reason *, const char*); - -SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Reason(struct soap*, const struct SOAP_ENV__Reason *, const char*, const char*); - -#ifndef soap_write_SOAP_ENV__Reason -#define soap_write_SOAP_ENV__Reason(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Reason(soap, data),0) || soap_put_SOAP_ENV__Reason(soap, data, "SOAP-ENV:Reason", NULL) || soap_end_send(soap), (soap)->error ) -#endif - -SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_get_SOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *, const char*, const char*); - -#ifndef soap_read_SOAP_ENV__Reason -#define soap_read_SOAP_ENV__Reason(soap, data) ( soap_begin_recv(soap) || !soap_get_SOAP_ENV__Reason(soap, data, NULL, NULL) || soap_end_recv(soap), (soap)->error ) -#endif - SOAP_FMAC1 struct SOAP_ENV__Reason * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Reason(struct soap*, int, const char*, const char*, size_t*); -inline struct SOAP_ENV__Reason * soap_new_SOAP_ENV__Reason(struct soap *soap, int n = -1) { return soap_instantiate_SOAP_ENV__Reason(soap, n, NULL, NULL, NULL); } +inline struct SOAP_ENV__Reason * soap_new_SOAP_ENV__Reason(struct soap *soap, int n = -1) +{ + return soap_instantiate_SOAP_ENV__Reason(soap, n, NULL, NULL, NULL); +} -inline struct SOAP_ENV__Reason * soap_new_req_SOAP_ENV__Reason(struct soap *soap) { struct SOAP_ENV__Reason *_p = soap_instantiate_SOAP_ENV__Reason(soap, -1, NULL, NULL, NULL); if (_p) { soap_default_SOAP_ENV__Reason(soap, _p); } return _p; } +inline struct SOAP_ENV__Reason * soap_new_req_SOAP_ENV__Reason( + struct soap *soap) +{ + struct SOAP_ENV__Reason *_p = soap_new_SOAP_ENV__Reason(soap); + if (_p) + { soap_default_SOAP_ENV__Reason(soap, _p); + } + return _p; +} -inline struct SOAP_ENV__Reason * soap_new_set_SOAP_ENV__Reason(struct soap *soap, char *SOAP_ENV__Text) { struct SOAP_ENV__Reason *_p = soap_instantiate_SOAP_ENV__Reason(soap, -1, NULL, NULL, NULL); if (_p) { soap_default_SOAP_ENV__Reason(soap, _p); _p->SOAP_ENV__Text = SOAP_ENV__Text; } return _p; } +inline struct SOAP_ENV__Reason * soap_new_set_SOAP_ENV__Reason( + struct soap *soap, + char *SOAP_ENV__Text) +{ + struct SOAP_ENV__Reason *_p = soap_new_SOAP_ENV__Reason(soap); + if (_p) + { soap_default_SOAP_ENV__Reason(soap, _p); + _p->SOAP_ENV__Text = SOAP_ENV__Text; + } + return _p; +} +SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Reason(struct soap*, const struct SOAP_ENV__Reason *, const char*, const char*); -inline void soap_delete_SOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason *p) { soap_delete(soap, p); } +inline int soap_write_SOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason const*p) +{ + soap_free_temp(soap); + if (p) + { if (soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Reason(soap, p), 0) || soap_put_SOAP_ENV__Reason(soap, p, "SOAP-ENV:Reason", "") || soap_end_send(soap)) + return soap->error; + } + return SOAP_OK; +} +SOAP_FMAC3 struct SOAP_ENV__Reason * SOAP_FMAC4 soap_get_SOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *, const char*, const char*); -SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Reason(struct soap*, int, int, void*, size_t, const void*, size_t); +inline int soap_read_SOAP_ENV__Reason(struct soap *soap, struct SOAP_ENV__Reason *p) +{ + if (p) + { soap_default_SOAP_ENV__Reason(soap, p); + if (soap_begin_recv(soap) || soap_get_SOAP_ENV__Reason(soap, p, NULL, NULL) == NULL || soap_end_recv(soap)) + return soap->error; + } + return SOAP_OK; +} +#endif #endif #ifndef WITH_NOGLOBAL -#ifndef SOAP_TYPE_SOAP_ENV__Detail -#define SOAP_TYPE_SOAP_ENV__Detail (14) -#endif +#ifndef SOAP_TYPE_SOAP_ENV__Detail_DEFINED +#define SOAP_TYPE_SOAP_ENV__Detail_DEFINED SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Detail(struct soap*, const struct SOAP_ENV__Detail *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Detail(struct soap*, const char*, int, const struct SOAP_ENV__Detail *, const char*); SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_in_SOAP_ENV__Detail(struct soap*, const char*, struct SOAP_ENV__Detail *, const char*); - -SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Detail(struct soap*, const struct SOAP_ENV__Detail *, const char*, const char*); - -#ifndef soap_write_SOAP_ENV__Detail -#define soap_write_SOAP_ENV__Detail(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Detail(soap, data),0) || soap_put_SOAP_ENV__Detail(soap, data, "SOAP-ENV:Detail", NULL) || soap_end_send(soap), (soap)->error ) -#endif - -SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_get_SOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *, const char*, const char*); - -#ifndef soap_read_SOAP_ENV__Detail -#define soap_read_SOAP_ENV__Detail(soap, data) ( soap_begin_recv(soap) || !soap_get_SOAP_ENV__Detail(soap, data, NULL, NULL) || soap_end_recv(soap), (soap)->error ) -#endif - SOAP_FMAC1 struct SOAP_ENV__Detail * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Detail(struct soap*, int, const char*, const char*, size_t*); -inline struct SOAP_ENV__Detail * soap_new_SOAP_ENV__Detail(struct soap *soap, int n = -1) { return soap_instantiate_SOAP_ENV__Detail(soap, n, NULL, NULL, NULL); } +inline struct SOAP_ENV__Detail * soap_new_SOAP_ENV__Detail(struct soap *soap, int n = -1) +{ + return soap_instantiate_SOAP_ENV__Detail(soap, n, NULL, NULL, NULL); +} -inline struct SOAP_ENV__Detail * soap_new_req_SOAP_ENV__Detail(struct soap *soap, int __type, void *fault) { struct SOAP_ENV__Detail *_p = soap_instantiate_SOAP_ENV__Detail(soap, -1, NULL, NULL, NULL); if (_p) { soap_default_SOAP_ENV__Detail(soap, _p); _p->__type = __type; _p->fault = fault; } return _p; } +inline struct SOAP_ENV__Detail * soap_new_req_SOAP_ENV__Detail( + struct soap *soap, + int __type, + void *fault) +{ + struct SOAP_ENV__Detail *_p = soap_new_SOAP_ENV__Detail(soap); + if (_p) + { soap_default_SOAP_ENV__Detail(soap, _p); + _p->__type = __type; + _p->fault = fault; + } + return _p; +} -inline struct SOAP_ENV__Detail * soap_new_set_SOAP_ENV__Detail(struct soap *soap, char *__any, int __type, void *fault) { struct SOAP_ENV__Detail *_p = soap_instantiate_SOAP_ENV__Detail(soap, -1, NULL, NULL, NULL); if (_p) { soap_default_SOAP_ENV__Detail(soap, _p); _p->__any = __any; _p->__type = __type; _p->fault = fault; } return _p; } +inline struct SOAP_ENV__Detail * soap_new_set_SOAP_ENV__Detail( + struct soap *soap, + char *__any, + int __type, + void *fault) +{ + struct SOAP_ENV__Detail *_p = soap_new_SOAP_ENV__Detail(soap); + if (_p) + { soap_default_SOAP_ENV__Detail(soap, _p); + _p->__any = __any; + _p->__type = __type; + _p->fault = fault; + } + return _p; +} +SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Detail(struct soap*, const struct SOAP_ENV__Detail *, const char*, const char*); -inline void soap_delete_SOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail *p) { soap_delete(soap, p); } +inline int soap_write_SOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail const*p) +{ + soap_free_temp(soap); + if (p) + { if (soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Detail(soap, p), 0) || soap_put_SOAP_ENV__Detail(soap, p, "SOAP-ENV:Detail", "") || soap_end_send(soap)) + return soap->error; + } + return SOAP_OK; +} +SOAP_FMAC3 struct SOAP_ENV__Detail * SOAP_FMAC4 soap_get_SOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *, const char*, const char*); -SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Detail(struct soap*, int, int, void*, size_t, const void*, size_t); +inline int soap_read_SOAP_ENV__Detail(struct soap *soap, struct SOAP_ENV__Detail *p) +{ + if (p) + { soap_default_SOAP_ENV__Detail(soap, p); + if (soap_begin_recv(soap) || soap_get_SOAP_ENV__Detail(soap, p, NULL, NULL) == NULL || soap_end_recv(soap)) + return soap->error; + } + return SOAP_OK; +} +#endif #endif #ifndef WITH_NOGLOBAL -#ifndef SOAP_TYPE_SOAP_ENV__Code -#define SOAP_TYPE_SOAP_ENV__Code (12) -#endif +#ifndef SOAP_TYPE_SOAP_ENV__Code_DEFINED +#define SOAP_TYPE_SOAP_ENV__Code_DEFINED SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Code(struct soap*, const struct SOAP_ENV__Code *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Code(struct soap*, const char*, int, const struct SOAP_ENV__Code *, const char*); SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_in_SOAP_ENV__Code(struct soap*, const char*, struct SOAP_ENV__Code *, const char*); - -SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Code(struct soap*, const struct SOAP_ENV__Code *, const char*, const char*); - -#ifndef soap_write_SOAP_ENV__Code -#define soap_write_SOAP_ENV__Code(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Code(soap, data),0) || soap_put_SOAP_ENV__Code(soap, data, "SOAP-ENV:Code", NULL) || soap_end_send(soap), (soap)->error ) -#endif - -SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_get_SOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *, const char*, const char*); - -#ifndef soap_read_SOAP_ENV__Code -#define soap_read_SOAP_ENV__Code(soap, data) ( soap_begin_recv(soap) || !soap_get_SOAP_ENV__Code(soap, data, NULL, NULL) || soap_end_recv(soap), (soap)->error ) -#endif - SOAP_FMAC1 struct SOAP_ENV__Code * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Code(struct soap*, int, const char*, const char*, size_t*); -inline struct SOAP_ENV__Code * soap_new_SOAP_ENV__Code(struct soap *soap, int n = -1) { return soap_instantiate_SOAP_ENV__Code(soap, n, NULL, NULL, NULL); } +inline struct SOAP_ENV__Code * soap_new_SOAP_ENV__Code(struct soap *soap, int n = -1) +{ + return soap_instantiate_SOAP_ENV__Code(soap, n, NULL, NULL, NULL); +} -inline struct SOAP_ENV__Code * soap_new_req_SOAP_ENV__Code(struct soap *soap) { struct SOAP_ENV__Code *_p = soap_instantiate_SOAP_ENV__Code(soap, -1, NULL, NULL, NULL); if (_p) { soap_default_SOAP_ENV__Code(soap, _p); } return _p; } +inline struct SOAP_ENV__Code * soap_new_req_SOAP_ENV__Code( + struct soap *soap) +{ + struct SOAP_ENV__Code *_p = soap_new_SOAP_ENV__Code(soap); + if (_p) + { soap_default_SOAP_ENV__Code(soap, _p); + } + return _p; +} -inline struct SOAP_ENV__Code * soap_new_set_SOAP_ENV__Code(struct soap *soap, char *SOAP_ENV__Value, struct SOAP_ENV__Code *SOAP_ENV__Subcode) { struct SOAP_ENV__Code *_p = soap_instantiate_SOAP_ENV__Code(soap, -1, NULL, NULL, NULL); if (_p) { soap_default_SOAP_ENV__Code(soap, _p); _p->SOAP_ENV__Value = SOAP_ENV__Value; _p->SOAP_ENV__Subcode = SOAP_ENV__Subcode; } return _p; } +inline struct SOAP_ENV__Code * soap_new_set_SOAP_ENV__Code( + struct soap *soap, + char *SOAP_ENV__Value, + struct SOAP_ENV__Code *SOAP_ENV__Subcode) +{ + struct SOAP_ENV__Code *_p = soap_new_SOAP_ENV__Code(soap); + if (_p) + { soap_default_SOAP_ENV__Code(soap, _p); + _p->SOAP_ENV__Value = SOAP_ENV__Value; + _p->SOAP_ENV__Subcode = SOAP_ENV__Subcode; + } + return _p; +} +SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Code(struct soap*, const struct SOAP_ENV__Code *, const char*, const char*); -inline void soap_delete_SOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code *p) { soap_delete(soap, p); } +inline int soap_write_SOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code const*p) +{ + soap_free_temp(soap); + if (p) + { if (soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Code(soap, p), 0) || soap_put_SOAP_ENV__Code(soap, p, "SOAP-ENV:Code", "") || soap_end_send(soap)) + return soap->error; + } + return SOAP_OK; +} +SOAP_FMAC3 struct SOAP_ENV__Code * SOAP_FMAC4 soap_get_SOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *, const char*, const char*); -SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Code(struct soap*, int, int, void*, size_t, const void*, size_t); +inline int soap_read_SOAP_ENV__Code(struct soap *soap, struct SOAP_ENV__Code *p) +{ + if (p) + { soap_default_SOAP_ENV__Code(soap, p); + if (soap_begin_recv(soap) || soap_get_SOAP_ENV__Code(soap, p, NULL, NULL) == NULL || soap_end_recv(soap)) + return soap->error; + } + return SOAP_OK; +} +#endif #endif #ifndef WITH_NOGLOBAL -#ifndef SOAP_TYPE_SOAP_ENV__Header -#define SOAP_TYPE_SOAP_ENV__Header (11) -#endif +#ifndef SOAP_TYPE_SOAP_ENV__Header_DEFINED +#define SOAP_TYPE_SOAP_ENV__Header_DEFINED SOAP_FMAC3 void SOAP_FMAC4 soap_default_SOAP_ENV__Header(struct soap*, struct SOAP_ENV__Header *); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Header(struct soap*, const struct SOAP_ENV__Header *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Header(struct soap*, const char*, int, const struct SOAP_ENV__Header *, const char*); SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_in_SOAP_ENV__Header(struct soap*, const char*, struct SOAP_ENV__Header *, const char*); - -SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Header(struct soap*, const struct SOAP_ENV__Header *, const char*, const char*); - -#ifndef soap_write_SOAP_ENV__Header -#define soap_write_SOAP_ENV__Header(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Header(soap, data),0) || soap_put_SOAP_ENV__Header(soap, data, "SOAP-ENV:Header", NULL) || soap_end_send(soap), (soap)->error ) -#endif - -SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_get_SOAP_ENV__Header(struct soap*, struct SOAP_ENV__Header *, const char*, const char*); - -#ifndef soap_read_SOAP_ENV__Header -#define soap_read_SOAP_ENV__Header(soap, data) ( soap_begin_recv(soap) || !soap_get_SOAP_ENV__Header(soap, data, NULL, NULL) || soap_end_recv(soap), (soap)->error ) -#endif - SOAP_FMAC1 struct SOAP_ENV__Header * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Header(struct soap*, int, const char*, const char*, size_t*); -inline struct SOAP_ENV__Header * soap_new_SOAP_ENV__Header(struct soap *soap, int n = -1) { return soap_instantiate_SOAP_ENV__Header(soap, n, NULL, NULL, NULL); } - -inline struct SOAP_ENV__Header * soap_new_req_SOAP_ENV__Header(struct soap *soap) { struct SOAP_ENV__Header *_p = soap_instantiate_SOAP_ENV__Header(soap, -1, NULL, NULL, NULL); if (_p) { soap_default_SOAP_ENV__Header(soap, _p); } return _p; } +inline struct SOAP_ENV__Header * soap_new_SOAP_ENV__Header(struct soap *soap, int n = -1) +{ + return soap_instantiate_SOAP_ENV__Header(soap, n, NULL, NULL, NULL); +} -inline struct SOAP_ENV__Header * soap_new_set_SOAP_ENV__Header(struct soap *soap) { struct SOAP_ENV__Header *_p = soap_instantiate_SOAP_ENV__Header(soap, -1, NULL, NULL, NULL); if (_p) { soap_default_SOAP_ENV__Header(soap, _p); } return _p; } +inline struct SOAP_ENV__Header * soap_new_req_SOAP_ENV__Header( + struct soap *soap) +{ + struct SOAP_ENV__Header *_p = soap_new_SOAP_ENV__Header(soap); + if (_p) + { soap_default_SOAP_ENV__Header(soap, _p); + } + return _p; +} -inline void soap_delete_SOAP_ENV__Header(struct soap *soap, struct SOAP_ENV__Header *p) { soap_delete(soap, p); } +inline struct SOAP_ENV__Header * soap_new_set_SOAP_ENV__Header( + struct soap *soap) +{ + struct SOAP_ENV__Header *_p = soap_new_SOAP_ENV__Header(soap); + if (_p) + { soap_default_SOAP_ENV__Header(soap, _p); + } + return _p; +} +SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Header(struct soap*, const struct SOAP_ENV__Header *, const char*, const char*); -SOAP_FMAC3 void SOAP_FMAC4 soap_copy_SOAP_ENV__Header(struct soap*, int, int, void*, size_t, const void*, size_t); +inline int soap_write_SOAP_ENV__Header(struct soap *soap, struct SOAP_ENV__Header const*p) +{ + soap_free_temp(soap); + if (p) + { if (soap_begin_send(soap) || (soap_serialize_SOAP_ENV__Header(soap, p), 0) || soap_put_SOAP_ENV__Header(soap, p, "SOAP-ENV:Header", "") || soap_end_send(soap)) + return soap->error; + } + return SOAP_OK; +} +SOAP_FMAC3 struct SOAP_ENV__Header * SOAP_FMAC4 soap_get_SOAP_ENV__Header(struct soap*, struct SOAP_ENV__Header *, const char*, const char*); +inline int soap_read_SOAP_ENV__Header(struct soap *soap, struct SOAP_ENV__Header *p) +{ + if (p) + { soap_default_SOAP_ENV__Header(soap, p); + if (soap_begin_recv(soap) || soap_get_SOAP_ENV__Header(soap, p, NULL, NULL) == NULL || soap_end_recv(soap)) + return soap->error; + } + return SOAP_OK; +} #endif -#ifndef SOAP_TYPE_ns1__executeCommand -#define SOAP_TYPE_ns1__executeCommand (10) #endif + +#ifndef SOAP_TYPE_ns1__executeCommand_DEFINED +#define SOAP_TYPE_ns1__executeCommand_DEFINED SOAP_FMAC3 void SOAP_FMAC4 soap_default_ns1__executeCommand(struct soap*, struct ns1__executeCommand *); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_ns1__executeCommand(struct soap*, const struct ns1__executeCommand *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_ns1__executeCommand(struct soap*, const char*, int, const struct ns1__executeCommand *, const char*); SOAP_FMAC3 struct ns1__executeCommand * SOAP_FMAC4 soap_in_ns1__executeCommand(struct soap*, const char*, struct ns1__executeCommand *, const char*); - -SOAP_FMAC3 int SOAP_FMAC4 soap_put_ns1__executeCommand(struct soap*, const struct ns1__executeCommand *, const char*, const char*); - -#ifndef soap_write_ns1__executeCommand -#define soap_write_ns1__executeCommand(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || (soap_serialize_ns1__executeCommand(soap, data),0) || soap_put_ns1__executeCommand(soap, data, "ns1:executeCommand", NULL) || soap_end_send(soap), (soap)->error ) -#endif - -SOAP_FMAC3 struct ns1__executeCommand * SOAP_FMAC4 soap_get_ns1__executeCommand(struct soap*, struct ns1__executeCommand *, const char*, const char*); - -#ifndef soap_read_ns1__executeCommand -#define soap_read_ns1__executeCommand(soap, data) ( soap_begin_recv(soap) || !soap_get_ns1__executeCommand(soap, data, NULL, NULL) || soap_end_recv(soap), (soap)->error ) -#endif - SOAP_FMAC1 struct ns1__executeCommand * SOAP_FMAC2 soap_instantiate_ns1__executeCommand(struct soap*, int, const char*, const char*, size_t*); -inline struct ns1__executeCommand * soap_new_ns1__executeCommand(struct soap *soap, int n = -1) { return soap_instantiate_ns1__executeCommand(soap, n, NULL, NULL, NULL); } - -inline struct ns1__executeCommand * soap_new_req_ns1__executeCommand(struct soap *soap) { struct ns1__executeCommand *_p = soap_instantiate_ns1__executeCommand(soap, -1, NULL, NULL, NULL); if (_p) { soap_default_ns1__executeCommand(soap, _p); } return _p; } +inline struct ns1__executeCommand * soap_new_ns1__executeCommand(struct soap *soap, int n = -1) +{ + return soap_instantiate_ns1__executeCommand(soap, n, NULL, NULL, NULL); +} -inline struct ns1__executeCommand * soap_new_set_ns1__executeCommand(struct soap *soap, char *command) { struct ns1__executeCommand *_p = soap_instantiate_ns1__executeCommand(soap, -1, NULL, NULL, NULL); if (_p) { soap_default_ns1__executeCommand(soap, _p); _p->command = command; } return _p; } +inline struct ns1__executeCommand * soap_new_req_ns1__executeCommand( + struct soap *soap) +{ + struct ns1__executeCommand *_p = soap_new_ns1__executeCommand(soap); + if (_p) + { soap_default_ns1__executeCommand(soap, _p); + } + return _p; +} -inline void soap_delete_ns1__executeCommand(struct soap *soap, struct ns1__executeCommand *p) { soap_delete(soap, p); } +inline struct ns1__executeCommand * soap_new_set_ns1__executeCommand( + struct soap *soap, + char *command) +{ + struct ns1__executeCommand *_p = soap_new_ns1__executeCommand(soap); + if (_p) + { soap_default_ns1__executeCommand(soap, _p); + _p->command = command; + } + return _p; +} +SOAP_FMAC3 int SOAP_FMAC4 soap_put_ns1__executeCommand(struct soap*, const struct ns1__executeCommand *, const char*, const char*); -SOAP_FMAC3 void SOAP_FMAC4 soap_copy_ns1__executeCommand(struct soap*, int, int, void*, size_t, const void*, size_t); +inline int soap_write_ns1__executeCommand(struct soap *soap, struct ns1__executeCommand const*p) +{ + soap_free_temp(soap); + if (p) + { if (soap_begin_send(soap) || (soap_serialize_ns1__executeCommand(soap, p), 0) || soap_put_ns1__executeCommand(soap, p, "ns1:executeCommand", "") || soap_end_send(soap)) + return soap->error; + } + return SOAP_OK; +} +SOAP_FMAC3 struct ns1__executeCommand * SOAP_FMAC4 soap_get_ns1__executeCommand(struct soap*, struct ns1__executeCommand *, const char*, const char*); -#ifndef SOAP_TYPE_ns1__executeCommandResponse -#define SOAP_TYPE_ns1__executeCommandResponse (9) +inline int soap_read_ns1__executeCommand(struct soap *soap, struct ns1__executeCommand *p) +{ + if (p) + { soap_default_ns1__executeCommand(soap, p); + if (soap_begin_recv(soap) || soap_get_ns1__executeCommand(soap, p, NULL, NULL) == NULL || soap_end_recv(soap)) + return soap->error; + } + return SOAP_OK; +} #endif + +#ifndef SOAP_TYPE_ns1__executeCommandResponse_DEFINED +#define SOAP_TYPE_ns1__executeCommandResponse_DEFINED SOAP_FMAC3 void SOAP_FMAC4 soap_default_ns1__executeCommandResponse(struct soap*, struct ns1__executeCommandResponse *); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_ns1__executeCommandResponse(struct soap*, const struct ns1__executeCommandResponse *); SOAP_FMAC3 int SOAP_FMAC4 soap_out_ns1__executeCommandResponse(struct soap*, const char*, int, const struct ns1__executeCommandResponse *, const char*); SOAP_FMAC3 struct ns1__executeCommandResponse * SOAP_FMAC4 soap_in_ns1__executeCommandResponse(struct soap*, const char*, struct ns1__executeCommandResponse *, const char*); - -SOAP_FMAC3 int SOAP_FMAC4 soap_put_ns1__executeCommandResponse(struct soap*, const struct ns1__executeCommandResponse *, const char*, const char*); - -#ifndef soap_write_ns1__executeCommandResponse -#define soap_write_ns1__executeCommandResponse(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || (soap_serialize_ns1__executeCommandResponse(soap, data),0) || soap_put_ns1__executeCommandResponse(soap, data, "ns1:executeCommandResponse", NULL) || soap_end_send(soap), (soap)->error ) -#endif - -SOAP_FMAC3 struct ns1__executeCommandResponse * SOAP_FMAC4 soap_get_ns1__executeCommandResponse(struct soap*, struct ns1__executeCommandResponse *, const char*, const char*); - -#ifndef soap_read_ns1__executeCommandResponse -#define soap_read_ns1__executeCommandResponse(soap, data) ( soap_begin_recv(soap) || !soap_get_ns1__executeCommandResponse(soap, data, NULL, NULL) || soap_end_recv(soap), (soap)->error ) -#endif - SOAP_FMAC1 struct ns1__executeCommandResponse * SOAP_FMAC2 soap_instantiate_ns1__executeCommandResponse(struct soap*, int, const char*, const char*, size_t*); -inline struct ns1__executeCommandResponse * soap_new_ns1__executeCommandResponse(struct soap *soap, int n = -1) { return soap_instantiate_ns1__executeCommandResponse(soap, n, NULL, NULL, NULL); } +inline struct ns1__executeCommandResponse * soap_new_ns1__executeCommandResponse(struct soap *soap, int n = -1) +{ + return soap_instantiate_ns1__executeCommandResponse(soap, n, NULL, NULL, NULL); +} -inline struct ns1__executeCommandResponse * soap_new_req_ns1__executeCommandResponse(struct soap *soap) { struct ns1__executeCommandResponse *_p = soap_instantiate_ns1__executeCommandResponse(soap, -1, NULL, NULL, NULL); if (_p) { soap_default_ns1__executeCommandResponse(soap, _p); } return _p; } +inline struct ns1__executeCommandResponse * soap_new_req_ns1__executeCommandResponse( + struct soap *soap) +{ + struct ns1__executeCommandResponse *_p = soap_new_ns1__executeCommandResponse(soap); + if (_p) + { soap_default_ns1__executeCommandResponse(soap, _p); + } + return _p; +} -inline struct ns1__executeCommandResponse * soap_new_set_ns1__executeCommandResponse(struct soap *soap, char **result) { struct ns1__executeCommandResponse *_p = soap_instantiate_ns1__executeCommandResponse(soap, -1, NULL, NULL, NULL); if (_p) { soap_default_ns1__executeCommandResponse(soap, _p); _p->result = result; } return _p; } +inline struct ns1__executeCommandResponse * soap_new_set_ns1__executeCommandResponse( + struct soap *soap, + char **result) +{ + struct ns1__executeCommandResponse *_p = soap_new_ns1__executeCommandResponse(soap); + if (_p) + { soap_default_ns1__executeCommandResponse(soap, _p); + _p->result = result; + } + return _p; +} +SOAP_FMAC3 int SOAP_FMAC4 soap_put_ns1__executeCommandResponse(struct soap*, const struct ns1__executeCommandResponse *, const char*, const char*); -inline void soap_delete_ns1__executeCommandResponse(struct soap *soap, struct ns1__executeCommandResponse *p) { soap_delete(soap, p); } +inline int soap_write_ns1__executeCommandResponse(struct soap *soap, struct ns1__executeCommandResponse const*p) +{ + soap_free_temp(soap); + if (p) + { if (soap_begin_send(soap) || (soap_serialize_ns1__executeCommandResponse(soap, p), 0) || soap_put_ns1__executeCommandResponse(soap, p, "ns1:executeCommandResponse", "") || soap_end_send(soap)) + return soap->error; + } + return SOAP_OK; +} +SOAP_FMAC3 struct ns1__executeCommandResponse * SOAP_FMAC4 soap_get_ns1__executeCommandResponse(struct soap*, struct ns1__executeCommandResponse *, const char*, const char*); -SOAP_FMAC3 void SOAP_FMAC4 soap_copy_ns1__executeCommandResponse(struct soap*, int, int, void*, size_t, const void*, size_t); +inline int soap_read_ns1__executeCommandResponse(struct soap *soap, struct ns1__executeCommandResponse *p) +{ + if (p) + { soap_default_ns1__executeCommandResponse(soap, p); + if (soap_begin_recv(soap) || soap_get_ns1__executeCommandResponse(soap, p, NULL, NULL) == NULL || soap_end_recv(soap)) + return soap->error; + } + return SOAP_OK; +} +#endif #ifndef WITH_NOGLOBAL -#ifndef SOAP_TYPE_PointerToSOAP_ENV__Reason -#define SOAP_TYPE_PointerToSOAP_ENV__Reason (20) -#endif +#ifndef SOAP_TYPE_PointerToSOAP_ENV__Reason_DEFINED +#define SOAP_TYPE_PointerToSOAP_ENV__Reason_DEFINED SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *const*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Reason(struct soap*, const char *, int, struct SOAP_ENV__Reason *const*, const char *); SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Reason(struct soap*, const char*, struct SOAP_ENV__Reason **, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason *const*, const char*, const char*); - -#ifndef soap_write_PointerToSOAP_ENV__Reason -#define soap_write_PointerToSOAP_ENV__Reason(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || (soap_serialize_PointerToSOAP_ENV__Reason(soap, data),0) || soap_put_PointerToSOAP_ENV__Reason(soap, data, "SOAP-ENV:Reason", NULL) || soap_end_send(soap), (soap)->error ) -#endif - SOAP_FMAC3 struct SOAP_ENV__Reason ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Reason(struct soap*, struct SOAP_ENV__Reason **, const char*, const char*); - -#ifndef soap_read_PointerToSOAP_ENV__Reason -#define soap_read_PointerToSOAP_ENV__Reason(soap, data) ( soap_begin_recv(soap) || !soap_get_PointerToSOAP_ENV__Reason(soap, data, NULL, NULL) || soap_end_recv(soap), (soap)->error ) #endif - #endif #ifndef WITH_NOGLOBAL -#ifndef SOAP_TYPE_PointerToSOAP_ENV__Detail -#define SOAP_TYPE_PointerToSOAP_ENV__Detail (19) -#endif +#ifndef SOAP_TYPE_PointerToSOAP_ENV__Detail_DEFINED +#define SOAP_TYPE_PointerToSOAP_ENV__Detail_DEFINED SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *const*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Detail(struct soap*, const char *, int, struct SOAP_ENV__Detail *const*, const char *); SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Detail(struct soap*, const char*, struct SOAP_ENV__Detail **, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail *const*, const char*, const char*); - -#ifndef soap_write_PointerToSOAP_ENV__Detail -#define soap_write_PointerToSOAP_ENV__Detail(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || (soap_serialize_PointerToSOAP_ENV__Detail(soap, data),0) || soap_put_PointerToSOAP_ENV__Detail(soap, data, "SOAP-ENV:Detail", NULL) || soap_end_send(soap), (soap)->error ) -#endif - SOAP_FMAC3 struct SOAP_ENV__Detail ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Detail(struct soap*, struct SOAP_ENV__Detail **, const char*, const char*); - -#ifndef soap_read_PointerToSOAP_ENV__Detail -#define soap_read_PointerToSOAP_ENV__Detail(soap, data) ( soap_begin_recv(soap) || !soap_get_PointerToSOAP_ENV__Detail(soap, data, NULL, NULL) || soap_end_recv(soap), (soap)->error ) #endif - #endif #ifndef WITH_NOGLOBAL -#ifndef SOAP_TYPE_PointerToSOAP_ENV__Code -#define SOAP_TYPE_PointerToSOAP_ENV__Code (13) -#endif +#ifndef SOAP_TYPE_PointerToSOAP_ENV__Code_DEFINED +#define SOAP_TYPE_PointerToSOAP_ENV__Code_DEFINED SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *const*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerToSOAP_ENV__Code(struct soap*, const char *, int, struct SOAP_ENV__Code *const*, const char *); SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_in_PointerToSOAP_ENV__Code(struct soap*, const char*, struct SOAP_ENV__Code **, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code *const*, const char*, const char*); - -#ifndef soap_write_PointerToSOAP_ENV__Code -#define soap_write_PointerToSOAP_ENV__Code(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || (soap_serialize_PointerToSOAP_ENV__Code(soap, data),0) || soap_put_PointerToSOAP_ENV__Code(soap, data, "SOAP-ENV:Code", NULL) || soap_end_send(soap), (soap)->error ) -#endif - SOAP_FMAC3 struct SOAP_ENV__Code ** SOAP_FMAC4 soap_get_PointerToSOAP_ENV__Code(struct soap*, struct SOAP_ENV__Code **, const char*, const char*); - -#ifndef soap_read_PointerToSOAP_ENV__Code -#define soap_read_PointerToSOAP_ENV__Code(soap, data) ( soap_begin_recv(soap) || !soap_get_PointerToSOAP_ENV__Code(soap, data, NULL, NULL) || soap_end_recv(soap), (soap)->error ) #endif - #endif -#ifndef SOAP_TYPE_PointerTostring -#define SOAP_TYPE_PointerTostring (7) -#endif +#ifndef SOAP_TYPE_PointerTostring_DEFINED +#define SOAP_TYPE_PointerTostring_DEFINED SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_PointerTostring(struct soap*, char **const*); SOAP_FMAC3 int SOAP_FMAC4 soap_out_PointerTostring(struct soap*, const char *, int, char **const*, const char *); SOAP_FMAC3 char *** SOAP_FMAC4 soap_in_PointerTostring(struct soap*, const char*, char ***, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_put_PointerTostring(struct soap*, char **const*, const char*, const char*); - -#ifndef soap_write_PointerTostring -#define soap_write_PointerTostring(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || (soap_serialize_PointerTostring(soap, data),0) || soap_put_PointerTostring(soap, data, "byte", NULL) || soap_end_send(soap), (soap)->error ) -#endif - SOAP_FMAC3 char *** SOAP_FMAC4 soap_get_PointerTostring(struct soap*, char ***, const char*, const char*); - -#ifndef soap_read_PointerTostring -#define soap_read_PointerTostring(soap, data) ( soap_begin_recv(soap) || !soap_get_PointerTostring(soap, data, NULL, NULL) || soap_end_recv(soap), (soap)->error ) #endif - -#ifndef SOAP_TYPE__QName -#define SOAP_TYPE__QName (5) +#ifndef SOAP_TYPE__XML_DEFINED +#define SOAP_TYPE__XML_DEFINED #endif -#define soap_default__QName(soap, a) soap_default_string(soap, a) - +#ifndef SOAP_TYPE__QName_DEFINED +#define SOAP_TYPE__QName_DEFINED +SOAP_FMAC3 void SOAP_FMAC4 soap_default__QName(struct soap*, char **); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize__QName(struct soap*, char *const*); + +#define soap__QName2s(soap, a) soap_QName2s(soap, (a)) SOAP_FMAC3 int SOAP_FMAC4 soap_out__QName(struct soap*, const char*, int, char*const*, const char*); + +#define soap_s2_QName(soap, s, a) soap_s2QName((soap), (s), (char**)(a), 0, -1, NULL) SOAP_FMAC3 char * * SOAP_FMAC4 soap_in__QName(struct soap*, const char*, char **, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_put__QName(struct soap*, char *const*, const char*, const char*); -#ifndef soap_write__QName -#define soap_write__QName(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || (soap_serialize__QName(soap, data),0) || soap_put__QName(soap, data, "byte", NULL) || soap_end_send(soap), (soap)->error ) -#endif - +inline int soap_write__QName(struct soap *soap, char *const*p) +{ + soap_free_temp(soap); + if (p) + { if (soap_begin_send(soap) || soap_put__QName(soap, p, "QName", "") || soap_end_send(soap)) + return soap->error; + } + return SOAP_OK; +} SOAP_FMAC3 char ** SOAP_FMAC4 soap_get__QName(struct soap*, char **, const char*, const char*); -#ifndef soap_read__QName -#define soap_read__QName(soap, data) ( soap_begin_recv(soap) || !soap_get__QName(soap, data, NULL, NULL) || soap_end_recv(soap), (soap)->error ) +inline int soap_read__QName(struct soap *soap, char **p) +{ + if (p) + { if (soap_begin_recv(soap) || soap_get__QName(soap, p, NULL, NULL) == NULL || soap_end_recv(soap)) + return soap->error; + } + return SOAP_OK; +} #endif - -#ifndef SOAP_TYPE_string -#define SOAP_TYPE_string (4) -#endif +#ifndef SOAP_TYPE_string_DEFINED +#define SOAP_TYPE_string_DEFINED SOAP_FMAC3 void SOAP_FMAC4 soap_default_string(struct soap*, char **); SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_string(struct soap*, char *const*); + +#define soap_string2s(soap, a) (a) SOAP_FMAC3 int SOAP_FMAC4 soap_out_string(struct soap*, const char*, int, char*const*, const char*); + +#define soap_s2string(soap, s, a) soap_s2char((soap), (s), (char**)(a), 0, -1, NULL) SOAP_FMAC3 char * * SOAP_FMAC4 soap_in_string(struct soap*, const char*, char **, const char*); SOAP_FMAC3 int SOAP_FMAC4 soap_put_string(struct soap*, char *const*, const char*, const char*); -#ifndef soap_write_string -#define soap_write_string(soap, data) ( soap_free_temp(soap), soap_begin_send(soap) || (soap_serialize_string(soap, data),0) || soap_put_string(soap, data, "byte", NULL) || soap_end_send(soap), (soap)->error ) -#endif - +inline int soap_write_string(struct soap *soap, char *const*p) +{ + soap_free_temp(soap); + if (p) + { if (soap_begin_send(soap) || soap_put_string(soap, p, "string", "") || soap_end_send(soap)) + return soap->error; + } + return SOAP_OK; +} SOAP_FMAC3 char ** SOAP_FMAC4 soap_get_string(struct soap*, char **, const char*, const char*); -#ifndef soap_read_string -#define soap_read_string(soap, data) ( soap_begin_recv(soap) || !soap_get_string(soap, data, NULL, NULL) || soap_end_recv(soap), (soap)->error ) +inline int soap_read_string(struct soap *soap, char **p) +{ + if (p) + { if (soap_begin_recv(soap) || soap_get_string(soap, p, NULL, NULL) == NULL || soap_end_recv(soap)) + return soap->error; + } + return SOAP_OK; +} #endif - #endif /* End of soapH.h */ diff --git a/dep/gsoap/soapServer.cpp b/dep/gsoap/soapServer.cpp index 6e5c8040165..f8fa4797180 100644 --- a/dep/gsoap/soapServer.cpp +++ b/dep/gsoap/soapServer.cpp @@ -1,11 +1,14 @@ /* soapServer.cpp - Generated by gSOAP 2.8.17r from gsoap.stub + Generated by gSOAP 2.8.33 for gsoap.stub -Copyright(C) 2000-2013, Robert van Engelen, Genivia Inc. All Rights Reserved. -The generated code is released under one of the following licenses: -GPL or Genivia's license for commercial use. +gSOAP XML Web services tools +Copyright (C) 2000-2016, Robert van Engelen, Genivia Inc. All Rights Reserved. +The soapcpp2 tool and its generated software are released under the GPL. This program is released under the GPL with the additional exemption that compiling, linking, and/or using OpenSSL is allowed. +-------------------------------------------------------------------------------- +A commercial use license is available from Genivia Inc., contact@genivia.com +-------------------------------------------------------------------------------- */ #if defined(__BORLANDC__) @@ -14,9 +17,7 @@ compiling, linking, and/or using OpenSSL is allowed. #endif #include "soapH.h" -SOAP_SOURCE_STAMP("@(#) soapServer.cpp ver 2.8.17r 2014-06-21 21:43:17 GMT") - - +SOAP_SOURCE_STAMP("@(#) soapServer.cpp ver 2.8.33 2016-07-29 05:51:35 GMT") extern "C" SOAP_FMAC5 int SOAP_FMAC6 soap_serve(struct soap *soap) { #ifndef WITH_FASTCGI @@ -88,7 +89,7 @@ SOAP_FMAC5 int SOAP_FMAC6 soap_serve_ns1__executeCommand(struct soap *soap) { if (soap_envelope_begin_out(soap) || soap_putheader(soap) || soap_body_begin_out(soap) - || soap_put_ns1__executeCommandResponse(soap, &soap_tmp_ns1__executeCommandResponse, "ns1:executeCommandResponse", NULL) + || soap_put_ns1__executeCommandResponse(soap, &soap_tmp_ns1__executeCommandResponse, "ns1:executeCommandResponse", "") || soap_body_end_out(soap) || soap_envelope_end_out(soap)) return soap->error; @@ -98,7 +99,7 @@ SOAP_FMAC5 int SOAP_FMAC6 soap_serve_ns1__executeCommand(struct soap *soap) || soap_envelope_begin_out(soap) || soap_putheader(soap) || soap_body_begin_out(soap) - || soap_put_ns1__executeCommandResponse(soap, &soap_tmp_ns1__executeCommandResponse, "ns1:executeCommandResponse", NULL) + || soap_put_ns1__executeCommandResponse(soap, &soap_tmp_ns1__executeCommandResponse, "ns1:executeCommandResponse", "") || soap_body_end_out(soap) || soap_envelope_end_out(soap) || soap_end_send(soap)) diff --git a/dep/gsoap/soapStub.h b/dep/gsoap/soapStub.h index 38374561cde..ce1a2546ef6 100644 --- a/dep/gsoap/soapStub.h +++ b/dep/gsoap/soapStub.h @@ -1,30 +1,27 @@ /* soapStub.h - Generated by gSOAP 2.8.17r from gsoap.stub + Generated by gSOAP 2.8.33 for gsoap.stub -Copyright(C) 2000-2013, Robert van Engelen, Genivia Inc. All Rights Reserved. -The generated code is released under one of the following licenses: -GPL or Genivia's license for commercial use. +gSOAP XML Web services tools +Copyright (C) 2000-2016, Robert van Engelen, Genivia Inc. All Rights Reserved. +The soapcpp2 tool and its generated software are released under the GPL. This program is released under the GPL with the additional exemption that compiling, linking, and/or using OpenSSL is allowed. +-------------------------------------------------------------------------------- +A commercial use license is available from Genivia Inc., contact@genivia.com +-------------------------------------------------------------------------------- */ + #ifndef soapStub_H #define soapStub_H #include "stdsoap2.h" -#if GSOAP_VERSION != 20817 -# error "GSOAP VERSION MISMATCH IN GENERATED CODE: PLEASE REINSTALL PACKAGE" +#if GSOAP_VERSION != 20833 +# error "GSOAP VERSION 20833 MISMATCH IN GENERATED CODE VERSUS LIBRARY CODE: PLEASE REINSTALL PACKAGE" #endif /******************************************************************************\ * * - * Enumerations * - * * -\******************************************************************************/ - - -/******************************************************************************\ - * * * Types with Custom Serializers * * * \******************************************************************************/ @@ -32,130 +29,197 @@ compiling, linking, and/or using OpenSSL is allowed. /******************************************************************************\ * * - * Classes and Structs * + * Classes, Structs and Unions * * * \******************************************************************************/ +struct ns1__executeCommandResponse; /* gsoap.stub:1 */ +struct ns1__executeCommand; /* gsoap.stub:1 */ -#if 0 /* volatile type: do not declare here, declared elsewhere */ - -#endif - +/* gsoap.stub:1 */ #ifndef SOAP_TYPE_ns1__executeCommandResponse #define SOAP_TYPE_ns1__executeCommandResponse (9) -/* ns1:executeCommandResponse */ -struct ns1__executeCommandResponse -{ -public: - char **result; /* SOAP 1.2 RPC return element (when namespace qualified) */ /* optional element of type xsd:string */ -public: - int soap_type() const { return 9; } /* = unique type id SOAP_TYPE_ns1__executeCommandResponse */ +/* complex XSD type 'ns1:executeCommandResponse': */ +struct ns1__executeCommandResponse { + public: + /** Optional element 'result' of XSD type 'xsd:string' */ + char **result; + public: + /** Return unique type id SOAP_TYPE_ns1__executeCommandResponse */ + int soap_type() const { return SOAP_TYPE_ns1__executeCommandResponse; } + /** Constructor with member initializations */ + ns1__executeCommandResponse() + { + result = (char **)0; + } + /** Friend allocator used by soap_new_ns1__executeCommandResponse(struct soap*, int) */ + friend SOAP_FMAC1 ns1__executeCommandResponse * SOAP_FMAC2 soap_instantiate_ns1__executeCommandResponse(struct soap*, int, const char*, const char*, size_t*); }; #endif +/* gsoap.stub:1 */ #ifndef SOAP_TYPE_ns1__executeCommand #define SOAP_TYPE_ns1__executeCommand (10) -/* ns1:executeCommand */ -struct ns1__executeCommand -{ -public: - char *command; /* optional element of type xsd:string */ -public: - int soap_type() const { return 10; } /* = unique type id SOAP_TYPE_ns1__executeCommand */ +/* complex XSD type 'ns1:executeCommand': */ +struct ns1__executeCommand { + public: + /** Optional element 'command' of XSD type 'xsd:string' */ + char *command; + public: + /** Return unique type id SOAP_TYPE_ns1__executeCommand */ + int soap_type() const { return SOAP_TYPE_ns1__executeCommand; } + /** Constructor with member initializations */ + ns1__executeCommand() + { + command = (char *)0; + } + /** Friend allocator used by soap_new_ns1__executeCommand(struct soap*, int) */ + friend SOAP_FMAC1 ns1__executeCommand * SOAP_FMAC2 soap_instantiate_ns1__executeCommand(struct soap*, int, const char*, const char*, size_t*); }; #endif +/* gsoap.stub:2 */ #ifndef WITH_NOGLOBAL - #ifndef SOAP_TYPE_SOAP_ENV__Header #define SOAP_TYPE_SOAP_ENV__Header (11) -/* SOAP Header: */ -struct SOAP_ENV__Header -{ -public: - int soap_type() const { return 11; } /* = unique type id SOAP_TYPE_SOAP_ENV__Header */ -#ifdef WITH_NOEMPTYSTRUCT -private: - char dummy; /* dummy member to enable compilation */ -#endif +/* SOAP_ENV__Header: */ +struct SOAP_ENV__Header { + public: + /** Return unique type id SOAP_TYPE_SOAP_ENV__Header */ + int soap_type() const { return SOAP_TYPE_SOAP_ENV__Header; } + /** Constructor with member initializations */ + SOAP_ENV__Header() + { + } + /** Friend allocator used by soap_new_SOAP_ENV__Header(struct soap*, int) */ + friend SOAP_FMAC1 SOAP_ENV__Header * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Header(struct soap*, int, const char*, const char*, size_t*); }; #endif - #endif +/* gsoap.stub:2 */ #ifndef WITH_NOGLOBAL - #ifndef SOAP_TYPE_SOAP_ENV__Code #define SOAP_TYPE_SOAP_ENV__Code (12) -/* SOAP Fault Code: */ -struct SOAP_ENV__Code -{ -public: - char *SOAP_ENV__Value; /* optional element of type xsd:QName */ - struct SOAP_ENV__Code *SOAP_ENV__Subcode; /* optional element of type SOAP-ENV:Code */ -public: - int soap_type() const { return 12; } /* = unique type id SOAP_TYPE_SOAP_ENV__Code */ +/* Type SOAP_ENV__Code is a recursive data type, (in)directly referencing itself through its (base or derived class) members */ +/* SOAP_ENV__Code: */ +struct SOAP_ENV__Code { + public: + /** Optional element 'SOAP-ENV:Value' of XSD type 'xsd:QName' */ + char *SOAP_ENV__Value; + /** Optional element 'SOAP-ENV:Subcode' of XSD type 'SOAP-ENV:Code' */ + struct SOAP_ENV__Code *SOAP_ENV__Subcode; + public: + /** Return unique type id SOAP_TYPE_SOAP_ENV__Code */ + int soap_type() const { return SOAP_TYPE_SOAP_ENV__Code; } + /** Constructor with member initializations */ + SOAP_ENV__Code() + { + SOAP_ENV__Value = (char *)0; + SOAP_ENV__Subcode = (struct SOAP_ENV__Code *)0; + } + /** Friend allocator used by soap_new_SOAP_ENV__Code(struct soap*, int) */ + friend SOAP_FMAC1 SOAP_ENV__Code * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Code(struct soap*, int, const char*, const char*, size_t*); }; #endif - #endif +/* gsoap.stub:2 */ #ifndef WITH_NOGLOBAL - #ifndef SOAP_TYPE_SOAP_ENV__Detail #define SOAP_TYPE_SOAP_ENV__Detail (14) -/* SOAP-ENV:Detail */ -struct SOAP_ENV__Detail -{ -public: - char *__any; - int __type; /* any type of element <fault> (defined below) */ - void *fault; /* transient */ -public: - int soap_type() const { return 14; } /* = unique type id SOAP_TYPE_SOAP_ENV__Detail */ +/* SOAP_ENV__Detail: */ +struct SOAP_ENV__Detail { + public: + char *__any; + /** Any type of element 'fault' assigned to fault with its SOAP_TYPE_T assigned to __type */ + /** Do not create a cyclic data structure throught this member unless SOAP encoding or SOAP_XML_GRAPH are used for id-ref serialization */ + int __type; + void *fault; + public: + /** Return unique type id SOAP_TYPE_SOAP_ENV__Detail */ + int soap_type() const { return SOAP_TYPE_SOAP_ENV__Detail; } + /** Constructor with member initializations */ + SOAP_ENV__Detail() + { + __any = (char *)0; + __type = 0; + fault = NULL; + } + /** Friend allocator used by soap_new_SOAP_ENV__Detail(struct soap*, int) */ + friend SOAP_FMAC1 SOAP_ENV__Detail * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Detail(struct soap*, int, const char*, const char*, size_t*); }; #endif - #endif +/* gsoap.stub:2 */ #ifndef WITH_NOGLOBAL - #ifndef SOAP_TYPE_SOAP_ENV__Reason #define SOAP_TYPE_SOAP_ENV__Reason (17) -/* SOAP-ENV:Reason */ -struct SOAP_ENV__Reason -{ -public: - char *SOAP_ENV__Text; /* optional element of type xsd:string */ -public: - int soap_type() const { return 17; } /* = unique type id SOAP_TYPE_SOAP_ENV__Reason */ +/* SOAP_ENV__Reason: */ +struct SOAP_ENV__Reason { + public: + /** Optional element 'SOAP-ENV:Text' of XSD type 'xsd:string' */ + char *SOAP_ENV__Text; + public: + /** Return unique type id SOAP_TYPE_SOAP_ENV__Reason */ + int soap_type() const { return SOAP_TYPE_SOAP_ENV__Reason; } + /** Constructor with member initializations */ + SOAP_ENV__Reason() + { + SOAP_ENV__Text = (char *)0; + } + /** Friend allocator used by soap_new_SOAP_ENV__Reason(struct soap*, int) */ + friend SOAP_FMAC1 SOAP_ENV__Reason * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Reason(struct soap*, int, const char*, const char*, size_t*); }; #endif - #endif +/* gsoap.stub:2 */ #ifndef WITH_NOGLOBAL - #ifndef SOAP_TYPE_SOAP_ENV__Fault #define SOAP_TYPE_SOAP_ENV__Fault (18) -/* SOAP Fault: */ -struct SOAP_ENV__Fault -{ -public: - char *faultcode; /* optional element of type xsd:QName */ - char *faultstring; /* optional element of type xsd:string */ - char *faultactor; /* optional element of type xsd:string */ - struct SOAP_ENV__Detail *detail; /* optional element of type SOAP-ENV:Detail */ - struct SOAP_ENV__Code *SOAP_ENV__Code; /* optional element of type SOAP-ENV:Code */ - struct SOAP_ENV__Reason *SOAP_ENV__Reason; /* optional element of type SOAP-ENV:Reason */ - char *SOAP_ENV__Node; /* optional element of type xsd:string */ - char *SOAP_ENV__Role; /* optional element of type xsd:string */ - struct SOAP_ENV__Detail *SOAP_ENV__Detail; /* optional element of type SOAP-ENV:Detail */ -public: - int soap_type() const { return 18; } /* = unique type id SOAP_TYPE_SOAP_ENV__Fault */ +/* SOAP_ENV__Fault: */ +struct SOAP_ENV__Fault { + public: + /** Optional element 'faultcode' of XSD type 'xsd:QName' */ + char *faultcode; + /** Optional element 'faultstring' of XSD type 'xsd:string' */ + char *faultstring; + /** Optional element 'faultactor' of XSD type 'xsd:string' */ + char *faultactor; + /** Optional element 'detail' of XSD type 'SOAP-ENV:Detail' */ + struct SOAP_ENV__Detail *detail; + /** Optional element 'SOAP-ENV:Code' of XSD type 'SOAP-ENV:Code' */ + struct SOAP_ENV__Code *SOAP_ENV__Code; + /** Optional element 'SOAP-ENV:Reason' of XSD type 'SOAP-ENV:Reason' */ + struct SOAP_ENV__Reason *SOAP_ENV__Reason; + /** Optional element 'SOAP-ENV:Node' of XSD type 'xsd:string' */ + char *SOAP_ENV__Node; + /** Optional element 'SOAP-ENV:Role' of XSD type 'xsd:string' */ + char *SOAP_ENV__Role; + /** Optional element 'SOAP-ENV:Detail' of XSD type 'SOAP-ENV:Detail' */ + struct SOAP_ENV__Detail *SOAP_ENV__Detail; + public: + /** Return unique type id SOAP_TYPE_SOAP_ENV__Fault */ + int soap_type() const { return SOAP_TYPE_SOAP_ENV__Fault; } + /** Constructor with member initializations */ + SOAP_ENV__Fault() + { + faultcode = (char *)0; + faultstring = (char *)0; + faultactor = (char *)0; + detail = (struct SOAP_ENV__Detail *)0; + SOAP_ENV__Code = (struct SOAP_ENV__Code *)0; + SOAP_ENV__Reason = (struct SOAP_ENV__Reason *)0; + SOAP_ENV__Node = (char *)0; + SOAP_ENV__Role = (char *)0; + SOAP_ENV__Detail = (struct SOAP_ENV__Detail *)0; + } + /** Friend allocator used by soap_new_SOAP_ENV__Fault(struct soap*, int) */ + friend SOAP_FMAC1 SOAP_ENV__Fault * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Fault(struct soap*, int, const char*, const char*, size_t*); }; #endif - #endif /******************************************************************************\ @@ -164,16 +228,105 @@ public: * * \******************************************************************************/ + +/* gsoap.stub:1 */ #ifndef SOAP_TYPE__QName #define SOAP_TYPE__QName (5) typedef char *_QName; #endif +/* gsoap.stub:1 */ #ifndef SOAP_TYPE__XML #define SOAP_TYPE__XML (6) typedef char *_XML; #endif +/******************************************************************************\ + * * + * Serializable Types * + * * +\******************************************************************************/ + + +/* char has binding name 'byte' for type 'xsd:byte' */ +#ifndef SOAP_TYPE_byte +#define SOAP_TYPE_byte (3) +#endif + +/* int has binding name 'int' for type 'xsd:int' */ +#ifndef SOAP_TYPE_int +#define SOAP_TYPE_int (1) +#endif + +/* struct SOAP_ENV__Fault has binding name 'SOAP_ENV__Fault' for type '' */ +#ifndef SOAP_TYPE_SOAP_ENV__Fault +#define SOAP_TYPE_SOAP_ENV__Fault (18) +#endif + +/* struct SOAP_ENV__Reason has binding name 'SOAP_ENV__Reason' for type '' */ +#ifndef SOAP_TYPE_SOAP_ENV__Reason +#define SOAP_TYPE_SOAP_ENV__Reason (17) +#endif + +/* struct SOAP_ENV__Detail has binding name 'SOAP_ENV__Detail' for type '' */ +#ifndef SOAP_TYPE_SOAP_ENV__Detail +#define SOAP_TYPE_SOAP_ENV__Detail (14) +#endif + +/* struct SOAP_ENV__Code has binding name 'SOAP_ENV__Code' for type '' */ +#ifndef SOAP_TYPE_SOAP_ENV__Code +#define SOAP_TYPE_SOAP_ENV__Code (12) +#endif + +/* struct SOAP_ENV__Header has binding name 'SOAP_ENV__Header' for type '' */ +#ifndef SOAP_TYPE_SOAP_ENV__Header +#define SOAP_TYPE_SOAP_ENV__Header (11) +#endif + +/* struct ns1__executeCommand has binding name 'ns1__executeCommand' for type 'ns1:executeCommand' */ +#ifndef SOAP_TYPE_ns1__executeCommand +#define SOAP_TYPE_ns1__executeCommand (10) +#endif + +/* struct ns1__executeCommandResponse has binding name 'ns1__executeCommandResponse' for type 'ns1:executeCommandResponse' */ +#ifndef SOAP_TYPE_ns1__executeCommandResponse +#define SOAP_TYPE_ns1__executeCommandResponse (9) +#endif + +/* struct SOAP_ENV__Reason * has binding name 'PointerToSOAP_ENV__Reason' for type '' */ +#ifndef SOAP_TYPE_PointerToSOAP_ENV__Reason +#define SOAP_TYPE_PointerToSOAP_ENV__Reason (20) +#endif + +/* struct SOAP_ENV__Detail * has binding name 'PointerToSOAP_ENV__Detail' for type '' */ +#ifndef SOAP_TYPE_PointerToSOAP_ENV__Detail +#define SOAP_TYPE_PointerToSOAP_ENV__Detail (19) +#endif + +/* struct SOAP_ENV__Code * has binding name 'PointerToSOAP_ENV__Code' for type '' */ +#ifndef SOAP_TYPE_PointerToSOAP_ENV__Code +#define SOAP_TYPE_PointerToSOAP_ENV__Code (13) +#endif + +/* char ** has binding name 'PointerTostring' for type 'xsd:string' */ +#ifndef SOAP_TYPE_PointerTostring +#define SOAP_TYPE_PointerTostring (7) +#endif + +/* _XML has binding name '_XML' for type '' */ +#ifndef SOAP_TYPE__XML +#define SOAP_TYPE__XML (6) +#endif + +/* _QName has binding name '_QName' for type 'xsd:QName' */ +#ifndef SOAP_TYPE__QName +#define SOAP_TYPE__QName (5) +#endif + +/* char * has binding name 'string' for type 'xsd:string' */ +#ifndef SOAP_TYPE_string +#define SOAP_TYPE_string (4) +#endif /******************************************************************************\ * * @@ -188,8 +341,8 @@ typedef char *_XML; * * \******************************************************************************/ - -SOAP_FMAC5 int SOAP_FMAC6 ns1__executeCommand(struct soap*, char *command, char **result); + /** Web service operation 'ns1__executeCommand' (returns SOAP_OK or error code) */ + SOAP_FMAC5 int SOAP_FMAC6 ns1__executeCommand(struct soap*, char *command, char **result); /******************************************************************************\ * * diff --git a/dep/gsoap/stdsoap2.cpp b/dep/gsoap/stdsoap2.cpp index 6186f8904e3..bec1d4b02a5 100644 --- a/dep/gsoap/stdsoap2.cpp +++ b/dep/gsoap/stdsoap2.cpp @@ -1,10 +1,10 @@ /* - stdsoap2.c[pp] 2.8.17r + stdsoap2.c[pp] 2.8.33 - gSOAP runtime engine + gSOAP runtime engine gSOAP XML Web services tools -Copyright (C) 2000-2013, Robert van Engelen, Genivia Inc., All Rights Reserved. +Copyright (C) 2000-2016, Robert van Engelen, Genivia Inc., All Rights Reserved. This part of the software is released under ONE of the following licenses: GPL, or the gSOAP public license, or Genivia's license for commercial use. -------------------------------------------------------------------------------- @@ -24,7 +24,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. The Initial Developer of the Original Code is Robert A. van Engelen. -Copyright (C) 2000-2013, Robert van Engelen, Genivia Inc., All Rights Reserved. +Copyright (C) 2000-2016, Robert van Engelen, Genivia Inc., All Rights Reserved. -------------------------------------------------------------------------------- GPL license. @@ -51,43 +51,52 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com -------------------------------------------------------------------------------- */ -#define GSOAP_LIB_VERSION 20817 +#define GSOAP_LIB_VERSION 20833 #ifdef AS400 -# pragma convert(819) /* EBCDIC to ASCII */ +# pragma convert(819) /* EBCDIC to ASCII */ #endif #include "stdsoap2.h" -#if defined(VXWORKS) && defined(WM_SECURE_KEY_STORAGE) -#include <ipcom_key_db.h> -#endif + #if GSOAP_VERSION != GSOAP_LIB_VERSION # error "GSOAP VERSION MISMATCH IN LIBRARY: PLEASE REINSTALL PACKAGE" #endif +#if defined(VXWORKS) && defined(WM_SECURE_KEY_STORAGE) +# include <ipcom_key_db.h> +#endif + #ifdef __BORLANDC__ # pragma warn -8060 #else # ifdef WIN32 # ifdef UNDER_CE -# pragma comment(lib, "ws2.lib") /* WinCE */ +# pragma comment(lib, "ws2.lib") /* WinCE */ # else -# pragma comment(lib, "ws2_32.lib") +# pragma comment(lib, "Ws2_32.lib") # endif # pragma warning(disable : 4996) /* disable deprecation warnings */ # endif #endif #ifdef __cplusplus -SOAP_SOURCE_STAMP("@(#) stdsoap2.cpp ver 2.8.17r 2013-12-18 00:00:00 GMT") +SOAP_SOURCE_STAMP("@(#) stdsoap2.cpp ver 2.8.33 2016-06-14 00:00:00 GMT") extern "C" { #else -SOAP_SOURCE_STAMP("@(#) stdsoap2.c ver 2.8.17r 2013-12-18 00:00:00 GMT") +SOAP_SOURCE_STAMP("@(#) stdsoap2.c ver 2.8.32 2016-06-14 00:00:00 GMT") #endif -/* 8bit character representing unknown/nonrepresentable character data (e.g. not supported by current locale with multibyte support enabled) */ +/* 8bit character representing unknown character entity or multibyte data */ #ifndef SOAP_UNKNOWN_CHAR -#define SOAP_UNKNOWN_CHAR (127) +# define SOAP_UNKNOWN_CHAR (0x7F) +#endif + +/* unicode character representing unknown characters outside the XML 1.0 UTF8 unicode space */ +#ifdef WITH_REPLACE_ILLEGAL_UTF8 +# ifndef SOAP_UNKNOWN_UNICODE_CHAR +# define SOAP_UNKNOWN_UNICODE_CHAR (0xFFFD) +# endif #endif /* EOF=-1 */ @@ -97,13 +106,13 @@ SOAP_SOURCE_STAMP("@(#) stdsoap2.c ver 2.8.17r 2013-12-18 00:00:00 GMT") #define SOAP_QT (soap_wchar)(-5) /* XML-specific '"' */ #define SOAP_AP (soap_wchar)(-6) /* XML-specific ''' */ -#define soap_blank(c) ((c)+1 > 0 && (c) <= 32) -#define soap_notblank(c) ((c) > 32) +#define soap_blank(c) ((c)+1 > 0 && (c) <= 32) +#define soap_notblank(c) ((c) > 32) #if defined(WIN32) && !defined(UNDER_CE) -#define soap_hash_ptr(p) ((PtrToUlong(p) >> 3) & (SOAP_PTRHASH - 1)) +#define soap_hash_ptr(p) ((PtrToUlong(p) >> 3) & (SOAP_PTRHASH - 1)) #else -#define soap_hash_ptr(p) ((size_t)(((unsigned long)(p) >> 3) & (SOAP_PTRHASH-1))) +#define soap_hash_ptr(p) ((size_t)(((unsigned long)(p) >> 3) & (SOAP_PTRHASH-1))) #endif #if !defined(WITH_LEAN) || defined(SOAP_DEBUG) @@ -123,7 +132,7 @@ static void soap_track_unlink(struct soap*, const void*); #ifndef PALM_2 static int soap_set_error(struct soap*, const char*, const char*, const char*, const char*, int); static int soap_copy_fault(struct soap*, const char*, const char*, const char*, const char*); -static int soap_getattrval(struct soap*, char*, size_t, soap_wchar); +static int soap_getattrval(struct soap*, char*, size_t*, soap_wchar); #endif #ifndef PALM_1 @@ -139,18 +148,26 @@ static int soap_ntlm_handshake(struct soap *soap, int command, const char *endpo #endif #ifndef WITH_NOIDREF static int soap_has_copies(struct soap*, const char*, const char*); +static int soap_type_punned(struct soap*, const struct soap_ilist*); +static int soap_is_shaky(struct soap*, void*); static void soap_init_iht(struct soap*); static void soap_free_iht(struct soap*); +#endif static void soap_init_pht(struct soap*); static void soap_free_pht(struct soap*); #endif -#endif #ifndef WITH_LEAN static const char *soap_set_validation_fault(struct soap*, const char*, const char*); static int soap_isnumeric(struct soap*, const char*); static struct soap_nlist *soap_push_ns(struct soap *soap, const char *id, const char *ns, short utilized); static void soap_utilize_ns(struct soap *soap, const char *tag); +static const wchar_t* soap_wstring(struct soap *soap, const char *s, long minlen, long maxlen, const char *pattern); +#endif + +#ifndef PALM_2 +static const char* soap_string(struct soap *soap, const char *s, long minlen, long maxlen, const char *pattern); +static const char* soap_QName(struct soap *soap, const char *s, long minlen, long maxlen, const char *pattern); #endif #ifndef WITH_LEANER @@ -184,6 +201,7 @@ static int ssl_password(char*, int, int, void *); # define SOAP_SSL_RSA_BITS 2048 # endif static int soap_ssl_init_done = 0; +static int ssl_auth_init(struct soap*); static const char *ssl_verify(struct soap *soap, const char *host); # if defined(HAVE_PTHREAD_H) # include <pthread.h> @@ -196,6 +214,12 @@ static const char *ssl_verify(struct soap *soap, const char *host); # endif #endif +#ifdef WITH_SYSTEMSSL +static int ssl_auth_init(struct soap*); +static int ssl_recv(int sk, void *s, int n, char *user); +static int ssl_send(int sk, void *s, int n, char *user); +#endif + #if !defined(WITH_NOHTTP) || !defined(WITH_LEANER) #ifndef PALM_1 static const char *soap_decode(char*, size_t, const char*, const char*); @@ -307,9 +331,9 @@ const char soap_base64i[81] = "\76XXX\77\64\65\66\67\70\71\72\73\74\75XXXXXXX\00 #endif #ifndef WITH_LEAN -static const char soap_indent[11] = "\n\t\t\t\t\t\t\t\t\t"; +static const char soap_indent[21] = "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"; /* Alternative indentation form for SOAP_XML_INDENT: -static const char soap_indent[21] = "\n "; +static const char soap_indent[41] = "\n "; */ #endif @@ -511,14 +535,14 @@ static const struct soap_code_map h_ssl_error_codes[] = #ifndef WITH_LEANER static const struct soap_code_map mime_codes[] = -{ { SOAP_MIME_7BIT, "7bit" }, - { SOAP_MIME_8BIT, "8bit" }, - { SOAP_MIME_BINARY, "binary" }, +{ { SOAP_MIME_7BIT, "7bit" }, + { SOAP_MIME_8BIT, "8bit" }, + { SOAP_MIME_BINARY, "binary" }, { SOAP_MIME_QUOTED_PRINTABLE, "quoted-printable" }, - { SOAP_MIME_BASE64, "base64" }, - { SOAP_MIME_IETF_TOKEN, "ietf-token" }, - { SOAP_MIME_X_TOKEN, "x-token" }, - { 0, NULL } + { SOAP_MIME_BASE64, "base64" }, + { SOAP_MIME_IETF_TOKEN, "ietf-token" }, + { SOAP_MIME_X_TOKEN, "x-token" }, + { 0, NULL } }; #endif @@ -531,13 +555,14 @@ extern int h_errno; #endif /******************************************************************************/ + #ifndef WITH_NOIO #ifndef PALM_1 static int fsend(struct soap *soap, const char *s, size_t n) -{ register int nwritten, err; +{ int nwritten, err; SOAP_SOCKET sk; -#if defined(__cplusplus) && !defined(WITH_LEAN) && !defined(WITH_COMPAT) +#if defined(__cplusplus) && !defined(WITH_COMPAT) if (soap->os) { soap->os->write(s, (std::streamsize)n); if (soap->os->good()) @@ -554,7 +579,7 @@ fsend(struct soap *soap, const char *s, size_t n) { if (soap->send_timeout) { for (;;) - { register int r; + { int r; #ifdef WITH_OPENSSL if (soap->ssl) r = tcp_select(soap, sk, SOAP_TCP_SELECT_ALL, soap->send_timeout); @@ -565,6 +590,11 @@ fsend(struct soap *soap, const char *s, size_t n) r = tcp_select(soap, sk, SOAP_TCP_SELECT_ALL, soap->send_timeout); else #endif +#ifdef WITH_SYSTEMSSL + if (soap->ssl) + r = tcp_select(soap, sk, SOAP_TCP_SELECT_ALL, soap->send_timeout); + else +#endif r = tcp_select(soap, sk, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, soap->send_timeout); if (r > 0) break; @@ -589,10 +619,18 @@ fsend(struct soap *soap, const char *s, size_t n) nwritten = gnutls_record_send(soap->session, s, n); else #endif +#ifdef WITH_SYSTEMSSL + if (soap->ssl) + { err = gsk_secure_socket_write(soap->ssl, (char*)s, n, &nwritten); + if (err != GSK_OK) + nwritten = 0; + } + else +#endif #ifndef WITH_LEAN if ((soap->omode & SOAP_IO_UDP)) { if (soap->peerlen) - nwritten = sendto(sk, (char*)s, (SOAP_WINSOCKINT)n, soap->socket_flags, (struct sockaddr*)&soap->peer, (SOAP_WINSOCKINT)soap->peerlen); + nwritten = sendto(sk, (char*)s, (SOAP_WINSOCKINT)n, soap->socket_flags, &soap->peer.addr, (SOAP_WINSOCKINT)soap->peerlen); else nwritten = send(sk, s, (SOAP_WINSOCKINT)n, soap->socket_flags); /* retry and back-off algorithm */ @@ -608,14 +646,13 @@ fsend(struct soap *soap, const char *s, size_t n) do { tcp_select(soap, sk, SOAP_TCP_SELECT_ERR, -1000 * udp_delay); if (soap->peerlen) - nwritten = sendto(sk, (char*)s, (SOAP_WINSOCKINT)n, soap->socket_flags, (struct sockaddr*)&soap->peer, (SOAP_WINSOCKINT)soap->peerlen); + nwritten = sendto(sk, (char*)s, (SOAP_WINSOCKINT)n, soap->socket_flags, &soap->peer.addr, (SOAP_WINSOCKINT)soap->peerlen); else nwritten = send(sk, s, (SOAP_WINSOCKINT)n, soap->socket_flags); udp_delay <<= 1; if (udp_delay > 500) /* UDP_UPPER_DELAY */ udp_delay = 500; - } - while (nwritten < 0 && --udp_repeat > 0); + } while (nwritten < 0 && --udp_repeat > 0); } if (nwritten < 0) { err = soap_socket_errno(sk); @@ -635,7 +672,7 @@ fsend(struct soap *soap, const char *s, size_t n) #endif if (nwritten <= 0) { - register int r = 0; + int r = 0; err = soap_socket_errno(sk); #ifdef WITH_OPENSSL if (soap->ssl && (r = SSL_get_error(soap->ssl, nwritten)) != SSL_ERROR_NONE && r != SSL_ERROR_WANT_READ && r != SSL_ERROR_WANT_WRITE) @@ -723,6 +760,7 @@ fsend(struct soap *soap, const char *s, size_t n) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int @@ -731,25 +769,25 @@ soap_send_raw(struct soap *soap, const char *s, size_t n) { if (!n) return SOAP_OK; #ifndef WITH_LEANER - if (soap->fpreparesend && (soap->mode & SOAP_IO) != SOAP_IO_STORE && (soap->mode & SOAP_IO_LENGTH) && (soap->error = soap->fpreparesend(soap, s, n))) + if (soap->fpreparesend && (soap->mode & SOAP_IO) != SOAP_IO_STORE && (soap->mode & SOAP_IO_LENGTH) && (soap->error = soap->fpreparesend(soap, s, n)) != SOAP_OK) return soap->error; - if (soap->ffiltersend && (soap->error = soap->ffiltersend(soap, &s, &n))) + if (soap->ffiltersend && (soap->error = soap->ffiltersend(soap, &s, &n)) != SOAP_OK) return soap->error; #endif - if (soap->mode & SOAP_IO_LENGTH) + if ((soap->mode & SOAP_IO_LENGTH)) soap->count += n; else if (soap->mode & SOAP_IO) - { register size_t i = SOAP_BUFLEN - soap->bufidx; + { size_t i = sizeof(soap->buf) - soap->bufidx; while (n >= i) - { memcpy(soap->buf + soap->bufidx, s, i); - soap->bufidx = SOAP_BUFLEN; + { soap_memcpy((void*)(soap->buf + soap->bufidx), i, (const void*)s, i); + soap->bufidx = sizeof(soap->buf); if (soap_flush(soap)) return soap->error; s += i; n -= i; - i = SOAP_BUFLEN; + i = sizeof(soap->buf); } - memcpy(soap->buf + soap->bufidx, s, n); + soap_memcpy((void*)(soap->buf + soap->bufidx), sizeof(soap->buf) - soap->bufidx, (const void*)s, n); soap->bufidx += n; } else @@ -759,18 +797,19 @@ soap_send_raw(struct soap *soap, const char *s, size_t n) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 soap_flush(struct soap *soap) -{ register size_t n = soap->bufidx; +{ size_t n = soap->bufidx; if (n) { #ifndef WITH_LEANER if ((soap->mode & SOAP_IO) == SOAP_IO_STORE) - { register int r; - if (soap->fpreparesend && (r = soap->fpreparesend(soap, soap->buf, n))) + { int r; + if (soap->fpreparesend && (r = soap->fpreparesend(soap, soap->buf, n)) != SOAP_OK) return soap->error = r; } #endif @@ -789,10 +828,10 @@ soap_flush(struct soap *soap) return soap->error = SOAP_ZLIB_ERROR; } if (!soap->d_stream->avail_out) - { if (soap_flush_raw(soap, soap->z_buf, SOAP_BUFLEN)) + { if (soap_flush_raw(soap, soap->z_buf, sizeof(soap->buf))) return soap->error; soap->d_stream->next_out = (Byte*)soap->z_buf; - soap->d_stream->avail_out = SOAP_BUFLEN; + soap->d_stream->avail_out = sizeof(soap->buf); } } while (soap->d_stream->avail_in); } @@ -805,28 +844,27 @@ soap_flush(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 soap_flush_raw(struct soap *soap, const char *s, size_t n) { if ((soap->mode & SOAP_IO) == SOAP_IO_STORE) - { register char *t; - if (!(t = (char*)soap_push_block(soap, NULL, n))) + { void *t; + t = soap_push_block(soap, NULL, n); + if (!t) return soap->error = SOAP_EOM; - memcpy(t, s, n); + soap_memcpy(t, n, (const void*)s, n); return SOAP_OK; } #ifndef WITH_LEANER if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) - { char t[16]; -#ifdef HAVE_SNPRINTF - soap_snprintf(t, sizeof(t), &"\r\n%lX\r\n"[soap->chunksize ? 0 : 2], (unsigned long)n); -#else - sprintf(t, &"\r\n%lX\r\n"[soap->chunksize ? 0 : 2], (unsigned long)n); -#endif + { char t[24]; + (SOAP_SNPRINTF(t, sizeof(t), 20), &"\r\n%lX\r\n"[soap->chunksize ? 0 : 2], (unsigned long)n); DBGMSG(SENT, t, strlen(t)); - if ((soap->error = soap->fsend(soap, t, strlen(t)))) + soap->error = soap->fsend(soap, t, strlen(t)); + if (soap->error) return soap->error; soap->chunksize += n; } @@ -838,6 +876,7 @@ soap_flush_raw(struct soap *soap, const char *s, size_t n) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int @@ -850,6 +889,7 @@ soap_send(struct soap *soap, const char *s) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 @@ -864,6 +904,7 @@ soap_send2(struct soap *soap, const char *s1, const char *s2) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 @@ -879,20 +920,30 @@ soap_send3(struct soap *soap, const char *s1, const char *s2, const char *s3) #endif /******************************************************************************/ + #ifndef WITH_NOIO #ifndef PALM_1 static size_t frecv(struct soap *soap, char *s, size_t n) -{ register int r; - register int retries = 100; /* max 100 retries with non-blocking sockets */ +{ int r; + int retries = 100; /* max 100 retries with non-blocking sockets */ SOAP_SOCKET sk; soap->errnum = 0; -#if defined(__cplusplus) && !defined(WITH_LEAN) && !defined(WITH_COMPAT) - if (soap->is) +#if defined(__cplusplus) && !defined(WITH_COMPAT) + if (soap->is) /* recv from C++ stream */ { if (soap->is->good()) - return soap->is->read(s, (std::streamsize)n).gcount(); + return (size_t)soap->is->read(s, (std::streamsize)n).gcount(); return 0; } +#else + if (soap->is) /* recv from C buffer until NUL */ + { size_t l = strlen(soap->is); + if (l > n) + l = n; + soap_memcpy(s, n, soap->is, l); + soap->is += l; + return l; + } #endif sk = soap->recvsk; if (!soap_valid_socket(sk)) @@ -900,11 +951,11 @@ frecv(struct soap *soap, char *s, size_t n) if (soap_valid_socket(sk)) { for (;;) { -#ifdef WITH_OPENSSL - register int err = 0; +#if defined(WITH_OPENSSL) || defined(WITH_SYSTEMSSL) + int err = 0; #endif #ifdef WITH_OPENSSL - if (soap->recv_timeout && !soap->ssl) /* SSL: sockets are nonblocking */ + if (soap->recv_timeout && !soap->ssl) /* OpenSSL: sockets are nonblocking so go ahead to read */ #else if (soap->recv_timeout) #endif @@ -944,20 +995,30 @@ frecv(struct soap *soap, char *s, size_t n) } else #endif +#ifdef WITH_SYSTEMSSL + if (soap->ssl) + { err = gsk_secure_socket_read(soap->ssl, s, n, &r); + if (err == GSK_OK && r > 0) + return (size_t)r; + if (err != GSK_OK && err != GSK_WOULD_BLOCK && err != GSK_WOULD_BLOCK_WRITE) + return 0; + } + else +#endif { #ifndef WITH_LEAN if ((soap->omode & SOAP_IO_UDP)) { SOAP_SOCKLEN_T k = (SOAP_SOCKLEN_T)sizeof(soap->peer); memset((void*)&soap->peer, 0, sizeof(soap->peer)); - r = recvfrom(sk, s, (SOAP_WINSOCKINT)n, soap->socket_flags, (struct sockaddr*)&soap->peer, &k); /* portability note: see SOAP_SOCKLEN_T definition in stdsoap2.h */ + r = recvfrom(sk, s, (SOAP_WINSOCKINT)n, soap->socket_flags, &soap->peer.addr, &k); /* portability note: see SOAP_SOCKLEN_T definition in stdsoap2.h */ soap->peerlen = (size_t)k; #ifndef WITH_IPV6 - soap->ip = ntohl(soap->peer.sin_addr.s_addr); + soap->ip = ntohl(soap->peer.in.sin_addr.s_addr); #endif } else #endif - r = recv(sk, s, (int)n, soap->socket_flags); + r = recv(sk, s, (SOAP_WINSOCKINT)n, soap->socket_flags); #ifdef PALM /* CycleSyncDisplay(curStatusMsg); */ #endif @@ -977,6 +1038,10 @@ frecv(struct soap *soap, char *s, size_t n) if (soap->session && gnutls_record_get_direction(soap->session)) r = tcp_select(soap, sk, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, soap->recv_timeout ? soap->recv_timeout : 5); else +#elif defined(WITH_SYSTEMSSL) + if (soap->ssl && err == GSK_WOULD_BLOCK_WRITE) + r = tcp_select(soap, sk, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, soap->recv_timeout ? soap->recv_timeout : 5); + else #endif r = tcp_select(soap, sk, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, soap->recv_timeout ? soap->recv_timeout : 5); if (!r && soap->recv_timeout) @@ -1011,7 +1076,7 @@ frecv(struct soap *soap, char *s, size_t n) #ifdef WIN32 r = _read(soap->recvfd, s, (unsigned int)n); #else - r = read(soap->recvfd, s, (unsigned int)n); + r = read(soap->recvfd, s, n); #endif if (r >= 0) return (size_t)r; @@ -1024,6 +1089,7 @@ frecv(struct soap *soap, char *s, size_t n) #endif /******************************************************************************/ + #ifndef WITH_NOHTTP #ifndef PALM_1 static soap_wchar @@ -1031,7 +1097,7 @@ soap_getchunkchar(struct soap *soap) { if (soap->bufidx < soap->buflen) return soap->buf[soap->bufidx++]; soap->bufidx = 0; - soap->buflen = soap->chunkbuflen = soap->frecv(soap, soap->buf, SOAP_BUFLEN); + soap->buflen = soap->chunkbuflen = soap->frecv(soap, soap->buf, sizeof(soap->buf)); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Read %u bytes from socket=%d/fd=%d\n", (unsigned int)soap->buflen, soap->socket, soap->recvfd)); DBGMSG(RECV, soap->buf, soap->buflen); if (soap->buflen) @@ -1042,6 +1108,7 @@ soap_getchunkchar(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_1 static int soap_isxdigit(int c) @@ -1050,17 +1117,18 @@ soap_isxdigit(int c) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 soap_recv_raw(struct soap *soap) -{ register size_t ret; +{ size_t ret; #if !defined(WITH_LEANER) || defined(WITH_ZLIB) - register int r; + int r; #endif #ifdef WITH_ZLIB - if (soap->mode & SOAP_ENC_ZLIB) + if ((soap->mode & SOAP_ENC_ZLIB) && soap->d_stream) { if (soap->d_stream->next_out == Z_NULL) { soap->bufidx = soap->buflen = 0; return EOF; @@ -1068,13 +1136,13 @@ soap_recv_raw(struct soap *soap) if (soap->d_stream->avail_in || !soap->d_stream->avail_out) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflating\n")); soap->d_stream->next_out = (Byte*)soap->buf; - soap->d_stream->avail_out = SOAP_BUFLEN; + soap->d_stream->avail_out = sizeof(soap->buf); r = inflate(soap->d_stream, Z_NO_FLUSH); if (r == Z_NEED_DICT && soap->z_dict) r = inflateSetDictionary(soap->d_stream, (const Bytef*)soap->z_dict, soap->z_dict_len); if (r == Z_OK || r == Z_STREAM_END) { soap->bufidx = 0; - ret = soap->buflen = SOAP_BUFLEN - soap->d_stream->avail_out; + ret = soap->buflen = sizeof(soap->buf) - soap->d_stream->avail_out; if (soap->zlib_in == SOAP_ZLIB_GZIP) soap->z_crc = crc32(soap->z_crc, (Byte*)soap->buf, (unsigned int)ret); if (r == Z_STREAM_END) @@ -1084,11 +1152,15 @@ soap_recv_raw(struct soap *soap) } if (ret) { soap->count += ret; + if (soap->count > SOAP_MAXINFLATESIZE && soap->z_ratio_in < SOAP_MINDEFLATERATIO) + { soap->d_stream->msg = (char*)"caught SOAP_MINDEFLATERATIO explosive decompression guard (remedy: increase SOAP_MAXINFLATESIZE and/or decrease SOAP_MINDEFLATERATIO)"; + return soap->error = SOAP_ZLIB_ERROR; + } DBGLOG(RECV, SOAP_MESSAGE(fdebug, "\n---- decompressed ----\n")); DBGMSG(RECV, soap->buf, ret); DBGLOG(RECV, SOAP_MESSAGE(fdebug, "\n----\n")); #ifndef WITH_LEANER - if (soap->fpreparerecv && (r = soap->fpreparerecv(soap, soap->buf, ret))) + if (soap->fpreparerecv && (r = soap->fpreparerecv(soap, soap->buf, ret)) != SOAP_OK) return soap->error = r; #endif return SOAP_OK; @@ -1102,7 +1174,7 @@ soap_recv_raw(struct soap *soap) } zlib_again: if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK && !soap->chunksize) - { memcpy(soap->buf, soap->z_buf, SOAP_BUFLEN); + { soap_memcpy((void*)soap->buf, sizeof(soap->buf), (const void*)soap->z_buf, sizeof(soap->buf)); soap->buflen = soap->z_buflen; } DBGLOG(RECV, SOAP_MESSAGE(fdebug, "\n---- compressed ----\n")); @@ -1111,10 +1183,10 @@ zlib_again: #ifndef WITH_NOHTTP if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) /* read HTTP chunked transfer */ { for (;;) - { register soap_wchar c; + { soap_wchar c; char *t, tmp[17]; if (soap->chunksize) - { soap->buflen = ret = soap->frecv(soap, soap->buf, soap->chunksize > SOAP_BUFLEN ? SOAP_BUFLEN : soap->chunksize); + { soap->buflen = ret = soap->frecv(soap, soap->buf, soap->chunksize > sizeof(soap->buf) ? sizeof(soap->buf) : soap->chunksize); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Getting chunk: read %u bytes\n", (unsigned int)ret)); DBGMSG(RECV, soap->buf, ret); soap->bufidx = 0; @@ -1123,7 +1195,7 @@ zlib_again: } t = tmp; if (!soap->chunkbuflen) - { soap->chunkbuflen = ret = soap->frecv(soap, soap->buf, SOAP_BUFLEN); + { soap->chunkbuflen = ret = soap->frecv(soap, soap->buf, sizeof(soap->buf)); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Read %u bytes (chunked) from socket=%d\n", (unsigned int)ret, soap->socket)); DBGMSG(RECV, soap->buf, ret); soap->bufidx = 0; @@ -1157,8 +1229,6 @@ zlib_again: if (!soap->chunksize) { soap->bufidx = soap->buflen = soap->chunkbuflen = 0; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of chunked message\n")); - while ((int)c != EOF && c != '\n') - c = soap_getchunkchar(soap); ret = 0; soap->ahead = EOF; break; @@ -1181,24 +1251,24 @@ zlib_again: else #endif { soap->bufidx = 0; - soap->buflen = ret = soap->frecv(soap, soap->buf, SOAP_BUFLEN); + soap->buflen = ret = soap->frecv(soap, soap->buf, sizeof(soap->buf)); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Read %u bytes from socket=%d/fd=%d\n", (unsigned int)ret, soap->socket, soap->recvfd)); DBGMSG(RECV, soap->buf, ret); } #ifdef WITH_ZLIB if (soap->mode & SOAP_ENC_ZLIB) - { memcpy(soap->z_buf, soap->buf, SOAP_BUFLEN); + { soap_memcpy((void*)soap->z_buf, sizeof(soap->buf), (const void*)soap->buf, sizeof(soap->buf)); soap->d_stream->next_in = (Byte*)(soap->z_buf + soap->bufidx); soap->d_stream->avail_in = (unsigned int)ret; soap->d_stream->next_out = (Byte*)soap->buf; - soap->d_stream->avail_out = SOAP_BUFLEN; + soap->d_stream->avail_out = sizeof(soap->buf); r = inflate(soap->d_stream, Z_NO_FLUSH); if (r == Z_NEED_DICT && soap->z_dict) r = inflateSetDictionary(soap->d_stream, (const Bytef*)soap->z_dict, soap->z_dict_len); if (r == Z_OK || r == Z_STREAM_END) { soap->bufidx = 0; soap->z_buflen = soap->buflen; - soap->buflen = SOAP_BUFLEN - soap->d_stream->avail_out; + soap->buflen = sizeof(soap->buf) - soap->d_stream->avail_out; if (soap->zlib_in == SOAP_ZLIB_GZIP) soap->z_crc = crc32(soap->z_crc, (Byte*)soap->buf, (unsigned int)soap->buflen); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflated %u bytes\n", (unsigned int)soap->buflen)); @@ -1210,10 +1280,14 @@ zlib_again: soap->z_ratio_in = (float)soap->d_stream->total_in / (float)soap->d_stream->total_out; soap->d_stream->next_out = Z_NULL; } + if (soap->count + ret > SOAP_MAXINFLATESIZE && soap->z_ratio_in < SOAP_MINDEFLATERATIO) + { soap->d_stream->msg = (char*)"caught SOAP_MINDEFLATERATIO explosive decompression guard (remedy: increase SOAP_MAXINFLATESIZE and/or decrease SOAP_MINDEFLATERATIO)"; + return soap->error = SOAP_ZLIB_ERROR; + } DBGLOG(RECV, SOAP_MESSAGE(fdebug, "\n---- decompressed ----\n")); DBGMSG(RECV, soap->buf, ret); #ifndef WITH_LEANER - if (soap->fpreparerecv && (r = soap->fpreparerecv(soap, soap->buf, ret))) + if (soap->fpreparerecv && (r = soap->fpreparerecv(soap, soap->buf, ret)) != SOAP_OK) return soap->error = r; #endif } @@ -1232,13 +1306,17 @@ zlib_again: && (r = soap->fpreparerecv(soap, soap->buf + soap->bufidx, ret))) return soap->error = r; #endif - soap->count += ret; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Read count=%lu (+%lu)\n", (unsigned long)soap->count, (unsigned long)ret)); - return !ret; + if (ret) + { soap->count += ret; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Read count=%lu (+%lu)\n", (unsigned long)soap->count, (unsigned long)ret)); + return SOAP_OK; + } + return EOF; } #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int @@ -1307,35 +1385,42 @@ soap_recv(struct soap *soap) } } while (soap->ffilterrecv) - { int err, last = soap->filterstop; - if (last) + { int err; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Filter recverror = %d\n", soap->recverror)); + if (soap->recverror) soap->bufidx = soap->buflen = 0; - if ((err = soap->ffilterrecv(soap, soap->buf, &soap->buflen, sizeof(soap->buf)))) + else + { soap->recverror = soap_recv_raw(soap); /* do not call again after EOF */ + soap->buflen -= soap->bufidx; /* chunked may set bufidx > 0 to skip hex chunk length */ + } + err = soap->ffilterrecv(soap, soap->buf + soap->bufidx, &soap->buflen, sizeof(soap->buf) - soap->bufidx); + if (err) return soap->error = err; if (soap->buflen) - { soap->bufidx = 0; - soap->filterstop = last; + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Filtered %lu\n", (unsigned long)soap->buflen)); + soap->buflen += soap->bufidx; return SOAP_OK; } - if (last) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Returning postponed error %d\n", last)); - soap->filterstop = SOAP_OK; - return last; + if (soap->recverror) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Returning postponed EOF%d\n", soap->recverror)); + return soap->recverror; } - soap->filterstop = soap_recv_raw(soap); /* do not call again after EOF */ } -#endif + return soap->recverror = soap_recv_raw(soap); +#else return soap_recv_raw(soap); +#endif } #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 soap_wchar SOAP_FMAC2 soap_getchar(struct soap *soap) -{ register soap_wchar c; +{ soap_wchar c; c = soap->ahead; if (c) { if (c != EOF) @@ -1347,6 +1432,7 @@ soap_getchar(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 const struct soap_code_map* @@ -1364,11 +1450,12 @@ soap_code(const struct soap_code_map *code_map, const char *str) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 -long +LONG64 SOAP_FMAC2 -soap_code_int(const struct soap_code_map *code_map, const char *str, long other) +soap_code_int(const struct soap_code_map *code_map, const char *str, LONG64 other) { if (code_map) { while (code_map->string) { if (!soap_tag_cmp(str, code_map->string)) /* case insensitive */ @@ -1381,6 +1468,7 @@ soap_code_int(const struct soap_code_map *code_map, const char *str, long other) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 const char* @@ -1395,17 +1483,18 @@ soap_code_str(const struct soap_code_map *code_map, long code) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 -long +LONG64 SOAP_FMAC2 soap_code_bits(const struct soap_code_map *code_map, const char *str) -{ register long bits = 0; +{ LONG64 bits = 0; if (code_map) { while (str && *str) { const struct soap_code_map *p; for (p = code_map; p->string; p++) - { register size_t n = strlen(p->string); + { size_t n = strlen(p->string); if (!strncmp(p->string, str, n) && soap_blank((soap_wchar)str[n])) { bits |= p->code; str += n; @@ -1423,16 +1512,17 @@ soap_code_bits(const struct soap_code_map *code_map, const char *str) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 const char* SOAP_FMAC2 soap_code_list(struct soap *soap, const struct soap_code_map *code_map, long code) -{ register char *t = soap->tmpbuf; +{ char *t = soap->tmpbuf; if (code_map) { while (code_map->string) { if (code_map->code & code) - { register const char *s = code_map->string; + { const char *s = code_map->string; if (t != soap->tmpbuf) *t++ = ' '; while (*s && t < soap->tmpbuf + sizeof(soap->tmpbuf) - 1) @@ -1449,13 +1539,14 @@ soap_code_list(struct soap *soap, const struct soap_code_map *code_map, long cod #endif /******************************************************************************/ + #ifndef PALM_1 static soap_wchar soap_char(struct soap *soap) { char tmp[8]; - register int i; - register soap_wchar c; - register char *s = tmp; + int i; + soap_wchar c; + char *s = tmp; for (i = 0; i < 7; i++) { c = soap_get1(soap); if (c == ';' || (int)c == EOF) @@ -1479,7 +1570,7 @@ soap_char(struct soap *soap) if (!strcmp(tmp, "apos")) return '\''; #ifndef WITH_LEAN - return (soap_wchar)soap_code_int(html_entity_codes, tmp, SOAP_UNKNOWN_CHAR); + return (soap_wchar)soap_code_int(html_entity_codes, tmp, (LONG64)SOAP_UNKNOWN_CHAR); #else return SOAP_UNKNOWN_CHAR; /* use this to represent unknown code */ #endif @@ -1487,6 +1578,7 @@ soap_char(struct soap *soap) #endif /******************************************************************************/ + #ifdef WITH_LEAN #ifndef PALM_1 soap_wchar @@ -1499,6 +1591,7 @@ soap_get0(struct soap *soap) #endif /******************************************************************************/ + #ifdef WITH_LEAN #ifndef PALM_1 soap_wchar @@ -1511,12 +1604,13 @@ soap_get1(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 soap_wchar SOAP_FMAC2 soap_get(struct soap *soap) -{ register soap_wchar c; +{ soap_wchar c; c = soap->ahead; if (c) { if ((int)c != EOF) @@ -1553,7 +1647,7 @@ soap_get(struct soap *soap) do c = soap_get1(soap); while (soap_blank(c)); if (c == '!' || c == '?' || c == '%') - { register int k = 1; + { int k = 1; if (c == '!') { c = soap_get1(soap); if (c == '[') @@ -1609,13 +1703,14 @@ soap_get(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_1 static soap_wchar soap_get_pi(struct soap *soap) { char buf[64]; - register char *s = buf; - register int i = sizeof(buf); - register soap_wchar c = soap_getchar(soap); + char *s = buf; + int i = sizeof(buf); + soap_wchar c = soap_getchar(soap); /* This is a quick way to parse XML PI and we could use a callback instead to * enable applications to intercept processing instructions */ while ((int)c != EOF && c != '?') @@ -1649,6 +1744,7 @@ soap_get_pi(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 @@ -1665,6 +1761,7 @@ soap_move(struct soap *soap, size_t n) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 @@ -1677,19 +1774,24 @@ soap_tell(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 -soap_pututf8(struct soap *soap, register unsigned long c) -{ char tmp[16]; - if (c < 0x80 && c > 0) +soap_pututf8(struct soap *soap, unsigned long c) +{ char tmp[24]; + if ((c < 0x7F && c > 0x1F)) { *tmp = (char)c; return soap_send_raw(soap, tmp, 1); } +#ifdef WITH_REPLACE_ILLEGAL_UTF8 + if (!(c == 0x09 || c == 0x0A || c == 0x0D || (c >= 0x80 && c <= 0xD7FF) || (c >= 0xE000 && c <= 0xFFFD) || (c >= 0x10000 && c <= 0x10FFFF))) + c = SOAP_UNKNOWN_UNICODE_CHAR; +#endif #ifndef WITH_LEAN - if (c >= 0x80) - { register char *t = tmp; + if (c > 0x9F) + { char *t = tmp; if (c < 0x0800) *t++ = (char)(0xC0 | ((c >> 6) & 0x1F)); else @@ -1716,22 +1818,19 @@ soap_pututf8(struct soap *soap, register unsigned long c) } else #endif -#ifdef HAVE_SNPRINTF - soap_snprintf(tmp, sizeof(tmp), "&#%lu;", c); -#else - sprintf(tmp, "&#%lu;", c); -#endif + (SOAP_SNPRINTF(tmp, sizeof(tmp), 20), "&#x%lX;", c); return soap_send(soap, tmp); } #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 soap_wchar SOAP_FMAC2 soap_getutf8(struct soap *soap) -{ register soap_wchar c, c1, c2, c3, c4; +{ soap_wchar c, c1, c2, c3, c4; c = soap->ahead; if (c >= 0x80) soap->ahead = 0; @@ -1761,22 +1860,39 @@ soap_getutf8(struct soap *soap) #endif /******************************************************************************/ + +#ifndef PALM_1 +SOAP_FMAC1 +size_t +SOAP_FMAC2 +soap_utf8len(const char *s) +{ size_t l = 0; + while (*s) + if ((*s++ & 0xC0) != 0x80) + l++; + return l; +} +#endif + +/******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 soap_puthex(struct soap *soap, const unsigned char *s, int n) { char d[2]; - register int i; + int i; #ifdef WITH_DOM if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { if (!(soap->dom->data = soap_s2hex(soap, s, NULL, n))) + { soap->dom->text = soap_s2hex(soap, s, NULL, n); + if (!soap->dom->text) return soap->error; return SOAP_OK; } #endif for (i = 0; i < n; i++) - { register int m = *s++; + { int m = *s++; d[0] = (char)((m >> 4) + (m > 159 ? '7' : '0')); m &= 0x0F; d[1] = (char)(m + (m > 9 ? '7' : '0')); @@ -1788,31 +1904,32 @@ soap_puthex(struct soap *soap, const unsigned char *s, int n) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 unsigned char* SOAP_FMAC2 soap_gethex(struct soap *soap, int *n) -{ +{ long l = 0; #ifdef WITH_DOM if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { soap->dom->data = soap_string_in(soap, 0, -1, -1); - return (unsigned char*)soap_hex2s(soap, soap->dom->data, NULL, 0, n); + { soap->dom->text = soap_string_in(soap, 0, -1, -1, NULL); + return (unsigned char*)soap_hex2s(soap, soap->dom->text, NULL, 0, n); } #endif #ifdef WITH_FAST soap->labidx = 0; for (;;) - { register char *s; - register size_t i, k; + { char *s; + size_t i, k; if (soap_append_lab(soap, NULL, 0)) return NULL; s = soap->labbuf + soap->labidx; k = soap->lablen - soap->labidx; soap->labidx = soap->lablen; for (i = 0; i < k; i++) - { register char d1, d2; - register soap_wchar c; + { char d1, d2; + soap_wchar c; c = soap_get(soap); if (soap_isxdigit(c)) { d1 = (char)c; @@ -1825,31 +1942,41 @@ soap_gethex(struct soap *soap, int *n) } } else - { unsigned char *p; + { unsigned char *p = NULL; + l = (long)(soap->lablen + i - k); soap_unget(soap, c); if (n) - *n = (int)(soap->lablen + i - k); - p = (unsigned char*)soap_malloc(soap, soap->lablen + i - k); - if (p) - memcpy(p, soap->labbuf, soap->lablen + i - k); + *n = (int)l; + if (soap->maxlength > 0 && l > soap->maxlength) + soap->error = SOAP_LENGTH; + else + { p = (unsigned char*)soap_malloc(soap, (size_t)l); + if (p) + soap_memcpy((void*)p, (size_t)l, (const void*)soap->labbuf, (size_t)l); + } return p; } *s++ = (char)(((d1 >= 'A' ? (d1 & 0x7) + 9 : d1 - '0') << 4) + (d2 >= 'A' ? (d2 & 0x7) + 9 : d2 - '0')); } + l = (long)soap->lablen; + if (soap->maxlength > 0 && l > soap->maxlength) + { soap->error = SOAP_LENGTH; + return NULL; + } } #else if (soap_new_block(soap) == NULL) return NULL; for (;;) - { register int i; - register char *s = (char*)soap_push_block(soap, NULL, SOAP_BLKLEN); + { int i; + char *s = (char*)soap_push_block(soap, NULL, SOAP_BLKLEN); if (!s) { soap_end_block(soap, NULL); return NULL; } for (i = 0; i < SOAP_BLKLEN; i++) - { register char d1, d2; - register soap_wchar c = soap_get(soap); + { char d1, d2; + soap_wchar c = soap_get(soap); if (soap_isxdigit(c)) { d1 = (char)c; c = soap_get(soap); @@ -1864,12 +1991,23 @@ soap_gethex(struct soap *soap, int *n) else { unsigned char *p; soap_unget(soap, c); + if (soap->maxlength > 0 && l > soap->maxlength) + { soap->error = SOAP_LENGTH; + soap_end_block(soap, NULL); + return NULL; + } if (n) *n = (int)soap_size_block(soap, NULL, i); - p = (unsigned char*)soap_save_block(soap, NULL, 0); + p = (unsigned char*)soap_save_block(soap, NULL, NULL, 0); return p; } *s++ = ((d1 >= 'A' ? (d1 & 0x7) + 9 : d1 - '0') << 4) + (d2 >= 'A' ? (d2 & 0x7) + 9 : d2 - '0'); + l++; + } + if (soap->maxlength > 0 && l > soap->maxlength) + { soap->error = SOAP_LENGTH; + soap_end_block(soap, NULL); + return NULL; } } #endif @@ -1877,19 +2015,21 @@ soap_gethex(struct soap *soap, int *n) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 soap_putbase64(struct soap *soap, const unsigned char *s, int n) -{ register int i; - register unsigned long m; +{ int i; + unsigned long m; char d[4]; if (!s) return SOAP_OK; #ifdef WITH_DOM if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { if (!(soap->dom->data = soap_s2base64(soap, s, NULL, n))) + { soap->dom->text = soap_s2base64(soap, s, NULL, n); + if (!soap->dom->text) return soap->error; return SOAP_OK; } @@ -1921,40 +2061,40 @@ soap_putbase64(struct soap *soap, const unsigned char *s, int n) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 unsigned char* SOAP_FMAC2 soap_getbase64(struct soap *soap, int *n, int malloc_flag) -{ (void)malloc_flag; +{ long l = 0; + (void)malloc_flag; #ifdef WITH_DOM if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { soap->dom->data = soap_string_in(soap, 0, -1, -1); - return (unsigned char*)soap_base642s(soap, soap->dom->data, NULL, 0, n); + { soap->dom->text = soap_string_in(soap, 0, -1, -1, NULL); + return (unsigned char*)soap_base642s(soap, soap->dom->text, NULL, 0, n); } #endif #ifdef WITH_FAST soap->labidx = 0; for (;;) - { register size_t i, k; - register char *s; + { size_t i, k; + char *s; if (soap_append_lab(soap, NULL, 2)) return NULL; s = soap->labbuf + soap->labidx; k = soap->lablen - soap->labidx; soap->labidx = 3 * (soap->lablen / 3); - if (!s) - return NULL; if (k > 2) { for (i = 0; i < k - 2; i += 3) - { register unsigned long m = 0; - register int j = 0; + { unsigned long m = 0; + int j = 0; do - { register soap_wchar c = soap_get(soap); + { soap_wchar c = soap_get(soap); if (c < SOAP_AP) c &= 0x7FFFFFFF; if (c == '=' || c < 0) - { unsigned char *p; + { unsigned char *p = NULL; switch (j) { case 2: *s++ = (char)((m >> 4) & 0xFF); @@ -1965,21 +2105,26 @@ soap_getbase64(struct soap *soap, int *n, int malloc_flag) *s++ = (char)((m >> 2) & 0xFF); i += 2; } + l = (long)(soap->lablen + i - k); if (n) - *n = (int)(soap->lablen + i - k); - p = (unsigned char*)soap_malloc(soap, soap->lablen + i - k); - if (p) - memcpy(p, soap->labbuf, soap->lablen + i - k); + *n = (int)l; + if (soap->maxlength > 0 && l > soap->maxlength) + soap->error = SOAP_LENGTH; + else + { p = (unsigned char*)soap_malloc(soap, (size_t)l); + if (p) + soap_memcpy((void*)p, (size_t)l, (const void*)soap->labbuf, (size_t)l); + } if (c >= 0) { while ((int)((c = soap_get(soap)) != EOF) && c != SOAP_LT && c != SOAP_TT) - ; + continue; } soap_unget(soap, c); return p; } c -= '+'; if (c >= 0 && c <= 79) - { register int b = soap_base64i[c]; + { int b = soap_base64i[c]; if (b >= 64) { soap->error = SOAP_TYPE; return NULL; @@ -1996,23 +2141,30 @@ soap_getbase64(struct soap *soap, int *n, int malloc_flag) *s++ = (char)((m >> 8) & 0xFF); *s++ = (char)(m & 0xFF); } + l = (long)soap->lablen; + if (soap->maxlength > 0 && l > soap->maxlength) + { soap->error = SOAP_LENGTH; + return NULL; + } } } #else if (soap_new_block(soap) == NULL) return NULL; for (;;) - { register int i; - register char *s = (char*)soap_push_block(soap, NULL, 3 * SOAP_BLKLEN); /* must be multiple of 3 */ + { int i; + char *s = (char*)soap_push_block(soap, NULL, 3 * SOAP_BLKLEN); /* must be multiple of 3 */ if (!s) { soap_end_block(soap, NULL); return NULL; } for (i = 0; i < SOAP_BLKLEN; i++) - { register unsigned long m = 0; - register int j = 0; + { unsigned long m = 0; + int j = 0; do - { register soap_wchar c = soap_get(soap); + { soap_wchar c = soap_get(soap); + if (c < SOAP_AP) + c &= 0x7FFFFFFF; if (c == '=' || c < 0) { unsigned char *p; i *= 3; @@ -2020,18 +2172,25 @@ soap_getbase64(struct soap *soap, int *n, int malloc_flag) { case 2: *s++ = (char)((m >> 4) & 0xFF); i++; + l++; break; case 3: *s++ = (char)((m >> 10) & 0xFF); *s++ = (char)((m >> 2) & 0xFF); + l += 2; i += 2; } if (n) *n = (int)soap_size_block(soap, NULL, i); - p = (unsigned char*)soap_save_block(soap, NULL, 0); + if (soap->maxlength > 0 && l > soap->maxlength) + { soap->error = SOAP_LENGTH; + soap_end_block(soap, NULL); + return NULL; + } + p = (unsigned char*)soap_save_block(soap, NULL, NULL, 0); if (c >= 0) { while ((int)((c = soap_get(soap)) != EOF) && c != SOAP_LT && c != SOAP_TT) - ; + continue; } soap_unget(soap, c); return p; @@ -2046,7 +2205,7 @@ soap_getbase64(struct soap *soap, int *n, int malloc_flag) m = (m << 6) + b; j++; } - else if (!soap_blank(c)) + else if (!soap_blank(c + '+')) { soap->error = SOAP_TYPE; return NULL; } @@ -2054,6 +2213,12 @@ soap_getbase64(struct soap *soap, int *n, int malloc_flag) *s++ = (char)((m >> 16) & 0xFF); *s++ = (char)((m >> 8) & 0xFF); *s++ = (char)(m & 0xFF); + l += 3; + } + if (soap->maxlength > 0 && l > soap->maxlength) + { soap->error = SOAP_LENGTH; + soap_end_block(soap, NULL); + return NULL; } } #endif @@ -2061,6 +2226,7 @@ soap_getbase64(struct soap *soap, int *n, int malloc_flag) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 @@ -2072,7 +2238,7 @@ soap_xop_forward(struct soap *soap, unsigned char **ptr, int *size, char **id, c short body = soap->body; /* should save type too? */ if (!soap_peek_element(soap)) { if (!soap_element_begin_in(soap, "xop:Include", 0, NULL)) - { if (soap_dime_forward(soap, ptr, size, id, type, options) + { if (soap_attachment_forward(soap, ptr, size, id, type, options) || (soap->body && soap_element_end_in(soap, "xop:Include"))) return soap->error; } @@ -2084,12 +2250,13 @@ soap_xop_forward(struct soap *soap, unsigned char **ptr, int *size, char **id, c #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 -soap_dime_forward(struct soap *soap, unsigned char **ptr, int *size, char **id, char **type, char **options) +soap_attachment_forward(struct soap *soap, unsigned char **ptr, int *size, char **id, char **type, char **options) { struct soap_xlist *xp; *ptr = NULL; *size = 0; @@ -2115,19 +2282,42 @@ soap_dime_forward(struct soap *soap, unsigned char **ptr, int *size, char **id, #endif /******************************************************************************/ + +#ifndef PALM_1 +SOAP_FMAC1 +void * +SOAP_FMAC2 +soap_memdup(struct soap *soap, const void *s, size_t n) +{ void *t = NULL; + if (s) + { t = soap_malloc(soap, n); + if (t) + soap_memcpy(t, n, s, n); + } + return t; +} +#endif + +/******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 char * SOAP_FMAC2 soap_strdup(struct soap *soap, const char *s) { char *t = NULL; - if (s && (t = (char*)soap_malloc(soap, strlen(s) + 1))) - strcpy(t, s); + if (s) + { size_t l = strlen(s) + 1; + t = (char*)soap_malloc(soap, l); + if (t) + soap_memcpy((void*)t, l, (const void*)s, l); + } return t; } #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 wchar_t * @@ -2138,14 +2328,63 @@ soap_wstrdup(struct soap *soap, const wchar_t *s) { size_t n = 0; while (s[n]) n++; - if ((t = (wchar_t*)soap_malloc(soap, sizeof(wchar_t)*(n+1)))) - memcpy(t, s, sizeof(wchar_t)*(n+1)); + n = sizeof(wchar_t)*(n+1); + t = (wchar_t*)soap_malloc(soap, n); + if (t) + soap_memcpy((void*)t, n, (const void*)s, n); } return t; } #endif /******************************************************************************/ + +#ifndef PALM_1 +SOAP_FMAC1 +char * +SOAP_FMAC2 +soap_strtrim(struct soap *soap, char *s) +{ (void)soap; + if (s) + { char *t; + while ((*s >= 9 && *s <= 13) || *s == 32) + s++; + t = s; + while (*t) + t++; + while (--t > s && ((*t >= 9 && *t <= 13) || *t == 32)) + continue; + t[1] = '\0'; + } + return s; +} +#endif + +/******************************************************************************/ + +#ifndef PALM_1 +SOAP_FMAC1 +wchar_t * +SOAP_FMAC2 +soap_wstrtrim(struct soap *soap, wchar_t *s) +{ (void)soap; + if (s) + { wchar_t *t; + while ((*s >= 9 && *s <= 13) || *s == 32) + s++; + t = s; + while (*t) + t++; + while (--t > s && ((*t >= 9 && *t <= 13) || *t == 32)) + continue; + t[1] = L'\0'; + } + return s; +} +#endif + +/******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 struct soap_blist* @@ -2153,135 +2392,169 @@ SOAP_FMAC2 soap_new_block(struct soap *soap) { struct soap_blist *p; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "New block sequence (prev=%p)\n", soap->blist)); - if (!(p = (struct soap_blist*)SOAP_MALLOC(soap, sizeof(struct soap_blist)))) + p = (struct soap_blist*)SOAP_MALLOC(soap, sizeof(struct soap_blist)); + if (!p) { soap->error = SOAP_EOM; return NULL; } p->next = soap->blist; - p->ptr = NULL; + p->head = NULL; p->size = 0; + p->item = 0; soap->blist = p; return p; } #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 void* SOAP_FMAC2 soap_push_block(struct soap *soap, struct soap_blist *b, size_t n) -{ char *p; +{ struct soap_bhead *p; if (!b) b = soap->blist; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push block of %u bytes (%u bytes total)\n", (unsigned int)n, (unsigned int)b->size + (unsigned int)n)); - if (!(p = (char*)SOAP_MALLOC(soap, n + sizeof(char*) + sizeof(size_t)))) + p = (struct soap_bhead*)SOAP_MALLOC(soap, sizeof(struct soap_bhead) + n); + if (!p) { soap->error = SOAP_EOM; return NULL; } - *(char**)p = b->ptr; - *(size_t*)(p + sizeof(char*)) = n; - b->ptr = p; + p->next = b->head; + b->head = p; + p->size = n; b->size += n; - return p + sizeof(char*) + sizeof(size_t); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push block %p of %u bytes on %lu previous blocks (%lu bytes total)\n", p, (unsigned int)n, (unsigned long)b->item, (unsigned long)b->size)); + b->item++; + return (void*)(p + 1); /* skip block header and point to n allocated bytes */ +} +#endif + +/******************************************************************************/ + +#ifndef PALM_1 +SOAP_FMAC1 +void* +SOAP_FMAC2 +soap_push_block_max(struct soap *soap, struct soap_blist *b, size_t n) +{ if (b && b->item >= soap->maxoccurs) /* restrict block array length */ + { soap->error = SOAP_OCCURS; + return NULL; + } + return soap_push_block(soap, b, n); } #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 void SOAP_FMAC2 soap_pop_block(struct soap *soap, struct soap_blist *b) -{ char *p; +{ struct soap_bhead *p; if (!b) b = soap->blist; - if (!b->ptr) + if (!b->head) return; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Pop block\n")); - p = b->ptr; - b->size -= *(size_t*)(p + sizeof(char*)); - b->ptr = *(char**)p; + p = b->head; + b->size -= p->size; + b->head = p->next; + b->item--; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Pop block %p (%lu items of %lu bytes total)\n", p, (unsigned long)b->item, (unsigned long)b->size)); SOAP_FREE(soap, p); } #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 void SOAP_FMAC2 -soap_update_pointers(struct soap *soap, char *start, char *end, char *p1, char *p2) -{ -#ifndef WITH_NOIDREF - int i; - register struct soap_ilist *ip = NULL; - register struct soap_flist *fp = NULL; +soap_update_pointers(struct soap *soap, const char *dst, const char *src, size_t len) +{ const void *start = src, *end = src + len; #ifndef WITH_LEANER - register struct soap_xlist *xp = NULL; + struct soap_xlist *xp; #endif - register void *p, **q; - for (i = 0; i < SOAP_IDHASH; i++) - { for (ip = soap->iht[i]; ip; ip = ip->next) - { if (ip->ptr && (char*)ip->ptr >= start && (char*)ip->ptr < end) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Update id='%s' %p -> %p\n", ip->id, ip->ptr, (char*)ip->ptr + (p1-p2))); - ip->ptr = (char*)ip->ptr + (p1-p2); - } - for (q = &ip->link; q; q = (void**)p) - { p = *q; - if (p && (char*)p >= start && (char*)p < end) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Link update id='%s' %p\n", ip->id, p)); - *q = (char*)p + (p1-p2); - } - } - for (q = &ip->copy; q; q = (void**)p) - { p = *q; - if (p && (char*)p >= start && (char*)p < end) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy chain update id='%s' %p\n", ip->id, p)); - *q = (char*)p + (p1-p2); - } - } - for (fp = ip->flist; fp; fp = fp->next) - { if ((char*)fp->ptr >= start && (char*)fp->ptr < end) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy list update id='%s' %p\n", ip->id, fp)); - fp->ptr = (char*)fp->ptr + (p1-p2); +#ifndef WITH_NOIDREF + if ((soap->version && !(soap->imode & SOAP_XML_TREE)) || (soap->mode & SOAP_XML_GRAPH)) + { int i; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Update pointers %p (%lu bytes) -> %p\n", src, (unsigned long)len, dst)); + for (i = 0; i < SOAP_IDHASH; i++) + { struct soap_ilist *ip; + for (ip = soap->iht[i]; ip; ip = ip->next) + { struct soap_flist *fp; + void *p, **q; + if (ip->shaky) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Update shaky id='%s'\n", ip->id)); + if (ip->ptr && ip->ptr >= start && ip->ptr < end) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Update ptr %p -> %p\n", ip->ptr, (const char*)ip->ptr + (dst-src))); + ip->ptr = (void*)((const char*)ip->ptr + (dst-src)); + } + for (q = &ip->link; q; q = (void**)p) + { p = *q; + if (p && p >= start && p < end) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Link update id='%s' %p -> %p\n", ip->id, p, (const char*)p + (dst-src))); + *q = (void*)((const char*)p + (dst-src)); + } + } + for (q = &ip->copy; q; q = (void**)p) + { p = *q; + if (p && p >= start && p < end) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy chain update id='%s' %p -> %p\n", ip->id, p, (const char*)p + (dst-src))); + *q = (void*)((const char*)p + (dst-src)); + } + } + for (fp = ip->flist; fp; fp = fp->next) + { if (fp->ptr >= start && fp->ptr < end) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy list update id='%s' target type=%d %p -> %p\n", ip->id, fp->type, fp->ptr, (char*)fp->ptr + (dst-src))); + fp->ptr = (void*)((const char*)fp->ptr + (dst-src)); + } + } + if (ip->smart && ip->smart >= start && ip->smart < end) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Smart shared pointer update %p -> %p\n", ip->smart, (const char*)ip->smart + (dst-src))); + ip->smart = (void*)((const char*)ip->smart + (dst-src)); + } } } } } +#else + (void)soap; (void)start; (void)end; (void)dst; (void)src; +#endif #ifndef WITH_LEANER for (xp = soap->xlist; xp; xp = xp->next) - { if (xp->ptr && (char*)xp->ptr >= start && (char*)xp->ptr < end) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Update id='%s' %p -> %p\n", xp->id ? xp->id : SOAP_STR_EOS, xp->ptr, (char*)xp->ptr + (p1-p2))); - xp->ptr = (unsigned char**)((char*)xp->ptr + (p1-p2)); - xp->size = (int*)((char*)xp->size + (p1-p2)); - xp->type = (char**)((char*)xp->type + (p1-p2)); - xp->options = (char**)((char*)xp->options + (p1-p2)); + { if (xp->ptr && (void*)xp->ptr >= start && (void*)xp->ptr < end) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Update attachment id='%s' %p -> %p\n", xp->id ? xp->id : SOAP_STR_EOS, xp->ptr, (char*)xp->ptr + (dst-src))); + xp->ptr = (unsigned char**)((char*)xp->ptr + (dst-src)); + xp->size = (int*)((char*)xp->size + (dst-src)); + xp->type = (char**)((char*)xp->type + (dst-src)); + xp->options = (char**)((char*)xp->options + (dst-src)); } } #endif -#else - (void)soap; (void)start; (void)end; (void)p1; (void)p2; -#endif } #endif /******************************************************************************/ + #ifndef WITH_NOIDREF #ifndef PALM_1 static int -soap_has_copies(struct soap *soap, register const char *start, register const char *end) -{ register int i; - register struct soap_ilist *ip = NULL; - register struct soap_flist *fp = NULL; - register const char *p; +soap_has_copies(struct soap *soap, const char *start, const char *end) +{ int i; + struct soap_ilist *ip = NULL; + struct soap_flist *fp = NULL; + const char *p; for (i = 0; i < SOAP_IDHASH; i++) { for (ip = soap->iht[i]; ip; ip = ip->next) { for (p = (const char*)ip->copy; p; p = *(const char**)p) if (p >= start && p < end) return SOAP_ERR; for (fp = ip->flist; fp; fp = fp->next) - if ((const char*)fp->ptr >= start && (const char*)fp->ptr < end) + if (fp->type == ip->type && (const char*)fp->ptr >= start && (const char*)fp->ptr < end) return SOAP_ERR; } } @@ -2291,91 +2564,112 @@ soap_has_copies(struct soap *soap, register const char *start, register const ch #endif /******************************************************************************/ + #ifndef WITH_NOIDREF #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 soap_resolve(struct soap *soap) -{ register int i; - register struct soap_ilist *ip = NULL; - register struct soap_flist *fp = NULL; +{ int i; short flag; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving forwarded data\n")); + const char *id; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving forwarded refs\n")); for (i = 0; i < SOAP_IDHASH; i++) - { for (ip = soap->iht[i]; ip; ip = ip->next) + { struct soap_ilist *ip; + for (ip = soap->iht[i]; ip; ip = ip->next) { if (ip->ptr) - { register void *p, **q, *r; + { void **q; + struct soap_flist *fp, **fpp = &ip->flist; + if (ip->spine) + ip->spine[0] = ip->ptr; q = (void**)ip->link; ip->link = NULL; - r = ip->ptr; - DBGLOG(TEST, if (q) SOAP_MESSAGE(fdebug, "Traversing link chain to resolve id='%s'\n", ip->id)); + DBGLOG(TEST, if (q) SOAP_MESSAGE(fdebug, "Traversing link chain to resolve id='%s' type=%d\n", ip->id, ip->type)); while (q) - { p = *q; - *q = r; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "... link %p -> %p\n", q, r)); + { void *p = *q; + *q = ip->ptr; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "... link %p -> %p\n", q, ip->ptr)); q = (void**)p; } + while ((fp = *fpp)) + { if (fp->level > 0 && fp->finsert) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "... insert type=%d link %p -> %p\n", fp->type, fp->ptr, ip->ptr)); + if (ip->spine && fp->level <= SOAP_MAXPTRS) + fp->finsert(soap, ip->type, fp->type, fp->ptr, fp->index, &ip->spine[fp->level - 1], &ip->smart); + else if (fp->level == 1) + fp->finsert(soap, ip->type, fp->type, fp->ptr, fp->index, &ip->ptr, &ip->smart); + else if (fp->level <= SOAP_MAXPTRS) + { int i; + ip->spine = (void**)soap_malloc(soap, SOAP_MAXPTRS * sizeof(void*)); + if (!ip->spine) + return soap->error = SOAP_EOM; + ip->spine[0] = ip->ptr; + for (i = 1; i < SOAP_MAXPTRS; i++) + ip->spine[i] = &ip->spine[i - 1]; + fp->finsert(soap, ip->type, fp->type, fp->ptr, fp->index, &ip->spine[fp->level - 1], &ip->smart); + } + *fpp = fp->next; + SOAP_FREE(soap, fp); + } + else + fpp = &fp->next; + } } else if (*ip->id == '#') - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Missing data for id='%s'\n", ip->id)); - strcpy(soap->id, ip->id + 1); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Missing id='%s'\n", ip->id)); + soap_strcpy(soap->id, sizeof(soap->id), ip->id + 1); return soap->error = SOAP_MISSING_ID; } } } do { flag = 0; + id = NULL; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolution phase\n")); for (i = 0; i < SOAP_IDHASH; i++) - { for (ip = soap->iht[i]; ip; ip = ip->next) - { if (ip->ptr && !soap_has_copies(soap, (const char*)ip->ptr, (const char*)ip->ptr + ip->size)) - { if (ip->copy) - { register void *p, **q = (void**)ip->copy; - DBGLOG(TEST, if (q) SOAP_MESSAGE(fdebug, "Traversing copy chain to resolve id='%s'\n", ip->id)); - ip->copy = NULL; - do - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "... copy %p -> %p (%u bytes)\n", ip->ptr, q, (unsigned int)ip->size)); - p = *q; - memcpy(q, ip->ptr, ip->size); - q = (void**)p; - } while (q); - flag = 1; - } - for (fp = ip->flist; fp; fp = ip->flist) - { register unsigned int k = fp->level; - register void *p = ip->ptr; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving forwarded data type=%d location=%p level=%u,%u id='%s'\n", ip->type, p, ip->level, fp->level, ip->id)); - while (ip->level < k) - { register void **q = (void**)soap_malloc(soap, sizeof(void*)); - if (!q) - return soap->error; - *q = p; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level, new location=%p holds=%p...\n", q, *q)); - p = (void*)q; - k--; + { struct soap_ilist *ip; + for (ip = soap->iht[i]; ip; ip = ip->next) + { if (ip->copy || ip->flist) + { if (ip->ptr && !soap_has_copies(soap, (const char*)ip->ptr, (const char*)ip->ptr + ip->size)) + { struct soap_flist *fp; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving id='%s' type=%d ptr=%p size=%lu ...\n", ip->id, ip->type, ip->ptr, (unsigned long)ip->size)); + if (ip->copy) + { void *p, **q = (void**)ip->copy; + DBGLOG(TEST, if (q) SOAP_MESSAGE(fdebug, "Traversing copy chain to resolve id='%s'\n", ip->id)); + ip->copy = NULL; + do + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "... copy %p -> %p (%u bytes)\n", ip->ptr, q, (unsigned int)ip->size)); + p = *q; + soap_memcpy((void*)q, ip->size, (const void*)ip->ptr, ip->size); + q = (void**)p; + } while (q); + flag = 1; + } + while ((fp = ip->flist)) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving forwarded data type=%d target type=%d location=%p level=%u id='%s'\n", ip->type, fp->type, ip->ptr, fp->level, ip->id)); + if (fp->level == 0) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "... copy %p -> %p (%lu bytes)\n", ip->ptr, fp->ptr, (unsigned long)ip->size)); + if (fp->finsert) + fp->finsert(soap, ip->type, fp->type, fp->ptr, fp->index, ip->ptr, &ip->smart); + else + soap_memcpy((void*)fp->ptr, ip->size, (const void*)ip->ptr, ip->size); + } + ip->flist = fp->next; + SOAP_FREE(soap, fp); + flag = 1; } - if (fp->fcopy) - fp->fcopy(soap, ip->type, fp->type, fp->ptr, fp->len, p, ip->size); - else - soap_fcopy(soap, ip->type, fp->type, fp->ptr, fp->len, p, ip->size); - ip->flist = fp->next; - SOAP_FREE(soap, fp); - flag = 1; } + else + id = ip->id; } } } } while (flag); -#ifdef SOAP_DEBUG - for (i = 0; i < SOAP_IDHASH; i++) - { for (ip = soap->iht[i]; ip; ip = ip->next) - { if (ip->copy || ip->flist) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolution error: forwarded data for id='%s' could not be propagated, please report this problem to the developers\n", ip->id)); - } - } + if (id) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolution error: forwarded data for id='%s' could not be propagated, please report this problem to the gSOAP developers\n", id)); + return soap_id_nullify(soap, id); } -#endif DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolution done\n")); return SOAP_OK; } @@ -2383,6 +2677,7 @@ soap_resolve(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 size_t @@ -2390,61 +2685,64 @@ SOAP_FMAC2 soap_size_block(struct soap *soap, struct soap_blist *b, size_t n) { if (!b) b = soap->blist; - if (b->ptr) - { b->size -= *(size_t*)(b->ptr + sizeof(char*)) - n; - *(size_t*)(b->ptr + sizeof(char*)) = n; + if (b->head) + { b->size -= b->head->size - n; + b->head->size = n; } return b->size; } #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 char* SOAP_FMAC2 soap_first_block(struct soap *soap, struct soap_blist *b) -{ char *p, *q, *r; +{ struct soap_bhead *p, *q, *r; if (!b) b = soap->blist; - p = b->ptr; + p = b->head; if (!p) return NULL; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "First block\n")); r = NULL; do - { q = *(char**)p; - *(char**)p = r; + { q = p->next; + p->next = r; r = p; p = q; } while (p); - b->ptr = r; - return r + sizeof(char*) + sizeof(size_t); + b->head = r; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "First block %p\n", r + 1)); + return (char*)(r + 1); } #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 char* SOAP_FMAC2 soap_next_block(struct soap *soap, struct soap_blist *b) -{ char *p; +{ struct soap_bhead *p; if (!b) b = soap->blist; - p = b->ptr; + p = b->head; if (p) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Next block\n")); - b->ptr = *(char**)p; + { b->head = p->next; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Next block %p, deleting current block\n", b->head ? b->head + 1 : NULL)); SOAP_FREE(soap, p); - if (b->ptr) - return b->ptr + sizeof(char*) + sizeof(size_t); + if (b->head) + return (char*)(b->head + 1); } return NULL; } #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 size_t @@ -2452,23 +2750,24 @@ SOAP_FMAC2 soap_block_size(struct soap *soap, struct soap_blist *b) { if (!b) b = soap->blist; - return *(size_t*)(b->ptr + sizeof(char*)); + return b->head->size; } #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 void SOAP_FMAC2 soap_end_block(struct soap *soap, struct soap_blist *b) -{ char *p, *q; +{ struct soap_bhead *p, *q; if (!b) b = soap->blist; if (b) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of block sequence, free all remaining blocks\n")); - for (p = b->ptr; p; p = q) - { q = *(char**)p; + for (p = b->head; p; p = q) + { q = p->next; SOAP_FREE(soap, p); } if (soap->blist == b) @@ -2484,33 +2783,42 @@ soap_end_block(struct soap *soap, struct soap_blist *b) } SOAP_FREE(soap, b); } - DBGLOG(TEST, if (soap->blist) SOAP_MESSAGE(fdebug, "Restore previous block sequence\n")); + DBGLOG(TEST, if (soap->blist) SOAP_MESSAGE(fdebug, "Restored previous block sequence\n")); +#ifndef WITH_NOIDREF + if (!soap->blist && ((soap->version && !(soap->imode & SOAP_XML_TREE)) || (soap->mode & SOAP_XML_GRAPH))) + { int i; + struct soap_ilist *ip = NULL; + for (i = 0; i < SOAP_IDHASH; i++) + for (ip = soap->iht[i]; ip; ip = ip->next) + ip->shaky = 0; + } +#endif } #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 char* SOAP_FMAC2 soap_save_block(struct soap *soap, struct soap_blist *b, char *p, int flag) -{ register size_t n; - register char *q, *s; +{ size_t n; + char *q, *s; if (!b) b = soap->blist; if (b->size) { if (!p) p = (char*)soap_malloc(soap, b->size); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Save all blocks in contiguous memory space of %u bytes (%p->%p)\n", (unsigned int)b->size, b->ptr, p)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Save all %lu blocks in contiguous memory space of %u bytes (%p->%p)\n", (unsigned long)b->item, (unsigned int)b->size, b->head, p)); if (p) - { for (s = p, q = soap_first_block(soap, b); q; q = soap_next_block(soap, b)) + { s = p; + for (q = soap_first_block(soap, b); q; q = soap_next_block(soap, b)) { n = soap_block_size(soap, b); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy %u bytes from %p to %p\n", (unsigned int)n, q, s)); -#ifndef WITH_NOIDREF if (flag) - soap_update_pointers(soap, q, q + n, s, q); -#endif - memcpy(s, q, n); + soap_update_pointers(soap, s, q, n); + soap_memcpy((void*)s, n, (const void*)q, n); s += n; } } @@ -2523,248 +2831,140 @@ soap_save_block(struct soap *soap, struct soap_blist *b, char *p, int flag) #endif /******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_putsize(struct soap *soap, const char *type, int size) -{ return soap_putsizes(soap, type, &size, 1); -} -#endif - -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -char * -SOAP_FMAC2 -soap_putsizes(struct soap *soap, const char *type, const int *size, int dim) -{ return soap_putsizesoffsets(soap, type, size, NULL, dim); -} -#endif -/******************************************************************************/ #ifndef PALM_2 SOAP_FMAC1 char * SOAP_FMAC2 soap_putsizesoffsets(struct soap *soap, const char *type, const int *size, const int *offset, int dim) -{ register int i; - register size_t l; - if (!type || strlen(type) + 13 > sizeof(soap->type)) /* prevent overruns */ +{ int i; + const char *t = ",%d"; + if (!type) return NULL; if (soap->version == 2) - { -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->type, sizeof(soap->type) - 1, "%s[%d", type, size[0]); -#else - sprintf(soap->type, "%s[%d", type, size[0]); -#endif + t = " %d"; + if (soap->version != 2 && offset) + { (SOAP_SNPRINTF(soap->type, sizeof(soap->type) - 1, strlen(type) + 20), "%s[%d", type, size[0] + offset[0]); for (i = 1; i < dim; i++) - { -#ifdef HAVE_SNPRINTF - l = strlen(soap->type); - soap_snprintf(soap->type + l, sizeof(soap->type) - l - 1, " %d", size[i]); -#else - if ((l = strlen(soap->type)) + 13 > sizeof(soap->type)) - return NULL; - sprintf(soap->type + l, " %d", size[i]); -#endif + { size_t l = strlen(soap->type); + (SOAP_SNPRINTF(soap->type + l, sizeof(soap->type) - l - 1, 20), t, size[i] + offset[i]); } } else - { if (offset) - { -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->type, sizeof(soap->type) - 1, "%s[%d", type, size[0] + offset[0]); -#else - sprintf(soap->type, "%s[%d", type, size[0] + offset[0]); -#endif - for (i = 1; i < dim; i++) - { -#ifdef HAVE_SNPRINTF - l = strlen(soap->type); - soap_snprintf(soap->type + l, sizeof(soap->type) - l - 1, ",%d", size[i] + offset[i]); -#else - if ((l = strlen(soap->type)) + 13 > sizeof(soap->type)) - return NULL; - sprintf(soap->type + l, ",%d", size[i] + offset[i]); -#endif - } - } - else - { -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->type, sizeof(soap->type) - 1, "%s[%d", type, size[0]); -#else - sprintf(soap->type, "%s[%d", type, size[0]); -#endif - for (i = 1; i < dim; i++) - { -#ifdef HAVE_SNPRINTF - l = strlen(soap->type); - soap_snprintf(soap->type + l, sizeof(soap->type) - l - 1, ",%d", size[i]); -#else - if ((l = strlen(soap->type)) + 13 > sizeof(soap->type)) - return NULL; - sprintf(soap->type + l, ",%d", size[i]); -#endif - } + { (SOAP_SNPRINTF(soap->type, sizeof(soap->type) - 1, strlen(type) + 20), "%s[%d", type, size[0]); + for (i = 1; i < dim; i++) + { size_t l = strlen(soap->type); + (SOAP_SNPRINTF(soap->type + l, sizeof(soap->type) - l - 1, 20), t, size[i]); } } - strcat(soap->type, "]"); + soap_strncat(soap->type, sizeof(soap->type), "]", 1); return soap->type; } #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 char * SOAP_FMAC2 -soap_putoffset(struct soap *soap, int offset) -{ return soap_putoffsets(soap, &offset, 1); +soap_putoffsets(struct soap *soap, const int *offset, int dim) +{ int i; + soap->arrayOffset[0] = '\0'; + if (soap->version == 1) + { (SOAP_SNPRINTF(soap->arrayOffset, sizeof(soap->arrayOffset) - 1, 20), "[%d", offset[0]); + for (i = 1; i < dim; i++) + { size_t l = strlen(soap->arrayOffset); + (SOAP_SNPRINTF(soap->arrayOffset + l, sizeof(soap->arrayOffset) - l - 1, 20), ",%d", offset[i]); + } + soap_strncat(soap->arrayOffset, sizeof(soap->arrayOffset), "]", 1); + } + return soap->arrayOffset; } #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 -char * +size_t SOAP_FMAC2 -soap_putoffsets(struct soap *soap, const int *offset, int dim) -{ register int i; - register size_t l; -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->arrayOffset, sizeof(soap->arrayOffset) - 1, "[%d", offset[0]); -#else - if (sizeof(soap->arrayOffset) < 13) /* prevent overruns */ - return NULL; - sprintf(soap->arrayOffset, "[%d", offset[0]); -#endif +soap_size(const int *size, int dim) +{ int i; + size_t n = 0; + if (size[0] <= 0) + return 0; + n = (size_t)size[0]; for (i = 1; i < dim; i++) - { -#ifdef HAVE_SNPRINTF - l = strlen(soap->arrayOffset); - soap_snprintf(soap->arrayOffset + l, sizeof(soap->arrayOffset) - l - 1, ",%d", offset[i]); -#else - if ((l = strlen(soap->arrayOffset)) + 13 > sizeof(soap->arrayOffset)) - return NULL; - sprintf(soap->arrayOffset + l, ",%d", offset[i]); -#endif + { if (size[i] <= 0) + return 0; + n *= (size_t)size[i]; } - strcat(soap->arrayOffset, "]"); - return soap->arrayOffset; + return (size_t)n; } #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 -int +size_t SOAP_FMAC2 -soap_size(const int *size, int dim) -{ register int i, n = size[0]; - for (i = 1; i < dim; i++) - n *= size[i]; +soap_getsizes(const char *attr, int *size, int dim) +{ size_t i, k, n; + if (!*attr) + return 0; + i = strlen(attr); + n = 1; + do + { for (; i > 0; i--) + if (attr[i - 1] == '[' || attr[i - 1] == ',' || attr[i - 1] == ' ') + break; + n *= k = (size_t)soap_strtoul(attr + i, NULL, 10); + size[--dim] = (int)k; + if (n > SOAP_MAXARRAYSIZE) + return 0; + } while (dim > 0 && --i > 0 && attr[i] != '['); return n; } #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 soap_getoffsets(const char *attr, const int *size, int *offset, int dim) -{ register int i, j = 0; +{ int i, j = 0; if (offset) - for (i = 0; i < dim && attr && *attr; i++) + { for (i = 0; i < dim && attr && *attr; i++) { attr++; j *= size[i]; j += offset[i] = (int)soap_strtol(attr, NULL, 10); attr = strchr(attr, ','); } + } else - for (i = 0; i < dim && attr && *attr; i++) + { for (i = 0; i < dim && attr && *attr; i++) { attr++; j *= size[i]; j += (int)soap_strtol(attr, NULL, 10); attr = strchr(attr, ','); } + } return j; } #endif /******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getsize(const char *attr1, const char *attr2, int *j) -{ register int n, k; - char *s; - *j = 0; - if (!*attr1) - return -1; - if (*attr1 == '[') - attr1++; - n = 1; - for (;;) - { k = (int)soap_strtol(attr1, &s, 10); - n *= k; - if (k < 0 || n > SOAP_MAXARRAYSIZE || s == attr1) - return -1; - attr1 = strchr(s, ','); - if (!attr1) - attr1 = strchr(s, ' '); - if (attr2 && *attr2) - { attr2++; - *j *= k; - k = (int)soap_strtol(attr2, &s, 10); - *j += k; - if (k < 0) - return -1; - attr2 = s; - } - if (!attr1) - break; - attr1++; - } - return n - *j; -} -#endif -/******************************************************************************/ -#ifndef PALM_2 -SOAP_FMAC1 -int -SOAP_FMAC2 -soap_getsizes(const char *attr, int *size, int dim) -{ register int i, k, n; - if (!*attr) - return -1; - i = (int)strlen(attr); - n = 1; - do - { for (i = i-1; i >= 0; i--) - if (attr[i] == '[' || attr[i] == ',' || attr[i] == ' ') - break; - k = (int)soap_strtol(attr + i + 1, NULL, 10); - n *= size[--dim] = k; - if (k < 0 || n > SOAP_MAXARRAYSIZE) - return -1; - } while (i >= 0 && attr[i] != '['); - return n; -} -#endif - -/******************************************************************************/ #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 soap_getposition(const char *attr, int *pos) -{ register int i, n; +{ int i, n; if (!*attr) return -1; n = 0; @@ -2781,15 +2981,16 @@ soap_getposition(const char *attr, int *pos) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 struct soap_nlist * SOAP_FMAC2 soap_push_namespace(struct soap *soap, const char *id, const char *ns) -{ register struct soap_nlist *np; - register struct Namespace *p; - register short i = -1; - register size_t n, k; +{ struct soap_nlist *np; + struct Namespace *p; + short i = -1; + size_t n, k; n = strlen(id); k = strlen(ns) + 1; p = soap->local_namespaces; @@ -2803,13 +3004,14 @@ soap_push_namespace(struct soap *soap, const char *id, const char *ns) } else if (p->in) { if (!soap_tag_cmp(ns, p->in)) - { if ((p->out = (char*)SOAP_MALLOC(soap, k))) - strcpy(p->out, ns); + { p->out = (char*)SOAP_MALLOC(soap, k); + if (p->out) + soap_strcpy(p->out, k, ns); break; } } } - if (!p || !p->id) + if (!p->id) i = -1; } if (i >= 0) @@ -2823,10 +3025,11 @@ soap_push_namespace(struct soap *soap, const char *id, const char *ns) soap->nlist = np; np->level = soap->level; np->index = i; - strcpy((char*)np->id, id); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push namespace binding (level=%u) '%s' '%s'\n", soap->level, id, ns)); + soap_strcpy((char*)np->id, n + 1, id); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push namespace binding (level=%u) '%s'='%s'\n", soap->level, id, ns)); if (i < 0) - { np->ns = strcpy((char*)np->id + n + 1, ns); + { np->ns = np->id + n + 1; + soap_strcpy((char*)np->ns, k, ns); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push NOT OK: no match found for '%s' in namespace mapping table (added to stack anyway)\n", ns)); } else @@ -2838,15 +3041,16 @@ soap_push_namespace(struct soap *soap, const char *id, const char *ns) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 void SOAP_FMAC2 soap_pop_namespace(struct soap *soap) -{ register struct soap_nlist *np, *nq; +{ struct soap_nlist *np, *nq; for (np = soap->nlist; np && np->level >= soap->level; np = nq) { nq = np->next; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Pop namespace binding (level=%u) '%s'\n", soap->level, np->id)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Pop namespace binding (level=%u) '%s' level=%u\n", soap->level, np->id, np->level)); SOAP_FREE(soap, np); } soap->nlist = np; @@ -2854,24 +3058,26 @@ soap_pop_namespace(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 soap_match_namespace(struct soap *soap, const char *id1, const char *id2, size_t n1, size_t n2) -{ register struct soap_nlist *np = soap->nlist; +{ struct soap_nlist *np = soap->nlist; const char *s; while (np && (strncmp(np->id, id1, n1) || np->id[n1])) np = np->next; if (np) - { if (!(soap->mode & SOAP_XML_IGNORENS)) - if (np->index < 0 + { if (!(soap->mode & SOAP_XML_IGNORENS) && (n2 > 0 || !np->ns || *np->ns)) + { if (np->index < 0 || ((s = soap->local_namespaces[np->index].id) && (strncmp(s, id2, n2) || (s[n2] && s[n2] != '_')))) return SOAP_NAMESPACE; + } return SOAP_OK; } if (n1 == 0) - return (soap->mode & SOAP_XML_IGNORENS) ? SOAP_OK : SOAP_NAMESPACE; + return n2 == 0 || (soap->mode & SOAP_XML_IGNORENS) ? SOAP_OK : SOAP_NAMESPACE; if ((n1 == 3 && n1 == n2 && !strncmp(id1, "xml", 3) && !strncmp(id1, id2, 3)) || (soap->mode & SOAP_XML_IGNORENS)) return SOAP_OK; @@ -2880,17 +3086,19 @@ soap_match_namespace(struct soap *soap, const char *id1, const char *id2, size_t #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 const char* SOAP_FMAC2 -soap_current_namespace(struct soap *soap, const char *tag) -{ register struct soap_nlist *np; - register const char *s; +soap_current_namespace_tag(struct soap *soap, const char *tag) +{ struct soap_nlist *np; + const char *s; if (!tag || !strncmp(tag, "xml", 3)) return NULL; np = soap->nlist; - if (!(s = strchr(tag, ':'))) + s = strchr(tag, ':'); + if (!s) { while (np && *np->id) /* find default namespace, if present */ np = np->next; } @@ -2903,7 +3111,7 @@ soap_current_namespace(struct soap *soap, const char *tag) if (np) { if (np->index >= 0) return soap->namespaces[np->index].ns; - if (np->ns) + if (np->ns && *np->ns) return soap_strdup(soap, np->ns); } return NULL; @@ -2911,14 +3119,44 @@ soap_current_namespace(struct soap *soap, const char *tag) #endif /******************************************************************************/ + +#ifndef PALM_2 +SOAP_FMAC1 +const char* +SOAP_FMAC2 +soap_current_namespace_att(struct soap *soap, const char *tag) +{ struct soap_nlist *np; + const char *s; + if (!tag || !strncmp(tag, "xml", 3)) + return NULL; + s = strchr(tag, ':'); + if (!s) + return NULL; + np = soap->nlist; + while (np && (strncmp(np->id, tag, s - tag) || np->id[s - tag])) + np = np->next; + if (!np) + soap->error = SOAP_NAMESPACE; + if (np) + { if (np->index >= 0) + return soap->namespaces[np->index].ns; + if (np->ns && *np->ns) + return soap_strdup(soap, np->ns); + } + return NULL; +} +#endif + +/******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 soap_tag_cmp(const char *s, const char *t) { for (;;) - { register int c1 = *s; - register int c2 = *t; + { int c1 = *s; + int c2 = *t; if (!c1 || c1 == '"') break; if (c2 != '-') @@ -2959,13 +3197,14 @@ soap_tag_cmp(const char *s, const char *t) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 soap_match_tag(struct soap *soap, const char *tag1, const char *tag2) -{ register const char *s, *t; - register int err; +{ const char *s, *t; + int err; if (!tag1 || !tag2 || !*tag2) return SOAP_OK; s = strchr(tag1, ':'); @@ -2974,35 +3213,40 @@ soap_match_tag(struct soap *soap, const char *tag1, const char *tag2) { if (s) { if (t[1] && SOAP_STRCMP(s + 1, t + 1)) return SOAP_TAG_MISMATCH; - if (t != tag2 && (err = soap_match_namespace(soap, tag1, tag2, s - tag1, t - tag2))) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags '%s' and '%s' match but namespaces differ\n", tag1, tag2)); - if (err == SOAP_NAMESPACE) - return SOAP_TAG_MISMATCH; - return err; + if (t != tag2 && !(soap->mode & SOAP_XML_IGNORENS)) + { err = soap_match_namespace(soap, tag1, tag2, s - tag1, t - tag2); + if (err) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags '%s' and '%s' match but namespaces differ\n", tag1, tag2)); + if (err == SOAP_NAMESPACE) + return SOAP_TAG_MISMATCH; + return err; + } } } else if (!t[1]) - { err = soap_match_namespace(soap, tag1, tag2, 0, t - tag2); - if (err == SOAP_NAMESPACE) + { if ((soap->mode & SOAP_XML_IGNORENS) || soap_match_namespace(soap, tag1, tag2, 0, t - tag2)) return SOAP_TAG_MISMATCH; } else if (SOAP_STRCMP(tag1, t + 1)) { return SOAP_TAG_MISMATCH; } - else if (t != tag2 && (err = soap_match_namespace(soap, tag1, tag2, 0, t - tag2))) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags '%s' and '%s' match but namespaces differ\n", tag1, tag2)); - if (err == SOAP_NAMESPACE) - return SOAP_TAG_MISMATCH; - return err; + else if (t != tag2) + { err = soap_match_namespace(soap, tag1, tag2, 0, t - tag2); + if (err) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags '%s' and '%s' match but namespaces differ\n", tag1, tag2)); + if (err == SOAP_NAMESPACE) + return SOAP_TAG_MISMATCH; + return err; + } } DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags and (default) namespaces match: '%s' '%s'\n", tag1, tag2)); return SOAP_OK; } if (s) - { if (SOAP_STRCMP(s + 1, tag2)) + { if (!(soap->mode & SOAP_XML_IGNORENS) || SOAP_STRCMP(s + 1, tag2)) /* always fails (except when ignoring ns) */ return SOAP_TAG_MISMATCH; } - else if (SOAP_STRCMP(tag1, tag2)) + else if (SOAP_STRCMP(tag1, tag2) || ((soap->mode & SOAP_XML_STRICT) && !(soap->mode & SOAP_XML_IGNORENS) && soap_match_namespace(soap, tag1, tag2, 0, 0))) /* strict checking: default namespace must be null namespace */ return SOAP_TAG_MISMATCH; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Tags match: '%s' '%s'\n", tag1, tag2)); return SOAP_OK; @@ -3010,6 +3254,50 @@ soap_match_tag(struct soap *soap, const char *tag1, const char *tag2) #endif /******************************************************************************/ + +#ifndef PALM_2 +SOAP_FMAC1 +int +SOAP_FMAC2 +soap_match_att(struct soap *soap, const char *tag1, const char *tag2) +{ const char *s, *t; + int err; + if (!tag1 || !tag2 || !*tag2) + return SOAP_OK; + s = strchr(tag1, ':'); + t = strchr(tag2, ':'); + if (t) + { if (s) + { if (t[1] && SOAP_STRCMP(s + 1, t + 1)) + return SOAP_TAG_MISMATCH; + if (t != tag2 && !(soap->mode & SOAP_XML_IGNORENS)) + { err = soap_match_namespace(soap, tag1, tag2, s - tag1, t - tag2); + if (err) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Atts '%s' and '%s' match but namespaces differ\n", tag1, tag2)); + if (err == SOAP_NAMESPACE) + return SOAP_TAG_MISMATCH; + return err; + } + } + } + else if (!t[1] || t != tag2 || SOAP_STRCMP(tag1, t + 1)) + return SOAP_TAG_MISMATCH; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Atts and (default) namespaces match: '%s' '%s'\n", tag1, tag2)); + return SOAP_OK; + } + if (s) + { if (!(soap->mode & SOAP_XML_IGNORENS) || SOAP_STRCMP(s + 1, tag2)) /* always fails (except when ignoring ns) */ + return SOAP_TAG_MISMATCH; + } + else if (SOAP_STRCMP(tag1, tag2)) + return SOAP_TAG_MISMATCH; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Atts match: '%s' '%s'\n", tag1, tag2)); + return SOAP_OK; +} +#endif + +/******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -3029,28 +3317,28 @@ soap_match_array(struct soap *soap, const char *type) /******************************************************************************\ * - * SSL/TLS + * SSL/TLS * \******************************************************************************/ -/******************************************************************************/ #ifdef WITH_OPENSSL #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 soap_rand() -{ unsigned char buf[4]; +{ int r; if (!soap_ssl_init_done) soap_ssl_init(); - RAND_pseudo_bytes(buf, 4); - return *(int*)buf; + RAND_pseudo_bytes((unsigned char*)&r, sizeof(int)); + return r; } #endif #endif /******************************************************************************/ -#if defined(WITH_OPENSSL) || defined(WITH_GNUTLS) + +#if defined(WITH_OPENSSL) || defined(WITH_GNUTLS) || defined(WITH_SYSTEMSSL) #ifndef PALM_2 SOAP_FMAC1 int @@ -3068,13 +3356,15 @@ soap_ssl_server_context(struct soap *soap, unsigned short flags, const char *key soap->password = password; soap->cafile = cafile; soap->capath = capath; - soap->crlfile = NULL; #ifdef WITH_OPENSSL soap->dhfile = dhfile; soap->randfile = randfile; + if (!soap->fsslverify) + soap->fsslverify = ssl_verify_callback; #endif soap->ssl_flags = flags | (dhfile == NULL ? SOAP_SSL_RSA : 0); #ifdef WITH_GNUTLS + (void)randfile; (void)sid; if (dhfile) { char *s; int n = (int)soap_strtoul(dhfile, &s, 10); @@ -3110,6 +3400,11 @@ soap_ssl_server_context(struct soap *soap, unsigned short flags, const char *key soap->xcred = NULL; } #endif +#ifdef WITH_SYSTEMSSL + (void)randfile; (void)sid; + if (soap->ctx) + gsk_environment_close(&soap->ctx); +#endif err = soap->fsslauth(soap); #ifdef WITH_OPENSSL if (!err) @@ -3125,7 +3420,8 @@ soap_ssl_server_context(struct soap *soap, unsigned short flags, const char *key #endif /******************************************************************************/ -#if defined(WITH_OPENSSL) || defined(WITH_GNUTLS) + +#if defined(WITH_OPENSSL) || defined(WITH_GNUTLS) || defined(WITH_SYSTEMSSL) #ifndef PALM_2 SOAP_FMAC1 int @@ -3146,9 +3442,11 @@ soap_ssl_client_context(struct soap *soap, unsigned short flags, const char *key #ifdef WITH_OPENSSL soap->dhfile = NULL; soap->randfile = randfile; - soap->fsslverify = (flags & SOAP_SSL_ALLOW_EXPIRED_CERTIFICATE) == 0 ? ssl_verify_callback : ssl_verify_callback_allow_expired_certificate; + if (!soap->fsslverify) + soap->fsslverify = (flags & SOAP_SSL_ALLOW_EXPIRED_CERTIFICATE) == 0 ? ssl_verify_callback : ssl_verify_callback_allow_expired_certificate; #endif #ifdef WITH_GNUTLS + (void)randfile; if (soap->session) { gnutls_deinit(soap->session); soap->session = NULL; @@ -3158,12 +3456,62 @@ soap_ssl_client_context(struct soap *soap, unsigned short flags, const char *key soap->xcred = NULL; } #endif +#ifdef WITH_SYSTEMSSL + (void)randfile; + if (soap->ctx) + gsk_environment_close(&soap->ctx); +#endif return soap->fsslauth(soap); } #endif #endif /******************************************************************************/ + +#if defined(WITH_OPENSSL) || defined(WITH_GNUTLS) +#ifndef PALM_2 +SOAP_FMAC1 +int +SOAP_FMAC2 +soap_ssl_crl(struct soap *soap, const char *crlfile) +{ +#ifdef WITH_OPENSSL + if (crlfile && soap->ctx) + { +#if (OPENSSL_VERSION_NUMBER >= 0x0090800fL) + X509_STORE *store = SSL_CTX_get_cert_store(soap->ctx); + if (*crlfile) + { int ret; + X509_LOOKUP *lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file()); + ret = X509_load_crl_file(lookup, crlfile, X509_FILETYPE_PEM); + if (ret <= 0) + return soap_set_receiver_error(soap, soap_ssl_error(soap, ret), "Can't read CRL file", SOAP_SSL_ERROR); + } + X509_VERIFY_PARAM *param = X509_VERIFY_PARAM_new(); + X509_VERIFY_PARAM_set_flags(param, X509_V_FLAG_CRL_CHECK); + X509_STORE_set1_param(store, param); + X509_VERIFY_PARAM_free(param); +#endif + } + else + soap->crlfile = crlfile; /* activate later when store is available */ +#endif +#ifdef WITH_GNUTLS + if (crlfile && soap->xcred) + { if (*crlfile) + if (gnutls_certificate_set_x509_crl_file(soap->xcred, crlfile, GNUTLS_X509_FMT_PEM) < 0) + return soap_set_receiver_error(soap, "SSL/TLS error", "Can't read CRL file", SOAP_SSL_ERROR); + } + else + soap->crlfile = crlfile; /* activate later when xcred is available */ +#endif + return SOAP_OK; +} +#endif +#endif + +/******************************************************************************/ + #if defined(WITH_OPENSSL) || defined(WITH_GNUTLS) #ifndef PALM_2 SOAP_FMAC1 @@ -3175,8 +3523,7 @@ soap_ssl_init() { soap_ssl_init_done = 1; #ifdef WITH_OPENSSL SSL_library_init(); - OpenSSL_add_all_algorithms(); /* 2.8.1 change (wsseapi.c) */ - OpenSSL_add_all_digests(); + OpenSSL_add_all_algorithms(); /* we keep ciphers and digests for the program's lifetime */ #ifndef WITH_LEAN SSL_load_error_strings(); #endif @@ -3206,6 +3553,21 @@ soap_ssl_init() #endif /******************************************************************************/ + +#if defined(WITH_OPENSSL) || defined(WITH_GNUTLS) +#ifndef PALM_2 +SOAP_FMAC1 +void +SOAP_FMAC2 +soap_ssl_noinit() +{ /* Call this first to bypass SSL init is SSL is already initialized elsewhere */ + soap_ssl_init_done = 1; +} +#endif +#endif + +/******************************************************************************/ + #if defined(WITH_OPENSSL) || defined(WITH_GNUTLS) #ifndef PALM_1 SOAP_FMAC1 @@ -3217,35 +3579,33 @@ soap_ssl_error(struct soap *soap, int ret) int err = SSL_get_error(soap->ssl, ret); const char *msg = soap_code_str(h_ssl_error_codes, err); if (msg) - strcpy(soap->msgbuf, msg); + (SOAP_SNPRINTF(soap->msgbuf, sizeof(soap->msgbuf), strlen(msg) + 1), "%s\n", msg); else return ERR_error_string(err, soap->msgbuf); if (ERR_peek_error()) { unsigned long r; - strcat(soap->msgbuf, "\n"); while ((r = ERR_get_error())) - ERR_error_string_n(r, soap->msgbuf + strlen(soap->msgbuf), sizeof(soap->msgbuf) - strlen(soap->msgbuf)); + { size_t l = strlen(soap->msgbuf); + ERR_error_string_n(r, soap->msgbuf + l, sizeof(soap->msgbuf) - l); + } } else - { switch (ret) + { size_t l = strlen(soap->msgbuf); + switch (ret) { case 0: - strcpy(soap->msgbuf, "EOF was observed that violates the SSL/TLS protocol. The client probably provided invalid authentication information."); + soap_strcpy(soap->msgbuf + l, sizeof(soap->msgbuf) - l, "EOF was observed that violates the SSL/TLS protocol. The client probably provided invalid authentication information."); break; case -1: -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->msgbuf, sizeof(soap->msgbuf), "Error observed by underlying SSL/TLS BIO: %s", strerror(errno)); -#else - { const char *s = strerror(errno); - size_t l = strlen(s); - sprintf(soap->msgbuf, "Error observed by underlying SSL/TLS BIO: %s", l + 44 < sizeof(soap->msgbuf) ? s : SOAP_STR_EOS); + { const char *s = strerror(soap_errno); + (SOAP_SNPRINTF(soap->msgbuf + l, sizeof(soap->msgbuf) - l, strlen(s) + 42), "Error observed by underlying SSL/TLS BIO: %s", s); } -#endif break; } } return soap->msgbuf; #endif #ifdef WITH_GNUTLS + (void)soap; return gnutls_strerror(ret); #endif } @@ -3253,7 +3613,30 @@ soap_ssl_error(struct soap *soap, int ret) #endif /******************************************************************************/ -#if defined(WITH_OPENSSL) || defined(WITH_GNUTLS) + +#ifdef WITH_SYSTEMSSL +static int +ssl_recv(int sk, void *s, int n, char *user) +{ + (void)user; + return recv(sk, s, n, 0); +} +#endif + +/******************************************************************************/ + +#ifdef WITH_SYSTEMSSL +static int +ssl_send(int sk, void *s, int n, char *user) +{ + (void)user; + return send(sk, s, n, 0); +} +#endif + +/******************************************************************************/ + +#if defined(WITH_OPENSSL) || defined(WITH_GNUTLS) || defined(WITH_SYSTEMSSL) #ifndef PALM_1 static int ssl_auth_init(struct soap *soap) @@ -3268,7 +3651,15 @@ ssl_auth_init(struct soap *soap) soap_ssl_init(); ERR_clear_error(); if (!soap->ctx) - { if (!(soap->ctx = SSL_CTX_new(SSLv23_method()))) + { +#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) + /* TLS_method: a TLS/SSL connection established may understand the SSLv3, TLSv1, TLSv1.1 and TLSv1.2 protocols. */ + soap->ctx = SSL_CTX_new(TLS_method()); +#else + /* SSLv23_method: a TLS/SSL connection established may understand the SSLv3, TLSv1, TLSv1.1 and TLSv1.2 protocols. */ + soap->ctx = SSL_CTX_new(SSLv23_method()); +#endif + if (!soap->ctx) return soap_set_receiver_error(soap, "SSL/TLS error", "Can't setup context", SOAP_SSL_ERROR); /* The following alters the behavior of SSL read/write: */ #if 0 @@ -3289,41 +3680,52 @@ ssl_auth_init(struct soap *soap) { if (!SSL_CTX_set_default_verify_paths(soap->ctx)) return soap_set_receiver_error(soap, "SSL/TLS error", "Can't read default CA file and/or directory", SOAP_SSL_ERROR); } -/* This code assumes a typical scenario, see alternative code below */ + if (soap->crlfile) + { if (soap_ssl_crl(soap, soap->crlfile)) + return soap->error; + } +/* This code assumes a typical scenario with key and cert in one PEM file, see alternative code below */ +#if 1 if (soap->keyfile) { if (!SSL_CTX_use_certificate_chain_file(soap->ctx, soap->keyfile)) - return soap_set_receiver_error(soap, "SSL/TLS error", "Can't read certificate key file", SOAP_SSL_ERROR); + return soap_set_receiver_error(soap, "SSL/TLS error", "Can't find or read certificate in key file", SOAP_SSL_ERROR); if (soap->password) { SSL_CTX_set_default_passwd_cb_userdata(soap->ctx, (void*)soap->password); SSL_CTX_set_default_passwd_cb(soap->ctx, ssl_password); } - if (!SSL_CTX_use_PrivateKey_file(soap->ctx, soap->keyfile, SSL_FILETYPE_PEM)) - return soap_set_receiver_error(soap, "SSL/TLS error", "Can't read key file", SOAP_SSL_ERROR); #ifndef WM_SECURE_KEY_STORAGE if (!SSL_CTX_use_PrivateKey_file(soap->ctx, soap->keyfile, SSL_FILETYPE_PEM)) return soap_set_receiver_error(soap, "SSL/TLS error", "Can't read key file", SOAP_SSL_ERROR); #endif } -#if defined(VXWORKS) && defined(WM_SECURE_KEY_STORAGE) - if (NULL == (pkey = ipcom_key_db_pkey_get(soap->keyid))) - return soap_set_receiver_error(soap, "SSL error", "Can't find key", SOAP_SSL_ERROR); - if (0 == SSL_CTX_use_PrivateKey(soap->ctx, pkey)) - return soap_set_receiver_error(soap, "SSL error", "Can't read key", SOAP_SSL_ERROR); -#endif -/* Suggested alternative approach to check the key file for certs (cafile=NULL):*/ -#if 0 +#else +/* Suggested alternative approach to check the key file for cert only when cafile==NULL */ if (soap->password) { SSL_CTX_set_default_passwd_cb_userdata(soap->ctx, (void*)soap->password); SSL_CTX_set_default_passwd_cb(soap->ctx, ssl_password); } - if (!soap->cafile || !SSL_CTX_use_certificate_chain_file(soap->ctx, soap->cafile)) + if (!soap->cafile) { if (soap->keyfile) { if (!SSL_CTX_use_certificate_chain_file(soap->ctx, soap->keyfile)) - return soap_set_receiver_error(soap, "SSL/TLS error", "Can't read certificate or key file", SOAP_SSL_ERROR); + return soap_set_receiver_error(soap, "SSL/TLS error", "Can't find or read certificate in key file", SOAP_SSL_ERROR); if (!SSL_CTX_use_PrivateKey_file(soap->ctx, soap->keyfile, SSL_FILETYPE_PEM)) return soap_set_receiver_error(soap, "SSL/TLS error", "Can't read key file", SOAP_SSL_ERROR); } } + else /* use cafile for (server) cert and keyfile for (server) key */ + { if (!SSL_CTX_use_certificate_chain_file(soap->ctx, soap->cafile)) + return soap_set_receiver_error(soap, "SSL/TLS error", "Can't read CA file", SOAP_SSL_ERROR); + if (soap->keyfile) + if (!SSL_CTX_use_PrivateKey_file(soap->ctx, soap->keyfile, SSL_FILETYPE_PEM)) + return soap_set_receiver_error(soap, "SSL/TLS error", "Can't read key file", SOAP_SSL_ERROR); + } +#endif +#if defined(VXWORKS) && defined(WM_SECURE_KEY_STORAGE) + pkey = ipcom_key_db_pkey_get(soap->keyid); + if (!pkey) + return soap_set_receiver_error(soap, "SSL error", "Can't find key", SOAP_SSL_ERROR); + if (!SSL_CTX_use_PrivateKey(soap->ctx, pkey)) + return soap_set_receiver_error(soap, "SSL error", "Can't read key", SOAP_SSL_ERROR); #endif if ((soap->ssl_flags & SOAP_SSL_RSA)) { RSA *rsa = RSA_generate_key(SOAP_SSL_RSA_BITS, RSA_F4, NULL, NULL); @@ -3360,11 +3762,27 @@ ssl_auth_init(struct soap *soap) } DH_free(dh); } - flags = (SSL_OP_ALL | SSL_OP_NO_SSLv2); /* disable SSL v2 */ + flags = (SSL_OP_ALL | SSL_OP_NO_SSLv2); /* disable SSL v2 by default */ if ((soap->ssl_flags & SOAP_SSLv3)) + { +#if (OPENSSL_VERSION_NUMBER >= 0x10001000L) + flags |= SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1 | SSL_OP_NO_TLSv1_2; +#else flags |= SSL_OP_NO_TLSv1; - if ((soap->ssl_flags & SOAP_TLSv1)) - flags |= SSL_OP_NO_SSLv3; +#endif + } + else + { if (!(soap->ssl_flags & SOAP_SSLv3_TLSv1)) + flags |= SSL_OP_NO_SSLv3; /* disable SSL v3 by default, unless SOAP_SSLv3 or SOAP_SSLv3_TLSv1 is set */ +#if (OPENSSL_VERSION_NUMBER >= 0x10001000L) + if ((soap->ssl_flags & SOAP_TLSv1_0)) + flags |= SSL_OP_NO_TLSv1_1 | SSL_OP_NO_TLSv1_2; + else if ((soap->ssl_flags & SOAP_TLSv1_1)) + flags |= SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_2; + else if ((soap->ssl_flags & SOAP_TLSv1_2)) + flags |= SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1; +#endif + } #ifdef SSL_OP_NO_TICKET /* TLS extension is enabled by default in OPENSSL v0.9.8k Disable it by adding SSL_OP_NO_TICKET */ @@ -3395,11 +3813,11 @@ ssl_auth_init(struct soap *soap) return soap_set_receiver_error(soap, "SSL/TLS error", "Can't read CA file", SOAP_SSL_ERROR); } if (soap->crlfile) - { if (gnutls_certificate_set_x509_crl_file(soap->xcred, soap->crlfile, GNUTLS_X509_FMT_PEM) < 0) - return soap_set_receiver_error(soap, "SSL/TLS error", "Can't read CRL file", SOAP_SSL_ERROR); + { if (soap_ssl_crl(soap, soap->crlfile)) + return soap->error; } if (soap->keyfile) - { if (gnutls_certificate_set_x509_key_file(soap->xcred, soap->keyfile, soap->keyfile, GNUTLS_X509_FMT_PEM) < 0) /* TODO: GNUTLS need to concat cert and key in single key file */ + { if (gnutls_certificate_set_x509_key_file(soap->xcred, soap->keyfile, soap->keyfile, GNUTLS_X509_FMT_PEM) < 0) /* Assumes that key and cert(s) are concatenated in the keyfile */ return soap_set_receiver_error(soap, "SSL/TLS error", "Can't read key file", SOAP_SSL_ERROR); } } @@ -3434,11 +3852,74 @@ ssl_auth_init(struct soap *soap) if ((soap->ssl_flags & SOAP_SSL_REQUIRE_CLIENT_AUTHENTICATION)) gnutls_certificate_server_set_request(soap->session, GNUTLS_CERT_REQUEST); gnutls_session_enable_compatibility_mode(soap->session); - if ((soap->ssl_flags & SOAP_TLSv1)) + if ((soap->ssl_flags & SOAP_SSLv3)) + { int protocol_priority[] = { GNUTLS_SSL3, 0 }; + if (gnutls_protocol_set_priority(soap->session, protocol_priority) != GNUTLS_E_SUCCESS) + return soap_set_receiver_error(soap, "SSL/TLS error", "Can't set SSLv3 protocol", SOAP_SSL_ERROR); + } + else if ((soap->ssl_flags & SOAP_TLSv1_0)) { int protocol_priority[] = { GNUTLS_TLS1_0, 0 }; if (gnutls_protocol_set_priority(soap->session, protocol_priority) != GNUTLS_E_SUCCESS) - return soap_set_receiver_error(soap, "SSL/TLS error", "Can't set TLS v1.0 protocol", SOAP_SSL_ERROR); + return soap_set_receiver_error(soap, "SSL/TLS error", "Can't set TLSv1.0 protocol", SOAP_SSL_ERROR); + } + else if ((soap->ssl_flags & SOAP_TLSv1_1)) + { int protocol_priority[] = { GNUTLS_TLS1_1, 0 }; + if (gnutls_protocol_set_priority(soap->session, protocol_priority) != GNUTLS_E_SUCCESS) + return soap_set_receiver_error(soap, "SSL/TLS error", "Can't set TLSv1.1 protocol", SOAP_SSL_ERROR); + } + else if ((soap->ssl_flags & SOAP_TLSv1_2)) + { int protocol_priority[] = { GNUTLS_TLS1_2, 0 }; + if (gnutls_protocol_set_priority(soap->session, protocol_priority) != GNUTLS_E_SUCCESS) + return soap_set_receiver_error(soap, "SSL/TLS error", "Can't set TLSv1.2 protocol", SOAP_SSL_ERROR); + } + else if ((soap->ssl_flags & SOAP_SSLv3_TLSv1)) + { int protocol_priority[] = { GNUTLS_SSL3, GNUTLS_TLS1_0, GNUTLS_TLS1_1, GNUTLS_TLS1_2, 0 }; + if (gnutls_protocol_set_priority(soap->session, protocol_priority) != GNUTLS_E_SUCCESS) + return soap_set_receiver_error(soap, "SSL/TLS error", "Can't set SSLv3 & TLSv1 protocols", SOAP_SSL_ERROR); + } + else + { int protocol_priority[] = { GNUTLS_TLS1_0, GNUTLS_TLS1_1, GNUTLS_TLS1_2, 0 }; + if (gnutls_protocol_set_priority(soap->session, protocol_priority) != GNUTLS_E_SUCCESS) + return soap_set_receiver_error(soap, "SSL/TLS error", "Can't set TLSv1 protocols", SOAP_SSL_ERROR); + } + } +#endif +#ifdef WITH_SYSTEMSSL + if (!soap->ctx) + { int err; + err = gsk_environment_open(&soap->ctx); + if (err == GSK_OK) + err = gsk_attribute_set_enum(soap->ctx, GSK_PROTOCOL_SSLV2, GSK_PROTOCOL_SSLV2_OFF); + if (err == GSK_OK) + { if ((soap->ssl_flags & SOAP_SSLv3) || (soap->ssl_flags & SOAP_SSLv3_TLSv1)) + err = gsk_attribute_set_enum(soap->ctx, GSK_PROTOCOL_SSLV3, GSK_PROTOCOL_SSLV3_ON); + else + err = gsk_attribute_set_enum(soap->ctx, GSK_PROTOCOL_SSLV3, GSK_PROTOCOL_SSLV3_OFF); } + if (!(soap->ssl_flags & SOAP_SSLv3)) + { if (err == GSK_OK) + err = gsk_attribute_set_enum(soap->ctx, GSK_PROTOCOL_TLSV1, GSK_PROTOCOL_TLSV1_ON); + if (err == GSK_OK) + err = gsk_attribute_set_enum(soap->ctx, GSK_PROTOCOL_TLSV1_1, GSK_PROTOCOL_TLSV1_1_ON); + if (err == GSK_OK) + err = gsk_attribute_set_enum(soap->ctx, GSK_PROTOCOL_TLSV1_2, GSK_PROTOCOL_TLSV1_2_ON); + } + else + { if (err == GSK_OK) + err = gsk_attribute_set_enum(soap->ctx, GSK_PROTOCOL_TLSV1, GSK_PROTOCOL_TLSV1_OFF); + if (err == GSK_OK) + err = gsk_attribute_set_enum(soap->ctx, GSK_PROTOCOL_TLSV1_1, GSK_PROTOCOL_TLSV1_1_OFF); + if (err == GSK_OK) + err = gsk_attribute_set_enum(soap->ctx, GSK_PROTOCOL_TLSV1_2, GSK_PROTOCOL_TLSV1_2_OFF); + } + if (err == GSK_OK) + err = gsk_attribute_set_buffer(soap->ctx, GSK_KEYRING_FILE, soap->keyfile, 0); /* keyfile is a keyring .kdb file */ + if (err == GSK_OK) + err = gsk_attribute_set_buffer(soap->ctx, GSK_KEYRING_PW, soap->password, 0); /* locked by password */ + if (err == GSK_OK) + err = gsk_environment_init(soap->ctx); + if (err != GSK_OK) + return soap_set_receiver_error(soap, gsk_strerror(err), "SYSTEM SSL error in ssl_auth_init()", SOAP_SSL_ERROR); } #endif return SOAP_OK; @@ -3447,63 +3928,75 @@ ssl_auth_init(struct soap *soap) #endif /******************************************************************************/ + #ifdef WITH_OPENSSL #ifndef PALM_1 static int ssl_password(char *buf, int num, int rwflag, void *userdata) -{ if (num < (int)strlen((char*)userdata) + 1) +{ (void)rwflag; + if (!buf || !userdata) return 0; - return (int)strlen(strcpy(buf, (char*)userdata)); + soap_strcpy(buf, (size_t)num, (char*)userdata); + return (int)strlen(buf); } #endif #endif /******************************************************************************/ + #ifdef WITH_OPENSSL #ifndef PALM_1 static int ssl_verify_callback(int ok, X509_STORE_CTX *store) -{ +{ (void)store; #ifdef SOAP_DEBUG if (!ok) { char buf[1024]; int err = X509_STORE_CTX_get_error(store); X509 *cert = X509_STORE_CTX_get_current_cert(store); - fprintf(stderr, "SSL verify error or warning with certificate at depth %d: %s\n", X509_STORE_CTX_get_error_depth(store), X509_verify_cert_error_string(err)); + fprintf(stderr, "\nDEBUG mode TLS/SSL warnings:\nSSL verify error %d or warning with certificate at depth %d: %s\n", err, X509_STORE_CTX_get_error_depth(store), X509_verify_cert_error_string(err)); X509_NAME_oneline(X509_get_issuer_name(cert), buf, sizeof(buf)); - fprintf(stderr, "certificate issuer %s\n", buf); + fprintf(stderr, " certificate issuer: %s\n", buf); X509_NAME_oneline(X509_get_subject_name(cert), buf, sizeof(buf)); - fprintf(stderr, "certificate subject %s\n", buf); - /* accept self signed certificates and certificates out of date */ + fprintf(stderr, " certificate subject: %s\n", buf); + /* accept self-signed certificates and certificates out of date */ switch (err) { case X509_V_ERR_CERT_NOT_YET_VALID: case X509_V_ERR_CERT_HAS_EXPIRED: case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: + case X509_V_ERR_UNABLE_TO_GET_CRL: + case X509_V_ERR_CRL_NOT_YET_VALID: + case X509_V_ERR_CRL_HAS_EXPIRED: X509_STORE_CTX_set_error(store, X509_V_OK); ok = 1; + fprintf(stderr, "Initialize soap_ssl_client_context with SOAP_SSL_ALLOW_EXPIRED_CERTIFICATE to allow this verification error to pass without DEBUG mode enabled\n"); } } #endif - /* Note: return 1 to continue, but unsafe progress will be terminated by OpenSSL */ + /* Note: return 1 to try to continue, but unsafe progress will be terminated by OpenSSL */ return ok; } #endif #endif /******************************************************************************/ + #ifdef WITH_OPENSSL #ifndef PALM_1 static int ssl_verify_callback_allow_expired_certificate(int ok, X509_STORE_CTX *store) { ok = ssl_verify_callback(ok, store); if (!ok) - { /* accept self signed certificates and certificates out of date */ + { /* accept self signed certificates, expired certificates, and certficiates w/o CRL */ switch (X509_STORE_CTX_get_error(store)) { case X509_V_ERR_CERT_NOT_YET_VALID: case X509_V_ERR_CERT_HAS_EXPIRED: case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: + case X509_V_ERR_UNABLE_TO_GET_CRL: + case X509_V_ERR_CRL_NOT_YET_VALID: + case X509_V_ERR_CRL_HAS_EXPIRED: X509_STORE_CTX_set_error(store, X509_V_OK); ok = 1; } @@ -3515,6 +4008,7 @@ ssl_verify_callback_allow_expired_certificate(int ok, X509_STORE_CTX *store) #endif /******************************************************************************/ + #ifdef WITH_GNUTLS static const char * ssl_verify(struct soap *soap, const char *host) @@ -3554,6 +4048,7 @@ ssl_verify(struct soap *soap, const char *host) #endif /******************************************************************************/ + #if defined(WITH_OPENSSL) || defined(WITH_GNUTLS) #ifndef WITH_NOIO #ifndef PALM_1 @@ -3568,7 +4063,7 @@ soap_ssl_accept(struct soap *soap) if (!soap_valid_socket(sk)) return soap_set_receiver_error(soap, "SSL/TLS error", "No socket in soap_ssl_accept()", SOAP_SSL_ERROR); soap->ssl_flags &= ~SOAP_SSL_CLIENT; - if (!soap->ctx && (soap->error = soap->fsslauth(soap))) + if (!soap->ctx && (soap->error = soap->fsslauth(soap)) != SOAP_OK) return soap->error; if (!soap->ssl) { soap->ssl = SSL_new(soap->ctx); @@ -3630,7 +4125,7 @@ soap_ssl_accept(struct soap *soap) if (!soap_valid_socket(sk)) return soap_set_receiver_error(soap, "SSL/TLS error", "No socket in soap_ssl_accept()", SOAP_SSL_ERROR); soap->ssl_flags &= ~SOAP_SSL_CLIENT; - if (!soap->session && (soap->error = soap->fsslauth(soap))) + if (!soap->session && (soap->error = soap->fsslauth(soap)) != SOAP_OK) { soap_closesock(soap); return soap->error; } @@ -3672,6 +4167,50 @@ soap_ssl_accept(struct soap *soap) } } #endif +#ifdef WITH_SYSTEMSSL + gsk_iocallback local_io = { ssl_recv, ssl_send, NULL, NULL, NULL, NULL }; + int err, s; + int retries = 0; + if (soap->accept_timeout) + { SOAP_SOCKNONBLOCK(sk) + retries = 10*soap->accept_timeout; + } + if (retries <= 0) + retries = 100; /* timeout: 10 sec retries, 100 times 0.1 sec */ + err = gsk_secure_socket_open(soap->ctx, &soap->ssl); + if (err == GSK_OK) + err = gsk_attribute_set_numeric_value(soap->ssl, GSK_FD, sk); + if (err == GSK_OK) + err = gsk_attribute_set_buffer(soap->ssl, GSK_KEYRING_LABEL, soap->cafile, 0); + if (err == GSK_OK) + err = gsk_attribute_set_enum(soap->ssl, GSK_SESSION_TYPE, GSK_SERVER_SESSION); + if (err == GSK_OK) + err = gsk_attribute_set_buffer(soap->ssl, GSK_V3_CIPHER_SPECS_EXPANDED, "0035002F000A", 0); + if (err == GSK_OK) + err = gsk_attribute_set_enum(soap->ssl, GSK_V3_CIPHERS, GSK_V3_CIPHERS_CHAR4); + if (err == GSK_OK) + err = gsk_attribute_set_callback(soap->ssl, GSK_IO_CALLBACK, &local_io); + if (err != GSK_OK) + return soap_set_receiver_error(soap, gsk_strerror(err), "SYSTEM SSL error in soap_ssl_accept()", SOAP_SSL_ERROR); + while ((err = gsk_secure_socket_init(soap->ssl)) != GSK_OK) + { if (retries-- <= 0) + break; + if (err == GSK_WOULD_BLOCK_READ || err == GSK_WOULD_BLOCK_WRITE) + { if (err == GSK_WOULD_BLOCK_READ) + s = tcp_select(soap, sk, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, -100000); + else + s = tcp_select(soap, sk, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, -100000); + if (s < 0) + break; + } + else + { soap->errnum = soap_socket_errno(sk); + break; + } + } + if (err != GSK_OK) + return soap_set_receiver_error(soap, gsk_strerror(err), "gsk_secure_socket_init() failed in soap_ssl_accept()", SOAP_SSL_ERROR); +#endif if (soap->recv_timeout || soap->send_timeout) SOAP_SOCKNONBLOCK(sk) else @@ -3686,11 +4225,10 @@ soap_ssl_accept(struct soap *soap) /******************************************************************************\ * - * TCP/UDP [SSL/TLS] IPv4 and IPv6 + * TCP/UDP [SSL/TLS] IPv4 and IPv6 * \******************************************************************************/ -/******************************************************************************/ #ifndef WITH_NOIO #ifndef PALM_1 static int @@ -3712,11 +4250,12 @@ tcp_init(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_NOIO #ifndef PALM_1 static const char* tcp_error(struct soap *soap) -{ register const char *msg = NULL; +{ const char *msg = NULL; switch (soap->errmode) { case 0: msg = soap_strerror(soap); @@ -3730,12 +4269,7 @@ tcp_error(struct soap *soap) msg = soap_code_str(h_error_codes, soap->errnum); if (!msg) #endif - { -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->msgbuf, sizeof(soap->msgbuf), "TCP/UDP IP error %d", soap->errnum); -#else - sprintf(soap->msgbuf, "TCP/UDP IP error %d", soap->errnum); -#endif + { (SOAP_SNPRINTF(soap->msgbuf, sizeof(soap->msgbuf), 37), "TCP/UDP IP error %d", soap->errnum); msg = soap->msgbuf; } } @@ -3746,6 +4280,7 @@ tcp_error(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_IPV6 #ifndef WITH_NOIO #ifndef PALM_1 @@ -3764,15 +4299,16 @@ tcp_gethost(struct soap *soap, const char *addr, struct in_addr *inaddr) #ifdef AS400 iadd = inet_addr((void*)addr); #else - iadd = inet_addr(addr); + iadd = inet_addr((char*)addr); #endif #endif if (iadd != -1) - { memcpy(inaddr, &iadd, sizeof(iadd)); + { if (soap_memcpy((void*)inaddr, sizeof(struct in_addr), (const void*)&iadd, sizeof(iadd))) + return soap->error = SOAP_EOM; return SOAP_OK; } #if defined(__GLIBC__) || (defined(HAVE_GETHOSTBYNAME_R) && (defined(FREEBSD) || defined(__FreeBSD__))) || defined(__ANDROID__) - if (gethostbyname_r(addr, &hostent, soap->buf, SOAP_BUFLEN, &host, &soap->errnum) < 0) + if (gethostbyname_r(addr, &hostent, soap->buf, sizeof(soap->buf), &host, &soap->errnum) < 0) host = NULL; #elif defined(_AIX43) || ((defined(TRU64) || defined(HP_UX)) && defined(HAVE_GETHOSTBYNAME_R)) memset((void*)&ht_data, 0, sizeof(ht_data)); @@ -3781,7 +4317,7 @@ tcp_gethost(struct soap *soap, const char *addr, struct in_addr *inaddr) soap->errnum = h_errno; } #elif defined(HAVE_GETHOSTBYNAME_R) - host = gethostbyname_r(addr, &hostent, soap->buf, SOAP_BUFLEN, &soap->errnum); + host = gethostbyname_r(addr, &hostent, soap->buf, sizeof(soap->buf), &soap->errnum); #elif defined(VXWORKS) /* If the DNS resolver library resolvLib has been configured in the vxWorks * image, a query for the host IP address is sent to the DNS server, if the @@ -3793,12 +4329,12 @@ tcp_gethost(struct soap *soap, const char *addr, struct in_addr *inaddr) } #else #ifdef AS400 - if (!(host = gethostbyname((void*)addr))) - soap->errnum = h_errno; + host = gethostbyname((void*)addr); #else - if (!(host = gethostbyname(addr))) - soap->errnum = h_errno; + host = gethostbyname((char*)addr); #endif + if (!host) + soap->errnum = h_errno; #endif if (!host) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Host name not found\n")); @@ -3807,7 +4343,8 @@ tcp_gethost(struct soap *soap, const char *addr, struct in_addr *inaddr) #ifdef VXWORKS inaddr->s_addr = hostint; #else - memcpy(inaddr, host->h_addr, host->h_length); + if (soap_memcpy((void*)inaddr, sizeof(struct in_addr), (const void*)host->h_addr, (size_t)host->h_length)) + return soap->error = SOAP_EOM; #endif return SOAP_OK; } @@ -3816,6 +4353,7 @@ tcp_gethost(struct soap *soap, const char *addr, struct in_addr *inaddr) #endif /******************************************************************************/ + #ifndef WITH_NOIO #ifndef PALM_1 static SOAP_SOCKET @@ -3827,14 +4365,9 @@ tcp_connect(struct soap *soap, const char *endpoint, const char *host, int port) SOAP_SOCKET sk; int err = 0; #ifndef WITH_LEAN -#ifndef WIN32 - int len = SOAP_BUFLEN; -#else - int len = SOAP_BUFLEN + 1; /* speeds up windows xfer */ -#endif int set = 1; #endif -#if !defined(WITH_LEAN) || defined(WITH_OPENSSL) || defined(WITH_GNUTLS) +#if !defined(WITH_LEAN) || defined(WITH_OPENSSL) || defined(WITH_GNUTLS) || defined(WITH_SYSTEMSSL) int retries; #endif if (soap_valid_socket(soap->socket)) @@ -3842,13 +4375,17 @@ tcp_connect(struct soap *soap, const char *endpoint, const char *host, int port) soap->socket = SOAP_INVALID_SOCKET; if (tcp_init(soap)) { soap->errnum = 0; - soap_set_sender_error(soap, tcp_error(soap), "TCP init failed in tcp_connect()", SOAP_TCP_ERROR); + soap_set_receiver_error(soap, tcp_error(soap), "TCP init failed in tcp_connect()", SOAP_TCP_ERROR); return SOAP_INVALID_SOCKET; } soap->errmode = 0; #ifdef WITH_IPV6 memset((void*)&hints, 0, sizeof(hints)); +#ifdef WITH_IPV6_V6ONLY + hints.ai_family = PF_INET6; +#else hints.ai_family = PF_UNSPEC; +#endif #ifndef WITH_LEAN if ((soap->omode & SOAP_IO_UDP)) hints.ai_socktype = SOCK_DGRAM; @@ -3860,13 +4397,14 @@ tcp_connect(struct soap *soap, const char *endpoint, const char *host, int port) err = getaddrinfo(soap->proxy_host, soap_int2s(soap, soap->proxy_port), &hints, &res); else err = getaddrinfo(host, soap_int2s(soap, port), &hints, &res); - if (err) - { soap_set_sender_error(soap, SOAP_GAI_STRERROR(err), "getaddrinfo failed in tcp_connect()", SOAP_TCP_ERROR); + if (err || !res) + { soap_set_receiver_error(soap, SOAP_GAI_STRERROR(err), "getaddrinfo failed in tcp_connect()", SOAP_TCP_ERROR); return SOAP_INVALID_SOCKET; } ressave = res; again: sk = socket(res->ai_family, res->ai_socktype, res->ai_protocol); + soap->error = SOAP_OK; soap->errmode = 0; #else #ifndef WITH_LEAN @@ -3888,13 +4426,13 @@ again: } #endif soap->errnum = soap_socket_errno(sk); - soap_set_sender_error(soap, tcp_error(soap), "socket failed in tcp_connect()", SOAP_TCP_ERROR); + soap_set_receiver_error(soap, tcp_error(soap), "socket failed in tcp_connect()", SOAP_TCP_ERROR); #ifdef WITH_IPV6 freeaddrinfo(ressave); #endif return SOAP_INVALID_SOCKET; } -#ifdef SOCKET_CLOSE_ON_EXEC +#ifdef SOCKET_CLOSE_ON_EXIT #ifdef WIN32 #ifndef UNDER_CE SetHandleInformation((HANDLE)sk, HANDLE_FLAG_INHERIT, 0); @@ -3904,14 +4442,14 @@ again: #endif #endif #ifndef WITH_LEAN - if (soap->connect_flags == SO_LINGER) + if ((soap->connect_flags & SO_LINGER)) { struct linger linger; memset((void*)&linger, 0, sizeof(linger)); linger.l_onoff = 1; linger.l_linger = soap->linger_time; if (setsockopt(sk, SOL_SOCKET, SO_LINGER, (char*)&linger, sizeof(struct linger))) { soap->errnum = soap_socket_errno(sk); - soap_set_sender_error(soap, tcp_error(soap), "setsockopt SO_LINGER failed in tcp_connect()", SOAP_TCP_ERROR); + soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_LINGER failed in tcp_connect()", SOAP_TCP_ERROR); soap->fclosesocket(soap, sk); #ifdef WITH_IPV6 freeaddrinfo(ressave); @@ -3919,36 +4457,37 @@ again: return SOAP_INVALID_SOCKET; } } - else if (soap->connect_flags && setsockopt(sk, SOL_SOCKET, soap->connect_flags, (char*)&set, sizeof(int))) + if ((soap->connect_flags & ~SO_LINGER) && setsockopt(sk, SOL_SOCKET, soap->connect_flags & ~SO_LINGER, (char*)&set, sizeof(int))) { soap->errnum = soap_socket_errno(sk); - soap_set_sender_error(soap, tcp_error(soap), "setsockopt failed in tcp_connect()", SOAP_TCP_ERROR); + soap_set_receiver_error(soap, tcp_error(soap), "setsockopt failed in tcp_connect()", SOAP_TCP_ERROR); soap->fclosesocket(soap, sk); #ifdef WITH_IPV6 freeaddrinfo(ressave); #endif return SOAP_INVALID_SOCKET; } +#ifndef UNDER_CE if ((soap->keep_alive || soap->tcp_keep_alive) && setsockopt(sk, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int))) { soap->errnum = soap_socket_errno(sk); - soap_set_sender_error(soap, tcp_error(soap), "setsockopt SO_KEEPALIVE failed in tcp_connect()", SOAP_TCP_ERROR); + soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_KEEPALIVE failed in tcp_connect()", SOAP_TCP_ERROR); soap->fclosesocket(soap, sk); #ifdef WITH_IPV6 freeaddrinfo(ressave); #endif return SOAP_INVALID_SOCKET; } - if (setsockopt(sk, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int))) + if (soap->sndbuf > 0 && setsockopt(sk, SOL_SOCKET, SO_SNDBUF, (char*)&soap->sndbuf, sizeof(int))) { soap->errnum = soap_socket_errno(sk); - soap_set_sender_error(soap, tcp_error(soap), "setsockopt SO_SNDBUF failed in tcp_connect()", SOAP_TCP_ERROR); + soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_SNDBUF failed in tcp_connect()", SOAP_TCP_ERROR); soap->fclosesocket(soap, sk); #ifdef WITH_IPV6 freeaddrinfo(ressave); #endif return SOAP_INVALID_SOCKET; } - if (setsockopt(sk, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int))) + if (soap->rcvbuf > 0 && setsockopt(sk, SOL_SOCKET, SO_RCVBUF, (char*)&soap->rcvbuf, sizeof(int))) { soap->errnum = soap_socket_errno(sk); - soap_set_sender_error(soap, tcp_error(soap), "setsockopt SO_RCVBUF failed in tcp_connect()", SOAP_TCP_ERROR); + soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_RCVBUF failed in tcp_connect()", SOAP_TCP_ERROR); soap->fclosesocket(soap, sk); #ifdef WITH_IPV6 freeaddrinfo(ressave); @@ -3958,7 +4497,7 @@ again: #ifdef TCP_KEEPIDLE if (soap->tcp_keep_idle && setsockopt((SOAP_SOCKET)sk, IPPROTO_TCP, TCP_KEEPIDLE, (char*)&(soap->tcp_keep_idle), sizeof(int))) { soap->errnum = soap_socket_errno(sk); - soap_set_sender_error(soap, tcp_error(soap), "setsockopt TCP_KEEPIDLE failed in tcp_connect()", SOAP_TCP_ERROR); + soap_set_receiver_error(soap, tcp_error(soap), "setsockopt TCP_KEEPIDLE failed in tcp_connect()", SOAP_TCP_ERROR); soap->fclosesocket(soap, (SOAP_SOCKET)sk); #ifdef WITH_IPV6 freeaddrinfo(ressave); @@ -3969,7 +4508,7 @@ again: #ifdef TCP_KEEPINTVL if (soap->tcp_keep_intvl && setsockopt((SOAP_SOCKET)sk, IPPROTO_TCP, TCP_KEEPINTVL, (char*)&(soap->tcp_keep_intvl), sizeof(int))) { soap->errnum = soap_socket_errno(sk); - soap_set_sender_error(soap, tcp_error(soap), "setsockopt TCP_KEEPINTVL failed in tcp_connect()", SOAP_TCP_ERROR); + soap_set_receiver_error(soap, tcp_error(soap), "setsockopt TCP_KEEPINTVL failed in tcp_connect()", SOAP_TCP_ERROR); soap->fclosesocket(soap, (SOAP_SOCKET)sk); #ifdef WITH_IPV6 freeaddrinfo(ressave); @@ -3980,7 +4519,7 @@ again: #ifdef TCP_KEEPCNT if (soap->tcp_keep_cnt && setsockopt((SOAP_SOCKET)sk, IPPROTO_TCP, TCP_KEEPCNT, (char*)&(soap->tcp_keep_cnt), sizeof(int))) { soap->errnum = soap_socket_errno(sk); - soap_set_sender_error(soap, tcp_error(soap), "setsockopt TCP_KEEPCNT failed in tcp_connect()", SOAP_TCP_ERROR); + soap_set_receiver_error(soap, tcp_error(soap), "setsockopt TCP_KEEPCNT failed in tcp_connect()", SOAP_TCP_ERROR); soap->fclosesocket(soap, (SOAP_SOCKET)sk); #ifdef WITH_IPV6 freeaddrinfo(ressave); @@ -3991,7 +4530,7 @@ again: #ifdef TCP_NODELAY if (!(soap->omode & SOAP_IO_UDP) && setsockopt(sk, IPPROTO_TCP, TCP_NODELAY, (char*)&set, sizeof(int))) { soap->errnum = soap_socket_errno(sk); - soap_set_sender_error(soap, tcp_error(soap), "setsockopt TCP_NODELAY failed in tcp_connect()", SOAP_TCP_ERROR); + soap_set_receiver_error(soap, tcp_error(soap), "setsockopt TCP_NODELAY failed in tcp_connect()", SOAP_TCP_ERROR); soap->fclosesocket(soap, sk); #ifdef WITH_IPV6 freeaddrinfo(ressave); @@ -4011,8 +4550,11 @@ again: { unsigned char ttl = soap->ipv4_multicast_ttl; if (setsockopt(sk, IPPROTO_IP, IP_MULTICAST_TTL, (char*)&ttl, sizeof(ttl))) { soap->errnum = soap_socket_errno(sk); - soap_set_sender_error(soap, tcp_error(soap), "setsockopt IP_MULTICAST_TTL failed in tcp_connect()", SOAP_TCP_ERROR); + soap_set_receiver_error(soap, tcp_error(soap), "setsockopt IP_MULTICAST_TTL failed in tcp_connect()", SOAP_TCP_ERROR); soap->fclosesocket(soap, sk); +#ifdef WITH_IPV6 + freeaddrinfo(ressave); +#endif return SOAP_INVALID_SOCKET; } } @@ -4020,8 +4562,11 @@ again: { if (setsockopt(sk, IPPROTO_IP, IP_MULTICAST_IF, (char*)soap->ipv4_multicast_if, sizeof(struct in_addr))) #ifndef WINDOWS { soap->errnum = soap_socket_errno(sk); - soap_set_sender_error(soap, tcp_error(soap), "setsockopt IP_MULTICAST_IF failed in tcp_connect()", SOAP_TCP_ERROR); + soap_set_receiver_error(soap, tcp_error(soap), "setsockopt IP_MULTICAST_IF failed in tcp_connect()", SOAP_TCP_ERROR); soap->fclosesocket(soap, sk); +#ifdef WITH_IPV6 + freeaddrinfo(ressave); +#endif return SOAP_INVALID_SOCKET; } #else @@ -4030,8 +4575,11 @@ again: #endif if (setsockopt(sk, IPPROTO_IP, IP_MULTICAST_IF, (char*)soap->ipv4_multicast_if, sizeof(struct in_addr))) { soap->errnum = soap_socket_errno(sk); - soap_set_sender_error(soap, tcp_error(soap), "setsockopt IP_MULTICAST_IF failed in tcp_connect()", SOAP_TCP_ERROR); + soap_set_receiver_error(soap, tcp_error(soap), "setsockopt IP_MULTICAST_IF failed in tcp_connect()", SOAP_TCP_ERROR); soap->fclosesocket(soap, sk); +#ifdef WITH_IPV6 + freeaddrinfo(ressave); +#endif return SOAP_INVALID_SOCKET; } #endif @@ -4039,27 +4587,28 @@ again: } #endif #endif - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Opening socket=%d to host='%s' port=%d\n", sk, host, port)); +#endif + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Opening socket=%d to host='%s' port=%d\n", sk, host, port)); #ifndef WITH_IPV6 - soap->peerlen = sizeof(soap->peer); - memset((void*)&soap->peer, 0, sizeof(soap->peer)); - soap->peer.sin_family = AF_INET; + soap->peerlen = sizeof(soap->peer.in); + memset((void*)&soap->peer.in, 0, sizeof(soap->peer.in)); + soap->peer.in.sin_family = AF_INET; soap->errmode = 2; if (soap->proxy_host) - { if (soap->fresolve(soap, soap->proxy_host, &soap->peer.sin_addr)) - { soap_set_sender_error(soap, tcp_error(soap), "get proxy host by name failed in tcp_connect()", SOAP_TCP_ERROR); + { if (soap->fresolve(soap, soap->proxy_host, &soap->peer.in.sin_addr)) + { soap_set_receiver_error(soap, tcp_error(soap), "get proxy host by name failed in tcp_connect()", SOAP_TCP_ERROR); soap->fclosesocket(soap, sk); return SOAP_INVALID_SOCKET; } - soap->peer.sin_port = htons((short)soap->proxy_port); + soap->peer.in.sin_port = htons((short)soap->proxy_port); } else - { if (soap->fresolve(soap, host, &soap->peer.sin_addr)) - { soap_set_sender_error(soap, tcp_error(soap), "get host by name failed in tcp_connect()", SOAP_TCP_ERROR); + { if (soap->fresolve(soap, host, &soap->peer.in.sin_addr)) + { soap_set_receiver_error(soap, tcp_error(soap), "get host by name failed in tcp_connect()", SOAP_TCP_ERROR); soap->fclosesocket(soap, sk); return SOAP_INVALID_SOCKET; } - soap->peer.sin_port = htons((short)port); + soap->peer.in.sin_port = htons((short)port); } soap->errmode = 0; #ifndef WITH_LEAN @@ -4068,7 +4617,11 @@ again: #endif #else if ((soap->omode & SOAP_IO_UDP)) - { memcpy(&soap->peer, res->ai_addr, res->ai_addrlen); + { if (soap_memcpy((void*)&soap->peer.storage, sizeof(soap->peer.storage), (const void*)res->ai_addr, res->ai_addrlen)) + { soap->error = SOAP_EOM; + soap->fclosesocket(soap, sk); + sk = SOAP_INVALID_SOCKET; + } soap->peerlen = res->ai_addrlen; freeaddrinfo(ressave); return sk; @@ -4086,9 +4639,16 @@ again: #ifdef WITH_IPV6 if (connect(sk, res->ai_addr, (int)res->ai_addrlen)) #else - if (connect(sk, (struct sockaddr*)&soap->peer, sizeof(soap->peer))) + if (connect(sk, &soap->peer.addr, sizeof(soap->peer.in))) #endif { err = soap_socket_errno(sk); +#ifdef WITH_IPV6 + if (err == SOAP_ECONNREFUSED && res->ai_next) + { soap->fclosesocket(soap, sk); + res = res->ai_next; + goto again; + } +#endif #ifndef WITH_LEAN if (err == SOAP_EADDRINUSE) { soap->fclosesocket(soap, sk); @@ -4099,15 +4659,19 @@ again: { SOAP_SOCKLEN_T k; for (;;) - { register int r; + { int r; r = tcp_select(soap, sk, SOAP_TCP_SELECT_SND, soap->connect_timeout); if (r > 0) break; if (!r) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Connect timeout\n")); - soap_set_sender_error(soap, "Timeout", "connect failed in tcp_connect()", SOAP_TCP_ERROR); + soap_set_receiver_error(soap, "Timeout", "connect failed in tcp_connect()", SOAP_TCP_ERROR); soap->fclosesocket(soap, sk); #ifdef WITH_IPV6 + if (res->ai_next) + { res = res->ai_next; + goto again; + } freeaddrinfo(ressave); #endif return SOAP_INVALID_SOCKET; @@ -4115,23 +4679,31 @@ again: r = soap->errnum = soap_socket_errno(sk); if (r != SOAP_EINTR) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not connect to host\n")); - soap_set_sender_error(soap, tcp_error(soap), "connect failed in tcp_connect()", SOAP_TCP_ERROR); + soap_set_receiver_error(soap, tcp_error(soap), "connect failed in tcp_connect()", SOAP_TCP_ERROR); soap->fclosesocket(soap, sk); #ifdef WITH_IPV6 + if (res->ai_next) + { res = res->ai_next; + goto again; + } freeaddrinfo(ressave); #endif return SOAP_INVALID_SOCKET; } } k = (SOAP_SOCKLEN_T)sizeof(soap->errnum); - if (!getsockopt(sk, SOL_SOCKET, SO_ERROR, (char*)&soap->errnum, &k) && !soap->errnum) /* portability note: see SOAP_SOCKLEN_T definition in stdsoap2.h */ + if (!getsockopt(sk, SOL_SOCKET, SO_ERROR, (char*)&soap->errnum, &k) && !soap->errnum) /* portability note: see SOAP_SOCKLEN_T definition in stdsoap2.h */ break; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not connect to host\n")); if (!soap->errnum) soap->errnum = soap_socket_errno(sk); - soap_set_sender_error(soap, tcp_error(soap), "connect failed in tcp_connect()", SOAP_TCP_ERROR); + soap_set_receiver_error(soap, tcp_error(soap), "connect failed in tcp_connect()", SOAP_TCP_ERROR); soap->fclosesocket(soap, sk); #ifdef WITH_IPV6 + if (res->ai_next) + { res = res->ai_next; + goto again; + } freeaddrinfo(ressave); #endif return SOAP_INVALID_SOCKET; @@ -4147,7 +4719,7 @@ again: if (err && err != SOAP_EINTR) { soap->errnum = err; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not connect to host\n")); - soap_set_sender_error(soap, tcp_error(soap), "connect failed in tcp_connect()", SOAP_TCP_ERROR); + soap_set_receiver_error(soap, tcp_error(soap), "connect failed in tcp_connect()", SOAP_TCP_ERROR); soap->fclosesocket(soap, sk); #ifdef WITH_IPV6 freeaddrinfo(ressave); @@ -4165,12 +4737,15 @@ again: soap->socket = sk; soap->imode &= ~SOAP_ENC_SSL; soap->omode &= ~SOAP_ENC_SSL; - if (!soap_tag_cmp(endpoint, "https:*")) + if (endpoint && !soap_tag_cmp(endpoint, "https:*")) { -#if defined(WITH_OPENSSL) || defined(WITH_GNUTLS) +#if defined(WITH_OPENSSL) || defined(WITH_GNUTLS) || defined(WITH_SYSTEMSSL) #ifdef WITH_OPENSSL BIO *bio; #endif +#ifdef WITH_SYSTEMSSL + gsk_iocallback local_io = { ssl_recv, ssl_send, NULL, NULL, NULL, NULL }; +#endif int r; if (soap->proxy_host) { soap_mode m = soap->mode; /* preserve settings */ @@ -4194,7 +4769,8 @@ again: } soap->status = SOAP_CONNECT; soap->keep_alive = 1; - if ((soap->error = soap->fpost(soap, endpoint, host, port, NULL, NULL, 0)) + soap->error = soap->fpost(soap, endpoint, host, port, NULL, NULL, 0); + if (soap->error || soap_end_send_flush(soap)) { soap->fclosesocket(soap, sk); return SOAP_INVALID_SOCKET; @@ -4205,7 +4781,8 @@ again: soap->imode &= ~SOAP_ENC; /* mask IO and ENC */ userid = soap->userid; /* preserve */ passwd = soap->passwd; /* preserve */ - if ((soap->error = soap->fparse(soap))) + soap->error = soap->fparse(soap); + if (soap->error) { soap->fclosesocket(soap, sk); return SOAP_INVALID_SOCKET; } @@ -4219,14 +4796,12 @@ again: return SOAP_INVALID_SOCKET; } if (endpoint) - { strncpy(soap->endpoint, endpoint, sizeof(soap->endpoint)); /* restore */ - soap->endpoint[sizeof(soap->endpoint) - 1] = '\0'; - } + soap_strcpy(soap->endpoint, sizeof(soap->endpoint), endpoint); /* restore */ soap->mode = m; } #ifdef WITH_OPENSSL soap->ssl_flags |= SOAP_SSL_CLIENT; - if (!soap->ctx && (soap->error = soap->fsslauth(soap))) + if (!soap->ctx && (soap->error = soap->fsslauth(soap)) != SOAP_OK) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "SSL required, but no ctx set\n")); soap->fclosesocket(soap, sk); soap->error = SOAP_SSL_ERROR; @@ -4248,8 +4823,19 @@ again: SSL_SESSION_free(soap->session); soap->session = NULL; } - soap->imode |= SOAP_ENC_SSL; - soap->omode |= SOAP_ENC_SSL; +#if (OPENSSL_VERSION_NUMBER >= 0x1000000aL) + if (!(soap->ssl_flags & SOAP_SSLv3) && !SSL_set_tlsext_host_name(soap->ssl, host)) + { soap_set_receiver_error(soap, "SSL/TLS error", "SNI failed", SOAP_SSL_ERROR); + soap->fclosesocket(soap, sk); + return SOAP_INVALID_SOCKET; + } +#elif (OPENSSL_VERSION_NUMBER >= 0x0090800fL) && defined(SSL_CTRL_SET_TLSEXT_HOSTNAME) + if (!SSL_ctrl(soap->ssl, SSL_CTRL_SET_TLSEXT_HOSTNAME, TLSEXT_NAMETYPE_host_name, (void*)host)) + { soap_set_receiver_error(soap, "SSL/TLS error", "SNI failed", SOAP_SSL_ERROR); + soap->fclosesocket(soap, sk); + return SOAP_INVALID_SOCKET; + } +#endif bio = BIO_new_socket((int)sk, BIO_NOCLOSE); SSL_set_bio(soap->ssl, bio, bio); /* Connect timeout: set SSL sockets to non-blocking */ @@ -4267,26 +4853,26 @@ again: { if ((r = SSL_connect(soap->ssl)) <= 0) { int err = SSL_get_error(soap->ssl, r); if (err == SSL_ERROR_WANT_CONNECT || err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) - { register int s; + { int s; if (err == SSL_ERROR_WANT_READ) s = tcp_select(soap, sk, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, -100000); else s = tcp_select(soap, sk, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, -100000); if (s < 0) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "SSL_connect/select error in tcp_connect\n")); - soap_set_sender_error(soap, soap_ssl_error(soap, r), "SSL_connect failed in tcp_connect()", SOAP_TCP_ERROR); + soap_set_receiver_error(soap, soap_ssl_error(soap, r), "SSL_connect failed in tcp_connect()", SOAP_TCP_ERROR); soap->fclosesocket(soap, sk); return SOAP_INVALID_SOCKET; } if (s == 0 && retries-- <= 0) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "SSL/TLS connect timeout\n")); - soap_set_sender_error(soap, "Timeout", "SSL_connect failed in tcp_connect()", SOAP_TCP_ERROR); + soap_set_receiver_error(soap, "Timeout", "SSL_connect failed in tcp_connect()", SOAP_TCP_ERROR); soap->fclosesocket(soap, sk); return SOAP_INVALID_SOCKET; } } else - { soap_set_sender_error(soap, soap_ssl_error(soap, r), "SSL_connect error in tcp_connect()", SOAP_SSL_ERROR); + { soap_set_receiver_error(soap, soap_ssl_error(soap, r), "SSL_connect error in tcp_connect()", SOAP_SSL_ERROR); soap->fclosesocket(soap, sk); return SOAP_INVALID_SOCKET; } @@ -4337,18 +4923,17 @@ again: if (meth->it) ext_data = ASN1_item_d2i(NULL, &data, ext->value->length, ASN1_ITEM_ptr(meth->it)); else - { /* OpenSSL is not portable at this point (?): - Some compilers appear to prefer - meth->d2i(NULL, (const unsigned char**)&data, ... - and others prefer - meth->d2i(NULL, &data, ext->value->length); - */ + { +#if (OPENSSL_VERSION_NUMBER > 0x0090800fL) + ext_data = meth->d2i(NULL, (const unsigned char **)&data, ext->value->length); +#else ext_data = meth->d2i(NULL, &data, ext->value->length); +#endif } if (ext_data) val = meth->i2v(meth, ext_data, NULL); - else - val = NULL; + else + val = NULL; if (meth->it) ASN1_item_free((ASN1_VALUE*)ext_data, ASN1_ITEM_ptr(meth->it)); else @@ -4359,11 +4944,11 @@ again: val = meth->i2v(meth, ext_data, NULL); meth->ext_free(ext_data); #endif - if (val) + if (val) { int j; for (j = 0; j < sk_CONF_VALUE_num(val); j++) { CONF_VALUE *nval = sk_CONF_VALUE_value(val, j); - if (nval && !strcmp(nval->name, "DNS") && !strcmp(nval->value, host)) + if (nval && (!strcmp(nval->name, "DNS") || !strcmp(nval->name,"IP Address")) && !soap_tag_cmp(nval->value, host)) { ok = 1; break; } @@ -4386,7 +4971,7 @@ again: { int j; for (j = 0; j < sk_CONF_VALUE_num(val); j++) { CONF_VALUE *nval = sk_CONF_VALUE_value(val, j); - if (nval && !strcmp(nval->name, "DNS") && !strcmp(nval->value, host)) + if (nval && (!strcmp(nval->name, "DNS") || !strcmp(nval->name,"IP Address")) && !soap_tag_cmp(nval->value, host)) { ok = 1; break; } @@ -4394,7 +4979,7 @@ again: sk_CONF_VALUE_pop_free(val, X509V3_conf_free); } #endif - if (!ok && (subj = X509_get_subject_name(peer))) + if (!ok && (subj = X509_get_subject_name(peer)) != 0) { int i = -1; do { ASN1_STRING *name; @@ -4433,7 +5018,7 @@ again: #endif #ifdef WITH_GNUTLS soap->ssl_flags |= SOAP_SSL_CLIENT; - if (!soap->session && (soap->error = soap->fsslauth(soap))) + if (!soap->session && (soap->error = soap->fsslauth(soap)) != SOAP_OK) { soap->fclosesocket(soap, sk); return SOAP_INVALID_SOCKET; } @@ -4474,11 +5059,75 @@ again: { const char *err = ssl_verify(soap, host); if (err) { soap->fclosesocket(soap, sk); - soap->error = soap_set_sender_error(soap, "SSL/TLS error", err, SOAP_SSL_ERROR); + soap->error = soap_set_sender_error(soap, "SSL/TLS verify error", err, SOAP_SSL_ERROR); return SOAP_INVALID_SOCKET; } } #endif +#ifdef WITH_SYSTEMSSL + soap->ssl_flags |= SOAP_SSL_CLIENT; + if (!soap->ctx && (soap->error = soap->fsslauth(soap)) != SOAP_OK) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "SSL required, but no ctx set\n")); + soap->fclosesocket(soap, sk); + soap->error = SOAP_SSL_ERROR; + return SOAP_INVALID_SOCKET; + } + /* Connect timeout: set SSL sockets to non-blocking */ + retries = 0; + if (soap->connect_timeout) + { SOAP_SOCKNONBLOCK(sk) + retries = 10*soap->connect_timeout; + } + else + SOAP_SOCKBLOCK(sk) + if (retries <= 0) + retries = 100; /* timeout: 10 sec retries, 100 times 0.1 sec */ + err = gsk_secure_socket_open(soap->ctx, &soap->ssl); + if (err == GSK_OK) + err = gsk_attribute_set_numeric_value(soap->ssl, GSK_FD, sk); + if (err == GSK_OK) + err = gsk_attribute_set_buffer(soap->ssl, GSK_KEYRING_LABEL, soap->cafile, 0); /* Certificate label */ + if (err == GSK_OK) + err = gsk_attribute_set_enum(soap->ssl, GSK_SESSION_TYPE, GSK_CLIENT_SESSION); + if (err == GSK_OK) + err = gsk_attribute_set_buffer(soap->ssl, GSK_V3_CIPHER_SPECS_EXPANDED, "0035002F000A", 0); + if (err == GSK_OK) + err = gsk_attribute_set_enum(soap->ssl, GSK_V3_CIPHERS, GSK_V3_CIPHERS_CHAR4); + if (err == GSK_OK) + err = gsk_attribute_set_callback(soap->ssl, GSK_IO_CALLBACK, &local_io); + if (err != GSK_OK) + { soap_set_receiver_error(soap, gsk_strerror(err), "SYSTEM SSL error in tcp_connect()", SOAP_SSL_ERROR); + return SOAP_INVALID_SOCKET; + } + /* Try connecting until success or timeout (when nonblocking) */ + while ((err = gsk_secure_socket_init(soap->ssl)) != GSK_OK) + { if (err == GSK_WOULD_BLOCK_READ || err == GSK_WOULD_BLOCK_WRITE) + { if (err == GSK_WOULD_BLOCK_READ) + r = tcp_select(soap, sk, SOAP_TCP_SELECT_RCV | SOAP_TCP_SELECT_ERR, -100000); + else + r = tcp_select(soap, sk, SOAP_TCP_SELECT_SND | SOAP_TCP_SELECT_ERR, -100000); + if (r < 0) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "SSL_connect/select error in tcp_connect\n")); + soap_set_receiver_error(soap, gsk_strerror(err), "gsk_secure_socket_init failed in tcp_connect()", SOAP_TCP_ERROR); + soap->fclosesocket(soap, sk); + return SOAP_INVALID_SOCKET; + } + if (r == 0 && retries-- <= 0) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "SSL/TLS connect timeout\n")); + soap_set_receiver_error(soap, "Timeout", "in tcp_connect()", SOAP_TCP_ERROR); + soap->fclosesocket(soap, sk); + return SOAP_INVALID_SOCKET; + } + } + else + { soap_set_receiver_error(soap, gsk_strerror(err), "gsk_secure_socket_init() failed in tcp_connect()", SOAP_SSL_ERROR); + soap->fclosesocket(soap, sk); + return SOAP_INVALID_SOCKET; + } + } +#endif + soap->imode |= SOAP_ENC_SSL; + soap->omode |= SOAP_ENC_SSL; #else soap->fclosesocket(soap, sk); soap->error = SOAP_SSL_ERROR; @@ -4495,6 +5144,7 @@ again: #endif /******************************************************************************/ + #ifndef WITH_NOIO #ifndef PALM_1 static int @@ -4531,9 +5181,11 @@ tcp_select(struct soap *soap, SOAP_SOCKET sk, int flags, int timeout) } do { r = poll(&pollfd, 1, timeout); - if (r < 0 && (soap->errnum = soap_socket_errno(sk)) == SOAP_EINTR && eintr--) - continue; - } while (r == 0 && retries--); + if (r < 0 && (soap->errnum = soap_socket_errno(sk)) == SOAP_EINTR && eintr-- > 0) + r = 0; + else if (retries-- <= 0) + break; + } while (r == 0); if (r > 0) { r = 0; if ((flags & SOAP_TCP_SELECT_RCV) && (pollfd.revents & POLLIN)) @@ -4543,6 +5195,8 @@ tcp_select(struct soap *soap, SOAP_SOCKET sk, int flags, int timeout) if ((flags & SOAP_TCP_SELECT_ERR) && (pollfd.revents & POLLERR)) r |= SOAP_TCP_SELECT_ERR; } + else if (r == 0) + soap->errnum = 0; return r; } #else @@ -4579,9 +5233,11 @@ tcp_select(struct soap *soap, SOAP_SOCKET sk, int flags, int timeout) tv.tv_usec = 0; } r = select((int)sk + 1, rfd, sfd, efd, &tv); - if (r < 0 && (soap->errnum = soap_socket_errno(sk)) == SOAP_EINTR && eintr--) - continue; - } while (r == 0 && retries--); + if (r < 0 && (soap->errnum = soap_socket_errno(sk)) == SOAP_EINTR && eintr-- > 0) + r = 0; + else if (retries-- <= 0) + break; + } while (r == 0); if (r > 0) { r = 0; if ((flags & SOAP_TCP_SELECT_RCV) && FD_ISSET(sk, rfd)) @@ -4591,12 +5247,15 @@ tcp_select(struct soap *soap, SOAP_SOCKET sk, int flags, int timeout) if ((flags & SOAP_TCP_SELECT_ERR) && FD_ISSET(sk, efd)) r |= SOAP_TCP_SELECT_ERR; } + else if (r == 0) + soap->errnum = 0; return r; } #endif #endif /******************************************************************************/ + #ifndef WITH_NOIO #ifndef PALM_1 static SOAP_SOCKET @@ -4604,7 +5263,7 @@ tcp_accept(struct soap *soap, SOAP_SOCKET s, struct sockaddr *a, int *n) { SOAP_SOCKET sk; (void)soap; sk = accept(s, a, (SOAP_SOCKLEN_T*)n); /* portability note: see SOAP_SOCKLEN_T definition in stdsoap2.h */ -#ifdef SOCKET_CLOSE_ON_EXEC +#ifdef SOCKET_CLOSE_ON_EXIT #ifdef WIN32 #ifndef UNDER_CE SetHandleInformation((HANDLE)sk, HANDLE_FLAG_INHERIT, 0); @@ -4619,6 +5278,7 @@ tcp_accept(struct soap *soap, SOAP_SOCKET s, struct sockaddr *a, int *n) #endif /******************************************************************************/ + #ifndef WITH_NOIO #ifndef PALM_1 static int @@ -4634,7 +5294,7 @@ tcp_disconnect(struct soap *soap) if (*soap->host) { soap->session = SSL_get1_session(soap->ssl); if (soap->session) - { strcpy(soap->session_host, soap->host); + { soap_strcpy(soap->session_host, sizeof(soap->session_host), soap->host); soap->session_port = soap->port; } } @@ -4700,6 +5360,12 @@ tcp_disconnect(struct soap *soap) soap->session = NULL; } #endif +#ifdef WITH_SYSTEMSSL + if (soap->ssl) + { gsk_secure_socket_shutdown(soap->ssl); + gsk_secure_socket_close(&soap->ssl); + } +#endif if (soap_valid_socket(soap->socket) && !(soap->omode & SOAP_IO_UDP)) { soap->fshutdownsocket(soap, soap->socket, SOAP_SHUT_RDWR); soap->fclosesocket(soap, soap->socket); @@ -4711,6 +5377,7 @@ tcp_disconnect(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_NOIO #ifndef PALM_1 static int @@ -4723,6 +5390,7 @@ tcp_closesocket(struct soap *soap, SOAP_SOCKET sk) #endif /******************************************************************************/ + #ifndef WITH_NOIO #ifndef PALM_1 static int @@ -4735,6 +5403,7 @@ tcp_shutdownsocket(struct soap *soap, SOAP_SOCKET sk, int how) #endif /******************************************************************************/ + #ifndef WITH_NOIO #ifndef PALM_1 SOAP_FMAC1 @@ -4752,11 +5421,6 @@ soap_bind(struct soap *soap, const char *host, int port, int backlog) #endif #endif #ifndef WITH_LEAN -#ifndef WIN32 - int len = SOAP_BUFLEN; -#else - int len = SOAP_BUFLEN + 1; /* speeds up windows xfer */ -#endif int set = 1; #endif if (soap_valid_socket(soap->master)) @@ -4771,7 +5435,11 @@ soap_bind(struct soap *soap, const char *host, int port, int backlog) } #ifdef WITH_IPV6 memset((void*)&hints, 0, sizeof(hints)); +#ifdef WITH_IPV6_V6ONLY + hints.ai_family = PF_INET6; +#else hints.ai_family = PF_UNSPEC; +#endif #ifndef WITH_LEAN if ((soap->omode & SOAP_IO_UDP)) hints.ai_socktype = SOCK_DGRAM; @@ -4783,12 +5451,18 @@ soap_bind(struct soap *soap, const char *host, int port, int backlog) err = getaddrinfo(host, soap_int2s(soap, port), &hints, &addrinfo); if (err || !addrinfo) { soap_set_receiver_error(soap, SOAP_GAI_STRERROR(err), "getaddrinfo failed in soap_bind()", SOAP_TCP_ERROR); + if (addrinfo) + freeaddrinfo(addrinfo); return SOAP_INVALID_SOCKET; } res = *addrinfo; - memcpy(&soap->peer, addrinfo->ai_addr, addrinfo->ai_addrlen); + if (soap_memcpy((void*)&soap->peer.storage, sizeof(soap->peer.storage), (const void*)addrinfo->ai_addr, addrinfo->ai_addrlen)) + { freeaddrinfo(addrinfo); + soap->error = SOAP_EOM; + return SOAP_INVALID_SOCKET; + } soap->peerlen = addrinfo->ai_addrlen; - res.ai_addr = (struct sockaddr*)&soap->peer; + res.ai_addr = &soap->peer.addr; res.ai_addrlen = soap->peerlen; freeaddrinfo(addrinfo); soap->master = (int)socket(res.ai_family, res.ai_socktype, res.ai_protocol); @@ -4811,7 +5485,7 @@ soap_bind(struct soap *soap, const char *host, int port, int backlog) if ((soap->omode & SOAP_IO_UDP)) soap->socket = soap->master; #endif -#ifdef SOCKET_CLOSE_ON_EXEC +#ifdef SOCKET_CLOSE_ON_EXIT #ifdef WIN32 #ifndef UNDER_CE SetHandleInformation((HANDLE)soap->master, HANDLE_FLAG_INHERIT, 0); @@ -4826,17 +5500,18 @@ soap_bind(struct soap *soap, const char *host, int port, int backlog) soap_set_receiver_error(soap, tcp_error(soap), "setsockopt failed in soap_bind()", SOAP_TCP_ERROR); return SOAP_INVALID_SOCKET; } +#ifndef UNDER_CE if (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) && (!((soap->imode | soap->omode) & SOAP_IO_UDP)) && setsockopt(soap->master, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int))) { soap->errnum = soap_socket_errno(soap->master); soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_KEEPALIVE failed in soap_bind()", SOAP_TCP_ERROR); return SOAP_INVALID_SOCKET; } - if (setsockopt(soap->master, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int))) + if (soap->sndbuf > 0 && setsockopt(soap->master, SOL_SOCKET, SO_SNDBUF, (char*)&soap->sndbuf, sizeof(int))) { soap->errnum = soap_socket_errno(soap->master); soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_SNDBUF failed in soap_bind()", SOAP_TCP_ERROR); return SOAP_INVALID_SOCKET; } - if (setsockopt(soap->master, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int))) + if (soap->rcvbuf > 0 && setsockopt(soap->master, SOL_SOCKET, SO_RCVBUF, (char*)&soap->rcvbuf, sizeof(int))) { soap->errnum = soap_socket_errno(soap->master); soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_RCVBUF failed in soap_bind()", SOAP_TCP_ERROR); return SOAP_INVALID_SOCKET; @@ -4848,17 +5523,24 @@ soap_bind(struct soap *soap, const char *host, int port, int backlog) return SOAP_INVALID_SOCKET; } #endif +#ifdef TCP_FASTOPEN + if (!(soap->omode & SOAP_IO_UDP) && setsockopt(soap->master, IPPROTO_TCP, TCP_FASTOPEN, (char*)&set, sizeof(int))) + { /* silently ignore */ + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "setsockopt TCP_FASTOPEN failed in soap_bind()\n")); + } +#endif +#endif #endif #ifdef WITH_IPV6 #ifdef WITH_IPV6_V6ONLY - if (setsockopt(soap->master, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&set, sizeof(int))) + if (res.ai_family == AF_INET6 && setsockopt(soap->master, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&set, sizeof(int))) { soap->errnum = soap_socket_errno(soap->master); soap_set_receiver_error(soap, tcp_error(soap), "setsockopt set IPV6_V6ONLY failed in soap_bind()", SOAP_TCP_ERROR); return SOAP_INVALID_SOCKET; } #endif #ifdef WITH_NO_IPV6_V6ONLY - if (setsockopt(soap->master, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&unset, sizeof(int))) + if (res.ai_family == AF_INET6 && setsockopt(soap->master, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&unset, sizeof(int))) { soap->errnum = soap_socket_errno(soap->master); soap_set_receiver_error(soap, tcp_error(soap), "setsockopt unset IPV6_V6ONLY failed in soap_bind()", SOAP_TCP_ERROR); return SOAP_INVALID_SOCKET; @@ -4873,21 +5555,21 @@ soap_bind(struct soap *soap, const char *host, int port, int backlog) return SOAP_INVALID_SOCKET; } #else - soap->peerlen = sizeof(soap->peer); - memset((void*)&soap->peer, 0, sizeof(soap->peer)); - soap->peer.sin_family = AF_INET; + soap->peerlen = sizeof(soap->peer.in); + memset((void*)&soap->peer.in, 0, sizeof(soap->peer.in)); + soap->peer.in.sin_family = AF_INET; soap->errmode = 2; if (host) - { if (soap->fresolve(soap, host, &soap->peer.sin_addr)) + { if (soap->fresolve(soap, host, &soap->peer.in.sin_addr)) { soap_set_receiver_error(soap, tcp_error(soap), "get host by name failed in soap_bind()", SOAP_TCP_ERROR); return SOAP_INVALID_SOCKET; } } else - soap->peer.sin_addr.s_addr = htonl(INADDR_ANY); - soap->peer.sin_port = htons((short)port); + soap->peer.in.sin_addr.s_addr = htonl(INADDR_ANY); + soap->peer.in.sin_port = htons((short)port); soap->errmode = 0; - if (bind(soap->master, (struct sockaddr*)&soap->peer, (int)soap->peerlen)) + if (bind(soap->master, &soap->peer.addr, (int)soap->peerlen)) { soap->errnum = soap_socket_errno(soap->master); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not bind to host\n")); soap_closesock(soap); @@ -4908,6 +5590,7 @@ soap_bind(struct soap *soap, const char *host, int port, int backlog) #endif /******************************************************************************/ + #ifndef WITH_NOIO #ifndef PALM_1 SOAP_FMAC1 @@ -4916,7 +5599,7 @@ SOAP_FMAC2 soap_poll(struct soap *soap) { #ifndef WITH_LEAN - register int r; + int r; if (soap_valid_socket(soap->socket)) { r = tcp_select(soap, soap->socket, SOAP_TCP_SELECT_ALL, 0); if (r > 0 && (r & SOAP_TCP_SELECT_ERR)) @@ -4953,9 +5636,10 @@ soap_poll(struct soap *soap) return soap->error = SOAP_TCP_ERROR; } } - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Polling: other end down on socket=%d select=%d\n", soap->socket, r)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Polling: other end down on socket=%d select=%d\n", soap->socket, r)); return SOAP_EOF; #else + (void)soap; return SOAP_OK; #endif } @@ -4963,6 +5647,7 @@ soap_poll(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_NOIO #ifndef PALM_1 SOAP_FMAC1 @@ -4970,13 +5655,8 @@ SOAP_SOCKET SOAP_FMAC2 soap_accept(struct soap *soap) { int n = (int)sizeof(soap->peer); - register int err; + int err; #ifndef WITH_LEAN -#ifndef WIN32 - int len = SOAP_BUFLEN; -#else - int len = SOAP_BUFLEN + 1; /* speeds up windows xfer */ -#endif int set = 1; #endif soap->error = SOAP_OK; @@ -4996,7 +5676,7 @@ soap_accept(struct soap *soap) for (;;) { if (soap->accept_timeout || soap->send_timeout || soap->recv_timeout) { for (;;) - { register int r; + { int r; r = tcp_select(soap, soap->master, SOAP_TCP_SELECT_ALL, soap->accept_timeout ? soap->accept_timeout : 60); if (r > 0) break; @@ -5008,7 +5688,7 @@ soap_accept(struct soap *soap) { r = soap->errnum; if (r != SOAP_EINTR) { soap_closesock(soap); - soap_set_sender_error(soap, tcp_error(soap), "accept failed in soap_accept()", SOAP_TCP_ERROR); + soap_set_receiver_error(soap, tcp_error(soap), "accept failed in soap_accept()", SOAP_TCP_ERROR); return SOAP_INVALID_SOCKET; } } @@ -5018,29 +5698,31 @@ soap_accept(struct soap *soap) SOAP_SOCKNONBLOCK(soap->master) else SOAP_SOCKBLOCK(soap->master) - soap->socket = soap->faccept(soap, soap->master, (struct sockaddr*)&soap->peer, &n); + n = (int)sizeof(soap->peer); + soap->socket = soap->faccept(soap, soap->master, &soap->peer.addr, &n); soap->peerlen = (size_t)n; if (soap_valid_socket(soap->socket)) { #ifdef WITH_IPV6 - unsigned int ip1, ip2, ip3, ip4; + char *s = soap->host; char port[16]; - getnameinfo((struct sockaddr*)&soap->peer, n, soap->host, sizeof(soap->host), port, 16, NI_NUMERICHOST | NI_NUMERICSERV); - sscanf(soap->host, "%u.%u.%u.%u", &ip1, &ip2, &ip3, &ip4); - soap->ip = (unsigned long)ip1 << 24 | (unsigned long)ip2 << 16 | (unsigned long)ip3 << 8 | (unsigned long)ip4; + int i; + getnameinfo(&soap->peer.addr, n, soap->host, sizeof(soap->host), port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV); + soap->ip = 0; + for (i = 0; i < 4 && *s; i++) + { soap->ip = (soap->ip << 8) + (unsigned int)soap_strtoul(s, &s, 10); + if (*s) + s++; + } soap->port = soap_strtol(port, NULL, 10); #else - soap->ip = ntohl(soap->peer.sin_addr.s_addr); -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->host, sizeof(soap->host), "%u.%u.%u.%u", (int)(soap->ip>>24)&0xFF, (int)(soap->ip>>16)&0xFF, (int)(soap->ip>>8)&0xFF, (int)soap->ip&0xFF); -#else - sprintf(soap->host, "%u.%u.%u.%u", (int)(soap->ip>>24)&0xFF, (int)(soap->ip>>16)&0xFF, (int)(soap->ip>>8)&0xFF, (int)soap->ip&0xFF); + soap->ip = ntohl(soap->peer.in.sin_addr.s_addr); + (SOAP_SNPRINTF(soap->host, sizeof(soap->host), 80), "%u.%u.%u.%u", (int)(soap->ip>>24)&0xFF, (int)(soap->ip>>16)&0xFF, (int)(soap->ip>>8)&0xFF, (int)soap->ip&0xFF); + soap->port = (int)ntohs(soap->peer.in.sin_port); /* does not return port number on some systems */ #endif - soap->port = (int)ntohs(soap->peer.sin_port); /* does not return port number on some systems */ -#endif - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Accept socket=%d at port=%d from IP='%s'\n", soap->socket, soap->port, soap->host)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Accept socket=%d at port=%d from IP='%s'\n", soap->socket, soap->port, soap->host)); #ifndef WITH_LEAN - if (soap->accept_flags == SO_LINGER) + if ((soap->accept_flags & SO_LINGER)) { struct linger linger; memset((void*)&linger, 0, sizeof(linger)); linger.l_onoff = 1; @@ -5052,25 +5734,26 @@ soap_accept(struct soap *soap) return SOAP_INVALID_SOCKET; } } - else if (soap->accept_flags && setsockopt(soap->socket, SOL_SOCKET, soap->accept_flags, (char*)&set, sizeof(int))) + if ((soap->accept_flags & ~SO_LINGER) && setsockopt(soap->socket, SOL_SOCKET, soap->accept_flags & ~SO_LINGER, (char*)&set, sizeof(int))) { soap->errnum = soap_socket_errno(soap->socket); soap_set_receiver_error(soap, tcp_error(soap), "setsockopt failed in soap_accept()", SOAP_TCP_ERROR); soap_closesock(soap); return SOAP_INVALID_SOCKET; } +#ifndef UNDER_CE if (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) && setsockopt(soap->socket, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int))) { soap->errnum = soap_socket_errno(soap->socket); soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_KEEPALIVE failed in soap_accept()", SOAP_TCP_ERROR); soap_closesock(soap); return SOAP_INVALID_SOCKET; } - if (setsockopt(soap->socket, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int))) + if (soap->sndbuf > 0 && setsockopt(soap->socket, SOL_SOCKET, SO_SNDBUF, (char*)&soap->sndbuf, sizeof(int))) { soap->errnum = soap_socket_errno(soap->socket); soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_SNDBUF failed in soap_accept()", SOAP_TCP_ERROR); soap_closesock(soap); return SOAP_INVALID_SOCKET; } - if (setsockopt(soap->socket, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int))) + if (soap->rcvbuf > 0 && setsockopt(soap->socket, SOL_SOCKET, SO_RCVBUF, (char*)&soap->rcvbuf, sizeof(int))) { soap->errnum = soap_socket_errno(soap->socket); soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_RCVBUF failed in soap_accept()", SOAP_TCP_ERROR); soap_closesock(soap); @@ -5085,6 +5768,7 @@ soap_accept(struct soap *soap) } #endif #endif +#endif soap->keep_alive = (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) != 0); if (soap->send_timeout || soap->recv_timeout) SOAP_SOCKNONBLOCK(soap->socket) @@ -5094,7 +5778,7 @@ soap_accept(struct soap *soap) } err = soap_socket_errno(soap->socket); if (err != 0 && err != SOAP_EINTR && err != SOAP_EAGAIN && err != SOAP_EWOULDBLOCK) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Accept failed from %s\n", soap->host)); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Accept failed from %s\n", soap->host)); soap->errnum = err; soap_set_receiver_error(soap, tcp_error(soap), "accept failed in soap_accept()", SOAP_TCP_ERROR); soap_closesock(soap); @@ -5106,12 +5790,13 @@ soap_accept(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 soap_closesock(struct soap *soap) -{ register int status = soap->error; +{ int status = soap->error; #ifndef WITH_LEANER if (status) /* close on error: attachment state is not to be trusted */ { soap->mime.first = NULL; @@ -5120,10 +5805,10 @@ soap_closesock(struct soap *soap) soap->dime.last = NULL; } #endif - if (soap->fdisconnect && (soap->error = soap->fdisconnect(soap))) + if (soap->fdisconnect && (soap->error = soap->fdisconnect(soap)) != SOAP_OK) return soap->error; if (status == SOAP_EOF || status == SOAP_TCP_ERROR || status == SOAP_SSL_ERROR || !soap->keep_alive) - { if (soap->fclose && (soap->error = soap->fclose(soap))) + { if (soap->fclose && (soap->error = soap->fclose(soap)) != SOAP_OK) return soap->error; soap->keep_alive = 0; } @@ -5141,6 +5826,7 @@ soap_closesock(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_NOIO #ifndef PALM_1 SOAP_FMAC1 @@ -5156,6 +5842,7 @@ soap_force_closesock(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_NOIO #ifndef PALM_2 SOAP_FMAC1 @@ -5174,6 +5861,7 @@ soap_cleanup(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 void @@ -5202,7 +5890,7 @@ soap_done(struct soap *soap) soap_free_cookies(soap); #endif while (soap->plugins) - { register struct soap_plugin *p = soap->plugins->next; + { struct soap_plugin *p = soap->plugins->next; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Removing plugin '%s'\n", soap->plugins->id)); if (soap->plugins->fcopy || soap->state == SOAP_INIT) soap->plugins->fdelete(soap, soap->plugins); @@ -5245,6 +5933,8 @@ soap_done(struct soap *soap) soap->fpoll = NULL; #endif #ifndef WITH_LEANER + soap->fsvalidate = NULL; + soap->fwvalidate = NULL; soap->feltbegin = NULL; soap->feltendin = NULL; soap->feltbegout = NULL; @@ -5314,20 +6004,31 @@ soap_done(struct soap *soap) soap->session = NULL; } #endif +#ifdef WITH_SYSTEMSSL + if (soap->ssl) + gsk_secure_socket_close(&soap->ssl); + if (soap->state == SOAP_INIT) + if (soap->ctx) + gsk_environment_close(&soap->ctx); +#endif #ifdef WITH_C_LOCALE + if (soap->c_locale) + { # ifdef WIN32 - _free_locale(soap->c_locale); + _free_locale(soap->c_locale); # else - freelocale(soap->c_locale); + freelocale(soap->c_locale); # endif + soap->c_locale = NULL; + } #endif #ifdef WITH_ZLIB if (soap->d_stream) - { SOAP_FREE(soap, (void*)soap->d_stream); + { SOAP_FREE(soap, soap->d_stream); soap->d_stream = NULL; } if (soap->z_buf) - { SOAP_FREE(soap, (void*)soap->z_buf); + { SOAP_FREE(soap, soap->z_buf); soap->z_buf = NULL; } #endif @@ -5335,7 +6036,7 @@ soap_done(struct soap *soap) DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free logfiles\n")); for (i = 0; i < SOAP_MAXLOGS; i++) { if (soap->logfile[i]) - { SOAP_FREE(soap, (void*)soap->logfile[i]); + { SOAP_FREE(soap, soap->logfile[i]); soap->logfile[i] = NULL; } soap_close_logfile(soap, i); @@ -5350,11 +6051,10 @@ soap_done(struct soap *soap) /******************************************************************************\ * - * HTTP + * HTTP * \******************************************************************************/ -/******************************************************************************/ #ifndef WITH_NOHTTP #ifndef PALM_1 static int @@ -5386,26 +6086,27 @@ http_parse(struct soap *soap) return SOAP_EOF; return soap->error = 414; } - if ((s = strchr(soap->msgbuf, ' '))) + s = strchr(soap->msgbuf, ' '); + if (s) { soap->status = (unsigned short)soap_strtoul(s, &s, 10); if (!soap_blank((soap_wchar)*s)) soap->status = 0; } else soap->status = 0; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "HTTP status: %s\n", soap->msgbuf)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "HTTP status: %s\n", soap->msgbuf)); for (;;) { if (soap_getline(soap, header, SOAP_HDRLEN)) { if (soap->error == SOAP_EOF) { soap->error = SOAP_OK; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "EOF in HTTP header, continue anyway\n")); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "EOF in HTTP header, continue anyway\n")); break; } return soap->error; } if (!*header) break; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "HTTP header: %s\n", header)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "HTTP header: %s\n", header)); s = strchr(header, ':'); if (s) { char *t; @@ -5420,7 +6121,8 @@ http_parse(struct soap *soap) if (t >= s && *t == '"') t--; t[1] = '\0'; - if ((soap->error = soap->fparsehdr(soap, header, s))) + soap->error = soap->fparsehdr(soap, header, s); + if (soap->error) { if (soap->error < SOAP_STOP) return soap->error; status = soap->error; @@ -5429,7 +6131,7 @@ http_parse(struct soap *soap) } } } while (soap->status == 100); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Finished HTTP header parsing, status = %d\n", soap->status)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Finished HTTP header parsing, status = %d\n", soap->status)); s = strstr(soap->msgbuf, "HTTP/"); if (s && s[7] != '1') { if (soap->keep_alive == 1) @@ -5439,7 +6141,7 @@ http_parse(struct soap *soap) } if (soap->keep_alive < 0) soap->keep_alive = 1; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Keep alive connection = %d\n", soap->keep_alive)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Keep alive connection = %d\n", soap->keep_alive)); if (soap->status == 0) { size_t l = 0; if (s) @@ -5457,24 +6159,28 @@ http_parse(struct soap *soap) httpcmd = 6; } if (s && httpcmd) - { size_t m = strlen(soap->endpoint); - size_t n = m + (s - soap->msgbuf) - l - 1; - size_t k; + { size_t m, n, k; + while (soap_blank(soap->msgbuf[l])) + l++; + m = strlen(soap->endpoint); + n = m + (s - soap->msgbuf) - l - 1; if (n >= sizeof(soap->endpoint)) n = sizeof(soap->endpoint) - 1; if (m > n) m = n; k = n - m + 1; - if (k > sizeof(soap->path)) - k = sizeof(soap->path); - strncpy(soap->path, soap->msgbuf + l, k); - soap->path[k - 1] = '\0'; + if (k >= sizeof(soap->path)) + k = sizeof(soap->path) - 1; + while (k > 0 && soap_blank(soap->msgbuf[l + k - 1])) + k--; + soap_strncpy(soap->path, sizeof(soap->path), soap->msgbuf + l, k); if (*soap->path && *soap->path != '/') - *soap->endpoint = '\0'; - strcat(soap->endpoint, soap->path); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Target endpoint='%s'\n", soap->endpoint)); + soap_strncpy(soap->endpoint, sizeof(soap->endpoint), soap->path, k); + else + soap_strncat(soap->endpoint, sizeof(soap->endpoint), soap->path, k); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Target endpoint='%s' path='%s'\n", soap->endpoint, soap->path)); if (httpcmd > 1) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "HTTP %s handler\n", soap->msgbuf)); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "HTTP %s handler\n", soap->msgbuf)); switch (httpcmd) { case 2: soap->error = soap->fput(soap); break; case 3: soap->error = soap->fget(soap); break; @@ -5483,7 +6189,7 @@ http_parse(struct soap *soap) case 6: soap->error = soap->fhead(soap); break; default: soap->error = 405; break; } - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "HTTP handler return = %d\n", soap->error)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "HTTP handler return = %d\n", soap->error)); if (soap->error == SOAP_OK) soap->error = SOAP_STOP; /* prevents further processing */ return soap->error; @@ -5504,7 +6210,7 @@ http_parse(struct soap *soap) { if ((soap->status >= 200 && soap->status <= 299) /* OK, Accepted, etc */ || soap->status == 400 /* Bad Request */ || soap->status == 500) /* Internal Server Error */ - return SOAP_OK; + return soap->error = SOAP_OK; /* force close afterwards in soap_closesock() */ soap->keep_alive = 0; #ifndef WITH_LEAN @@ -5516,13 +6222,14 @@ http_parse(struct soap *soap) } else if (soap->status >= 200 && soap->status <= 299) return soap->error = soap->status; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "HTTP error %d\n", soap->status)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "HTTP error %d: %s\n", soap->status, soap->msgbuf)); return soap_set_receiver_error(soap, "HTTP Error", soap->msgbuf, soap->status); } #endif #endif /******************************************************************************/ + #ifndef WITH_NOHTTP #ifndef PALM_1 static int @@ -5531,11 +6238,11 @@ http_parse_header(struct soap *soap, const char *key, const char *val) { #if defined(WITH_OPENSSL) || defined(WITH_GNUTLS) if (soap->imode & SOAP_ENC_SSL) - strcpy(soap->endpoint, "https://"); + soap_strcpy(soap->endpoint, sizeof(soap->endpoint), "https://"); else #endif - strcpy(soap->endpoint, "http://"); - strncat(soap->endpoint, val, sizeof(soap->endpoint) - 8); + soap_strcpy(soap->endpoint, sizeof(soap->endpoint), "http://"); + soap_strncat(soap->endpoint, sizeof(soap->endpoint), val, sizeof(soap->endpoint) - 9); } #ifndef WITH_LEANER else if (!soap_tag_cmp(key, "Content-Type")) @@ -5605,7 +6312,7 @@ http_parse_header(struct soap *soap, const char *key, const char *val) else if (!soap_tag_cmp(val, "close")) soap->keep_alive = 0; } -#ifndef WITH_LEAN +#if !defined(WITH_LEAN) || defined(WITH_NTLM) else if (!soap_tag_cmp(key, "Authorization") || !soap_tag_cmp(key, "Proxy-Authorization")) { #ifdef WITH_NTLM @@ -5618,7 +6325,8 @@ http_parse_header(struct soap *soap, const char *key, const char *val) char *s; soap_base642s(soap, val + 6, soap->tmpbuf, sizeof(soap->tmpbuf) - 1, &n); soap->tmpbuf[n] = '\0'; - if ((s = strchr(soap->tmpbuf, ':'))) + s = strchr(soap->tmpbuf, ':'); + if (s) { *s = '\0'; soap->userid = soap_strdup(soap, soap->tmpbuf); soap->passwd = soap_strdup(soap, s + 1); @@ -5636,8 +6344,8 @@ http_parse_header(struct soap *soap, const char *key, const char *val) } else if (!soap_tag_cmp(key, "Expect")) { if (!soap_tag_cmp(val, "100-continue")) - { if ((soap->error = soap->fposthdr(soap, "HTTP/1.1 100 Continue", NULL)) - || (soap->error = soap->fposthdr(soap, NULL, NULL))) + { if ((soap->error = soap->fposthdr(soap, "HTTP/1.1 100 Continue", NULL)) != SOAP_OK + || (soap->error = soap->fposthdr(soap, NULL, NULL)) != SOAP_OK) return soap->error; } } @@ -5652,8 +6360,7 @@ http_parse_header(struct soap *soap, const char *key, const char *val) soap->action = soap_strdup(soap, val); } else if (!soap_tag_cmp(key, "Location")) - { strncpy(soap->endpoint, val, sizeof(soap->endpoint)); - soap->endpoint[sizeof(soap->endpoint) - 1] = '\0'; + { soap_strcpy(soap->endpoint, sizeof(soap->endpoint), val); } else if (!soap_tag_cmp(key, "X-Forwarded-For")) { soap->proxy_from = soap_strdup(soap, val); @@ -5672,16 +6379,17 @@ http_parse_header(struct soap *soap, const char *key, const char *val) #endif /******************************************************************************/ + #if !defined(WITH_NOHTTP) || !defined(WITH_LEANER) #ifndef PALM_1 SOAP_FMAC1 const char* SOAP_FMAC2 soap_get_header_attribute(struct soap *soap, const char *line, const char *key) -{ register const char *s = line; +{ const char *s = line; if (s) { while (*s) - { register short flag; + { short flag; s = soap_decode_key(soap->tmpbuf, sizeof(soap->tmpbuf), s); flag = soap_tag_cmp(soap->tmpbuf, key); s = soap_decode_val(soap->tmpbuf, sizeof(soap->tmpbuf), s); @@ -5695,6 +6403,7 @@ soap_get_header_attribute(struct soap *soap, const char *line, const char *key) #endif /******************************************************************************/ + #if !defined(WITH_NOHTTP) || !defined(WITH_LEANER) #ifndef PALM_1 SOAP_FMAC1 @@ -5707,6 +6416,7 @@ soap_decode_key(char *buf, size_t len, const char *val) #endif /******************************************************************************/ + #if !defined(WITH_NOHTTP) || !defined(WITH_LEANER) #ifndef PALM_1 SOAP_FMAC1 @@ -5723,6 +6433,7 @@ soap_decode_val(char *buf, size_t len, const char *val) #endif /******************************************************************************/ + #if !defined(WITH_NOHTTP) || !defined(WITH_LEANER) #ifndef PALM_1 static const char* @@ -5761,12 +6472,14 @@ soap_decode(char *buf, size_t len, const char *val, const char *sep) #endif /******************************************************************************/ + #ifndef WITH_NOHTTP #ifndef PALM_1 static const char* http_error(struct soap *soap, int status) -{ register const char *msg = SOAP_STR_EOS; +{ const char *msg = SOAP_STR_EOS; (void)soap; + (void)status; #ifndef WITH_LEAN msg = soap_code_str(h_http_error_codes, status); if (!msg) @@ -5791,6 +6504,7 @@ http_get(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_NOHTTP #ifndef PALM_1 static int @@ -5802,6 +6516,7 @@ http_405(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_NOHTTP #ifndef PALM_1 static int @@ -5812,12 +6527,14 @@ http_200(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_NOHTTP #ifndef PALM_1 static int http_post(struct soap *soap, const char *endpoint, const char *host, int port, const char *path, const char *action, size_t count) -{ register const char *s; - register int err; +{ const char *s; + int err; + size_t l; switch (soap->status) { case SOAP_GET: s = "GET"; @@ -5836,39 +6553,23 @@ http_post(struct soap *soap, const char *endpoint, const char *host, int port, c } DBGLOG(TEST, SOAP_MESSAGE(fdebug, "HTTP %s to %s\n", s, endpoint ? endpoint : "(null)")); #ifdef PALM - if (!endpoint || (soap_tag_cmp(endpoint, "http:*") && soap_tag_cmp(endpoint, "https:*") && strncmp(endpoint, "httpg:", 6)) && strncmp(endpoint, "_beam:", 6) && strncmp(endpoint, "_local:", 7) && strncmp(endpoint, "_btobex:", 8)) + if (!endpoint || (soap_tag_cmp(endpoint, "http:*") && soap_tag_cmp(endpoint, "https:*") && strncmp(endpoint, "_beam:", 6) && strncmp(endpoint, "_local:", 7) && strncmp(endpoint, "_btobex:", 8)) #else - if (!endpoint || (soap_tag_cmp(endpoint, "http:*") && soap_tag_cmp(endpoint, "https:*") && strncmp(endpoint, "httpg:", 6))) + if (!endpoint || (soap_tag_cmp(endpoint, "http:*") && soap_tag_cmp(endpoint, "https:*") && soap_tag_cmp(endpoint, "httpg:*"))) #endif return SOAP_OK; - if (strlen(endpoint) + strlen(soap->http_version) > sizeof(soap->tmpbuf) - 80 - || strlen(host) + strlen(soap->http_version) > sizeof(soap->tmpbuf) - 80) - return soap->error = SOAP_EOM; /* prevent overrun (note that 'host' and 'soap->host' are substrings of 'endpoint') */ + /* set l to prevent overruns ('host' and 'soap->host' are substrings of 'endpoint') */ + l = strlen(endpoint) + strlen(soap->http_version) + 80; + if (l > sizeof(soap->tmpbuf)) + return soap->error = SOAP_EOM; if (soap->status == SOAP_CONNECT) - { -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), "%s %s:%d HTTP/%s", s, soap->host, soap->port, soap->http_version); -#else - sprintf(soap->tmpbuf, "%s %s:%d HTTP/%s", s, soap->host, soap->port, soap->http_version); -#endif - } + (SOAP_SNPRINTF(soap->tmpbuf, sizeof(soap->tmpbuf), l), "%s %s:%d HTTP/%s", s, soap->host, soap->port, soap->http_version); else if (soap->proxy_host && endpoint) - { -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), "%s %s HTTP/%s", s, endpoint, soap->http_version); -#else - sprintf(soap->tmpbuf, "%s %s HTTP/%s", s, endpoint, soap->http_version); -#endif - } + (SOAP_SNPRINTF(soap->tmpbuf, sizeof(soap->tmpbuf), l), "%s %s HTTP/%s", s, endpoint, soap->http_version); else - { -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), "%s /%s HTTP/%s", s, (*path == '/' ? path + 1 : path), soap->http_version); -#else - sprintf(soap->tmpbuf, "%s /%s HTTP/%s", s, (*path == '/' ? path + 1 : path), soap->http_version); -#endif - } - if ((err = soap->fposthdr(soap, soap->tmpbuf, NULL))) + (SOAP_SNPRINTF(soap->tmpbuf, sizeof(soap->tmpbuf), l), "%s /%s HTTP/%s", s, (*path == '/' ? path + 1 : path), soap->http_version); + err = soap->fposthdr(soap, soap->tmpbuf, NULL); + if (err) return err; #ifdef WITH_OPENSSL if ((soap->ssl && port != 443) || (!soap->ssl && port != 80)) @@ -5878,93 +6579,73 @@ http_post(struct soap *soap, const char *endpoint, const char *host, int port, c { #ifdef WITH_IPV6 if (*host != '[' && strchr(host, ':')) - { -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), "[%s]:%d", host, port); /* RFC 2732 */ -#else - sprintf(soap->tmpbuf, "[%s]:%d", host, port); /* RFC 2732 */ -#endif - } + (SOAP_SNPRINTF(soap->tmpbuf, sizeof(soap->tmpbuf), l), "[%s]:%d", host, port); /* RFC 2732 */ else #endif - { -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), "%s:%d", host, port); -#else - sprintf(soap->tmpbuf, "%s:%d", host, port); -#endif - } + (SOAP_SNPRINTF(soap->tmpbuf, sizeof(soap->tmpbuf), l), "%s:%d", host, port); } else { #ifdef WITH_IPV6 if (*host != '[' && strchr(host, ':')) - { -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), "[%s]", host); /* RFC 2732 */ -#else - sprintf(soap->tmpbuf, "[%s]", host); /* RFC 2732 */ -#endif - } + (SOAP_SNPRINTF(soap->tmpbuf, sizeof(soap->tmpbuf), l), "[%s]", host); /* RFC 2732 */ else #endif - strcpy(soap->tmpbuf, host); + soap_strcpy(soap->tmpbuf, sizeof(soap->tmpbuf), host); } - if ((err = soap->fposthdr(soap, "Host", soap->tmpbuf))) + err = soap->fposthdr(soap, "Host", soap->tmpbuf); + if (err) return err; - if ((err = soap->fposthdr(soap, "User-Agent", "gSOAP/2.8"))) + err = soap->fposthdr(soap, "User-Agent", "gSOAP/2.8"); + if (err) return err; - if ((err = soap_puthttphdr(soap, SOAP_OK, count))) + err = soap_puthttphdr(soap, SOAP_OK, count); + if (err) return err; #ifdef WITH_ZLIB #ifdef WITH_GZIP - if ((err = soap->fposthdr(soap, "Accept-Encoding", "gzip, deflate"))) + err = soap->fposthdr(soap, "Accept-Encoding", "gzip, deflate"); #else - if ((err = soap->fposthdr(soap, "Accept-Encoding", "deflate"))) + err = soap->fposthdr(soap, "Accept-Encoding", "deflate"); #endif + if (err) return err; #endif -#ifndef WITH_LEAN +#if !defined(WITH_LEAN) || defined(WITH_NTLM) #ifdef WITH_NTLM - if (soap->ntlm_challenge && strlen(soap->ntlm_challenge) + 6 < sizeof(soap->tmpbuf)) - { if (*soap->ntlm_challenge) - { -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), "NTLM %s", soap->ntlm_challenge); -#else - sprintf(soap->tmpbuf, "NTLM %s", soap->ntlm_challenge); -#endif + if (soap->ntlm_challenge) + { l = strlen(soap->ntlm_challenge); + if (l) + { (SOAP_SNPRINTF(soap->tmpbuf, sizeof(soap->tmpbuf), l + 5), "NTLM %s", soap->ntlm_challenge); if (soap->proxy_host) - { if ((err = soap->fposthdr(soap, "Proxy-Authorization", soap->tmpbuf))) + { err = soap->fposthdr(soap, "Proxy-Authorization", soap->tmpbuf); + if (err) + return err; + } + else + { err = soap->fposthdr(soap, "Authorization", soap->tmpbuf); + if (err) return err; } - else if ((err = soap->fposthdr(soap, "Authorization", soap->tmpbuf))) - return err; } } else { #endif - if (soap->userid && soap->passwd && strlen(soap->userid) + strlen(soap->passwd) < 761) - { strcpy(soap->tmpbuf, "Basic "); -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf + 262, sizeof(soap->tmpbuf) - 262, "%s:%s", soap->userid, soap->passwd); -#else - sprintf(soap->tmpbuf + 262, "%s:%s", soap->userid, soap->passwd); -#endif + if (soap->userid && soap->passwd) + { soap_strcpy(soap->tmpbuf, sizeof(soap->tmpbuf), "Basic "); + (SOAP_SNPRINTF(soap->tmpbuf + 262, sizeof(soap->tmpbuf) - 262, strlen(soap->userid) + strlen(soap->passwd) + 1), "%s:%s", soap->userid, soap->passwd); soap_s2base64(soap, (const unsigned char*)(soap->tmpbuf + 262), soap->tmpbuf + 6, (int)strlen(soap->tmpbuf + 262)); - if ((err = soap->fposthdr(soap, "Authorization", soap->tmpbuf))) + err = soap->fposthdr(soap, "Authorization", soap->tmpbuf); + if (err) return err; } - if (soap->proxy_userid && soap->proxy_passwd && strlen(soap->proxy_userid) + strlen(soap->proxy_passwd) < 761) - { strcpy(soap->tmpbuf, "Basic "); -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf + 262, sizeof(soap->tmpbuf) - 262, "%s:%s", soap->proxy_userid, soap->proxy_passwd); -#else - sprintf(soap->tmpbuf + 262, "%s:%s", soap->proxy_userid, soap->proxy_passwd); -#endif + if (soap->proxy_userid && soap->proxy_passwd) + { soap_strcpy(soap->tmpbuf, sizeof(soap->tmpbuf), "Basic "); + (SOAP_SNPRINTF(soap->tmpbuf + 262, sizeof(soap->tmpbuf) - 262, strlen(soap->proxy_userid) + strlen(soap->proxy_passwd) + 1), "%s:%s", soap->proxy_userid, soap->proxy_passwd); soap_s2base64(soap, (const unsigned char*)(soap->tmpbuf + 262), soap->tmpbuf + 6, (int)strlen(soap->tmpbuf + 262)); - if ((err = soap->fposthdr(soap, "Proxy-Authorization", soap->tmpbuf))) + err = soap->fposthdr(soap, "Proxy-Authorization", soap->tmpbuf); + if (err) return err; } #ifdef WITH_NTLM @@ -5981,13 +6662,9 @@ http_post(struct soap *soap, const char *endpoint, const char *host, int port, c #endif #endif if (action && soap->status != SOAP_GET && soap->status != SOAP_DEL) - { -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), "\"%s\"", action); -#else - sprintf(soap->tmpbuf, "\"%s\"", strlen(action) < sizeof(soap->tmpbuf) - 3 ? action : SOAP_STR_EOS); -#endif - if ((err = soap->fposthdr(soap, "SOAPAction", soap->tmpbuf))) + { (SOAP_SNPRINTF(soap->tmpbuf, sizeof(soap->tmpbuf), strlen(action) + 2), "\"%s\"", action); + err = soap->fposthdr(soap, "SOAPAction", soap->tmpbuf); + if (err) return err; } return soap->fposthdr(soap, NULL, NULL); @@ -5996,11 +6673,12 @@ http_post(struct soap *soap, const char *endpoint, const char *host, int port, c #endif /******************************************************************************/ + #ifndef WITH_NOHTTP #ifndef PALM_1 static int http_send_header(struct soap *soap, const char *s) -{ register const char *t; +{ const char *t; do { t = strchr(s, '\n'); /* disallow \n in HTTP headers */ if (!t) @@ -6015,6 +6693,7 @@ http_send_header(struct soap *soap, const char *s) #endif /******************************************************************************/ + #ifndef WITH_NOHTTP #ifndef PALM_1 static int @@ -6031,34 +6710,27 @@ http_post_header(struct soap *soap, const char *key, const char *val) #endif /******************************************************************************/ + #ifndef WITH_NOHTTP #ifndef PALM_1 static int http_response(struct soap *soap, int status, size_t count) -{ register int err; - char http[10]; +{ int err; + char http[16]; int code = status; const char *line; #ifdef WMW_RPM_IO if (soap->rpmreqid) httpOutputEnable(soap->rpmreqid); #endif - if (!soap->http_version || strlen(soap->http_version) > 4) - return soap->error = SOAP_EOM; #ifdef WMW_RPM_IO if (soap->rpmreqid || soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* RPM behaves as if standalone */ #else if (soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* standalone application (socket) or CGI (stdin/out)? */ #endif - { -#ifdef HAVE_SNPRINTF - soap_snprintf(http, sizeof(http), "HTTP/%s", soap->http_version); -#else - sprintf(http, "HTTP/%s", soap->http_version); -#endif - } + (SOAP_SNPRINTF(http, sizeof(http), strlen(soap->http_version) + 5), "HTTP/%s", soap->http_version); else - strcpy(http, "Status:"); + soap_strcpy(http, sizeof(http), "Status:"); if (!status || status == SOAP_HTML || status == SOAP_FILE) { if (count || ((soap->omode & SOAP_IO) == SOAP_IO_CHUNK)) code = 200; @@ -6076,31 +6748,28 @@ http_response(struct soap *soap, int status, size_t count) } line = http_error(soap, code); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "HTTP Status = %d %s\n", code, line)); -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), "%s %d %s", http, code, line); -#else - sprintf(soap->tmpbuf, "%s %d %s", http, code, line); -#endif - if ((err = soap->fposthdr(soap, soap->tmpbuf, NULL))) + (SOAP_SNPRINTF(soap->tmpbuf, sizeof(soap->tmpbuf), sizeof(http) + 22 + strlen(line)), "%s %d %s", http, code, line); + err = soap->fposthdr(soap, soap->tmpbuf, NULL); + if (err) return err; #ifndef WITH_LEAN if (status == 401) - { -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), "Basic realm=\"%s\"", (soap->authrealm && strlen(soap->authrealm) < sizeof(soap->tmpbuf) - 14) ? soap->authrealm : "gSOAP Web Service"); -#else - sprintf(soap->tmpbuf, "Basic realm=\"%s\"", (soap->authrealm && strlen(soap->authrealm) < sizeof(soap->tmpbuf) - 14) ? soap->authrealm : "gSOAP Web Service"); -#endif - if ((err = soap->fposthdr(soap, "WWW-Authenticate", soap->tmpbuf))) + { (SOAP_SNPRINTF_SAFE(soap->tmpbuf, sizeof(soap->tmpbuf)), "Basic realm=\"%s\"", (soap->authrealm && strlen(soap->authrealm) + 14 < sizeof(soap->tmpbuf)) ? soap->authrealm : "gSOAP Web Service"); + err = soap->fposthdr(soap, "WWW-Authenticate", soap->tmpbuf); + if (err) return err; } else if ((status >= 301 && status <= 303) || status == 307) - { if ((err = soap->fposthdr(soap, "Location", soap->endpoint))) + { err = soap->fposthdr(soap, "Location", soap->endpoint); + if (err) return err; } #endif - if ((err = soap->fposthdr(soap, "Server", "gSOAP/2.8")) - || (err = soap_puthttphdr(soap, status, count))) + err = soap->fposthdr(soap, "Server", "gSOAP/2.8"); + if (err) + return err; + err = soap_puthttphdr(soap, status, count); + if (err) return err; #ifdef WITH_COOKIES if (soap_putsetcookies(soap)) @@ -6112,12 +6781,13 @@ http_response(struct soap *soap, int status, size_t count) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 soap_response(struct soap *soap, int status) -{ register size_t count; +{ size_t count; if (!(soap->omode & (SOAP_ENC_XML | SOAP_IO_STORE /* this tests for chunking too */)) && (status == SOAP_HTML || status == SOAP_FILE)) soap->omode = (soap->omode & ~SOAP_IO) | SOAP_IO_STORE; @@ -6127,11 +6797,12 @@ soap_response(struct soap *soap, int status) return soap->error; #ifndef WITH_NOHTTP if ((soap->mode & SOAP_IO) != SOAP_IO_STORE && !(soap->mode & SOAP_ENC_XML)) - { register int n = soap->mode; + { int n = soap->mode; soap->mode &= ~(SOAP_IO | SOAP_ENC_ZLIB); if ((n & SOAP_IO) != SOAP_IO_FLUSH) soap->mode |= SOAP_IO_BUFFER; - if ((soap->error = soap->fresponse(soap, status, count))) + soap->error = soap->fresponse(soap, status, count); + if (soap->error) return soap->error; #ifndef WITH_LEANER if ((n & SOAP_IO) == SOAP_IO_CHUNK) @@ -6147,27 +6818,63 @@ soap_response(struct soap *soap, int status) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 const char* SOAP_FMAC2 -soap_url(struct soap *soap, const char *s, const char *t) -{ if (!t || (*t != '/' && *t != '?') || strlen(s) + strlen(t) >= sizeof(soap->msgbuf)) - return s; - strcpy(soap->msgbuf, s); - strcat(soap->msgbuf, t); +soap_extend_url(struct soap *soap, const char *s, const char *t) +{ if (s) + soap_strcpy(soap->msgbuf, sizeof(soap->msgbuf), s); + else + *soap->msgbuf = '\0'; + if (t && (*t == '/' || *t == '?')) + { char *r = strchr(soap->msgbuf, '?'); + if (r) + { if (*t == '?') + { soap_strncat(soap->msgbuf, sizeof(soap->msgbuf), "&", 1); + soap_strncat(soap->msgbuf, sizeof(soap->msgbuf), t + 1, strlen(t) - 1); + } + else /* *t == '/' */ + { size_t l = r - soap->msgbuf; + *r = '\0'; + soap_strncat(soap->msgbuf, sizeof(soap->msgbuf), t, strlen(t)); + if (s) + soap_strncat(soap->msgbuf, sizeof(soap->msgbuf), s + l, strlen(s + l)); + } + } + else + soap_strncat(soap->msgbuf, sizeof(soap->msgbuf), t, strlen(t)); + } return soap->msgbuf; } #endif /******************************************************************************/ + +#ifndef PALM_1 +SOAP_FMAC1 +const char* +SOAP_FMAC2 +soap_extend_url_query(struct soap *soap, const char *s, const char *t) +{ soap_extend_url(soap, s, t); + if (strchr(soap->msgbuf, '?')) + soap_strncat(soap->msgbuf, sizeof(soap->msgbuf), "&", 1); + else + soap_strncat(soap->msgbuf, sizeof(soap->msgbuf), "?", 1); + return soap->msgbuf; +} +#endif + +/******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 size_t SOAP_FMAC2 soap_encode_url(const char *s, char *t, size_t len) -{ register int c; - register size_t n = len; +{ int c; + size_t n = len; while ((c = *s++) && --n > 0) { if (c > ' ' && c < 128 && !strchr("()<>@,;:\\\"/[]?={}#!$&'*+", c)) *t++ = c; @@ -6187,6 +6894,7 @@ soap_encode_url(const char *s, char *t, size_t len) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 const char* @@ -6206,12 +6914,12 @@ soap_encode_url_string(struct soap *soap, const char *s) /******************************************************************************\ * - * HTTP Cookies + * HTTP Cookies * \******************************************************************************/ #ifdef WITH_COOKIES -/******************************************************************************/ + SOAP_FMAC1 struct soap_cookie* SOAP_FMAC2 @@ -6229,16 +6937,15 @@ soap_cookie(struct soap *soap, const char *name, const char *domain, const char for (p = soap->cookies; p; p = p->next) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Cookie in database: %s='%s' domain='%s' path='%s' env=%hd\n", p->name, p->value ? p->value : "(null)", p->domain ? p->domain : "(null)", p->path ? p->path : "(null)", p->env)); if (!strcmp(p->name, name) - && p->domain - && p->path - && !strcmp(p->domain, domain) - && (!*p->path || !strncmp(p->path, path, strlen(p->path)))) + && ((!domain && !p->domain) || (domain && p->domain && !strcmp(p->domain, domain))) + && ((!path && !p->path) || (path && p->path && !strncmp(p->path, path, strlen(p->path))))) break; } return p; } /******************************************************************************/ + SOAP_FMAC1 struct soap_cookie* SOAP_FMAC2 @@ -6256,9 +6963,12 @@ soap_set_cookie(struct soap *soap, const char *name, const char *value, const ch q = soap_cookie(soap, name, domain, path); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set %scookie: %s='%s' domain='%s' path='%s'\n", q ? SOAP_STR_EOS : "new ", name, value ? value : "(null)", domain ? domain : "(null)", path ? path : "(null)")); if (!q) - { if ((q = (struct soap_cookie*)SOAP_MALLOC(soap, sizeof(struct soap_cookie)))) - { if ((q->name = (char*)SOAP_MALLOC(soap, strlen(name)+1))) - strcpy(q->name, name); + { q = (struct soap_cookie*)SOAP_MALLOC(soap, sizeof(struct soap_cookie)); + if (q) + { size_t l = strlen(name); + q->name = (char*)SOAP_MALLOC(soap, l + 1); + if (q->name) + soap_strcpy(q->name, l + 1, name); q->value = NULL; q->domain = NULL; q->path = NULL; @@ -6290,24 +7000,36 @@ soap_set_cookie(struct soap *soap, const char *name, const char *value, const ch q->value = NULL; } } - if (value && *value && !q->value && (q->value = (char*)SOAP_MALLOC(soap, strlen(value)+1))) - strcpy(q->value, value); + if (value && *value && !q->value) + { size_t l = strlen(value); + q->value = (char*)SOAP_MALLOC(soap, l + 1); + if (q->value) + soap_strcpy(q->value, l + 1, value); + } if (q->domain) { if (!domain || strcmp(domain, q->domain)) { SOAP_FREE(soap, q->domain); q->domain = NULL; } } - if (domain && !q->domain && (q->domain = (char*)SOAP_MALLOC(soap, strlen(domain)+1))) - strcpy(q->domain, domain); + if (domain && !q->domain) + { size_t l = strlen(domain); + q->domain = (char*)SOAP_MALLOC(soap, l + 1); + if (q->domain) + soap_strcpy(q->domain, l + 1, domain); + } if (q->path) { if (!path || strncmp(path, q->path, strlen(q->path))) { SOAP_FREE(soap, q->path); q->path = NULL; } } - if (path && !q->path && (q->path = (char*)SOAP_MALLOC(soap, strlen(path)+1))) - strcpy(q->path, path); + if (path && !q->path) + { size_t l = strlen(path); + q->path = (char*)SOAP_MALLOC(soap, l + 1); + if (q->path) + soap_strcpy(q->path, l + 1, path); + } q->session = 1; q->env = 0; } @@ -6315,6 +7037,7 @@ soap_set_cookie(struct soap *soap, const char *name, const char *value, const ch } /******************************************************************************/ + SOAP_FMAC1 void SOAP_FMAC2 @@ -6335,7 +7058,7 @@ soap_clr_cookie(struct soap *soap, const char *name, const char *domain, const c if (*path == '/') path++; for (p = &soap->cookies, q = *p; q; q = *p) - { if (!strcmp(q->name, name) && !strcmp(q->domain, domain) && !strncmp(q->path, path, strlen(q->path))) + { if (!strcmp(q->name, name) && (!q->domain || !strcmp(q->domain, domain)) && (!q->path || !strncmp(q->path, path, strlen(q->path)))) { if (q->value) SOAP_FREE(soap, q->value); if (q->domain) @@ -6351,46 +7074,54 @@ soap_clr_cookie(struct soap *soap, const char *name, const char *domain, const c } /******************************************************************************/ + SOAP_FMAC1 char * SOAP_FMAC2 soap_cookie_value(struct soap *soap, const char *name, const char *domain, const char *path) { struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path))) + p = soap_cookie(soap, name, domain, path); + if (p) return p->value; return NULL; } /******************************************************************************/ + SOAP_FMAC1 char * SOAP_FMAC2 soap_env_cookie_value(struct soap *soap, const char *name, const char *domain, const char *path) { struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path)) && p->env) + p = soap_cookie(soap, name, domain, path); + if (p && p->env) return p->value; return NULL; } /******************************************************************************/ + SOAP_FMAC1 time_t SOAP_FMAC2 soap_cookie_expire(struct soap *soap, const char *name, const char *domain, const char *path) { struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path))) + p = soap_cookie(soap, name, domain, path); + if (p) return p->expire; return -1; } /******************************************************************************/ + SOAP_FMAC1 int SOAP_FMAC2 soap_set_cookie_expire(struct soap *soap, const char *name, long expire, const char *domain, const char *path) { struct soap_cookie *p; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set cookie expiration max-age=%ld: cookie='%s' domain='%s' path='%s'\n", expire, name, domain ? domain : "(null)", path ? path : "(null)")); - if ((p = soap_cookie(soap, name, domain, path))) + p = soap_cookie(soap, name, domain, path); + if (p) { p->maxage = expire; p->modified = 1; return SOAP_OK; @@ -6399,12 +7130,14 @@ soap_set_cookie_expire(struct soap *soap, const char *name, long expire, const c } /******************************************************************************/ + SOAP_FMAC1 int SOAP_FMAC2 soap_set_cookie_session(struct soap *soap, const char *name, const char *domain, const char *path) { struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path))) + p = soap_cookie(soap, name, domain, path); + if (p) { p->session = 1; p->modified = 1; return SOAP_OK; @@ -6413,12 +7146,14 @@ soap_set_cookie_session(struct soap *soap, const char *name, const char *domain, } /******************************************************************************/ + SOAP_FMAC1 int SOAP_FMAC2 soap_clr_cookie_session(struct soap *soap, const char *name, const char *domain, const char *path) { struct soap_cookie *p; - if ((p = soap_cookie(soap, name, domain, path))) + p = soap_cookie(soap, name, domain, path); + if (p) { p->session = 0; p->modified = 1; return SOAP_OK; @@ -6427,6 +7162,7 @@ soap_clr_cookie_session(struct soap *soap, const char *name, const char *domain, } /******************************************************************************/ + SOAP_FMAC1 int SOAP_FMAC2 @@ -6435,28 +7171,28 @@ soap_putsetcookies(struct soap *soap) char *s, tmp[4096]; const char *t; for (p = soap->cookies; p; p = p->next) - { - if (p->modified + { if (p->modified #ifdef WITH_OPENSSL || (!p->env && !soap->ssl == !p->secure) #endif ) { s = tmp; if (p->name) - s += soap_encode_url(p->name, s, tmp-s+4064); + s += soap_encode_url(p->name, s, 4064 - (s-tmp)); if (p->value && *p->value) { *s++ = '='; - s += soap_encode_url(p->value, s, tmp-s+4064); + s += soap_encode_url(p->value, s, 4064 - (s-tmp)); } - if (p->domain && (int)strlen(p->domain) < tmp-s+4064) - { strcpy(s, ";Domain="); - strcat(s, p->domain); + if (p->domain && (int)strlen(p->domain) < 4064 - (s-tmp)) + { soap_strcpy(s, 4096 - (s-tmp), ";Domain="); + soap_strcpy(s + 8, 4088 - (s-tmp), p->domain); } - else if (soap->cookie_domain && (int)strlen(soap->cookie_domain) < tmp-s+4064) - { strcpy(s, ";Domain="); - strcat(s, soap->cookie_domain); + else if (soap->cookie_domain && (int)strlen(soap->cookie_domain) < 4064 - (s-tmp)) + { soap_strcpy(s, 4096 - (s-tmp), ";Domain="); + soap_strcpy(s + 8, 4088 - (s-tmp), soap->cookie_domain); } - strcat(s, ";Path=/"); + s += strlen(s); + soap_strcpy(s, 4096 - (s-tmp), ";Path=/"); s += strlen(s); if (p->path) t = p->path; @@ -6465,31 +7201,21 @@ soap_putsetcookies(struct soap *soap) if (t) { if (*t == '/') t++; - if ((int)strlen(t) < tmp-s+4064) - { if (strchr(t, '%')) /* already URL encoded? */ - { strcpy(s, t); + if ((int)strlen(t) < 4064 - (s-tmp)) + { if (strchr(t, '%')) /* already URL encoded? */ + { soap_strcpy(s, 4096 - (s-tmp), t); s += strlen(s); } else - s += soap_encode_url(t, s, tmp-s+4064); + s += soap_encode_url(t, s, 4064 - (s-tmp)); } } - if (p->version > 0 && s-tmp < 4060) - { -#ifdef HAVE_SNPRINTF - soap_snprintf(s, 4096 - (s-tmp), ";Version=%u", p->version); -#else - sprintf(s, ";Version=%u", p->version); -#endif + if (p->version > 0 && s-tmp < 4064) + { (SOAP_SNPRINTF(s, 4096 - (s-tmp), 29), ";Version=%u", p->version); s += strlen(s); } - if (p->maxage >= 0 && s-tmp < 4060) - { -#ifdef HAVE_SNPRINTF - soap_snprintf(s, 4096 - (s-tmp), ";Max-Age=%ld", p->maxage); -#else - sprintf(s, ";Max-Age=%ld", p->maxage); -#endif + if (p->maxage >= 0 && s-tmp < 4064) + { (SOAP_SNPRINTF(s, 4096 - (s-tmp), 29), ";Max-Age=%ld", p->maxage); s += strlen(s); } if (s-tmp < 4073 @@ -6498,9 +7224,10 @@ soap_putsetcookies(struct soap *soap) || soap->ssl #endif )) - strcpy(s, ";Secure"); + soap_strcpy(s, 4096 - (s-tmp), ";Secure"); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set-Cookie: %s\n", tmp)); - if ((soap->error = soap->fposthdr(soap, "Set-Cookie", tmp))) + soap->error = soap->fposthdr(soap, "Set-Cookie", tmp); + if (soap->error) return soap->error; } } @@ -6508,6 +7235,7 @@ soap_putsetcookies(struct soap *soap) } /******************************************************************************/ + SOAP_FMAC1 int SOAP_FMAC2 @@ -6555,10 +7283,14 @@ soap_putcookies(struct soap *soap, const char *domain, const char *path, int sec if (!flag) { struct hostent *hostent = gethostbyname((char*)domain); if (hostent) - { const char *r = strchr(hostent->h_name, '.'); - if (!r) - r = hostent->h_name; + { const char *r = hostent->h_name; + if (*t == '.') + { size_t k = strlen(hostent->h_name); + if (k >= n) + r = hostent->h_name + k - n; + } flag = !strncmp(t, r, n); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Domain cookie %s host %s (match=%d)\n", t, r, flag)); } } #endif @@ -6578,21 +7310,16 @@ soap_putcookies(struct soap *soap, const char *domain, const char *path, int sec { if (s == tmp) return SOAP_OK; /* HTTP header size overflow */ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Cookie: %s\n", tmp)); - if ((soap->error = soap->fposthdr(soap, "Cookie", tmp))) + soap->error = soap->fposthdr(soap, "Cookie", tmp); + if (soap->error) return soap->error; s = tmp; } else if (s != tmp) - { strcat(s, " "); - s++; + { *s++ = ' '; } if (q->version != version && s-tmp < 4060) - { -#ifdef HAVE_SNPRINTF - soap_snprintf(s, 4096 - (s-tmp), "$Version=%u;", q->version); -#else - sprintf(s, "$Version=%u;", q->version); -#endif + { (SOAP_SNPRINTF(s, 4096 - (s-tmp), 29), "$Version=%u;", q->version); version = q->version; s += strlen(s); } @@ -6603,21 +7330,11 @@ soap_putcookies(struct soap *soap, const char *domain, const char *path, int sec s += soap_encode_url(q->value, s, tmp+sizeof(tmp)-s-16); } if (q->path && (s-tmp) + strlen(q->path) < 4060) - { -#ifdef HAVE_SNPRINTF - soap_snprintf(s, 4096 - (s-tmp), ";$Path=\"/%s\"", (*q->path == '/' ? q->path + 1 : q->path)); -#else - sprintf(s, ";$Path=\"/%s\"", (*q->path == '/' ? q->path + 1 : q->path)); -#endif + { (SOAP_SNPRINTF_SAFE(s, 4096 - (s-tmp)), ";$Path=\"/%s\"", (*q->path == '/' ? q->path + 1 : q->path)); s += strlen(s); } if (q->domain && (s-tmp) + strlen(q->domain) < 4060) - { -#ifdef HAVE_SNPRINTF - soap_snprintf(s, 4096 - (s-tmp), ";$Domain=\"%s\"", q->domain); -#else - sprintf(s, ";$Domain=\"%s\"", q->domain); -#endif + { (SOAP_SNPRINTF_SAFE(s, 4096 - (s-tmp)), ";$Domain=\"%s\"", q->domain); s += strlen(s); } } @@ -6625,12 +7342,15 @@ soap_putcookies(struct soap *soap, const char *domain, const char *path, int sec } } if (s != tmp) - if ((soap->error = soap->fposthdr(soap, "Cookie", tmp))) + { soap->error = soap->fposthdr(soap, "Cookie", tmp); + if (soap->error) return soap->error; + } return SOAP_OK; } /******************************************************************************/ + SOAP_FMAC1 void SOAP_FMAC2 @@ -6648,7 +7368,8 @@ soap_getcookies(struct soap *soap, const char *val) while (*s) { s = soap_decode_key(tmp, sizeof(tmp), s); if (!soap_tag_cmp(tmp, "$Version")) - { if ((s = soap_decode_val(tmp, sizeof(tmp), s))) + { s = soap_decode_val(tmp, sizeof(tmp), s); + if (s) { if (p) p->version = (int)soap_strtol(tmp, NULL, 10); else @@ -6658,8 +7379,10 @@ soap_getcookies(struct soap *soap, const char *val) else if (!soap_tag_cmp(tmp, "$Path")) { s = soap_decode_val(tmp, sizeof(tmp), s); if (*tmp) - { if ((t = (char*)SOAP_MALLOC(soap, strlen(tmp)+1))) - strcpy(t, tmp); + { size_t l = strlen(tmp) + 1; + t = (char*)SOAP_MALLOC(soap, l); + if (t) + soap_memcpy((void*)t, l, (const void*)tmp, l); } else t = NULL; @@ -6677,8 +7400,10 @@ soap_getcookies(struct soap *soap, const char *val) else if (!soap_tag_cmp(tmp, "$Domain")) { s = soap_decode_val(tmp, sizeof(tmp), s); if (*tmp) - { if ((t = (char*)SOAP_MALLOC(soap, strlen(tmp)+1))) - strcpy(t, tmp); + { size_t l = strlen(tmp) + 1; + t = (char*)SOAP_MALLOC(soap, l); + if (t) + soap_memcpy((void*)t, l, (const void*)tmp, l); } else t = NULL; @@ -6698,8 +7423,10 @@ soap_getcookies(struct soap *soap, const char *val) SOAP_FREE(soap, p->path); s = soap_decode_val(tmp, sizeof(tmp), s); if (*tmp) - { if ((p->path = (char*)SOAP_MALLOC(soap, strlen(tmp)+1))) - strcpy(p->path, tmp); + { size_t l = strlen(tmp) + 1; + p->path = (char*)SOAP_MALLOC(soap, l); + if (p->path) + soap_memcpy((void*)p->path, l, (const void*)tmp, l); } else p->path = NULL; @@ -6709,8 +7436,10 @@ soap_getcookies(struct soap *soap, const char *val) SOAP_FREE(soap, p->domain); s = soap_decode_val(tmp, sizeof(tmp), s); if (*tmp) - { if ((p->domain = (char*)SOAP_MALLOC(soap, strlen(tmp)+1))) - strcpy(p->domain, tmp); + { size_t l = strlen(tmp) + 1; + p->domain = (char*)SOAP_MALLOC(soap, l); + if (p->domain) + soap_memcpy((void*)p->domain, l, (const void*)tmp, l); } else p->domain = NULL; @@ -6757,7 +7486,8 @@ soap_getcookies(struct soap *soap, const char *val) else { if (p) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Got environment cookie='%s' value='%s' domain='%s' path='%s' expire=%ld secure=%d\n", p->name, p->value ? p->value : "(null)", p->domain ? p->domain : "(null)", p->path ? p->path : "(null)", p->expire, p->secure)); - if ((q = soap_set_cookie(soap, p->name, p->value, p->domain, p->path))) + q = soap_set_cookie(soap, p->name, p->value, p->domain, p->path); + if (q) { q->version = p->version; q->expire = p->expire; q->secure = p->secure; @@ -6773,33 +7503,43 @@ soap_getcookies(struct soap *soap, const char *val) SOAP_FREE(soap, p->path); SOAP_FREE(soap, p); } - if ((p = (struct soap_cookie*)SOAP_MALLOC(soap, sizeof(struct soap_cookie)))) - { p->name = (char*)SOAP_MALLOC(soap, strlen(tmp)+1); - strcpy(p->name, tmp); + p = (struct soap_cookie*)SOAP_MALLOC(soap, sizeof(struct soap_cookie)); + if (p) + { size_t l = strlen(tmp) + 1; + p->name = (char*)SOAP_MALLOC(soap, l); + if (p->name) + soap_memcpy((void*)p->name, l, (const void*)tmp, l); s = soap_decode_val(tmp, sizeof(tmp), s); if (*tmp) - { p->value = (char*)SOAP_MALLOC(soap, strlen(tmp)+1); - strcpy(p->value, tmp); + { l = strlen(tmp) + 1; + p->value = (char*)SOAP_MALLOC(soap, l); + if (p->value) + soap_memcpy((void*)p->value, l, (const void*)tmp, l); } else p->value = NULL; if (domain) p->domain = domain; else if (*soap->host) - { p->domain = (char*)SOAP_MALLOC(soap, strlen(soap->host)+1); - strcpy(p->domain, soap->host); + { l = strlen(soap->host) + 1; + p->domain = (char*)SOAP_MALLOC(soap, l); + if (p->domain) + soap_memcpy((void*)p->domain, l, (const void*)soap->host, l); } else p->domain = NULL; if (path) p->path = path; - else if (soap->path && *soap->path) - { p->path = (char*)SOAP_MALLOC(soap, strlen(soap->path)+1); - strcpy(p->path, soap->path); + else if (*soap->path) + { l = strlen(soap->path) + 1; + p->path = (char*)SOAP_MALLOC(soap, l); + if (p->path) + soap_memcpy((void*)p->path, l, (const void*)soap->path, l); } else { p->path = (char*)SOAP_MALLOC(soap, 2); - strcpy(p->path, "/"); + if (p->path) + soap_memcpy((void*)p->path, 2, (const void*)"/", 2); } p->expire = 0; p->secure = 0; @@ -6809,7 +7549,8 @@ soap_getcookies(struct soap *soap, const char *val) } if (p) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Got environment cookie='%s' value='%s' domain='%s' path='%s' expire=%ld secure=%d\n", p->name, p->value ? p->value : "(null)", p->domain ? p->domain : "(null)", p->path ? p->path : "(null)", p->expire, p->secure)); - if ((q = soap_set_cookie(soap, p->name, p->value, p->domain, p->path))) + q = soap_set_cookie(soap, p->name, p->value, p->domain, p->path); + if (q) { q->version = p->version; q->expire = p->expire; q->secure = p->secure; @@ -6832,6 +7573,7 @@ soap_getcookies(struct soap *soap, const char *val) } /******************************************************************************/ + SOAP_FMAC1 int SOAP_FMAC2 @@ -6839,7 +7581,8 @@ soap_getenv_cookies(struct soap *soap) { struct soap_cookie *p; const char *s; char key[4096], val[4096]; /* cookie size is up to 4096 bytes [RFC2109] */ - if (!(s = getenv("HTTP_COOKIE"))) + s = getenv("HTTP_COOKIE"); + if (!s) return SOAP_ERR; do { s = soap_decode_key(key, sizeof(key), s); @@ -6852,6 +7595,7 @@ soap_getenv_cookies(struct soap *soap) } /******************************************************************************/ + SOAP_FMAC1 struct soap_cookie* SOAP_FMAC2 @@ -6859,24 +7603,33 @@ soap_copy_cookies(struct soap *copy, const struct soap *soap) { struct soap_cookie *p, **q, *r; q = &r; for (p = soap->cookies; p; p = p->next) - { if (!(*q = (struct soap_cookie*)SOAP_MALLOC(copy, sizeof(struct soap_cookie)))) + { *q = (struct soap_cookie*)SOAP_MALLOC(copy, sizeof(struct soap_cookie)); + if (!*q) return r; **q = *p; if (p->name) - { if (((*q)->name = (char*)SOAP_MALLOC(copy, strlen(p->name)+1))) - strcpy((*q)->name, p->name); + { size_t l = strlen(p->name) + 1; + (*q)->name = (char*)SOAP_MALLOC(copy, l); + if ((*q)->name) + soap_memcpy((*q)->name, l, p->name, l); } if (p->value) - { if (((*q)->value = (char*)SOAP_MALLOC(copy, strlen(p->value)+1))) - strcpy((*q)->value, p->value); + { size_t l = strlen(p->value) + 1; + (*q)->value = (char*)SOAP_MALLOC(copy, l); + if ((*q)->value) + soap_memcpy((*q)->value, l, p->value, l); } if (p->domain) - { if (((*q)->domain = (char*)SOAP_MALLOC(copy, strlen(p->domain)+1))) - strcpy((*q)->domain, p->domain); + { size_t l = strlen(p->domain) + 1; + (*q)->domain = (char*)SOAP_MALLOC(copy, l); + if ((*q)->domain) + soap_memcpy((*q)->domain, l, p->domain, l); } if (p->path) - { if (((*q)->path = (char*)SOAP_MALLOC(copy, strlen(p->path)+1))) - strcpy((*q)->path, p->path); + { size_t l = strlen(p->path) + 1; + (*q)->path = (char*)SOAP_MALLOC(copy, l); + if ((*q)->path) + soap_memcpy((*q)->path, l, p->path, l); } q = &(*q)->next; } @@ -6885,6 +7638,7 @@ soap_copy_cookies(struct soap *copy, const struct soap *soap) } /******************************************************************************/ + SOAP_FMAC1 void SOAP_FMAC2 @@ -6904,44 +7658,49 @@ soap_free_cookies(struct soap *soap) } /******************************************************************************/ + #endif /* WITH_COOKIES */ /******************************************************************************/ -#ifndef WITH_NOIDREF + #ifndef PALM_2 SOAP_FMAC1 size_t SOAP_FMAC2 -soap_hash(register const char *s) -{ register size_t h = 0; +soap_hash(const char *s) +{ size_t h = 0; while (*s) h = 65599*h + *s++; return h % SOAP_IDHASH; } #endif -#endif /******************************************************************************/ -#ifndef WITH_NOIDREF + #ifndef PALM_1 static void soap_init_pht(struct soap *soap) -{ register int i; +{ int i; soap->pblk = NULL; soap->pidx = 0; for (i = 0; i < (int)SOAP_PTRHASH; i++) soap->pht[i] = NULL; } #endif -#endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 struct soap* SOAP_FMAC2 soap_versioning(soap_new)(soap_mode imode, soap_mode omode) -{ struct soap *soap = (struct soap*)malloc(sizeof(struct soap)); +{ struct soap *soap; +#ifdef __cplusplus + soap = SOAP_NEW(struct soap); +#else + soap = (struct soap*)malloc(sizeof(struct soap)); +#endif if (soap) soap_versioning(soap_init)(soap, imode, omode); return soap; @@ -6949,17 +7708,23 @@ soap_versioning(soap_new)(soap_mode imode, soap_mode omode) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 void SOAP_FMAC2 soap_free(struct soap *soap) { soap_done(soap); +#ifdef __cplusplus + SOAP_DELETE(soap); +#else free(soap); +#endif } #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 void @@ -6970,12 +7735,12 @@ soap_del(struct soap *soap) #endif /******************************************************************************/ -#ifndef WITH_NOIDREF + #ifndef PALM_1 static void soap_free_pht(struct soap *soap) -{ register struct soap_pblk *pb, *next; - register int i; +{ struct soap_pblk *pb, *next; + int i; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free pointer hashtable\n")); for (pb = soap->pblk; pb; pb = next) { next = pb->next; @@ -6987,43 +7752,44 @@ soap_free_pht(struct soap *soap) soap->pht[i] = NULL; } #endif -#endif /******************************************************************************/ + #ifndef WITH_NOIDREF #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 -soap_embed(struct soap *soap, const void *p, const struct soap_array *a, int n, const char *tag, int type) -{ register int i; +soap_embed(struct soap *soap, const void *p, const void *a, int n, int t) +{ int id; struct soap_plist *pp; - (void)soap; if (soap->version == 2) soap->encoding = 1; + if (!p || (!soap->encodingStyle && !(soap->omode & SOAP_XML_GRAPH)) || (soap->omode & SOAP_XML_TREE)) + return 0; if (a) - i = soap_array_pointer_lookup(soap, p, a, n, type, &pp); + id = soap_array_pointer_lookup(soap, p, a, n, t, &pp); else - i = soap_pointer_lookup(soap, p, type, &pp); - if (i) + id = soap_pointer_lookup(soap, p, t, &pp); + if (id) { if (soap_is_embedded(soap, pp) || soap_is_single(soap, pp)) return 0; soap_set_embedded(soap, pp); } - return i; + return id; } #endif #endif /******************************************************************************/ -#ifndef WITH_NOIDREF + #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 soap_pointer_lookup(struct soap *soap, const void *p, int type, struct soap_plist **ppp) -{ register struct soap_plist *pp; +{ struct soap_plist *pp; *ppp = NULL; if (p) { for (pp = soap->pht[soap_hash_ptr(p)]; pp; pp = pp->next) @@ -7038,20 +7804,19 @@ soap_pointer_lookup(struct soap *soap, const void *p, int type, struct soap_plis return 0; } #endif -#endif /******************************************************************************/ -#ifndef WITH_NOIDREF + #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 -soap_pointer_enter(struct soap *soap, const void *p, const struct soap_array *a, int n, int type, struct soap_plist **ppp) -{ register size_t h; - register struct soap_plist *pp; +soap_pointer_enter(struct soap *soap, const void *p, const void *a, int n, int type, struct soap_plist **ppp) +{ size_t h; + struct soap_plist *pp; (void)n; if (!soap->pblk || soap->pidx >= SOAP_PTRBLK) - { register struct soap_pblk *pb = (struct soap_pblk*)SOAP_MALLOC(soap, sizeof(struct soap_pblk)); + { struct soap_pblk *pb = (struct soap_pblk*)SOAP_MALLOC(soap, sizeof(struct soap_pblk)); if (!pb) { soap->error = SOAP_EOM; return 0; @@ -7062,54 +7827,49 @@ soap_pointer_enter(struct soap *soap, const void *p, const struct soap_array *a, } *ppp = pp = &soap->pblk->plist[soap->pidx++]; if (a) - h = soap_hash_ptr(a->__ptr); + h = soap_hash_ptr(a); else h = soap_hash_ptr(p); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Pointer enter location=%p array=%p size=%d dim=%d type=%d id=%d\n", p, a ? a->__ptr : NULL, a ? a->__size : 0, n, type, soap->idnum+1)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Pointer enter location=%p array=%p size=%lu type=%d id=%d\n", p, a, (unsigned long)n, type, soap->idnum+1)); pp->next = soap->pht[h]; pp->type = type; pp->mark1 = 0; pp->mark2 = 0; pp->ptr = p; + pp->dup = NULL; pp->array = a; + pp->size = n; soap->pht[h] = pp; pp->id = ++soap->idnum; return pp->id; } #endif -#endif /******************************************************************************/ -#ifndef WITH_NOIDREF + #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 -soap_array_pointer_lookup(struct soap *soap, const void *p, const struct soap_array *a, int n, int type, struct soap_plist **ppp) -{ register struct soap_plist *pp; +soap_array_pointer_lookup(struct soap *soap, const void *p, const void *a, int n, int type, struct soap_plist **ppp) +{ struct soap_plist *pp; *ppp = NULL; - if (!p || !a->__ptr) + if (!p || !a) return 0; - for (pp = soap->pht[soap_hash_ptr(a->__ptr)]; pp; pp = pp->next) - { if (pp->type == type && pp->array && pp->array->__ptr == a->__ptr) - { register int i; - for (i = 0; i < n; i++) - if (((const int*)&pp->array->__size)[i] != ((const int*)&a->__size)[i]) - break; - if (i == n) - { *ppp = pp; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array lookup location=%p type=%d id=%d\n", a->__ptr, type, pp->id)); - return pp->id; - } + for (pp = soap->pht[soap_hash_ptr(a)]; pp; pp = pp->next) + { if (pp->type == type && pp->array == a && pp->size == n) + { *ppp = pp; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array lookup location=%p type=%d id=%d\n", a, type, pp->id)); + return pp->id; } } - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array lookup location=%p type=%d: not found\n", a->__ptr, type)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array lookup location=%p type=%d: not found\n", a, type)); return 0; } #endif -#endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int @@ -7123,7 +7883,9 @@ soap_begin_count(struct soap *soap) #endif { soap->mode = soap->omode; if ((soap->mode & SOAP_IO_UDP)) - soap->mode |= SOAP_ENC_XML; + { soap->mode |= SOAP_ENC_XML; + soap->mode &= ~SOAP_IO_CHUNK; + } if ((soap->mode & SOAP_IO) == SOAP_IO_STORE || (((soap->mode & SOAP_IO) == SOAP_IO_CHUNK || (soap->mode & SOAP_ENC_XML)) #ifndef WITH_LEANER @@ -7151,7 +7913,7 @@ soap_begin_count(struct soap *soap) soap->mode &= ~SOAP_ENC_MTOM; if (soap->mode & SOAP_ENC_MIME) soap_select_mime_boundary(soap); - soap->dime.list = soap->dime.last; /* keep track of last DIME attachment */ + soap->dime.list = soap->dime.last; /* keep track of last DIME attachment */ #endif soap->count = 0; soap->ns = 0; @@ -7163,12 +7925,14 @@ soap_begin_count(struct soap *soap) soap->event = 0; soap->evlev = 0; soap->idnum = 0; + soap->body = 1; + soap->level = 0; soap_clr_attr(soap); soap_set_local_namespaces(soap); #ifndef WITH_LEANER soap->dime.count = 0; /* count # of attachments */ soap->dime.size = 0; /* accumulate total size of attachments */ - if (soap->fprepareinitsend && (soap->mode & SOAP_IO) != SOAP_IO_STORE && (soap->error = soap->fprepareinitsend(soap))) + if (soap->fprepareinitsend && (soap->mode & SOAP_IO) != SOAP_IO_STORE && (soap->error = soap->fprepareinitsend(soap)) != SOAP_OK) return soap->error; #endif DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Begin count phase (socket=%d mode=0x%x count=%lu)\n", soap->socket, (unsigned int)soap->mode, (unsigned long)soap->count)); @@ -7177,6 +7941,7 @@ soap_begin_count(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int @@ -7185,15 +7950,18 @@ soap_end_count(struct soap *soap) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of count phase\n")); #ifndef WITH_LEANER if ((soap->mode & SOAP_IO_LENGTH)) - { if (soap->fpreparefinalsend && (soap->error = soap->fpreparefinalsend(soap))) + { if (soap->fpreparefinalsend && (soap->error = soap->fpreparefinalsend(soap)) != SOAP_OK) return soap->error; } +#else + (void)soap; #endif return SOAP_OK; } #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int @@ -7203,27 +7971,36 @@ soap_begin_send(struct soap *soap) soap_free_ns(soap); soap->error = SOAP_OK; soap->mode = soap->omode | (soap->mode & (SOAP_IO_LENGTH | SOAP_ENC_DIME)); -#ifdef WITH_ZLIB - if ((soap->mode & SOAP_ENC_ZLIB) && (soap->mode & SOAP_IO) == SOAP_IO_FLUSH) - { if (soap->mode & SOAP_ENC_XML) - soap->mode |= SOAP_IO_BUFFER; - else - soap->mode |= SOAP_IO_STORE; - } -#endif #ifndef WITH_LEAN if ((soap->mode & SOAP_IO_UDP)) { soap->mode |= SOAP_ENC_XML; - if (soap->count > SOAP_BUFLEN) + soap->mode &= ~SOAP_IO_CHUNK; + if (soap->count > sizeof(soap->buf)) return soap->error = SOAP_UDP_ERROR; } #endif - if ((soap->mode & SOAP_IO) == SOAP_IO_FLUSH && soap_valid_socket(soap->socket)) - { if (soap->count || (soap->mode & SOAP_IO_LENGTH) || (soap->mode & SOAP_ENC_XML)) +#ifdef WITH_ZLIB + if ((soap->mode & SOAP_ENC_ZLIB) && (soap->mode & SOAP_IO) == SOAP_IO_FLUSH) + { if (soap->mode & SOAP_ENC_XML) soap->mode |= SOAP_IO_BUFFER; else soap->mode |= SOAP_IO_STORE; } +#endif + if ((soap->mode & SOAP_IO) == SOAP_IO_FLUSH) + { if (soap_valid_socket(soap->socket)) + { if (soap->count || (soap->mode & SOAP_IO_LENGTH) || (soap->mode & SOAP_ENC_XML)) + soap->mode |= SOAP_IO_BUFFER; + else + soap->mode |= SOAP_IO_STORE; + } +#if !defined(__cplusplus) || defined(WITH_COMPAT) + else if (soap->os != NULL) + { *soap->os = NULL; + soap->mode |= SOAP_IO_STORE; + } +#endif + } soap->mode &= ~SOAP_IO_LENGTH; if ((soap->mode & SOAP_IO) == SOAP_IO_STORE) if (soap_new_block(soap) == NULL) @@ -7242,7 +8019,7 @@ soap_begin_send(struct soap *soap) #ifdef WIN32 #ifndef UNDER_CE #ifndef WITH_FASTCGI - if (!soap_valid_socket(soap->socket) && !soap->os) /* Set win32 stdout or soap->sendfd to BINARY, e.g. to support DIME */ + if (!soap_valid_socket(soap->socket) && !soap->os && soap->sendfd >= 0) /* Set win32 stdout or soap->sendfd to BINARY, e.g. to support DIME */ #ifdef __BORLANDC__ setmode(soap->sendfd, _O_BINARY); #else @@ -7263,21 +8040,30 @@ soap_begin_send(struct soap *soap) soap->mustUnderstand = 0; soap->encoding = 0; soap->idnum = 0; + soap->body = 1; soap->level = 0; soap_clr_attr(soap); soap_set_local_namespaces(soap); #ifdef WITH_ZLIB soap->z_ratio_out = 1.0; if ((soap->mode & SOAP_ENC_ZLIB) && soap->zlib_state != SOAP_ZLIB_DEFLATE) - { if (!soap->z_buf) - soap->z_buf = (char*)SOAP_MALLOC(soap, SOAP_BUFLEN); + { if (!soap->d_stream) + { soap->d_stream = (z_stream*)SOAP_MALLOC(soap, sizeof(z_stream)); + soap->d_stream->zalloc = Z_NULL; + soap->d_stream->zfree = Z_NULL; + soap->d_stream->opaque = Z_NULL; + soap->d_stream->next_in = Z_NULL; + } + if (!soap->z_buf) + soap->z_buf = (char*)SOAP_MALLOC(soap, sizeof(soap->buf)); soap->d_stream->next_out = (Byte*)soap->z_buf; - soap->d_stream->avail_out = SOAP_BUFLEN; + soap->d_stream->avail_out = sizeof(soap->buf); #ifdef WITH_GZIP if (soap->zlib_out != SOAP_ZLIB_DEFLATE) - { memcpy(soap->z_buf, "\37\213\10\0\0\0\0\0\0\377", 10); + { if (soap_memcpy((void*)soap->z_buf, sizeof(soap->buf), (const void*)"\37\213\10\0\0\0\0\0\0\377", 10)) + return soap->error = SOAP_EOM; soap->d_stream->next_out = (Byte*)soap->z_buf + 10; - soap->d_stream->avail_out = SOAP_BUFLEN - 10; + soap->d_stream->avail_out = sizeof(soap->buf) - 10; soap->z_crc = crc32(0L, NULL, 0); soap->zlib_out = SOAP_ZLIB_GZIP; if (soap->z_dict) @@ -7304,7 +8090,7 @@ soap_begin_send(struct soap *soap) DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Begin send phase (socket=%d mode=0x%x count=%lu)\n", soap->socket, soap->mode, (unsigned long)soap->count)); soap->part = SOAP_BEGIN; #ifndef WITH_LEANER - if (soap->fprepareinitsend && (soap->mode & SOAP_IO) == SOAP_IO_STORE && (soap->error = soap->fprepareinitsend(soap))) + if (soap->fprepareinitsend && (soap->mode & SOAP_IO) == SOAP_IO_STORE && (soap->error = soap->fprepareinitsend(soap)) != SOAP_OK) return soap->error; #endif return SOAP_OK; @@ -7312,6 +8098,7 @@ soap_begin_send(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_NOIDREF #ifndef PALM_2 SOAP_FMAC1 @@ -7329,6 +8116,7 @@ soap_embedded(struct soap *soap, const void *p, int t) #endif /******************************************************************************/ + #ifndef WITH_NOIDREF #ifndef PALM_2 SOAP_FMAC1 @@ -7353,14 +8141,15 @@ soap_reference(struct soap *soap, const void *p, int t) #endif /******************************************************************************/ + #ifndef WITH_NOIDREF #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 -soap_array_reference(struct soap *soap, const void *p, const struct soap_array *a, int n, int t) +soap_array_reference(struct soap *soap, const void *p, const void *a, int n, int t) { struct soap_plist *pp; - if (!p || !a->__ptr || (!soap->encodingStyle && !(soap->omode & (SOAP_ENC_DIME|SOAP_ENC_MIME|SOAP_ENC_MTOM|SOAP_XML_GRAPH))) || (soap->omode & SOAP_XML_TREE)) + if (!p || !a || (!soap->encodingStyle && !(soap->omode & (SOAP_ENC_DIME|SOAP_ENC_MIME|SOAP_ENC_MTOM|SOAP_XML_GRAPH))) || (soap->omode & SOAP_XML_TREE)) return 1; if (soap_array_pointer_lookup(soap, p, a, n, t, &pp)) { if (pp->mark1 == 0) @@ -7370,13 +8159,14 @@ soap_array_reference(struct soap *soap, const void *p, const struct soap_array * } else if (!soap_pointer_enter(soap, p, a, n, t, &pp)) return 1; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array reference %p ptr=%p dim=%d type=%d (%d %d)\n", p, a->__ptr, n, t, (int)pp->mark1, (int)pp->mark2)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array reference %p ptr=%p n=%lu type=%d (%d %d)\n", p, a, (unsigned long)n, t, (int)pp->mark1, (int)pp->mark2)); return pp->mark1; } #endif #endif /******************************************************************************/ + #ifndef WITH_NOIDREF #ifndef PALM_2 SOAP_FMAC1 @@ -7384,13 +8174,15 @@ int SOAP_FMAC2 soap_embedded_id(struct soap *soap, int id, const void *p, int t) { struct soap_plist *pp = NULL; - if (!id || (!soap->encodingStyle && !(soap->omode & SOAP_XML_GRAPH)) || (soap->omode & SOAP_XML_TREE)) + if (id >= 0 || (!soap->encodingStyle && !(soap->omode & SOAP_XML_GRAPH)) || (soap->omode & SOAP_XML_TREE)) return id; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Embedded_id %p type=%d id=%d\n", p, t, id)); - if (soap->version == 1 && soap->part != SOAP_IN_HEADER) - { if (id < 0) - { id = soap_pointer_lookup(soap, p, t, &pp); - if (id) + if (id < -1) + return soap_embed(soap, p, NULL, 0, t); + if (id < 0) + { id = soap_pointer_lookup(soap, p, t, &pp); + if (soap->version == 1 && soap->part != SOAP_IN_HEADER) + { if (id) { if (soap->mode & SOAP_IO_LENGTH) pp->mark1 = 2; else @@ -7399,18 +8191,13 @@ soap_embedded_id(struct soap *soap, int id, const void *p, int t) } return -1; } - return id; - } - if (id < 0) - id = soap_pointer_lookup(soap, p, t, &pp); - else if (id && !soap_pointer_lookup(soap, p, t, &pp)) - return 0; - if (id && pp) - { if (soap->mode & SOAP_IO_LENGTH) - pp->mark1 = 1; - else - pp->mark2 = 1; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Embedded_id embedded ref id=%d %p type=%d = (%d %d)\n", id, p, t, (int)pp->mark1, (int)pp->mark2)); + else if (id) + { if (soap->mode & SOAP_IO_LENGTH) + pp->mark1 = 1; + else + pp->mark2 = 1; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Embedded_id embedded ref id=%d %p type=%d = (%d %d)\n", id, p, t, (int)pp->mark1, (int)pp->mark2)); + } } return id; } @@ -7418,6 +8205,7 @@ soap_embedded_id(struct soap *soap, int id, const void *p, int t) #endif /******************************************************************************/ + #ifndef WITH_NOIDREF #ifndef PALM_2 SOAP_FMAC1 @@ -7440,6 +8228,7 @@ soap_is_embedded(struct soap *soap, struct soap_plist *pp) #endif /******************************************************************************/ + #ifndef WITH_NOIDREF #ifndef PALM_2 SOAP_FMAC1 @@ -7458,6 +8247,7 @@ soap_is_single(struct soap *soap, struct soap_plist *pp) #endif /******************************************************************************/ + #ifndef WITH_NOIDREF #ifndef PALM_2 SOAP_FMAC1 @@ -7475,18 +8265,17 @@ soap_set_embedded(struct soap *soap, struct soap_plist *pp) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 -soap_attachment(struct soap *soap, const char *tag, int id, const void *p, const struct soap_array *a, const char *aid, const char *atype, const char *aoptions, int n, const char *type, int t) -{ -#ifndef WITH_NOIDREF - struct soap_plist *pp; +soap_attachment(struct soap *soap, const char *tag, int id, const void *p, const void *a, int n, const char *aid, const char *atype, const char *aoptions, const char *type, int t) +{ struct soap_plist *pp; int i; - if (!p || !a->__ptr || (!aid && !atype)) - return soap_element_id(soap, tag, id, p, a, n, type, t); + if (!p || !a || (!aid && !atype)) + return soap_element_id(soap, tag, id, p, a, n, type, t, NULL); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Attachment tag='%s' id='%s' (%d) type='%s'\n", tag, aid ? aid : SOAP_STR_EOS, id, atype ? atype : SOAP_STR_EOS)); i = soap_array_pointer_lookup(soap, p, a, n, t, &pp); if (!i) @@ -7499,12 +8288,7 @@ soap_attachment(struct soap *soap, const char *tag, int id, const void *p, const if (id <= 0) id = i; if (!aid) - { -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), soap->dime_id_format, id); -#else - sprintf(soap->tmpbuf, soap->dime_id_format, id); -#endif + { (SOAP_SNPRINTF(soap->tmpbuf, sizeof(soap->tmpbuf), strlen(soap->dime_id_format) + 20), soap->dime_id_format, id); aid = soap_strdup(soap, soap->tmpbuf); } /* Add MTOM xop:Include element when necessary */ @@ -7521,20 +8305,22 @@ soap_attachment(struct soap *soap, const char *tag, int id, const void *p, const { if (pp->mark1 != 3) { struct soap_multipart *content; if (soap->mode & SOAP_ENC_MTOM) - content = soap_new_multipart(soap, &soap->mime.first, &soap->mime.last, (char*)a->__ptr, a->__size); + content = soap_new_multipart(soap, &soap->mime.first, &soap->mime.last, (char*)a, n); else - content = soap_new_multipart(soap, &soap->dime.first, &soap->dime.last, (char*)a->__ptr, a->__size); + content = soap_new_multipart(soap, &soap->dime.first, &soap->dime.last, (char*)a, n); if (!content) { soap->error = SOAP_EOM; return -1; } if (!strncmp(aid, "cid:", 4)) /* RFC 2111 */ { if (soap->mode & SOAP_ENC_MTOM) - { char *s = (char*)soap_malloc(soap, strlen(aid) - 1); + { size_t l = strlen(aid) - 1; + char *s = (char*)soap_malloc(soap, l); if (s) - { *s = '<'; - strcpy(s + 1, aid + 4); - strcat(s, ">"); + { s[0] = '<'; + soap_strncpy(s + 1, l - 1, aid + 4, l - 3); + s[l - 2] = '>'; + s[l - 1] = '\0'; content->id = s; } } @@ -7551,18 +8337,18 @@ soap_attachment(struct soap *soap, const char *tag, int id, const void *p, const } else pp->mark2 = 3; -#endif return -1; } #endif #endif /******************************************************************************/ + #ifndef WITH_NOIDREF #ifndef PALM_1 static void soap_init_iht(struct soap *soap) -{ register int i; +{ int i; for (i = 0; i < SOAP_IDHASH; i++) soap->iht[i] = NULL; } @@ -7570,13 +8356,14 @@ soap_init_iht(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_NOIDREF #ifndef PALM_1 static void soap_free_iht(struct soap *soap) -{ register int i; - register struct soap_ilist *ip = NULL, *p = NULL; - register struct soap_flist *fp = NULL, *fq = NULL; +{ int i; + struct soap_ilist *ip = NULL, *p = NULL; + struct soap_flist *fp = NULL, *fq = NULL; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free ID hashtable\n")); for (i = 0; i < SOAP_IDHASH; i++) { for (ip = soap->iht[i]; ip; ip = p) @@ -7594,13 +8381,14 @@ soap_free_iht(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_NOIDREF #ifndef PALM_2 SOAP_FMAC1 struct soap_ilist * SOAP_FMAC2 soap_lookup(struct soap *soap, const char *id) -{ register struct soap_ilist *ip = NULL; +{ struct soap_ilist *ip = NULL; for (ip = soap->iht[soap_hash(id)]; ip; ip = ip->next) if (!strcmp(ip->id, id)) return ip; @@ -7610,17 +8398,28 @@ soap_lookup(struct soap *soap, const char *id) #endif /******************************************************************************/ + #ifndef WITH_NOIDREF #ifndef PALM_2 SOAP_FMAC1 struct soap_ilist * SOAP_FMAC2 -soap_enter(struct soap *soap, const char *id) -{ register size_t h; - register struct soap_ilist *ip; - ip = (struct soap_ilist*)SOAP_MALLOC(soap, sizeof(struct soap_ilist) + strlen(id)); +soap_enter(struct soap *soap, const char *id, int t, size_t n) +{ size_t h; + struct soap_ilist *ip; + size_t l = strlen(id); + ip = (struct soap_ilist*)SOAP_MALLOC(soap, sizeof(struct soap_ilist) + l); if (ip) - { strcpy((char*)ip->id, id); + { ip->type = t; + ip->size = n; + ip->ptr = NULL; + ip->spine = NULL; + ip->link = NULL; + ip->copy = NULL; + ip->flist = NULL; + ip->smart = NULL; + ip->shaky = 0; + soap_strcpy((char*)ip->id, l + 1, id); h = soap_hash(id); /* h = (HASH(id) % SOAP_IDHASH) so soap->iht[h] is safe */ ip->next = soap->iht[h]; soap->iht[h] = ip; @@ -7631,14 +8430,13 @@ soap_enter(struct soap *soap, const char *id) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 void* SOAP_FMAC2 soap_malloc(struct soap *soap, size_t n) -{ register char *p; - if (!n) - return (void*)SOAP_NON_NULL; +{ char *p; if (!soap) return SOAP_MALLOC(soap, n); if (soap->fmalloc) @@ -7646,38 +8444,40 @@ soap_malloc(struct soap *soap, size_t n) else { n += sizeof(short); n += (-(long)n) & (sizeof(void*)-1); /* align at 4-, 8- or 16-byte boundary */ - if (!(p = (char*)SOAP_MALLOC(soap, n + sizeof(void*) + sizeof(size_t)))) + p = (char*)SOAP_MALLOC(soap, n + sizeof(void*) + sizeof(size_t)); + if (!p) { soap->error = SOAP_EOM; return NULL; } - /* set the canary to detect corruption */ + /* set a canary word to detect memory overruns and data corruption */ *(unsigned short*)(p + n - sizeof(unsigned short)) = (unsigned short)SOAP_CANARY; /* keep chain of alloced cells for destruction */ *(void**)(p + n) = soap->alist; *(size_t*)(p + n + sizeof(void*)) = n; soap->alist = p + n; } - soap->alloced = 1; return p; } #endif /******************************************************************************/ + #ifdef SOAP_MEM_DEBUG static void soap_init_mht(struct soap *soap) -{ register int i; +{ int i; for (i = 0; i < (int)SOAP_PTRHASH; i++) soap->mht[i] = NULL; } #endif /******************************************************************************/ + #ifdef SOAP_MEM_DEBUG static void soap_free_mht(struct soap *soap) -{ register int i; - register struct soap_mlist *mp, *mq; +{ int i; + struct soap_mlist *mp, *mq; for (i = 0; i < (int)SOAP_PTRHASH; i++) { for (mp = soap->mht[i]; mp; mp = mq) { mq = mp->next; @@ -7691,15 +8491,16 @@ soap_free_mht(struct soap *soap) #endif /******************************************************************************/ + #ifdef SOAP_MEM_DEBUG SOAP_FMAC1 void* SOAP_FMAC2 soap_track_malloc(struct soap *soap, const char *file, int line, size_t size) -{ register void *p = malloc(size); +{ void *p = malloc(size); if (soap) - { register size_t h = soap_hash_ptr(p); - register struct soap_mlist *mp = (struct soap_mlist*)malloc(sizeof(struct soap_mlist)); + { size_t h = soap_hash_ptr(p); + struct soap_mlist *mp = (struct soap_mlist*)malloc(sizeof(struct soap_mlist)); if (soap->fdebug[SOAP_INDEX_TEST]) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "%s(%d): malloc(%lu) = %p\n", file, line, (unsigned long)size, p)); } @@ -7715,38 +8516,44 @@ soap_track_malloc(struct soap *soap, const char *file, int line, size_t size) #endif /******************************************************************************/ + #ifdef SOAP_MEM_DEBUG SOAP_FMAC1 void SOAP_FMAC2 soap_track_free(struct soap *soap, const char *file, int line, void *p) -{ register size_t h = soap_hash_ptr(p); - register struct soap_mlist *mp; - for (mp = soap->mht[h]; mp; mp = mp->next) - if (mp->ptr == p) - break; - if (mp) - { if (mp->live) - { free(p); - if (soap->fdebug[SOAP_INDEX_TEST]) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "%s(%d): free(%p)\n", file, line, p)); +{ if (!soap) + free(p); + else + { size_t h = soap_hash_ptr(p); + struct soap_mlist *mp; + for (mp = soap->mht[h]; mp; mp = mp->next) + if (mp->ptr == p) + break; + if (mp) + { if (mp->live) + { if (soap->fdebug[SOAP_INDEX_TEST]) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "%s(%d): free(%p)\n", file, line, p)); + } + free(p); + mp->live = 0; } - mp->live = 0; + else + fprintf(stderr, "%s(%d): free(%p) double free of pointer malloced at %s(%d)\n", file, line, p, mp->file, mp->line); } else - fprintf(stderr, "%s(%d): free(%p) double free of pointer malloced at %s(%d)\n", file, line, p, mp->file, mp->line); + fprintf(stderr, "%s(%d): free(%p) pointer not malloced\n", file, line, p); } - else - fprintf(stderr, "%s(%d): free(%p) pointer not malloced\n", file, line, p); } #endif /******************************************************************************/ + #ifdef SOAP_MEM_DEBUG static void soap_track_unlink(struct soap *soap, const void *p) -{ register size_t h = soap_hash_ptr(p); - register struct soap_mlist *mp; +{ size_t h = soap_hash_ptr(p); + struct soap_mlist *mp; for (mp = soap->mht[h]; mp; mp = mp->next) if (mp->ptr == p) break; @@ -7756,6 +8563,7 @@ soap_track_unlink(struct soap *soap, const void *p) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 void @@ -7764,8 +8572,8 @@ soap_dealloc(struct soap *soap, void *p) { if (soap_check_state(soap)) return; if (p) - { register char **q; - for (q = (char**)&soap->alist; *q; q = *(char***)q) + { char **q; + for (q = (char**)(void*)&soap->alist; *q; q = *(char***)q) { if (*(unsigned short*)(char*)(*q - sizeof(unsigned short)) != (unsigned short)SOAP_CANARY) { @@ -7788,7 +8596,7 @@ soap_dealloc(struct soap *soap, void *p) soap_delete(soap, p); } else - { register char *q; + { char *q; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free all soap_malloc() data\n")); while (soap->alist) { q = (char*)soap->alist; @@ -7807,7 +8615,7 @@ soap_dealloc(struct soap *soap, void *p) q -= *(size_t*)(q + sizeof(void*)); SOAP_FREE(soap, q); } - /* we must assume these were deallocated: */ + /* assume these were deallocated: */ soap->http_content = NULL; soap->action = NULL; soap->fault = NULL; @@ -7826,19 +8634,20 @@ soap_dealloc(struct soap *soap, void *p) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 void SOAP_FMAC2 soap_delete(struct soap *soap, void *p) -{ register struct soap_clist **cp; +{ struct soap_clist **cp; if (soap_check_state(soap)) return; cp = &soap->clist; if (p) { while (*cp) { if (p == (*cp)->ptr) - { register struct soap_clist *q = *cp; + { struct soap_clist *q = *cp; *cp = q->next; if (q->fdelete(q)) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not dealloc data %p: deletion callback failed for object type %d\n", q->ptr, q->type)); @@ -7855,8 +8664,9 @@ soap_delete(struct soap *soap, void *p) } else { while (*cp) - { register struct soap_clist *q = *cp; + { struct soap_clist *q = *cp; *cp = q->next; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Delete %p type=%d (cp=%p)\n", q->ptr, q->type, q)); if (q->fdelete(q)) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not dealloc data %p: deletion callback failed for object type %d\n", q->ptr, q->type)); #ifdef SOAP_MEM_DEBUG @@ -7866,25 +8676,26 @@ soap_delete(struct soap *soap, void *p) SOAP_FREE(soap, q); } } - soap->fault = NULL; /* this was possibly deallocated */ - soap->header = NULL; /* this was possibly deallocated */ + soap->fault = NULL; /* assume this was deallocated */ + soap->header = NULL; /* assume this was deallocated */ } #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 void SOAP_FMAC2 soap_delegate_deletion(struct soap *soap, struct soap *soap_to) -{ register struct soap_clist *cp; - register char **q; +{ struct soap_clist *cp; + char **q; #ifdef SOAP_MEM_DEBUG - register void *p; - register struct soap_mlist **mp, *mq; + void *p; + struct soap_mlist **mp, *mq; size_t h; #endif - for (q = (char**)&soap->alist; *q; q = *(char***)q) + for (q = (char**)(void*)&soap->alist; *q; q = *(char***)q) { if (*(unsigned short*)(char*)(*q - sizeof(unsigned short)) != (unsigned short)SOAP_CANARY) { @@ -7943,41 +8754,51 @@ soap_delegate_deletion(struct soap *soap, struct soap *soap_to) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 struct soap_clist * SOAP_FMAC2 soap_link(struct soap *soap, void *p, int t, int n, int (*fdelete)(struct soap_clist*)) -{ register struct soap_clist *cp; - if ((cp = (struct soap_clist*)SOAP_MALLOC(soap, sizeof(struct soap_clist)))) - { cp->next = soap->clist; - cp->type = t; - cp->size = n; - cp->ptr = p; - cp->fdelete = fdelete; - soap->clist = cp; +{ struct soap_clist *cp = NULL; + if (soap) + { if (p && n != SOAP_NO_LINK_TO_DELETE) + { cp = (struct soap_clist*)SOAP_MALLOC(soap, sizeof(struct soap_clist)); + if (!cp) + soap->error = SOAP_EOM; + else + { cp->next = soap->clist; + cp->type = t; + cp->size = n; + cp->ptr = p; + cp->fdelete = fdelete; + soap->clist = cp; + } + } + soap->alloced = t; } return cp; } #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 soap_unlink(struct soap *soap, const void *p) -{ register char **q; - register struct soap_clist **cp; +{ char **q; + struct soap_clist **cp; if (soap && p) - { for (q = (char**)&soap->alist; *q; q = *(char***)q) + { for (q = (char**)(void*)&soap->alist; *q; q = *(char***)q) { if (p == (void*)(*q - *(size_t*)(*q + sizeof(void*)))) { *q = **(char***)q; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unlinked data %p\n", p)); #ifdef SOAP_MEM_DEBUG soap_track_unlink(soap, p); #endif - return SOAP_OK; /* found and removed from dealloc chain */ + return SOAP_OK; /* found and removed from dealloc chain */ } } for (cp = &soap->clist; *cp; cp = &(*cp)->next) @@ -7986,7 +8807,7 @@ soap_unlink(struct soap *soap, const void *p) q = (char**)*cp; *cp = (*cp)->next; SOAP_FREE(soap, q); - return SOAP_OK; /* found and removed from dealloc chain */ + return SOAP_OK; /* found and removed from dealloc chain */ } } } @@ -7995,13 +8816,14 @@ soap_unlink(struct soap *soap, const void *p) #endif /******************************************************************************/ + #ifndef WITH_NOIDREF #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 soap_lookup_type(struct soap *soap, const char *id) -{ register struct soap_ilist *ip; +{ struct soap_ilist *ip; if (id && *id) { ip = soap_lookup(soap, id); if (ip) @@ -8016,87 +8838,119 @@ soap_lookup_type(struct soap *soap, const char *id) #endif /******************************************************************************/ + +#ifndef WITH_NOIDREF +#ifndef PALM_1 +SOAP_FMAC1 +short +SOAP_FMAC2 +soap_begin_shaky(struct soap *soap) +{ short f = soap->shaky; + soap->shaky = 1; + return f; +} +#endif +#endif + +/******************************************************************************/ + +#ifndef WITH_NOIDREF +#ifndef PALM_1 +SOAP_FMAC1 +void +SOAP_FMAC2 +soap_end_shaky(struct soap *soap, short f) +{ soap->shaky = f; +} +#endif +#endif + +/******************************************************************************/ + +#ifndef WITH_NOIDREF +static int +soap_is_shaky(struct soap *soap, void *p) +{ (void)p; + if (!soap->blist && !soap->shaky) + return 0; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Shaky %p\n", p)); + return 1; +} +#endif + +/******************************************************************************/ + #ifndef WITH_NOIDREF #ifndef PALM_2 SOAP_FMAC1 void* SOAP_FMAC2 -soap_id_lookup(struct soap *soap, const char *id, void **p, int t, size_t n, unsigned int k) +soap_id_lookup(struct soap *soap, const char *id, void **p, int t, size_t n, unsigned int k, int (*fbase)(int, int)) { struct soap_ilist *ip; - void **q; if (!p || !id || !*id) return p; ip = soap_lookup(soap, id); /* lookup pointer to hash table entry for string id */ if (!ip) - { if (!(ip = soap_enter(soap, id))) /* new hash table entry for string id */ + { ip = soap_enter(soap, id, t, n); /* new hash table entry for string id */ + if (!ip) return NULL; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding first href='%s' type=%d %p (%u bytes)\n", id, t, p, (unsigned int)n)); - ip->type = t; - ip->size = n; - ip->link = p; - ip->copy = NULL; - ip->flist = NULL; - ip->ptr = NULL; - ip->level = k; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding first href='%s' type=%d location=%p (%u bytes) level=%u\n", id, t, p, (unsigned int)n, k)); *p = NULL; - } - else if (ip->ptr) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolved href='%s' type=%d location=%p (%u bytes)\n", id, t, ip->ptr, (unsigned int)n)); - if (ip->type != t) - { strcpy(soap->id, id); - soap->error = SOAP_HREF; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Type incompatibility: href='%s' id-type=%d href-type=%d\n", id, ip->type, t)); - return NULL; - } - while (ip->level < k) - { q = (void**)soap_malloc(soap, sizeof(void*)); - if (!q) + if (k) + { int i; + if (k > SOAP_MAXPTRS) return NULL; - *p = (void*)q; - p = q; - k--; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level...\n")); + ip->spine = (void**)soap_malloc(soap, SOAP_MAXPTRS * sizeof(void*)); + if (!ip->spine) + return NULL; + ip->spine[0] = NULL; + for (i = 1; i < SOAP_MAXPTRS; i++) + ip->spine[i] = &ip->spine[i - 1]; + *p = &ip->spine[k - 1]; + } + else + { ip->link = p; + ip->shaky = soap_is_shaky(soap, (void*)p); } + } + else if (ip->type != t && (!fbase || !fbase(ip->type, t)) && (!fbase || !fbase(t, ip->type) || soap_type_punned(soap, ip))) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Lookup type incompatibility: ref='%s' id-type=%d ref-type=%d\n", id, ip->type, t)); + (void)soap_id_nullify(soap, id); + return NULL; + } + else if (k == 0 && ip->ptr && !ip->shaky) /* when block lists are in use, ip->ptr will change */ + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolved href='%s' type=%d location=%p (%u bytes) level=%u\n", id, t, ip->ptr, (unsigned int)n, k)); *p = ip->ptr; } - else if (ip->level > k) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving level %u pointers to href='%s'\n", ip->level, id)); - while (ip->level > k) - { void *s, **r = &ip->link; - q = (void**)ip->link; - while (q) - { *r = (void*)soap_malloc(soap, sizeof(void*)); - if (!*r) + else + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarded href='%s' type=%d location=%p (%u bytes) level=%u\n", id, t, p, (unsigned int)n, k)); + if (fbase && fbase(t, ip->type) && !soap_type_punned(soap, ip)) + { ip->type = t; + ip->size = n; + } + *p = NULL; + if (k) + { if (!ip->spine) + { int i; + if (k > SOAP_MAXPTRS) + return NULL; + ip->spine = (void**)soap_malloc(soap, SOAP_MAXPTRS * sizeof(void*)); + if (!ip->spine) return NULL; - s = *q; - *q = *r; - r = (void**)*r; - q = (void**)s; + ip->spine[0] = NULL; + for (i = 1; i < SOAP_MAXPTRS; i++) + ip->spine[i] = &ip->spine[i - 1]; } - *r = NULL; - ip->size = n; - ip->copy = NULL; - ip->level = ip->level - 1; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level...\n")); + *p = &ip->spine[k - 1]; + if (ip->ptr && !ip->shaky) + ip->spine[0] = ip->ptr; } - q = (void**)ip->link; - ip->link = p; - *p = (void*)q; - } - else - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarded href='%s' type=%d location=%p (%u bytes)\n", id, t, p, (unsigned int)n)); - while (ip->level < k) - { q = (void**)soap_malloc(soap, sizeof(void*)); - if (!q) - return NULL; + else + { void *q = ip->link; + ip->link = p; + ip->shaky = soap_is_shaky(soap, (void*)p); *p = q; - p = q; - k--; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Descending one level...\n")); } - q = (void**)ip->link; - ip->link = p; - *p = (void*)q; } return p; } @@ -8104,81 +8958,87 @@ soap_id_lookup(struct soap *soap, const char *id, void **p, int t, size_t n, uns #endif /******************************************************************************/ + #ifndef WITH_NOIDREF #ifndef PALM_2 SOAP_FMAC1 void* SOAP_FMAC2 -soap_id_forward(struct soap *soap, const char *href, void *p, size_t len, int st, int tt, size_t n, unsigned int k, void (*fcopy)(struct soap*, int, int, void*, size_t, const void*, size_t)) +soap_id_forward(struct soap *soap, const char *href, void *p, size_t i, int t, int tt, size_t n, unsigned int k, void (*finsert)(struct soap*, int, int, void*, size_t, const void*, void**), int (*fbase)(int, int)) { struct soap_ilist *ip; if (!p || !href || !*href) return p; ip = soap_lookup(soap, href); /* lookup pointer to hash table entry for string id */ if (!ip) - { if (!(ip = soap_enter(soap, href))) /* new hash table entry for string id */ + { ip = soap_enter(soap, href, t, n); /* new hash table entry for string id */ + if (!ip) return NULL; - ip->type = st; - ip->size = n; - ip->link = NULL; - ip->copy = NULL; - ip->ptr = NULL; - ip->level = 0; - ip->flist = NULL; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "New entry href='%s' type=%d size=%lu level=%d location=%p\n", href, st, (unsigned long)n, k, p)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "New entry href='%s' type=%d size=%lu level=%d location=%p\n", href, t, (unsigned long)n, k, p)); } - else if (ip->type != st || (ip->level == k && ip->size != n)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Type incompatibility id='%s' expect type=%d size=%lu level=%u got type=%d size=%lu\n", href, ip->type, (unsigned long)ip->size, k, st, (unsigned long)n)); - strcpy(soap->id, href); - soap->error = SOAP_HREF; + else if ((ip->type != t || ip->size != n) && k == 0) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forward type incompatibility id='%s' expect type=%d size=%lu level=%u got type=%d size=%lu\n", href, ip->type, (unsigned long)ip->size, k, t, (unsigned long)n)); + (void)soap_id_nullify(soap, href); return NULL; } - if (fcopy || n < sizeof(void*) || *href != '#') - { register struct soap_flist *fp = (struct soap_flist*)SOAP_MALLOC(soap, sizeof(struct soap_flist)); + if (finsert || n < sizeof(void*)) + { struct soap_flist *fp = (struct soap_flist*)SOAP_MALLOC(soap, sizeof(struct soap_flist)); if (!fp) { soap->error = SOAP_EOM; return NULL; } + if (fbase && fbase(t, ip->type) && !soap_type_punned(soap, ip)) + { ip->type = t; + ip->size = n; + } + if ((ip->type != t || ip->size != n) && (!fbase || !fbase(ip->type, t))) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forward type incompatibility id='%s' expect type=%d size=%lu level=%u got type=%d size=%lu\n", href, ip->type, (unsigned long)ip->size, k, t, (unsigned long)n)); + SOAP_FREE(soap, fp); + (void)soap_id_nullify(soap, href); + return NULL; + } fp->next = ip->flist; fp->type = tt; fp->ptr = p; fp->level = k; - fp->len = len; - if (fcopy) - fp->fcopy = fcopy; - else - fp->fcopy = soap_fcopy; + fp->index = i; + fp->finsert = finsert; ip->flist = fp; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding type=%d (target type=%d) size=%lu location=%p level=%u len=%lu href='%s'\n", st, tt, (unsigned long)n, p, k, (unsigned long)len, href)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding type=%d (target type=%d) size=%lu location=%p level=%u index=%lu href='%s'\n", t, tt, (unsigned long)n, p, k, (unsigned long)i, href)); } else - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding copying address %p for type=%d href='%s'\n", p, st, href)); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Forwarding copying address %p for type=%d href='%s'\n", p, t, href)); *(void**)p = ip->copy; ip->copy = p; } + ip->shaky = soap_is_shaky(soap, p); return p; } #endif #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 void* SOAP_FMAC2 -soap_id_enter(struct soap *soap, const char *id, void *p, int t, size_t n, unsigned int k, const char *type, const char *arrayType, void *(*finstantiate)(struct soap*, int, const char*, const char*, size_t*)) +soap_id_enter(struct soap *soap, const char *id, void *p, int t, size_t n, const char *type, const char *arrayType, void *(*finstantiate)(struct soap*, int, const char*, const char*, size_t*), int (*fbase)(int, int)) { #ifndef WITH_NOIDREF struct soap_ilist *ip; #endif - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Enter id='%s' type=%d loc=%p size=%lu level=%u\n", id, t, p, (unsigned long)n, k)); + (void)id; (void)fbase; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Enter id='%s' type=%d location=%p size=%lu\n", id, t, p, (unsigned long)n)); soap->alloced = 0; if (!p) { if (finstantiate) - p = finstantiate(soap, t, type, arrayType, &n); + { p = finstantiate(soap, t, type, arrayType, &n); /* soap->alloced is set in soap_link() */ + t = soap->alloced; + } else - p = soap_malloc(soap, n); - if (p) - soap->alloced = 1; + { p = soap_malloc(soap, n); + soap->alloced = t; + } } #ifndef WITH_NOIDREF if (!id || !*id) @@ -8186,36 +9046,48 @@ soap_id_enter(struct soap *soap, const char *id, void *p, int t, size_t n, unsig return p; #ifndef WITH_NOIDREF ip = soap_lookup(soap, id); /* lookup pointer to hash table entry for string id */ - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Lookup entry id='%s for location=%p'\n", id, p)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Lookup entry id='%s' for location=%p type=%d\n", id, p, t)); if (!ip) - { if (!(ip = soap_enter(soap, id))) /* new hash table entry for string id */ + { ip = soap_enter(soap, id, t, n); /* new hash table entry for string id */ + if (!ip) return NULL; - ip->type = t; - ip->link = NULL; - ip->copy = NULL; - ip->flist = NULL; - ip->size = n; ip->ptr = p; - ip->level = k; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "New entry id='%s' type=%d size=%lu level=%u location=%p\n", id, t, (unsigned long)n, k, p)); - } - else if ((ip->type != t || (ip->level == k && ip->size != n)) && (ip->copy || ip->flist)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Type incompatibility id='%s' expect type=%d size=%lu level=%u got type=%d size=%lu\n", id, ip->type, (unsigned long)ip->size, k, t, (unsigned long)n)); - strcpy(soap->id, id); - soap->error = SOAP_HREF; - return NULL; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "New entry id='%s' type=%d size=%lu location=%p\n", id, t, (unsigned long)n, p)); + if (!soap->alloced) + ip->shaky = soap_is_shaky(soap, p); } else if (ip->ptr) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Multiply defined id='%s'\n", id)); - strcpy(soap->id, id); + soap_strcpy(soap->id, sizeof(soap->id), id); soap->error = SOAP_DUPLICATE_ID; return NULL; } + else if ((ip->type != t && (!fbase || !fbase(t, ip->type) || soap_type_punned(soap, ip))) + || (ip->type == t && ip->size != n && soap_type_punned(soap, ip))) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Enter type incompatibility id='%s' expect type=%d size=%lu got type=%d size=%lu\n", id, ip->type, (unsigned long)ip->size, t, (unsigned long)n)); + (void)soap_id_nullify(soap, id); + return NULL; + } else - { ip->size = n; + { ip->type = t; + ip->size = n; ip->ptr = p; - ip->level = k; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Update entry id='%s' type=%d location=%p size=%lu level=%u\n", id, t, p, (unsigned long)n, k)); + if (!soap->alloced) + ip->shaky = soap_is_shaky(soap, p); + if (soap->alloced || !ip->shaky) + { void **q; /* ptr will not change later, so resolve links now */ + if (ip->spine) + ip->spine[0] = p; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Traversing link chain to resolve id='%s' type=%d\n", ip->id, ip->type)); + q = (void**)ip->link; + while (q) + { void *r = *q; + *q = p; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "... link %p -> %p\n", q, p)); + q = (void**)r; + } + ip->link = NULL; + } } return ip->ptr; #endif @@ -8223,18 +9095,75 @@ soap_id_enter(struct soap *soap, const char *id, void *p, int t, size_t n, unsig #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 -void +void** SOAP_FMAC2 -soap_fcopy(struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n) -{ DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Copying data type=%d (target type=%d) %p -> %p (%lu bytes)\n", st, tt, q, p, (unsigned long)n)); - memcpy(p, q, n); - (void)soap; (void)st; (void)tt; (void)len; +soap_id_smart(struct soap *soap, const char *id, int t, size_t n) +{ (void)soap; (void)id; (void)t; (void)n; +#ifndef WITH_NOIDREF + if (id && *id) + { struct soap_ilist *ip = soap_lookup(soap, id); /* lookup pointer to hash table entry for string id */ + if (!ip) + { ip = soap_enter(soap, id, t, n); /* new hash table entry for string id */ + if (!ip) + return NULL; + } + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "New smart shared pointer entry id='%s' type=%d size=%lu smart=%p\n", id, t, (unsigned long)n, ip->smart)); + return &ip->smart; + } +#endif + return NULL; } #endif /******************************************************************************/ + +#ifndef WITH_NOIDREF +#ifndef PALM_2 +static int +soap_type_punned(struct soap *soap, const struct soap_ilist *ip) +{ const struct soap_flist *fp; + (void)soap; + if (ip->ptr || ip->copy) + return 1; + for (fp = ip->flist; fp; fp = fp->next) + if (fp->level == 0) + return 1; + return 0; +} +#endif +#endif + +/******************************************************************************/ + +#ifndef WITH_NOIDREF +#ifndef PALM_2 +SOAP_FMAC1 +int +SOAP_FMAC2 +soap_id_nullify(struct soap *soap, const char *id) +{ int i; + for (i = 0; i < SOAP_IDHASH; i++) + { struct soap_ilist *ip; + for (ip = soap->iht[i]; ip; ip = ip->next) + { void *p, *q; + for (p = ip->link; p; p = q) + { q = *(void**)p; + *(void**)p = NULL; + } + ip->link = NULL; + } + } + soap_strcpy(soap->id, sizeof(soap->id), id); + return soap->error = SOAP_HREF; +} +#endif +#endif + +/******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int @@ -8250,7 +9179,8 @@ soap_end_send(struct soap *soap) soap->dime.list->next = NULL; soap->dime.last = soap->dime.list; } - if (!(err = soap_putdime(soap))) + err = soap_putdime(soap); + if (!err) err = soap_putmime(soap); soap->mime.list = NULL; soap->mime.first = NULL; @@ -8266,6 +9196,7 @@ soap_end_send(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int @@ -8285,20 +9216,20 @@ soap_end_send_flush(struct soap *soap) return soap->error; #endif #ifdef WITH_ZLIB - if (soap->mode & SOAP_ENC_ZLIB) + if ((soap->mode & SOAP_ENC_ZLIB) && soap->d_stream) { int r; soap->d_stream->avail_in = 0; do { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflating remainder\n")); r = deflate(soap->d_stream, Z_FINISH); - if (soap->d_stream->avail_out != SOAP_BUFLEN) - { if (soap_flush_raw(soap, soap->z_buf, SOAP_BUFLEN - soap->d_stream->avail_out)) + if (soap->d_stream->avail_out != sizeof(soap->buf)) + { if (soap_flush_raw(soap, soap->z_buf, sizeof(soap->buf) - soap->d_stream->avail_out)) { soap->zlib_state = SOAP_ZLIB_NONE; deflateEnd(soap->d_stream); return soap->error; } soap->d_stream->next_out = (Byte*)soap->z_buf; - soap->d_stream->avail_out = SOAP_BUFLEN; + soap->d_stream->avail_out = sizeof(soap->buf); } } while (r == Z_OK); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflated total %lu->%lu bytes\n", soap->d_stream->total_in, soap->d_stream->total_out)); @@ -8327,49 +9258,65 @@ soap_end_send_flush(struct soap *soap) } #endif if ((soap->mode & SOAP_IO) == SOAP_IO_STORE) - { char *p; -#ifndef WITH_NOHTTP - if (!(soap->mode & SOAP_ENC_XML)) - { soap->mode--; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Sending buffered message of length %u\n", (unsigned int)soap->blist->size)); - if (soap->status >= SOAP_POST) - soap->error = soap->fpost(soap, soap->endpoint, soap->host, soap->port, soap->path, soap->action, soap->blist->size); - else if (soap->status != SOAP_STOP) - soap->error = soap->fresponse(soap, soap->status, soap->blist->size); - if (soap->error || soap_flush(soap)) - return soap->error; - soap->mode++; + { +#if !defined(__cplusplus) || defined(WITH_COMPAT) + if (soap->os) + { char *b = (char*)soap_push_block(soap, NULL, 1); + if (b) + *soap->os = soap_save_block(soap, NULL, NULL, 0); } + else #endif - for (p = soap_first_block(soap, NULL); p; p = soap_next_block(soap, NULL)) - { DBGMSG(SENT, p, soap_block_size(soap, NULL)); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Send %u bytes to socket=%d/fd=%d\n", (unsigned int)soap_block_size(soap, NULL), soap->socket, soap->sendfd)); - if ((soap->error = soap->fsend(soap, p, soap_block_size(soap, NULL)))) - { soap_end_block(soap, NULL); - return soap->error; + { char *p; +#ifndef WITH_NOHTTP + if (!(soap->mode & SOAP_ENC_XML)) + { soap->mode--; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Sending buffered message of length %u\n", (unsigned int)soap->blist->size)); + if (soap->status >= SOAP_POST) + soap->error = soap->fpost(soap, soap->endpoint, soap->host, soap->port, soap->path, soap->action, soap->blist->size); + else if (soap->status != SOAP_STOP) + soap->error = soap->fresponse(soap, soap->status, soap->blist->size); + if (soap->error || soap_flush(soap)) + return soap->error; + soap->mode++; } +#endif + for (p = soap_first_block(soap, NULL); p; p = soap_next_block(soap, NULL)) + { DBGMSG(SENT, p, soap_block_size(soap, NULL)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Send %u bytes to socket=%d/fd=%d\n", (unsigned int)soap_block_size(soap, NULL), soap->socket, soap->sendfd)); + soap->error = soap->fsend(soap, p, soap_block_size(soap, NULL)); + if (soap->error) + { soap_end_block(soap, NULL); + return soap->error; + } + } + soap_end_block(soap, NULL); } - soap_end_block(soap, NULL); - if (soap->fpreparefinalsend && (soap->error = soap->fpreparefinalsend(soap))) +#ifndef WITH_LEANER + if (soap->fpreparefinalsend && (soap->error = soap->fpreparefinalsend(soap)) != SOAP_OK) return soap->error; +#endif } #ifndef WITH_LEANER else if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) { DBGMSG(SENT, "\r\n0\r\n\r\n", 7); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Send 7 bytes to socket=%d/fd=%d\n", soap->socket, soap->sendfd)); - if ((soap->error = soap->fsend(soap, "\r\n0\r\n\r\n", 7))) + soap->error = soap->fsend(soap, "\r\n0\r\n\r\n", 7); + if (soap->error) return soap->error; } #endif } #ifdef WITH_TCPFIN -#ifdef WITH_OPENSSL - if (!soap->ssl && soap_valid_socket(soap->socket) && !soap->keep_alive && !(soap->omode & SOAP_IO_UDP)) - soap->fshutdownsocket(soap, soap->socket, SOAP_SHUT_WR); /* Send TCP FIN */ -#else - if (soap_valid_socket(soap->socket) && !soap->keep_alive && !(soap->omode & SOAP_IO_UDP)) - soap->fshutdownsocket(soap, soap->socket, SOAP_SHUT_WR); /* Send TCP FIN */ +#if defined(WITH_OPENSSL) || defined(WITH_SYSTEMSSL) + if (!soap->ssl) #endif + if (soap_valid_socket(soap->socket) && !soap->keep_alive && !(soap->omode & SOAP_IO_UDP)) + soap->fshutdownsocket(soap, soap->socket, SOAP_SHUT_WR); /* Send TCP FIN */ +#endif +#if defined(__cplusplus) && !defined(WITH_COMPAT) + if (soap->os) + soap->os->flush(); #endif DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of send phase\n")); soap->omode &= ~SOAP_SEC_WSUID; @@ -8380,6 +9327,7 @@ soap_end_send_flush(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int @@ -8387,8 +9335,9 @@ SOAP_FMAC2 soap_end_recv(struct soap *soap) { soap->part = SOAP_END; #ifndef WITH_LEAN - soap->wsuid = NULL; /* reset before next send */ - soap->c14nexclude = NULL; /* reset before next send */ + soap->wsuid = NULL; /* reset before next send */ + soap->c14nexclude = NULL; /* reset before next send */ + soap->c14ninclude = NULL; /* reset before next send */ #endif #ifndef WITH_LEANER soap->ffilterrecv = NULL; @@ -8403,7 +9352,7 @@ soap_end_recv(struct soap *soap) /* Check if MIME attachments and mime-post-check flag is set, if so call soap_resolve() and return */ if (soap->mode & SOAP_ENC_MIME) { if (soap->mode & SOAP_MIME_POSTCHECK) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Post checking MIME attachments\n")); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Post checking MIME attachments\n")); if (!soap->keep_alive) soap->keep_alive = -1; #ifndef WITH_NOIDREF @@ -8424,39 +9373,39 @@ soap_end_recv(struct soap *soap) soap_resolve_attachment(soap, content); } #endif - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "End of receive message ok\n")); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of receive message ok\n")); #ifdef WITH_ZLIB - if (soap->mode & SOAP_ENC_ZLIB) + if ((soap->mode & SOAP_ENC_ZLIB) && soap->d_stream) { /* Make sure end of compressed content is reached */ while (soap->d_stream->next_out != Z_NULL) if ((int)soap_get1(soap) == EOF) break; soap->mode &= ~SOAP_ENC_ZLIB; - memcpy(soap->buf, soap->z_buf, SOAP_BUFLEN); + soap_memcpy((void*)soap->buf, sizeof(soap->buf), (const void*)soap->z_buf, sizeof(soap->buf)); soap->bufidx = (char*)soap->d_stream->next_in - soap->z_buf; soap->buflen = soap->z_buflen; soap->zlib_state = SOAP_ZLIB_NONE; if (inflateEnd(soap->d_stream) != Z_OK) return soap->error = SOAP_ZLIB_ERROR; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Inflate end ok\n")); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflate end ok\n")); #ifdef WITH_GZIP if (soap->zlib_in == SOAP_ZLIB_GZIP) { soap_wchar c; short i; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Inflate gzip crc check\n")); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflate gzip crc check\n")); for (i = 0; i < 8; i++) { if ((int)(c = soap_get1(soap)) == EOF) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Gzip error: unable to read crc value\n")); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Gzip error: unable to read crc value\n")); return soap->error = SOAP_ZLIB_ERROR; } soap->z_buf[i] = (char)c; } if (soap->z_crc != ((uLong)(unsigned char)soap->z_buf[0] | ((uLong)(unsigned char)soap->z_buf[1] << 8) | ((uLong)(unsigned char)soap->z_buf[2] << 16) | ((uLong)(unsigned char)soap->z_buf[3] << 24))) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Gzip inflate error: crc check failed, message corrupted? (crc32=%lu)\n", (unsigned long)soap->z_crc)); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Gzip inflate error: crc check failed, message corrupted? (crc32=%lu)\n", (unsigned long)soap->z_crc)); return soap->error = SOAP_ZLIB_ERROR; } if (soap->d_stream->total_out != ((uLong)(unsigned char)soap->z_buf[4] | ((uLong)(unsigned char)soap->z_buf[5] << 8) | ((uLong)(unsigned char)soap->z_buf[6] << 16) | ((uLong)(unsigned char)soap->z_buf[7] << 24))) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Gzip inflate error: incorrect message length\n")); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Gzip inflate error: incorrect message length\n")); return soap->error = SOAP_ZLIB_ERROR; } } @@ -8466,7 +9415,7 @@ soap_end_recv(struct soap *soap) #endif if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) while (soap->ahead != EOF && !soap_recv_raw(soap)) - ; + continue; #ifndef WITH_NOIDREF if (soap_resolve(soap)) return soap->error; @@ -8488,13 +9437,14 @@ soap_end_recv(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 void SOAP_FMAC2 soap_free_temp(struct soap *soap) -{ register struct soap_attribute *tp, *tq; - register struct Namespace *ns; +{ struct soap_attribute *tp, *tq; + struct Namespace *ns; soap_free_ns(soap); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free any remaining temp blocks\n")); while (soap->blist) @@ -8533,17 +9483,18 @@ soap_free_temp(struct soap *soap) } #endif #ifndef WITH_NOIDREF - soap_free_pht(soap); soap_free_iht(soap); #endif + soap_free_pht(soap); } #endif /******************************************************************************/ + #ifndef PALM_1 static void soap_free_ns(struct soap *soap) -{ register struct soap_nlist *np, *nq; +{ struct soap_nlist *np, *nq; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Free namespace stack\n")); for (np = soap->nlist; np; np = nq) { nq = np->next; @@ -8554,6 +9505,7 @@ soap_free_ns(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_1 #if !defined(WITH_LEAN) || defined(SOAP_DEBUG) static void @@ -8568,6 +9520,7 @@ soap_init_logs(struct soap *soap) #endif /******************************************************************************/ + #if !defined(WITH_LEAN) || defined(SOAP_DEBUG) SOAP_FMAC1 void @@ -8579,6 +9532,7 @@ soap_open_logfile(struct soap *soap, int i) #endif /******************************************************************************/ + #ifdef SOAP_DEBUG static void soap_close_logfile(struct soap *soap, int i) @@ -8590,6 +9544,7 @@ soap_close_logfile(struct soap *soap, int i) #endif /******************************************************************************/ + #ifdef SOAP_DEBUG SOAP_FMAC1 void @@ -8602,6 +9557,7 @@ soap_close_logfiles(struct soap *soap) #endif /******************************************************************************/ + #ifdef SOAP_DEBUG static void soap_set_logfile(struct soap *soap, int i, const char *logfile) @@ -8611,58 +9567,73 @@ soap_set_logfile(struct soap *soap, int i, const char *logfile) s = soap->logfile[i]; soap->logfile[i] = logfile; if (s) - SOAP_FREE(soap, (void*)s); + SOAP_FREE(soap, s); if (logfile) - if ((t = (char*)SOAP_MALLOC(soap, strlen(logfile) + 1))) - strcpy(t, logfile); + { size_t l = strlen(logfile) + 1; + t = (char*)SOAP_MALLOC(soap, l); + if (t) + soap_memcpy((void*)t, l, (const void*)logfile, l); + } soap->logfile[i] = t; } #endif /******************************************************************************/ + SOAP_FMAC1 void SOAP_FMAC2 soap_set_recv_logfile(struct soap *soap, const char *logfile) { + (void)soap; (void)logfile; #ifdef SOAP_DEBUG soap_set_logfile(soap, SOAP_INDEX_RECV, logfile); #endif } /******************************************************************************/ + SOAP_FMAC1 void SOAP_FMAC2 soap_set_sent_logfile(struct soap *soap, const char *logfile) { + (void)soap; (void)logfile; #ifdef SOAP_DEBUG soap_set_logfile(soap, SOAP_INDEX_SENT, logfile); #endif } /******************************************************************************/ + SOAP_FMAC1 void SOAP_FMAC2 soap_set_test_logfile(struct soap *soap, const char *logfile) { + (void)soap; (void)logfile; #ifdef SOAP_DEBUG soap_set_logfile(soap, SOAP_INDEX_TEST, logfile); #endif } /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 struct soap* SOAP_FMAC2 soap_copy(const struct soap *soap) -{ return soap_copy_context((struct soap*)malloc(sizeof(struct soap)), soap); +{ struct soap *copy = soap_versioning(soap_new)(SOAP_IO_DEFAULT, SOAP_IO_DEFAULT); + if (soap_copy_context(copy, soap) != NULL) + return copy; + soap_free(copy); + return NULL; } #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 struct soap* @@ -8673,13 +9644,9 @@ soap_copy_context(struct soap *copy, const struct soap *soap) if (soap_check_state(soap)) return NULL; if (copy) - { register struct soap_plugin *p = NULL; + { struct soap_plugin *p = NULL; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying context\n")); -#ifdef __cplusplus - *copy = *soap; -#else - memcpy(copy, soap, sizeof(struct soap)); -#endif + soap_memcpy((void*)copy, sizeof(struct soap), (const void*)soap, sizeof(struct soap)); copy->state = SOAP_COPY; copy->error = SOAP_OK; copy->userid = NULL; @@ -8710,15 +9677,7 @@ soap_copy_context(struct soap *copy, const struct soap *soap) copy->local_namespaces = NULL; soap_set_local_namespaces(copy); /* copy content of soap->local_namespaces */ copy->namespaces = soap->namespaces; /* point to shared read-only namespaces table */ -#ifdef WITH_C_LOCALE -# ifdef WIN32 - copy->c_locale = _create_locale(LC_ALL, "C"); -# else - copy->c_locale = duplocale(soap->c_locale); -# endif -#else copy->c_locale = NULL; -#endif #ifdef WITH_OPENSSL copy->bio = NULL; copy->ssl = NULL; @@ -8728,16 +9687,13 @@ soap_copy_context(struct soap *copy, const struct soap *soap) copy->session = NULL; #endif #ifdef WITH_ZLIB - copy->d_stream = (z_stream*)SOAP_MALLOC(copy, sizeof(z_stream)); - copy->d_stream->zalloc = Z_NULL; - copy->d_stream->zfree = Z_NULL; - copy->d_stream->opaque = Z_NULL; + copy->d_stream = NULL; copy->z_buf = NULL; #endif #ifndef WITH_NOIDREF soap_init_iht(copy); - soap_init_pht(copy); #endif + soap_init_pht(copy); copy->header = NULL; copy->fault = NULL; copy->action = NULL; @@ -8750,14 +9706,20 @@ soap_copy_context(struct soap *copy, const struct soap *soap) #endif copy->plugins = NULL; for (p = soap->plugins; p; p = p->next) - { register struct soap_plugin *q = (struct soap_plugin*)SOAP_MALLOC(copy, sizeof(struct soap_plugin)); + { struct soap_plugin *q = (struct soap_plugin*)SOAP_MALLOC(copy, sizeof(struct soap_plugin)); if (!q) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not allocate plugin '%s'\n", p->id)); + soap_end(copy); + soap_done(copy); return NULL; + } DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copying plugin '%s'\n", p->id)); *q = *p; - if (p->fcopy && p->fcopy(copy, q, p)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not copy plugin '%s'\n", p->id)); + if (p->fcopy && (copy->error = p->fcopy(copy, q, p)) != SOAP_OK) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not copy plugin '%s' error = %d\n", p->id, copy->error)); SOAP_FREE(copy, q); + soap_end(copy); + soap_done(copy); return NULL; } q->next = copy->plugins; @@ -8769,6 +9731,7 @@ soap_copy_context(struct soap *copy, const struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 void @@ -8787,10 +9750,20 @@ soap_copy_stream(struct soap *copy, struct soap *soap) copy->recvsk = soap->recvsk; copy->recv_timeout = soap->recv_timeout; copy->send_timeout = soap->send_timeout; -#if defined(__cplusplus) && !defined(WITH_LEAN) + copy->connect_timeout = soap->connect_timeout; + copy->accept_timeout = soap->accept_timeout; + copy->socket_flags = soap->socket_flags; + copy->connect_flags = soap->connect_flags; + copy->bind_flags = soap->bind_flags; + copy->accept_flags = soap->accept_flags; + copy->sndbuf = soap->sndbuf; + copy->rcvbuf = soap->rcvbuf; + copy->linger_time = soap->linger_time; + copy->maxlevel = soap->maxlevel; + copy->maxlength = soap->maxlength; + copy->maxoccurs = soap->maxoccurs; copy->os = soap->os; copy->is = soap->is; -#endif copy->sendfd = soap->sendfd; copy->recvfd = soap->recvfd; copy->bufidx = soap->bufidx; @@ -8810,8 +9783,8 @@ soap_copy_stream(struct soap *copy, struct soap *soap) copy->peerlen = soap->peerlen; copy->ip = soap->ip; copy->port = soap->port; - memcpy(copy->host, soap->host, sizeof(soap->host)); - memcpy(copy->endpoint, soap->endpoint, sizeof(soap->endpoint)); + soap_memcpy((void*)copy->host, sizeof(copy->host), (const void*)soap->host, sizeof(soap->host)); + soap_memcpy((void*)copy->endpoint, sizeof(copy->endpoint), (const void*)soap->endpoint, sizeof(soap->endpoint)); #endif #ifdef WITH_OPENSSL copy->bio = soap->bio; @@ -8821,14 +9794,20 @@ soap_copy_stream(struct soap *copy, struct soap *soap) #ifdef WITH_GNUTLS copy->session = soap->session; #endif +#ifdef WITH_SYSTEMSSL + copy->ctx = soap->ctx; + copy->ssl = soap->ssl; +#endif #ifdef WITH_ZLIB copy->zlib_state = soap->zlib_state; copy->zlib_in = soap->zlib_in; copy->zlib_out = soap->zlib_out; - if (!copy->d_stream) - copy->d_stream = (z_stream*)SOAP_MALLOC(copy, sizeof(z_stream)); - if (copy->d_stream) - memcpy(copy->d_stream, soap->d_stream, sizeof(z_stream)); + if (soap->d_stream && soap->zlib_state != SOAP_ZLIB_NONE) + { if (!copy->d_stream) + copy->d_stream = (z_stream*)SOAP_MALLOC(copy, sizeof(z_stream)); + if (copy->d_stream) + soap_memcpy((void*)copy->d_stream, sizeof(z_stream), (const void*)soap->d_stream, sizeof(z_stream)); + } copy->z_crc = soap->z_crc; copy->z_ratio_in = soap->z_ratio_in; copy->z_ratio_out = soap->z_ratio_out; @@ -8836,32 +9815,32 @@ soap_copy_stream(struct soap *copy, struct soap *soap) copy->z_buflen = soap->z_buflen; copy->z_level = soap->z_level; if (soap->z_buf && soap->zlib_state != SOAP_ZLIB_NONE) - { copy->z_buf = (char*)SOAP_MALLOC(copy, SOAP_BUFLEN); + { copy->z_buf = (char*)SOAP_MALLOC(copy, sizeof(soap->buf)); if (copy->z_buf) - memcpy(copy->z_buf, soap->z_buf, SOAP_BUFLEN); + soap_memcpy((void*)copy->z_buf, sizeof(soap->buf), (const void*)soap->z_buf, sizeof(soap->buf)); } copy->z_dict = soap->z_dict; copy->z_dict_len = soap->z_dict_len; #endif - memcpy(copy->buf, soap->buf, sizeof(soap->buf)); + soap_memcpy((void*)copy->buf, sizeof(copy->buf), (const void*)soap->buf, sizeof(soap->buf)); /* copy XML parser state */ soap_free_ns(copy); soap_set_local_namespaces(copy); copy->version = soap->version; if (soap->nlist && soap->local_namespaces) - { register struct soap_nlist *np = NULL, *nq; + { struct soap_nlist *np = NULL, *nq; /* copy reversed nlist */ for (nq = soap->nlist; nq; nq = nq->next) - { register struct soap_nlist *nr = np; + { struct soap_nlist *nr = np; size_t n = sizeof(struct soap_nlist) + strlen(nq->id); np = (struct soap_nlist*)SOAP_MALLOC(copy, n); if (!np) break; - memcpy(np, nq, n); + soap_memcpy((void*)np, n, (const void*)nq, n); np->next = nr; } while (np) - { register const char *s = np->ns; + { const char *s = np->ns; copy->level = np->level; /* preserve element nesting level */ if (!s && np->index >= 0) { s = soap->local_namespaces[np->index].out; @@ -8875,10 +9854,10 @@ soap_copy_stream(struct soap *copy, struct soap *soap) SOAP_FREE(copy, nq); } } - memcpy(copy->tag, soap->tag, sizeof(copy->tag)); - memcpy(copy->id, soap->id, sizeof(copy->id)); - memcpy(copy->href, soap->href, sizeof(copy->href)); - memcpy(copy->type, soap->type, sizeof(copy->type)); + soap_memcpy((void*)copy->tag, sizeof(copy->tag), (const void*)soap->tag, sizeof(soap->tag)); + soap_memcpy((void*)copy->id, sizeof(copy->id), (const void*)soap->id, sizeof(soap->id)); + soap_memcpy((void*)copy->href, sizeof(copy->href), (const void*)soap->href, sizeof(soap->href)); + soap_memcpy((void*)copy->type, sizeof(copy->type), (const void*)soap->type, sizeof(soap->type)); copy->other = soap->other; copy->root = soap->root; copy->null = soap->null; @@ -8892,11 +9871,11 @@ soap_copy_stream(struct soap *copy, struct soap *soap) { struct soap_attribute *tr = tp; size_t n = sizeof(struct soap_attribute) + strlen(tq->name); tp = (struct soap_attribute*)SOAP_MALLOC(copy, n); - memcpy(tp, tq, n); + soap_memcpy((void*)tp, n, (const void*)tq, n); if (tp->size) { tp->value = (char*)SOAP_MALLOC(copy, tp->size); if (tp->value) - strcpy(tp->value, tq->value); + soap_memcpy((void*)tp->value, tp->size, (const void*)tq->value, tp->size); } tp->ns = NULL; tp->next = tr; @@ -8906,6 +9885,7 @@ soap_copy_stream(struct soap *copy, struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 void @@ -8927,6 +9907,10 @@ soap_free_stream(struct soap *soap) soap->dh_params = NULL; soap->rsa_params = NULL; #endif +#ifdef WITH_SYSTEMSSL + soap->ctx = (gsk_handle)NULL; + soap->ssl = (gsk_handle)NULL; +#endif #ifdef WITH_ZLIB if (soap->z_buf) SOAP_FREE(soap, soap->z_buf); @@ -8936,6 +9920,7 @@ soap_free_stream(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 void @@ -8946,6 +9931,7 @@ soap_initialize(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 void @@ -8971,9 +9957,9 @@ soap_versioning(soap_init)(struct soap *soap, soap_mode imode, soap_mode omode) #endif #endif soap->version = 0; - soap_mode(soap, imode); - soap_imode(soap, imode); - soap_omode(soap, omode); + soap->imode = imode; + soap->omode = omode; + soap->mode = imode; soap->plugins = NULL; soap->user = NULL; for (i = 0; i < sizeof(soap->data)/sizeof(*soap->data); i++) @@ -9028,6 +10014,8 @@ soap_versioning(soap_init)(struct soap *soap, soap_mode imode, soap_mode omode) soap->fplugin = fplugin; soap->fmalloc = NULL; #ifndef WITH_LEANER + soap->fsvalidate = NULL; + soap->fwvalidate = NULL; soap->feltbegin = NULL; soap->feltendin = NULL; soap->feltbegout = NULL; @@ -9055,7 +10043,27 @@ soap_versioning(soap_init)(struct soap *soap, soap_mode imode, soap_mode omode) #endif soap->float_format = "%.9G"; /* Alternative: use "%G" */ soap->double_format = "%.17lG"; /* Alternative: use "%lG" */ - soap->dime_id_format = "cid:id%d"; /* default DIME id format */ + soap->long_double_format = NULL; /* Defined in custom serializer custom/long_double.c */ + soap->dime_id_format = "cid:id%d"; /* default DIME id format for int id index */ + soap->recv_timeout = 0; + soap->send_timeout = 0; + soap->connect_timeout = 0; + soap->accept_timeout = 0; + soap->socket_flags = 0; + soap->connect_flags = 0; + soap->bind_flags = 0; + soap->accept_flags = 0; +#ifdef WIN32 + soap->sndbuf = SOAP_BUFLEN + 1; /* this size speeds up windows xfer */ + soap->rcvbuf = SOAP_BUFLEN + 1; +#else + soap->sndbuf = SOAP_BUFLEN; + soap->rcvbuf = SOAP_BUFLEN; +#endif + soap->linger_time = 0; + soap->maxlevel = SOAP_MAXLEVEL; + soap->maxlength = SOAP_MAXLENGTH; + soap->maxoccurs = SOAP_MAXOCCURS; soap->http_version = "1.1"; soap->proxy_http_version = "1.0"; soap->http_content = NULL; @@ -9067,15 +10075,6 @@ soap_versioning(soap_init)(struct soap *soap, soap_mode imode, soap_mode omode) soap->tcp_keep_intvl = 0; soap->tcp_keep_cnt = 0; soap->max_keep_alive = SOAP_MAXKEEPALIVE; - soap->recv_timeout = 0; - soap->send_timeout = 0; - soap->connect_timeout = 0; - soap->accept_timeout = 0; - soap->socket_flags = 0; - soap->connect_flags = 0; - soap->bind_flags = 0; - soap->accept_flags = 0; - soap->linger_time = 0; soap->ip = 0; soap->labbuf = NULL; soap->lablen = 0; @@ -9091,6 +10090,7 @@ soap_versioning(soap_init)(struct soap *soap, soap_mode imode, soap_mode omode) soap->blist = NULL; soap->clist = NULL; soap->alist = NULL; + soap->shaky = 0; soap->attributes = NULL; soap->header = NULL; soap->fault = NULL; @@ -9120,21 +10120,19 @@ soap_versioning(soap_init)(struct soap *soap, soap_mode imode, soap_mode omode) soap->sendfd = stdout; #endif soap->host[0] = '\0'; + soap->path[0] = '\0'; soap->port = 0; soap->action = NULL; soap->proxy_host = NULL; soap->proxy_port = 8080; soap->proxy_userid = NULL; soap->proxy_passwd = NULL; - soap->prolog = NULL; + soap->prolog = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; #ifdef WITH_ZLIB soap->zlib_state = SOAP_ZLIB_NONE; soap->zlib_in = SOAP_ZLIB_NONE; soap->zlib_out = SOAP_ZLIB_NONE; - soap->d_stream = (z_stream*)SOAP_MALLOC(soap, sizeof(z_stream)); - soap->d_stream->zalloc = Z_NULL; - soap->d_stream->zfree = Z_NULL; - soap->d_stream->opaque = Z_NULL; + soap->d_stream = NULL; soap->z_buf = NULL; soap->z_level = 6; soap->z_dict = NULL; @@ -9143,6 +10141,7 @@ soap_versioning(soap_init)(struct soap *soap, soap_mode imode, soap_mode omode) #ifndef WITH_LEAN soap->wsuid = NULL; soap->c14nexclude = NULL; + soap->c14ninclude = NULL; soap->cookies = NULL; soap->cookie_domain = NULL; soap->cookie_path = NULL; @@ -9156,13 +10155,13 @@ soap_versioning(soap_init)(struct soap *soap, soap_mode imode, soap_mode omode) #endif #ifndef WITH_NOIDREF soap_init_iht(soap); - soap_init_pht(soap); #endif + soap_init_pht(soap); #ifdef WITH_OPENSSL if (!soap_ssl_init_done) soap_ssl_init(); soap->fsslauth = ssl_auth_init; - soap->fsslverify = ssl_verify_callback; + soap->fsslverify = NULL; soap->bio = NULL; soap->ssl = NULL; soap->ctx = NULL; @@ -9196,15 +10195,24 @@ soap_versioning(soap_init)(struct soap *soap, soap_mode imode, soap_mode omode) soap->dh_params = NULL; soap->rsa_params = NULL; #endif -#ifdef WITH_C_LOCALE -# ifdef WIN32 - soap->c_locale = _create_locale(LC_ALL, "C"); -# else - soap->c_locale = newlocale(LC_ALL_MASK, "C", NULL); -# endif -#else - soap->c_locale = NULL; +#ifdef WITH_SYSTEMSSL + soap->fsslauth = ssl_auth_init; + soap->fsslverify = NULL; + soap->bio = NULL; + soap->ssl = (gsk_handle)NULL; + soap->ctx = (gsk_handle)NULL; + soap->session = NULL; + soap->ssl_flags = SOAP_SSL_DEFAULT; + soap->keyfile = NULL; + soap->keyid = NULL; + soap->password = NULL; + soap->cafile = NULL; + soap->capath = NULL; + soap->crlfile = NULL; + soap->dhfile = NULL; + soap->randfile = NULL; #endif + soap->c_locale = NULL; soap->buflen = 0; soap->bufidx = 0; #ifndef WITH_LEANER @@ -9233,12 +10241,15 @@ soap_versioning(soap_init)(struct soap *soap, soap_mode imode, soap_mode omode) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 void SOAP_FMAC2 soap_begin(struct soap *soap) -{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Reinitializing context\n")); +{ if (soap_check_state(soap)) + return; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Reinitializing context\n")); if (!soap->keep_alive) { soap->buflen = 0; soap->bufidx = 0; @@ -9252,7 +10263,6 @@ soap_begin(struct soap *soap) soap->part = SOAP_END; soap->event = 0; soap->evlev = 0; - soap->alloced = 0; soap->count = 0; soap->length = 0; soap->cdata = 0; @@ -9272,6 +10282,7 @@ soap_begin(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 void @@ -9282,7 +10293,7 @@ soap_end(struct soap *soap) soap_free_temp(soap); soap_dealloc(soap, NULL); while (soap->clist) - { register struct soap_clist *cp = soap->clist->next; + { struct soap_clist *cp = soap->clist->next; SOAP_FREE(soap, soap->clist); soap->clist = cp; } @@ -9297,13 +10308,14 @@ soap_end(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 void SOAP_FMAC2 soap_set_version(struct soap *soap, short version) { soap_set_local_namespaces(soap); - if (soap->version != version) + if (soap->version != version && soap->local_namespaces && soap->local_namespaces[0].id && soap->local_namespaces[1].id) { if (version == 1) { soap->local_namespaces[0].ns = soap_env1; soap->local_namespaces[1].ns = soap_enc1; @@ -9314,18 +10326,55 @@ soap_set_version(struct soap *soap, short version) } soap->version = version; } + if (version == 0) + soap->encodingStyle = SOAP_STR_EOS; + else + soap->encodingStyle = NULL; } #endif /******************************************************************************/ + +#ifndef PALM_1 +SOAP_FMAC1 +void +SOAP_FMAC2 +soap_get_version(struct soap *soap) +{ struct Namespace *p = soap->local_namespaces; + if (p) + { const char *ns = p[0].out; + if (!ns) + ns = p[0].ns; + if (!strcmp(ns, soap_env1)) + { soap->version = 1; /* make sure we use SOAP 1.1 */ + if (p[1].out) + SOAP_FREE(soap, p[1].out); + p[1].out = (char*)SOAP_MALLOC(soap, sizeof(soap_enc1)); + if (p[1].out) + soap_strncpy(p[1].out, sizeof(soap_enc1), soap_enc1, sizeof(soap_enc1) - 1); + } + else if (!strcmp(ns, soap_env2)) + { soap->version = 2; /* make sure we use SOAP 1.2 */ + if (p[1].out) + SOAP_FREE(soap, p[1].out); + p[1].out = (char*)SOAP_MALLOC(soap, sizeof(soap_enc2)); + if (p[1].out) + soap_strncpy(p[1].out, sizeof(soap_enc2), soap_enc2, sizeof(soap_enc2) - 1); + } + } +} +#endif + +/******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 soap_set_namespaces(struct soap *soap, const struct Namespace *p) -{ register struct Namespace *ns = soap->local_namespaces; - register struct soap_nlist *np, *nq, *nr; - register unsigned int level = soap->level; +{ struct Namespace *ns = soap->local_namespaces; + struct soap_nlist *np, *nq, *nr; + unsigned int level = soap->level; soap->namespaces = p; soap->local_namespaces = NULL; soap_set_local_namespaces(soap); @@ -9344,7 +10393,7 @@ soap_set_namespaces(struct soap *soap, const struct Namespace *p) } /* then push on new stack */ while (np) - { register const char *s; + { const char *s; soap->level = np->level; /* preserve element nesting level */ s = np->ns; if (!s && np->index >= 0 && ns) @@ -9359,7 +10408,7 @@ soap_set_namespaces(struct soap *soap, const struct Namespace *p) SOAP_FREE(soap, nq); } if (ns) - { register int i; + { int i; for (i = 0; ns[i].id; i++) { if (ns[i].out) { SOAP_FREE(soap, ns[i].out); @@ -9374,21 +10423,22 @@ soap_set_namespaces(struct soap *soap, const struct Namespace *p) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 void SOAP_FMAC2 soap_set_local_namespaces(struct soap *soap) { if (soap->namespaces && !soap->local_namespaces) - { register const struct Namespace *ns1; - register struct Namespace *ns2; - register size_t n = 1; + { const struct Namespace *ns1; + struct Namespace *ns2; + size_t n = 1; for (ns1 = soap->namespaces; ns1->id; ns1++) n++; n *= sizeof(struct Namespace); ns2 = (struct Namespace*)SOAP_MALLOC(soap, n); if (ns2) - { memcpy(ns2, soap->namespaces, n); + { soap_memcpy((void*)ns2, n, (const void*)soap->namespaces, n); if (ns2[0].ns) { if (!strcmp(ns2[0].ns, soap_env1)) soap->version = 1; @@ -9404,18 +10454,19 @@ soap_set_local_namespaces(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_LEAN #ifndef PALM_1 SOAP_FMAC1 const char * SOAP_FMAC2 soap_tagsearch(const char *big, const char *little) -{ if (little) - { register size_t n = strlen(little); - register const char *s = big; +{ if (big && little) + { size_t n = strlen(little); + const char *s = big; while (s) - { register const char *t = s; - register size_t i; + { const char *t = s; + size_t i; for (i = 0; i < n; i++, t++) { if (*t != little[i]) break; @@ -9435,27 +10486,26 @@ soap_tagsearch(const char *big, const char *little) #endif /******************************************************************************/ -#ifndef WITH_LEAN + #ifndef PALM_1 SOAP_FMAC1 struct soap_nlist * SOAP_FMAC2 soap_lookup_ns(struct soap *soap, const char *tag, size_t n) -{ register struct soap_nlist *np; +{ struct soap_nlist *np; for (np = soap->nlist; np; np = np->next) - { if (!strncmp(np->id, tag, n) && !np->id[n]) + if (!strncmp(np->id, tag, n) && !np->id[n]) return np; - } return NULL; } #endif -#endif /******************************************************************************/ + #ifndef WITH_LEAN static struct soap_nlist * soap_push_ns(struct soap *soap, const char *id, const char *ns, short utilized) -{ register struct soap_nlist *np; +{ struct soap_nlist *np; size_t n, k; if (soap_tagsearch(soap->c14nexclude, id)) return NULL; @@ -9484,9 +10534,11 @@ soap_push_ns(struct soap *soap, const char *id, const char *ns, short utilized) } np->next = soap->nlist; soap->nlist = np; - strcpy((char*)np->id, id); + soap_strcpy((char*)np->id, n + 1, id); if (ns) - np->ns = strcpy((char*)np->id + n + 1, ns); + { np->ns = np->id + n + 1; + soap_strcpy((char*)np->ns, k + 1, ns); + } else np->ns = NULL; np->level = soap->level; @@ -9496,32 +10548,34 @@ soap_push_ns(struct soap *soap, const char *id, const char *ns, short utilized) #endif /******************************************************************************/ + #ifndef WITH_LEAN static void soap_utilize_ns(struct soap *soap, const char *tag) -{ register struct soap_nlist *np; +{ struct soap_nlist *np; size_t n = 0; const char *t = strchr(tag, ':'); if (t) - { n = t - tag; - if (n >= sizeof(soap->tmpbuf)) - n = sizeof(soap->tmpbuf) - 1; - } + n = t - tag; np = soap_lookup_ns(soap, tag, n); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Utilizing namespace of '%s'\n", tag)); if (np) { if (np->index <= 0) - soap_push_ns(soap, np->id, np->ns, 1); + { if (np->level == soap->level) + np->index = 1; + else + soap_push_ns(soap, np->id, np->ns, 1); + } } - else if (strncmp(tag, "xml", 3)) - { strncpy(soap->tmpbuf, tag, n); - soap->tmpbuf[n] = '\0'; + else if (n && strncmp(tag, "xml", 3)) + { soap_strncpy(soap->tmpbuf, sizeof(soap->tmpbuf), tag, n); soap_push_ns(soap, soap->tmpbuf, NULL, 1); } } #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -9529,13 +10583,15 @@ SOAP_FMAC2 soap_element(struct soap *soap, const char *tag, int id, const char *type) { #ifndef WITH_LEAN - register const char *s; + const char *s; #endif DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Element begin tag='%s' level='%u' id='%d' type='%s'\n", tag, soap->level, id, type ? type : SOAP_STR_EOS)); soap->level++; + if (soap->level > soap->maxlevel) + return soap->error = SOAP_LEVEL; #ifdef WITH_DOM #ifndef WITH_LEAN - if (soap->wsuid && soap_tagsearch(soap->wsuid, tag)) + if (soap_tagsearch(soap->wsuid, tag)) { size_t i; for (s = tag, i = 0; *s && i < sizeof(soap->tag) - 1; s++, i++) soap->tag[i] = *s == ':' ? '-' : *s; @@ -9547,12 +10603,13 @@ soap_element(struct soap *soap, const char *tag, int id, const char *type) { if (soap->evlev >= soap->level) soap->evlev = 0; if (soap->event == SOAP_SEC_BEGIN && !soap->evlev) - { register struct soap_nlist *np; + { struct soap_nlist *np; /* non-nested wsu:Id found: clear xmlns, re-emit them for exc-c14n */ for (np = soap->nlist; np; np = np->next) - { if (np->index == 2) + { int p = soap_tagsearch(soap->c14ninclude, np->id) != NULL; + if (np->index == 2 || p) { struct soap_nlist *np1 = soap_push_ns(soap, np->id, np->ns, 1); - if (np1) + if (np1 && !p) np1->index = 0; } } @@ -9561,22 +10618,22 @@ soap_element(struct soap *soap, const char *tag, int id, const char *type) } #endif if (soap->mode & SOAP_XML_DOM) - { register struct soap_dom_element *elt = (struct soap_dom_element*)soap_malloc(soap, sizeof(struct soap_dom_element)); + { struct soap_dom_element *elt = (struct soap_dom_element*)soap_malloc(soap, sizeof(struct soap_dom_element)); if (!elt) return soap->error; elt->soap = soap; elt->next = NULL; elt->prnt = soap->dom; - elt->name = soap_strdup(soap, tag); elt->elts = NULL; elt->atts = NULL; elt->nstr = NULL; - elt->data = NULL; - elt->wide = NULL; + elt->name = soap_strdup(soap, tag); + elt->lead = NULL; + elt->text = NULL; + elt->code = NULL; + elt->tail = NULL; elt->node = NULL; elt->type = 0; - elt->head = NULL; - elt->tail = NULL; if (soap->dom) { struct soap_dom_element *p = soap->dom->elts; if (p) @@ -9594,8 +10651,7 @@ soap_element(struct soap *soap, const char *tag, int id, const char *type) #endif #ifndef WITH_LEAN if (!soap->ns) - { if (!(soap->mode & SOAP_XML_CANONICAL) - && soap_send(soap, soap->prolog ? soap->prolog : "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")) + { if (!(soap->mode & SOAP_XML_CANONICAL) && soap_send(soap, soap->prolog)) return soap->error; } else if (soap->mode & SOAP_XML_INDENT) @@ -9603,22 +10659,34 @@ soap_element(struct soap *soap, const char *tag, int id, const char *type) return soap->error; soap->body = 1; } - if ((soap->mode & SOAP_XML_DEFAULTNS) && (s = strchr(tag, ':'))) + if ((soap->mode & SOAP_XML_DEFAULTNS)) { struct Namespace *ns = soap->local_namespaces; - size_t n = s - tag; + size_t n = 0; + s = strchr(tag, ':'); + if (s) + n = s++ - tag; + else + s = tag; if (soap_send_raw(soap, "<", 1) - || soap_send(soap, s + 1)) + || soap_send(soap, s)) return soap->error; - if (soap->nlist && !strncmp(soap->nlist->id, tag, n) && !soap->nlist->id[n]) - ns = NULL; - for (; ns && ns->id; ns++) - { if (*ns->id && (ns->out || ns->ns) && !strncmp(ns->id, tag, n) && !ns->id[n]) - { soap_push_ns(soap, ns->id, ns->out ? ns->out : ns->ns, 0); - if (soap_attribute(soap, "xmlns", ns->out ? ns->out : ns->ns)) - return soap->error; - break; + if (n) + { if (soap->nlist && !strncmp(soap->nlist->id, tag, n) && !soap->nlist->id[n]) + ns = NULL; + for (; ns && ns->id; ns++) + { if (*ns->id && ns->ns && !strncmp(ns->id, tag, n) && !ns->id[n]) + { soap_push_ns(soap, ns->id, ns->out ? ns->out : ns->ns, 0); + if (soap_attribute(soap, "xmlns", ns->out ? ns->out : ns->ns)) + return soap->error; + break; + } } } + else if (!soap->nlist || *soap->nlist->id) + { soap_push_ns(soap, "", "", 0); + if (soap_attribute(soap, "xmlns", "")) + return soap->error; + } } else #endif @@ -9646,14 +10714,12 @@ soap_element(struct soap *soap, const char *tag, int id, const char *type) } #endif while (k-- && ns->id) - { if (*ns->id && (ns->out || ns->ns)) - { -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), "xmlns:%s", ns->id); -#else - sprintf(soap->tmpbuf, "xmlns:%s", ns->id); -#endif - if (soap_attribute(soap, soap->tmpbuf, ns->out ? ns->out : ns->ns)) + { const char *t = ns->out; + if (!t) + t = ns->ns; + if (*ns->id && t && *t) + { (SOAP_SNPRINTF(soap->tmpbuf, sizeof(soap->tmpbuf), strlen(ns->id) + 6), "xmlns:%s", ns->id); + if (soap_attribute(soap, soap->tmpbuf, t)) return soap->error; } ns++; @@ -9662,16 +10728,11 @@ soap_element(struct soap *soap, const char *tag, int id, const char *type) } soap->ns = 1; /* namespace table control: ns = 0 or 2 to start, then 1 to stop dumping the table */ #ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) + if ((soap->mode & SOAP_XML_CANONICAL)) soap_utilize_ns(soap, tag); #endif if (id > 0) - { -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), "_%d", id); -#else - sprintf(soap->tmpbuf, "_%d", id); -#endif + { (SOAP_SNPRINTF(soap->tmpbuf, sizeof(soap->tmpbuf), sizeof(SOAP_BASEREFNAME) + 20), SOAP_BASEREFNAME "%d", id); if (soap->version == 2) { if (soap_attribute(soap, "SOAP-ENC:id", soap->tmpbuf)) return soap->error; @@ -9679,41 +10740,30 @@ soap_element(struct soap *soap, const char *tag, int id, const char *type) else if (soap_attribute(soap, "id", soap->tmpbuf)) return soap->error; } - if (type && *type && !(soap->mode & SOAP_XML_NOTYPE) && soap->part != SOAP_IN_HEADER) + if (type && *type && !(soap->mode & SOAP_XML_NOTYPE)) { const char *t = type; #ifndef WITH_LEAN - if (soap->mode & SOAP_XML_DEFAULTNS) + if ((soap->mode & SOAP_XML_DEFAULTNS)) { t = strchr(type, ':'); if (t) t++; else t = type; } + else if ((soap->mode & SOAP_XML_CANONICAL)) + soap_utilize_ns(soap, type); #endif if (soap->attributes ? soap_set_attr(soap, "xsi:type", t, 1) : soap_attribute(soap, "xsi:type", t)) return soap->error; -#ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) - soap_utilize_ns(soap, type); -#endif } - if (soap->null && soap->position > 0) - { register int i; -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf) - 1, "[%d", soap->positions[0]); -#else - sprintf(soap->tmpbuf, "[%d", soap->positions[0]); -#endif + if (soap->null && soap->position > 0 && soap->version == 1) + { int i; + (SOAP_SNPRINTF(soap->tmpbuf, sizeof(soap->tmpbuf) - 1, 20), "[%d", soap->positions[0]); for (i = 1; i < soap->position; i++) - { register size_t l = strlen(soap->tmpbuf); -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf + l, sizeof(soap->tmpbuf)-l-1, ",%d", soap->positions[i]); -#else - if (l + 13 < sizeof(soap->tmpbuf)) - sprintf(soap->tmpbuf + l, ",%d", soap->positions[i]); -#endif + { size_t l = strlen(soap->tmpbuf); + (SOAP_SNPRINTF(soap->tmpbuf + l, sizeof(soap->tmpbuf) - l - 1, 20), ",%d", soap->positions[i]); } - strcat(soap->tmpbuf, "]"); + soap_strncat(soap->tmpbuf, sizeof(soap->tmpbuf), "]", 1); if (soap_attribute(soap, "SOAP-ENC:position", soap->tmpbuf)) return soap->error; } @@ -9750,6 +10800,7 @@ soap_element(struct soap *soap, const char *tag, int id, const char *type) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -9772,13 +10823,14 @@ soap_element_begin_out(struct soap *soap, const char *tag, int id, const char *t #endif /******************************************************************************/ + #ifndef PALM_2 #ifndef HAVE_STRRCHR SOAP_FMAC1 char* SOAP_FMAC2 soap_strrchr(const char *s, int t) -{ register char *r = NULL; +{ char *r = NULL; while (*s) if (*s++ == t) r = (char*)s - 1; @@ -9788,14 +10840,15 @@ soap_strrchr(const char *s, int t) #endif /******************************************************************************/ + #ifndef PALM_2 #ifndef HAVE_STRTOL SOAP_FMAC1 long SOAP_FMAC2 soap_strtol(const char *s, char **t, int b) -{ register long n = 0; - register int c; +{ long n = 0; + int c; while (*s > 0 && *s <= 32) s++; if (b == 10) @@ -9808,7 +10861,13 @@ soap_strtol(const char *s, char **t, int b) s++; while ((c = *s) && c >= '0' && c <= '9') { if (n >= 214748364 && (n > 214748364 || c >= '8')) + { if (neg && n == 214748364 && c == '8') + { if (t) + *t = (char*)(s + 1); + return -2147483648; + } break; + } n *= 10; n += c - '0'; s++; @@ -9839,6 +10898,7 @@ soap_strtol(const char *s, char **t, int b) #endif /******************************************************************************/ + #ifndef PALM_2 #ifndef HAVE_STRTOUL SOAP_FMAC1 @@ -9846,11 +10906,16 @@ unsigned long SOAP_FMAC2 soap_strtoul(const char *s, char **t, int b) { unsigned long n = 0; - register int c; + int c; while (*s > 0 && *s <= 32) s++; if (b == 10) - { if (*s == '+') + { short neg = 0; + if (*s == '-') + { s++; + neg = 1; + } + else if (*s == '+') s++; while ((c = *s) && c >= '0' && c <= '9') { if (n >= 429496729 && (n > 429496729 || c >= '6')) @@ -9859,6 +10924,8 @@ soap_strtoul(const char *s, char **t, int b) n += c - '0'; s++; } + if (neg && n > 0) + s--; } else /* b == 16 */ { while ((c = *s)) @@ -9883,39 +10950,38 @@ soap_strtoul(const char *s, char **t, int b) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 soap_array_begin_out(struct soap *soap, const char *tag, int id, const char *type, const char *offset) -{ if (!type || !*type) +{ if (!type || !*type || soap->version == 0) return soap_element_begin_out(soap, tag, id, NULL); - if (soap_element(soap, tag, id, "SOAP-ENC:Array")) + if (soap_element(soap, tag, id, NULL)) return soap->error; - if (soap->version == 2) + if (soap->version == 1) + { if (offset && soap_attribute(soap, "SOAP-ENC:offset", offset)) + return soap->error; + if (soap_attribute(soap, "SOAP-ENC:arrayType", type)) + return soap->error; + } + else { const char *s; s = soap_strrchr(type, '['); if (s && (size_t)(s - type) < sizeof(soap->tmpbuf)) - { strncpy(soap->tmpbuf, type, s - type); - soap->tmpbuf[s - type] = '\0'; + { soap_strncpy(soap->tmpbuf, sizeof(soap->tmpbuf), type, s - type); if (soap_attribute(soap, "SOAP-ENC:itemType", soap->tmpbuf)) return soap->error; s++; if (*s) - { strncpy(soap->tmpbuf, s, sizeof(soap->tmpbuf)); - soap->tmpbuf[sizeof(soap->tmpbuf) - 1] = '\0'; + { soap_strcpy(soap->tmpbuf, sizeof(soap->tmpbuf), s); soap->tmpbuf[strlen(soap->tmpbuf) - 1] = '\0'; if (soap_attribute(soap, "SOAP-ENC:arraySize", soap->tmpbuf)) return soap->error; } } } - else - { if (offset && soap_attribute(soap, "SOAP-ENC:offset", offset)) - return soap->error; - if (soap_attribute(soap, "SOAP-ENC:arrayType", type)) - return soap->error; - } #ifndef WITH_LEAN if ((soap->mode & SOAP_XML_CANONICAL)) soap_utilize_ns(soap, type); @@ -9925,41 +10991,40 @@ soap_array_begin_out(struct soap *soap, const char *tag, int id, const char *typ #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 soap_element_start_end_out(struct soap *soap, const char *tag) -{ register struct soap_attribute *tp; +{ struct soap_attribute *tp; #ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) + if ((soap->mode & SOAP_XML_CANONICAL)) { struct soap_nlist *np; for (tp = soap->attributes; tp; tp = tp->next) - { if (tp->visible && tp->name) + { if (tp->visible && *tp->name) soap_utilize_ns(soap, tp->name); } for (np = soap->nlist; np; np = np->next) - { if (np->index == 1 && np->ns) + { if (np->ns && (np->index == 1 || (np->index == 0 && soap->event == SOAP_SEC_BEGIN && soap_tagsearch(soap->c14ninclude, np->id)))) { if (*(np->id)) - { -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), "xmlns:%s", np->id); -#else - sprintf(soap->tmpbuf, "xmlns:%s", np->id); -#endif - } + (SOAP_SNPRINTF(soap->tmpbuf, sizeof(soap->tmpbuf), strlen(np->id) + 6), "xmlns:%s", np->id); else - strcpy(soap->tmpbuf, "xmlns"); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Enabling utilized binding (level=%u) %s='%s'\n", np->level, soap->tmpbuf, np->ns)); + soap_strcpy(soap->tmpbuf, sizeof(soap->tmpbuf), "xmlns"); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Enabling utilized binding (level=%u) %s='%s' c14ninclude='%s'\n", np->level, soap->tmpbuf, np->ns, soap->c14ninclude ? soap->c14ninclude : "(null)")); soap_set_attr(soap, soap->tmpbuf, np->ns, 1); np->index = 2; } + else + { + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Binding (level=%u) %s='%s' utilized=%d\n", np->level, np->id, np->ns, np->index)); + } } } #endif #ifdef WITH_DOM if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { register struct soap_dom_attribute **att; + { struct soap_dom_attribute **att; att = &soap->dom->atts; for (tp = soap->attributes; tp; tp = tp->next) { if (tp->visible) @@ -9969,8 +11034,7 @@ soap_element_start_end_out(struct soap *soap, const char *tag) (*att)->next = NULL; (*att)->nstr = NULL; (*att)->name = soap_strdup(soap, tp->name); - (*att)->data = soap_strdup(soap, tp->value); - (*att)->wide = NULL; + (*att)->text = soap_strdup(soap, tp->value); (*att)->soap = soap; att = &(*att)->next; tp->visible = 0; @@ -9981,41 +11045,35 @@ soap_element_start_end_out(struct soap *soap, const char *tag) #endif for (tp = soap->attributes; tp; tp = tp->next) { if (tp->visible) - { -#ifndef WITH_LEAN - const char *s; - if ((soap->mode & SOAP_XML_DEFAULTNS) && (s = strchr(tp->name, ':'))) - { size_t n = s - tp->name; - if (soap->nlist && !strncmp(soap->nlist->id, tp->name, n) && !soap->nlist->id[n]) - s++; - else - s = tp->name; - if (soap_send(soap, " ") || soap_send(soap, s)) - return soap->error; - } - else -#endif - if (soap_send(soap, " ") || soap_send(soap, tp->name)) + { if (soap_send_raw(soap, " ", 1) || soap_send(soap, tp->name)) return soap->error; if (tp->visible == 2 && tp->value) - if (soap_send_raw(soap, "=\"", 2) + { if (soap_send_raw(soap, "=\"", 2) || soap_string_out(soap, tp->value, tp->flag) || soap_send_raw(soap, "\"", 1)) return soap->error; + } + else if (soap->mode & SOAP_XML_STRICT) + { if (soap_send_raw(soap, "=\"\"", 3)) + return soap->error; + } tp->visible = 0; } } if (tag) { #ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) + if ((soap->mode & SOAP_XML_CANONICAL)) { if (soap_send_raw(soap, ">", 1) || soap_element_end_out(soap, tag)) return soap->error; return SOAP_OK; } #endif - soap->level--; /* decrement level just before /> */ + if (soap->nlist) + soap_pop_namespace(soap); + soap->level--; /* decrement level just before /> */ + soap->body = 0; return soap_send_raw(soap, "/>", 2); } return soap_send_raw(soap, ">", 1); @@ -10023,6 +11081,7 @@ soap_element_start_end_out(struct soap *soap, const char *tag) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int @@ -10036,7 +11095,7 @@ soap_element_end_out(struct soap *soap, const char *tag) return SOAP_OK; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Element ending tag='%s'\n", tag)); #ifdef WITH_DOM - if (soap->feltendout && (soap->error = soap->feltendout(soap, tag))) + if (soap->feltendout && (soap->error = soap->feltendout(soap, tag)) != SOAP_OK) return soap->error; if ((soap->mode & SOAP_XML_DOM) && soap->dom) { if (soap->dom->prnt) @@ -10045,7 +11104,7 @@ soap_element_end_out(struct soap *soap, const char *tag) } #endif #ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) + if (soap->nlist) soap_pop_namespace(soap); if (soap->mode & SOAP_XML_INDENT) { if (!soap->body) @@ -10054,43 +11113,39 @@ soap_element_end_out(struct soap *soap, const char *tag) } soap->body = 0; } - if ((soap->mode & SOAP_XML_DEFAULTNS) && (s = strchr(tag, ':'))) - { soap_pop_namespace(soap); + if ((soap->mode & SOAP_XML_DEFAULTNS) && (s = strchr(tag, ':')) != NULL) tag = s + 1; - } #endif if (soap_send_raw(soap, "</", 2) || soap_send(soap, tag)) return soap->error; - soap->level--; /* decrement level just before > */ + soap->level--; /* decrement level just before > */ return soap_send_raw(soap, ">", 1); } #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 soap_element_ref(struct soap *soap, const char *tag, int id, int href) -{ register const char *s = "ref"; - register int n = 1; +{ const char *s = "ref"; + int n = 1; if (soap->version == 1) { s = "href"; n = 0; } else if (soap->version == 2) s = "SOAP-ENC:ref"; -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->href, sizeof(soap->href), "#_%d", href); -#else - sprintf(soap->href, "#_%d", href); -#endif + (SOAP_SNPRINTF(soap->href, sizeof(soap->href), sizeof(SOAP_BASEREFNAME) + 21), "#" SOAP_BASEREFNAME "%d", href); return soap_element_href(soap, tag, id, s, soap->href + n); } #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int @@ -10101,11 +11156,13 @@ soap_element_href(struct soap *soap, const char *tag, int id, const char *ref, c || soap_attribute(soap, ref, val) || soap_element_start_end_out(soap, tag)) return soap->error; + soap->body = 0; return SOAP_OK; } #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int @@ -10117,44 +11174,55 @@ soap_element_null(struct soap *soap, const char *tag, int id, const char *type) break; if (tp || (soap->version == 2 && soap->position > 0) || id > 0 || (soap->mode & SOAP_XML_NIL)) { if (soap_element(soap, tag, id, type) - || (!tp && soap_attribute(soap, "xsi:nil", "true"))) + || (!tp && soap_attribute(soap, "xsi:nil", "true")) + || soap_element_start_end_out(soap, tag)) return soap->error; - return soap_element_start_end_out(soap, tag); + soap->body = 0; + } + else + { soap->null = 1; + soap->position = 0; + soap->mustUnderstand = 0; } - soap->null = 1; - soap->position = 0; - soap->mustUnderstand = 0; return SOAP_OK; } #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 soap_element_nil(struct soap *soap, const char *tag) { if (soap_element(soap, tag, -1, NULL) - || ((soap->mode & SOAP_XML_NIL) && soap_attribute(soap, "xsi:nil", "true"))) + || (soap_attribute(soap, "xsi:nil", "true"))) return soap->error; return soap_element_start_end_out(soap, tag); } #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 -soap_element_id(struct soap *soap, const char *tag, int id, const void *p, const struct soap_array *a, int n, const char *type, int t) -{ if (!p) +soap_element_id(struct soap *soap, const char *tag, int id, const void *p, const void *a, int n, const char *type, int t, char **mark) +{ (void)a; (void)n; + if (!p) { soap->error = soap_element_null(soap, tag, id, type); return -1; } #ifndef WITH_NOIDREF + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Element_id %p type=%d id=%d\n", p, t, id)); if ((!soap->encodingStyle && !(soap->omode & SOAP_XML_GRAPH)) || (soap->omode & SOAP_XML_TREE)) - return 0; - if (id < 0) + return soap_check_and_mark(soap, p, t, mark); + if (mark) + *mark = NULL; + if (id < -1) + return soap_embed(soap, p, a, n, t); + else if (id <= 0) { struct soap_plist *pp; if (a) id = soap_array_pointer_lookup(soap, p, a, n, t, &pp); @@ -10172,12 +11240,113 @@ soap_element_id(struct soap *soap, const char *tag, int id, const void *p, const } return id; #else + return soap_check_and_mark(soap, p, t, mark); +#endif +} +#endif + +/******************************************************************************/ + +#ifndef PALM_1 +SOAP_FMAC1 +int +SOAP_FMAC2 +soap_check_and_mark(struct soap *soap, const void *p, int t, char **mark) +{ if (mark) + { struct soap_plist *pp; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Check %p and mark %p\n", p, mark)); + if (!soap_pointer_lookup(soap, p, t, &pp)) + if (!soap_pointer_enter(soap, p, NULL, 0, t, &pp)) + return -1; + if (soap->mode & SOAP_IO_LENGTH) + { if (pp->mark1 > 0) + return -1; + pp->mark1 = 1; + *mark = &pp->mark1; + } + else + { if (pp->mark2 > 0) + return -1; + pp->mark2 = 1; + *mark = &pp->mark2; + } + } return 0; +} #endif + +/******************************************************************************/ + +#ifndef PALM_1 +SOAP_FMAC1 +void * +SOAP_FMAC2 +soap_mark_lookup(struct soap *soap, const void *p, int t, struct soap_plist **ppp, char **mark) +{ if (!soap) + return NULL; + if (mark || !(soap->mode & SOAP_XML_TREE)) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Mark lookup %p type %d\n", p, t)); + if (!soap_pointer_lookup(soap, p, t, ppp)) + { if (!soap_pointer_enter(soap, p, NULL, 0, t, ppp)) + return NULL; + } + else if (!(soap->mode & SOAP_XML_TREE)) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Mark found %p\n", (*ppp)->dup)); + return (*ppp)->dup; + } + if (mark) + { if ((*ppp)->mark1 > 0) + (*ppp)->mark1 = 2; /* cycle */ + else + (*ppp)->mark1 = 1; /* cycle detection */ + *mark = &(*ppp)->mark1; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Mark cycle %d\n", (*ppp)->mark1)); + } + } + return NULL; } #endif /******************************************************************************/ + +#ifndef PALM_1 +SOAP_FMAC1 +int +SOAP_FMAC2 +soap_mark_cycle(struct soap *soap, struct soap_plist *pp) +{ (void)soap; + return pp && pp->mark1 == 2 && (soap->mode & SOAP_XML_TREE); +} +#endif + +/******************************************************************************/ + +#ifndef PALM_1 +SOAP_FMAC1 +void +SOAP_FMAC2 +soap_mark_dup(struct soap *soap, void *a, struct soap_plist *pp) +{ (void)soap; + if (pp) + pp->dup = a; +} +#endif + +/******************************************************************************/ + +#ifndef PALM_1 +SOAP_FMAC1 +void +SOAP_FMAC2 +soap_unmark(struct soap *soap, char *mark) +{ (void)soap; + if (mark) + *mark = 0; /* release detection */ +} +#endif + +/******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int @@ -10196,44 +11365,44 @@ soap_element_result(struct soap *soap, const char *tag) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 void SOAP_FMAC2 soap_check_result(struct soap *soap, const char *tag) -{ if (soap->version == 2 && soap->encodingStyle) - { soap_instring(soap, ":result", NULL, NULL, 0, 2, -1, -1); +{ (void)tag; + if (soap->version == 2 && soap->encodingStyle) + { soap_instring(soap, ":result", NULL, NULL, 0, 2, -1, -1, NULL); /* just ignore content for compliance reasons, but should compare tag to element's QName value? */ } - (void)tag; } #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 soap_attribute(struct soap *soap, const char *name, const char *value) -{ - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Attribute '%s'='%s'\n", name, value)); +{ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Attribute '%s'='%s'\n", name, value)); #ifdef WITH_DOM if ((soap->mode & SOAP_XML_DOM) && !(soap->mode & SOAP_XML_CANONICAL) && soap->dom) - { register struct soap_dom_attribute *a = (struct soap_dom_attribute*)soap_malloc(soap, sizeof(struct soap_dom_attribute)); + { struct soap_dom_attribute *a = (struct soap_dom_attribute*)soap_malloc(soap, sizeof(struct soap_dom_attribute)); if (!a) return soap->error; a->next = soap->dom->atts; a->nstr = NULL; a->name = soap_strdup(soap, name); - a->data = soap_strdup(soap, value); - a->wide = NULL; + a->text = soap_strdup(soap, value); a->soap = soap; soap->dom->atts = a; return SOAP_OK; } #endif #ifndef WITH_LEAN - if (soap->mode & SOAP_XML_CANONICAL) + if ((soap->mode & SOAP_XML_CANONICAL)) { /* push namespace */ if (!strncmp(name, "xmlns", 5) && (name[5] == ':' || name[5] == '\0')) soap_push_ns(soap, name + 5 + (name[5] == ':'), value, 0); @@ -10242,7 +11411,8 @@ soap_attribute(struct soap *soap, const char *name, const char *value) } else #endif - { if (soap_send(soap, " ") || soap_send(soap, name)) + { if (soap_send_raw(soap, " ", 1) + || soap_send(soap, name)) return soap->error; if (value) if (soap_send_raw(soap, "=\"", 2) @@ -10255,6 +11425,7 @@ soap_attribute(struct soap *soap, const char *name, const char *value) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -10265,15 +11436,19 @@ soap_element_begin_in(struct soap *soap, const char *tag, int nillable, const ch return soap->error = SOAP_TAG_MISMATCH; if (tag && *tag == '-') return SOAP_OK; - if (!(soap->error = soap_match_tag(soap, soap->tag, tag))) + soap->error = soap_match_tag(soap, soap->tag, tag); + if (!soap->error) { soap->peeked = 0; if (type && *soap->type && soap_match_tag(soap, soap->type, type)) return soap->error = SOAP_TYPE; if (!nillable && soap->null && (soap->mode & SOAP_XML_STRICT)) return soap->error = SOAP_NULL; if (soap->body) - soap->level++; - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Begin element found (level=%u) '%s'='%s'\n", soap->level, soap->tag, tag ? tag : SOAP_STR_EOS )); + { soap->level++; + if (soap->level > soap->maxlevel) + return soap->error = SOAP_LEVEL; + } + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Begin tag found (level=%u) '%s'='%s'\n", soap->level, soap->tag, tag ? tag : SOAP_STR_EOS )); soap->error = SOAP_OK; } } @@ -10284,25 +11459,32 @@ soap_element_begin_in(struct soap *soap, const char *tag, int nillable, const ch #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 soap_element_end_in(struct soap *soap, const char *tag) -{ register soap_wchar c; - register char *s; - register int n = 0; +{ soap_wchar c; + char *s; + int n = 0; if (tag && *tag == '-') return SOAP_OK; if (soap->error == SOAP_NO_TAG) soap->error = SOAP_OK; #ifdef WITH_DOM - /* this whitespace or mixed content is significant for DOM */ + /* this whitespace or mixed content is significant for DOM "as-is" */ if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { if (!soap->peeked && !soap_string_in(soap, 3, -1, -1)) + { s = soap_string_in(soap, -1, -1, -1, NULL); + if (!soap->peeked && !s) return soap->error; if (soap->dom->prnt) soap->dom = soap->dom->prnt; + if ((soap->mode & SOAP_XML_STRICT)) + { for (; *s; s++) + if (soap_notblank(*s)) + return soap->error = SOAP_SYNTAX_ERROR; /* reject mixed content before ending tag */ + } } #endif if (soap->peeked) @@ -10314,14 +11496,18 @@ soap_element_end_in(struct soap *soap, const char *tag) { while (((c = soap_get(soap)) != SOAP_TT)) { if ((int)c == EOF) return soap->error = SOAP_CHK_EOF; - if (c == SOAP_LT) - n++; - else if (c == '/') - { c = soap_get(soap); - if (c == SOAP_GT) - n--; - else - soap_unget(soap, c); + if (!soap_blank(c)) + { if ((soap->mode & SOAP_XML_STRICT)) + return soap->error = SOAP_SYNTAX_ERROR; /* reject mixed content before ending tag */ + if (c == SOAP_LT) + n++; + else if (c == '/') + { c = soap_get(soap); + if (c == SOAP_GT && n > 0) + n--; + else + soap_unget(soap, c); + } } } } while (n--); @@ -10348,37 +11534,38 @@ soap_element_end_in(struct soap *soap, const char *tag) if (tag && (soap->mode & SOAP_XML_STRICT)) { soap_pop_namespace(soap); if (soap_match_tag(soap, soap->tag, tag)) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End element tag '%s' does not match '%s'\n", soap->tag, tag ? tag : SOAP_STR_EOS)); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End tag '%s' does not match '%s'\n", soap->tag, tag ? tag : SOAP_STR_EOS)); return soap->error = SOAP_SYNTAX_ERROR; } } #endif - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End element found (level=%u) '%s'='%s'\n", soap->level, soap->tag, tag ? tag : SOAP_STR_EOS)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End tag found (level=%u) '%s'='%s'\n", soap->level, soap->tag, tag ? tag : SOAP_STR_EOS)); soap->level--; return SOAP_OK; } #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 const char * SOAP_FMAC2 soap_attr_value(struct soap *soap, const char *name, int flag) -{ register struct soap_attribute *tp; +{ struct soap_attribute *tp; if (*name == '-') return SOAP_STR_EOS; for (tp = soap->attributes; tp; tp = tp->next) - { if (tp->visible && !soap_match_tag(soap, tp->name, name)) + { if (!soap_match_att(soap, tp->name, name)) break; } - if (tp) - { if (flag == 2 && (soap->mode & SOAP_XML_STRICT)) + if (tp && tp->visible == 2) + { if (flag == 4 || (flag == 2 && (soap->mode & SOAP_XML_STRICT))) soap->error = SOAP_PROHIBITED; else return tp->value; } - else if (flag == 1 && (soap->mode & SOAP_XML_STRICT)) + else if (flag == 3 || (flag == 1 && (soap->mode & SOAP_XML_STRICT))) soap->error = SOAP_REQUIRED; else soap->error = SOAP_OK; @@ -10387,22 +11574,26 @@ soap_attr_value(struct soap *soap, const char *name, int flag) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 soap_set_attr(struct soap *soap, const char *name, const char *value, int flag) -{ register struct soap_attribute *tp; +{ struct soap_attribute *tp, *tq; if (*name == '-') return SOAP_OK; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Set attribute %s='%s'\n", name, value ? value : SOAP_STR_EOS)); - for (tp = soap->attributes; tp; tp = tp->next) + tq = NULL; + for (tp = soap->attributes; tp; tq = tp, tp = tp->next) { if (!strcmp(tp->name, name)) break; } if (!tp) - { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Allocate attribute %s\n", name)); - if (!(tp = (struct soap_attribute*)SOAP_MALLOC(soap, sizeof(struct soap_attribute) + strlen(name)))) + { size_t l = strlen(name); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Allocate attribute %s\n", name)); + tp = (struct soap_attribute*)SOAP_MALLOC(soap, sizeof(struct soap_attribute) + l); + if (!tp) return soap->error = SOAP_EOM; tp->ns = NULL; #ifndef WITH_LEAN @@ -10444,10 +11635,15 @@ soap_set_attr(struct soap *soap, const char *name, const char *value, int flag) } else #endif + if (tq) + { tq->next = tp; + tp->next = NULL; + } + else { tp->next = soap->attributes; soap->attributes = tp; } - strcpy((char*)tp->name, name); + soap_strcpy((char*)tp->name, l + 1, name); tp->value = NULL; } else if (tp->visible) @@ -10462,11 +11658,12 @@ soap_set_attr(struct soap *soap, const char *name, const char *value, int flag) if (value) { if (!tp->value) { tp->size = strlen(value) + 1; - if (!(tp->value = (char*)SOAP_MALLOC(soap, tp->size))) + tp->value = (char*)SOAP_MALLOC(soap, tp->size); + if (!tp->value) return soap->error = SOAP_EOM; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Allocate attribute value for %s (%p)\n", tp->name, tp->value)); } - strcpy(tp->value, value); + soap_strcpy(tp->value, tp->size, value); if (!strncmp(tp->name, "xmlns:", 6)) tp->ns = tp->value; tp->visible = 2; @@ -10474,8 +11671,18 @@ soap_set_attr(struct soap *soap, const char *name, const char *value, int flag) #ifndef WITH_LEAN if (!strcmp(name, "wsu:Id")) { soap->event = SOAP_SEC_BEGIN; - strncpy(soap->id, value, sizeof(soap->id)); - soap->id[sizeof(soap->id) - 1] = '\0'; + soap_strcpy(soap->id, sizeof(soap->id), value); + } + if ((soap->mode & SOAP_XML_CANONICAL)) + { const char *s = strchr(name, ':'); + if (s) /* should also check default namespace when 'type' is not qualified? */ + { struct soap_nlist *np = soap_lookup_ns(soap, name, s - name); + if (np && np->ns && soap->local_namespaces) + { if ((!strcmp(s + 1, "type") && !strcmp(np->ns, soap->local_namespaces[2].ns)) /* xsi:type QName */ + || ((!strcmp(s + 1, "arrayType") || !strcmp(s + 1, "itemType")) && !strcmp(np->ns, soap->local_namespaces[1].ns))) /* SOAP-ENC:arrayType and SOAP-ENC:itemType QName */ + soap_utilize_ns(soap, value); + } + } } #endif } @@ -10486,12 +11693,13 @@ soap_set_attr(struct soap *soap, const char *name, const char *value, int flag) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 void SOAP_FMAC2 soap_clr_attr(struct soap *soap) -{ register struct soap_attribute *tp; +{ struct soap_attribute *tp; #ifndef WITH_LEAN if ((soap->mode & SOAP_XML_CANONICAL)) { while (soap->attributes) @@ -10511,12 +11719,62 @@ soap_clr_attr(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_2 static int -soap_getattrval(struct soap *soap, char *s, size_t n, soap_wchar d) -{ register size_t i; - for (i = 0; i < n; i++) - { register soap_wchar c = soap_get(soap); +soap_getattrval(struct soap *soap, char *s, size_t *n, soap_wchar d) +{ char buf[8]; + size_t i; + size_t k = *n; + size_t m = 0; + char *t = buf; + for (i = 0; i < k; i++) + { soap_wchar c; + if (m) + { *s++ = *t++; + m--; + continue; + } + if ((soap->mode & SOAP_C_UTFSTRING)) + { c = soap_get(soap); + if ((c & 0x80000000) && c >= -0x7FFFFF80 && c < SOAP_AP) + { t = buf; + c &= 0x7FFFFFFF; + if (c < 0x0800) + *t++ = (char)(0xC0 | ((c >> 6) & 0x1F)); + else + { if (c < 0x010000) + *t++ = (char)(0xE0 | ((c >> 12) & 0x0F)); + else + { if (c < 0x200000) + *t++ = (char)(0xF0 | ((c >> 18) & 0x07)); + else + { if (c < 0x04000000) + *t++ = (char)(0xF8 | ((c >> 24) & 0x03)); + else + { *t++ = (char)(0xFC | ((c >> 30) & 0x01)); + *t++ = (char)(0x80 | ((c >> 24) & 0x3F)); + } + *t++ = (char)(0x80 | ((c >> 18) & 0x3F)); + } + *t++ = (char)(0x80 | ((c >> 12) & 0x3F)); + } + *t++ = (char)(0x80 | ((c >> 6) & 0x3F)); + } + *t++ = (char)(0x80 | (c & 0x3F)); + m = t - buf - 1; + if (i + m >= k) + { soap_unget(soap, c | 0x80000000); + *n = i; + return soap->error = SOAP_EOM; + } + t = buf; + *s++ = *t++; + continue; + } + } + else + c = soap_getutf8(soap); switch (c) { case SOAP_TT: @@ -10530,6 +11788,7 @@ soap_getattrval(struct soap *soap, char *s, size_t n, soap_wchar d) if (d == ' ') { soap_unget(soap, c); *s = '\0'; + *n = i + 1; return SOAP_OK; } *s++ = '>'; @@ -10537,6 +11796,7 @@ soap_getattrval(struct soap *soap, char *s, size_t n, soap_wchar d) case SOAP_QT: if (c == d) { *s = '\0'; + *n = i + 1; return SOAP_OK; } *s++ = '"'; @@ -10544,6 +11804,7 @@ soap_getattrval(struct soap *soap, char *s, size_t n, soap_wchar d) case SOAP_AP: if (c == d) { *s = '\0'; + *n = i + 1; return SOAP_OK; } *s++ = '\''; @@ -10556,11 +11817,15 @@ soap_getattrval(struct soap *soap, char *s, size_t n, soap_wchar d) if (d == ' ') { soap_unget(soap, c); *s = '\0'; + *n = i + 1; return SOAP_OK; } + *s++ = (char)c; + break; default: if ((int)c == EOF) { *s = '\0'; + *n = i + 1; return soap->error = SOAP_CHK_EOF; } *s++ = (char)c; @@ -10571,6 +11836,7 @@ soap_getattrval(struct soap *soap, char *s, size_t n, soap_wchar d) #endif /******************************************************************************/ + #ifdef WITH_FAST #ifndef PALM_2 SOAP_FMAC1 @@ -10584,6 +11850,7 @@ soap_store_lab(struct soap *soap, const char *s, size_t n) #endif /******************************************************************************/ + #ifdef WITH_FAST #ifndef PALM_2 SOAP_FMAC1 @@ -10591,7 +11858,7 @@ int SOAP_FMAC2 soap_append_lab(struct soap *soap, const char *s, size_t n) { if (soap->labidx + n >= soap->lablen) - { register char *t = soap->labbuf; + { char *t = soap->labbuf; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Enlarging look-aside buffer to append data, size=%lu\n", (unsigned long)soap->lablen)); if (soap->lablen == 0) soap->lablen = SOAP_LABLEN; @@ -10605,12 +11872,12 @@ soap_append_lab(struct soap *soap, const char *s, size_t n) return soap->error = SOAP_EOM; } if (t) - { memcpy(soap->labbuf, t, soap->labidx); + { soap_memcpy((void*)soap->labbuf, soap->lablen, (const void*)t, soap->labidx); SOAP_FREE(soap, t); } } if (s) - { memcpy(soap->labbuf + soap->labidx, s, n); + { soap_memcpy((void*)(soap->labbuf + soap->labidx), soap->lablen - soap->labidx, (const void*)s, n); soap->labidx += n; } return SOAP_OK; @@ -10619,6 +11886,7 @@ soap_append_lab(struct soap *soap, const char *s, size_t n) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -10626,14 +11894,14 @@ SOAP_FMAC2 soap_peek_element(struct soap *soap) { #ifdef WITH_DOM - register struct soap_dom_attribute **att = NULL; - register char *lead = NULL; -#endif - register struct soap_attribute *tp, *tq = NULL; - register const char *t; - register char *s; - register soap_wchar c; - register int i; + struct soap_dom_attribute **att = NULL; + char *lead = NULL; +#endif + struct soap_attribute *tp, *tq = NULL; + const char *t; + char *s; + soap_wchar c; + int i; if (soap->peeked) { if (!*soap->tag) return soap->error = SOAP_NO_TAG; @@ -10654,8 +11922,9 @@ soap_peek_element(struct soap *soap) /* UTF-8 BOM? */ c = soap_getchar(soap); if (c == 0xEF && soap_get0(soap) == 0xBB) - { c = soap_get1(soap); - if ((c = soap_get1(soap)) == 0xBF) + { soap_get1(soap); + c = soap_get1(soap); + if (c == 0xBF) soap->mode &= ~SOAP_ENC_LATIN; else soap_unget(soap, (0x0F << 12) | (0xBB << 6) | (c & 0x3F)); /* UTF-8 */ @@ -10667,7 +11936,7 @@ soap_peek_element(struct soap *soap) soap_unget(soap, c); c = soap_get(soap); #ifdef WITH_DOM - /* whitespace leading to tag is not insignificant for DOM */ + /* whitespace leading up to the start tag is significant for DOM as-is (but comments and PIs are removed from this lead) */ if (soap_blank(c)) { soap->labidx = 0; do @@ -10680,8 +11949,7 @@ soap_peek_element(struct soap *soap) { *s++ = c; c = soap_get(soap); } - } - while (soap_blank(c)); + } while (soap_blank(c)); *s = '\0'; lead = soap->labbuf; } @@ -10696,12 +11964,12 @@ soap_peek_element(struct soap *soap) return soap->error = SOAP_CHK_EOF; soap_unget(soap, c); #ifdef WITH_DOM - /* whitespace leading to end tag is significant for DOM */ + /* whitespace leading up to the end tag is significant for DOM as-is */ if ((soap->mode & SOAP_XML_DOM) && soap->dom) { if (lead && *lead) soap->dom->tail = soap_strdup(soap, lead); else - soap->dom->tail = (char*)SOAP_STR_EOS; + soap->dom->tail = SOAP_STR_EOS; /* body with closing tag instead of <tag/> */ } #endif return soap->error = SOAP_NO_TAG; @@ -10720,22 +11988,25 @@ soap_peek_element(struct soap *soap) c = soap_get1(soap); #ifdef WITH_DOM if (soap->mode & SOAP_XML_DOM) - { register struct soap_dom_element *elt; + { struct soap_dom_element *elt; elt = (struct soap_dom_element*)soap_malloc(soap, sizeof(struct soap_dom_element)); if (!elt) return soap->error; elt->next = NULL; - elt->nstr = NULL; - elt->name = soap_strdup(soap, soap->tag); elt->prnt = soap->dom; elt->elts = NULL; elt->atts = NULL; - elt->data = NULL; - elt->wide = NULL; - elt->type = 0; - elt->node = NULL; - elt->head = soap_strdup(soap, lead); + elt->nstr = NULL; + elt->name = soap_strdup(soap, soap->tag); + elt->text = NULL; + elt->code = NULL; elt->tail = NULL; + elt->node = NULL; + elt->type = 0; + if (lead && *lead) + elt->lead = soap_strdup(soap, lead); + else + elt->lead = NULL; elt->soap = soap; if (soap->dom) { struct soap_dom_element *p = soap->dom->elts; @@ -10774,8 +12045,7 @@ soap_peek_element(struct soap *soap) (*att)->next = NULL; (*att)->nstr = NULL; (*att)->name = soap_strdup(soap, soap->tmpbuf); - (*att)->data = NULL; - (*att)->wide = NULL; + (*att)->text = NULL; (*att)->soap = soap; } #endif @@ -10795,15 +12065,16 @@ soap_peek_element(struct soap *soap) break; } if (!tp) - { tp = (struct soap_attribute*)SOAP_MALLOC(soap, sizeof(struct soap_attribute) + strlen(soap->tmpbuf)); + { size_t l = strlen(soap->tmpbuf); + tp = (struct soap_attribute*)SOAP_MALLOC(soap, sizeof(struct soap_attribute) + l); if (!tp) return soap->error = SOAP_EOM; - strcpy((char*)tp->name, soap->tmpbuf); + soap_strcpy((char*)tp->name, l + 1, soap->tmpbuf); tp->value = NULL; tp->size = 0; tp->ns = NULL; - /* if attribute name is qualified, append it to the end of the list */ - if (tq && strchr(soap->tmpbuf, ':')) + /* append attribute to the end of the list */ + if (tq) { tq->next = tp; tp->next = NULL; } @@ -10815,25 +12086,28 @@ soap_peek_element(struct soap *soap) while (soap_blank(c)) c = soap_get1(soap); if (c == '=') - { do c = soap_getutf8(soap); + { size_t k; + do c = soap_getutf8(soap); while (soap_blank(c)); if (c != SOAP_QT && c != SOAP_AP) { soap_unget(soap, c); c = ' '; /* blank delimiter */ } - if (soap_getattrval(soap, tp->value, tp->size, c)) + k = tp->size; + if (soap_getattrval(soap, tp->value, &k, c)) { #ifdef WITH_FAST if (soap->error != SOAP_EOM) return soap->error; soap->error = SOAP_OK; - if (soap_store_lab(soap, tp->value, tp->size)) + if (soap_store_lab(soap, tp->value, k)) return soap->error; if (tp->value) SOAP_FREE(soap, tp->value); tp->value = NULL; for (;;) - { if (soap_getattrval(soap, soap->labbuf + soap->labidx, soap->lablen - soap->labidx, c)) + { k = soap->lablen - soap->labidx; + if (soap_getattrval(soap, soap->labbuf + soap->labidx, &k, c)) { if (soap->error != SOAP_EOM) return soap->error; soap->error = SOAP_OK; @@ -10851,37 +12125,42 @@ soap_peek_element(struct soap *soap) if (tp->size < SOAP_LABLEN) tp->size = SOAP_LABLEN; } - if (!(tp->value = (char*)SOAP_MALLOC(soap, tp->size))) + tp->value = (char*)SOAP_MALLOC(soap, tp->size); + if (!tp->value) return soap->error = SOAP_EOM; - strcpy(tp->value, soap->labbuf); + soap_strcpy(tp->value, tp->size, soap->labbuf); #else - size_t n; + tp->size = k; if (soap->error != SOAP_EOM) return soap->error; soap->error = SOAP_OK; if (soap_new_block(soap) == NULL) return soap->error; for (;;) - { if (!(s = (char*)soap_push_block(soap, NULL, SOAP_BLKLEN))) + { s = (char*)soap_push_block(soap, NULL, SOAP_BLKLEN); + if (!s) return soap->error; - if (soap_getattrval(soap, s, SOAP_BLKLEN, c)) + k = SOAP_BLKLEN; + if (soap_getattrval(soap, s, &k, c)) { if (soap->error != SOAP_EOM) return soap->error; soap->error = SOAP_OK; + soap_size_block(soap, NULL, k); } else break; } - n = tp->size + soap->blist->size; - if (!(s = (char*)SOAP_MALLOC(soap, n))) + k = tp->size + soap->blist->size; + s = (char*)SOAP_MALLOC(soap, k); + if (!s) return soap->error = SOAP_EOM; if (tp->value) - { memcpy(s, tp->value, tp->size); + { soap_memcpy((void*)s, k, (const void*)tp->value, tp->size); SOAP_FREE(soap, tp->value); } soap_save_block(soap, NULL, s + tp->size, 0); tp->value = s; - tp->size = n; + tp->size = k; #endif } do c = soap_get1(soap); @@ -10889,7 +12168,7 @@ soap_peek_element(struct soap *soap) tp->visible = 2; /* seen this attribute w/ value */ #ifdef WITH_DOM if (att) - (*att)->data = soap_strdup(soap, tp->value); + (*att)->text = soap_strdup(soap, tp->value); #endif } else @@ -10905,16 +12184,18 @@ soap_peek_element(struct soap *soap) } #ifdef WITH_DOM if (att) - { soap->dom->nstr = soap_current_namespace(soap, soap->tag); + { soap->dom->nstr = soap_current_namespace_tag(soap, soap->tag); for (att = &soap->dom->atts; *att; att = &(*att)->next) - (*att)->nstr = soap_current_namespace(soap, (*att)->name); + (*att)->nstr = soap_current_namespace_att(soap, (*att)->name); } #endif if ((int)c == EOF) return soap->error = SOAP_CHK_EOF; - if (!(soap->body = (c != '/'))) - do c = soap_get1(soap); + soap->body = (c != '/'); + if (!soap->body) + { do c = soap_get1(soap); while (soap_blank(c)); + } #ifdef WITH_DOM if (soap->mode & SOAP_XML_DOM) { if (!soap->body && soap->dom->prnt) @@ -10929,32 +12210,30 @@ soap_peek_element(struct soap *soap) { if ((soap->version > 0 && !(soap->imode & SOAP_XML_TREE)) || (soap->mode & SOAP_XML_GRAPH)) { *soap->id = '#'; - strncpy(soap->id + 1, tp->value, sizeof(soap->id) - 2); - soap->id[sizeof(soap->id) - 1] = '\0'; + soap_strcpy(soap->id + 1, sizeof(soap->id) - 1, tp->value); } } else if (!strcmp(tp->name, "href")) { if ((soap->version == 1 && !(soap->imode & SOAP_XML_TREE)) || (soap->mode & SOAP_XML_GRAPH) - || (soap->mode & SOAP_ENC_MTOM) - || (soap->mode & SOAP_ENC_DIME)) - { strncpy(soap->href, tp->value, sizeof(soap->href) - 1); - soap->href[sizeof(soap->href) - 1] = '\0'; - } + || ((soap->mode & (SOAP_ENC_MTOM | SOAP_ENC_DIME)) && *tp->value != '#')) + soap_strcpy(soap->href, sizeof(soap->href), tp->value); } else if (!strcmp(tp->name, "ref")) { if ((soap->version == 2 && !(soap->imode & SOAP_XML_TREE)) || (soap->mode & SOAP_XML_GRAPH)) { *soap->href = '#'; - strncpy(soap->href + (*tp->value != '#'), tp->value, sizeof(soap->href) - 2); - soap->href[sizeof(soap->href) - 1] = '\0'; + soap_strcpy(soap->href + (*tp->value != '#'), sizeof(soap->href) - 1, tp->value); } } - else +#else + if (!strcmp(tp->name, "href")) + { if ((soap->mode & (SOAP_ENC_MTOM | SOAP_ENC_DIME)) && *tp->value != '#') + soap_strcpy(soap->href, sizeof(soap->href), tp->value); + } #endif - if (!soap_match_tag(soap, tp->name, "xsi:type")) - { strncpy(soap->type, tp->value, sizeof(soap->type) - 1); - soap->type[sizeof(soap->type) - 1] = '\0'; + else if (!soap_match_tag(soap, tp->name, "xsi:type")) + { soap_strcpy(soap->type, sizeof(soap->type), tp->value); } else if ((!soap_match_tag(soap, tp->name, "xsi:null") || !soap_match_tag(soap, tp->name, "xsi:nil")) @@ -10962,21 +12241,24 @@ soap_peek_element(struct soap *soap) || !strcmp(tp->value, "true"))) { soap->null = 1; } + else if (!soap_match_tag(soap, tp->name, "SOAP-ENV:encodingStyle")) + { if (!soap->encodingStyle) + soap->encodingStyle = SOAP_STR_EOS; + soap_get_version(soap); + } else if (soap->version == 1) - { if (!soap_match_tag(soap, tp->name, "SOAP-ENC:arrayType")) + { + if (!soap_match_tag(soap, tp->name, "SOAP-ENC:arrayType")) { s = soap_strrchr(tp->value, '['); if (s && (size_t)(s - tp->value) < sizeof(soap->arrayType)) - { strncpy(soap->arrayType, tp->value, s - tp->value); - soap->arrayType[s - tp->value] = '\0'; - strncpy(soap->arraySize, s, sizeof(soap->arraySize)); + { soap_strncpy(soap->arrayType, sizeof(soap->arrayType), tp->value, s - tp->value); + soap_strcpy(soap->arraySize, sizeof(soap->arraySize), s); } else - strncpy(soap->arrayType, tp->value, sizeof(soap->arrayType)); - soap->arraySize[sizeof(soap->arraySize) - 1] = '\0'; - soap->arrayType[sizeof(soap->arrayType) - 1] = '\0'; + soap_strcpy(soap->arrayType, sizeof(soap->arrayType), tp->value); } else if (!soap_match_tag(soap, tp->name, "SOAP-ENC:offset")) - strncpy(soap->arrayOffset, tp->value, sizeof(soap->arrayOffset)); + soap_strcpy(soap->arrayOffset, sizeof(soap->arrayOffset), tp->value); else if (!soap_match_tag(soap, tp->name, "SOAP-ENC:position")) soap->position = soap_getposition(tp->value, soap->positions); else if (!soap_match_tag(soap, tp->name, "SOAP-ENC:root")) @@ -10995,20 +12277,18 @@ soap_peek_element(struct soap *soap) #ifndef WITH_NOIDREF if (!soap_match_tag(soap, tp->name, "SOAP-ENC:id")) { *soap->id = '#'; - strncpy(soap->id + 1, tp->value, sizeof(soap->id) - 2); - soap->id[sizeof(soap->id) - 1] = '\0'; + soap_strcpy(soap->id + 1, sizeof(soap->id) - 1, tp->value); } else if (!soap_match_tag(soap, tp->name, "SOAP-ENC:ref")) { *soap->href = '#'; - strncpy(soap->href + (*tp->value != '#'), tp->value, sizeof(soap->href) - 2); - soap->href[sizeof(soap->href) - 1] = '\0'; + soap_strcpy(soap->href + (*tp->value != '#'), sizeof(soap->href) - 1, tp->value); } else #endif if (!soap_match_tag(soap, tp->name, "SOAP-ENC:itemType")) - strncpy(soap->arrayType, tp->value, sizeof(soap->arrayType) - 1); + soap_strcpy(soap->arrayType, sizeof(soap->arrayType), tp->value); else if (!soap_match_tag(soap, tp->name, "SOAP-ENC:arraySize")) - strncpy(soap->arraySize, tp->value, sizeof(soap->arraySize) - 1); + soap_strcpy(soap->arraySize, sizeof(soap->arraySize), tp->value); else if (!soap_match_tag(soap, tp->name, "SOAP-ENV:mustUnderstand") && (!strcmp(tp->value, "1") || !strcmp(tp->value, "true"))) soap->mustUnderstand = 1; @@ -11033,6 +12313,7 @@ soap_peek_element(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 void @@ -11044,6 +12325,7 @@ soap_retry(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 void @@ -11059,21 +12341,68 @@ soap_revert(struct soap *soap) #endif /******************************************************************************/ + +#ifndef PALM_2 +SOAP_FMAC1 +int +SOAP_FMAC2 +soap_ignore(struct soap *soap) +{ int n = 0; + soap_wchar c; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Ignoring XML content at level=%u\n", soap->level)); +#ifdef WITH_DOM + if ((soap->mode & SOAP_XML_DOM) && soap->dom) + { if (!soap_string_in(soap, -1, -1, -1, NULL)) + return soap->error; + return SOAP_OK; + } +#endif + for (;;) + { c = soap_get(soap); + switch (c) + { case SOAP_TT: + if (n == 0) + goto end; + n--; + break; + case SOAP_LT: + n++; + break; + case '/': + if (n > 0) + { c = soap_getchar(soap); + if (c == '>') + n--; + } + break; + default: + if ((int)c == EOF) + goto end; + } + } +end: + soap_unget(soap, c); + return SOAP_OK; +} +#endif + +/******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 soap_string_out(struct soap *soap, const char *s, int flag) -{ register const char *t; - register soap_wchar c; - register soap_wchar mask = (soap_wchar)0xFFFFFF80UL; +{ const char *t; + soap_wchar c; + soap_wchar mask = (soap_wchar)0xFFFFFF80UL; #ifdef WITH_DOM if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { soap->dom->data = soap_strdup(soap, s); + { soap->dom->text = soap_strdup(soap, s); return SOAP_OK; } #endif - if (flag == 2 || soap->mode & SOAP_C_UTFSTRING) + if (flag == 2 || (soap->mode & SOAP_C_UTFSTRING)) mask = 0; t = s; while ((c = *t++)) @@ -11093,11 +12422,6 @@ soap_string_out(struct soap *soap, const char *s, int flag) s = t; } break; - case 0x0D: - if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, "
", 5)) - return soap->error; - s = t; - break; case '&': if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, "&", 5)) return soap->error; @@ -11122,12 +12446,17 @@ soap_string_out(struct soap *soap, const char *s, int flag) s = t; } break; + case 0x7F: + if (soap_send_raw(soap, s, t - s - 1) || soap_send_raw(soap, "", 6)) + return soap->error; + s = t; + break; default: #ifndef WITH_LEANER #ifdef HAVE_MBTOWC if (soap->mode & SOAP_C_MBSTRING) { wchar_t wc; - register int m = mbtowc(&wc, t - 1, MB_CUR_MAX); + int m = mbtowc(&wc, t - 1, MB_CUR_MAX); if (m > 0 && !((soap_wchar)wc == c && m == 1 && c < 0x80)) { if (soap_send_raw(soap, s, t - s - 1) || soap_pututf8(soap, (unsigned long)wc)) return soap->error; @@ -11151,47 +12480,51 @@ soap_string_out(struct soap *soap, const char *s, int flag) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 char * SOAP_FMAC2 -soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) -{ register char *s; +soap_string_in(struct soap *soap, int flag, long minlen, long maxlen, const char *pattern) +{ char *s; char *t = NULL; - register size_t i; - register long l = 0; - register int n = 0, f = 0, m = 0; - register soap_wchar c; + size_t i; + long l = 0; + int n = 0, f = 0, m = 0; + soap_wchar c; #if !defined(WITH_LEANER) && defined(HAVE_WCTOMB) char buf[MB_LEN_MAX > 8 ? MB_LEN_MAX : 8]; #else char buf[8]; #endif - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Reading string content, flag=%d\n", flag)); - if (soap->peeked && *soap->tag) + if (maxlen < 0 && soap->maxlength > 0) + maxlen = soap->maxlength; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Reading string content, flag=%d\n", flag)); + if (flag <= 0 && soap->peeked && *soap->tag) { #ifndef WITH_LEAN struct soap_attribute *tp; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "String content includes tag '%s' and attributes\n", soap->tag)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "String content includes tag '%s' and attributes\n", soap->tag)); t = soap->tmpbuf; *t = '<'; - strncpy(t + 1, soap->tag, sizeof(soap->tmpbuf) - 2); - t[sizeof(soap->tmpbuf) - 1] = '\0'; + soap_strcpy(t + 1, sizeof(soap->tmpbuf) - 1, soap->tag); t += strlen(t); for (tp = soap->attributes; tp; tp = tp->next) { if (tp->visible) - { if (t >= soap->tmpbuf + sizeof(soap->tmpbuf) - 2) - break; + { size_t l = strlen(tp->name); + if (t + l + 1 >= soap->tmpbuf + sizeof(soap->tmpbuf)) + break; /* too many or attribute values to large */ *t++ = ' '; - strcpy(t, tp->name); - t += strlen(t); - if (t >= soap->tmpbuf + sizeof(soap->tmpbuf) - 2) - break; /* too many or large attribute values */ + soap_strncpy(t, sizeof(soap->tmpbuf) - (t - soap->tmpbuf), tp->name, l); + t += l; if (tp->value) - { *t++ = '='; + { l = strlen(tp->value); + if (t + l + 3 >= soap->tmpbuf + sizeof(soap->tmpbuf)) + break; /* too many or attribute values to large */ + *t++ = '='; *t++ = '"'; - strcpy(t, tp->value); - t += strlen(t); + soap_strncpy(t, sizeof(soap->tmpbuf) - (t - soap->tmpbuf), tp->value, l); + t += l; *t++ = '"'; } } @@ -11209,10 +12542,10 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) soap->peeked = 0; } #ifdef WITH_CDATA - if (!flag) - { register int state = 0; + if (flag <= 0) + { int state = 0; #ifdef WITH_FAST - soap->labidx = 0; /* use look-aside buffer */ + soap->labidx = 0; /* use look-aside buffer */ #else if (soap_new_block(soap) == NULL) return NULL; @@ -11220,20 +12553,21 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) for (;;) { #ifdef WITH_FAST - register size_t k; - if (soap_append_lab(soap, NULL, 0)) /* allocate more space in look-aside buffer if necessary */ + size_t k; + if (soap_append_lab(soap, NULL, 0)) /* allocate more space in look-aside buffer if necessary */ return NULL; - s = soap->labbuf + soap->labidx; /* space to populate */ - k = soap->lablen - soap->labidx; /* number of bytes available */ - soap->labidx = soap->lablen; /* claim this space */ + s = soap->labbuf + soap->labidx; /* space to populate */ + k = soap->lablen - soap->labidx; /* number of bytes available */ + soap->labidx = soap->lablen; /* claim this space */ #else - register size_t k = SOAP_BLKLEN; - if (!(s = (char*)soap_push_block(soap, NULL, k))) + size_t k = SOAP_BLKLEN; + s = (char*)soap_push_block(soap, NULL, k); + if (!s) return NULL; #endif for (i = 0; i < k; i++) { if (m > 0) - { *s++ = *t++; /* copy multibyte characters */ + { *s++ = *t++; /* copy multibyte characters */ m--; continue; } @@ -11245,7 +12579,7 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) { soap_unget(soap, c); c = soap_getutf8(soap); } - if ((c & 0x7FFFFFFF) >= 0x80 && (!flag || (soap->mode & SOAP_C_UTFSTRING))) + if ((c & 0x7FFFFFFF) >= 0x80 && (flag <= 0 || (soap->mode & SOAP_C_UTFSTRING))) { c &= 0x7FFFFFFF; t = buf; if (c < 0x0800) @@ -11303,7 +12637,7 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) case 5: if (c == '>') state = 0; - else if (c != ']') + else if (c != ']') state = 1; *s++ = (char)c; continue; @@ -11342,7 +12676,7 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) m = 1; break; case SOAP_LT: - if (f && n == 0) + if (flag == 3 || (f && n == 0)) goto end; n++; *s++ = '<'; @@ -11386,7 +12720,8 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) state = 1; } else if (c == '-') - { if ((c = soap_getchar(soap)) == '-') + { c = soap_getchar(soap); + if (c == '-') state = 2; t = (char*)"!-"; m = 2; @@ -11402,7 +12737,7 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) } else if (c == '?') state = 3; - else if (f && n == 0) + else if (flag == 3 || (f && n == 0)) { soap_revget1(soap); c = '<'; goto end; @@ -11422,7 +12757,13 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) #ifndef WITH_LEANER #ifdef HAVE_WCTOMB if (soap->mode & SOAP_C_MBSTRING) - { m = wctomb(buf, (wchar_t)(c & 0x7FFFFFFF)); + { +#ifdef WIN32 + m = 0; + wctomb_s(&m, buf, sizeof(buf), (wchar_t)(c & 0x7FFFFFFF)); +#else + m = wctomb(buf, (wchar_t)(c & 0x7FFFFFFF)); +#endif if (m >= 1 && m <= (int)MB_CUR_MAX) { t = buf; *s++ = *t++; @@ -11440,7 +12781,7 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) } l++; if (maxlen >= 0 && l > maxlen) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "String too long: maxlen=%ld\n", maxlen)); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "String too long: maxlen=%ld\n", maxlen)); soap->error = SOAP_LENGTH; return NULL; } @@ -11449,7 +12790,7 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) } #endif #ifdef WITH_FAST - soap->labidx = 0; /* use look-aside buffer */ + soap->labidx = 0; /* use look-aside buffer */ #else if (soap_new_block(soap) == NULL) return NULL; @@ -11457,62 +12798,69 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) for (;;) { #ifdef WITH_FAST - register size_t k; - if (soap_append_lab(soap, NULL, 0)) /* allocate more space in look-aside buffer if necessary */ + size_t k; + if (soap_append_lab(soap, NULL, 0)) /* allocate more space in look-aside buffer if necessary */ return NULL; - s = soap->labbuf + soap->labidx; /* space to populate */ - k = soap->lablen - soap->labidx; /* number of bytes available */ - soap->labidx = soap->lablen; /* claim this space */ + s = soap->labbuf + soap->labidx; /* space to populate */ + k = soap->lablen - soap->labidx; /* number of bytes available */ + soap->labidx = soap->lablen; /* claim this space */ #else - register size_t k = SOAP_BLKLEN; - if (!(s = (char*)soap_push_block(soap, NULL, k))) + size_t k = SOAP_BLKLEN; + s = (char*)soap_push_block(soap, NULL, k); + if (!s) return NULL; #endif for (i = 0; i < k; i++) { if (m > 0) - { *s++ = *t++; /* copy multibyte characters */ + { *s++ = *t++; /* copy multibyte characters */ m--; continue; } #ifndef WITH_CDATA - if (!flag) + if (flag <= 0) c = soap_getchar(soap); else #endif - if ((soap->mode & SOAP_C_UTFSTRING)) - { if (((c = soap_get(soap)) & 0x80000000) && c >= -0x7FFFFF80 && c < SOAP_AP) - { c &= 0x7FFFFFFF; - t = buf; - if (c < 0x0800) - *t++ = (char)(0xC0 | ((c >> 6) & 0x1F)); - else - { if (c < 0x010000) - *t++ = (char)(0xE0 | ((c >> 12) & 0x0F)); + { c = soap_getutf8(soap); + if ((soap->mode & SOAP_C_UTFSTRING)) + { if (c >= 0x80 || (c < SOAP_AP && c >= -0x7FFFFF80)) + { c &= 0x7FFFFFFF; + t = buf; + if (c < 0x0800) + *t++ = (char)(0xC0 | ((c >> 6) & 0x1F)); else - { if (c < 0x200000) - *t++ = (char)(0xF0 | ((c >> 18) & 0x07)); + { if (c < 0x010000) + *t++ = (char)(0xE0 | ((c >> 12) & 0x0F)); else - { if (c < 0x04000000) - *t++ = (char)(0xF8 | ((c >> 24) & 0x03)); + { if (c < 0x200000) + *t++ = (char)(0xF0 | ((c >> 18) & 0x07)); else - { *t++ = (char)(0xFC | ((c >> 30) & 0x01)); - *t++ = (char)(0x80 | ((c >> 24) & 0x3F)); + { if (c < 0x04000000) + *t++ = (char)(0xF8 | ((c >> 24) & 0x03)); + else + { *t++ = (char)(0xFC | ((c >> 30) & 0x01)); + *t++ = (char)(0x80 | ((c >> 24) & 0x3F)); + } + *t++ = (char)(0x80 | ((c >> 18) & 0x3F)); } - *t++ = (char)(0x80 | ((c >> 18) & 0x3F)); + *t++ = (char)(0x80 | ((c >> 12) & 0x3F)); } - *t++ = (char)(0x80 | ((c >> 12) & 0x3F)); + *t++ = (char)(0x80 | ((c >> 6) & 0x3F)); } - *t++ = (char)(0x80 | ((c >> 6) & 0x3F)); + *t++ = (char)(0x80 | (c & 0x3F)); + m = (int)(t - buf) - 1; + t = buf; + *s++ = *t++; + l++; + if (maxlen >= 0 && l > maxlen) + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "String too long: maxlen=%ld\n", maxlen)); + soap->error = SOAP_LENGTH; + return NULL; + } + continue; } - *t++ = (char)(0x80 | (c & 0x3F)); - m = (int)(t - buf) - 1; - t = buf; - *s++ = *t++; - continue; } } - else - c = soap_getutf8(soap); switch (c) { case SOAP_TT: @@ -11524,7 +12872,7 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) m = 1; break; case SOAP_LT: - if (f && n == 0) + if (flag == 3 || (f && n == 0)) goto end; n++; *s++ = '<'; @@ -11540,22 +12888,22 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) break; case '/': if (n > 0) - { if (!flag) - { c = soap_getchar(soap); - if (c == '>') - n--; - } - else - { c = soap_get(soap); + { if (flag > 0) + { c = soap_get(soap); if (c == SOAP_GT) n--; - } + } + else + { c = soap_getchar(soap); + if (c == '>') + n--; + } soap_unget(soap, c); } *s++ = '/'; break; case (soap_wchar)('<' | 0x80000000): - if (flag) + if (flag > 0) *s++ = '<'; else { *s++ = '&'; @@ -11564,7 +12912,7 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) } break; case (soap_wchar)('>' | 0x80000000): - if (flag) + if (flag > 0) *s++ = '>'; else { *s++ = '&'; @@ -11573,7 +12921,7 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) } break; case (soap_wchar)('&' | 0x80000000): - if (flag) + if (flag > 0) *s++ = '&'; else { *s++ = '&'; @@ -11582,7 +12930,7 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) } break; case (soap_wchar)('"' | 0x80000000): - if (flag) + if (flag > 0) *s++ = '"'; else { *s++ = '&'; @@ -11591,7 +12939,7 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) } break; case (soap_wchar)('\'' | 0x80000000): - if (flag) + if (flag > 0) *s++ = '\''; else { *s++ = '&'; @@ -11603,28 +12951,31 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) if ((int)c == EOF) goto end; #ifndef WITH_CDATA - if (c == '<' && !flag) - { if (f && n == 0) + if (c == '<') + { c = soap_getchar(soap); + soap_unget(soap, c); + if (c == '/') + { c = SOAP_TT; + if (n == 0) goto end; - c = soap_getchar(soap); - soap_unget(soap, c); - if (c == '/') - { c = SOAP_TT; - if (n == 0) - goto end; - n--; - } - else - n++; - *s++ = '<'; - break; + n--; + } + else + n++; + *s++ = '<'; } else #endif #ifndef WITH_LEANER #ifdef HAVE_WCTOMB if (soap->mode & SOAP_C_MBSTRING) - { m = wctomb(buf, (wchar_t)(c & 0x7FFFFFFF)); + { +#ifdef WIN32 + m = 0; + wctomb_s(&m, buf, sizeof(buf), (wchar_t)(c & 0x7FFFFFFF)); +#else + m = wctomb(buf, (wchar_t)(c & 0x7FFFFFFF)); +#endif if (m >= 1 && m <= (int)MB_CUR_MAX) { t = buf; *s++ = *t++; @@ -11642,7 +12993,7 @@ soap_string_in(struct soap *soap, int flag, long minlen, long maxlen) } l++; if (maxlen >= 0 && l > maxlen) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "String too long: maxlen=%ld\n", maxlen)); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "String too long: maxlen=%ld\n", maxlen)); soap->error = SOAP_LENGTH; return NULL; } @@ -11655,29 +13006,38 @@ end: t = soap_strdup(soap, soap->labbuf); #else soap_size_block(soap, NULL, i + 1); - t = soap_save_block(soap, NULL, 0); + t = soap_save_block(soap, NULL, NULL, 0); #endif if (l < minlen) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "String too short: %ld chars, minlen=%ld\n", l, minlen)); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "String too short: %ld chars, minlen=%ld\n", l, minlen)); soap->error = SOAP_LENGTH; return NULL; } #ifdef WITH_DOM if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { if (flag == 3) - soap->dom->tail = t; + { if (flag > 0) + soap->dom->text = t; else - soap->dom->data = t; + soap->dom->code = t; } #endif if (flag == 2) - if (soap_s2QName(soap, t, &t, minlen, maxlen)) + { if (soap_s2QName(soap, t, &t, minlen, maxlen, pattern)) + return NULL; + } +#ifndef WITH_LEANER + else if (pattern && soap->fsvalidate) + { soap->error = soap->fsvalidate(soap, pattern, t); + if (soap->error) return NULL; + } +#endif return t; } #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_2 SOAP_FMAC1 @@ -11686,16 +13046,10 @@ SOAP_FMAC2 soap_wstring_out(struct soap *soap, const wchar_t *s, int flag) { const char *t; char tmp; - register soap_wchar c; + soap_wchar c; #ifdef WITH_DOM if ((soap->mode & SOAP_XML_DOM) && soap->dom) - { wchar_t *r = (wchar_t*)s; - int n = 1; - while (*r++) - n++; - soap->dom->wide = r = (wchar_t*)soap_malloc(soap, n * sizeof(wchar_t)); - while (n--) - *r++ = *s++; + { soap->dom->text = soap_wchar2s(soap, s); return SOAP_OK; } #endif @@ -11744,7 +13098,7 @@ soap_wstring_out(struct soap *soap, const wchar_t *s, int flag) else { /* check for UTF16 encoding when wchar_t is too small to hold UCS */ if (sizeof(wchar_t) < 4 && (c & 0xFC00) == 0xD800) - { register soap_wchar d = *s++; + { soap_wchar d = *s++; if ((d & 0xFC00) == 0xDC00) c = ((c - 0xD800) << 10) + (d - 0xDC00) + 0x10000; else @@ -11764,62 +13118,65 @@ soap_wstring_out(struct soap *soap, const wchar_t *s, int flag) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_2 SOAP_FMAC1 wchar_t * SOAP_FMAC2 -soap_wstring_in(struct soap *soap, int flag, long minlen, long maxlen) +soap_wstring_in(struct soap *soap, int flag, long minlen, long maxlen, const char *pattern) { wchar_t *s; - register int i, n = 0, f = 0; - register long l = 0; - register soap_wchar c; + int i, n = 0, f = 0; + long l = 0; + soap_wchar c; char *t = NULL; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Reading wide string content\n")); - if (soap->peeked) - { if (*soap->tag) - { + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Reading wide string content\n")); + if (maxlen < 0 && soap->maxlength > 0) + maxlen = soap->maxlength; + if (flag <= 0 && soap->peeked && *soap->tag) + { #ifndef WITH_LEAN - struct soap_attribute *tp; - t = soap->tmpbuf; - *t = '<'; - strncpy(t + 1, soap->tag, sizeof(soap->tmpbuf) - 2); - t[sizeof(soap->tmpbuf) - 1] = '\0'; - t += strlen(t); - for (tp = soap->attributes; tp; tp = tp->next) - { if (tp->visible) - { if (t >= soap->tmpbuf + sizeof(soap->tmpbuf) - 2) - break; - *t++ = ' '; - strcpy(t, tp->name); - t += strlen(t); - if (t >= soap->tmpbuf + sizeof(soap->tmpbuf) - 2) + struct soap_attribute *tp; + t = soap->tmpbuf; + *t = '<'; + soap_strcpy(t + 1, sizeof(soap->tmpbuf) - 1, soap->tag); + t += strlen(t); + for (tp = soap->attributes; tp; tp = tp->next) + { if (tp->visible) + { size_t l = strlen(tp->name); + if (t + l + 1 >= soap->tmpbuf + sizeof(soap->tmpbuf)) + break; + *t++ = ' '; + soap_strncpy(t, sizeof(soap->tmpbuf) - (t - soap->tmpbuf), tp->name, l); + t += l; + if (tp->value) + { l = strlen(tp->value); + if (t + l + 3 >= soap->tmpbuf + sizeof(soap->tmpbuf)) break; - if (tp->value) - { *t++ = '='; - *t++ = '"'; - strcpy(t, tp->value); - t += strlen(t); - *t++ = '"'; - } + *t++ = '='; + *t++ = '"'; + soap_strncpy(t, sizeof(soap->tmpbuf) - (t - soap->tmpbuf), tp->value, l); + t += l; + *t++ = '"'; } } - if (!soap->body) - *t++ = '/'; - *t++ = '>'; - *t = '\0'; - t = soap->tmpbuf; -#endif - if (soap->body) - n = 1; - f = 1; - soap->peeked = 0; } + if (!soap->body) + *t++ = '/'; + *t++ = '>'; + *t = '\0'; + t = soap->tmpbuf; +#endif + if (soap->body) + n = 1; + f = 1; + soap->peeked = 0; } if (soap_new_block(soap) == NULL) return NULL; for (;;) - { if (!(s = (wchar_t*)soap_push_block(soap, NULL, sizeof(wchar_t)*SOAP_BLKLEN))) + { s = (wchar_t*)soap_push_block(soap, NULL, sizeof(wchar_t)*SOAP_BLKLEN); + if (!s) return NULL; for (i = 0; i < SOAP_BLKLEN; i++) { if (t) @@ -11839,7 +13196,7 @@ soap_wstring_in(struct soap *soap, int flag, long minlen, long maxlen) soap_unget(soap, '/'); break; case SOAP_LT: - if (f && n == 0) + if (flag == 3 || (f && n == 0)) goto end; n++; *s++ = '<'; @@ -11863,7 +13220,7 @@ soap_wstring_in(struct soap *soap, int flag, long minlen, long maxlen) *s++ = '/'; break; case '<': - if (flag) + if (flag > 0) *s++ = (soap_wchar)'<'; else { *s++ = (soap_wchar)'&'; @@ -11871,7 +13228,7 @@ soap_wstring_in(struct soap *soap, int flag, long minlen, long maxlen) } break; case '>': - if (flag) + if (flag > 0) *s++ = (soap_wchar)'>'; else { *s++ = (soap_wchar)'&'; @@ -11879,7 +13236,7 @@ soap_wstring_in(struct soap *soap, int flag, long minlen, long maxlen) } break; case '"': - if (flag) + if (flag > 0) *s++ = (soap_wchar)'"'; else { *s++ = (soap_wchar)'&'; @@ -11891,7 +13248,7 @@ soap_wstring_in(struct soap *soap, int flag, long minlen, long maxlen) goto end; /* use UTF16 encoding when wchar_t is too small to hold UCS */ if (sizeof(wchar_t) < 4 && c > 0xFFFF) - { register soap_wchar c1, c2; + { soap_wchar c1, c2; c1 = 0xD800 - (0x10000 >> 10) + (c >> 10); c2 = 0xDC00 + (c & 0x3FF); c = c1; @@ -11901,7 +13258,7 @@ soap_wstring_in(struct soap *soap, int flag, long minlen, long maxlen) } l++; if (maxlen >= 0 && l > maxlen) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "String too long: maxlen=%ld\n", maxlen)); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "String too long: maxlen=%ld\n", maxlen)); soap->error = SOAP_LENGTH; return NULL; } @@ -11912,14 +13269,21 @@ end: *s = '\0'; soap_size_block(soap, NULL, sizeof(wchar_t) * (i + 1)); if (l < minlen) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "String too short: %ld chars, minlen=%ld\n", l, minlen)); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "String too short: %ld chars, minlen=%ld\n", l, minlen)); soap->error = SOAP_LENGTH; return NULL; } s = (wchar_t*)soap_save_block(soap, NULL, NULL, 0); +#ifndef WITH_LEANER + if (pattern && soap->fwvalidate) + { soap->error = soap->fwvalidate(soap, pattern, s); + if (soap->error) + return NULL; + } +#endif #ifdef WITH_DOM if ((soap->mode & SOAP_XML_DOM) && soap->dom) - soap->dom->wide = s; + soap->dom->text = soap_wchar2s(soap, s); #endif return s; } @@ -11927,6 +13291,7 @@ end: #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 const char* @@ -11937,6 +13302,7 @@ soap_int2s(struct soap *soap, int n) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -11950,6 +13316,7 @@ soap_outint(struct soap *soap, const char *tag, int id, const int *p, const char #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -11982,6 +13349,7 @@ soap_s2int(struct soap *soap, const char *s, int *p) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int * @@ -11999,10 +13367,12 @@ soap_inint(struct soap *soap, const char *tag, int *p, const char *type, int t) soap_revert(soap); return NULL; } +#else + (void)type; #endif - p = (int*)soap_id_enter(soap, soap->id, p, t, sizeof(int), 0, NULL, NULL, NULL); + p = (int*)soap_id_enter(soap, soap->id, p, t, sizeof(int), NULL, NULL, NULL, NULL); if (*soap->href) - p = (int*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(int), 0, NULL); + p = (int*)soap_id_forward(soap, soap->href, p, 0, t, t, sizeof(int), 0, NULL, NULL); else if (p) { if (soap_s2int(soap, soap_value(soap), p)) return NULL; @@ -12014,22 +13384,19 @@ soap_inint(struct soap *soap, const char *tag, int *p, const char *type, int t) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 const char* SOAP_FMAC2 soap_long2s(struct soap *soap, long n) -{ -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), "%ld", n); -#else - sprintf(soap->tmpbuf, "%ld", n); -#endif +{ (SOAP_SNPRINTF(soap->tmpbuf, sizeof(soap->tmpbuf), 20), "%ld", n); return soap->tmpbuf; } #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -12043,6 +13410,7 @@ soap_outlong(struct soap *soap, const char *tag, int id, const long *p, const ch #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -12070,6 +13438,7 @@ soap_s2long(struct soap *soap, const char *s, long *p) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 long * @@ -12087,10 +13456,12 @@ soap_inlong(struct soap *soap, const char *tag, long *p, const char *type, int t soap_revert(soap); return NULL; } +#else + (void)type; #endif - p = (long*)soap_id_enter(soap, soap->id, p, t, sizeof(long), 0, NULL, NULL, NULL); + p = (long*)soap_id_enter(soap, soap->id, p, t, sizeof(long), NULL, NULL, NULL, NULL); if (*soap->href) - p = (long*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(long), 0, NULL); + p = (long*)soap_id_forward(soap, soap->href, p, 0, t, t, sizeof(long), 0, NULL, NULL); else if (p) { if (soap_s2long(soap, soap_value(soap), p)) return NULL; @@ -12102,22 +13473,19 @@ soap_inlong(struct soap *soap, const char *tag, long *p, const char *type, int t #endif /******************************************************************************/ + #ifndef WITH_LEAN SOAP_FMAC1 const char* SOAP_FMAC2 soap_LONG642s(struct soap *soap, LONG64 n) -{ -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), SOAP_LONG_FORMAT, n); -#else - sprintf(soap->tmpbuf, SOAP_LONG_FORMAT, n); -#endif +{ (SOAP_SNPRINTF(soap->tmpbuf, sizeof(soap->tmpbuf), 20), SOAP_LONG_FORMAT, n); return soap->tmpbuf; } #endif /******************************************************************************/ + #ifndef WITH_LEAN SOAP_FMAC1 int @@ -12131,15 +13499,14 @@ soap_outLONG64(struct soap *soap, const char *tag, int id, const LONG64 *p, cons #endif /******************************************************************************/ + #ifndef WITH_LEAN SOAP_FMAC1 int SOAP_FMAC2 soap_s2LONG64(struct soap *soap, const char *s, LONG64 *p) { if (s) - { -#ifdef HAVE_STRTOLL - char *r; + { char *r; #ifndef WITH_NOIO #ifndef WITH_LEAN soap_reset_errno; @@ -12153,11 +13520,6 @@ soap_s2LONG64(struct soap *soap, const char *s, LONG64 *p) #endif #endif ) -#else -# ifdef HAVE_SSCANF - if (sscanf(s, SOAP_LONG_FORMAT, p) != 1) -# endif -#endif soap->error = SOAP_TYPE; } return soap->error; @@ -12165,6 +13527,7 @@ soap_s2LONG64(struct soap *soap, const char *s, LONG64 *p) #endif /******************************************************************************/ + #ifndef WITH_LEAN SOAP_FMAC1 LONG64 * @@ -12189,9 +13552,9 @@ soap_inLONG64(struct soap *soap, const char *tag, LONG64 *p, const char *type, i return NULL; } #endif - p = (LONG64*)soap_id_enter(soap, soap->id, p, t, sizeof(LONG64), 0, NULL, NULL, NULL); + p = (LONG64*)soap_id_enter(soap, soap->id, p, t, sizeof(LONG64), NULL, NULL, NULL, NULL); if (*soap->href) - p = (LONG64*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(LONG64), 0, NULL); + p = (LONG64*)soap_id_forward(soap, soap->href, p, 0, t, t, sizeof(LONG64), 0, NULL, NULL); else if (p) { if (soap_s2LONG64(soap, soap_value(soap), p)) return NULL; @@ -12203,6 +13566,7 @@ soap_inLONG64(struct soap *soap, const char *tag, LONG64 *p, const char *type, i #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 const char* @@ -12213,6 +13577,7 @@ soap_byte2s(struct soap *soap, char n) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -12226,6 +13591,7 @@ soap_outbyte(struct soap *soap, const char *tag, int id, const char *p, const ch #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -12244,6 +13610,7 @@ soap_s2byte(struct soap *soap, const char *s, char *p) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 char * @@ -12259,10 +13626,12 @@ soap_inbyte(struct soap *soap, const char *tag, char *p, const char *type, int t soap_revert(soap); return NULL; } +#else + (void)type; #endif - p = (char*)soap_id_enter(soap, soap->id, p, t, sizeof(char), 0, NULL, NULL, NULL); + p = (char*)soap_id_enter(soap, soap->id, p, t, sizeof(char), NULL, NULL, NULL, NULL); if (*soap->href) - p = (char*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(char), 0, NULL); + p = (char*)soap_id_forward(soap, soap->href, p, 0, t, t, sizeof(char), 0, NULL, NULL); else if (p) { if (soap_s2byte(soap, soap_value(soap), p)) return NULL; @@ -12274,6 +13643,7 @@ soap_inbyte(struct soap *soap, const char *tag, char *p, const char *type, int t #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 const char* @@ -12284,6 +13654,7 @@ soap_short2s(struct soap *soap, short n) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -12297,6 +13668,7 @@ soap_outshort(struct soap *soap, const char *tag, int id, const short *p, const #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -12315,6 +13687,7 @@ soap_s2short(struct soap *soap, const char *s, short *p) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 short * @@ -12331,10 +13704,12 @@ soap_inshort(struct soap *soap, const char *tag, short *p, const char *type, int soap_revert(soap); return NULL; } +#else + (void)type; #endif - p = (short*)soap_id_enter(soap, soap->id, p, t, sizeof(short), 0, NULL, NULL, NULL); + p = (short*)soap_id_enter(soap, soap->id, p, t, sizeof(short), NULL, NULL, NULL, NULL); if (*soap->href) - p = (short*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(short), 0, NULL); + p = (short*)soap_id_forward(soap, soap->href, p, 0, t, t, sizeof(short), 0, NULL, NULL); else if (p) { if (soap_s2short(soap, soap_value(soap), p)) return NULL; @@ -12346,31 +13721,31 @@ soap_inshort(struct soap *soap, const char *tag, short *p, const char *type, int #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 const char* SOAP_FMAC2 soap_float2s(struct soap *soap, float n) -{ char *s; +{ +#if !defined(WITH_C_LOCALE) || !defined(HAVE_SPRINTF_L) + char *s; +#endif if (soap_isnan((double)n)) return "NaN"; if (soap_ispinff(n)) return "INF"; if (soap_isninff(n)) return "-INF"; -#if defined(HAVE_SPRINTF_L) +#if defined(WITH_C_LOCALE) && defined(HAVE_SPRINTF_L) # ifdef WIN32 - _sprintf_s_l(soap->tmpbuf, _countof(soap->tmpbuf), soap->float_format, soap->c_locale, n); + _sprintf_s_l(soap->tmpbuf, _countof(soap->tmpbuf), soap->float_format, SOAP_LOCALE(soap), n); # else - sprintf_l(soap->tmpbuf, soap->c_locale, soap->float_format, n); + sprintf_l(soap->tmpbuf, SOAP_LOCALE(soap), soap->float_format, n); # endif #else -# ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), soap->float_format, n); -# else - sprintf(soap->tmpbuf, soap->float_format, n); -# endif - s = strchr(soap->tmpbuf, ','); /* convert decimal comma to DP */ + (SOAP_SNPRINTF(soap->tmpbuf, sizeof(soap->tmpbuf), 20), soap->float_format, n); + s = strchr(soap->tmpbuf, ','); /* convert decimal comma to DP */ if (s) *s = '.'; #endif @@ -12379,6 +13754,7 @@ soap_float2s(struct soap *soap, float n) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -12392,6 +13768,7 @@ soap_outfloat(struct soap *soap, const char *tag, int id, const float *p, const #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -12411,38 +13788,43 @@ soap_s2float(struct soap *soap, const char *s, float *p) else { /* On some systems strtof requires -std=c99 or does not even link: so we try to use strtod first */ -#if defined(HAVE_STRTOD_L) +#if defined(WITH_C_LOCALE) && defined(HAVE_STRTOD_L) char *r; # ifdef WIN32 - *p = (float)_strtod_l(s, &r, soap->c_locale); + *p = (float)_strtod_l(s, &r, SOAP_LOCALE(soap)); # else - *p = (float)strtod_l(s, &r, soap->c_locale); + *p = (float)strtod_l(s, &r, SOAP_LOCALE(soap)); # endif if (*r) + soap->error = SOAP_TYPE; #elif defined(HAVE_STRTOD) char *r; *p = (float)strtod(s, &r); if (*r) -#elif defined(HAVE_STRTOF_L) + soap->error = SOAP_TYPE; +#elif defined(WITH_C_LOCALE) && defined(HAVE_STRTOF_L) char *r; - *p = strtof_l((char*)s, &r, soap->c_locale); + *p = strtof_l((char*)s, &r, SOAP_LOCALE(soap)); if (*r) + soap->error = SOAP_TYPE; #elif defined(HAVE_STRTOF) char *r; *p = strtof((char*)s, &r); if (*r) -#endif - { -#if defined(HAVE_SSCANF_L) && !defined(HAVE_STRTOF_L) && !defined(HAVE_STRTOD_L) - if (sscanf_l(s, soap->c_locale, "%f", p) != 1) - soap->error = SOAP_TYPE; + soap->error = SOAP_TYPE; +#elif defined(WITH_C_LOCALE) && defined(HAVE_SSCANF_L) && !defined(HAVE_STRTOF_L) && !defined(HAVE_STRTOD_L) + double n; + if (sscanf_l(s, SOAP_LOCALE(soap), "%lf", &n) != 1) + soap->error = SOAP_TYPE; + *p = (float)n; #elif defined(HAVE_SSCANF) - if (sscanf(s, "%f", p) != 1) - soap->error = SOAP_TYPE; -#else + double n; + if (sscanf(s, "%lf", &n) != 1) soap->error = SOAP_TYPE; + *p = (float)n; +#else + soap->error = SOAP_TYPE; #endif - } } } return soap->error; @@ -12450,6 +13832,7 @@ soap_s2float(struct soap *soap, const char *s, float *p) #endif /******************************************************************************/ + #ifndef WITH_LEAN static int soap_isnumeric(struct soap *soap, const char *type) { if (soap_match_tag(soap, soap->type, type) @@ -12478,6 +13861,7 @@ static int soap_isnumeric(struct soap *soap, const char *type) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 float * @@ -12488,10 +13872,12 @@ soap_infloat(struct soap *soap, const char *tag, float *p, const char *type, int #ifndef WITH_LEAN if (*soap->type != '\0' && soap_isnumeric(soap, type)) return NULL; +#else + (void)type; #endif - p = (float*)soap_id_enter(soap, soap->id, p, t, sizeof(float), 0, NULL, NULL, NULL); + p = (float*)soap_id_enter(soap, soap->id, p, t, sizeof(float), NULL, NULL, NULL, NULL); if (*soap->href) - p = (float*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(float), 0, NULL); + p = (float*)soap_id_forward(soap, soap->href, p, 0, t, t, sizeof(float), 0, NULL, NULL); else if (p) { if (soap_s2float(soap, soap_value(soap), p)) return NULL; @@ -12503,31 +13889,31 @@ soap_infloat(struct soap *soap, const char *tag, float *p, const char *type, int #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 const char* SOAP_FMAC2 soap_double2s(struct soap *soap, double n) -{ char *s; +{ +#if !defined(WITH_C_LOCALE) || !defined(HAVE_SPRINTF_L) + char *s; +#endif if (soap_isnan(n)) return "NaN"; if (soap_ispinfd(n)) return "INF"; if (soap_isninfd(n)) return "-INF"; -#if defined(HAVE_SPRINTF_L) +#if defined(WITH_C_LOCALE) && defined(HAVE_SPRINTF_L) # ifdef WIN32 - _sprintf_s_l(soap->tmpbuf, _countof(soap->tmpbuf), soap->double_format, soap->c_locale, n); + _sprintf_s_l(soap->tmpbuf, _countof(soap->tmpbuf), soap->double_format, SOAP_LOCALE(soap), n); # else - sprintf_l(soap->tmpbuf, soap->c_locale, soap->double_format, n); + sprintf_l(soap->tmpbuf, SOAP_LOCALE(soap), soap->double_format, n); # endif #else -# ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), soap->double_format, n); -#else - sprintf(soap->tmpbuf, soap->double_format, n); -#endif - s = strchr(soap->tmpbuf, ','); /* convert decimal comma to DP */ + (SOAP_SNPRINTF(soap->tmpbuf, sizeof(soap->tmpbuf), 40), soap->double_format, n); + s = strchr(soap->tmpbuf, ','); /* convert decimal comma to DP */ if (s) *s = '.'; #endif @@ -12536,6 +13922,7 @@ soap_double2s(struct soap *soap, double n) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -12549,6 +13936,7 @@ soap_outdouble(struct soap *soap, const char *tag, int id, const double *p, cons #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -12567,30 +13955,29 @@ soap_s2double(struct soap *soap, const char *s, double *p) *p = DBL_NAN; else { -#if defined(HAVE_STRTOD_L) +#if defined(WITH_C_LOCALE) && defined(HAVE_STRTOD_L) char *r; # ifdef WIN32 - *p = _strtod_l(s, &r, soap->c_locale); + *p = _strtod_l(s, &r, SOAP_LOCALE(soap)); # else - *p = strtod_l(s, &r, soap->c_locale); + *p = strtod_l(s, &r, SOAP_LOCALE(soap)); # endif if (*r) + soap->error = SOAP_TYPE; #elif defined(HAVE_STRTOD) char *r; *p = strtod(s, &r); if (*r) -#endif - { -#if defined(HAVE_SSCANF_L) && !defined(HAVE_STRTOF_L) && !defined(HAVE_STRTOD_L) - if (sscanf_l(s, soap->c_locale, "%lf", p) != 1) - soap->error = SOAP_TYPE; + soap->error = SOAP_TYPE; +#elif defined(WITH_C_LOCALE) && defined(HAVE_SSCANF_L) && !defined(HAVE_STRTOF_L) && !defined(HAVE_STRTOD_L) + if (sscanf_l(s, SOAP_LOCALE(soap), "%lf", p) != 1) + soap->error = SOAP_TYPE; #elif defined(HAVE_SSCANF) - if (sscanf(s, "%lf", p) != 1) - soap->error = SOAP_TYPE; -#else + if (sscanf(s, "%lf", p) != 1) soap->error = SOAP_TYPE; +#else + soap->error = SOAP_TYPE; #endif - } } } return soap->error; @@ -12598,6 +13985,7 @@ soap_s2double(struct soap *soap, const char *s, double *p) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 double * @@ -12608,10 +13996,12 @@ soap_indouble(struct soap *soap, const char *tag, double *p, const char *type, i #ifndef WITH_LEAN if (*soap->type != '\0' && soap_isnumeric(soap, type)) return NULL; +#else + (void)type; #endif - p = (double*)soap_id_enter(soap, soap->id, p, t, sizeof(double), 0, NULL, NULL, NULL); + p = (double*)soap_id_enter(soap, soap->id, p, t, sizeof(double), NULL, NULL, NULL, NULL); if (*soap->href) - p = (double*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(double), 0, NULL); + p = (double*)soap_id_forward(soap, soap->href, p, 0, t, t, sizeof(double), 0, NULL, NULL); else if (p) { if (soap_s2double(soap, soap_value(soap), p)) return NULL; @@ -12623,6 +14013,7 @@ soap_indouble(struct soap *soap, const char *tag, double *p, const char *type, i #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 const char* @@ -12633,6 +14024,7 @@ soap_unsignedByte2s(struct soap *soap, unsigned char n) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -12646,16 +14038,17 @@ soap_outunsignedByte(struct soap *soap, const char *tag, int id, const unsigned #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 soap_s2unsignedByte(struct soap *soap, const char *s, unsigned char *p) { if (s) - { unsigned long n; + { long n; char *r; - n = soap_strtoul(s, &r, 10); - if (s == r || *r || n > 255) + n = soap_strtol(s, &r, 10); + if (s == r || *r || n < 0 || n > 255) soap->error = SOAP_TYPE; *p = (unsigned char)n; } @@ -12664,6 +14057,7 @@ soap_s2unsignedByte(struct soap *soap, const char *s, unsigned char *p) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 unsigned char * @@ -12679,10 +14073,12 @@ soap_inunsignedByte(struct soap *soap, const char *tag, unsigned char *p, const soap_revert(soap); return NULL; } +#else + (void)type; #endif - p = (unsigned char*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned char), 0, NULL, NULL, NULL); + p = (unsigned char*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned char), NULL, NULL, NULL, NULL); if (*soap->href) - p = (unsigned char*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(unsigned char), 0, NULL); + p = (unsigned char*)soap_id_forward(soap, soap->href, p, 0, t, t, sizeof(unsigned char), 0, NULL, NULL); else if (p) { if (soap_s2unsignedByte(soap, soap_value(soap), p)) return NULL; @@ -12694,6 +14090,7 @@ soap_inunsignedByte(struct soap *soap, const char *tag, unsigned char *p, const #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 const char* @@ -12704,6 +14101,7 @@ soap_unsignedShort2s(struct soap *soap, unsigned short n) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -12717,16 +14115,17 @@ soap_outunsignedShort(struct soap *soap, const char *tag, int id, const unsigned #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 soap_s2unsignedShort(struct soap *soap, const char *s, unsigned short *p) { if (s) - { unsigned long n; + { long n; char *r; - n = soap_strtoul(s, &r, 10); - if (s == r || *r || n > 65535) + n = soap_strtol(s, &r, 10); + if (s == r || *r || n < 0 || n > 65535) soap->error = SOAP_TYPE; *p = (unsigned short)n; } @@ -12735,6 +14134,7 @@ soap_s2unsignedShort(struct soap *soap, const char *s, unsigned short *p) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 unsigned short * @@ -12751,10 +14151,12 @@ soap_inunsignedShort(struct soap *soap, const char *tag, unsigned short *p, cons soap_revert(soap); return NULL; } +#else + (void)type; #endif - p = (unsigned short*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned short), 0, NULL, NULL, NULL); + p = (unsigned short*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned short), NULL, NULL, NULL, NULL); if (*soap->href) - p = (unsigned short*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(unsigned short), 0, NULL); + p = (unsigned short*)soap_id_forward(soap, soap->href, p, 0, t, t, sizeof(unsigned short), 0, NULL, NULL); else if (p) { if (soap_s2unsignedShort(soap, soap_value(soap), p)) return NULL; @@ -12766,6 +14168,7 @@ soap_inunsignedShort(struct soap *soap, const char *tag, unsigned short *p, cons #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 const char* @@ -12776,6 +14179,7 @@ soap_unsignedInt2s(struct soap *soap, unsigned int n) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -12789,6 +14193,7 @@ soap_outunsignedInt(struct soap *soap, const char *tag, int id, const unsigned i #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -12802,7 +14207,7 @@ soap_s2unsignedInt(struct soap *soap, const char *s, unsigned int *p) #endif #endif *p = (unsigned int)soap_strtoul(s, &r, 10); - if ((s == r && (soap->mode & SOAP_XML_STRICT)) || *r + if (s == r || *r #ifndef WITH_NOIO #ifndef WITH_LEAN || soap_errno == SOAP_ERANGE @@ -12810,12 +14215,17 @@ soap_s2unsignedInt(struct soap *soap, const char *s, unsigned int *p) #endif ) soap->error = SOAP_TYPE; +#ifdef HAVE_STRTOUL + if (*p > 0 && strchr(s, '-')) + return soap->error = SOAP_TYPE; +#endif } return soap->error; } #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 unsigned int * @@ -12833,10 +14243,12 @@ soap_inunsignedInt(struct soap *soap, const char *tag, unsigned int *p, const ch soap_revert(soap); return NULL; } +#else + (void)type; #endif - p = (unsigned int*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned int), 0, NULL, NULL, NULL); + p = (unsigned int*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned int), NULL, NULL, NULL, NULL); if (*soap->href) - p = (unsigned int*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(unsigned int), 0, NULL); + p = (unsigned int*)soap_id_forward(soap, soap->href, p, 0, t, t, sizeof(unsigned int), 0, NULL, NULL); else if (p) { if (soap_s2unsignedInt(soap, soap_value(soap), p)) return NULL; @@ -12848,22 +14260,19 @@ soap_inunsignedInt(struct soap *soap, const char *tag, unsigned int *p, const ch #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 const char* SOAP_FMAC2 soap_unsignedLong2s(struct soap *soap, unsigned long n) -{ -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), "%lu", n); -#else - sprintf(soap->tmpbuf, "%lu", n); -#endif +{ (SOAP_SNPRINTF(soap->tmpbuf, sizeof(soap->tmpbuf), 20), "%lu", n); return soap->tmpbuf; } #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -12877,6 +14286,7 @@ soap_outunsignedLong(struct soap *soap, const char *tag, int id, const unsigned #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -12890,7 +14300,7 @@ soap_s2unsignedLong(struct soap *soap, const char *s, unsigned long *p) #endif #endif *p = soap_strtoul(s, &r, 10); - if ((s == r && (soap->mode & SOAP_XML_STRICT)) || *r + if (s == r || *r #ifndef WITH_NOIO #ifndef WITH_LEAN || soap_errno == SOAP_ERANGE @@ -12898,12 +14308,17 @@ soap_s2unsignedLong(struct soap *soap, const char *s, unsigned long *p) #endif ) soap->error = SOAP_TYPE; +#ifdef HAVE_STRTOUL + if (*p > 0 && strchr(s, '-')) + return soap->error = SOAP_TYPE; +#endif } return soap->error; } #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 unsigned long * @@ -12921,10 +14336,12 @@ soap_inunsignedLong(struct soap *soap, const char *tag, unsigned long *p, const soap_revert(soap); return NULL; } +#else + (void)type; #endif - p = (unsigned long*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned long), 0, NULL, NULL, NULL); + p = (unsigned long*)soap_id_enter(soap, soap->id, p, t, sizeof(unsigned long), NULL, NULL, NULL, NULL); if (*soap->href) - p = (unsigned long*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(unsigned long), 0, NULL); + p = (unsigned long*)soap_id_forward(soap, soap->href, p, 0, t, t, sizeof(unsigned long), 0, NULL, NULL); else if (p) { if (soap_s2unsignedLong(soap, soap_value(soap), p)) return NULL; @@ -12936,23 +14353,20 @@ soap_inunsignedLong(struct soap *soap, const char *tag, unsigned long *p, const #endif /******************************************************************************/ -#ifndef WITH_LEAN + +#ifndef PALM_2 SOAP_FMAC1 const char* SOAP_FMAC2 soap_ULONG642s(struct soap *soap, ULONG64 n) -{ -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), SOAP_ULONG_FORMAT, n); -#else - sprintf(soap->tmpbuf, SOAP_ULONG_FORMAT, n); -#endif +{ (SOAP_SNPRINTF(soap->tmpbuf, sizeof(soap->tmpbuf), 20), SOAP_ULONG_FORMAT, n); return soap->tmpbuf; } #endif /******************************************************************************/ -#ifndef WITH_LEAN + +#ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 @@ -12965,41 +14379,38 @@ soap_outULONG64(struct soap *soap, const char *tag, int id, const ULONG64 *p, co #endif /******************************************************************************/ -#ifndef WITH_LEAN + +#ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 soap_s2ULONG64(struct soap *soap, const char *s, ULONG64 *p) { if (s) - { -#ifdef HAVE_STRTOULL - char *r; + { char *r; #ifndef WITH_NOIO #ifndef WITH_LEAN soap_reset_errno; #endif #endif *p = soap_strtoull(s, &r, 10); - if ((s == r && (soap->mode & SOAP_XML_STRICT)) || *r + if (s == r || *r #ifndef WITH_NOIO #ifndef WITH_LEAN || soap_errno == SOAP_ERANGE #endif #endif ) -#else -#ifdef HAVE_SSCANF - if (sscanf(s, SOAP_ULONG_FORMAT, p) != 1) -#endif -#endif soap->error = SOAP_TYPE; + if (*p > 0 && strchr(s, '-')) + return soap->error = SOAP_TYPE; } return soap->error; } #endif /******************************************************************************/ -#ifndef WITH_LEAN + +#ifndef PALM_2 SOAP_FMAC1 ULONG64 * SOAP_FMAC2 @@ -13018,9 +14429,9 @@ soap_inULONG64(struct soap *soap, const char *tag, ULONG64 *p, const char *type, soap_revert(soap); return NULL; } - p = (ULONG64*)soap_id_enter(soap, soap->id, p, t, sizeof(ULONG64), 0, NULL, NULL, NULL); + p = (ULONG64*)soap_id_enter(soap, soap->id, p, t, sizeof(ULONG64), NULL, NULL, NULL, NULL); if (*soap->href) - p = (ULONG64*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(ULONG64), 0, NULL); + p = (ULONG64*)soap_id_forward(soap, soap->href, p, 0, t, t, sizeof(ULONG64), 0, NULL, NULL); else if (p) { if (soap_s2ULONG64(soap, soap_value(soap), p)) return NULL; @@ -13032,47 +14443,148 @@ soap_inULONG64(struct soap *soap, const char *tag, ULONG64 *p, const char *type, #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 -soap_s2string(struct soap *soap, const char *s, char **t, long minlen, long maxlen) +soap_s2char(struct soap *soap, const char *s, char **t, long minlen, long maxlen, const char *pattern) { if (s) - { long l = (long)strlen(s); - if ((maxlen >= 0 && l > maxlen) || l < minlen) - return soap->error = SOAP_LENGTH; - if (!(*t = soap_strdup(soap, s))) + { const char *r = soap_string(soap, s, minlen, maxlen, pattern); + if (r && (*t = soap_strdup(soap, r)) == NULL) return soap->error = SOAP_EOM; - if (!(soap->mode & (SOAP_ENC_LATIN | SOAP_C_UTFSTRING))) - { char *r = *t; - /* remove non-ASCII chars */ - for (s = *t; *s; s++) - if (!(*s & 0x80)) - *r++ = *s; - *r = '\0'; + } + return soap->error; +} +#endif + +/******************************************************************************/ + +#ifndef WITH_COMPAT +#ifdef __cplusplus +#ifndef PALM_2 +SOAP_FMAC1 +int +SOAP_FMAC2 +soap_s2stdchar(struct soap *soap, const char *s, std::string *t, long minlen, long maxlen, const char *pattern) +{ if (s) + { const char *r = soap_string(soap, s, minlen, maxlen, pattern); + if (r) + t->assign(r); + } + return soap->error; +} +#endif +#endif +#endif + +/******************************************************************************/ + +#ifndef PALM_2 +static const char* +soap_string(struct soap *soap, const char *s, long minlen, long maxlen, const char *pattern) +{ if (s) + { if (maxlen < 0 && soap->maxlength > 0) + maxlen = soap->maxlength; + if (minlen > 0 || maxlen >= 0) + { long l; + if ((soap->mode & SOAP_C_UTFSTRING)) + l = (long)soap_utf8len(s); + else + l = (long)strlen(s); + if ((maxlen >= 0 && l > maxlen) || l < minlen) + { soap->error = SOAP_LENGTH; + return NULL; + } } +#ifndef WITH_LEANER + if (pattern && soap->fsvalidate) + { soap->error = soap->fsvalidate(soap, pattern, s); + if (soap->error) + return NULL; + } +#else + (void)pattern; +#endif + } + return s; +} +#endif + +/******************************************************************************/ + +#ifndef PALM_2 +SOAP_FMAC1 +int +SOAP_FMAC2 +soap_s2QName(struct soap *soap, const char *s, char **t, long minlen, long maxlen, const char *pattern) +{ if (s) + { const char *r = soap_QName(soap, s, minlen, maxlen, pattern); + if (r && (*t = soap_strdup(soap, r)) == NULL) + return soap->error = SOAP_EOM; } return soap->error; } #endif /******************************************************************************/ + +#ifndef WITH_COMPAT +#ifdef __cplusplus #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 -soap_s2QName(struct soap *soap, const char *s, char **t, long minlen, long maxlen) +soap_s2stdQName(struct soap *soap, const char *s, std::string *t, long minlen, long maxlen, const char *pattern) { if (s) - { long l = (long)strlen(s); - if ((maxlen >= 0 && l > maxlen) || l < minlen) - return soap->error = SOAP_LENGTH; + { const char *r = soap_QName(soap, s, minlen, maxlen, pattern); + if (r) + t->assign(r); + } + return soap->error; +} +#endif +#endif +#endif + +/******************************************************************************/ + +#ifndef PALM_2 +static const char* +soap_QName(struct soap *soap, const char *s, long minlen, long maxlen, const char *pattern) +{ if (s) + { char *b; + if (maxlen < 0 && soap->maxlength > 0) + maxlen = soap->maxlength; + if (minlen > 0 || maxlen >= 0) + { long l; + if ((soap->mode & SOAP_C_UTFSTRING)) + l = (long)soap_utf8len(s); + else + l = (long)strlen(s); + if ((maxlen >= 0 && l > maxlen) || l < minlen) + { soap->error = SOAP_LENGTH; + return NULL; + } + } +#ifdef WITH_FAST soap->labidx = 0; +#else + if (soap_new_block(soap) == NULL) + return NULL; +#endif DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Normalized namespace(s) of QNames '%s'", s)); /* convert (by prefix normalize prefix) all QNames in s */ for (;;) { size_t n; struct soap_nlist *np; - register const char *p; + const char *p = NULL; + short flag = 0; + const char *r = NULL; + size_t m = 0; +#ifndef WITH_FAST + size_t k = 0; +#endif /* skip blanks */ while (*s && soap_blank((soap_wchar)*s)) s++; @@ -13085,7 +14597,8 @@ soap_s2QName(struct soap *soap, const char *s, char **t, long minlen, long maxle np = soap->nlist; /* if there is no namespace stack, or prefix is "#" or "xml" then copy string */ if (!np || *s == '#' || !strncmp(s, "xml:", 4)) - { soap_append_lab(soap, s, n); + { r = s; + m = n; } else /* we normalize the QName by replacing its prefix */ { const char *q; @@ -13105,49 +14618,110 @@ soap_s2QName(struct soap *soap, const char *s, char **t, long minlen, long maxle } /* replace prefix */ if (np) - { if (np->index >= 0 && soap->local_namespaces && (q = soap->local_namespaces[np->index].id)) + { if (np->index >= 0 && soap->local_namespaces && (q = soap->local_namespaces[np->index].id) != NULL) { size_t k = strlen(q); if (q[k-1] != '_') - soap_append_lab(soap, q, k); + { r = q; + m = k; + } else - { soap_append_lab(soap, "\"", 1); - soap_append_lab(soap, soap->local_namespaces[np->index].ns, strlen(soap->local_namespaces[np->index].ns)); - soap_append_lab(soap, "\"", 1); + { flag = 1; + r = soap->local_namespaces[np->index].ns; + m = strlen(r); } } else if (np->ns) - { soap_append_lab(soap, "\"", 1); - soap_append_lab(soap, np->ns, strlen(np->ns)); - soap_append_lab(soap, "\"", 1); + { flag = 1; + r = np->ns; + m = strlen(r); } else { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "\nNamespace prefix of '%s' not defined (index=%d, URI='%s')\n", s, np->index, np->ns ? np->ns : SOAP_STR_EOS)); - return soap->error = SOAP_NAMESPACE; + soap->error = SOAP_NAMESPACE; + return NULL; } } else if (s[n]) /* no namespace, part of string */ - { soap_append_lab(soap, s, n); + { r = s; + m = n; } else /* no namespace: assume "" namespace */ - { soap_append_lab(soap, "\"\"", 2); + { flag = 1; + } + } +#ifdef WITH_FAST + if ((flag && soap_append_lab(soap, "\"", 1)) + || (m && soap_append_lab(soap, r, m)) + || (flag && soap_append_lab(soap, "\"", 1)) + || (p && (soap_append_lab(soap, ":", 1) || soap_append_lab(soap, p, n - (p-s))))) + return NULL; +#else + k = 2*flag + m + (p ? n - (p-s) + 1 : 0) + (s[n] != '\0'); + b = (char*)soap_push_block(soap, NULL, k); + if (!b) + return NULL; + if (flag) + *b++ = '"'; + if (m) + { if (soap_memcpy((void*)b, k, (const void*)r, m)) + { soap->error = SOAP_EOM; + return NULL; + } + b += m; + } + if (flag) + *b++ = '"'; + if (p) + { *b++ = ':'; + if (soap_memcpy((void*)b, k - m - flag - 1, (const void*)p, n - (p-s))) + { soap->error = SOAP_EOM; + return NULL; } - soap_append_lab(soap, ":", 1); - soap_append_lab(soap, p, n - (p-s)); + b += n - (p-s); } +#endif /* advance to next and add spacing */ s += n; + while (*s && soap_blank(*s)) + s++; if (*s) - soap_append_lab(soap, " ", 1); + { +#ifdef WITH_FAST + if (soap_append_lab(soap, " ", 1)) + return NULL; +#else + *b = ' '; +#endif + } } - soap_append_lab(soap, SOAP_STR_EOS, 1); - *t = soap_strdup(soap, soap->labbuf); - DBGLOG(TEST, SOAP_MESSAGE(fdebug, " into '%s'\n", *t)); +#ifdef WITH_FAST + if (soap_append_lab(soap, SOAP_STR_EOS, 1)) + return NULL; + b = soap->labbuf; +#else + b = (char*)soap_push_block(soap, NULL, 1); + if (!b) + return NULL; + *b = '\0'; + b = (char*)soap_save_block(soap, NULL, NULL, 0); +#endif +#ifndef WITH_LEANER + if (pattern && soap->fsvalidate) + { soap->error = soap->fsvalidate(soap, pattern, b); + if (soap->error) + return NULL; + } +#else + (void)pattern; +#endif + return b; } - return soap->error; + return NULL; } #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 const char* @@ -13155,16 +14729,39 @@ SOAP_FMAC2 soap_QName2s(struct soap *soap, const char *s) { const char *t = NULL; if (s) - { soap->labidx = 0; + { +#ifdef WITH_FAST + soap->labidx = 0; +#else + char *b = NULL; + if (soap_new_block(soap) == NULL) + return NULL; +#endif for (;;) { size_t n; + const char *q = NULL; + const char *r = NULL; + size_t m = 0; +#ifndef WITH_FAST + size_t k = 0; +#endif /* skip blanks */ while (*s && soap_blank((soap_wchar)*s)) s++; if (!*s) + { +#ifdef WITH_FAST + soap->labbuf[soap->labidx > 0 ? soap->labidx - 1 : 0] = '\0'; +#else + if (!b) + return soap_strdup(soap, SOAP_STR_EOS); + --b; + *b = '\0'; +#endif break; + } /* find next QName */ - n = 1; + n = 0; while (s[n] && !soap_blank((soap_wchar)s[n])) n++; /* normal prefix: pass string as is */ @@ -13174,18 +14771,18 @@ soap_QName2s(struct soap *soap, const char *s) if ((soap->mode & SOAP_XML_CANONICAL)) soap_utilize_ns(soap, s); if ((soap->mode & SOAP_XML_DEFAULTNS)) - { const char *r = strchr(s, ':'); - if (r && soap->nlist && !strncmp(soap->nlist->id, s, r-s) && !soap->nlist->id[r-s]) - { n -= r-s + 1; + { r = strchr(s, ':'); + if (r && soap->nlist && !strncmp(soap->nlist->id, s, r - s) && !soap->nlist->id[r - s]) + { n -= r - s + 1; s = r + 1; } } #endif - soap_append_lab(soap, s, n); + r = s; + m = n + 1; } else /* URL-based string prefix */ - { const char *q; - s++; + { s++; q = strchr(s, '"'); if (q) { struct Namespace *p = soap->local_namespaces; @@ -13199,108 +14796,187 @@ soap_QName2s(struct soap *soap, const char *s) break; } } + q++; /* URL is in the namespace table? */ if (p && p->id) - { const char *r = p->id; + { r = p->id; #ifndef WITH_LEAN if ((soap->mode & SOAP_XML_DEFAULTNS) && soap->nlist && !strcmp(soap->nlist->id, r)) q++; else #endif - soap_append_lab(soap, r, strlen(r)); + m = strlen(r); } else /* not in namespace table: create xmlns binding */ - { char *r = soap_strdup(soap, s); - r[q-s] = '\0'; -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), "xmlns:_%d", soap->idnum++); -#else - sprintf(soap->tmpbuf, "xmlns:_%d", soap->idnum++); -#endif - soap_set_attr(soap, soap->tmpbuf, r, 1); - soap_append_lab(soap, soap->tmpbuf + 6, strlen(soap->tmpbuf + 6)); + { char *x = soap_strdup(soap, s); + x[q - s - 1] = '\0'; + (SOAP_SNPRINTF(soap->tmpbuf, sizeof(soap->tmpbuf), 27), "xmlns:_%d", soap->idnum++); + soap_set_attr(soap, soap->tmpbuf, x, 1); + r = soap->tmpbuf + 6; + m = strlen(r); } - soap_append_lab(soap, q + 1, n - (q-s) - 1); } } - /* advance to next and add spacing */ + /* copy normalized QName into buffer, including the ending blank or NUL */ +#ifdef WITH_FAST + if ((m && soap_append_lab(soap, r, m)) + || (q && soap_append_lab(soap, q, n - (q - s)))) + return NULL; +#else + k = m + (q ? n - (q - s) : 0); + b = (char*)soap_push_block(soap, NULL, k); + if (!b) + { soap->error = SOAP_EOM; + return NULL; + } + if (soap_memcpy((void*)b, k, (const void*)r, m)) + { soap->error = SOAP_EOM; + return NULL; + } + b += m; + if (q) + { if (soap_memcpy((void*)b, k - m, (const void*)q, n - (q - s))) + { soap->error = SOAP_EOM; + return NULL; + } + b += n - (q - s); + } +#endif + /* advance to next */ s += n; - if (*s) - soap_append_lab(soap, " ", 1); } - soap_append_lab(soap, SOAP_STR_EOS, 1); +#ifdef WITH_FAST t = soap_strdup(soap, soap->labbuf); +#else + t = (char*)soap_save_block(soap, NULL, NULL, 0); +#endif } return t; } #endif /******************************************************************************/ + #ifndef WITH_LEAN SOAP_FMAC1 int SOAP_FMAC2 -soap_s2wchar(struct soap *soap, const char *s, wchar_t **t, long minlen, long maxlen) +soap_s2wchar(struct soap *soap, const char *s, wchar_t **t, long minlen, long maxlen, const char *pattern) { if (s) - { long l; - wchar_t *r; - *t = r = (wchar_t*)soap_malloc(soap, sizeof(wchar_t) * (strlen(s) + 1)); - if (!r) + { const wchar_t *r = soap_wstring(soap, s, minlen, maxlen, pattern); + if (r && (*t = soap_wstrdup(soap, r)) == NULL) return soap->error = SOAP_EOM; + } + return soap->error; +} +#endif + +/******************************************************************************/ + +#ifndef WITH_COMPAT +#ifdef __cplusplus +#ifndef WITH_LEAN +SOAP_FMAC1 +int +SOAP_FMAC2 +soap_s2stdwchar(struct soap *soap, const char *s, std::wstring *t, long minlen, long maxlen, const char *pattern) +{ if (s) + { const wchar_t *r = soap_wstring(soap, s, minlen, maxlen, pattern); + if (r) + t->assign(r); + } + return soap->error; +} +#endif +#endif +#endif + +/******************************************************************************/ + +#ifndef WITH_LEAN +static const wchar_t* +soap_wstring(struct soap *soap, const char *s, long minlen, long maxlen, const char *pattern) +{ if (s) + { long l; + wchar_t wc; + if (maxlen < 0 && soap->maxlength > 0) + maxlen = soap->maxlength; + soap->labidx = 0; if (soap->mode & SOAP_ENC_LATIN) - { while (*s) + { wchar_t *r; + if (soap_append_lab(soap, NULL, sizeof(wchar_t) * (strlen(s) + 1))) + return NULL; + r = (wchar_t*)soap->labbuf; + while (*s) *r++ = (wchar_t)*s++; } else { /* Convert UTF8 to wchar */ while (*s) - { register soap_wchar c, c1, c2, c3, c4; + { soap_wchar c, c1, c2, c3, c4; c = (unsigned char)*s++; if (c < 0x80) - *r++ = (wchar_t)c; + wc = (wchar_t)c; else { c1 = (soap_wchar)*s++ & 0x3F; if (c < 0xE0) - *r++ = (wchar_t)(((soap_wchar)(c & 0x1F) << 6) | c1); + wc = (wchar_t)(((soap_wchar)(c & 0x1F) << 6) | c1); else { c2 = (soap_wchar)*s++ & 0x3F; if (c < 0xF0) - *r++ = (wchar_t)(((soap_wchar)(c & 0x0F) << 12) | (c1 << 6) | c2); + wc = (wchar_t)(((soap_wchar)(c & 0x0F) << 12) | (c1 << 6) | c2); else { c3 = (soap_wchar)*s++ & 0x3F; if (c < 0xF8) - *r++ = (wchar_t)(((soap_wchar)(c & 0x07) << 18) | (c1 << 12) | (c2 << 6) | c3); + wc = (wchar_t)(((soap_wchar)(c & 0x07) << 18) | (c1 << 12) | (c2 << 6) | c3); else { c4 = (soap_wchar)*s++ & 0x3F; if (c < 0xFC) - *r++ = (wchar_t)(((soap_wchar)(c & 0x03) << 24) | (c1 << 18) | (c2 << 12) | (c3 << 6) | c4); + wc = (wchar_t)(((soap_wchar)(c & 0x03) << 24) | (c1 << 18) | (c2 << 12) | (c3 << 6) | c4); else - *r++ = (wchar_t)(((soap_wchar)(c & 0x01) << 30) | (c1 << 24) | (c2 << 18) | (c3 << 12) | (c4 << 6) | (soap_wchar)(*s++ & 0x3F)); + wc = (wchar_t)(((soap_wchar)(c & 0x01) << 30) | (c1 << 24) | (c2 << 18) | (c3 << 12) | (c4 << 6) | (soap_wchar)(*s++ & 0x3F)); } } } } + if (soap_append_lab(soap, (const char*)&wc, sizeof(wc))) + return NULL; } } - *r = L'\0'; - l = (long)(r - *t); + l = (long)(soap->labidx / sizeof(wchar_t)); + wc = L'\0'; + if (soap_append_lab(soap, (const char*)&wc, sizeof(wc))) + return NULL; if ((maxlen >= 0 && l > maxlen) || l < minlen) - return soap->error = SOAP_LENGTH; + { soap->error = SOAP_LENGTH; + return NULL; + } +#ifndef WITH_LEANER + if (pattern && soap->fwvalidate) + { soap->error = soap->fwvalidate(soap, pattern, (wchar_t*)soap->labbuf); + if (soap->error) + return NULL; + } +#endif + return (wchar_t*)soap->labbuf; } - return soap->error; + return NULL; } #endif /******************************************************************************/ + #ifndef WITH_LEAN SOAP_FMAC1 const char* SOAP_FMAC2 soap_wchar2s(struct soap *soap, const wchar_t *s) -{ register soap_wchar c; - register char *r, *t; +{ soap_wchar c; + char *r, *t; const wchar_t *q = s; size_t n = 0; + if (!s) + return NULL; while ((c = *q++)) { if (c > 0 && c < 0x80) n++; @@ -13345,12 +15021,13 @@ soap_wchar2s(struct soap *soap, const wchar_t *s) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 soap_outstring(struct soap *soap, const char *tag, int id, char *const*p, const char *type, int n) -{ id = soap_element_id(soap, tag, id, *p, NULL, 0, type, n); +{ id = soap_element_id(soap, tag, id, *p, NULL, 0, type, n, NULL); if (id < 0) return soap->error; if (!**p && (soap->mode & SOAP_C_NILSTRING)) @@ -13364,11 +15041,12 @@ soap_outstring(struct soap *soap, const char *tag, int id, char *const*p, const #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 char ** SOAP_FMAC2 -soap_instring(struct soap *soap, const char *tag, char **p, const char *type, int t, int flag, long minlen, long maxlen) +soap_instring(struct soap *soap, const char *tag, char **p, const char *type, int t, int flag, long minlen, long maxlen, const char *pattern) { (void)type; if (soap_element_begin_in(soap, tag, 1, NULL)) { if (!tag || *tag != '-' || soap->error != SOAP_NO_TAG) @@ -13376,14 +15054,15 @@ soap_instring(struct soap *soap, const char *tag, char **p, const char *type, in soap->error = SOAP_OK; } if (!p) - { if (!(p = (char**)soap_malloc(soap, sizeof(char*)))) + { p = (char**)soap_malloc(soap, sizeof(char*)); + if (!p) return NULL; } if (soap->null) *p = NULL; else if (soap->body) - { *p = soap_string_in(soap, flag, minlen, maxlen); - if (!*p || !(char*)soap_id_enter(soap, soap->id, *p, t, sizeof(char*), 0, NULL, NULL, NULL)) + { *p = soap_string_in(soap, flag, minlen, maxlen, pattern); + if (!*p || !(char*)soap_id_enter(soap, soap->id, *p, t, sizeof(char*), NULL, NULL, NULL, NULL)) return NULL; if (!**p && tag && *tag == '-') { soap->error = SOAP_NO_TAG; @@ -13394,14 +15073,15 @@ soap_instring(struct soap *soap, const char *tag, char **p, const char *type, in { soap->error = SOAP_NO_TAG; return NULL; } - else if (!*soap->href && minlen > 0) - { soap->error = SOAP_LENGTH; - return NULL; - } - else + else if (!*soap->href) + { if (minlen > 0) + { soap->error = SOAP_LENGTH; + return NULL; + } *p = soap_strdup(soap, SOAP_STR_EOS); + } if (*soap->href) - p = (char**)soap_id_lookup(soap, soap->href, (void**)p, t, sizeof(char**), 0); + p = (char**)soap_id_lookup(soap, soap->href, (void**)p, t, sizeof(char**), 0, NULL); if (soap->body && soap_element_end_in(soap, tag)) return NULL; return p; @@ -13409,13 +15089,14 @@ soap_instring(struct soap *soap, const char *tag, char **p, const char *type, in #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 soap_outwstring(struct soap *soap, const char *tag, int id, wchar_t *const*p, const char *type, int n) -{ id = soap_element_id(soap, tag, id, *p, NULL, 0, type, n); +{ id = soap_element_id(soap, tag, id, *p, NULL, 0, type, n, NULL); if (id < 0) return soap->error; if (!**p && (soap->mode & SOAP_C_NILSTRING)) @@ -13430,12 +15111,13 @@ soap_outwstring(struct soap *soap, const char *tag, int id, wchar_t *const*p, co #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_2 SOAP_FMAC1 wchar_t ** SOAP_FMAC2 -soap_inwstring(struct soap *soap, const char *tag, wchar_t **p, const char *type, int t, long minlen, long maxlen) +soap_inwstring(struct soap *soap, const char *tag, wchar_t **p, const char *type, int t, long minlen, long maxlen, const char *pattern) { (void)type; if (soap_element_begin_in(soap, tag, 1, NULL)) { if (!tag || *tag != '-' || soap->error != SOAP_NO_TAG) @@ -13443,12 +15125,15 @@ soap_inwstring(struct soap *soap, const char *tag, wchar_t **p, const char *type soap->error = SOAP_OK; } if (!p) - { if (!(p = (wchar_t**)soap_malloc(soap, sizeof(wchar_t*)))) + { p = (wchar_t**)soap_malloc(soap, sizeof(wchar_t*)); + if (!p) return NULL; } - if (soap->body) - { *p = soap_wstring_in(soap, 1, minlen, maxlen); - if (!*p || !(wchar_t*)soap_id_enter(soap, soap->id, *p, t, sizeof(wchar_t*), 0, NULL, NULL, NULL)) + if (soap->null) + *p = NULL; + else if (soap->body) + { *p = soap_wstring_in(soap, 1, minlen, maxlen, pattern); + if (!*p || !(wchar_t*)soap_id_enter(soap, soap->id, *p, t, sizeof(wchar_t*), NULL, NULL, NULL, NULL)) return NULL; if (!**p && tag && *tag == '-') { soap->error = SOAP_NO_TAG; @@ -13459,12 +15144,15 @@ soap_inwstring(struct soap *soap, const char *tag, wchar_t **p, const char *type { soap->error = SOAP_NO_TAG; return NULL; } - else if (soap->null) - *p = NULL; - else - *p = soap_wstrdup(soap, (wchar_t*)SOAP_STR_EOS); + else if (!*soap->href) + { if (minlen > 0) + { soap->error = SOAP_LENGTH; + return NULL; + } + *p = soap_wstrdup(soap, L""); + } if (*soap->href) - p = (wchar_t**)soap_id_lookup(soap, soap->href, (void**)p, t, sizeof(wchar_t**), 0); + p = (wchar_t**)soap_id_lookup(soap, soap->href, (void**)p, t, sizeof(wchar_t**), 0, NULL); if (soap->body && soap_element_end_in(soap, tag)) return NULL; return p; @@ -13473,6 +15161,89 @@ soap_inwstring(struct soap *soap, const char *tag, wchar_t **p, const char *type #endif /******************************************************************************/ + +#ifndef WITH_LEAN +#ifdef UNDER_CE +/* WinCE mktime (based on the mingw-runtime, public domain) */ +#define __FILETIME_to_ll(f) ((long long)(f).dwHighDateTime << 32 | (long long)(f).dwLowDateTime) +static time_t +mktime(struct tm *pt) +{ SYSTEMTIME s, s1, s2; + FILETIME f, f1, f2; + long long diff; + GetSystemTime(&s1); + GetLocalTime(&s2); + SystemTimeToFileTime(&s1, &f1); + SystemTimeToFileTime(&s2, &f2); + diff = (__FILETIME_to_ll(f2) - __FILETIME_to_ll(f1)) / 10000000LL; + s.wYear = pt->tm_year + 1900; + s.wMonth = pt->tm_mon + 1; + s.wDayOfWeek = pt->tm_wday; + s.wDay = pt->tm_mday; + s.wHour = pt->tm_hour; + s.wMinute = pt->tm_min; + s.wSecond = pt->tm_sec; + s.wMilliseconds = 0; + SystemTimeToFileTime(&s, &f); + return (time_t)((__FILETIME_to_ll(f) - 116444736000000000LL) / 10000000LL) - (time_t)diff; +} +#endif +#endif + +/******************************************************************************/ + +#ifndef WITH_LEAN +#ifdef UNDER_CE +/* WinCE gmtime_r (based on the mingw-runtime, public domain) */ +#define HAVE_GMTIME_R +static struct tm* +gmtime_r(const time_t *t, struct tm *pt) +{ FILETIME f, f1, f2; + SYSTEMTIME s, s1 = {0}; + long long time = (long long)(*t) * 10000000LL + 116444736000000000LL; + f.dwHighDateTime = (DWORD)((time >> 32) & 0x00000000FFFFFFFF); + f.dwLowDateTime = (DWORD)(time & 0x00000000FFFFFFFF); + FileTimeToSystemTime(&f, &s); + pt->tm_year = s.wYear - 1900; + pt->tm_mon = s.wMonth - 1; + pt->tm_wday = s.wDayOfWeek; + pt->tm_mday = s.wDay; + s1.wYear = s.wYear; + s1.wMonth = 1; + s1.wDayOfWeek = 1; + s1.wDay = 1; + SystemTimeToFileTime(&s1, &f1); + SystemTimeToFileTime(&s, &f2); + pt->tm_yday = (((__FILETIME_to_ll(f2) - __FILETIME_to_ll(f1)) / 10000000LL) / (60 * 60 * 24)); + pt->tm_hour = s.wHour; + pt->tm_min = s.wMinute; + pt->tm_sec = s.wSecond; + pt->tm_isdst = 0; + return pt; +} +#endif +#endif + +/******************************************************************************/ + +#ifndef WITH_LEAN +#ifdef UNDER_CE +/* WinCE very simple strftime for format "%Y-%m-%dT%H:%M:%SZ", note: %F and %T not supported by MS */ +static size_t +strftime(char *buf, size_t len, const char *format, const struct tm *pT) +{ (void)len; (void)format; +#ifndef WITH_NOZONE + (SOAP_SNPRINTF(buf, len, 20), "%04d-%02d-%02dT%02d:%02d:%02dZ", pT->tm_year + 1900, pT->tm_mon + 1, pT->tm_mday, pT->tm_hour, pT->tm_min, pT->tm_sec); +#else + (SOAP_SNPRINTF(buf, len, 20), "%04d-%02d-%02dT%02d:%02d:%02d", pT->tm_year + 1900, pT->tm_mon + 1, pT->tm_mday, pT->tm_hour, pT->tm_min, pT->tm_sec); +#endif + return len; +} +#endif +#endif + +/******************************************************************************/ + #ifndef WITH_LEAN SOAP_FMAC1 time_t @@ -13484,13 +15255,20 @@ soap_timegm(struct tm *T) #else time_t t, g, z; struct tm tm; +#ifndef HAVE_GMTIME_R + struct tm *tp; +#endif t = mktime(T); if (t == (time_t)-1) return (time_t)-1; #ifdef HAVE_GMTIME_R - gmtime_r(&t, &tm); + if (gmtime_r(&t, &tm) == SOAP_FUNC_R_ERR) + return (time_t)-1; #else - tm = *gmtime(&t); + tp = gmtime(&t); + if (!tp) + return (time_t)-1; + tm = *tp; #endif tm.tm_isdst = 0; g = mktime(&tm); @@ -13503,106 +15281,108 @@ soap_timegm(struct tm *T) #endif /******************************************************************************/ + #ifndef WITH_LEAN SOAP_FMAC1 const char* SOAP_FMAC2 soap_dateTime2s(struct soap *soap, time_t n) { struct tm T, *pT = &T; -#if defined(HAVE_GMTIME_R) - if (gmtime_r(&n, pT)) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%SZ", pT); -#elif defined(HAVE_GMTIME) - if ((pT = gmtime(&n))) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%SZ", pT); -#elif defined(HAVE_TM_GMTOFF) || defined(HAVE_STRUCT_TM_TM_GMTOFF) || defined(HAVE_STRUCT_TM___TM_GMTOFF) + size_t l = 0; +#if defined(HAVE_GMTIME_R) && !defined(WITH_NOZONE) + if (gmtime_r(&n, pT) != SOAP_FUNC_R_ERR) + l = strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%SZ", pT); +#elif defined(HAVE_GMTIME) && !defined(WITH_NOZONE) + pT = gmtime(&n); + if (pT) + l = strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%SZ", pT); +#elif (defined(HAVE_TM_GMTOFF) || defined(HAVE_STRUCT_TM_TM_GMTOFF) || defined(HAVE_STRUCT_TM___TM_GMTOFF)) && !defined(WITH_NOZONE) #if defined(HAVE_LOCALTIME_R) - if (localtime_r(&n, pT)) - { strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S%z", pT); - memmove(soap->tmpbuf + 23, soap->tmpbuf + 22, 3); /* 2000-03-01T02:00:00+0300 */ - soap->tmpbuf[22] = ':'; /* 2000-03-01T02:00:00+03:00 */ + if (localtime_r(&n, pT) != SOAP_FUNC_R_ERR) + { l = strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S%z", pT); + if (l) + { soap_memmove(soap->tmpbuf + 23, sizeof(soap->tmpbuf) - 23, soap->tmpbuf + 22, 3); /* 2000-03-01T02:00:00+0300 */ + soap->tmpbuf[22] = ':'; /* 2000-03-01T02:00:00+03:00 */ + } } #else - if ((pT = localtime(&n))) - { strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S%z", pT); - memmove(soap->tmpbuf + 23, soap->tmpbuf + 22, 3); /* 2000-03-01T02:00:00+0300 */ - soap->tmpbuf[22] = ':'; /* 2000-03-01T02:00:00+03:00 */ + pT = localtime(&n); + if (pT) + { l = strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S%z", pT); + if (l) + { soap_memmove(soap->tmpbuf + 23, sizeof(soap->tmpbuf) - 23, soap->tmpbuf + 22, 3); /* 2000-03-01T02:00:00+0300 */ + soap->tmpbuf[22] = ':'; /* 2000-03-01T02:00:00+03:00 */ + } } #endif -#elif defined(HAVE_GETTIMEOFDAY) - struct timezone tz; - memset((void*)&tz, 0, sizeof(tz)); +#elif defined(HAVE_GETTIMEOFDAY) && !defined(WITH_NOZONE) #if defined(HAVE_LOCALTIME_R) - if (localtime_r(&n, pT)) + if (localtime_r(&n, pT) != SOAP_FUNC_R_ERR) { struct timeval tv; + struct timezone tz; + memset((void*)&tz, 0, sizeof(tz)); gettimeofday(&tv, &tz); - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf + strlen(soap->tmpbuf), sizeof(soap->tmpbuf) - strlen(soap->tmpbuf), "%+03d:%02d", -tz.tz_minuteswest/60+(pT->tm_isdst!=0), abs(tz.tz_minuteswest)%60); -#else - sprintf(soap->tmpbuf + strlen(soap->tmpbuf), "%+03d:%02d", -tz.tz_minuteswest/60+(pT->tm_isdst!=0), abs(tz.tz_minuteswest)%60); -#endif + l = strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); + if (l) + (SOAP_SNPRINTF(soap->tmpbuf + l, sizeof(soap->tmpbuf) - l, 7), "%+03d:%02d", -tz.tz_minuteswest/60+(pT->tm_isdst!=0), abs(tz.tz_minuteswest)%60); } #else - if ((pT = localtime(&n))) + pT = localtime(&n); + if (pT) { struct timeval tv; + struct timezone tz; + memset((void*)&tz, 0, sizeof(tz)); gettimeofday(&tv, &tz); - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf + strlen(soap->tmpbuf), sizeof(soap->tmpbuf) - strlen(soap->tmpbuf), "%+03d:%02d", -tz.tz_minuteswest/60+(pT->tm_isdst!=0), abs(tz.tz_minuteswest)%60); -#else - sprintf(soap->tmpbuf + strlen(soap->tmpbuf), "%+03d:%02d", -tz.tz_minuteswest/60+(pT->tm_isdst!=0), abs(tz.tz_minuteswest)%60); -#endif + l = strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); + if (l) + (SOAP_SNPRINTF(soap->tmpbuf + l, sizeof(soap->tmpbuf) - l, 7), "%+03d:%02d", -tz.tz_minuteswest/60+(pT->tm_isdst!=0), abs(tz.tz_minuteswest)%60); } #endif -#elif defined(HAVE_FTIME) - struct timeb t; - memset((void*)&t, 0, sizeof(t)); +#elif defined(HAVE_FTIME) && !defined(WITH_NOZONE) #if defined(HAVE_LOCALTIME_R) - if (localtime_r(&n, pT)) - { + if (localtime_r(&n, pT) != SOAP_FUNC_R_ERR) + { struct timeb t; + memset((void*)&t, 0, sizeof(t)); #ifdef __BORLANDC__ ::ftime(&t); #else ftime(&t); #endif - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf + strlen(soap->tmpbuf), sizeof(soap->tmpbuf) - strlen(soap->tmpbuf), "%+03d:%02d", -t.timezone/60+(pT->tm_isdst!=0), abs(t.timezone)%60); -#else - sprintf(soap->tmpbuf + strlen(soap->tmpbuf), "%+03d:%02d", -t.timezone/60+(pT->tm_isdst!=0), abs(t.timezone)%60); -#endif + l = strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); + if (l) + (SOAP_SNPRINTF(soap->tmpbuf + l, sizeof(soap->tmpbuf) - l, 7), "%+03d:%02d", -t.timezone/60+(pT->tm_isdst!=0), abs(t.timezone)%60); } #else - if ((pT = localtime(&n))) - { + pT = localtime(&n); + if (pT) + { struct timeb t; + memset((void*)&t, 0, sizeof(t)); #ifdef __BORLANDC__ ::ftime(&t); #else ftime(&t); #endif - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf + strlen(soap->tmpbuf), sizeof(soap->tmpbuf) - strlen(soap->tmpbuf), "%+03d:%02d", -t.timezone/60+(pT->tm_isdst!=0), abs(t.timezone)%60); -#else - sprintf(soap->tmpbuf + strlen(soap->tmpbuf), "%+03d:%02d", -t.timezone/60+(pT->tm_isdst!=0), abs(t.timezone)%60); -#endif + l = strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); + if (l) + (SOAP_SNPRINTF(soap->tmpbuf + l, sizeof(soap->tmpbuf) - l, 7), "%+03d:%02d", -t.timezone/60+(pT->tm_isdst!=0), abs(t.timezone)%60); } #endif #elif defined(HAVE_LOCALTIME_R) - if (localtime_r(&n, pT)) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); + if (localtime_r(&n, pT) != SOAP_FUNC_R_ERR) + l = strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); #else - if ((pT = localtime(&n))) - strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); + pT = localtime(&n); + if (pT) + l = strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%S", pT); #endif - else - strcpy(soap->tmpbuf, "1969-12-31T23:59:59Z"); + if (!l) + soap_strcpy(soap->tmpbuf, sizeof(soap->tmpbuf), "1969-12-31T23:59:59Z"); return soap->tmpbuf; } #endif /******************************************************************************/ + #ifndef WITH_LEAN SOAP_FMAC1 int @@ -13616,53 +15396,87 @@ soap_outdateTime(struct soap *soap, const char *tag, int id, const time_t *p, co #endif /******************************************************************************/ + #ifndef WITH_LEAN SOAP_FMAC1 int SOAP_FMAC2 soap_s2dateTime(struct soap *soap, const char *s, time_t *p) -{ if (s) - { char zone[32]; +{ *p = 0; + if (s) + { char *t; + unsigned long d; struct tm T; - const char *t; - *zone = '\0'; memset((void*)&T, 0, sizeof(T)); - if (strchr(s, '-')) - t = "%d-%d-%dT%d:%d:%d%31s"; - else if (strchr(s, ':')) - t = "%4d%2d%2dT%d:%d:%d%31s"; - else /* parse non-XSD-standard alternative ISO 8601 format */ - t = "%4d%2d%2dT%2d%2d%2d%31s"; - if (sscanf(s, t, &T.tm_year, &T.tm_mon, &T.tm_mday, &T.tm_hour, &T.tm_min, &T.tm_sec, zone) < 6) + d = soap_strtoul(s, &t, 10); + if (*t == '-') + { /* YYYY-MM-DD */ + T.tm_year = (int)d; + T.tm_mon = (int)soap_strtoul(t + 1, &t, 10); + T.tm_mday = (int)soap_strtoul(t + 1, &t, 10); + } + else if (!(soap->mode & SOAP_XML_STRICT)) + { /* YYYYMMDD */ + T.tm_year = (int)(d / 10000); + T.tm_mon = (int)(d / 100 % 100); + T.tm_mday = (int)(d % 100); + } + else return soap->error = SOAP_TYPE; + if (*t == 'T' || ((*t == 't' || *t == ' ') && !(soap->mode & SOAP_XML_STRICT))) + { d = soap_strtoul(t + 1, &t, 10); + if (*t == ':') + { /* Thh:mm:ss */ + T.tm_hour = (int)d; + T.tm_min = (int)soap_strtoul(t + 1, &t, 10); + T.tm_sec = (int)soap_strtoul(t + 1, &t, 10); + } + else if (!(soap->mode & SOAP_XML_STRICT)) + { /* Thhmmss */ + T.tm_hour = (int)(d / 10000); + T.tm_min = (int)(d / 100 % 100); + T.tm_sec = (int)(d % 100); + } + else + return soap->error = SOAP_TYPE; + } if (T.tm_year == 1) T.tm_year = 70; else T.tm_year -= 1900; T.tm_mon--; - if (*zone == '.') - { for (s = zone + 1; *s; s++) - if (*s < '0' || *s > '9') + if (*t == '.') + { for (t++; *t; t++) + if (*t < '0' || *t > '9') break; } - else - s = zone; - if (*s) + if (*t == ' ' && !(soap->mode & SOAP_XML_STRICT)) + t++; + if (*t) { #ifndef WITH_NOZONE - if (*s == '+' || *s == '-') - { int h = 0, m = 0; - if (s[3] == ':') + if (*t == '+' || *t == '-') + { int h, m; + m = (int)soap_strtol(t, &t, 10); + if (*t == ':') { /* +hh:mm */ - sscanf(s, "%d:%d", &h, &m); + h = m; + m = (int)soap_strtol(t + 1, &t, 10); if (h < 0) m = -m; } - else /* +hhmm */ - { m = (int)soap_strtol(s, NULL, 10); + else if (!(soap->mode & SOAP_XML_STRICT)) + { /* +hhmm */ h = m / 100; m = m % 100; } + else + { /* +hh */ + h = m; + m = 0; + } + if (*t) + return soap->error = SOAP_TYPE; T.tm_min -= m; T.tm_hour -= h; /* put hour and min in range */ @@ -13680,6 +15494,8 @@ soap_s2dateTime(struct soap *soap, const char *s, time_t *p) } /* note: day of the month may be out of range, timegm() handles it */ } + else if (*t != 'Z') + return soap->error = SOAP_TYPE; #endif *p = soap_timegm(&T); } @@ -13693,6 +15509,7 @@ soap_s2dateTime(struct soap *soap, const char *s, time_t *p) #endif /******************************************************************************/ + #ifndef WITH_LEAN SOAP_FMAC1 time_t * @@ -13707,9 +15524,9 @@ soap_indateTime(struct soap *soap, const char *tag, time_t *p, const char *type, soap_revert(soap); return NULL; } - p = (time_t*)soap_id_enter(soap, soap->id, p, t, sizeof(time_t), 0, NULL, NULL, NULL); + p = (time_t*)soap_id_enter(soap, soap->id, p, t, sizeof(time_t), NULL, NULL, NULL, NULL); if (*soap->href) - p = (time_t*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(time_t), 0, NULL); + p = (time_t*)soap_id_forward(soap, soap->href, p, 0, t, t, sizeof(time_t), 0, NULL, NULL); else if (p) { if (soap_s2dateTime(soap, soap_value(soap), p)) return NULL; @@ -13721,62 +15538,46 @@ soap_indateTime(struct soap *soap, const char *tag, time_t *p, const char *type, #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 soap_outliteral(struct soap *soap, const char *tag, char *const*p, const char *type) -{ int i; - const char *t = NULL; - if (tag && *tag != '-') - { if (soap->local_namespaces && (t = strchr(tag, ':'))) - { size_t n = t - tag; - if (n >= sizeof(soap->tmpbuf)) - n = sizeof(soap->tmpbuf) - 1; - strncpy(soap->tmpbuf, tag, n); - soap->tmpbuf[n] = '\0'; - for (i = 0; soap->local_namespaces[i].id; i++) - if (!strcmp(soap->tmpbuf, soap->local_namespaces[i].id)) - break; - t++; - if (soap_element(soap, t, 0, type) - || soap_attribute(soap, "xmlns", soap->local_namespaces[i].ns ? soap->local_namespaces[i].ns : SOAP_STR_EOS) - || soap_element_start_end_out(soap, NULL)) - return soap->error; - } - else - { t = tag; - if (soap_element_begin_out(soap, t, 0, type)) - return soap->error; - } - } +{ if (tag && *tag != '-') + if (soap_element_begin_out(soap, tag, 0, type)) + return soap->error; if (p && *p) - { if (soap_send(soap, *p)) /* send as-is */ + if (soap_send(soap, *p)) /* send as-is */ return soap->error; - } - if (t) - return soap_element_end_out(soap, t); + if (tag && *tag != '-') + return soap_element_end_out(soap, tag); return SOAP_OK; } #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 char ** SOAP_FMAC2 soap_inliteral(struct soap *soap, const char *tag, char **p) { if (soap_element_begin_in(soap, tag, 1, NULL)) - { if (soap->error != SOAP_NO_TAG || soap_unget(soap, soap_get(soap)) == SOAP_TT) + { if (soap->error != SOAP_NO_TAG || soap_peek(soap) == SOAP_TT) return NULL; soap->error = SOAP_OK; } if (!p) - { if (!(p = (char**)soap_malloc(soap, sizeof(char*)))) + { p = (char**)soap_malloc(soap, sizeof(char*)); + if (!p) return NULL; } if (soap->body || (tag && *tag == '-')) - { *p = soap_string_in(soap, 0, -1, -1); + { if (tag && *tag != '-') + *p = soap_string_in(soap, -1, -1, -1, NULL); + else + *p = soap_string_in(soap, 0, -1, -1, NULL); if (!*p) return NULL; if (!**p && tag && *tag == '-') @@ -13795,36 +15596,16 @@ soap_inliteral(struct soap *soap, const char *tag, char **p) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 soap_outwliteral(struct soap *soap, const char *tag, wchar_t *const*p, const char *type) -{ int i; - const char *t = NULL; - if (tag && *tag != '-') - { if (soap->local_namespaces && (t = strchr(tag, ':'))) - { size_t n = t - tag; - if (n >= sizeof(soap->tmpbuf)) - n = sizeof(soap->tmpbuf) - 1; - strncpy(soap->tmpbuf, tag, n); - soap->tmpbuf[n] = '\0'; - for (i = 0; soap->local_namespaces[i].id; i++) - if (!strcmp(soap->tmpbuf, soap->local_namespaces[i].id)) - break; - t++; - if (soap_element(soap, t, 0, type) - || soap_attribute(soap, "xmlns", soap->local_namespaces[i].ns ? soap->local_namespaces[i].ns : SOAP_STR_EOS) - || soap_element_start_end_out(soap, NULL)) - return soap->error; - } - else - { t = tag; - if (soap_element_begin_out(soap, t, 0, type)) - return soap->error; - } - } +{ if (tag && *tag != '-') + if (soap_element_begin_out(soap, tag, 0, type)) + return soap->error; if (p) { wchar_t c; const wchar_t *s = *p; @@ -13833,14 +15614,15 @@ soap_outwliteral(struct soap *soap, const char *tag, wchar_t *const*p, const cha return soap->error; } } - if (t) - return soap_element_end_out(soap, t); + if (tag && *tag != '-') + return soap_element_end_out(soap, tag); return SOAP_OK; } #endif #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_2 SOAP_FMAC1 @@ -13848,16 +15630,20 @@ wchar_t ** SOAP_FMAC2 soap_inwliteral(struct soap *soap, const char *tag, wchar_t **p) { if (soap_element_begin_in(soap, tag, 1, NULL)) - { if (soap->error != SOAP_NO_TAG || soap_unget(soap, soap_get(soap)) == SOAP_TT) + { if (soap->error != SOAP_NO_TAG || soap_peek(soap) == SOAP_TT) return NULL; soap->error = SOAP_OK; } if (!p) - { if (!(p = (wchar_t**)soap_malloc(soap, sizeof(wchar_t*)))) + { p = (wchar_t**)soap_malloc(soap, sizeof(wchar_t*)); + if (!p) return NULL; } if (soap->body) - { *p = soap_wstring_in(soap, 0, -1, -1); + { if (tag && *tag != '-') + *p = soap_wstring_in(soap, -1, -1, -1, NULL); + else + *p = soap_wstring_in(soap, 0, -1, -1, NULL); if (!*p) return NULL; if (!**p && tag && *tag == '-') @@ -13872,7 +15658,7 @@ soap_inwliteral(struct soap *soap, const char *tag, wchar_t **p) else if (soap->null) *p = NULL; else - *p = soap_wstrdup(soap, (wchar_t*)SOAP_STR_EOS); + *p = soap_wstrdup(soap, L""); if (soap->body && soap_element_end_in(soap, tag)) return NULL; return p; @@ -13881,14 +15667,15 @@ soap_inwliteral(struct soap *soap, const char *tag, wchar_t **p) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 const char * SOAP_FMAC2 soap_value(struct soap *soap) -{ register size_t i; - register soap_wchar c = 0; - register char *s = soap->tmpbuf; +{ size_t i; + soap_wchar c = 0; + char *s = soap->tmpbuf; if (!soap->body) return SOAP_STR_EOS; do c = soap_get(soap); @@ -13908,26 +15695,28 @@ soap_value(struct soap *soap) DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Element content value='%s'\n", soap->tmpbuf)); if (c == SOAP_TT || c == SOAP_LT || (int)c == EOF) soap_unget(soap, c); - else if (soap->mode & SOAP_XML_STRICT) + else { soap->error = SOAP_LENGTH; return NULL; } #ifdef WITH_DOM if ((soap->mode & SOAP_XML_DOM) && soap->dom) - soap->dom->data = soap_strdup(soap, soap->tmpbuf); + soap->dom->text = soap_strdup(soap, soap->tmpbuf); #endif return soap->tmpbuf; /* return non-null pointer */ } #endif /******************************************************************************/ + #if !defined(WITH_LEANER) || !defined(WITH_NOHTTP) #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 -soap_getline(struct soap *soap, char *s, int len) -{ int i = len; +soap_getline(struct soap *soap, char *buf, int len) +{ char *s = buf; + int i = len; soap_wchar c = 0; for (;;) { while (--i > 0) @@ -13959,13 +15748,14 @@ soap_getline(struct soap *soap, char *s, int len) #endif /******************************************************************************/ + #ifndef PALM_1 static size_t soap_count_attachments(struct soap *soap) { #ifndef WITH_LEANER - register struct soap_multipart *content; - register size_t count = soap->count; + struct soap_multipart *content; + size_t count = soap->count; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Calculating the message size with attachments, current count=%lu\n", (unsigned long)count)); if ((soap->mode & SOAP_ENC_DIME) && !(soap->mode & SOAP_ENC_MTOM)) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Calculating the size of DIME attachments\n")); @@ -13981,10 +15771,10 @@ soap_count_attachments(struct soap *soap) } } if ((soap->mode & SOAP_ENC_MIME) && soap->mime.boundary) - { register size_t n = strlen(soap->mime.boundary); + { size_t n = strlen(soap->mime.boundary); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Calculating the size of MIME attachments\n")); for (content = soap->mime.first; content; content = content->next) - { register const char *s; + { const char *s; /* count \r\n--boundary\r\n */ count += 6 + n; /* count Content-Type: ...\r\n */ @@ -14019,6 +15809,7 @@ soap_count_attachments(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 static int @@ -14031,6 +15822,7 @@ soap_putdimefield(struct soap *soap, const char *s, size_t n) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 @@ -14047,7 +15839,7 @@ soap_dime_option(struct soap *soap, unsigned short optype, const char *option) s[1] = (char)(optype & 0xFF); s[2] = (char)(n >> 8); s[3] = (char)(n & 0xFF); - strcpy(s + 4, option); + soap_strcpy(s + 4, n + 1, option); } } return s; @@ -14056,6 +15848,7 @@ soap_dime_option(struct soap *soap, unsigned short optype, const char *option) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 @@ -14100,6 +15893,7 @@ soap_putdimehdr(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 @@ -14116,7 +15910,7 @@ soap_putdime(struct soap *soap) soap->dime.type = content->type; soap->dime.options = content->options; soap->dime.flags = SOAP_DIME_VERSION | SOAP_DIME_MEDIA; - if (soap->fdimereadopen && ((handle = soap->fdimereadopen(soap, (void*)content->ptr, content->id, content->type, content->options)) || soap->error)) + if (soap->fdimereadopen && ((handle = soap->fdimereadopen(soap, (void*)content->ptr, content->id, content->type, content->options)) != NULL || soap->error)) { size_t size = content->size; if (!handle) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimereadopen failed\n")); @@ -14158,7 +15952,8 @@ soap_putdime(struct soap *soap) bufsize = size; else bufsize = sizeof(soap->tmpbuf); - if (!(bufsize = soap->fdimeread(soap, handle, soap->tmpbuf, bufsize))) + bufsize = soap->fdimeread(soap, handle, soap->tmpbuf, bufsize); + if (!bufsize) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimeread failed: insufficient data (%lu bytes remaining from %lu bytes)\n", (unsigned long)size, (unsigned long)content->size)); soap->error = SOAP_CHK_EOF; break; @@ -14168,7 +15963,8 @@ soap_putdime(struct soap *soap) size -= bufsize; } while (size); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimereadclose\n")); - soap_send_raw(soap, SOAP_STR_PADDING, -(long)soap->dime.size&3); + if (soap_send_raw(soap, SOAP_STR_PADDING, -(long)soap->dime.size&3)) + return soap->error; } DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimereadclose\n")); if (soap->fdimereadclose) @@ -14188,27 +15984,30 @@ soap_putdime(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 static char * soap_getdimefield(struct soap *soap, size_t n) -{ register soap_wchar c; - register size_t i; - register char *s; - register char *p = NULL; +{ soap_wchar c; + size_t i; + char *s; + char *p = NULL; if (n) { p = (char*)soap_malloc(soap, n + 1); if (p) { s = p; for (i = n; i > 0; i--) - { if ((int)(c = soap_get1(soap)) == EOF) + { c = soap_get1(soap); + if ((int)c == EOF) { soap->error = SOAP_CHK_EOF; return NULL; } *s++ = (char)c; } - *s = '\0'; - if ((soap->error = soap_move(soap, (size_t)(-(long)n&3)))) + *s = '\0'; /* force NUL terminated */ + soap->error = soap_move(soap, (size_t)(-(long)n&3)); + if (soap->error) return NULL; } else @@ -14220,15 +16019,16 @@ soap_getdimefield(struct soap *soap, size_t n) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 soap_getdimehdr(struct soap *soap) -{ register soap_wchar c; - register char *s; - register int i; +{ soap_wchar c; + char *s; + int i; unsigned char tmp[12]; size_t optlen, idlen, typelen; if (!(soap->mode & SOAP_ENC_DIME)) @@ -14243,7 +16043,8 @@ soap_getdimehdr(struct soap *soap) } s = (char*)tmp; for (i = 12; i > 0; i--) - { if ((int)(c = soap_getchar(soap)) == EOF) + { c = soap_getchar(soap); + if ((int)c == EOF) return soap->error = SOAP_CHK_EOF; *s++ = (char)c; } @@ -14255,11 +16056,14 @@ soap_getdimehdr(struct soap *soap) typelen = (tmp[6] << 8) | tmp[7]; soap->dime.size = ((size_t)tmp[8] << 24) | ((size_t)tmp[9] << 16) | ((size_t)tmp[10] << 8) | ((size_t)tmp[11]); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DIME size=%lu flags=0x%X\n", (unsigned long)soap->dime.size, soap->dime.flags)); - if (!(soap->dime.options = soap_getdimefield(soap, optlen)) && soap->error) + soap->dime.options = soap_getdimefield(soap, optlen); + if (!soap->dime.options && soap->error) return soap->error; - if (!(soap->dime.id = soap_getdimefield(soap, idlen)) && soap->error) + soap->dime.id = soap_getdimefield(soap, idlen); + if (!soap->dime.id && soap->error) return soap->error; - if (!(soap->dime.type = soap_getdimefield(soap, typelen)) && soap->error) + soap->dime.type = soap_getdimefield(soap, typelen); + if (!soap->dime.type && soap->error) return soap->error; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DIME id='%s', type='%s', options='%s'\n", soap->dime.id ? soap->dime.id : SOAP_STR_EOS, soap->dime.type ? soap->dime.type : "", soap->dime.options ? soap->dime.options+4 : SOAP_STR_EOS)); if (soap->dime.flags & SOAP_DIME_ME) @@ -14270,6 +16074,7 @@ soap_getdimehdr(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 @@ -14285,10 +16090,10 @@ soap_getdime(struct soap *soap) if (soap_move(soap, (size_t)(((soap->dime.size+3)&(~3)) - soap_tell(soap)))) return soap->error = SOAP_EOF; for (;;) - { register struct soap_multipart *content; + { struct soap_multipart *content; if (soap_getdimehdr(soap)) break; - if (soap->fdimewriteopen && ((soap->dime.ptr = (char*)soap->fdimewriteopen(soap, soap->dime.id, soap->dime.type, soap->dime.options)) || soap->error)) + if (soap->fdimewriteopen && ((soap->dime.ptr = (char*)soap->fdimewriteopen(soap, soap->dime.id, soap->dime.type, soap->dime.options)) != NULL || soap->error)) { const char *id, *type, *options; size_t size, n; if (!soap->dime.ptr) @@ -14302,7 +16107,8 @@ soap_getdime(struct soap *soap) { n = soap->buflen - soap->bufidx; if (size < n) n = size; - if ((soap->error = soap->fdimewrite(soap, (void*)soap->dime.ptr, soap->buf + soap->bufidx, n))) + soap->error = soap->fdimewrite(soap, (void*)soap->dime.ptr, soap->buf + soap->bufidx, n); + if (soap->error) break; size -= n; if (!size) @@ -14339,9 +16145,9 @@ end: if (soap_new_block(soap) == NULL) return SOAP_EOM; for (;;) - { register soap_wchar c; - register size_t i; - register char *s; + { soap_wchar c; + size_t i; + char *s; if (soap->dime.size > SOAP_MAXDIMESIZE) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DIME size=%lu exceeds SOAP_MAXDIMESIZE=%lu\n", (unsigned long)soap->dime.size, (unsigned long)SOAP_MAXDIMESIZE)); return soap->error = SOAP_DIME_ERROR; @@ -14350,7 +16156,8 @@ end: if (!s) return soap->error = SOAP_EOM; for (i = soap->dime.size; i > 0; i--) - { if ((int)(c = soap_get1(soap)) == EOF) + { c = soap_get1(soap); + if ((int)c == EOF) return soap->error = SOAP_EOF; *s++ = (char)c; } @@ -14362,7 +16169,8 @@ end: return soap->error; } soap->dime.size = soap->blist->size++; /* allocate one more byte in blist for the terminating '\0' */ - if (!(soap->dime.ptr = soap_save_block(soap, NULL, NULL, 0))) + soap->dime.ptr = soap_save_block(soap, NULL, NULL, 0); + if (!soap->dime.ptr) return soap->error; soap->dime.ptr[soap->dime.size] = '\0'; /* make 0-terminated */ soap->dime.id = id; @@ -14389,6 +16197,7 @@ end: #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 @@ -14396,11 +16205,11 @@ int SOAP_FMAC2 soap_getmimehdr(struct soap *soap) { struct soap_multipart *content; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get MIME header\n")); do { if (soap_getline(soap, soap->msgbuf, sizeof(soap->msgbuf))) return soap->error; - } - while (!*soap->msgbuf); + } while (!*soap->msgbuf); if (soap->msgbuf[0] == '-' && soap->msgbuf[1] == '-') { char *s = soap->msgbuf + strlen(soap->msgbuf) - 1; /* remove white space */ @@ -14420,11 +16229,11 @@ soap_getmimehdr(struct soap *soap) return soap->error = SOAP_EOM; content = soap->mime.last; for (;;) - { register char *key = soap->msgbuf; - register char *val; + { char *key = soap->msgbuf; + char *val; if (!*key) break; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "MIME header: %s\n", key)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "MIME header: %s\n", key)); val = strchr(soap->msgbuf, ':'); if (val) { *val = '\0'; @@ -14434,14 +16243,14 @@ soap_getmimehdr(struct soap *soap) content->id = soap_strdup(soap, val); else if (!soap_tag_cmp(key, "Content-Location")) content->location = soap_strdup(soap, val); - else if (!soap_tag_cmp(key, "Content-Disposition")) + else if (!content->id && !soap_tag_cmp(key, "Content-Disposition")) content->id = soap_strdup(soap, soap_get_header_attribute(soap, val, "name")); else if (!soap_tag_cmp(key, "Content-Type")) content->type = soap_strdup(soap, val); else if (!soap_tag_cmp(key, "Content-Description")) content->description = soap_strdup(soap, val); else if (!soap_tag_cmp(key, "Content-Transfer-Encoding")) - content->encoding = (enum soap_mime_encoding)soap_code_int(mime_codes, val, (long)SOAP_MIME_NONE); + content->encoding = (enum soap_mime_encoding)soap_code_int(mime_codes, val, (LONG64)SOAP_MIME_NONE); } if (soap_getline(soap, key, sizeof(soap->msgbuf))) return soap->error; @@ -14452,6 +16261,7 @@ soap_getmimehdr(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 @@ -14459,13 +16269,14 @@ int SOAP_FMAC2 soap_getmime(struct soap *soap) { while (soap_get_mime_attachment(soap, NULL)) - ; + continue; return soap->error; } #endif #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 @@ -14478,6 +16289,7 @@ soap_post_check_mime_attachments(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 @@ -14492,27 +16304,29 @@ soap_check_mime_attachments(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 struct soap_multipart * SOAP_FMAC2 soap_get_mime_attachment(struct soap *soap, void *handle) -{ register soap_wchar c = 0; - register size_t i, m = 0; - register char *s, *t = NULL; - register struct soap_multipart *content; - register short flag = 0; +{ soap_wchar c = 0; + size_t i, m = 0; + char *s, *t = NULL; + struct soap_multipart *content; + short flag = 0; if (!(soap->mode & SOAP_ENC_MIME)) return NULL; content = soap->mime.last; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get MIME (%p)\n", content)); if (!content) { if (soap_getmimehdr(soap)) return NULL; content = soap->mime.last; } else if (content != soap->mime.first) - { if (soap->fmimewriteopen && ((content->ptr = (char*)soap->fmimewriteopen(soap, (void*)handle, content->id, content->type, content->description, content->encoding)) || soap->error)) + { if (soap->fmimewriteopen && ((content->ptr = (char*)soap->fmimewriteopen(soap, (void*)handle, content->id, content->type, content->description, content->encoding)) != NULL || soap->error)) { if (!content->ptr) return NULL; } @@ -14524,10 +16338,15 @@ soap_get_mime_attachment(struct soap *soap, void *handle) } for (;;) { if (content->ptr) + { s = soap->tmpbuf; - else if (!(s = (char*)soap_push_block(soap, NULL, sizeof(soap->tmpbuf)))) - { soap->error = SOAP_EOM; - return NULL; + } + else + { s = (char*)soap_push_block(soap, NULL, sizeof(soap->tmpbuf)); + if (!s) + { soap->error = SOAP_EOM; + return NULL; + } } for (i = 0; i < sizeof(soap->tmpbuf); i++) { if (m > 0) @@ -14536,7 +16355,7 @@ soap_get_mime_attachment(struct soap *soap, void *handle) } else { if (!flag) - { c = soap_get1(soap); + { c = soap_getchar(soap); if ((int)c == EOF) { if (content->ptr && soap->fmimewriteclose) soap->fmimewriteclose(soap, (void*)content->ptr); @@ -14545,11 +16364,11 @@ soap_get_mime_attachment(struct soap *soap, void *handle) } } if (flag || c == '\r') - { t = soap->msgbuf; - memset(t, 0, sizeof(soap->msgbuf)); - strcpy(t, "\n--"); + { memset((void*)soap->msgbuf, 0, sizeof(soap->msgbuf)); + soap_strcpy(soap->msgbuf, sizeof(soap->msgbuf), "\n--"); if (soap->mime.boundary) - strncat(t, soap->mime.boundary, sizeof(soap->msgbuf)-4); + soap_strncat(soap->msgbuf, sizeof(soap->msgbuf), soap->mime.boundary, sizeof(soap->msgbuf) - 4); + t = soap->msgbuf; do c = soap_getchar(soap); while (c == *t++); if ((int)c == EOF) @@ -14570,12 +16389,12 @@ soap_get_mime_attachment(struct soap *soap, void *handle) } } if (content->ptr && soap->fmimewrite) - { if ((soap->error = soap->fmimewrite(soap, (void*)content->ptr, soap->tmpbuf, i))) + { soap->error = soap->fmimewrite(soap, (void*)content->ptr, soap->tmpbuf, i); + if (soap->error) break; } } end: - *s = '\0'; /* make 0-terminated */ if (content->ptr) { if (!soap->error && soap->fmimewrite) soap->error = soap->fmimewrite(soap, (void*)content->ptr, soap->tmpbuf, i); @@ -14585,7 +16404,8 @@ end: return NULL; } else - { content->size = soap_size_block(soap, NULL, i+1) - 1; /* last block with '\0' */ + { *s = '\0'; /* make 0-terminated, just in case */ + content->size = soap_size_block(soap, NULL, i+1) - 1; /* last block with '\0' */ content->ptr = soap_save_block(soap, NULL, NULL, 0); } soap_resolve_attachment(soap, content); @@ -14614,13 +16434,14 @@ end: #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 soap_match_cid(struct soap *soap, const char *s, const char *t) -{ register size_t n; +{ size_t n; if (!s) return 1; if (!strcmp(s, t)) @@ -14643,15 +16464,16 @@ soap_match_cid(struct soap *soap, const char *s, const char *t) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 static void soap_resolve_attachment(struct soap *soap, struct soap_multipart *content) { if (content->id) - { register struct soap_xlist **xp = &soap->xlist; + { struct soap_xlist **xp = &soap->xlist; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving attachment data for id='%s'\n", content->id)); while (*xp) - { register struct soap_xlist *xq = *xp; + { struct soap_xlist *xq = *xp; if (!soap_match_cid(soap, xq->id, content->id)) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Found matching attachment id='%s' for content id='%s'\n", xq->id, content->id)); *xp = xq->next; @@ -14673,6 +16495,7 @@ soap_resolve_attachment(struct soap *soap, struct soap_multipart *content) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 @@ -14700,6 +16523,7 @@ soap_putmimehdr(struct soap *soap, struct soap_multipart *content) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 @@ -14712,7 +16536,7 @@ soap_putmime(struct soap *soap) DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Sending MIME attachments\n")); for (content = soap->mime.first; content; content = content->next) { void *handle; - if (soap->fmimereadopen && ((handle = soap->fmimereadopen(soap, (void*)content->ptr, content->id, content->type, content->description)) || soap->error)) + if (soap->fmimereadopen && ((handle = soap->fmimereadopen(soap, (void*)content->ptr, content->id, content->type, content->description)) != NULL || soap->error)) { size_t size = content->size; if (!handle) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fmimereadopen failed\n")); @@ -14741,7 +16565,8 @@ soap_putmime(struct soap *soap) bufsize = size; else bufsize = sizeof(soap->tmpbuf); - if (!(bufsize = soap->fmimeread(soap, handle, soap->tmpbuf, bufsize))) + bufsize = soap->fmimeread(soap, handle, soap->tmpbuf, bufsize); + if (!bufsize) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fmimeread failed: insufficient data (%lu bytes remaining from %lu bytes)\n", (unsigned long)size, (unsigned long)content->size)); soap->error = SOAP_EOF; break; @@ -14766,6 +16591,7 @@ soap_putmime(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 @@ -14780,6 +16606,7 @@ soap_set_dime(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 @@ -14796,6 +16623,7 @@ soap_set_mime(struct soap *soap, const char *boundary, const char *start) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 @@ -14810,6 +16638,7 @@ soap_clr_dime(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 @@ -14826,11 +16655,13 @@ soap_clr_mime(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 static struct soap_multipart* soap_new_multipart(struct soap *soap, struct soap_multipart **first, struct soap_multipart **last, char *ptr, size_t size) { struct soap_multipart *content; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "New MIME attachment %p (%lu)\n", ptr, (unsigned long)size)); content = (struct soap_multipart*)soap_malloc(soap, sizeof(struct soap_multipart)); if (content) { content->next = NULL; @@ -14854,6 +16685,7 @@ soap_new_multipart(struct soap *soap, struct soap_multipart **first, struct soap #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 @@ -14872,6 +16704,7 @@ soap_set_dime_attachment(struct soap *soap, char *ptr, size_t size, const char * #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 @@ -14892,6 +16725,7 @@ soap_set_mime_attachment(struct soap *soap, char *ptr, size_t size, enum soap_mi #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 SOAP_FMAC1 @@ -14906,13 +16740,14 @@ soap_next_multipart(struct soap_multipart *content) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 static void soap_select_mime_boundary(struct soap *soap) { while (!soap->mime.boundary || soap_valid_mime_boundary(soap)) - { register char *s = soap->mime.boundary; - register size_t n = 0; + { char *s = soap->mime.boundary; + size_t n = 0; if (s) n = strlen(s); if (n < 16) @@ -14921,14 +16756,16 @@ soap_select_mime_boundary(struct soap *soap) if (!s) return; } - strcpy(s, "=="); - s += 2; + *s++ = '='; + *s++ = '='; n -= 4; while (n) { *s++ = soap_base64o[soap_random & 0x3F]; n--; } - strcpy(s, "=="); + *s++ = '='; + *s++ = '='; + *s = '\0'; } if (!soap->mime.start) soap->mime.start = "<SOAP-ENV:Envelope>"; @@ -14937,19 +16774,20 @@ soap_select_mime_boundary(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_LEANER #ifndef PALM_1 static int soap_valid_mime_boundary(struct soap *soap) -{ register struct soap_multipart *content; - register size_t k; +{ struct soap_multipart *content; + size_t k; if (soap->fmimeread) return SOAP_OK; k = strlen(soap->mime.boundary); for (content = soap->mime.first; content; content = content->next) { if (content->ptr && content->size >= k) - { register const char *p = (const char*)content->ptr; - register size_t i; + { const char *p = (const char*)content->ptr; + size_t i; for (i = 0; i < content->size - k; i++, p++) { if (!strncmp(p, soap->mime.boundary, k)) return SOAP_ERR; @@ -14962,6 +16800,7 @@ soap_valid_mime_boundary(struct soap *soap) #endif /******************************************************************************/ + #ifdef WITH_GZIP #ifndef PALM_1 static int @@ -14970,15 +16809,16 @@ soap_getgziphdr(struct soap *soap) soap_wchar c = 0, f = 0; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Get gzip header\n")); for (i = 0; i < 9; i++) - { if ((int)(c = soap_get1(soap) == EOF)) - return soap->error = SOAP_ZLIB_ERROR; + { c = soap_get1(soap); if (i == 1 && c == 8) soap->z_dict = 0; if (i == 2) f = c; } if (f & 0x04) /* FEXTRA */ - { for (i = soap_get1(soap) | (soap_get1(soap) << 8); i; i--) + { i = soap_get1(soap); + i |= soap_get1(soap) << 8; + while (i-- > 0) { if ((int)soap_get1(soap) == EOF) return soap->error = SOAP_ZLIB_ERROR; } @@ -14994,7 +16834,8 @@ soap_getgziphdr(struct soap *soap) while (c && (int)c != EOF); } if ((int)c != EOF && (f & 0x02)) /* skip FHCRC (CRC32 is used) */ - { if ((int)(c = soap_get1(soap)) != EOF) + { c = soap_get1(soap); + if ((int)c != EOF) c = soap_get1(soap); } if ((int)c == EOF) @@ -15005,6 +16846,7 @@ soap_getgziphdr(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int @@ -15025,7 +16867,7 @@ soap_begin_serve(struct soap *soap) { if (soap->error < SOAP_STOP) { #ifdef WITH_FASTCGI - soap_send_fault(soap); + (void)soap_send_fault(soap); #else return soap_send_fault(soap); #endif @@ -15037,18 +16879,21 @@ soap_begin_serve(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 soap_begin_recv(struct soap *soap) -{ register soap_wchar c; +{ soap_wchar c; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Initializing for input from socket=%d/fd=%d\n", soap->socket, soap->recvfd)); soap->error = SOAP_OK; - soap->filterstop = SOAP_OK; +#ifndef WITH_LEANER + soap->recverror = SOAP_OK; +#endif soap_free_temp(soap); soap_set_local_namespaces(soap); - soap->version = 0; /* don't assume we're parsing SOAP content by default */ + soap->version = 0; /* don't assume we're parsing SOAP content by default */ #ifndef WITH_NOIDREF soap_free_iht(soap); #endif @@ -15062,11 +16907,11 @@ soap_begin_recv(struct soap *soap) } if (!(soap->mode & SOAP_IO_KEEPALIVE)) soap->keep_alive = 0; + soap->shaky = 0; soap->ahead = 0; soap->peeked = 0; soap->level = 0; soap->part = SOAP_BEGIN; - soap->alloced = 0; soap->body = 1; soap->count = 0; soap->length = 0; @@ -15093,7 +16938,7 @@ soap_begin_recv(struct soap *soap) #ifdef WIN32 #ifndef UNDER_CE #ifndef WITH_FASTCGI - if (!soap_valid_socket(soap->socket) && !soap->is) /* Set win32 stdout or soap->sendfd to BINARY, e.g. to support DIME */ + if (!soap_valid_socket(soap->socket) && !soap->is && soap->recvfd >= 0) /* Set win32 stdin or soap->recvfd to BINARY, e.g. to support DIME */ #ifdef __BORLANDC__ setmode(soap->recvfd, _O_BINARY); #else @@ -15106,10 +16951,16 @@ soap_begin_recv(struct soap *soap) soap->mode &= ~SOAP_ENC_ZLIB; soap->zlib_in = SOAP_ZLIB_NONE; soap->zlib_out = SOAP_ZLIB_NONE; - soap->d_stream->next_in = Z_NULL; + if (!soap->d_stream) + { soap->d_stream = (z_stream*)SOAP_MALLOC(soap, sizeof(z_stream)); + soap->d_stream->zalloc = Z_NULL; + soap->d_stream->zfree = Z_NULL; + soap->d_stream->opaque = Z_NULL; + soap->d_stream->next_in = Z_NULL; + } soap->d_stream->avail_in = 0; soap->d_stream->next_out = (Byte*)soap->buf; - soap->d_stream->avail_out = SOAP_BUFLEN; + soap->d_stream->avail_out = sizeof(soap->buf); soap->z_ratio_in = 1.0; #endif #ifdef WITH_OPENSSL @@ -15117,7 +16968,7 @@ soap_begin_recv(struct soap *soap) ERR_clear_error(); #endif #ifndef WITH_LEANER - if (soap->fprepareinitrecv && (soap->error = soap->fprepareinitrecv(soap))) + if (soap->fprepareinitrecv && (soap->error = soap->fprepareinitrecv(soap)) != SOAP_OK) return soap->error; #endif c = soap_getchar(soap); @@ -15137,8 +16988,8 @@ soap_begin_recv(struct soap *soap) soap->z_crc = crc32(0L, NULL, 0); DBGLOG(TEST, SOAP_MESSAGE(fdebug, "gzip initialized\n")); if (!soap->z_buf) - soap->z_buf = (char*)SOAP_MALLOC(soap, SOAP_BUFLEN); - memcpy(soap->z_buf, soap->buf, SOAP_BUFLEN); + soap->z_buf = (char*)SOAP_MALLOC(soap, sizeof(soap->buf)); + soap_memcpy((void*)soap->z_buf, sizeof(soap->buf), (const void*)soap->buf, sizeof(soap->buf)); /* should not chunk over plain transport, so why bother to check? */ /* if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) */ /* soap->z_buflen = soap->bufidx; */ @@ -15161,8 +17012,9 @@ soap_begin_recv(struct soap *soap) #endif { /* skip BOM */ if (c == 0xEF && soap_get0(soap) == 0xBB) - { c = soap_get1(soap); - if ((c = soap_get1(soap)) == 0xBF) + { soap_get1(soap); + c = soap_get1(soap); + if (c == 0xBF) { soap->mode &= ~SOAP_ENC_LATIN; c = soap_getchar(soap); } @@ -15186,7 +17038,8 @@ soap_begin_recv(struct soap *soap) soap->mode &= ~SOAP_IO; soap->error = soap->fparse(soap); if (soap->error && soap->error < SOAP_STOP) - { soap->keep_alive = 0; /* force close later */ + { if (soap->error < 200 || soap->error > 202) + soap->keep_alive = 0; /* force close later if error but excluding HTTP codes 200..202 */ return soap->error; } if (soap->error == SOAP_STOP) @@ -15248,8 +17101,8 @@ soap_begin_recv(struct soap *soap) DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflate initialized\n")); soap->mode |= SOAP_ENC_ZLIB; if (!soap->z_buf) - soap->z_buf = (char*)SOAP_MALLOC(soap, SOAP_BUFLEN); - memcpy(soap->z_buf, soap->buf, SOAP_BUFLEN); + soap->z_buf = (char*)SOAP_MALLOC(soap, sizeof(soap->buf)); + soap_memcpy((void*)soap->z_buf, sizeof(soap->buf), (const void*)soap->buf, sizeof(soap->buf)); soap->d_stream->next_in = (Byte*)(soap->z_buf + soap->bufidx); soap->d_stream->avail_in = (unsigned int)(soap->buflen - soap->bufidx); soap->z_buflen = soap->buflen; @@ -15260,14 +17113,15 @@ soap_begin_recv(struct soap *soap) if (soap->fpreparerecv && (soap->mode & SOAP_IO) != SOAP_IO_CHUNK && soap->buflen > soap->bufidx) { int r; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Invoking fpreparerecv\n")); - if ((r = soap->fpreparerecv(soap, soap->buf + soap->bufidx, soap->buflen - soap->bufidx))) + r = soap->fpreparerecv(soap, soap->buf + soap->bufidx, soap->buflen - soap->bufidx); + if (r) return soap->error = r; } #endif if (soap_get0(soap) == (int)EOF) - { if (soap->status == 0 || soap->status == 200) - return soap->error = SOAP_NO_DATA; /* HTTP OK: always expect data */ - return soap->error = soap->status; + { if (soap->status == 0) + return soap->error = SOAP_NO_DATA; /* server side expects data */ + return soap->error = soap->status; /* client side received HTTP status code */ } if (soap->error) { if (soap->error == SOAP_FORM && soap->fform) @@ -15282,7 +17136,8 @@ soap_begin_recv(struct soap *soap) #ifndef WITH_LEANER if (soap->mode & SOAP_ENC_MIME) { do /* skip preamble */ - { if ((int)(c = soap_getchar(soap)) == EOF) + { c = soap_getchar(soap); + if ((int)c == EOF) return soap->error = SOAP_CHK_EOF; } while (c != '-' || soap_get0(soap) != '-'); soap_unget(soap, c); @@ -15320,6 +17175,7 @@ soap_begin_recv(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -15328,8 +17184,10 @@ soap_envelope_begin_out(struct soap *soap) { #ifndef WITH_LEANER size_t n = 0; - if ((soap->mode & SOAP_ENC_MIME) && soap->mime.boundary && soap->mime.start && strlen(soap->mime.boundary) + strlen(soap->mime.start) < sizeof(soap->tmpbuf) - 80 ) + if ((soap->mode & SOAP_ENC_MIME) && soap->mime.boundary && soap->mime.start) { const char *s; + if (strlen(soap->mime.boundary) + strlen(soap->mime.start) + 140 > sizeof(soap->tmpbuf)) + return soap->error = SOAP_EOM; if ((soap->mode & SOAP_ENC_DIME) && !(soap->mode & SOAP_ENC_MTOM)) s = "application/dime"; else if (soap->version == 2) @@ -15342,17 +17200,13 @@ soap_envelope_begin_out(struct soap *soap) s = "application/xop+xml; charset=utf-8; type=\"text/xml\""; else s = "text/xml; charset=utf-8"; -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), "--%s\r\nContent-Type: %s\r\nContent-Transfer-Encoding: binary\r\nContent-ID: %s\r\n\r\n", soap->mime.boundary, s, soap->mime.start); -#else - sprintf(soap->tmpbuf, "--%s\r\nContent-Type: %s\r\nContent-Transfer-Encoding: binary\r\nContent-ID: %s\r\n\r\n", soap->mime.boundary, s, soap->mime.start); -#endif + (SOAP_SNPRINTF_SAFE(soap->tmpbuf, sizeof(soap->tmpbuf)), "--%s\r\nContent-Type: %s\r\nContent-Transfer-Encoding: binary\r\nContent-ID: %s\r\n\r\n", soap->mime.boundary, s, soap->mime.start); n = strlen(soap->tmpbuf); if (soap_send_raw(soap, soap->tmpbuf, n)) return soap->error; } if (soap->mode & SOAP_IO_LENGTH) - soap->dime.size = soap->count; /* DIME in MIME correction */ + soap->dime.size = soap->count; /* DIME in MIME correction */ if (!(soap->mode & SOAP_IO_LENGTH) && (soap->mode & SOAP_ENC_DIME)) { if (soap_putdimehdr(soap)) return soap->error; @@ -15366,6 +17220,7 @@ soap_envelope_begin_out(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -15374,16 +17229,12 @@ soap_envelope_end_out(struct soap *soap) { if (soap->version == 0) return SOAP_OK; if (soap_element_end_out(soap, "SOAP-ENV:Envelope") - || soap_send_raw(soap, "\r\n", 2)) /* 2.8: always emit \r\n */ + || soap_send_raw(soap, "\r\n", 2)) /* 2.8: always emit \r\n */ return soap->error; #ifndef WITH_LEANER if ((soap->mode & SOAP_IO_LENGTH) && (soap->mode & SOAP_ENC_DIME) && !(soap->mode & SOAP_ENC_MTOM)) - { soap->dime.size = soap->count - soap->dime.size; /* DIME in MIME correction */ -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->id, sizeof(soap->id), soap->dime_id_format, 0); -#else - sprintf(soap->id, soap->dime_id_format, 0); -#endif + { soap->dime.size = soap->count - soap->dime.size; /* DIME in MIME correction */ + (SOAP_SNPRINTF(soap->id, sizeof(soap->id), strlen(soap->dime_id_format) + 20), soap->dime_id_format, 0); soap->dime.id = soap->id; if (soap->local_namespaces) { if (soap->local_namespaces[0].out) @@ -15406,26 +17257,28 @@ soap_envelope_end_out(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_LEAN #ifndef PALM_1 SOAP_FMAC1 char* SOAP_FMAC2 soap_get_http_body(struct soap *soap, size_t *len) -{ if (len) - *len = 0; +{ #ifndef WITH_LEAN - register size_t l = 0, n = 0; - register char *s; + size_t l = 0, n = 0; + char *s; + if (len) + *len = 0; /* get HTTP body length */ if (!(soap->mode & SOAP_ENC_ZLIB) && (soap->mode & SOAP_IO) != SOAP_IO_CHUNK) { n = soap->length; if (!n) return NULL; } - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Parsing HTTP body (mode=0x%x,len=%lu)\n", soap->mode, (unsigned long)n)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Parsing HTTP body (mode=0x%x,len=%lu)\n", soap->mode, (unsigned long)n)); #ifdef WITH_FAST - soap->labidx = 0; /* use look-aside buffer */ + soap->labidx = 0; /* use look-aside buffer */ #else if (soap_new_block(soap) == NULL) return NULL; @@ -15433,19 +17286,20 @@ soap_get_http_body(struct soap *soap, size_t *len) for (;;) { #ifdef WITH_FAST - register size_t i, k; - if (soap_append_lab(soap, NULL, 0)) /* allocate more space in look-aside buffer if necessary */ + size_t i, k; + if (soap_append_lab(soap, NULL, 0)) /* allocate more space in look-aside buffer if necessary */ return NULL; - s = soap->labbuf + soap->labidx; /* space to populate */ - k = soap->lablen - soap->labidx; /* number of bytes available */ - soap->labidx = soap->lablen; /* claim this space */ + s = soap->labbuf + soap->labidx; /* space to populate */ + k = soap->lablen - soap->labidx; /* number of bytes available */ + soap->labidx = soap->lablen; /* claim this space */ #else - register size_t i, k = SOAP_BLKLEN; - if (!(s = (char*)soap_push_block(soap, NULL, k))) + size_t i, k = SOAP_BLKLEN; + s = (char*)soap_push_block(soap, NULL, k); + if (!s) return NULL; #endif for (i = 0; i < k; i++) - { register soap_wchar c; + { soap_wchar c; l++; if (n > 0 && l > n) goto end; @@ -15460,14 +17314,17 @@ end: if (len) *len = l - 1; /* len excludes terminating \0 */ #ifdef WITH_FAST - if ((s = (char*)soap_malloc(soap, l))) - memcpy(s, soap->labbuf, l); + s = (char*)soap_malloc(soap, l); + if (s) + soap_memcpy((void*)s, l, (const void*)soap->labbuf, l); #else soap_size_block(soap, NULL, i+1); - s = soap_save_block(soap, NULL, 0); + s = soap_save_block(soap, NULL, NULL, 0); #endif return s; #else + if (len) + *len = 0; return NULL; #endif } @@ -15475,50 +17332,32 @@ end: #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 soap_envelope_begin_in(struct soap *soap) -{ register struct Namespace *p; - soap->part = SOAP_IN_ENVELOPE; +{ soap->part = SOAP_IN_ENVELOPE; if (soap_element_begin_in(soap, "SOAP-ENV:Envelope", 0, NULL)) { if (soap->error == SOAP_TAG_MISMATCH) { if (!soap_element_begin_in(soap, "Envelope", 0, NULL)) soap->error = SOAP_VERSIONMISMATCH; else if (soap->status == 0 || (soap->status >= 200 && soap->status <= 299)) - return SOAP_OK; /* allow non-SOAP XML content to be captured */ + return SOAP_OK; /* allow non-SOAP (REST) XML content to be captured */ soap->error = soap->status; } else if (soap->status) soap->error = soap->status; return soap->error; } - p = soap->local_namespaces; - if (p) - { const char *ns = p[0].out; - if (!ns) - ns = p[0].ns; - if (!strcmp(ns, soap_env1)) - { soap->version = 1; /* make sure we use SOAP 1.1 */ - if (p[1].out) - SOAP_FREE(soap, p[1].out); - if ((p[1].out = (char*)SOAP_MALLOC(soap, sizeof(soap_enc1)))) - strcpy(p[1].out, soap_enc1); - } - else if (!strcmp(ns, soap_env2)) - { soap->version = 2; /* make sure we use SOAP 1.2 */ - if (p[1].out) - SOAP_FREE(soap, p[1].out); - if ((p[1].out = (char*)SOAP_MALLOC(soap, sizeof(soap_enc2)))) - strcpy(p[1].out, soap_enc2); - } - } + soap_get_version(soap); return SOAP_OK; } #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int @@ -15532,6 +17371,7 @@ soap_envelope_end_in(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -15551,6 +17391,7 @@ soap_body_begin_out(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -15566,6 +17407,7 @@ soap_body_end_out(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -15583,6 +17425,7 @@ soap_body_begin_in(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -15598,6 +17441,7 @@ soap_body_end_in(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -15612,13 +17456,14 @@ soap_recv_header(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 void SOAP_FMAC2 soap_set_endpoint(struct soap *soap, const char *endpoint) -{ register const char *s; - register size_t i, n; +{ const char *s, *t; + size_t i, n; soap->endpoint[0] = '\0'; soap->host[0] = '\0'; soap->path[0] = '/'; @@ -15630,13 +17475,36 @@ soap_set_endpoint(struct soap *soap, const char *endpoint) if (!soap_tag_cmp(endpoint, "https:*")) soap->port = 443; #endif - strncpy(soap->endpoint, endpoint, sizeof(soap->endpoint)); - soap->endpoint[sizeof(soap->endpoint) - 1] = '\0'; + soap_strcpy(soap->endpoint, sizeof(soap->endpoint), endpoint); s = strchr(endpoint, ':'); if (s && s[1] == '/' && s[2] == '/') s += 3; else s = endpoint; +#if !defined(WITH_NOHTTP) || !defined(WITH_LEANER) + t = strchr(s, '@'); + if (t && *s != ':' && *s != '@') + { size_t l = t - s + 1; + char *r = (char*)soap_malloc(soap, l); + n = s - endpoint; + if (r) + { s = soap_decode(r, l, s, ":@"); + soap->userid = r; + soap->passwd = SOAP_STR_EOS; + if (*s == ':') + { s++; + if (*s != '@') + { l = t - s + 1; + r = r + strlen(r) + 1; + s = soap_decode(r, l, s, "@"); + soap->passwd = r; + } + } + } + s++; + soap_strcpy(soap->endpoint + n, sizeof(soap->endpoint) - n, s); + } +#endif n = strlen(s); if (n >= sizeof(soap->host)) n = sizeof(soap->host) - 1; @@ -15674,13 +17542,14 @@ soap_set_endpoint(struct soap *soap, const char *endpoint) break; } if (i < n && s[i]) - { strncpy(soap->path, s + i, sizeof(soap->path)); - soap->path[sizeof(soap->path) - 1] = '\0'; - } + soap_strcpy(soap->path, sizeof(soap->path), s + i); + if (soap->userid && !soap->authrealm) + soap->authrealm = soap->host; } #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int @@ -15691,39 +17560,44 @@ soap_connect(struct soap *soap, const char *endpoint, const char *action) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 soap_connect_command(struct soap *soap, int http_command, const char *endpoints, const char *action) -{ char *endpoint; - const char *s; - if (endpoints && (s = strchr(endpoints, ' '))) - { endpoint = (char*)SOAP_MALLOC(soap, strlen(endpoints) + 1); - for (;;) - { strncpy(endpoint, endpoints, s - endpoints); - endpoint[s - endpoints] = '\0'; - if (soap_try_connect_command(soap, http_command, endpoint, action) != SOAP_TCP_ERROR) - break; - if (!*s) - break; - soap->error = SOAP_OK; - while (*s == ' ') - s++; - endpoints = s; - s = strchr(endpoints, ' '); - if (!s) - s = endpoints + strlen(endpoints); +{ if (endpoints) + { const char *s; + s = strchr(endpoints, ' '); + if (s) + { size_t l = strlen(endpoints); + char *endpoint = (char*)SOAP_MALLOC(soap, l + 1); + for (;;) + { soap_strncpy(endpoint, l + 1, endpoints, s - endpoints); + endpoint[s - endpoints] = '\0'; + if (soap_try_connect_command(soap, http_command, endpoint, action) != SOAP_TCP_ERROR) + break; + if (!*s) + break; + soap->error = SOAP_OK; + while (*s == ' ') + s++; + endpoints = s; + s = strchr(endpoints, ' '); + if (!s) + s = endpoints + strlen(endpoints); + } + SOAP_FREE(soap, endpoint); } - SOAP_FREE(soap, endpoint); + else + soap_try_connect_command(soap, http_command, endpoints, action); } - else - soap_try_connect_command(soap, http_command, endpoints, action); return soap->error; } #endif /******************************************************************************/ + #ifndef PALM_1 static int soap_try_connect_command(struct soap *soap, int http_command, const char *endpoint, const char *action) @@ -15731,18 +17605,19 @@ soap_try_connect_command(struct soap *soap, int http_command, const char *endpoi int port; size_t count; soap->error = SOAP_OK; - strcpy(host, soap->host); /* save previous host name: if != then reconnect */ + soap_strcpy(host, sizeof(soap->host), soap->host); /* save previous host name: if != then reconnect */ port = soap->port; /* save previous port to compare */ soap->status = http_command; soap_set_endpoint(soap, endpoint); + soap->action = soap_strdup(soap, action); #ifndef WITH_LEANER if (soap->fconnect) - { if ((soap->error = soap->fconnect(soap, endpoint, soap->host, soap->port))) + { soap->error = soap->fconnect(soap, endpoint, soap->host, soap->port); + if (soap->error) return soap->error; } else #endif - soap->action = soap_strdup(soap, action); if (soap->fopen && *soap->host) { if (!soap->keep_alive || !soap_valid_socket(soap->socket) || strcmp(soap->host, host) || soap->port != port || !soap->fpoll || soap->fpoll(soap)) { soap->error = SOAP_OK; @@ -15755,7 +17630,7 @@ soap_try_connect_command(struct soap *soap, int http_command, const char *endpoi soap->omode &= ~SOAP_IO_UDP; /* to force close */ } soap_closesock(soap); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Connect/reconnect to '%s' host='%s' path='%s' port=%d\n", endpoint?endpoint:"(null)", soap->host, soap->path, soap->port)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Connect/reconnect to '%s' host='%s' path='%s' port=%d\n", endpoint?endpoint:"(null)", soap->host, soap->path, soap->port)); if (!soap->keep_alive || !soap_valid_socket(soap->socket)) { soap->socket = soap->fopen(soap, endpoint, soap->host, soap->port); if (soap->error) @@ -15781,7 +17656,8 @@ soap_try_connect_command(struct soap *soap, int http_command, const char *endpoi soap->mode &= ~(SOAP_IO | SOAP_ENC_ZLIB); if ((k & SOAP_IO) != SOAP_IO_FLUSH) soap->mode |= SOAP_IO_BUFFER; - if ((soap->error = soap->fpost(soap, endpoint, soap->host, soap->port, soap->path, action, count))) + soap->error = soap->fpost(soap, endpoint, soap->host, soap->port, soap->path, action, count); + if (soap->error) return soap->error; #ifndef WITH_LEANER if ((k & SOAP_IO) == SOAP_IO_CHUNK) @@ -15799,6 +17675,7 @@ soap_try_connect_command(struct soap *soap, int http_command, const char *endpoi #endif /******************************************************************************/ + #ifdef WITH_NTLM #ifndef PALM_1 static int @@ -15818,15 +17695,15 @@ soap_ntlm_handshake(struct soap *soap, int command, const char *endpoint, const int s = soap->status; char *a = soap->action; short v = soap->version; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "NTLM '%s'\n", soap->ntlm_challenge)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "NTLM '%s'\n", soap->ntlm_challenge)); if (!*soap->ntlm_challenge) - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "NTLM S->C Type 1: received NTLM authentication challenge from server\n")); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "NTLM S->C Type 1: received NTLM authentication challenge from server\n")); /* S -> C 401 Unauthorized WWW-Authenticate: NTLM */ buildSmbNtlmAuthRequest(&req, userid, soap->authrealm); - soap->ntlm_challenge = soap_s2base64(soap, (unsigned char*)&req, NULL, SmbLength(&req)); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "NTLM C->S Type 2: sending NTLM authorization to server\nAuthorization: NTLM %s\n", soap->ntlm_challenge)); + soap->ntlm_challenge = soap_s2base64(soap, (unsigned char*)(void*)&req, NULL, SmbLength(&req)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "NTLM C->S Type 2: sending NTLM authorization to server\nAuthorization: NTLM %s\n", soap->ntlm_challenge)); /* C -> S GET ... Authorization: NTLM TlRMTVNTUAABAAAAA7IAAAoACgApAAAACQAJACAAAABMSUdIVENJVFlVUlNBLU1JTk9S */ @@ -15840,12 +17717,12 @@ soap_ntlm_handshake(struct soap *soap, int command, const char *endpoint, const return soap->error; soap->mode = m; soap->keep_alive = k; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "NTLM S->C Type 2: waiting on server NTLM response\n")); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "NTLM S->C Type 2: waiting on server NTLM response\n")); oldheader = soap->header; if (soap_begin_recv(soap)) if (soap->error == SOAP_EOF) return soap->error; - soap_end_recv(soap); + (void)soap_end_recv(soap); soap->header = oldheader; soap->length = l; if (soap->status != 401 && soap->status != 407) @@ -15857,8 +17734,8 @@ soap_ntlm_handshake(struct soap *soap, int command, const char *endpoint, const */ soap_base642s(soap, soap->ntlm_challenge, (char*)&ch, sizeof(tSmbNtlmAuthChallenge), NULL); buildSmbNtlmAuthResponse(&ch, &res, userid, passwd); - soap->ntlm_challenge = soap_s2base64(soap, (unsigned char*)&res, NULL, SmbLength(&res)); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "NTLM C->S Type 3: sending NTLM authorization to server\nAuthorization: NTLM %s\n", soap->ntlm_challenge)); + soap->ntlm_challenge = soap_s2base64(soap, (unsigned char*)(void*)&res, NULL, SmbLength(&res)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "NTLM C->S Type 3: sending NTLM authorization to server\nAuthorization: NTLM %s\n", soap->ntlm_challenge)); /* C -> S GET ... Authorization: NTLM TlRMTVNTUAADAAAAGAAYAHIAAAAYABgAigAAABQAFABAAAAADAAMAFQAAAASABIAYAAAAAAAAACiAAAAAYIAAFUAUgBTAEEALQBNAEkATgBPAFIAWgBhAHAAaABvAGQATABJAEcASABUAEMASQBUAFkArYfKbe/jRoW5xDxHeoxC1gBmfWiS5+iX4OAN4xBKG/IFPwfH3agtPEia6YnhsADT */ @@ -15881,14 +17758,15 @@ soap_ntlm_handshake(struct soap *soap, int command, const char *endpoint, const #endif /******************************************************************************/ -#ifndef WITH_LEAN + +#if !defined(WITH_LEAN) || defined(WITH_NTLM) SOAP_FMAC1 char* SOAP_FMAC2 soap_s2base64(struct soap *soap, const unsigned char *s, char *t, int n) -{ register int i; - register unsigned long m; - register char *p; +{ int i; + unsigned long m; + char *p; if (!t) t = (char*)soap_malloc(soap, (n + 2) / 3 * 4 + 1); if (!t) @@ -15923,15 +17801,16 @@ soap_s2base64(struct soap *soap, const unsigned char *s, char *t, int n) #endif /******************************************************************************/ -#ifndef WITH_LEAN + +#if !defined(WITH_LEAN) || defined(WITH_NTLM) SOAP_FMAC1 const char* SOAP_FMAC2 soap_base642s(struct soap *soap, const char *s, char *t, size_t l, int *n) -{ register size_t i, j; - register soap_wchar c; - register unsigned long m; - register const char *p; +{ size_t i, j; + soap_wchar c; + unsigned long m; + const char *p; if (!s || !*s) { if (n) *n = 0; @@ -15940,7 +17819,7 @@ soap_base642s(struct soap *soap, const char *s, char *t, size_t l, int *n) return SOAP_NON_NULL; } if (!t) - { l = (strlen(s) + 3) / 4 * 3 + 1; /* make sure enough space for \0 */ + { l = (strlen(s) + 3) / 4 * 3 + 1; /* space for raw binary and \0 */ t = (char*)soap_malloc(soap, l); } if (!t) @@ -16004,12 +17883,13 @@ soap_base642s(struct soap *soap, const char *s, char *t, size_t l, int *n) #endif /******************************************************************************/ + #ifndef WITH_LEAN SOAP_FMAC1 char* SOAP_FMAC2 soap_s2hex(struct soap *soap, const unsigned char *s, char *t, int n) -{ register char *p; +{ char *p; if (!t) t = (char*)soap_malloc(soap, 2 * n + 1); if (!t) @@ -16018,7 +17898,7 @@ soap_s2hex(struct soap *soap, const unsigned char *s, char *t, int n) t[0] = '\0'; if (s) { for (; n > 0; n--) - { register int m = *s++; + { int m = *s++; *t++ = (char)((m >> 4) + (m > 159 ? 'a' - 10 : '0')); m &= 0x0F; *t++ = (char)(m + (m > 9 ? 'a' - 10 : '0')); @@ -16030,12 +17910,13 @@ soap_s2hex(struct soap *soap, const unsigned char *s, char *t, int n) #endif /******************************************************************************/ + #ifndef WITH_LEAN SOAP_FMAC1 const char* SOAP_FMAC2 soap_hex2s(struct soap *soap, const char *s, char *t, size_t l, int *n) -{ register const char *p; +{ const char *p; if (!s || !*s) { if (n) *n = 0; @@ -16044,14 +17925,14 @@ soap_hex2s(struct soap *soap, const char *s, char *t, size_t l, int *n) return SOAP_NON_NULL; } if (!t) - { l = strlen(s) / 2 + 1; /* make sure enough space for \0 */ + { l = strlen(s) / 2 + 1; /* make sure enough space for \0 */ t = (char*)soap_malloc(soap, l); } if (!t) return NULL; p = t; while (l) - { register int d1, d2; + { int d1, d2; d1 = *s++; if (!d1) break; @@ -16070,6 +17951,7 @@ soap_hex2s(struct soap *soap, const char *s, char *t, size_t l, int *n) #endif /******************************************************************************/ + #ifndef WITH_NOHTTP #ifndef PALM_1 SOAP_FMAC1 @@ -16077,10 +17959,11 @@ int SOAP_FMAC2 soap_puthttphdr(struct soap *soap, int status, size_t count) { if (soap->status != SOAP_GET && soap->status != SOAP_DEL && soap->status != SOAP_CONNECT) - { register const char *s = "text/xml; charset=utf-8"; - register int err = SOAP_OK; + { const char *s = "text/xml; charset=utf-8"; + int err = SOAP_OK; #ifndef WITH_LEANER - register const char *r = NULL; + const char *r = NULL; + size_t n; #endif if ((status == SOAP_FILE || soap->status == SOAP_PUT || soap->status == SOAP_POST_FILE) && soap->http_content && !strchr(s, 10) && !strchr(s, 13)) s = soap->http_content; @@ -16102,44 +17985,43 @@ soap_puthttphdr(struct soap *soap, int status, size_t count) else s = "application/dime"; } - if ((soap->mode & SOAP_ENC_MIME) && soap->mime.boundary && strlen(soap->mime.boundary) + strlen(soap->mime.start ? soap->mime.start : SOAP_STR_EOS) < sizeof(soap->tmpbuf) - 80) - { register const char *t; -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), "multipart/related; charset=utf-8; boundary=\"%s\"; type=\"", soap->mime.boundary); -#else - sprintf(soap->tmpbuf, "multipart/related; charset=utf-8; boundary=\"%s\"; type=\"", soap->mime.boundary); -#endif + if ((soap->mode & SOAP_ENC_MIME) && soap->mime.boundary) + { const char *t; + size_t l; + n = strlen(soap->mime.boundary); + (SOAP_SNPRINTF(soap->tmpbuf, sizeof(soap->tmpbuf), n + 53), "multipart/related; charset=utf-8; boundary=\"%s\"; type=\"", soap->mime.boundary); t = strchr(s, ';'); if (t) - strncat(soap->tmpbuf, s, t - s); + n = t - s; else - strcat(soap->tmpbuf, s); - if (soap->mime.start && strlen(soap->tmpbuf) + strlen(soap->mime.start) + 11 < sizeof(soap->tmpbuf)) - { strcat(soap->tmpbuf, "\"; start=\""); - strcat(soap->tmpbuf, soap->mime.start); + n = strlen(s); + l = strlen(soap->tmpbuf); + if (sizeof(soap->tmpbuf) - l > n) + soap_strncpy(soap->tmpbuf + l, sizeof(soap->tmpbuf) - l, s, n); + if (soap->mime.start) + { l = strlen(soap->tmpbuf); + n = strlen(soap->mime.start); + (SOAP_SNPRINTF(soap->tmpbuf + l, sizeof(soap->tmpbuf) - l, n + 10), "\"; start=\"%s", soap->mime.start); } - strcat(soap->tmpbuf, "\""); - if (r && strlen(soap->tmpbuf) + strlen(r) + 15 < sizeof(soap->tmpbuf)) - { strcat(soap->tmpbuf, "; start-info=\""); - strcat(soap->tmpbuf, r); - strcat(soap->tmpbuf, "\""); + if (r) + { l = strlen(soap->tmpbuf); + n = strlen(r); + (SOAP_SNPRINTF(soap->tmpbuf + l, sizeof(soap->tmpbuf) - l, n + 15), "\"; start-info=\"%s", r); } + l = strlen(soap->tmpbuf); + if (sizeof(soap->tmpbuf) - l > 1) + soap_strncpy(soap->tmpbuf + l, sizeof(soap->tmpbuf) - l, "\"", 1); } else - strncpy(soap->tmpbuf, s, sizeof(soap->tmpbuf)); - soap->tmpbuf[sizeof(soap->tmpbuf) - 1] = '\0'; - s = soap->tmpbuf; - if (status == SOAP_OK && soap->version == 2 && soap->action && strlen(soap->action) + strlen(s) < sizeof(soap->tmpbuf) - 80) - { -#ifdef HAVE_SNPRINTF - size_t l = strlen(s); - soap_snprintf(soap->tmpbuf + l, sizeof(soap->tmpbuf) - l, "; action=\"%s\"", soap->action); -#else - sprintf(soap->tmpbuf + strlen(s), "; action=\"%s\"", soap->action); -#endif + soap_strcpy(soap->tmpbuf, sizeof(soap->tmpbuf), s); + if (status == SOAP_OK && soap->version == 2 && soap->action) + { size_t l = strlen(soap->tmpbuf); + n = strlen(soap->action); + (SOAP_SNPRINTF(soap->tmpbuf + l, sizeof(soap->tmpbuf) - l, n + 11), "; action=\"%s\"", soap->action); } #endif - if ((err = soap->fposthdr(soap, "Content-Type", s))) + err = soap->fposthdr(soap, "Content-Type", soap->tmpbuf); + if (err) return err; #ifdef WITH_ZLIB if ((soap->omode & SOAP_ENC_ZLIB)) @@ -16158,13 +18040,7 @@ soap_puthttphdr(struct soap *soap, int status, size_t count) err = soap->fposthdr(soap, "Transfer-Encoding", "chunked"); else #endif - if (s) - { -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), "%lu", (unsigned long)count); -#else - sprintf(soap->tmpbuf, "%lu", (unsigned long)count); -#endif + { (SOAP_SNPRINTF(soap->tmpbuf, sizeof(soap->tmpbuf), 20), SOAP_ULONG_FORMAT, (ULONG64)count); err = soap->fposthdr(soap, "Content-Length", soap->tmpbuf); } if (err) @@ -16176,38 +18052,22 @@ soap_puthttphdr(struct soap *soap, int status, size_t count) #endif /******************************************************************************/ + #ifndef WITH_LEAN static const char* soap_set_validation_fault(struct soap *soap, const char *s, const char *t) { if (!t) t = SOAP_STR_EOS; if (*soap->tag) - { -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->msgbuf, sizeof(soap->msgbuf), "Validation constraint violation: %s%s in element '%s'", s, t ? t : SOAP_STR_EOS, soap->tag); -#else - if (strlen(soap->tag) + strlen(t) < sizeof(soap->msgbuf) - 100) - sprintf(soap->msgbuf, "Validation constraint violation: %s%s in element '%s'", s, t, soap->tag); - else - sprintf(soap->msgbuf, "Validation constraint violation: %s", s); -#endif - } + (SOAP_SNPRINTF(soap->msgbuf, sizeof(soap->msgbuf), strlen(s) + strlen(t) + strlen(soap->tag) + 47), "Validation constraint violation: %s%s in element '%s'", s, t, soap->tag); else - { -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->msgbuf, sizeof(soap->msgbuf), "Validation constraint violation: %s%s", s, t ? t : SOAP_STR_EOS); -#else - if (strlen(soap->tag) + strlen(t) < sizeof(soap->msgbuf) - 100) - sprintf(soap->msgbuf, "Validation constraint violation: %s%s", s, t); - else - sprintf(soap->msgbuf, "Validation constraint violation: %s", s); -#endif - } + (SOAP_SNPRINTF(soap->msgbuf, sizeof(soap->msgbuf), strlen(s) + strlen(t) + 33), "Validation constraint violation: %s%s", s, t); return soap->msgbuf; } #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 void @@ -16220,8 +18080,10 @@ soap_set_fault(struct soap *soap) if (!*c) { if (soap->version == 2) *c = "SOAP-ENV:Sender"; - else + else if (soap->version == 1) *c = "SOAP-ENV:Client"; + else + *c = "at source"; } if (*s) return; @@ -16238,22 +18100,25 @@ soap_set_fault(struct soap *soap) *s = soap_set_validation_fault(soap, "tag name or namespace mismatch", NULL); break; case SOAP_TYPE: - *s = soap_set_validation_fault(soap, "data type mismatch ", soap->type); + if (*soap->type) + *s = soap_set_validation_fault(soap, "type mismatch ", soap->type); + else + *s = soap_set_validation_fault(soap, "invalid value", NULL); break; case SOAP_SYNTAX_ERROR: - *s = "Well-formedness violation"; + *s = soap_set_validation_fault(soap, "syntax error", NULL); break; case SOAP_NO_TAG: - *s = "No tag: no XML root element or missing SOAP message body element"; + if (soap->version == 0 && soap->level == 0) + *s = soap_set_validation_fault(soap, "missing root element", NULL); + else if (soap->version != 0 && soap->level < 3) + *s = soap_set_validation_fault(soap, "missing SOAP message", NULL); + else + *s = soap_set_validation_fault(soap, "missing element", NULL); break; case SOAP_MUSTUNDERSTAND: *c = "SOAP-ENV:MustUnderstand"; -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->msgbuf, sizeof(soap->msgbuf), "The data in element '%s' must be understood but cannot be handled", soap->tag); -#else - strncpy(soap->msgbuf, soap->tag, sizeof(soap->msgbuf)); - soap->msgbuf[sizeof(soap->msgbuf) - 1] = '\0'; -#endif + (SOAP_SNPRINTF(soap->msgbuf, sizeof(soap->msgbuf), strlen(soap->tag) + 65), "The data in element '%s' must be understood but cannot be processed", soap->tag); *s = soap->msgbuf; break; case SOAP_VERSIONMISMATCH: @@ -16268,17 +18133,13 @@ soap_set_fault(struct soap *soap) *s = soap_set_validation_fault(soap, "namespace error", NULL); break; case SOAP_USER_ERROR: - *s = "User data error"; + *s = "User data access error"; break; case SOAP_FATAL_ERROR: - *s = "Fatal error"; + *s = "A fatal error has occurred"; break; case SOAP_NO_METHOD: -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->msgbuf, sizeof(soap->msgbuf), "Method '%s' not implemented: method name or namespace not recognized", soap->tag); -#else - sprintf(soap->msgbuf, "Method '%s' not implemented: method name or namespace not recognized", soap->tag); -#endif + (SOAP_SNPRINTF(soap->msgbuf, sizeof(soap->msgbuf), strlen(soap->tag) + 66), "Method '%s' not implemented: method name or namespace not recognized", soap->tag); *s = soap->msgbuf; break; case SOAP_NO_DATA: @@ -16348,7 +18209,7 @@ soap_set_fault(struct soap *soap) *s = "Plugin registry error"; break; case SOAP_DIME_ERROR: - *s = "DIME format error or max DIME size exceeds SOAP_MAXDIMESIZE"; + *s = "DIME format error or max DIME size exceeds SOAP_MAXDIMESIZE currently set to " SOAP_XSTRINGIFY(SOAP_MAXDIMESIZE); break; case SOAP_DIME_HREF: *s = "DIME href to missing attachment"; @@ -16370,11 +18231,7 @@ soap_set_fault(struct soap *soap) break; case SOAP_ZLIB_ERROR: #ifdef WITH_ZLIB -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->msgbuf, sizeof(soap->msgbuf), "Zlib/gzip error: '%s'", soap->d_stream->msg ? soap->d_stream->msg : SOAP_STR_EOS); -#else - sprintf(soap->msgbuf, "Zlib/gzip error: '%s'", soap->d_stream->msg ? soap->d_stream->msg : SOAP_STR_EOS); -#endif + (SOAP_SNPRINTF(soap->msgbuf, sizeof(soap->msgbuf), (soap->d_stream && soap->d_stream->msg ? strlen(soap->d_stream->msg) : 0) + 19), "Zlib/gzip error: '%s'", soap->d_stream && soap->d_stream->msg ? soap->d_stream->msg : SOAP_STR_EOS); *s = soap->msgbuf; #else *s = "Zlib/gzip not installed for (de)compression: recompile with -DWITH_GZIP"; @@ -16386,14 +18243,17 @@ soap_set_fault(struct soap *soap) case SOAP_PROHIBITED: *s = soap_set_validation_fault(soap, "prohibited attribute present", NULL); break; - case SOAP_OCCURS: - *s = soap_set_validation_fault(soap, "occurrence violation", NULL); + case SOAP_LEVEL: + *s = "Maximum XML nesting depth level exceeded: increase maxlevel"; break; case SOAP_LENGTH: - *s = soap_set_validation_fault(soap, "content range or length violation", NULL); + *s = soap_set_validation_fault(soap, "value range or content length violation", NULL); + break; + case SOAP_OCCURS: + *s = soap_set_validation_fault(soap, "occurrence constraint violation or maxoccurs exceeded", NULL); break; case SOAP_FD_EXCEEDED: - *s = "Maximum number of open connections was reached (no define HAVE_POLL): increase FD_SETSIZE"; + *s = "Maximum number of open connections was reached: increase FD_SETSIZE or define HAVE_POLL"; break; case SOAP_UTF_ERROR: *s = "UTF content encoding error"; @@ -16407,8 +18267,15 @@ soap_set_fault(struct soap *soap) *s = soap_strerror(soap); /* *s = soap->msgbuf */ #ifndef WITH_LEAN if (strlen(soap->msgbuf) + 25 < sizeof(soap->msgbuf)) - { memmove(soap->msgbuf + 25, soap->msgbuf, strlen(soap->msgbuf) + 1); - memcpy(soap->msgbuf, "End of file or no input: ", 25); + { soap_memmove((void*)(soap->msgbuf + 25), sizeof(soap->tmpbuf) - 25, (const void*)soap->msgbuf, strlen(soap->msgbuf) + 1); + if (soap->is) +#if defined(__cplusplus) && !defined(WITH_COMPAT) + soap_memcpy((void*)soap->msgbuf, sizeof(soap->msgbuf), (const void*)"End or bad std::istream: ", 25); +#else + soap_memcpy((void*)soap->msgbuf, sizeof(soap->msgbuf), (const void*)"End at NUL buffer input: ", 25); +#endif + else + soap_memcpy((void*)soap->msgbuf, sizeof(soap->msgbuf), (const void*)"End of file or no input: ", 25); } #endif break; @@ -16419,24 +18286,15 @@ soap_set_fault(struct soap *soap) default: #ifndef WITH_NOHTTP #ifndef WITH_LEAN - if (soap->error > 200 && soap->error < 600) - { -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->msgbuf, sizeof(soap->msgbuf), "HTTP Error: %d %s", soap->error, http_error(soap, soap->error)); -#else - sprintf(soap->msgbuf, "HTTP Error: %d %s", soap->error, http_error(soap, soap->error)); -#endif + if (soap->error >= 200 && soap->error < 600) + { const char *t = http_error(soap, soap->error); + (SOAP_SNPRINTF(soap->msgbuf, sizeof(soap->msgbuf), strlen(t) + 54), "Error %d: HTTP %d %s", soap->error, soap->error, t); *s = soap->msgbuf; } else #endif #endif - { -#ifdef HAVE_SNPRINTF - soap_snprintf(soap->msgbuf, sizeof(soap->msgbuf), "Error %d", soap->error); -#else - sprintf(soap->msgbuf, "Error %d", soap->error); -#endif + { (SOAP_SNPRINTF(soap->msgbuf, sizeof(soap->msgbuf), 26), "Error %d", soap->error); *s = soap->msgbuf; } } @@ -16444,21 +18302,22 @@ soap_set_fault(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 soap_send_fault(struct soap *soap) -{ register int status = soap->error; +{ int status = soap->error; if (status == SOAP_OK || status == SOAP_STOP) return soap_closesock(soap); - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Sending back fault struct for error code %d\n", soap->error)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Sending back fault struct for error code %d\n", soap->error)); soap->keep_alive = 0; /* to terminate connection */ soap_set_fault(soap); if (soap->error < 200 && soap->error != SOAP_FAULT) soap->header = NULL; if (status != SOAP_EOF || (!soap->recv_timeout && !soap->send_timeout)) - { register int r = 1; + { int r = 1; #ifndef WITH_NOIO if (soap->fpoll && soap->fpoll(soap)) r = 0; @@ -16480,25 +18339,26 @@ soap_send_fault(struct soap *soap) soap->encodingStyle = NULL; /* no encodingStyle in Faults */ soap_serializeheader(soap); soap_serializefault(soap); - soap_begin_count(soap); + (void)soap_begin_count(soap); if (soap->mode & SOAP_IO_LENGTH) - { soap_envelope_begin_out(soap); - soap_putheader(soap); - soap_body_begin_out(soap); - soap_putfault(soap); - soap_body_end_out(soap); - soap_envelope_end_out(soap); - } - soap_end_count(soap); + { if (soap_envelope_begin_out(soap) + || soap_putheader(soap) + || soap_body_begin_out(soap) + || soap_putfault(soap) + || soap_body_end_out(soap) + || soap_envelope_end_out(soap)) + return soap_closesock(soap); + } + (void)soap_end_count(soap); if (soap_response(soap, status) || soap_envelope_begin_out(soap) || soap_putheader(soap) || soap_body_begin_out(soap) || soap_putfault(soap) || soap_body_end_out(soap) - || soap_envelope_end_out(soap)) + || soap_envelope_end_out(soap) + || soap_end_send(soap)) return soap_closesock(soap); - soap_end_send(soap); } } soap->error = status; @@ -16507,13 +18367,14 @@ soap_send_fault(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 soap_recv_fault(struct soap *soap, int check) -{ register int status = soap->error; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Check if receiving SOAP Fault\n")); +{ int status = soap->status; + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Check (%d) if receiving SOAP Fault (status = %d)\n", check, status)); if (!check) { /* try getfault when no tag or tag mismatched at level 2, otherwise ret */ if (soap->error != SOAP_NO_TAG @@ -16521,55 +18382,64 @@ soap_recv_fault(struct soap *soap, int check) return soap->error; } else if (soap->version == 0) /* check == 1 but no SOAP: do not parse SOAP Fault */ + { + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Not a SOAP protocol\n")); return SOAP_OK; + } soap->error = SOAP_OK; if (soap_getfault(soap)) { /* check flag set: check if SOAP Fault is present, if not just return */ - if (check && soap->error == SOAP_TAG_MISMATCH && soap->level == 2) + if (check && ((soap->error == SOAP_TAG_MISMATCH && soap->level == 2) || soap->error == SOAP_NO_TAG)) return soap->error = SOAP_OK; - DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Error: soap_get_soapfault() failed at level %u tag '%s'\n", soap->level, soap->tag)); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Error: soap_get_soapfault() failed at level %u tag '%s'\n", soap->level, soap->tag)); *soap_faultcode(soap) = (soap->version == 2 ? "SOAP-ENV:Sender" : "SOAP-ENV:Client"); - soap->error = status; + if (status) + soap->error = status; + else + soap->error = status = SOAP_NO_DATA; soap_set_fault(soap); } else - { register const char *s = *soap_faultcode(soap); - if (!soap_match_tag(soap, s, "SOAP-ENV:Server") || !soap_match_tag(soap, s, "SOAP-ENV:Receiver")) + { const char *s = *soap_faultcode(soap); + if (!soap_match_tag(soap, s, "SOAP-ENV:Server") + || !soap_match_tag(soap, s, "SOAP-ENV:Receiver")) status = SOAP_SVR_FAULT; - else if (!soap_match_tag(soap, s, "SOAP-ENV:Client") || !soap_match_tag(soap, s, "SOAP-ENV:Sender")) + else if (!soap_match_tag(soap, s, "SOAP-ENV:Client") + || !soap_match_tag(soap, s, "SOAP-ENV:Sender")) status = SOAP_CLI_FAULT; else if (!soap_match_tag(soap, s, "SOAP-ENV:MustUnderstand")) status = SOAP_MUSTUNDERSTAND; else if (!soap_match_tag(soap, s, "SOAP-ENV:VersionMismatch")) status = SOAP_VERSIONMISMATCH; else - { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Received SOAP Fault code %s\n", s)); + { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Received SOAP Fault code %s\n", s)); status = SOAP_FAULT; } if (!soap_body_end_in(soap)) soap_envelope_end_in(soap); } - soap_end_recv(soap); + (void)soap_end_recv(soap); soap->error = status; return soap_closesock(soap); } #endif /******************************************************************************/ + #ifndef WITH_NOHTTP #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 soap_send_empty_response(struct soap *soap, int httpstatuscode) -{ register soap_mode m = soap->omode; +{ soap_mode m = soap->omode; if (!(m & SOAP_IO_UDP)) { soap->count = 0; if ((m & SOAP_IO) == SOAP_IO_CHUNK) soap->omode = (m & ~SOAP_IO) | SOAP_IO_BUFFER; - soap_response(soap, httpstatuscode); - soap_end_send(soap); /* force end of sends */ - soap->error = SOAP_STOP; /* stops the server (from returning a response) */ + (void)soap_response(soap, httpstatuscode); + (void)soap_end_send(soap); /* force end of sends */ + soap->error = SOAP_STOP; /* stops the server (from returning another response */ soap->omode = m; } return soap_closesock(soap); @@ -16578,6 +18448,7 @@ soap_send_empty_response(struct soap *soap, int httpstatuscode) #endif /******************************************************************************/ + #ifndef WITH_NOHTTP #ifndef PALM_1 SOAP_FMAC1 @@ -16586,14 +18457,28 @@ SOAP_FMAC2 soap_recv_empty_response(struct soap *soap) { if (!(soap->omode & SOAP_IO_UDP)) { if (!soap_begin_recv(soap)) - { + { if (soap->body) + { if ((soap->status != 400 && soap->status != 500) + || soap_envelope_begin_in(soap) + || soap_recv_header(soap) + || soap_body_begin_in(soap)) + { #ifndef WITH_LEAN - if (soap->body) - soap_get_http_body(soap, NULL); /* read (empty?) HTTP body and discard */ + const char *s = soap_get_http_body(soap, NULL); +#endif + (void)soap_end_recv(soap); +#ifndef WITH_LEAN + if (s) + soap_set_receiver_error(soap, "HTTP Error", s, soap->status); #endif - soap_end_recv(soap); + } + else + return soap_recv_fault(soap, 1); + } + else + (void)soap_end_recv(soap); } - else if (soap->error == SOAP_NO_DATA || soap->error == 202) + else if (soap->error == SOAP_NO_DATA || soap->error == 200 || soap->error == 202) soap->error = SOAP_OK; } return soap_closesock(soap); @@ -16602,17 +18487,18 @@ soap_recv_empty_response(struct soap *soap) #endif /******************************************************************************/ + #ifndef WITH_NOIO #ifndef PALM_1 static const char* soap_strerror(struct soap *soap) -{ register int err = soap->errnum; +{ int err = soap->errnum; *soap->msgbuf = '\0'; if (err) { #ifndef WIN32 # ifdef HAVE_STRERROR_R -# ifdef _GNU_SOURCE +# if defined(_GNU_SOURCE) && !defined(__ANDROID__) return strerror_r(err, soap->msgbuf, sizeof(soap->msgbuf)); /* GNU-specific */ # else strerror_r(err, soap->msgbuf, sizeof(soap->msgbuf)); /* XSI-compliant */ @@ -16639,12 +18525,13 @@ soap_strerror(struct soap *soap) #endif } else - { char *s = soap->msgbuf; + { int rt = soap->recv_timeout, st = soap->send_timeout; #ifndef WITH_LEAN - int rt = soap->recv_timeout, st = soap->send_timeout; int ru = ' ', su = ' '; #endif - strcpy(s, "Operation interrupted or timed out"); + soap_strcpy(soap->msgbuf, sizeof(soap->msgbuf), "message transfer interrupted"); + if (rt || st) + soap_strcpy(soap->msgbuf + 28, sizeof(soap->msgbuf) - 28, " or timed out"); #ifndef WITH_LEAN if (rt < 0) { rt = -rt; @@ -16655,22 +18542,12 @@ soap_strerror(struct soap *soap) su = 'u'; } if (rt) - { -#ifdef HAVE_SNPRINTF - size_t l = strlen(s); - soap_snprintf(s + l, sizeof(soap->msgbuf) - l, " (%d%cs recv delay)", rt, ru); -#else - sprintf(s + strlen(s), " (%d%cs recv delay)", rt, ru); -#endif + { size_t l = strlen(soap->msgbuf); + (SOAP_SNPRINTF(soap->msgbuf + l, sizeof(soap->msgbuf) - l, 36), " (%d%cs recv delay)", rt, ru); } if (st) - { -#ifdef HAVE_SNPRINTF - size_t l = strlen(s); - soap_snprintf(s + l, sizeof(soap->msgbuf) - l, " (%d%cs send delay)", st, su); -#else - sprintf(s + strlen(s), " (%d%cs send delay)", st, su); -#endif + { size_t l = strlen(soap->msgbuf); + (SOAP_SNPRINTF(soap->msgbuf + l, sizeof(soap->msgbuf) - l, 36), " (%d%cs send delay)", st, su); } #endif } @@ -16680,6 +18557,7 @@ soap_strerror(struct soap *soap) #endif /******************************************************************************/ + #ifndef PALM_2 static int soap_set_error(struct soap *soap, const char *faultcode, const char *faultsubcodeQName, const char *faultstring, const char *faultdetailXML, int soaperror) @@ -16688,7 +18566,7 @@ soap_set_error(struct soap *soap, const char *faultcode, const char *faultsubcod *soap_faultsubcode(soap) = faultsubcodeQName; *soap_faultstring(soap) = faultstring; if (faultdetailXML && *faultdetailXML) - { register const char **s = soap_faultdetail(soap); + { const char **s = soap_faultdetail(soap); if (s) *s = faultdetailXML; } @@ -16697,26 +18575,29 @@ soap_set_error(struct soap *soap, const char *faultcode, const char *faultsubcod #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 soap_set_sender_error(struct soap *soap, const char *faultstring, const char *faultdetailXML, int soaperror) -{ return soap_set_error(soap, soap->version == 2 ? "SOAP-ENV:Sender" : "SOAP-ENV:Client", NULL, faultstring, faultdetailXML, soaperror); +{ return soap_set_error(soap, soap->version == 2 ? "SOAP-ENV:Sender" : soap->version == 1 ? "SOAP-ENV:Client" : "at source", NULL, faultstring, faultdetailXML, soaperror); } #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 soap_set_receiver_error(struct soap *soap, const char *faultstring, const char *faultdetailXML, int soaperror) -{ return soap_set_error(soap, soap->version == 2 ? "SOAP-ENV:Receiver" : "SOAP-ENV:Server", NULL, faultstring, faultdetailXML, soaperror); +{ return soap_set_error(soap, soap->version == 2 ? "SOAP-ENV:Receiver" : soap->version == 1 ? "SOAP-ENV:Server" : "is internal", NULL, faultstring, faultdetailXML, soaperror); } #endif /******************************************************************************/ + #ifndef PALM_2 static int soap_copy_fault(struct soap *soap, const char *faultcode, const char *faultsubcodeQName, const char *faultstring, const char *faultdetailXML) @@ -16732,6 +18613,7 @@ soap_copy_fault(struct soap *soap, const char *faultcode, const char *faultsubco #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -16742,16 +18624,18 @@ soap_sender_fault(struct soap *soap, const char *faultstring, const char *faultd #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 soap_sender_fault_subcode(struct soap *soap, const char *faultsubcodeQName, const char *faultstring, const char *faultdetailXML) -{ return soap_copy_fault(soap, soap->version == 2 ? "SOAP-ENV:Sender" : "SOAP-ENV:Client", faultsubcodeQName, faultstring, faultdetailXML); +{ return soap_copy_fault(soap, soap->version == 2 ? "SOAP-ENV:Sender" : soap->version == 1 ? "SOAP-ENV:Client" : "at source", faultsubcodeQName, faultstring, faultdetailXML); } #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int @@ -16762,16 +18646,18 @@ soap_receiver_fault(struct soap *soap, const char *faultstring, const char *faul #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 int SOAP_FMAC2 soap_receiver_fault_subcode(struct soap *soap, const char *faultsubcodeQName, const char *faultstring, const char *faultdetailXML) -{ return soap_copy_fault(soap, soap->version == 2 ? "SOAP-ENV:Receiver" : "SOAP-ENV:Server", faultsubcodeQName, faultstring, faultdetailXML); +{ return soap_copy_fault(soap, soap->version == 2 ? "SOAP-ENV:Receiver" : soap->version == 1 ? "SOAP-ENV:Server" : "is internal", faultsubcodeQName, faultstring, faultdetailXML); } #endif /******************************************************************************/ + #ifndef PALM_2 #ifndef WITH_NOSTDLIB SOAP_FMAC1 @@ -16779,23 +18665,26 @@ void SOAP_FMAC2 soap_print_fault(struct soap *soap, FILE *fd) { if (soap_check_state(soap)) - fprintf(fd, "Error: soap struct state not initialized\n"); + fprintf(fd, "Error: soap struct state not initialized with soap_init\n"); else if (soap->error) { const char **c, *v = NULL, *s, *d; c = soap_faultcode(soap); if (!*c) - soap_set_fault(soap); + { soap_set_fault(soap); + c = soap_faultcode(soap); + } if (soap->version == 2) v = soap_check_faultsubcode(soap); s = *soap_faultstring(soap); d = soap_check_faultdetail(soap); - fprintf(fd, "%s%d fault: %s [%s]\n\"%s\"\nDetail: %s\n", soap->version ? "SOAP 1." : "Error ", soap->version ? (int)soap->version : soap->error, *c, v ? v : "no subcode", s ? s : "[no reason]", d ? d : "[no detail]"); + fprintf(fd, "%s%d fault %s [%s]\n\"%s\"\nDetail: %s\n", soap->version ? "SOAP 1." : "Error ", soap->version ? (int)soap->version : soap->error, *c, v ? v : "no subcode", s ? s : "[no reason]", d ? d : "[no detail]"); } } #endif #endif /******************************************************************************/ + #ifdef __cplusplus #ifndef WITH_LEAN #ifndef WITH_NOSTDLIB @@ -16805,19 +18694,21 @@ void SOAP_FMAC2 soap_stream_fault(struct soap *soap, std::ostream& os) { if (soap_check_state(soap)) - os << "Error: soap struct state not initialized\n"; + os << "Error: soap struct state not initialized with soap_init\n"; else if (soap->error) { const char **c, *v = NULL, *s, *d; c = soap_faultcode(soap); if (!*c) - soap_set_fault(soap); + { soap_set_fault(soap); + c = soap_faultcode(soap); + } if (soap->version == 2) v = soap_check_faultsubcode(soap); s = *soap_faultstring(soap); d = soap_check_faultdetail(soap); os << (soap->version ? "SOAP 1." : "Error ") << (soap->version ? (int)soap->version : soap->error) - << " fault: " << *c + << " fault " << *c << "[" << (v ? v : "no subcode") << "]" << std::endl << "\"" << (s ? s : "[no reason]") << "\"" @@ -16832,6 +18723,7 @@ soap_stream_fault(struct soap *soap, std::ostream& os) #endif /******************************************************************************/ + #ifndef WITH_LEAN #ifndef WITH_NOSTDLIB SOAP_FMAC1 @@ -16839,28 +18731,20 @@ char* SOAP_FMAC2 soap_sprint_fault(struct soap *soap, char *buf, size_t len) { if (soap_check_state(soap)) - { strncpy(buf, "Error: soap struct not initialized", len); - buf[len - 1] = '\0'; + { soap_strcpy(buf, len, "Error: soap struct not initialized with soap_init"); } else if (soap->error) { const char **c, *v = NULL, *s, *d; c = soap_faultcode(soap); if (!*c) - soap_set_fault(soap); + { soap_set_fault(soap); + c = soap_faultcode(soap); + } if (soap->version == 2) - v = *soap_faultsubcode(soap); + v = soap_check_faultsubcode(soap); s = *soap_faultstring(soap); d = soap_check_faultdetail(soap); -#ifdef HAVE_SNPRINTF - soap_snprintf(buf, len, "%s%d fault: %s [%s]\n\"%s\"\nDetail: %s\n", soap->version ? "SOAP 1." : "Error ", soap->version ? (int)soap->version : soap->error, *c, v ? v : "no subcode", s ? s : "[no reason]", d ? d : "[no detail]"); -#else - if (len > 40 + (v ? strlen(v) : 0) + (s ? strlen(s) : 0) + (d ? strlen(d) : 0)) - sprintf(buf, "%s%d fault: %s [%s]\n\"%s\"\nDetail: %s\n", soap->version ? "SOAP 1." : "Error ", soap->version ? (int)soap->version : soap->error, *c, v ? v : "no subcode", s ? s : "[no reason]", d ? d : "[no detail]"); - else if (len > 40) - sprintf(buf, "%s%d fault: %s\n", soap->version ? "SOAP 1." : "Error ", soap->version ? (int)soap->version : soap->error, *c); - else - buf[0] = '\0'; -#endif + (SOAP_SNPRINTF(buf, len, strlen(*c) + strlen(v) + strlen(s) + strlen(d) + 72), "%s%d fault %s [%s]\n\"%s\"\nDetail: %s\n", soap->version ? "SOAP 1." : "Error ", soap->version ? (int)soap->version : soap->error, *c, v ? v : "no subcode", s ? s : "[no reason]", d ? d : "[no detail]"); } return buf; } @@ -16868,6 +18752,7 @@ soap_sprint_fault(struct soap *soap, char *buf, size_t len) #endif /******************************************************************************/ + #ifndef PALM_1 #ifndef WITH_NOSTDLIB SOAP_FMAC1 @@ -16877,7 +18762,7 @@ soap_print_fault_location(struct soap *soap, FILE *fd) { #ifndef WITH_LEAN int i, j, c1, c2; - if (soap->error && soap->error != SOAP_STOP && soap->bufidx <= soap->buflen && soap->buflen > 0 && soap->buflen <= SOAP_BUFLEN) + if (soap->error && soap->error != SOAP_STOP && soap->bufidx <= soap->buflen && soap->buflen > 0 && soap->buflen <= sizeof(soap->buf)) { i = (int)soap->bufidx - 1; if (i <= 0) i = 0; @@ -16895,20 +18780,25 @@ soap_print_fault_location(struct soap *soap, FILE *fd) soap->buf[i] = (char)c1; soap->buf[j] = (char)c2; } +#else + (void)soap; + (void)fd; #endif } #endif #endif /******************************************************************************/ + #ifndef PALM_1 SOAP_FMAC1 int SOAP_FMAC2 soap_register_plugin_arg(struct soap *soap, int (*fcreate)(struct soap*, struct soap_plugin*, void*), void *arg) -{ register struct soap_plugin *p; - register int r; - if (!(p = (struct soap_plugin*)SOAP_MALLOC(soap, sizeof(struct soap_plugin)))) +{ struct soap_plugin *p; + int r; + p = (struct soap_plugin*)SOAP_MALLOC(soap, sizeof(struct soap_plugin)); + if (!p) return soap->error = SOAP_EOM; p->id = NULL; p->data = NULL; @@ -16928,10 +18818,11 @@ soap_register_plugin_arg(struct soap *soap, int (*fcreate)(struct soap*, struct #endif /******************************************************************************/ + #ifndef PALM_1 static void * fplugin(struct soap *soap, const char *id) -{ register struct soap_plugin *p; +{ struct soap_plugin *p; for (p = soap->plugins; p; p = p->next) if (p->id == id || !strcmp(p->id, id)) return p->data; @@ -16940,6 +18831,7 @@ fplugin(struct soap *soap, const char *id) #endif /******************************************************************************/ + #ifndef PALM_2 SOAP_FMAC1 void * @@ -16950,23 +18842,29 @@ soap_lookup_plugin(struct soap *soap, const char *id) #endif /******************************************************************************/ + #ifdef __cplusplus } #endif /******************************************************************************\ * - * C++ soap struct methods + * C++ soap struct methods * \******************************************************************************/ #ifdef __cplusplus soap::soap() { soap_init(this); + /* no logs to prevent leaks when user calls soap_init() on this context */ + soap_set_test_logfile(this, NULL); + soap_set_sent_logfile(this, NULL); + soap_set_recv_logfile(this, NULL); } #endif /******************************************************************************/ + #ifdef __cplusplus soap::soap(soap_mode m) { soap_init1(this, m); @@ -16974,6 +18872,7 @@ soap::soap(soap_mode m) #endif /******************************************************************************/ + #ifdef __cplusplus soap::soap(soap_mode im, soap_mode om) { soap_init2(this, im, om); @@ -16981,6 +18880,7 @@ soap::soap(soap_mode im, soap_mode om) #endif /******************************************************************************/ + #ifdef __cplusplus soap::soap(const struct soap& soap) { soap_copy_context(this, &soap); @@ -16988,11 +18888,19 @@ soap::soap(const struct soap& soap) #endif /******************************************************************************/ + +#ifdef __cplusplus +struct soap& soap::operator=(const struct soap& soap) +{ soap_copy_context(this, &soap); + return *this; +} +#endif + +/******************************************************************************/ + #ifdef __cplusplus soap::~soap() -{ soap_destroy(this); - soap_end(this); - soap_done(this); +{ soap_done(this); } #endif diff --git a/dep/gsoap/stdsoap2.h b/dep/gsoap/stdsoap2.h index 31aece07f1a..7b1a0eb8b77 100644 --- a/dep/gsoap/stdsoap2.h +++ b/dep/gsoap/stdsoap2.h @@ -1,10 +1,10 @@ /* - stdsoap2.h 2.8.17r + stdsoap2.h 2.8.33 - gSOAP runtime engine + gSOAP runtime engine gSOAP XML Web services tools -Copyright (C) 2000-2013, Robert van Engelen, Genivia Inc., All Rights Reserved. +Copyright (C) 2000-2016, Robert van Engelen, Genivia Inc., All Rights Reserved. This part of the software is released under ONE of the following licenses: GPL, or the gSOAP public license, or Genivia's license for commercial use. -------------------------------------------------------------------------------- @@ -24,7 +24,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. The Initial Developer of the Original Code is Robert A. van Engelen. -Copyright (C) 2000-2013, Robert van Engelen, Genivia Inc., All Rights Reserved. +Copyright (C) 2000-2016, Robert van Engelen, Genivia Inc., All Rights Reserved. -------------------------------------------------------------------------------- GPL license. @@ -51,10 +51,10 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com -------------------------------------------------------------------------------- */ -#define GSOAP_VERSION 20817 +#define GSOAP_VERSION 20833 #ifdef WITH_SOAPDEFS_H -# include "soapdefs.h" /* include user-defined stuff */ +# include "soapdefs.h" /* include user-defined stuff in soapdefs.h */ #endif #ifndef _THREAD_SAFE @@ -67,43 +67,63 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # endif #endif -#ifndef SOAP_FMAC1 /* stdsoap2.h declaration macro */ +#ifdef WIN32 +# ifdef SOAP_STD_EXPORTS /* dllexport the API functions and classes */ +# ifndef SOAP_STD_API +# define SOAP_STD_API __declspec(dllexport) +# endif +# ifndef SOAP_CMAC +# define SOAP_CMAC SOAP_STD_API /* export soap struct and generated classes */ +# endif +# ifndef SOAP_FMAC1 +# define SOAP_FMAC1 SOAP_STD_API /* export stdsoap2.cpp API */ +# endif +# ifndef SOAP_FMAC3 +# define SOAP_FMAC3 SOAP_STD_API /* export soapC.cpp serializers API */ +# endif +# ifndef SOAP_FMAC5 +# define SOAP_FMAC5 SOAP_STD_API /* export soapClient.cpp and soapServer.cpp API */ +# endif +# endif +#endif + +#ifndef SOAP_FMAC1 /* stdsoap2.h declaration macro */ # define SOAP_FMAC1 #endif -#ifndef SOAP_FMAC2 /* stdsoap2.h declaration macro */ +#ifndef SOAP_FMAC2 /* stdsoap2.h declaration macro */ # define SOAP_FMAC2 #endif -#ifndef SOAP_FMAC3 /* (de)serializer declaration macro */ +#ifndef SOAP_FMAC3 /* (de)serializer declaration macro */ # define SOAP_FMAC3 #endif -#ifndef SOAP_FMAC3S /* string converter for (de)serializer declaration macro */ +#ifndef SOAP_FMAC3S /* string converter for (de)serializer declaration macro */ # define SOAP_FMAC3S SOAP_FMAC3 #endif -#ifndef SOAP_FMAC4 /* (de)serializer declaration macro */ +#ifndef SOAP_FMAC4 /* (de)serializer declaration macro */ # define SOAP_FMAC4 #endif -#ifndef SOAP_FMAC4S /* string converter for (de)serializer declaration macro */ +#ifndef SOAP_FMAC4S /* string converter for (de)serializer declaration macro */ # define SOAP_FMAC4S SOAP_FMAC4 #endif -#ifndef SOAP_FMAC5 /* stub/skeleton declaration macro */ +#ifndef SOAP_FMAC5 /* stub/skeleton declaration macro */ # define SOAP_FMAC5 #endif -#ifndef SOAP_FMAC6 /* stub/skeleton declaration macro */ +#ifndef SOAP_FMAC6 /* stub/skeleton declaration macro */ # define SOAP_FMAC6 #endif -#ifndef SOAP_CMAC /* class declaration macro */ +#ifndef SOAP_CMAC /* class declaration macro */ # define SOAP_CMAC #endif -#ifndef SOAP_NMAC /* namespace table declaration macro */ +#ifndef SOAP_NMAC /* namespace table declaration macro */ # define SOAP_NMAC #endif @@ -111,14 +131,16 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # define SOAP_SOURCE_STAMP(str) #endif -/* gSOAP 2.7.4 and higher: fast look-aside buffering is stable */ -#ifndef WITH_FAST -# define WITH_FAST -#endif - #ifndef STDSOAP_H #define STDSOAP_H +#define SOAP_XSTRINGIFY(s) SOAP_STRINGIFY(s) +#define SOAP_STRINGIFY(s) #s + +#ifdef SOAPDEFS_H +# include SOAP_XSTRINGIFY(SOAPDEFS_H) /* include user-defined "SOAPDEFS_H" */ +#endif + #if defined(__vxworks) || defined(__VXWORKS__) # ifndef VXWORKS # define VXWORKS @@ -131,7 +153,7 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # endif #endif -/* for legacy purposes we use WIN32 macro even though 64 bit is supported */ +/* for legacy purposes we use WIN32 macro, even when WIN64 is supported */ #ifdef _WIN64 # ifndef WIN32 # define WIN32 @@ -193,6 +215,12 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # endif #endif +#if defined(__sun) && defined(__SVR4) +# ifndef SUN_OS +# define SUN_OS +# endif +#endif + #ifdef HAVE_CONFIG_H # include "config.h" # if defined(WITH_OPENSSL) @@ -213,7 +241,13 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # endif #else # if defined(UNDER_CE) -# define WITH_LEAN +# define SOAP_BUFLEN (2048) +# define SOAP_PTRHASH (32) +# define SOAP_IDHASH (19) +# define SOAP_BLKLEN (32) +# define SOAP_TAGLEN (128) +# define SOAP_HDRLEN (1024) +# define SOAP_MAXDIMS (4) # define HAVE_SSCANF # elif defined(WIN32) # if _MSC_VER >= 1400 @@ -227,8 +261,8 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # define HAVE_STRTOL # define HAVE_STRTOUL # if _MSC_VER >= 1300 -# define HAVE_STRTOLL /* use _strtoi64 */ -# define HAVE_STRTOULL /* use _strtoui64 */ +# define HAVE_STRTOLL /* use _strtoi64 */ +# define HAVE_STRTOULL /* use _strtoui64 */ # endif # define HAVE_SYS_TIMEB_H # define HAVE_FTIME @@ -256,6 +290,7 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # elif defined(__APPLE__) # define HAVE_POLL # define HAVE_SNPRINTF +# define HAVE_STRLCPY # define HAVE_STRRCHR # define HAVE_STRTOD # define HAVE_SSCANF @@ -264,6 +299,8 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # define HAVE_SPRINTF_L # define HAVE_STRTOL # define HAVE_STRTOUL +# define HAVE_STRTOLL +# define HAVE_STRTOULL # define HAVE_RAND_R # define HAVE_GMTIME_R # define HAVE_TM_GMTOFF @@ -299,12 +336,19 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # define HAVE_WCTOMB # define HAVE_MBTOWC # elif defined(HP_UX) +# include <sys/_inttypes.h> +extern intmax_t __strtoll(const char*, char**, int); +extern intmax_t __strtoull(const char*, char**, int); +# define strtoll __strtoll +# define strtoull __strtoull # define HAVE_SNPRINTF # define HAVE_STRRCHR # define HAVE_STRTOD # define HAVE_SSCANF # define HAVE_STRTOL # define HAVE_STRTOUL +# define HAVE_STRTOLL +# define HAVE_STRTOULL # define HAVE_SYS_TIMEB_H # define HAVE_FTIME # define HAVE_RAND_R @@ -316,6 +360,7 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # elif defined(FREEBSD) || defined(__FreeBSD__) || defined(OPENBSD) # define HAVE_POLL # define HAVE_SNPRINTF +# define HAVE_STRLCPY # define HAVE_STRRCHR # define HAVE_STRTOD # define HAVE_SSCANF @@ -415,7 +460,7 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # elif defined(PALM) # define WITH_LEAN # define HAVE_STRTOD /* strtod() is defined in palmFunctions.h */ -# include <stdlib.h> /* Needs to be included before unix headers */ +# include <stdlib.h> /* Needs to be included before unix headers */ # include <sys_types.h> # define IGNORE_STDIO_STUBS # include <StdIOPalm.h> @@ -425,7 +470,7 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # elif defined(SYMBIAN) # define WITH_LEAN # define WITH_NONAMESPACES -# define HAVE_STRTOD /* use STRTOD since sscanf doesn't seem to work */ +# define HAVE_STRTOD /* use STRTOD since sscanf doesn't seem to work */ # include <e32def.h> # include <sys/ioctl.h> # elif defined(VXWORKS) @@ -478,6 +523,8 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # define HAVE_SSCANF # define HAVE_STRTOL # define HAVE_STRTOUL +# define HAVE_STRTOLL +# define HAVE_STRTOULL # define HAVE_SYS_TIMEB_H # define HAVE_FTIME # define HAVE_RAND_R @@ -500,14 +547,15 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # define HAVE_GETHOSTBYNAME_R # define HAVE_GMTIME_R # define HAVE_LOCALTIME_R -# else -/* Default assumptions for supported functions */ +# else /* Default assumptions for supported library functions when not including config.h */ # define HAVE_SNPRINTF # define HAVE_STRRCHR # define HAVE_STRTOD # define HAVE_SSCANF # define HAVE_STRTOL # define HAVE_STRTOUL +# define HAVE_STRTOLL +# define HAVE_STRTOULL # define HAVE_SYS_TIMEB_H # define HAVE_FTIME # define HAVE_RAND_R @@ -522,8 +570,17 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # endif #endif -/* gSOAP 2.7.15 and higher: always retain CDATA in literal XML, unless WITH_LEAN or WITH_NOCDATA */ +#ifdef WITH_LEANER +# ifndef WITH_LEAN +# define WITH_LEAN +# endif +#endif + +/* gSOAP 2.7.15 and higher: always use FAST and retain CDATA in literal XML, unless WITH_LEAN or WITH_NOCDATA */ #ifndef WITH_LEAN +# ifndef WITH_FAST +# define WITH_FAST +# endif # ifndef WITH_NOCDATA # ifndef WITH_CDATA # define WITH_CDATA @@ -531,34 +588,28 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # endif #endif -#ifdef WITH_LEANER -# ifndef WITH_LEAN -# define WITH_LEAN -# endif -#endif - #ifdef WITH_LEAN # ifdef WITH_COOKIES # error "Cannot build WITH_LEAN code WITH_COOKIES enabled" # endif #endif -/* native Win, HP-UX, and AIX compilers don't like empty structs */ -#if defined(WIN32) || defined(HP_UX) || defined(_AIX) || defined(AIX) || defined(VXWORKS) +/* allowing empty struct/union in C is a GNU extension */ +#if !defined(__GNU__) # define WITH_NOEMPTYSTRUCT #endif +/* silence clang's C99 variadic macro warnings */ +#ifdef __clang__ +# pragma clang diagnostic ignored "-Wvariadic-macros" +#endif + #ifdef WITH_PURE_VIRTUAL # define SOAP_PURE_VIRTUAL = 0 #else # define SOAP_PURE_VIRTUAL #endif -#ifdef HP_UX -# undef HAVE_STRTOLL -# undef HAVE_STRTOULL -#endif - /* older OpenVMS TCP/IP stacks cannot handle 65536 bytes */ #ifdef __VMS # ifndef SOAP_BUFLEN @@ -566,12 +617,14 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # endif #endif -/* if we have xlocale.h we use it to avoid decimal point conversion issues */ +/* if we have xlocale.h then we can use it WITH_C_LOCALE enabled to avoid decimal point conversion issues */ #ifdef WITH_C_LOCALE # ifdef WIN32 # include <locale.h> +# define SOAP_LOCALE(soap) ((soap)->c_locale ? (soap)->c_locale : ((soap)->c_locale = _create_locale(LC_ALL, "C"))) # else # include <xlocale.h> +# define SOAP_LOCALE(soap) ((soap)->c_locale ? (soap)->c_locale : ((soap)->c_locale = newlocale(LC_ALL_MASK, "C", NULL))) # endif #else # undef HAVE_STRTOF_L @@ -589,7 +642,6 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # define LONG64 long long # define ULONG64 long long # define DBL_PINFTY (1.1579208923716189e77) -# define WITH_NOEMPTYSTRUCT # undef HAVE_WCTOMB # undef HAVE_MBTOWC # undef HAVE_GMTIME_R @@ -622,8 +674,20 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # include <stdio.h> # include <string.h> # endif -# include <ctype.h> -# include <limits.h> +# if !defined(HAVE_CONFIG_H) || defined(HAVE_CTYPE_H) +# include <ctype.h> +# endif +# if !defined(HAVE_CONFIG_H) || defined(HAVE_LIMITS_H) +# include <limits.h> /* for MB_LEN_MAX */ +# endif +# if !defined(HAVE_CONFIG_H) || defined(HAVE_FLOAT_H) +# include <float.h> /* for INFINITY */ +# endif +# if !defined(HAVE_CONFIG_H) || defined(HAVE_MATH_H) +# ifndef PALM +# include <math.h> /* for isnan() and isinf() */ +# endif +# endif #endif #ifdef WITH_NTLM @@ -634,9 +698,13 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # include <poll.h> #endif -#if defined(__cplusplus) && !defined(WITH_LEAN) && !defined(WITH_COMPAT) -# include <string> -# include <iostream> +#if defined(__cplusplus) +# include <new> +# include <memory> +# if !defined(WITH_COMPAT) +# include <string> +# include <iostream> +# endif #endif #ifdef WITH_NOHTTP @@ -659,7 +727,7 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # endif # ifndef WITH_LEAN # ifdef HAVE_SYS_TIMEB_H -# include <sys/timeb.h> /* for ftime() */ +# include <sys/timeb.h> /* for ftime() */ # endif # include <time.h> # endif @@ -689,8 +757,8 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # endif # endif # ifdef SUN_OS -# include <sys/stream.h> /* SUN */ -# include <sys/socketvar.h> /* SUN < 2.8 (?) */ +# include <sys/stream.h> /* SUN */ +# include <sys/socketvar.h> /* only needed with SUN < 2.8 ? */ # endif # ifdef VXWORKS # ifdef _WRS_KERNEL @@ -703,7 +771,7 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # ifdef OS390 # include <netinet/tcp_var.h> # else -# include <netinet/tcp.h> /* TCP_NODELAY */ +# include <netinet/tcp.h> /* TCP_NODELAY, TCP_FASTOPEN */ # endif # include <arpa/inet.h> # endif @@ -798,6 +866,10 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com # endif #endif +#ifdef WITH_SYSTEMSSL +# include <gskssl.h> +#endif + #ifdef WITH_GZIP # ifndef WITH_ZLIB # define WITH_ZLIB @@ -805,21 +877,15 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com #endif #ifdef WITH_CASEINSENSITIVETAGS -# define SOAP_STRCMP soap_tag_cmp /* case insensitve XML element/attribute names */ +# define SOAP_STRCMP soap_tag_cmp /* case insensitve XML element/attribute names */ #else -# define SOAP_STRCMP strcmp /* case sensitive XML element/attribute names */ +# define SOAP_STRCMP strcmp /* case sensitive XML element/attribute names */ #endif #ifdef WITH_ZLIB # include <zlib.h> #endif -#ifndef WITH_NOSTDLIB -# ifndef PALM -# include <math.h> /* for isnan() */ -# endif -#endif - /* #define DEBUG */ /* Uncomment to debug sending (in file SENT.log) receiving (in file RECV.log) and internal operations (in file TEST.log) */ /* #define DEBUG_STAMP */ /* Uncomment to debug sending (in file SENT.log) receiving (in file RECV.log) and time-stamped operations (in file TEST.log) */ @@ -828,7 +894,7 @@ A commercial use license is available from Genivia, Inc., contact@genivia.com extern "C" { #endif -/* Portability: define SOAP_SOCKLEN_T */ +/* Portability (X/Open, BSD sockets etc): define SOAP_SOCKLEN_T as socklen_t or int or ... */ #if defined(_AIX) || defined(AIX) # if defined(_AIX43) # define SOAP_SOCKLEN_T socklen_t @@ -837,14 +903,21 @@ extern "C" { # endif #elif defined(SOCKLEN_T) # define SOAP_SOCKLEN_T SOCKLEN_T -#elif defined(__socklen_t_defined) || defined(_SOCKLEN_T) || defined(CYGWIN) || defined(FREEBSD) || defined(__FreeBSD__) || defined(OPENBSD) || defined(__QNX__) || defined(QNX) || defined(OS390) || defined(__ANDROID__) +#elif defined(__socklen_t_defined) || defined(_SOCKLEN_T) || defined(CYGWIN) || defined(FREEBSD) || defined(__FreeBSD__) || defined(OPENBSD) || defined(__QNX__) || defined(QNX) || defined(OS390) || defined(__ANDROID__) || defined(_XOPEN_SOURCE) # define SOAP_SOCKLEN_T socklen_t #elif defined(IRIX) || defined(WIN32) || defined(__APPLE__) || defined(SUN_OS) || defined(OPENSERVER) || defined(TRU64) || defined(VXWORKS) || defined(HP_UX) # define SOAP_SOCKLEN_T int -#else +#elif !defined(SOAP_SOCKLEN_T) # define SOAP_SOCKLEN_T size_t #endif +/* AIX DCE threads portability: define SOAP_FUNC_R_ERR gmtime_r and localtime_r err ret val as -1 */ +#ifdef _AIX32_THREADS +# define SOAP_FUNC_R_ERR (-1) +#elif !defined(SOAP_FUNC_R_ERR) +# define SOAP_FUNC_R_ERR (NULL) +#endif + #ifndef SOAP_SOCKET # ifdef WIN32 # define SOAP_SOCKET SOCKET @@ -858,8 +931,8 @@ extern "C" { #define SOAP_INVALID_SOCKET ((SOAP_SOCKET)-1) #define soap_valid_socket(n) ((n) != SOAP_INVALID_SOCKET) -#define SOAP_SHUT_WR 1 -#define SOAP_SHUT_RDWR 2 +#define SOAP_SHUT_WR (1) +#define SOAP_SHUT_RDWR (2) #ifndef SOAP_GAI_STRERROR # define SOAP_GAI_STRERROR gai_strerror @@ -884,6 +957,17 @@ extern "C" { #if defined(SYMBIAN) # define LONG64 long # define ULONG64 unsigned LONG64 +#elif !defined(__cplusplus) && defined(__STDC__) && !defined(__STDC_VERSION__) /* C90? */ +# define LONG64 long +# define ULONG64 unsigned LONG64 +# ifndef SOAP_LONG_FORMAT +# define SOAP_LONG_FORMAT "%ld" +# endif +# ifndef SOAP_ULONG_FORMAT +# define SOAP_ULONG_FORMAT "%lu" +# endif +# define soap_strtoll soap_strtol +# define soap_strtoull soap_strtoul #elif !defined(WIN32) || defined(CYGWIN) || defined(__GLIBC__) || defined(__GNU__) # ifndef LONG64 # if defined(HAVE_INTTYPES_H) @@ -942,11 +1026,11 @@ extern "C" { #endif #ifndef SOAP_LONG_FORMAT -# define SOAP_LONG_FORMAT "%lld" /* printf format for 64 bit ints */ +# define SOAP_LONG_FORMAT "%lld" /* printf format for 64 bit ints */ #endif #ifndef SOAP_ULONG_FORMAT -# define SOAP_ULONG_FORMAT "%llu" /* printf format for unsigned 64 bit ints */ +# define SOAP_ULONG_FORMAT "%llu" /* printf format for unsigned 64 bit ints */ #endif #if defined(WIN32) && !defined(CYGWIN) @@ -972,11 +1056,17 @@ extern "C" { # define SOAP_EWOULDBLOCK WSAEWOULDBLOCK # define SOAP_EINPROGRESS WSAEINPROGRESS # define SOAP_EADDRINUSE WSAEADDRINUSE +# define SOAP_ECONNREFUSED WSAECONNREFUSED #else -# define SOAP_ERANGE ERANGE +# ifdef ERANGE +# define SOAP_ERANGE ERANGE +# else +# define SOAP_ERANGE (34) +# endif # define SOAP_EINTR EINTR # define SOAP_EAGAIN EAGAIN # define SOAP_EADDRINUSE EADDRINUSE +# define SOAP_ECONNREFUSED ECONNREFUSED # ifdef SYMBIAN # define SOAP_EWOULDBLOCK 9898 # define SOAP_EINPROGRESS 9899 @@ -1056,45 +1146,109 @@ extern "C" { # define SOAP_HDRLEN (1024) # endif #endif +#ifndef SOAP_TMPLEN +# ifndef WITH_LEAN +# define SOAP_TMPLEN (1024) /* maximum length of msgbuf and tmpbuf short message buffers, must be >=1024 */ +# else +# define SOAP_TMPLEN (1024) +# endif +#endif #ifndef SOAP_MAXDIMS # ifndef WITH_LEAN -# define SOAP_MAXDIMS (16) /* maximum array dimensions (array nestings) must be less than 64 to protect soap->tmpbuf */ +# define SOAP_MAXDIMS (16) /* maximum array dimensions (array nestings) must be less than 64 to protect soap->tmpbuf */ # else -# define SOAP_MAXDIMS (4) +# define SOAP_MAXDIMS (4) +# endif +#endif +#ifndef SOAP_MAXPTRS +# ifndef WITH_LEAN +# define SOAP_MAXPTRS (4) /* maximum depth + 1 of id-ref deserialized pointer types (int* has depth 0, int*** has depth 2) */ +# else +# define SOAP_MAXPTRS (2) # endif #endif #ifndef SOAP_MAXLOGS -# define SOAP_MAXLOGS (3) /* max number of debug logs per struct soap environment */ +# define SOAP_MAXLOGS (3) /* max number of debug logs per struct soap environment */ # define SOAP_INDEX_RECV (0) # define SOAP_INDEX_SENT (1) # define SOAP_INDEX_TEST (2) #endif +/* Tag name of multiref elements in SOAP 1.1 encoding */ +#ifndef SOAP_MULTIREFTAG +# define SOAP_MULTIREFTAG "id" +#endif + +/* href-id value base name in multiref SOAP encoding */ +#ifndef SOAP_BASEREFNAME +# define SOAP_BASEREFNAME "_" +#endif + /* Max number of EINTR while poll/select on a socket */ /* Each EINTR can lengthen the I/O blocking time by at most one second */ #ifndef SOAP_MAXEINTR # define SOAP_MAXEINTR (10) #endif -/* Max iterations in soap_serve() to keep server connection alive */ +/* SOAP_MAXKEEPALIVE: Max iterations in soap_serve() to keep server connection alive */ #ifndef SOAP_MAXKEEPALIVE # define SOAP_MAXKEEPALIVE (100) #endif -/* Trusted max size of inbound SOAP array for compound array allocation. - Increase if necessary to allow larger arrays. +/* SOAP_MAXARRAYSIZE: Trusted total max size of an inbound SOAP Array. + Arrays of larger size are not pre-allocated, but deserialized + on an element-by-element basis until XML validation contrains kick in. + This macro only affects the efficiency of parsing SOAP arrays. */ #ifndef SOAP_MAXARRAYSIZE -# define SOAP_MAXARRAYSIZE (1000000) +# define SOAP_MAXARRAYSIZE (100000) #endif -/* Trusted max size of inbound DIME data. +/* SOAP_MAXDIMESIZE: Trusted max size of inbound DIME data. Increase if necessary to allow larger attachments, or decrease when server resources are limited. */ #ifndef SOAP_MAXDIMESIZE -# define SOAP_MAXDIMESIZE (8388608) /* 8 MB */ +# define SOAP_MAXDIMESIZE (8*1048576) /* 8 MB */ +#endif + +/* SOAP_MAXINFLATESIZE: Trusted inflated content size. + Larger content is subject to the SOAP_MINDEFLATERATIO constraint. + If SOAP_MINDEFLATERATIO is 1.0, SOAP_MAXINFLATESIZE is always the max + size of uncompressed content. +*/ +#ifndef SOAP_MAXINFLATESIZE +# define SOAP_MAXINFLATESIZE (1*1048576) /* 1 MB */ +#endif + +/* SOAP_MINDEFLATERATIO: Trusted deflation ratio after SOAP_MAXINFLATESIZE is reached. + Trust when compressed / deflated > SOAP_MINDEFLATERATIO + Sets a ratio > 0.00096899224806 (1032:1) + According to the zlib site: the limit (1032:1) comes from the fact that one + length/distance pair can represent at most 258 output bytes. A length + requires at least one bit and a distance requires at least one bit, so two + bits in can give 258 bytes out, or eight bits in give 1032 bytes out. A + dynamic block has no length restriction, so you could get arbitrarily close + to the limit of 1032:1. +*/ +#ifndef SOAP_MINDEFLATERATIO +# define SOAP_MINDEFLATERATIO (1.0/1032.0) /* ratio of deflated/inflated */ +#endif + +/* maximum XML nesting depth level allowed for inbound XML parsing, must be greater than zero (0) */ +#ifndef SOAP_MAXLEVEL +# define SOAP_MAXLEVEL (10000) +#endif + +/* maximum string content length if not already constrained by XML schema validation maxLength constraints, zero or negative means unlimited string lengths are allowed unless restricted by XML schema maxLength */ +#ifndef SOAP_MAXLENGTH +# define SOAP_MAXLENGTH (0) +#endif + +/* maximum number of array or container elements, must be greater than zero (0) */ +#ifndef SOAP_MAXOCCURS +# define SOAP_MAXOCCURS (100000) #endif #ifdef VXWORKS @@ -1116,7 +1270,6 @@ extern "C" { #endif #ifdef WIN32 -# include <float.h> # ifndef HAVE_ISNAN # define HAVE_ISNAN # endif @@ -1168,7 +1321,9 @@ extern const char soap_base64o[], soap_base64i[]; #endif #ifndef FLT_PINFTY -# if defined(FLT_MAX) +# if defined(INFINITY) +# define FLT_PINFTY INFINITY +# elif defined(FLT_MAX) # define FLT_PINFTY FLT_MAX # elif defined(HUGE_VALF) # define FLT_PINFTY (float)HUGE_VALF @@ -1190,7 +1345,9 @@ extern const char soap_base64o[], soap_base64i[]; #endif #ifndef DBL_PINFTY -# if defined(DBL_MAX) +# if defined(INFINITY) +# define DBL_PINFTY INFINITY +# elif defined(DBL_MAX) # define DBL_PINFTY DBL_MAX # elif defined(HUGE_VALF) # define DBL_PINFTY (double)HUGE_VALF @@ -1228,75 +1385,132 @@ extern const char soap_base64o[], soap_base64i[]; #define soap_isninfd(n) ((n) < 0 && soap_isinf(n)) #define soap_isninff(n) ((n) < 0 && soap_isinf(n)) -#ifdef HAVE_SNPRINTF -# ifdef WIN32 -# define soap_snprintf(buf, len, ...) (_snprintf((buf), (len), __VA_ARGS__), (buf)[(len)-1] = '\0') +/* Safer str & mem functions */ + +/* The gSOAP code uses guards to ensure that these functions are well behaved + and do not raise errors. Therefore, the WIN _s functions should never + execute the "invalid parameter handler". +*/ + +/* use safer snprintf if possible or guard sprintf against overrun (assumes no variadic macros) */ +# ifdef HAVE_SNPRINTF +# if _MSC_VER >= 1400 +# define SOAP_SNPRINTF(buf, len, num) void)_snprintf_s((buf), (len), _TRUNCATE +# define SOAP_SNPRINTF_SAFE(buf, len) void)_snprintf_s((buf), (len), _TRUNCATE +# else +# define SOAP_SNPRINTF(buf, len, num) void)snprintf((buf), (len) +# define SOAP_SNPRINTF_SAFE(buf, len) void)snprintf((buf), (len) +# endif # else -# define soap_snprintf snprintf +# define SOAP_SNPRINTF(buf, len, num) (len) <= (num)) ? (void)((buf)[0] = '\0') : (void)sprintf((buf) +# define SOAP_SNPRINTF_SAFE(buf, len) void)sprintf((buf) # endif + +/* copy string (truncating the result) */ +#if _MSC_VER >= 1400 +# define soap_strcpy(buf, len, src) (void)strncpy_s((buf), (len), (src), _TRUNCATE) +#elif defined(HAVE_STRLCPY) +# define soap_strcpy(buf, len, src) (void)strlcpy((buf), (src), (len)) +#else +# define soap_strcpy(buf, len, src) (void)((buf) == NULL || (len) <= 0 || (strncpy((buf), (src), (len) - 1), (buf)[(len) - 1] = '\0') || 1) +#endif + +/* copy string up to n chars (nul on overrun) */ +#if _MSC_VER >= 1400 +# define soap_strncpy(buf, len, src, num) (void)strncpy_s((buf), (len), (src), (num)) +#else +# define soap_strncpy(buf, len, src, num) (void)((buf) == NULL || ((size_t)(len) > (size_t)(num) ? (strncpy((buf), (src), (num)), (buf)[(size_t)(num)] = '\0') : ((buf)[0] = '\0')) || 1) +#endif + +/* concat string up to n chars (nul on overrun) */ +#if _MSC_VER >= 1400 +# define soap_strncat(buf, len, src, num) (void)strncat_s((buf), (len), (src), (num)) +#else +# define soap_strncat(buf, len, src, num) (void)((buf) == NULL || ((size_t)(len) > strlen((buf)) + (size_t)(num) ? (strncat((buf), (src), (num)), (buf)[(size_t)(len) - 1] = '\0') : ((buf)[0] = '\0')) || 1) +#endif + +/* copy memory (error on overrun) */ +#if _MSC_VER >= 1400 +# define soap_memcpy(buf, len, src, num) ((buf) && (size_t)(len) >= (size_t)(num) ? memcpy_s((buf), (len), (src), (num)) : SOAP_ERANGE) +#else +# define soap_memcpy(buf, len, src, num) ((buf) && (size_t)(len) >= (size_t)(num) ? !memcpy((buf), (src), (num)) : SOAP_ERANGE) +#endif + +/* move memory (error on overrun) */ +#if _MSC_VER >= 1400 +# define soap_memmove(buf, len, src, num) ((buf) && (size_t)(len) >= (size_t)(num) ? memmove_s((buf), (len), (src), (num)) : SOAP_ERANGE) +#else +# define soap_memmove(buf, len, src, num) ((buf) && (size_t)(len) >= (size_t)(num) ? !memmove((buf), (src), (num)) : SOAP_ERANGE) #endif /* gSOAP status/error codes */ typedef soap_int32 soap_status; -#define SOAP_EOF EOF -#define SOAP_ERR EOF -#define SOAP_OK 0 -#define SOAP_CLI_FAULT 1 -#define SOAP_SVR_FAULT 2 -#define SOAP_TAG_MISMATCH 3 -#define SOAP_TYPE 4 -#define SOAP_SYNTAX_ERROR 5 -#define SOAP_NO_TAG 6 -#define SOAP_IOB 7 -#define SOAP_MUSTUNDERSTAND 8 -#define SOAP_NAMESPACE 9 -#define SOAP_USER_ERROR 10 -#define SOAP_FATAL_ERROR 11 -#define SOAP_FAULT 12 -#define SOAP_NO_METHOD 13 -#define SOAP_NO_DATA 14 -#define SOAP_GET_METHOD 15 -#define SOAP_PUT_METHOD 16 -#define SOAP_DEL_METHOD 17 /* deprecated */ -#define SOAP_HEAD_METHOD 18 /* deprecated */ -#define SOAP_HTTP_METHOD 19 -#define SOAP_EOM 20 -#define SOAP_MOE 21 -#define SOAP_HDR 22 -#define SOAP_NULL 23 -#define SOAP_DUPLICATE_ID 24 -#define SOAP_MISSING_ID 25 -#define SOAP_HREF 26 -#define SOAP_UDP_ERROR 27 -#define SOAP_TCP_ERROR 28 -#define SOAP_HTTP_ERROR 29 -#define SOAP_SSL_ERROR 30 -#define SOAP_ZLIB_ERROR 31 -#define SOAP_DIME_ERROR 32 -#define SOAP_DIME_HREF 33 -#define SOAP_DIME_MISMATCH 34 -#define SOAP_DIME_END 35 -#define SOAP_MIME_ERROR 36 -#define SOAP_MIME_HREF 37 -#define SOAP_MIME_END 38 -#define SOAP_VERSIONMISMATCH 39 -#define SOAP_PLUGIN_ERROR 40 -#define SOAP_DATAENCODINGUNKNOWN 41 -#define SOAP_REQUIRED 42 -#define SOAP_PROHIBITED 43 -#define SOAP_OCCURS 44 -#define SOAP_LENGTH 45 -#define SOAP_FD_EXCEEDED 46 -#define SOAP_UTF_ERROR 47 -#define SOAP_NTLM_ERROR 48 - -#define soap_xml_error_check(e) ((e) == SOAP_TAG_MISMATCH || (e) == SOAP_NO_TAG || (e) == SOAP_SYNTAX_ERROR || (e) == SOAP_NAMESPACE || (e) == SOAP_DUPLICATE_ID || (e) == SOAP_MISSING_ID || (e) == SOAP_REQUIRED || (e) == SOAP_PROHIBITED || (e) == SOAP_OCCURS || (e) == SOAP_LENGTH || (e) == SOAP_NULL || (e) == SOAP_HREF) +#define SOAP_EOF EOF +#define SOAP_ERR EOF +#define SOAP_OK 0 +#define SOAP_CLI_FAULT 1 +#define SOAP_SVR_FAULT 2 +#define SOAP_TAG_MISMATCH 3 +#define SOAP_TYPE 4 +#define SOAP_SYNTAX_ERROR 5 +#define SOAP_NO_TAG 6 +#define SOAP_IOB 7 +#define SOAP_MUSTUNDERSTAND 8 +#define SOAP_NAMESPACE 9 +#define SOAP_USER_ERROR 10 +#define SOAP_FATAL_ERROR 11 +#define SOAP_FAULT 12 +#define SOAP_NO_METHOD 13 +#define SOAP_NO_DATA 14 +#define SOAP_GET_METHOD 15 +#define SOAP_PUT_METHOD 16 +#define SOAP_DEL_METHOD 17 /* deprecated */ +#define SOAP_HEAD_METHOD 18 /* deprecated */ +#define SOAP_HTTP_METHOD 19 +#define SOAP_EOM 20 +#define SOAP_MOE 21 +#define SOAP_HDR 22 +#define SOAP_NULL 23 +#define SOAP_DUPLICATE_ID 24 +#define SOAP_MISSING_ID 25 +#define SOAP_HREF 26 +#define SOAP_UDP_ERROR 27 +#define SOAP_TCP_ERROR 28 +#define SOAP_HTTP_ERROR 29 +#define SOAP_SSL_ERROR 30 +#define SOAP_ZLIB_ERROR 31 +#define SOAP_DIME_ERROR 32 +#define SOAP_DIME_HREF 33 +#define SOAP_DIME_MISMATCH 34 +#define SOAP_DIME_END 35 +#define SOAP_MIME_ERROR 36 +#define SOAP_MIME_HREF 37 +#define SOAP_MIME_END 38 +#define SOAP_VERSIONMISMATCH 39 +#define SOAP_PLUGIN_ERROR 40 +#define SOAP_DATAENCODINGUNKNOWN 41 +#define SOAP_REQUIRED 42 +#define SOAP_PROHIBITED 43 +#define SOAP_OCCURS 44 +#define SOAP_LENGTH 45 +#define SOAP_PATTERN 46 +#define SOAP_FD_EXCEEDED 47 +#define SOAP_UTF_ERROR 48 +#define SOAP_NTLM_ERROR 49 +#define SOAP_LEVEL 50 + +#define soap_xml_error_check(e) ((e) == SOAP_TAG_MISMATCH || (e) == SOAP_NO_TAG || (e) == SOAP_SYNTAX_ERROR || (e) == SOAP_NAMESPACE || (e) == SOAP_TYPE || (e) == SOAP_DUPLICATE_ID || (e) == SOAP_MISSING_ID || (e) == SOAP_REQUIRED || (e) == SOAP_PROHIBITED || (e) == SOAP_OCCURS || (e) == SOAP_LENGTH || (e) == SOAP_LEVEL || (e) == SOAP_PATTERN || (e) == SOAP_NULL || (e) == SOAP_HREF) + #define soap_soap_error_check(e) ((e) == SOAP_CLI_FAULT || (e) == SOAP_SVR_FAULT || (e) == SOAP_VERSIONMISMATCH || (e) == SOAP_MUSTUNDERSTAND || (e) == SOAP_FAULT || (e) == SOAP_NO_METHOD) + #define soap_tcp_error_check(e) ((e) == SOAP_EOF || (e) == SOAP_TCP_ERROR) + #define soap_ssl_error_check(e) ((e) == SOAP_SSL_ERROR) + #define soap_zlib_error_check(e) ((e) == SOAP_ZLIB_ERROR) + #define soap_http_error_check(e) ((e) == SOAP_HTTP_ERROR || (e) == SOAP_NO_DATA || ((e) >= SOAP_GET_METHOD && (e) <= SOAP_HTTP_METHOD) || ((e) >= 100 && (e) < 600)) /* gSOAP HTTP response status codes 100 to 599 are reserved */ @@ -1305,132 +1519,137 @@ typedef soap_int32 soap_status; /* Exceptional gSOAP HTTP server response status codes >= 1000 */ -#define SOAP_STOP 1000 /* No HTTP response */ -#define SOAP_FORM 1001 /* Request (form) data is present, no HTTP response */ -#define SOAP_HTML 1002 /* Custom HTML response */ -#define SOAP_FILE 1003 /* Custom file-based response */ +#define SOAP_STOP 1000 /* No HTTP response */ +#define SOAP_FORM 1001 /* Request (form) data is present, no HTTP response */ +#define SOAP_HTML 1002 /* Custom HTML response */ +#define SOAP_FILE 1003 /* Custom file-based response */ /* gSOAP HTTP method codes (client) */ -#define SOAP_POST 2000 /* POST request */ -#define SOAP_POST_FILE 2001 /* Custom file-based POST request */ -#define SOAP_GET 2002 /* GET request */ -#define SOAP_PUT 2003 /* PUT request */ -#define SOAP_DEL 2004 /* DELETE request */ -#define SOAP_CONNECT 2005 /* CONNECT request */ +#define SOAP_POST 2000 /* POST request */ +#define SOAP_POST_FILE 2001 /* Custom file-based POST request */ +#define SOAP_GET 2002 /* GET request */ +#define SOAP_PUT 2003 /* PUT request */ +#define SOAP_DEL 2004 /* DELETE request */ +#define SOAP_CONNECT 2005 /* CONNECT request */ /* gSOAP DIME */ -#define SOAP_DIME_CF 0x01 -#define SOAP_DIME_ME 0x02 -#define SOAP_DIME_MB 0x04 -#define SOAP_DIME_VERSION 0x08 /* DIME version 1 */ -#define SOAP_DIME_MEDIA 0x10 -#define SOAP_DIME_ABSURI 0x20 +#define SOAP_DIME_CF 0x01 +#define SOAP_DIME_ME 0x02 +#define SOAP_DIME_MB 0x04 +#define SOAP_DIME_VERSION 0x08 /* DIME version 1 */ +#define SOAP_DIME_MEDIA 0x10 +#define SOAP_DIME_ABSURI 0x20 /* gSOAP ZLIB */ -#define SOAP_ZLIB_NONE 0x00 -#define SOAP_ZLIB_DEFLATE 0x01 -#define SOAP_ZLIB_INFLATE 0x02 -#define SOAP_ZLIB_GZIP 0x02 +#define SOAP_ZLIB_NONE 0x00 +#define SOAP_ZLIB_DEFLATE 0x01 +#define SOAP_ZLIB_INFLATE 0x02 +#define SOAP_ZLIB_GZIP 0x02 /* gSOAP transport, connection, and content encoding modes */ typedef soap_int32 soap_mode; -#define SOAP_IO 0x00000003 /* IO mask */ -#define SOAP_IO_FLUSH 0x00000000 /* flush output immediately, no buffering */ -#define SOAP_IO_BUFFER 0x00000001 /* buffer output in packets of size SOAP_BUFLEN */ -#define SOAP_IO_STORE 0x00000002 /* store entire output to determine length for transport */ -#define SOAP_IO_CHUNK 0x00000003 /* use HTTP chunked transfer AND buffer packets */ - -#define SOAP_IO_UDP 0x00000004 /* TCP or UDP */ -#define SOAP_IO_LENGTH 0x00000008 /* calc message length (internal) */ -#define SOAP_IO_KEEPALIVE 0x00000010 /* keep connection alive */ - -#define SOAP_ENC 0x00000FFF /* IO and ENC mask */ -#define SOAP_ENC_LATIN 0x00000020 /* in: accept iso-8859-1 */ -#define SOAP_ENC_XML 0x00000040 /* out: plain XML encoding, no HTTP header */ -#define SOAP_ENC_DIME 0x00000080 -#define SOAP_ENC_MIME 0x00000100 -#define SOAP_ENC_MTOM 0x00000200 -#define SOAP_ENC_ZLIB 0x00000400 -#define SOAP_ENC_SSL 0x00000800 - -#define SOAP_XML_STRICT 0x00001000 /* in: strict validation */ -#define SOAP_XML_INDENT 0x00002000 /* out: emit indented XML */ -#define SOAP_XML_IGNORENS 0x00004000 /* in: ignore namespaces */ -#define SOAP_XML_DEFAULTNS 0x00008000 /* out: emit xmlns="..." */ -#define SOAP_XML_CANONICAL 0x00010000 /* out: excC14N canonical XML */ -#define SOAP_XML_TREE 0x00020000 /* in/out: XML tree (no id/ref) */ -#define SOAP_XML_NIL 0x00040000 /* out: NULLs as xsi:nil */ -#define SOAP_XML_NOTYPE 0x00080000 /* out: do not add xsi:type */ - -#define SOAP_DOM_TREE 0x00100000 /* see DOM manual */ -#define SOAP_DOM_NODE 0x00200000 -#define SOAP_DOM_ASIS 0x00400000 - -#define SOAP_C_NOIOB 0x01000000 /* don't fault on array index out of bounds (just ignore) */ -#define SOAP_C_UTFSTRING 0x02000000 /* (de)serialize strings with UTF8 content */ -#define SOAP_C_MBSTRING 0x04000000 /* (de)serialize strings with multi-byte content */ -#define SOAP_C_NILSTRING 0x08000000 /* serialize empty strings as nil (omitted) */ - -#define SOAP_XML_DOM 0x10000000 /* enable internal DOM */ -#define SOAP_XML_GRAPH 0x20000000 /* force id-ref XML graph */ - -#define SOAP_MIME_POSTCHECK 0x40000000 /* MIME flag (internal) */ - -#define SOAP_SEC_WSUID 0x80000000 /* Add Body wsu:Id */ +#define SOAP_IO 0x00000003 /* IO mask */ +#define SOAP_IO_FLUSH 0x00000000 /* flush output immediately, no buffering */ +#define SOAP_IO_BUFFER 0x00000001 /* buffer output in packets of size SOAP_BUFLEN */ +#define SOAP_IO_STORE 0x00000002 /* store entire output to determine length for transport */ +#define SOAP_IO_CHUNK 0x00000003 /* use HTTP chunked transfer AND buffer packets */ + +#define SOAP_IO_UDP 0x00000004 /* TCP or UDP */ +#define SOAP_IO_LENGTH 0x00000008 /* calc message length (internal) */ +#define SOAP_IO_KEEPALIVE 0x00000010 /* keep connection alive */ + +#define SOAP_ENC 0x00000FFF /* IO and ENC mask */ +#define SOAP_ENC_LATIN 0x00000020 /* in: accept iso-8859-1 */ +#define SOAP_ENC_XML 0x00000040 /* out: plain (XML or other) body, no HTTP header */ +#define SOAP_ENC_DIME 0x00000080 +#define SOAP_ENC_MIME 0x00000100 +#define SOAP_ENC_MTOM 0x00000200 +#define SOAP_ENC_ZLIB 0x00000400 +#define SOAP_ENC_SSL 0x00000800 + +#define SOAP_XML_STRICT 0x00001000 /* in: strict validation */ +#define SOAP_XML_INDENT 0x00002000 /* out: emit indented XML */ +#define SOAP_XML_IGNORENS 0x00004000 /* in: ignore namespaces */ +#define SOAP_XML_DEFAULTNS 0x00008000 /* out: emit xmlns="..." */ +#define SOAP_XML_CANONICAL 0x00010000 /* out: excC14N canonical XML */ +#define SOAP_XML_TREE 0x00020000 /* in/out: XML tree (no id/ref) */ +#define SOAP_XML_NIL 0x00040000 /* out: all NULLs as xsi:nil */ +#define SOAP_XML_NOTYPE 0x00080000 /* out: do not add xsi:type */ + +#define SOAP_DOM_TREE 0x00100000 /* see DOM manual */ +#define SOAP_DOM_NODE 0x00200000 +#define SOAP_DOM_ASIS 0x00400000 + +#define SOAP_RESERVED 0x00800000 /* reserved for future use */ + +#define SOAP_C_NOIOB 0x01000000 /* don't fault on array index out of bounds (just ignore) */ +#define SOAP_C_UTFSTRING 0x02000000 /* (de)serialize strings with UTF8 content */ +#define SOAP_C_MBSTRING 0x04000000 /* (de)serialize strings with multi-byte content */ +#define SOAP_C_NILSTRING 0x08000000 /* serialize empty strings as nil (omitted) */ + +#define SOAP_XML_DOM 0x10000000 /* enable internal DOM */ +#define SOAP_XML_GRAPH 0x20000000 /* force id-ref XML graph */ + +#define SOAP_MIME_POSTCHECK 0x40000000 /* MIME flag (internal) */ + +#define SOAP_SEC_WSUID 0x80000000 /* Add Body wsu:Id flag (internal) */ /* WITH_XMLNS backward compatibility: always use XML default namespaces */ #ifdef WITH_XMLNS -# define SOAP_IO_DEFAULT (SOAP_IO_FLUSH | SOAP_XML_DEFAULTNS) +# define SOAP_IO_DEFAULT (SOAP_IO_FLUSH | SOAP_XML_DEFAULTNS) #else -# define SOAP_IO_DEFAULT SOAP_IO_FLUSH +# define SOAP_IO_DEFAULT SOAP_IO_FLUSH #endif /* SSL client/server authentication settings */ -#define SOAP_SSL_NO_AUTHENTICATION 0x00 /* for testing purposes */ -#define SOAP_SSL_REQUIRE_SERVER_AUTHENTICATION 0x01 /* client requires server to authenticate */ -#define SOAP_SSL_REQUIRE_CLIENT_AUTHENTICATION 0x02 /* server requires client to authenticate */ -#define SOAP_SSL_SKIP_HOST_CHECK 0x04 /* client does not check the common name of the host in certificate */ -#define SOAP_SSL_ALLOW_EXPIRED_CERTIFICATE 0x08 /* client does not check the expiration date of the host certificate */ -#define SOAP_SSL_NO_DEFAULT_CA_PATH 0x10 /* don't use default_verify_paths */ -#define SOAP_SSL_RSA 0x20 /* use RSA */ -#define SOAP_SSLv3 0x40 /* SSL v3 only */ -#define SOAP_TLSv1 0x80 /* TLS v1 only */ -#define SOAP_SSLv3_TLSv1 0x00 /* SSL v3 and TLS v1 support by default (no SSL v1/v2) */ -#define SOAP_SSL_CLIENT 0x100 /* client context */ - -#define SOAP_SSL_DEFAULT (SOAP_SSL_REQUIRE_SERVER_AUTHENTICATION | SOAP_SSLv3_TLSv1) +#define SOAP_SSL_NO_AUTHENTICATION 0x0000 /* for testing purposes */ +#define SOAP_SSL_REQUIRE_SERVER_AUTHENTICATION 0x0001 /* client requires server to authenticate (default) */ +#define SOAP_SSL_REQUIRE_CLIENT_AUTHENTICATION 0x0002 /* server requires client to authenticate */ +#define SOAP_SSL_SKIP_HOST_CHECK 0x0004 /* client skips common name check against host name */ +#define SOAP_SSL_ALLOW_EXPIRED_CERTIFICATE 0x0008 /* allow self-signed and expired certificates and those w/o CRL */ +#define SOAP_SSL_NO_DEFAULT_CA_PATH 0x0010 /* don't use default_verify_paths */ +#define SOAP_SSL_RSA 0x0020 /* use RSA */ +#define SOAP_TLSv1 0x0000 /* enable TLS v1.0/1.1/1.2 only (default) */ +#define SOAP_SSLv3_TLSv1 0x0040 /* enable SSL v3 and TLS v1.0/1.1/1.2 */ +#define SOAP_SSLv3 0x0080 /* only SSL v3 */ +#define SOAP_TLSv1_0 0x0100 /* only TLS v1.0 */ +#define SOAP_TLSv1_1 0x0200 /* only TLS v1.1 */ +#define SOAP_TLSv1_2 0x0400 /* only TLS v1.2 */ +#define SOAP_SSL_CLIENT 0x1000 /* client context */ + +#define SOAP_SSL_DEFAULT (SOAP_SSL_REQUIRE_SERVER_AUTHENTICATION | SOAP_TLSv1) /* state */ -#define SOAP_NONE 0 -#define SOAP_INIT 1 -#define SOAP_COPY 2 +#define SOAP_NONE 0 +#define SOAP_INIT 1 +#define SOAP_COPY 2 #define soap_check_state(soap) (!(soap) || ((soap)->state != SOAP_INIT && (soap)->state != SOAP_COPY)) /* parts */ -#define SOAP_BEGIN 0 -#define SOAP_IN_ENVELOPE 2 -#define SOAP_IN_HEADER 3 -#define SOAP_END_HEADER 4 -#define SOAP_NO_BODY 5 -#define SOAP_IN_BODY 6 -#define SOAP_END_BODY 7 -#define SOAP_END_ENVELOPE 8 -#define SOAP_END 9 +#define SOAP_BEGIN 0 +#define SOAP_IN_ENVELOPE 2 +#define SOAP_IN_HEADER 3 +#define SOAP_END_HEADER 4 +#define SOAP_NO_BODY 5 +#define SOAP_IN_BODY 6 +#define SOAP_END_BODY 7 +#define SOAP_END_ENVELOPE 8 +#define SOAP_END 9 /* events */ -#define SOAP_SEC_BEGIN 1 -#define SOAP_SEC_SIGN 2 -#define SOAP_SEC_DECRYPT 3 +#define SOAP_SEC_BEGIN 1 +#define SOAP_SEC_SIGN 2 +#define SOAP_SEC_DECRYPT 3 /* DEBUG macros */ @@ -1452,27 +1671,29 @@ typedef soap_int32 soap_mode; #ifdef SOAP_MEM_DEBUG # ifndef SOAP_MALLOC -# define SOAP_MALLOC(soap, size) soap_track_malloc(soap, __FILE__, __LINE__, size) +# define SOAP_MALLOC(soap, size) soap_track_malloc((soap), __FILE__, __LINE__, (size)) # endif # ifndef SOAP_FREE -# define SOAP_FREE(soap, ptr) soap_track_free(soap, __FILE__, __LINE__, ptr) +# define SOAP_FREE(soap, ptr) soap_track_free((soap), __FILE__, __LINE__, (void*)(ptr)) # endif #endif -#ifndef SOAP_MALLOC /* use libc malloc */ +#ifndef SOAP_MALLOC /* use libc malloc */ # define SOAP_MALLOC(soap, size) malloc(size) #endif -#ifndef SOAP_FREE /* use libc free */ -# define SOAP_FREE(soap, ptr) free(ptr) +#ifndef SOAP_FREE /* use libc free */ +# define SOAP_FREE(soap, ptr) free((void*)(ptr)) #endif -#if defined(__GNUC__) && (__GNUC__ <= 2) -# define SOAP_NOTHROW -#elif !defined(WITH_LEAN) && !defined(WITH_COMPAT) && !defined(SOAP_NOTHROW) -# define SOAP_NOTHROW (std::nothrow) -#else -# define SOAP_NOTHROW +#ifndef SOAP_NOTHROW +# if defined(__GNUC__) && (__GNUC__ <= 2) +# define SOAP_NOTHROW +# elif defined(WITH_LEAN) || defined(WITH_COMPAT) +# define SOAP_NOTHROW +# else +# define SOAP_NOTHROW (std::nothrow) +# endif #endif #if (defined(__GNUC__) && (__GNUC__ <= 2) && !defined(__BORLANDC__)) || defined(__clang__) || defined(_AIX) || defined(AIX) @@ -1499,15 +1720,15 @@ typedef soap_int32 soap_mode; # endif #endif -#ifndef SOAP_NEW_COPY /* use C++ new operator for ::copy() */ +#ifndef SOAP_NEW_COPY /* use C++ new operator for ::copy() */ # define SOAP_NEW_COPY(clas) new SOAP_NOTHROW clas #endif -#ifndef SOAP_DELETE /* use C++ delete operator */ +#ifndef SOAP_DELETE /* use C++ delete operator */ # define SOAP_DELETE(obj) delete obj #endif -#ifndef SOAP_DELETE_ARRAY /* use C++ delete[] operator */ +#ifndef SOAP_DELETE_ARRAY /* use C++ delete[] operator */ # define SOAP_DELETE_ARRAY(obj) delete[] obj #endif @@ -1570,7 +1791,7 @@ typedef soap_int32 soap_mode; { if (!soap->fdebug[SOAP_INDEX_##DBGFILE])\ soap_open_logfile((struct soap*)soap, SOAP_INDEX_##DBGFILE);\ if (soap->fdebug[SOAP_INDEX_##DBGFILE])\ - { fwrite((MSG), 1, (LEN), soap->fdebug[SOAP_INDEX_##DBGFILE]);\ + { fwrite((void*)(MSG), 1, (size_t)(LEN), soap->fdebug[SOAP_INDEX_##DBGFILE]);\ fflush(soap->fdebug[SOAP_INDEX_##DBGFILE]);\ }\ }\ @@ -1623,27 +1844,30 @@ struct soap_nlist unsigned int level; /* nesting depth level */ short index; /* corresponding entry in ns mapping table */ const char *ns; /* only set when parsed ns URI is not in the ns mapping table */ - char id[1]; /* the actual string value flows into the allocated region below this struct */ + char id[1]; /* the actual string value flows into the allocated region id[0...] below this struct */ +}; + +/* block header, the data flows into the allocated region below this struct */ +struct soap_bhead +{ struct soap_bhead *next; + size_t size; }; /* block stack for nested block allocations */ struct soap_blist { struct soap_blist *next; - char *ptr; + struct soap_bhead *head; size_t size; -}; - -/* array layout */ -struct soap_array -{ void *__ptr; - int __size; + size_t item; }; /* pointer serialization management */ struct soap_plist { struct soap_plist *next; const void *ptr; - const struct soap_array *array; + void *dup; + const void *array; /* array pointer */ + int size; /* array size */ int type; int id; char mark1; /* 0=single-ref, 1=embedded-multi-ref (SOAP1.1), 2=multi-ref, 3=attachment */ @@ -1672,14 +1896,14 @@ struct soap_clist { struct soap_clist *next; void *ptr; int type; - int size; + int size; /* array size */ int (*fdelete)(struct soap_clist*); }; /* attributes */ struct soap_attribute { struct soap_attribute *next; - short flag; /* soap_set_attr: 1 = normal, 2 = utf content */ + short flag; /* soap_set_attr: 1 = normal, 2 = utf content */ char *value; size_t size; const char *ns; @@ -1694,13 +1918,13 @@ struct soap_cookie char *value; char *domain; char *path; - time_t expire; /* client-side: local time to expire */ - long maxage; /* server-side: seconds to expire */ + time_t expire; /* client-side: local time to expire */ + long maxage; /* server-side: seconds to expire */ unsigned int version; short secure; - short session; /* server-side */ - short env; /* server-side: got cookie from client and should not be (re)send */ - short modified; /* server-side: client cookie was modified and should be send */ + short session; /* server-side */ + short env; /* server-side: got cookie from client and should not be (re)send */ + short modified; /* server-side: client cookie was modified and should be send */ }; #endif @@ -1709,7 +1933,8 @@ SOAP_FMAC1 struct soap_multipart* SOAP_FMAC2 soap_next_multipart(struct soap_mul #ifdef __cplusplus class soap_multipart_iterator -{ public: +{ + public: struct soap_multipart *content; bool operator==(const soap_multipart_iterator& iter) const { return (bool)(content == iter.content); } @@ -1724,6 +1949,7 @@ class soap_multipart_iterator soap_multipart_iterator(struct soap_multipart *p) : content(p) { } }; + #endif #ifndef WITH_LEANER @@ -1737,8 +1963,8 @@ struct soap_dime const char *id; const char *type; const char *options; - struct soap_multipart *list; /* list of DIME attachments received */ - struct soap_multipart *first, *last; /* temporary in/out queue */ + struct soap_multipart *list; /* list of DIME attachments received */ + struct soap_multipart *first, *last; /* temporary in/out queue */ #ifdef __cplusplus soap_multipart_iterator begin() { soap_multipart_iterator iter(list); return iter; }; @@ -1750,10 +1976,10 @@ struct soap_dime #ifndef WITH_LEANER struct soap_mime -{ char *boundary; /* MIME boundary */ - const char *start; /* MIME start ID */ - struct soap_multipart *list; /* list of MIME attachments received */ - struct soap_multipart *first, *last; /* temporary in/out queue */ +{ char *boundary; /* MIME boundary */ + const char *start; /* MIME start ID */ + struct soap_multipart *list; /* list of MIME attachments received */ + struct soap_multipart *first, *last; /* temporary in/out queue */ #ifdef __cplusplus soap_multipart_iterator begin() { soap_multipart_iterator iter(list); return iter; }; @@ -1781,14 +2007,14 @@ enum soap_mime_encoding /* DIME/MIME multipart list */ struct soap_multipart { struct soap_multipart *next; - char *ptr; /* points to raw data content */ - size_t size; /* size of data content */ - const char *id; /* DIME/MIME content ID or form data name */ - const char *type; /* DIME/MIME type (MIME type format) */ - const char *options; /* DIME options */ - enum soap_mime_encoding encoding; /* MIME Content-Transfer-Encoding */ - const char *location; /* MIME Content-Location (optional) */ - const char *description; /* MIME Content-Description (optional) */ + char *ptr; /* points to raw data content */ + size_t size; /* size of data content */ + const char *id; /* DIME/MIME content ID or form data name */ + const char *type; /* DIME/MIME type (MIME type format) */ + const char *options; /* DIME options */ + enum soap_mime_encoding encoding; /* MIME Content-Transfer-Encoding */ + const char *location; /* MIME Content-Location (optional) */ + const char *description; /* MIME Content-Description (optional) */ #ifdef __cplusplus typedef soap_multipart_iterator iterator; #endif @@ -1810,16 +2036,155 @@ struct soap_xlist /******************************************************************************/ #ifndef WITH_LEANER + +/* dom.c[pp] functions (optional, compile and link dom.c[pp] */ +struct SOAP_CMAC soap; +struct SOAP_CMAC soap_dom_element; +struct SOAP_CMAC soap_dom_attribute; + +/* soap_dom_element construction */ + +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_elt_new(struct soap *soap, const char *ns, const char *tag); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_elt_new_w(struct soap *soap, const char *ns, const wchar_t *tag); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_elt_set(struct soap_dom_element *elt, const char *ns, const char *tag); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_elt_set_w(struct soap_dom_element *elt, const char *ns, const wchar_t *tag); + +SOAP_FMAC1 struct soap_dom_attribute * SOAP_FMAC2 soap_att(struct soap_dom_element *elt, const char *ns, const char *tag); +SOAP_FMAC1 struct soap_dom_attribute * SOAP_FMAC2 soap_att_w(struct soap_dom_element *elt, const char *ns, const wchar_t *tag); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_elt(struct soap_dom_element *elt, const char *ns, const char *tag); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_elt_w(struct soap_dom_element *elt, const char *ns, const wchar_t *tag); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_nth_elt(struct soap_dom_element *elt, const char *ns, const char *tag, size_t n); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_nth_elt_w(struct soap_dom_element *elt, const char *ns, const wchar_t *tag, size_t n); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_nth(struct soap_dom_element *elt, size_t n); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_add_att(struct soap_dom_element *elt, const struct soap_dom_attribute *node); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_add_elt(struct soap_dom_element *elt, const struct soap_dom_element *node); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_add_atts(struct soap_dom_element *elt, const struct soap_dom_attribute *atts); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_add_elts(struct soap_dom_element *elt, const struct soap_dom_element *elts); + +/* soap_dom_element assignment */ + +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_elt_bool(struct soap_dom_element *elt, LONG64 b); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_elt_int(struct soap_dom_element *elt, LONG64 n); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_elt_double(struct soap_dom_element *elt, double x); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_elt_text(struct soap_dom_element *elt, const char *text); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_elt_text_w(struct soap_dom_element *elt, const wchar_t *text); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_elt_node(struct soap_dom_element *elt, const void *node, int type); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_elt_copy(struct soap_dom_element *elt, const struct soap_dom_element *node); + +/* soap_dom_element properties */ + +SOAP_FMAC1 int SOAP_FMAC2 soap_elt_match(const struct soap_dom_element *elt, const char *ns, const char *patt); +SOAP_FMAC1 int SOAP_FMAC2 soap_elt_match_w(const struct soap_dom_element *elt, const char *ns, const wchar_t *patt); +SOAP_FMAC1 const char * SOAP_FMAC2 soap_elt_get_ns(const struct soap_dom_element *elt); +SOAP_FMAC1 const char * SOAP_FMAC2 soap_elt_get_tag(const struct soap_dom_element *elt); +SOAP_FMAC1 int SOAP_FMAC2 soap_elt_is_true(const struct soap_dom_element *elt); +SOAP_FMAC1 int SOAP_FMAC2 soap_elt_is_false(const struct soap_dom_element *elt); +SOAP_FMAC1 int SOAP_FMAC2 soap_elt_get_int(const struct soap_dom_element *elt); +SOAP_FMAC1 long SOAP_FMAC2 soap_elt_get_long(const struct soap_dom_element *elt); +SOAP_FMAC1 LONG64 SOAP_FMAC2 soap_elt_get_LONG64(const struct soap_dom_element *elt); +SOAP_FMAC1 double SOAP_FMAC2 soap_elt_get_double(const struct soap_dom_element *elt); +SOAP_FMAC1 const char * SOAP_FMAC2 soap_elt_get_text(const struct soap_dom_element *elt); +SOAP_FMAC1 const void * SOAP_FMAC2 soap_elt_get_node(const struct soap_dom_element *elt, int type); +SOAP_FMAC1 int SOAP_FMAC2 soap_elt_get_type(const struct soap_dom_element *elt, const void **node); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_elt_parent(const struct soap_dom_element *elt); +SOAP_FMAC1 size_t SOAP_FMAC2 soap_elt_depth(const struct soap_dom_element *elt); +SOAP_FMAC1 size_t SOAP_FMAC2 soap_elt_index(const struct soap_dom_element *elt); +SOAP_FMAC1 size_t SOAP_FMAC2 soap_elt_len(const struct soap_dom_element *elt); +SOAP_FMAC1 size_t SOAP_FMAC2 soap_elt_nth(const struct soap_dom_element *elt); + +/* soap_dom_attribute construction */ + +SOAP_FMAC1 struct soap_dom_attribute * SOAP_FMAC2 soap_att_new(struct soap *soap, const char *ns, const char *tag); +SOAP_FMAC1 struct soap_dom_attribute * SOAP_FMAC2 soap_att_new_w(struct soap *soap, const char *ns, const wchar_t *tag); +SOAP_FMAC1 struct soap_dom_attribute * SOAP_FMAC2 soap_att_set(struct soap_dom_attribute *att, const char *ns, const char *tag); +SOAP_FMAC1 struct soap_dom_attribute * SOAP_FMAC2 soap_att_set_w(struct soap_dom_attribute *att, const char *ns, const wchar_t *tag); +SOAP_FMAC1 struct soap_dom_attribute * SOAP_FMAC2 soap_att_add(struct soap_dom_attribute *att, const char *ns, const char *tag); +SOAP_FMAC1 struct soap_dom_attribute * SOAP_FMAC2 soap_att_add_w(struct soap_dom_attribute *att, const char *ns, const wchar_t *tag); + +/* soap_dom_attribute assignment */ + +SOAP_FMAC1 struct soap_dom_attribute * SOAP_FMAC2 soap_att_bool(struct soap_dom_attribute *att, LONG64 b); +SOAP_FMAC1 struct soap_dom_attribute * SOAP_FMAC2 soap_att_int(struct soap_dom_attribute *att, LONG64 n); +SOAP_FMAC1 struct soap_dom_attribute * SOAP_FMAC2 soap_att_double(struct soap_dom_attribute *att, double x); +SOAP_FMAC1 struct soap_dom_attribute * SOAP_FMAC2 soap_att_text(struct soap_dom_attribute *att, const char *text); +SOAP_FMAC1 struct soap_dom_attribute * SOAP_FMAC2 soap_att_text_w(struct soap_dom_attribute *att, const wchar_t *text); +SOAP_FMAC1 struct soap_dom_attribute * SOAP_FMAC2 soap_att_copy(struct soap_dom_attribute *att, const struct soap_dom_attribute *node); + +/* soap_dom_attribute properties */ + +SOAP_FMAC1 int SOAP_FMAC2 soap_att_match(const struct soap_dom_attribute *att, const char *ns, const char *patt); +SOAP_FMAC1 int SOAP_FMAC2 soap_att_match_w(const struct soap_dom_attribute *att, const char *ns, const wchar_t *patt); +SOAP_FMAC1 const char * SOAP_FMAC2 soap_att_get_ns(const struct soap_dom_attribute *att); +SOAP_FMAC1 const char * SOAP_FMAC2 soap_att_get_tag(const struct soap_dom_attribute *att); +SOAP_FMAC1 int SOAP_FMAC2 soap_att_is_true(const struct soap_dom_attribute *att); +SOAP_FMAC1 int SOAP_FMAC2 soap_att_is_false(const struct soap_dom_attribute *att); +SOAP_FMAC1 int SOAP_FMAC2 soap_att_get_int(const struct soap_dom_attribute *att); +SOAP_FMAC1 long SOAP_FMAC2 soap_att_get_long(const struct soap_dom_attribute *att); +SOAP_FMAC1 LONG64 SOAP_FMAC2 soap_att_get_LONG64(const struct soap_dom_attribute *att); +SOAP_FMAC1 double SOAP_FMAC2 soap_att_get_double(const struct soap_dom_attribute *att); +SOAP_FMAC1 const char * SOAP_FMAC2 soap_att_get_text(const struct soap_dom_attribute *att); + +/* DOM local traversal */ + +SOAP_FMAC1 struct soap_dom_attribute * SOAP_FMAC2 soap_att_first(struct soap_dom_element *elt); +SOAP_FMAC1 struct soap_dom_attribute * SOAP_FMAC2 soap_att_next(const struct soap_dom_attribute *att); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_elt_first(struct soap_dom_element *elt); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_elt_next(const struct soap_dom_element *elt); + +/* DOM local retrieval */ + +SOAP_FMAC1 struct soap_dom_attribute * SOAP_FMAC2 soap_att_get(const struct soap_dom_element *elt, const char *ns, const char *tag); +SOAP_FMAC1 struct soap_dom_attribute * SOAP_FMAC2 soap_att_get_w(const struct soap_dom_element *elt, const char *ns, const wchar_t *tag); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_elt_get(const struct soap_dom_element *elt, const char *ns, const char *tag); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_elt_get_w(const struct soap_dom_element *elt, const char *ns, const wchar_t *tag); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_elt_get_next(const struct soap_dom_element *elt); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_elt_get_nth(struct soap_dom_element *elt, size_t n); + +/* DOM local search */ + +SOAP_FMAC1 struct soap_dom_attribute * SOAP_FMAC2 soap_att_find(struct soap_dom_element *elt, const char *ns, const char *patt); +SOAP_FMAC1 struct soap_dom_attribute * SOAP_FMAC2 soap_att_find_next(const struct soap_dom_attribute *att, const char *ns, const char *patt); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_elt_find(struct soap_dom_element *elt, const char *ns, const char *patt); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_elt_find_next(const struct soap_dom_element *elt, const char *ns, const char *patt); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_elt_find_type(struct soap_dom_element *elt, const char *ns, const char *patt, int type); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_elt_find_next_type(const struct soap_dom_element *elt, const char *ns, const char *patt, int type); + +/* DOM size of local search results */ + +SOAP_FMAC1 size_t SOAP_FMAC2 soap_att_size(struct soap_dom_element *elt, const char *ns, const char *patt); +SOAP_FMAC1 size_t SOAP_FMAC2 soap_elt_size(struct soap_dom_element *elt, const char *ns, const char *patt); +SOAP_FMAC1 size_t SOAP_FMAC2 soap_elt_size_type(struct soap_dom_element *elt, const char *ns, const char *patt, int type); + +/* DOM deep traversal */ + +SOAP_FMAC1 struct soap_dom_attribute * SOAP_FMAC2 soap_dom_next_attribute(const struct soap_dom_attribute *att); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_dom_next_element(const struct soap_dom_element *elt, const struct soap_dom_element *end); + +/* DOM deep search */ + +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_dom_find(struct soap_dom_element *begin, const struct soap_dom_element *end, const char *ns, const char *patt, int type); +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_dom_find_next(const struct soap_dom_element *elt, const struct soap_dom_element *end, const char *ns, const char *patt, int type); + +#endif + +#if defined(__cplusplus) +} +#endif + +#ifndef WITH_LEANER #ifdef __cplusplus -class soap_dom_attribute_iterator -{ public: - struct soap_dom_attribute *att; +class SOAP_CMAC soap_dom_attribute_iterator +{ + public: + struct soap_dom_attribute *iter; const char *nstr; const char *name; bool operator==(const soap_dom_attribute_iterator&) const; bool operator!=(const soap_dom_attribute_iterator&) const; - struct soap_dom_attribute &operator*() const; - soap_dom_attribute_iterator &operator++(); + struct soap_dom_attribute& operator*() const; + struct soap_dom_attribute *operator->() const; + soap_dom_attribute_iterator& operator++(); + soap_dom_attribute_iterator operator++(int); soap_dom_attribute_iterator(); soap_dom_attribute_iterator(struct soap_dom_attribute*); ~soap_dom_attribute_iterator(); @@ -1828,41 +2193,100 @@ class soap_dom_attribute_iterator #endif #ifndef WITH_LEANER -struct soap_dom_attribute +struct SOAP_CMAC soap_dom_attribute { struct soap_dom_attribute *next; const char *nstr; - char *name; - char *data; - wchar_t *wide; + const char *name; + const char *text; struct soap *soap; #ifdef __cplusplus typedef soap_dom_attribute_iterator iterator; - struct soap_dom_attribute &set(const char *nstr, const char *name); /* set namespace and name */ - struct soap_dom_attribute &set(const char *data); /* set data */ - soap_dom_attribute_iterator begin(); - soap_dom_attribute_iterator end(); - soap_dom_attribute_iterator find(const char *nstr, const char *name); - void unlink(); - soap_dom_attribute(); - soap_dom_attribute(struct soap *soap); - soap_dom_attribute(struct soap *soap, const char *nstr, const char *name, const char *data); + soap_dom_attribute(struct soap *soap = NULL); + soap_dom_attribute(const soap_dom_attribute& att); + soap_dom_attribute(struct soap *soap, const char *tag); + soap_dom_attribute(struct soap *soap, const wchar_t *tag); + soap_dom_attribute(struct soap *soap, const char *ns, const char *tag, const char *text); + soap_dom_attribute(struct soap *soap, const char *ns, const char *tag, const wchar_t *text); + soap_dom_attribute(struct soap *soap, const char *ns, const wchar_t *tag, const char *text); + soap_dom_attribute(struct soap *soap, const char *ns, const wchar_t *tag, const wchar_t *text); + soap_dom_attribute(struct soap *soap, const char *ns, const char *tag, const std::string& text); + soap_dom_attribute(struct soap *soap, const char *ns, const char *tag, const std::wstring& text); + soap_dom_attribute(struct soap *soap, const char *ns, const wchar_t *tag, const std::string& text); + soap_dom_attribute(struct soap *soap, const char *ns, const wchar_t *tag, const std::wstring& text); ~soap_dom_attribute(); + soap_dom_attribute& set(const char *ns, const char *tag) { return *soap_att_set(this, ns, tag); } + soap_dom_attribute& set(const char *ns, const wchar_t *tag) { return *soap_att_set_w(this, ns, tag); } + soap_dom_attribute& set(bool b) { return *soap_att_bool(this, b); } + soap_dom_attribute& set(int n) { return *soap_att_int(this, n); } + soap_dom_attribute& set(LONG64 n) { return *soap_att_int(this, n); } + soap_dom_attribute& set(float x) { return *soap_att_double(this, x); } + soap_dom_attribute& set(double x) { return *soap_att_double(this, x); } + soap_dom_attribute& set(const char *text) { return *soap_att_text(this, text); } + soap_dom_attribute& set(const wchar_t *text) { return *soap_att_text_w(this, text); } +#ifndef WITH_COMPAT + soap_dom_attribute& set(const std::string& text) { return *soap_att_text(this, text.c_str()); } + soap_dom_attribute& set(const std::wstring& text) { return *soap_att_text_w(this, text.c_str()); } +#endif + soap_dom_attribute& operator=(bool b) { return *soap_att_bool(this, b); } + soap_dom_attribute& operator=(int n) { return *soap_att_int(this, n); } + soap_dom_attribute& operator=(LONG64 n) { return *soap_att_int(this, n); } + soap_dom_attribute& operator=(float x) { return *soap_att_double(this, x); } + soap_dom_attribute& operator=(double x) { return *soap_att_double(this, x); } + soap_dom_attribute& operator=(const char *text) { return *soap_att_text(this, text); } + soap_dom_attribute& operator=(const wchar_t *text) { return *soap_att_text_w(this, text); } +#ifndef WITH_COMPAT + soap_dom_attribute& operator=(const std::string& text) { return *soap_att_text(this, text.c_str()); } + soap_dom_attribute& operator=(const std::wstring& text) { return *soap_att_text_w(this, text.c_str()); } +#endif + soap_dom_attribute& operator=(const soap_dom_attribute& att) { return *soap_att_copy(this, &att); } + soap_dom_attribute& att(const char *tag) { return *soap_att_add(this, NULL, tag); } + soap_dom_attribute& att(const wchar_t *tag) { return *soap_att_add_w(this, NULL, tag); } + soap_dom_attribute& att(const char *ns, const char *tag) { return *soap_att_add(this, ns, tag); } + soap_dom_attribute& att(const char *ns, const wchar_t *tag) { return *soap_att_add_w(this, ns, tag); } + bool match(const char *patt) const { return soap_att_match(this, NULL, patt) != 0; } + bool match(const wchar_t *patt) const { return soap_att_match_w(this, NULL, patt) != 0; } + bool match(const char *ns, const char *patt) const { return soap_att_match(this, ns, patt) != 0; } + bool match(const char *ns, const wchar_t *patt) const { return soap_att_match_w(this, ns, patt) != 0; } + const char *ns() const { return this->nstr; } + const char *tag() const { return this->name; } + bool is_true() const { return soap_att_is_true(this) != 0; } + bool is_false() const { return soap_att_is_false(this) != 0; } + LONG64 get_int() const { return soap_att_get_LONG64(this); } + double get_double() const { return soap_att_get_double(this); } + const char *get_text() const { return this->text; } + operator bool() const { return soap_att_is_true(this) != 0; } + operator int() const { return soap_att_get_int(this); } + operator LONG64() const { return soap_att_get_LONG64(this); } + operator double() const { return soap_att_get_double(this); } + operator const char*() const { return this->text; } + soap_dom_attribute_iterator att_begin() { return soap_dom_attribute_iterator(this); } + soap_dom_attribute_iterator att_end() { return soap_dom_attribute_iterator(NULL); } + soap_dom_attribute_iterator att_find(const char *patt) { return att_find(NULL, patt); } + soap_dom_attribute_iterator att_find(const wchar_t *patt) { return att_find(NULL, patt); } + soap_dom_attribute_iterator att_find(const char *ns, const char *patt); + soap_dom_attribute_iterator att_find(const char *ns, const wchar_t *patt); + void unlink(); #endif }; #endif #ifndef WITH_LEANER #ifdef __cplusplus -class soap_dom_element_iterator -{ public: - struct soap_dom_element *elt; +class SOAP_CMAC soap_dom_element_iterator +{ + public: + struct soap_dom_element *iter; + struct soap_dom_element *stop; const char *nstr; const char *name; int type; + bool deep; bool operator==(const soap_dom_element_iterator&) const; bool operator!=(const soap_dom_element_iterator&) const; - struct soap_dom_element &operator*() const; - soap_dom_element_iterator &operator++(); + struct soap_dom_element& operator*() const; + struct soap_dom_element *operator->() const; + soap_dom_element_iterator& operator++(); + soap_dom_element_iterator operator++(int); soap_dom_element_iterator(); soap_dom_element_iterator(struct soap_dom_element*); ~soap_dom_element_iterator(); @@ -1871,121 +2295,249 @@ class soap_dom_element_iterator #endif #ifndef WITH_LEANER -struct soap_dom_element -{ struct soap_dom_element *next; /* next sibling */ - struct soap_dom_element *prnt; /* parent */ - struct soap_dom_element *elts; /* list of child elements */ - struct soap_dom_attribute *atts; /* list of attributes */ - const char *nstr; /* namespace string */ - char *name; /* element tag name */ - char *data; /* element content data (with SOAP_C_UTFSTRING flag set) */ - wchar_t *wide; /* element content data */ - int type; /* optional: serialized C/C++ data type */ - void *node; /* optional: pointer to serialized C/C++ data */ - char *head; /* leading content before start tag */ - char *tail; /* leading content before end tag */ - struct soap *soap; /* soap context that manages this node */ +struct SOAP_CMAC soap_dom_element +{ struct soap_dom_element *next; + struct soap_dom_element *prnt; + struct soap_dom_element *elts; + struct soap_dom_attribute *atts; + const char *nstr; + const char *name; + const char *lead; + const char *text; + const char *code; + const char *tail; + const void *node; + int type; + struct soap *soap; #ifdef __cplusplus typedef soap_dom_element_iterator iterator; - struct soap_dom_element &set(const char *nstr, const char *name); - struct soap_dom_element &set(const char *data); - struct soap_dom_element &set(void *node, int type); - struct soap_dom_element &add(struct soap_dom_element*); - struct soap_dom_element &add(struct soap_dom_element&); - struct soap_dom_element &add(struct soap_dom_attribute*); - struct soap_dom_element &add(struct soap_dom_attribute&); + soap_dom_element(struct soap *soap = NULL); + soap_dom_element(const soap_dom_element& elt); + soap_dom_element(struct soap *soap, const char *tag); + soap_dom_element(struct soap *soap, const wchar_t *tag); + soap_dom_element(struct soap *soap, const char *ns, const char *tag); + soap_dom_element(struct soap *soap, const char *ns, const wchar_t *tag); + soap_dom_element(struct soap *soap, const char *ns, const char *tag, const char *text); + soap_dom_element(struct soap *soap, const char *ns, const char *tag, const wchar_t *text); + soap_dom_element(struct soap *soap, const char *ns, const wchar_t *tag, const char *text); + soap_dom_element(struct soap *soap, const char *ns, const wchar_t *tag, const wchar_t *text); +#ifndef WITH_COMPAT + soap_dom_element(struct soap *soap, const char *ns, const char *tag, const std::string& text); + soap_dom_element(struct soap *soap, const char *ns, const char *tag, const std::wstring& text); + soap_dom_element(struct soap *soap, const char *ns, const wchar_t *tag, const std::string& text); + soap_dom_element(struct soap *soap, const char *ns, const wchar_t *tag, const std::wstring& text); +#endif + soap_dom_element(struct soap *soap, const char *ns, const char *tag, const void *node, int type); + soap_dom_element(struct soap *soap, const char *ns, const wchar_t *tag, const void *node, int type); + ~soap_dom_element(); + soap_dom_element& set(const char *ns, const char *tag) { return *soap_elt_set(this, ns, tag); } + soap_dom_element& set(const char *ns, const wchar_t *tag) { return *soap_elt_set_w(this, ns, tag); } + soap_dom_element& set(bool b) { return *soap_elt_bool(this, b); } + soap_dom_element& set(int n) { return *soap_elt_int(this, n); } + soap_dom_element& set(LONG64 n) { return *soap_elt_int(this, n); } + soap_dom_element& set(float x) { return *soap_elt_double(this, x); } + soap_dom_element& set(double x) { return *soap_elt_double(this, x); } + soap_dom_element& set(const char *text) { return *soap_elt_text(this, text); } + soap_dom_element& set(const wchar_t *text) { return *soap_elt_text_w(this, text); } +#ifndef WITH_COMPAT + soap_dom_element& set(const std::string& text) { return *soap_elt_text(this, text.c_str()); } + soap_dom_element& set(const std::wstring& text) { return *soap_elt_text_w(this, text.c_str()); } +#endif + soap_dom_element& set(const void *node, int type) { return *soap_elt_node(this, node, type); } + soap_dom_element& add(soap_dom_element& elt) { return *soap_add_elt(this, &elt); } + soap_dom_element& add(soap_dom_element *elt) { return *soap_add_elt(this, elt); } + soap_dom_element& add(soap_dom_attribute& att) { return *soap_add_att(this, &att); } + soap_dom_element& add(soap_dom_attribute *att) { return *soap_add_att(this, att); } + soap_dom_element& adds(soap_dom_element& elts) { return *soap_add_elts(this, &elts); } + soap_dom_element& adds(soap_dom_element *elts) { return *soap_add_elts(this, elts); } + soap_dom_element& adds(soap_dom_attribute& atts) { return *soap_add_atts(this, &atts); } + soap_dom_element& adds(soap_dom_attribute *atts) { return *soap_add_atts(this, atts); } + soap_dom_element& operator=(bool b) { return *soap_elt_bool(this, b); } + soap_dom_element& operator=(int n) { return *soap_elt_int(this, n); } + soap_dom_element& operator=(LONG64 n) { return *soap_elt_int(this, n); } + soap_dom_element& operator=(float x) { return *soap_elt_double(this, x); } + soap_dom_element& operator=(double x) { return *soap_elt_double(this, x); } + soap_dom_element& operator=(const char *text) { return *soap_elt_text(this, text); } + soap_dom_element& operator=(const wchar_t *text) { return *soap_elt_text_w(this, text); } +#ifndef WITH_COMPAT + soap_dom_element& operator=(const std::string& text) { return *soap_elt_text(this, text.c_str()); } + soap_dom_element& operator=(const std::wstring& text) { return *soap_elt_text_w(this, text.c_str()); } +#endif + soap_dom_element& operator=(const soap_dom_element& elt) { return *soap_elt_copy(this, &elt); } + template<class T> soap_dom_element& operator=(const T& node) { return this->set(&node, node.soap_type()); } + template<class T> soap_dom_element& operator=(const T *node) { return this->set(node, node->soap_type()); } + template<class T> soap_dom_element& operator=(T *node) { return this->set(node, node->soap_type()); } + soap_dom_attribute& att(const char *tag) { return *soap_att(this, NULL, tag); } + soap_dom_attribute& att(const wchar_t *tag) { return *soap_att_w(this, NULL, tag); } + soap_dom_attribute& att(const char *ns, const char *tag) { return *soap_att(this, ns, tag); } + soap_dom_attribute& att(const char *ns, const wchar_t *tag) { return *soap_att_w(this, ns, tag); } + soap_dom_element& elt() { return *soap_elt(this, NULL, NULL); } + soap_dom_element& elt(const char *tag) { return *soap_elt(this, NULL, tag); } + soap_dom_element& elt(const wchar_t *tag) { return *soap_elt_w(this, NULL, tag); } + soap_dom_element& elt(const char *ns, const char *tag) { return *soap_elt(this, ns, tag); } + soap_dom_element& elt(const char *ns, const wchar_t *tag) { return *soap_elt_w(this, ns, tag); } + soap_dom_element& operator[](const char *tag) { return *soap_elt(this, NULL, tag); } + soap_dom_element& operator[](const wchar_t *tag) { return *soap_elt_w(this, NULL, tag); } + soap_dom_element& operator[](size_t n) { return *soap_nth(this, n); } + soap_dom_attribute *att_get(const char *tag) const { return soap_att_get(this, NULL, tag); } + soap_dom_attribute *att_get(const wchar_t *tag) const { return soap_att_get_w(this, NULL, tag); } + soap_dom_attribute *att_get(const char *ns, const char *tag) const { return soap_att_get(this, ns, tag); } + soap_dom_attribute *att_get(const char *ns, const wchar_t *tag) const { return soap_att_get_w(this, ns, tag); } + soap_dom_element *elt_get() const { return soap_elt_get(this, NULL, NULL); } + soap_dom_element *elt_get(const char *tag) const { return soap_elt_get(this, NULL, tag); } + soap_dom_element *elt_get(const wchar_t *tag) const { return soap_elt_get_w(this, NULL, tag); } + soap_dom_element *elt_get(const char *ns, const char *tag) const { return soap_elt_get(this, ns, tag); } + soap_dom_element *elt_get(const char *ns, const wchar_t *tag) const { return soap_elt_get_w(this, ns, tag); } + soap_dom_element *get_next() const { return soap_elt_get_next(this); } + soap_dom_element *get_nth(size_t n) { return soap_elt_get_nth(this, n); } + bool match(const char *patt) const { return soap_elt_match(this, NULL, patt) != 0; } + bool match(const wchar_t *patt) const { return soap_elt_match_w(this, NULL, patt) != 0; } + bool match(const char *ns, const char *patt) const { return soap_elt_match(this, ns, patt) != 0; } + bool match(const char *ns, const wchar_t *patt) const { return soap_elt_match_w(this, ns, patt) != 0; } + const char *ns() const { return this->nstr; } + const char *tag() const { return this->name; } + soap_dom_element *parent() { return this->prnt; } + size_t depth() const { return soap_elt_depth(this); } + size_t index() const { return soap_elt_index(this); } + size_t len() const { return soap_elt_len(this); } + size_t nth() const { return soap_elt_nth(this); } + size_t elt_size() { return soap_elt_size(this, NULL, NULL); } + size_t elt_size(const char *patt, int type = 0) { return elt_size(NULL, patt, type); } + size_t elt_size(const char *ns, const char *patt, int type = 0) { return soap_elt_size_type(this, ns, patt, type); } + size_t att_size() { return soap_att_size(this, NULL, NULL); } + size_t att_size(const char *patt) { return att_size(NULL, patt); } +#ifndef WITH_COMPAT + size_t att_size(const std::string& patt) { return att_size(NULL, patt); } +#endif + size_t att_size(const char *ns, const char *patt) { return soap_att_size(this, ns, patt); } +#ifndef WITH_COMPAT + size_t att_size(const char *ns, const std::string& patt) { return soap_att_size(this, ns, patt.c_str()); } +#endif + bool is_true() const { return soap_elt_is_true(this) != 0; } + bool is_false() const { return soap_elt_is_false(this) != 0; } + LONG64 get_int() const { return soap_elt_get_LONG64(this); } + double get_double() const { return soap_elt_get_double(this); } + const char *get_text() const { return this->text; } + const void *get_node(int type) const { return soap_elt_get_node(this, type); } + int get_type(const void **node) const { return soap_elt_get_type(this, node); } + operator bool() const { return soap_elt_is_true(this) != 0; } + operator int() const { return soap_elt_get_int(this); } + operator LONG64() const { return soap_elt_get_LONG64(this); } + operator double() const { return soap_elt_get_double(this); } + operator const char*() const { return this->text; } soap_dom_element_iterator begin(); - soap_dom_element_iterator end(); - soap_dom_element_iterator find(const char *nstr, const char *name); + soap_dom_element_iterator end() { return soap_dom_element_iterator(NULL); } + soap_dom_element_iterator elt_begin() { return soap_dom_element_iterator(this->elts); } + soap_dom_element_iterator elt_end() { return soap_dom_element_iterator(NULL); } + soap_dom_attribute_iterator att_begin() { return soap_dom_attribute_iterator(this->atts); } + soap_dom_attribute_iterator att_end() { return soap_dom_attribute_iterator(NULL); } + soap_dom_element_iterator find(const char *patt, int type = 0) { return find(NULL, patt, type); } + soap_dom_element_iterator find(const wchar_t *patt, int type = 0) { return find(NULL, patt, type); } + soap_dom_element_iterator find(const char *ns, const char *patt, int type = 0); + soap_dom_element_iterator find(const char *ns, const wchar_t *patt, int type = 0); soap_dom_element_iterator find(int type); + soap_dom_element_iterator elt_find(const char *patt, int type = 0) { return elt_find(NULL, patt, type); } + soap_dom_element_iterator elt_find(const wchar_t *patt, int type = 0) { return elt_find(NULL, patt, type); } + soap_dom_element_iterator elt_find(const char *ns, const char *patt, int type = 0); + soap_dom_element_iterator elt_find(const char *ns, const wchar_t *patt, int type = 0); + soap_dom_element_iterator elt_find(int type); + soap_dom_attribute_iterator att_find(const char *patt) { return att_find(NULL, patt); } + soap_dom_attribute_iterator att_find(const wchar_t *patt) { return att_find(NULL, patt); } + soap_dom_attribute_iterator att_find(const char *ns, const char *patt); + soap_dom_attribute_iterator att_find(const char *ns, const wchar_t *patt); void unlink(); - soap_dom_element(); - soap_dom_element(struct soap *soap); - soap_dom_element(struct soap *soap, const char *nstr, const char *name); - soap_dom_element(struct soap *soap, const char *nstr, const char *name, const char *data); - soap_dom_element(struct soap *soap, const char *nstr, const char *name, void *node, int type); - ~soap_dom_element(); #endif }; -SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_dom_next_element(struct soap_dom_element *elt); -SOAP_FMAC1 struct soap_dom_attribute * SOAP_FMAC2 soap_dom_next_attribute(struct soap_dom_attribute *att); #endif -#if defined(__cplusplus) && !defined(WITH_LEAN) && !defined(WITH_COMPAT) -} +#ifndef WITH_LEANER +SOAP_FMAC1 struct soap_dom_element * SOAP_FMAC2 soap_dup_xsd__anyType(struct soap *soap, struct soap_dom_element *d, const struct soap_dom_element *a); +SOAP_FMAC1 void SOAP_FMAC2 soap_del_xsd__anyType(const struct soap_dom_element *a); +SOAP_FMAC1 struct soap_dom_attribute * SOAP_FMAC2 soap_dup_xsd__anyAttribute(struct soap *soap, struct soap_dom_attribute *d, const struct soap_dom_attribute *a); +SOAP_FMAC1 void SOAP_FMAC2 soap_del_xsd__anyAttribute(const struct soap_dom_attribute *a); +SOAP_FMAC1 int SOAP_FMAC2 soap_dom_call(struct soap *soap, const char *endpoint, const char *action, const struct soap_dom_element *in, struct soap_dom_element *out); +#endif + +#ifndef WITH_LEANER +#if defined(__cplusplus) && !defined(WITH_COMPAT) extern std::ostream &operator<<(std::ostream&, const struct soap_dom_element&); extern std::istream &operator>>(std::istream&, struct soap_dom_element&); + +SOAP_FMAC1 int SOAP_FMAC2 soap_dom_call(struct soap *soap, const char *endpoint, const char *action, const struct soap_dom_element& in, struct soap_dom_element& out); +SOAP_FMAC1 int SOAP_FMAC2 soap_dom_call(struct soap *soap, const char *endpoint, const char *action, const struct soap_dom_element *in, struct soap_dom_element& out); +SOAP_FMAC1 int SOAP_FMAC2 soap_dom_call(struct soap *soap, const char *endpoint, const char *action, const struct soap_dom_element& in, struct soap_dom_element *out); +#endif +#endif + +#if defined(__cplusplus) extern "C" { #endif /******************************************************************************/ -#ifdef WIN32 -# ifdef SOAP_STD_EXPORTS -# define SOAP_STD_API __declspec(dllexport) -# else -# define SOAP_STD_API -# endif -#else -# define SOAP_STD_API -#endif - -struct SOAP_STD_API soap -{ short state; /* 0 = uninitialized, 1 = initialized, 2 = copy of another soap struct */ - short version; /* 1 = SOAP1.1 and 2 = SOAP1.2 (set automatically from namespace URI in nsmap table), 0 indicates non-SOAP content */ +struct SOAP_CMAC soap +{ short state; /* 0 = uninitialized, 1 = initialized, 2 = copy of another soap struct */ + short version; /* 1 = SOAP1.1 and 2 = SOAP1.2 (set automatically from namespace URI in nsmap table), 0 indicates non-SOAP content */ soap_mode mode; soap_mode imode; soap_mode omode; - const char *float_format; /* user-definable format string for floats (<1024 chars) */ - const char *double_format; /* user-definable format string for doubles (<1024 chars) */ - const char *dime_id_format; /* user-definable format string for integer DIME id (<SOAP_TAGLEN chars) */ - const char *http_version; /* HTTP version used "1.0" or "1.1" */ - const char *http_content; /* optional custom response content type (with SOAP_FILE) */ - const char *encodingStyle; /* default = "" which means that SOAP encoding is used */ - const char *actor; /* SOAP-ENV:actor or role attribute value */ - const char *lang; /* xml:lang attribute value of SOAP-ENV:Text */ - int recv_timeout; /* when > 0, gives socket recv timeout in seconds, < 0 in usec */ - int send_timeout; /* when > 0, gives socket send timeout in seconds, < 0 in usec */ - int connect_timeout; /* when > 0, gives socket connect() timeout in seconds, < 0 in usec */ - int accept_timeout; /* when > 0, gives socket accept() timeout in seconds, < 0 in usec */ - int socket_flags; /* socket recv() and send() flags, e.g. set to MSG_NOSIGNAL to disable sigpipe */ - int connect_flags; /* connect() SOL_SOCKET sockopt flags, e.g. set to SO_DEBUG to debug socket */ - int bind_flags; /* bind() SOL_SOCKET sockopt flags, e.g. set to SO_REUSEADDR to enable reuse */ - int accept_flags; /* accept() SOL_SOCKET sockopt flags */ - unsigned short linger_time; /* linger time for SO_LINGER option */ - const struct Namespace *namespaces; /* Pointer to global namespace mapping table */ - struct Namespace *local_namespaces; /* Local namespace mapping table */ - struct soap_nlist *nlist; /* namespace stack */ - struct soap_blist *blist; /* block allocation stack */ - struct soap_clist *clist; /* class instance allocation list */ - void *alist; /* memory allocation (malloc) list */ -#if !defined(WITH_LEAN) || !defined(WITH_NOIDREF) + const char *float_format; /* user-definable format string for floats (<1024 chars) */ + const char *double_format; /* user-definable format string for doubles (<1024 chars) */ + const char *long_double_format; /* user-definable format string for long doubles (<1024 chars) */ + const char *dime_id_format; /* user-definable format string for integer DIME id (<SOAP_TAGLEN chars) */ + int recv_timeout; /* user-definable, when > 0, gives socket recv timeout in seconds, < 0 in usec */ + int send_timeout; /* user-definable, when > 0, gives socket send timeout in seconds, < 0 in usec */ + int connect_timeout; /* user-definable, when > 0, gives socket connect() timeout in seconds, < 0 in usec */ + int accept_timeout; /* user-definable, when > 0, gives socket accept() timeout in seconds, < 0 in usec */ + int socket_flags; /* user-definable socket recv() and send() flags, e.g. set to MSG_NOSIGNAL to disable sigpipe */ + int connect_flags; /* user-definable connect() SOL_SOCKET sockopt flags, e.g. set to SO_DEBUG to debug socket */ + int bind_flags; /* user-definable bind() SOL_SOCKET sockopt flags, e.g. set to SO_REUSEADDR to enable reuse */ + int accept_flags; /* user-definable accept() SOL_SOCKET sockopt flags */ + int sndbuf; /* user-definable SO_SNFBUF setsockopt */ + int rcvbuf; /* user-definable SO_SNFBUF setsockopt */ + unsigned short linger_time; /* user-definable linger time for SO_LINGER option */ + unsigned int maxlevel; /* user-definable max XML nesting depth levels, initialized to SOAP_MAXLEVEL */ + long maxlength; /* user-definable max string length, initialized to SOAP_MAXLENGTH, maxlength<=0 is unbounded */ + size_t maxoccurs; /* user-definable max array/container size, initialized to SOAP_MAXOCCURS */ + const char *http_version; /* HTTP version used "1.0" or "1.1" */ + const char *http_content; /* optional custom response content type (with SOAP_FILE) */ + const char *encodingStyle; /* default = "" which means that SOAP encoding is used */ + const char *actor; /* SOAP-ENV:actor or role attribute value */ + const char *lang; /* user-definable xml:lang attribute value of SOAP-ENV:Text */ + const struct Namespace *namespaces; /* Pointer to global namespace mapping table */ + struct Namespace *local_namespaces; /* Local namespace mapping table */ + struct soap_nlist *nlist; /* namespace stack */ + struct soap_blist *blist; /* block allocation stack */ + struct soap_clist *clist; /* class instance allocation list */ + void *alist; /* memory allocation (malloc) list */ + short shaky; /* objects in reallocatable containers are on shaky grounds */ +#if !defined(WITH_LEANER) || !defined(WITH_NOIDREF) struct soap_ilist *iht[SOAP_IDHASH]; - struct soap_plist *pht[SOAP_PTRHASH]; - struct soap_pblk *pblk; /* plist block allocation */ - short pidx; /* plist block allocation */ #endif + struct soap_plist *pht[SOAP_PTRHASH]; + struct soap_pblk *pblk; /* plist block allocation */ + short pidx; /* plist block allocation */ struct SOAP_ENV__Header *header; struct SOAP_ENV__Fault *fault; int idnum; - void *user; /* for user to pass user-defined data */ - void *data[4]; /* extension data = {smdevp, mecevp, ...} */ - struct soap_plugin *plugins; /* linked list of plug-in data */ - const char *userid; /* HTTP Basic authorization userid */ - const char *passwd; /* HTTP Basic authorization passwd */ - const char *authrealm; /* HTTP authentication realm (NTLM domain) */ + void *user; /* for user to pass user-defined data to callbacks */ + void *data[4]; /* extension data = {smdevp, mecevp, ...} */ + struct soap_plugin *plugins; /* linked list of plug-in data */ + const char *userid; /* HTTP Basic authorization userid */ + const char *passwd; /* HTTP Basic authorization passwd */ + const char *authrealm; /* HTTP authentication realm (and NTLM domain) */ #if !defined(WITH_LEAN) || defined(WITH_NTLM) - const char *ntlm_challenge; /* HTTP NTLM challenge key string */ - short ntlm_auth; /* HTTP NTLM authentication type */ - short ntlm_stage; /* HTTP NTLM stage 0..3 */ + const char *ntlm_challenge; /* HTTP NTLM challenge key string */ + short ntlm_auth; /* HTTP NTLM authentication type */ + short ntlm_stage; /* HTTP NTLM stage 0..3 */ #endif int (*fpost)(struct soap*, const char*, const char*, int, const char*, const char*, size_t); - int (*fget)(struct soap*); /* HTTP GET hook (not set by default) */ - int (*fput)(struct soap*); /* HTTP PUT hook (handled as POST by default) */ - int (*fdel)(struct soap*); /* HTTP DELETE hook (not set by default) */ - int (*fopt)(struct soap*); /* HTTP OPTIONS hook (not set by default) */ - int (*fhead)(struct soap*); /* HTTP HEAD hook (not set by default) */ - int (*fform)(struct soap*); /* HTTP/HTML form handler for plugins */ + int (*fget)(struct soap*); /* HTTP GET hook (not set by default) */ + int (*fput)(struct soap*); /* HTTP PUT hook (handled as POST by default) */ + int (*fdel)(struct soap*); /* HTTP DELETE hook (not set by default) */ + int (*fopt)(struct soap*); /* HTTP OPTIONS hook (not set by default) */ + int (*fhead)(struct soap*); /* HTTP HEAD hook (not set by default) */ + int (*fform)(struct soap*); /* HTTP/HTML form handler for plugins */ int (*fposthdr)(struct soap*, const char*, const char*); int (*fresponse)(struct soap*, int, size_t); int (*fparse)(struct soap*); @@ -2008,6 +2560,8 @@ struct SOAP_STD_API soap void *(*fplugin)(struct soap*, const char*); void *(*fmalloc)(struct soap*, size_t); #ifndef WITH_LEANER + int (*fsvalidate)(struct soap*, const char*, const char*); + int (*fwvalidate)(struct soap*, const char*, const wchar_t*); int (*feltbegin)(struct soap*, const char*); int (*feltendin)(struct soap*, const char*, const char*); int (*feltbegout)(struct soap*, const char*); @@ -2018,7 +2572,7 @@ struct SOAP_STD_API soap int (*fpreparerecv)(struct soap*, const char*, size_t); int (*fpreparefinalsend)(struct soap*); int (*fpreparefinalrecv)(struct soap*); - int filterstop; + int recverror; /* last soap_recv_raw error code for filterrecv */ int (*ffiltersend)(struct soap*, const char**, size_t*); int (*ffilterrecv)(struct soap*, char*, size_t*, size_t); void *(*fdimereadopen)(struct soap*, void*, const char*, const char*, const char*); @@ -2034,38 +2588,38 @@ struct SOAP_STD_API soap size_t (*fmimeread)(struct soap*, void*, char*, size_t); int (*fmimewrite)(struct soap*, void*, const char*, size_t); #endif - SOAP_SOCKET master; /* socket bound to TCP/IP port */ - SOAP_SOCKET socket; /* socket to send and receive */ - SOAP_SOCKET sendsk; /* socket to send (overrides ::socket) */ - SOAP_SOCKET recvsk; /* socket to receive (overrides ::socket) */ -#if defined(__cplusplus) && !defined(WITH_LEAN) && !defined(WITH_COMPAT) - std::ostream *os; /* stream to send */ - std::istream *is; /* stream to receive */ + SOAP_SOCKET master; /* socket bound to TCP/IP port */ + SOAP_SOCKET socket; /* socket to send and receive */ + SOAP_SOCKET sendsk; /* socket to send (overrides ::socket) */ + SOAP_SOCKET recvsk; /* socket to receive (overrides ::socket) */ +#if defined(__cplusplus) && !defined(WITH_COMPAT) + std::ostream *os; /* C++ only: ostream to send */ + std::istream *is; /* C++ only: istream to receive */ #else - void *os; /* preserve struct size */ - void *is; /* preserve struct size */ + const char **os; /* C only: pointer to a const char*, will be set to point to the string output */ + const char *is; /* C only: a const char* to read from (soap->is will advance) */ #endif #ifndef UNDER_CE - int sendfd; /* WinCE FD to send */ - int recvfd; /* WinCE FD to receive */ + int sendfd; /* int file descriptor for sending */ + int recvfd; /* int file descriptor for receiving */ #else - FILE *sendfd; /* FD to send */ - FILE *recvfd; /* FD to receive */ -#endif - size_t bufidx; /* index in soap.buf[] */ - size_t buflen; /* length of soap.buf[] content */ - soap_wchar ahead; /* parser lookahead */ - short cdata; /* CDATA parser state */ - short body; /* HTTP or XML element has a body (1) or not (0) */ - unsigned int level; /* XML nesting level */ - size_t count; /* message length counter */ - size_t length; /* message length as set by HTTP header */ - char *labbuf; /* look-aside buffer */ - size_t lablen; /* look-aside buffer allocated length */ - size_t labidx; /* look-aside buffer index to available part */ + FILE *sendfd; /* WinCE FILE* to send */ + FILE *recvfd; /* WinCE FILE* to receive */ +#endif + size_t bufidx; /* index in soap.buf[] */ + size_t buflen; /* length of soap.buf[] content */ + soap_wchar ahead; /* parser lookahead */ + short cdata; /* CDATA parser state */ + short body; /* HTTP or XML element has a body (1) or not (0) */ + unsigned int level; /* XML nesting level */ + size_t count; /* message length counter */ + size_t length; /* message length as set by HTTP header */ + char *labbuf; /* look-aside buffer */ + size_t lablen; /* look-aside buffer allocated length */ + size_t labidx; /* look-aside buffer index to available part */ char buf[SOAP_BUFLEN];/* send and receive buffer */ - char msgbuf[1024]; /* in/out buffer for HTTP/MIME headers >=1024 bytes */ - char tmpbuf[1024]; /* in/out buffer for HTTP/MIME headers, simpleType values, element and attribute tag names, and DIME must be >=1024 bytes */ + char msgbuf[SOAP_TMPLEN]; /* in/out buffer for HTTP/MIME headers and short messages, must be >=1024 bytes */ + char tmpbuf[SOAP_TMPLEN]; /* in/out buffer for HTTP/MIME headers, simpleType values, element and attribute tag names, and DIME must be >=1024 bytes */ char tag[SOAP_TAGLEN]; char id[SOAP_TAGLEN]; char href[SOAP_TAGLEN]; @@ -2077,38 +2631,38 @@ struct SOAP_STD_API soap short root; int position; int positions[SOAP_MAXDIMS]; - struct soap_attribute *attributes; /* attribute list */ - short encoding; /* when set, output encodingStyle */ - short mustUnderstand; /* a mustUnderstand element was parsed or is output */ - short null; /* parsed XML is xsi:nil */ - short ns; /* when not set, output full xmlns bindings */ - short part; /* SOAP part state (header or body) */ - short event; /* engine events and states for use by plugins */ - unsigned int evlev; /* event level */ - short alloced; + struct soap_attribute *attributes; /* attribute list */ + short encoding; /* when set, output encodingStyle */ + short mustUnderstand; /* a mustUnderstand element was parsed or is output */ + short null; /* parsed XML is xsi:nil */ + short ns; /* zero to output all xmlns */ + short part; /* SOAP part state (header or body) */ + short event; /* engine events and states for use by plugins */ short peeked; + unsigned int evlev; /* event level */ + int alloced; size_t chunksize; size_t chunkbuflen; char endpoint[SOAP_TAGLEN]; char path[SOAP_TAGLEN]; char host[SOAP_TAGLEN]; char *action; - char *prolog; /* XML declaration prolog */ - unsigned long ip; /* IP number */ - int port; /* port number */ - short keep_alive; /* connection should be kept open */ - short tcp_keep_alive; /* enable SO_KEEPALIVE */ - unsigned int tcp_keep_idle; /* set TCP_KEEPIDLE */ - unsigned int tcp_keep_intvl; /* set TCP_KEEPINTVL */ - unsigned int tcp_keep_cnt; /* set TCP_KEEPCNT */ + const char *prolog; /* XML declaration prolog */ + unsigned long ip; /* IP number */ + int port; /* port number */ + short keep_alive; /* connection should be kept open */ + short tcp_keep_alive; /* enable SO_KEEPALIVE */ + unsigned int tcp_keep_idle; /* set TCP_KEEPIDLE */ + unsigned int tcp_keep_intvl; /* set TCP_KEEPINTVL */ + unsigned int tcp_keep_cnt; /* set TCP_KEEPCNT */ unsigned int max_keep_alive; /* maximum keep-alive session (default=100) */ const char *proxy_http_version;/* HTTP version of proxy "1.0" or "1.1" */ - const char *proxy_host; /* Proxy Server host name */ - int proxy_port; /* Proxy Server port (default = 8080) */ - const char *proxy_userid; /* Proxy Authorization user name */ - const char *proxy_passwd; /* Proxy Authorization password */ - const char *proxy_from; /* X-Forwarding-For header returned by proxy */ - int status; /* -1 when request, else error code to be returned by server */ + const char *proxy_host; /* Proxy Server host name */ + int proxy_port; /* Proxy Server port (default = 8080) */ + const char *proxy_userid; /* Proxy Authorization user name */ + const char *proxy_passwd; /* Proxy Authorization password */ + const char *proxy_from; /* X-Forwarding-For header returned by proxy */ + int status; /* -1 when request, else error code to be returned by server */ int error; int errmode; int errnum; @@ -2124,8 +2678,9 @@ struct SOAP_STD_API soap struct soap_mlist *mht[SOAP_PTRHASH]; #endif #ifndef WITH_LEAN - const char *wsuid; /* space-separated string of element tags */ - const char *c14nexclude; /* space-separated string of prefixes */ + const char *wsuid; /* space-separated string of element tags */ + const char *c14nexclude; /* space-separated string of prefixes for c14n exclusion */ + const char *c14ninclude; /* space-separated string of prefixes for c14n inclusion */ struct soap_cookie *cookies; const char *cookie_domain; const char *cookie_path; @@ -2135,14 +2690,14 @@ struct SOAP_STD_API soap unsigned int ipv6_multicast_if; /* in_addr_t in6addr->sin6_scope_id IPv6 value */ char* ipv4_multicast_if; /* IP_MULTICAST_IF IPv4 setsockopt interface_addr */ unsigned char ipv4_multicast_ttl; /* IP_MULTICAST_TTL value 0..255 */ -#ifdef WITH_IPV6 - struct sockaddr_storage peer; /* IPv6: set by soap_accept and by UDP recv */ -#else - struct sockaddr_in peer; /* IPv4: set by soap_connect/soap_accept and by UDP recv */ -#endif + union + { struct sockaddr addr; + struct sockaddr_in in; + struct sockaddr_storage storage; + } peer; /* set by soap_connect/soap_accept and by UDP recv */ #endif size_t peerlen; -#if defined(WITH_OPENSSL) /* OpenSSL */ +#if defined(WITH_OPENSSL) /* OpenSSL */ int (*fsslauth)(struct soap*); int (*fsslverify)(int, X509_STORE_CTX*); BIO *bio; @@ -2151,17 +2706,26 @@ struct SOAP_STD_API soap SSL_SESSION *session; const char *dhfile; const char *randfile; -#elif defined(WITH_GNUTLS) /* GNUTLS */ +#elif defined(WITH_GNUTLS) /* GNUTLS */ int (*fsslauth)(struct soap*); void *fsslverify; - gnutls_certificate_credentials_t xcred; /* cert pointer */ - gnutls_anon_client_credentials_t acred; /* anon pointer */ - gnutls_priority_t cache; /* priority cache pointer */ - gnutls_session_t session; /* session pointer */ + gnutls_certificate_credentials_t xcred; /* cert pointer */ + gnutls_anon_client_credentials_t acred; /* anon pointer */ + gnutls_priority_t cache; /* priority cache pointer */ + gnutls_session_t session; /* session pointer */ gnutls_dh_params_t dh_params; gnutls_rsa_params_t rsa_params; -#else /* No SSL/TLS */ - void *fsslauth; /* dummy members, to preserve struct size */ +#elif defined(WITH_SYSTEMSSL) /* SYSTEM SSL */ + int (*fsslauth)(struct soap*); + void *fsslverify; /* N/A */ + void *bio; /* N/A */ + gsk_handle ctx; /* environment */ + gsk_handle ssl; /* ssl socket */ + void *session; /* N/A */ + const char *dhfile; /* N/A */ + const char *randfile; /* N/A */ +#else /* No SSL/TLS */ + void *fsslauth; /* dummy members, to preserve struct size */ void *fsslverify; void *bio; void *ssl; @@ -2181,31 +2745,31 @@ struct SOAP_STD_API soap int session_port; #ifdef WITH_C_LOCALE # ifdef WIN32 - _locale_t c_locale; /* set to C locale by default */ + _locale_t c_locale; /* set to C locale by default */ # else - locale_t c_locale; /* set to C locale by default */ + locale_t c_locale; /* set to C locale by default */ # endif #else void *c_locale; #endif #ifdef WITH_ZLIB - z_stream *d_stream; /* decompression stream */ - uLong z_crc; /* internal gzip crc */ + z_stream *d_stream; /* decompression stream */ + uLong z_crc; /* internal gzip crc */ #else - void *d_stream; /* dummy members, to preserve struct size */ + void *d_stream; /* dummy members, to preserve struct size */ soap_int32 z_crc; #endif - const char *z_dict; /* support for zlib static dictionaries */ + const char *z_dict; /* support for zlib static dictionaries */ unsigned int z_dict_len; - short zlib_state; /* SOAP_ZLIB_NONE, SOAP_ZLIB_DEFLATE, or SOAP_ZLIB_INFLATE */ - short zlib_in; /* SOAP_ZLIB_NONE, SOAP_ZLIB_DEFLATE, or SOAP_ZLIB_GZIP */ - short zlib_out; /* SOAP_ZLIB_NONE, SOAP_ZLIB_DEFLATE, or SOAP_ZLIB_GZIP */ - char *z_buf; /* buffer */ + short zlib_state; /* SOAP_ZLIB_NONE, SOAP_ZLIB_DEFLATE, or SOAP_ZLIB_INFLATE */ + short zlib_in; /* SOAP_ZLIB_NONE, SOAP_ZLIB_DEFLATE, or SOAP_ZLIB_GZIP */ + short zlib_out; /* SOAP_ZLIB_NONE, SOAP_ZLIB_DEFLATE, or SOAP_ZLIB_GZIP */ + char *z_buf; /* buffer */ size_t z_buflen; - unsigned short z_level; /* compression level to be used (0=none, 1=fast to 9=best) */ - float z_ratio_in; /* detected compression ratio compressed_length/length of inbound message */ - float z_ratio_out; /* detected compression ratio compressed_length/length of outbound message */ -#ifdef WMW_RPM_IO /* VxWorks */ + unsigned short z_level; /* compression level to be used (0=none, 1=fast to 9=best) */ + float z_ratio_in; /* detected compression ratio compressed_length/length of inbound message */ + float z_ratio_out; /* detected compression ratio compressed_length/length of outbound message */ +#ifdef WMW_RPM_IO /* VxWorks */ void *rpmreqid; #endif #ifdef __cplusplus @@ -2213,14 +2777,13 @@ struct SOAP_STD_API soap soap(soap_mode); soap(soap_mode, soap_mode); soap(const struct soap&); - virtual ~soap(); -#else - void (*dummy)(void); + struct soap& operator=(const struct soap&); + ~soap(); /* no virtual methods, so sizeof(soap) should be the same in C and C++ */ #endif }; struct soap_code_map -{ long code; +{ LONG64 code; const char *string; }; @@ -2230,8 +2793,8 @@ struct soap_flist int type; void *ptr; unsigned int level; - size_t len; - void (*fcopy)(struct soap*, int, int, void*, size_t, const void*, size_t); + size_t index; + void (*finsert)(struct soap*, int, int, void*, size_t, const void*, void**); }; /* id-ref forwarding list */ @@ -2239,11 +2802,13 @@ struct soap_ilist { struct soap_ilist *next; int type; size_t size; + void *ptr; + void **spine; void *link; void *copy; struct soap_flist *flist; - void *ptr; - unsigned int level; + void *smart; + short shaky; char id[1]; /* the actual id string value flows into the allocated region below this struct */ }; @@ -2265,10 +2830,7 @@ soap_wchar soap_get0(struct soap*); soap_wchar soap_get1(struct soap*); #endif -#define SOAP_XSTRINGIFY(s) SOAP_STRINGIFY(s) -#define SOAP_STRINGIFY(s) #s - -#define soap_versioning_paste(name, ext) name##_LIBRARY_VERSION_REQUIRED_##ext +#define soap_versioning_paste(name, ext) name##_REQUIRE_lib_v##ext #define soap_versioning_ext(name, ext) soap_versioning_paste(name, ext) #define soap_versioning(name) soap_versioning_ext(name, GSOAP_VERSION) @@ -2282,6 +2844,7 @@ soap_wchar soap_get1(struct soap*); #define soap_revget1(soap) ((soap)->bufidx--) #define soap_unget(soap, c) ((soap)->ahead = c) +#define soap_peek(soap) ((soap)->ahead = soap_get(soap)) #define soap_register_plugin(soap, plugin) soap_register_plugin_arg(soap, plugin, NULL) #define soap_mode(soap, n) ((soap)->mode = (soap)->imode = (soap)->omode = (n)) #define soap_imode(soap, n) ((soap)->imode = (n)) @@ -2290,10 +2853,12 @@ soap_wchar soap_get1(struct soap*); #define soap_clr_imode(soap, n) ((soap)->imode &= ~(n)) #define soap_set_omode(soap, n) ((soap)->omode |= (n)) #define soap_clr_omode(soap, n) ((soap)->omode &= ~(n)) -#define soap_set_mode(soap, n) ((soap)->imode |= (n), (soap)->omode |= (n)) -#define soap_clr_mode(soap, n) ((soap)->imode &= ~(n), (soap)->omode &= ~(n)) +#define soap_set_mode(soap, n) ((soap)->mode |= (n), (soap)->imode |= (n), (soap)->omode |= (n)) +#define soap_clr_mode(soap, n) ((soap)->mode &= ~(n), (soap)->imode &= ~(n), (soap)->omode &= ~(n)) #define soap_destroy(soap) soap_delete((soap), NULL) +#define SOAP_NO_LINK_TO_DELETE (-2) /* pass to soap_link() as size n: do not manage, smart pointers are self-managing */ + #ifdef HAVE_STRRCHR # define soap_strrchr(s, t) strrchr(s, t) #else @@ -2303,24 +2868,24 @@ soap_wchar soap_get1(struct soap*); #ifdef HAVE_STRTOL # define soap_strtol(s, t, b) strtol(s, t, b) #else - SOAP_FMAC1 long SOAP_FMAC2 soap_strtol(const char *s, char **t, int b); + SOAP_FMAC1 long SOAP_FMAC2 soap_strtol(const char*, char**, int); #endif #ifdef HAVE_STRTOUL # define soap_strtoul(s, t, b) strtoul(s, t, b) #else - SOAP_FMAC1 unsigned long SOAP_FMAC2 soap_strtoul(const char *s, char **t, int b); + SOAP_FMAC1 unsigned long SOAP_FMAC2 soap_strtoul(const char*, char**, int); #endif -#if defined(WIN32) && !defined(__MINGW32__) +#if defined(WIN32) && !defined(__MINGW32__) && !defined(__MINGW64__) # define soap_strtoll _strtoi64 -#else +#elif !defined(soap_strtoll) # define soap_strtoll strtoll #endif -#if defined(WIN32) && !defined(__MINGW32__) +#if defined(WIN32) && !defined(__MINGW32__) && !defined(__MINGW64__) # define soap_strtoull _strtoui64 -#else +#elif !defined(soap_strtoull) # define soap_strtoull strtoull #endif @@ -2334,19 +2899,22 @@ SOAP_FMAC1 int SOAP_FMAC2 soap_rand(void); #endif #ifdef WITH_NOIDREF -# define soap_embedded(s, p, t) (0) -# define soap_id_lookup(s, i, p, t, n, k) (p) -# define soap_id_forward(s, h, p, len, st, tt, n, k, fc) (p) -# define soap_reference(s, a, t) (1) -# define soap_array_reference(s, p, a, n, t) (1) -# define soap_embed(s, p, a, n, t, pp) (0) -# define soap_embedded_id(s, i, p, t) (i) -# define soap_is_embedded(s, p) (0) -# define soap_is_single(s, p) (1) -# define soap_lookup_type(s, i) (0) -# define soap_getindependent(s) (0) -# define soap_putindependent(s) (0) -# define soap_markelement(s, p, n) (0) +# define soap_embedded(s, p, t) ((void)(s), 0) +# define soap_id_lookup(s, i, p, t, n, k, fb) ((void)(s), (p)) +# define soap_id_forward(s, h, p, i, t, tt, n, k, fi, fb) ((void)(s), (p)) +# define soap_id_nullify(s, i) ((void)(s), (i)) +# define soap_reference(s, a, t) ((void)(s), 1) +# define soap_array_reference(s, p, a, n, t) ((void)(s), 1) +# define soap_embed(s, p, a, n, t) ((void)(s), 0) +# define soap_embedded_id(s, i, p, t) ((void)(s), (void)(t), i) +# define soap_is_embedded(s, p) ((void)(s), 0) +# define soap_is_single(s, p) ((void)(s), 1) +# define soap_lookup_type(s, i) ((void)(s), 0) +# define soap_getindependent(s) ((void)(s), 0) +# define soap_putindependent(s) ((void)(s), 0) +# define soap_markelement(s, p, t) ((void)(s), 0) +# define soap_begin_shaky(s) ((void)(s), 0) +# define soap_end_shaky(s, f) ((void)(s), (void)(f), 0) #endif /* soap_traverse() traversal/walker routines take walker function arguments */ @@ -2372,6 +2940,7 @@ SOAP_FMAC1 int SOAP_FMAC2 soap_getfault(struct soap*); SOAP_FMAC1 int SOAP_FMAC2 soap_putfault(struct soap*); SOAP_FMAC1 void SOAP_FMAC2 soap_ssl_init(void); +SOAP_FMAC1 void SOAP_FMAC2 soap_ssl_noinit(void); SOAP_FMAC1 int SOAP_FMAC2 soap_poll(struct soap*); SOAP_FMAC1 int SOAP_FMAC2 soap_connect_command(struct soap*, int, const char*, const char*); SOAP_FMAC1 int SOAP_FMAC2 soap_connect(struct soap*, const char*, const char*); @@ -2379,6 +2948,7 @@ SOAP_FMAC1 SOAP_SOCKET SOAP_FMAC2 soap_bind(struct soap*, const char*, int, int) SOAP_FMAC1 SOAP_SOCKET SOAP_FMAC2 soap_accept(struct soap*); SOAP_FMAC1 int SOAP_FMAC2 soap_ssl_accept(struct soap*); SOAP_FMAC1 const char * SOAP_FMAC2 soap_ssl_error(struct soap*, int); +SOAP_FMAC1 int SOAP_FMAC2 soap_ssl_crl(struct soap*, const char*); #if defined(VXWORKS) && defined(WM_SECURE_KEY_STORAGE) SOAP_FMAC1 int SOAP_FMAC2 soap_ssl_server_context(struct soap *soap, unsigned short flags, const char *keyfile, const char *keyid, const char *password, const char *cafile, const char *capath, const char *dhfile, const char *randfile, const char *sid); @@ -2421,6 +2991,7 @@ SOAP_FMAC1 int SOAP_FMAC2 soap_send3(struct soap*, const char*, const char*, con SOAP_FMAC1 int SOAP_FMAC2 soap_pututf8(struct soap*, unsigned long); SOAP_FMAC1 soap_wchar SOAP_FMAC2 soap_getutf8(struct soap*); +SOAP_FMAC1 size_t SOAP_FMAC2 soap_utf8len(const char*); SOAP_FMAC1 int SOAP_FMAC2 soap_putbase64(struct soap*, const unsigned char*, int); SOAP_FMAC1 unsigned char* SOAP_FMAC2 soap_getbase64(struct soap*, int*, int); @@ -2429,26 +3000,31 @@ SOAP_FMAC1 unsigned char* SOAP_FMAC2 soap_gethex(struct soap*, int*); #ifndef WITH_LEANER SOAP_FMAC1 int SOAP_FMAC2 soap_xop_forward(struct soap*, unsigned char**, int*, char**, char**, char**); -SOAP_FMAC1 int SOAP_FMAC2 soap_dime_forward(struct soap*, unsigned char**, int*, char**, char**, char**); +SOAP_FMAC1 int SOAP_FMAC2 soap_attachment_forward(struct soap*, unsigned char**, int*, char**, char**, char**); #endif +SOAP_FMAC1 int SOAP_FMAC2 soap_pointer_lookup(struct soap*, const void *p, int t, struct soap_plist**); +SOAP_FMAC1 int SOAP_FMAC2 soap_pointer_enter(struct soap*, const void *p, const void *a, int n, int t, struct soap_plist**); +SOAP_FMAC1 int SOAP_FMAC2 soap_array_pointer_lookup(struct soap*, const void *p, const void *a, int n, int t, struct soap_plist**); #ifndef WITH_NOIDREF SOAP_FMAC1 int SOAP_FMAC2 soap_pointer_lookup_id(struct soap*, void *p, int t, struct soap_plist**); -SOAP_FMAC1 int SOAP_FMAC2 soap_pointer_lookup(struct soap*, const void *p, int t, struct soap_plist**); -SOAP_FMAC1 int SOAP_FMAC2 soap_pointer_enter(struct soap*, const void *p, const struct soap_array *a, int n, int t, struct soap_plist**); -SOAP_FMAC1 int SOAP_FMAC2 soap_array_pointer_lookup(struct soap*, const void *p, const struct soap_array *a, int n, int t, struct soap_plist**); -SOAP_FMAC1 int SOAP_FMAC2 soap_embed(struct soap *soap, const void *p, const struct soap_array *a, int n, const char *tag, int type); +SOAP_FMAC1 int SOAP_FMAC2 soap_embed(struct soap *soap, const void *p, const void *a, int n, int type); SOAP_FMAC1 struct soap_ilist* SOAP_FMAC2 soap_lookup(struct soap*, const char*); -SOAP_FMAC1 struct soap_ilist* SOAP_FMAC2 soap_enter(struct soap*, const char*); +SOAP_FMAC1 struct soap_ilist* SOAP_FMAC2 soap_enter(struct soap*, const char*, int, size_t); SOAP_FMAC1 int SOAP_FMAC2 soap_resolve(struct soap*); SOAP_FMAC1 void SOAP_FMAC2 soap_embedded(struct soap*, const void *p, int t); SOAP_FMAC1 int SOAP_FMAC2 soap_reference(struct soap*, const void *p, int t); -SOAP_FMAC1 int SOAP_FMAC2 soap_array_reference(struct soap*, const void *p, const struct soap_array *a, int n, int t); +SOAP_FMAC1 int SOAP_FMAC2 soap_array_reference(struct soap*, const void *p, const void *a, int n, int t); SOAP_FMAC1 int SOAP_FMAC2 soap_embedded_id(struct soap*, int id, const void *p, int t); SOAP_FMAC1 int SOAP_FMAC2 soap_is_embedded(struct soap*, struct soap_plist*); SOAP_FMAC1 int SOAP_FMAC2 soap_is_single(struct soap*, struct soap_plist*); SOAP_FMAC1 void SOAP_FMAC2 soap_set_embedded(struct soap*, struct soap_plist*); #endif +SOAP_FMAC1 int SOAP_FMAC2 soap_check_and_mark(struct soap *soap, const void *p, int t, char **mark); +SOAP_FMAC1 void * SOAP_FMAC2 soap_mark_lookup(struct soap *soap, const void *p, int t, struct soap_plist **pp, char **mark); +SOAP_FMAC1 int SOAP_FMAC2 soap_mark_cycle(struct soap *soap, struct soap_plist *pp); +SOAP_FMAC1 void SOAP_FMAC2 soap_mark_dup(struct soap *soap, void *a, struct soap_plist *pp); +SOAP_FMAC1 void SOAP_FMAC2 soap_unmark(struct soap *soap, char *mark); SOAP_FMAC1 int SOAP_FMAC2 soap_begin_count(struct soap*); SOAP_FMAC1 int SOAP_FMAC2 soap_end_count(struct soap*); @@ -2457,9 +3033,9 @@ SOAP_FMAC1 int SOAP_FMAC2 soap_end_send(struct soap*); SOAP_FMAC1 int SOAP_FMAC2 soap_end_send_flush(struct soap*); SOAP_FMAC1 const struct soap_code_map* SOAP_FMAC2 soap_code(const struct soap_code_map*, const char*); -SOAP_FMAC1 long SOAP_FMAC2 soap_code_int(const struct soap_code_map*, const char*, long); +SOAP_FMAC1 LONG64 SOAP_FMAC2 soap_code_int(const struct soap_code_map*, const char*, LONG64); SOAP_FMAC1 const char* SOAP_FMAC2 soap_code_str(const struct soap_code_map*, long); -SOAP_FMAC1 long SOAP_FMAC2 soap_code_bits(const struct soap_code_map*, const char*); +SOAP_FMAC1 LONG64 SOAP_FMAC2 soap_code_bits(const struct soap_code_map*, const char*); SOAP_FMAC1 const char* SOAP_FMAC2 soap_code_list(struct soap*, const struct soap_code_map*, long); SOAP_FMAC1 int SOAP_FMAC2 soap_getline(struct soap*, char*, int); @@ -2479,22 +3055,22 @@ SOAP_FMAC1 void SOAP_FMAC2 soap_track_free(struct soap*, const char*, int, void* #ifndef WITH_NOIDREF SOAP_FMAC1 int SOAP_FMAC2 soap_lookup_type(struct soap*, const char *id); -SOAP_FMAC1 void* SOAP_FMAC2 soap_id_lookup(struct soap*, const char *id, void **p, int t, size_t n, unsigned int k); -SOAP_FMAC1 void* SOAP_FMAC2 soap_id_forward(struct soap*, const char *id, void *p, size_t len, int st, int tt, size_t n, unsigned int k, void(*fcopy)(struct soap*, int, int, void*, size_t, const void*, size_t)); +SOAP_FMAC1 short SOAP_FMAC2 soap_begin_shaky(struct soap*); +SOAP_FMAC1 void SOAP_FMAC2 soap_end_shaky(struct soap*, short); +SOAP_FMAC1 void* SOAP_FMAC2 soap_id_lookup(struct soap*, const char *id, void **p, int t, size_t n, unsigned int k, int (*fbase)(int, int)); +SOAP_FMAC1 void* SOAP_FMAC2 soap_id_forward(struct soap*, const char *id, void *p, size_t i, int t, int tt, size_t n, unsigned int k, void(*finsert)(struct soap*, int, int, void*, size_t, const void*, void**), int (*fbase)(int, int)); +SOAP_FMAC1 int SOAP_FMAC2 soap_id_nullify(struct soap*, const char*); #endif -SOAP_FMAC1 void* SOAP_FMAC2 soap_id_enter(struct soap*, const char *id, void *p, int t, size_t n, unsigned int k, const char *type, const char *arrayType, void *(*finstantiate)(struct soap*, int, const char*, const char*, size_t*)); -SOAP_FMAC1 void SOAP_FMAC2 soap_fcopy(struct soap *soap, int st, int tt, void *p, size_t, const void *q, size_t n); +SOAP_FMAC1 void* SOAP_FMAC2 soap_id_enter(struct soap*, const char *id, void *p, int t, size_t n, const char *type, const char *arrayType, void *(*finstantiate)(struct soap*, int, const char*, const char*, size_t*), int (*fbase)(int, int)); +SOAP_FMAC1 void** SOAP_FMAC2 soap_id_smart(struct soap *soap, const char*, int, size_t); -SOAP_FMAC1 int SOAP_FMAC2 soap_size(const int *, int); +SOAP_FMAC1 size_t SOAP_FMAC2 soap_size(const int *, int); +SOAP_FMAC1 size_t SOAP_FMAC2 soap_getsizes(const char *, int *, int); SOAP_FMAC1 int SOAP_FMAC2 soap_getoffsets(const char *, const int *, int *, int); -SOAP_FMAC1 int SOAP_FMAC2 soap_getsize(const char *, const char *, int *); -SOAP_FMAC1 int SOAP_FMAC2 soap_getsizes(const char *, int *, int); + SOAP_FMAC1 int SOAP_FMAC2 soap_getposition(const char *, int *); -SOAP_FMAC1 char* SOAP_FMAC2 soap_putsize(struct soap*, const char *, int); SOAP_FMAC1 char* SOAP_FMAC2 soap_putsizesoffsets(struct soap*, const char *, const int *, const int *, int); -SOAP_FMAC1 char* SOAP_FMAC2 soap_putsizes(struct soap*, const char *, const int *, int); -SOAP_FMAC1 char* SOAP_FMAC2 soap_putoffset(struct soap*, int); SOAP_FMAC1 char* SOAP_FMAC2 soap_putoffsets(struct soap*, const int *, int); SOAP_FMAC1 int SOAP_FMAC2 soap_closesock(struct soap*); @@ -2526,6 +3102,7 @@ SOAP_FMAC1 void SOAP_FMAC2 soap_open_logfile(struct soap*, int); SOAP_FMAC1 const char* SOAP_FMAC2 soap_value(struct soap*); SOAP_FMAC1 int SOAP_FMAC2 soap_match_tag(struct soap*, const char*, const char *); +SOAP_FMAC1 int SOAP_FMAC2 soap_match_att(struct soap*, const char*, const char *); SOAP_FMAC1 int SOAP_FMAC2 soap_match_array(struct soap*, const char*); SOAP_FMAC1 int SOAP_FMAC2 soap_element(struct soap*, const char*, int, const char*); @@ -2535,7 +3112,7 @@ SOAP_FMAC1 int SOAP_FMAC2 soap_element_ref(struct soap*, const char *tag, int id SOAP_FMAC1 int SOAP_FMAC2 soap_element_href(struct soap*, const char *tag, int id, const char *ref, const char *val); SOAP_FMAC1 int SOAP_FMAC2 soap_element_null(struct soap*, const char *tag, int id, const char *type); SOAP_FMAC1 int SOAP_FMAC2 soap_element_nil(struct soap*, const char *tag); -SOAP_FMAC1 int SOAP_FMAC2 soap_element_id(struct soap*, const char *tag, int id, const void *p, const struct soap_array *a, int d, const char *type, int n); +SOAP_FMAC1 int SOAP_FMAC2 soap_element_id(struct soap*, const char *tag, int id, const void *p, const void *a, int n, const char *type, int t, char **mark); SOAP_FMAC1 int SOAP_FMAC2 soap_element_result(struct soap*, const char *tag); SOAP_FMAC1 void SOAP_FMAC2 soap_check_result(struct soap*, const char *tag); SOAP_FMAC1 int SOAP_FMAC2 soap_element_end_out(struct soap*, const char *tag); @@ -2551,28 +3128,34 @@ SOAP_FMAC1 int SOAP_FMAC2 soap_peek_element(struct soap*); SOAP_FMAC1 void SOAP_FMAC2 soap_retry(struct soap*); SOAP_FMAC1 void SOAP_FMAC2 soap_revert(struct soap*); +SOAP_FMAC1 int SOAP_FMAC2 soap_ignore(struct soap*); +SOAP_FMAC1 void* SOAP_FMAC2 soap_memdup(struct soap*, const void*, size_t); SOAP_FMAC1 char* SOAP_FMAC2 soap_strdup(struct soap*, const char*); SOAP_FMAC1 wchar_t* SOAP_FMAC2 soap_wstrdup(struct soap*, const wchar_t*); +SOAP_FMAC1 char* SOAP_FMAC2 soap_strtrim(struct soap*, char*); +SOAP_FMAC1 wchar_t* SOAP_FMAC2 soap_wstrtrim(struct soap*, wchar_t*); SOAP_FMAC1 const char * SOAP_FMAC2 soap_tagsearch(const char *big, const char *little); SOAP_FMAC1 int SOAP_FMAC2 soap_string_out(struct soap*, const char *s, int flag); -SOAP_FMAC1 char* SOAP_FMAC2 soap_string_in(struct soap*, int, long, long); +SOAP_FMAC1 char* SOAP_FMAC2 soap_string_in(struct soap*, int, long, long, const char*); #ifndef WITH_LEANER SOAP_FMAC1 int SOAP_FMAC2 soap_wstring_out(struct soap*, const wchar_t *s, int flag); -SOAP_FMAC1 wchar_t* SOAP_FMAC2 soap_wstring_in(struct soap*, int, long, long); +SOAP_FMAC1 wchar_t* SOAP_FMAC2 soap_wstring_in(struct soap*, int, long, long, const char*); #endif SOAP_FMAC1 int SOAP_FMAC2 soap_match_namespace(struct soap*, const char *, const char*, size_t n1, size_t n2); SOAP_FMAC1 void SOAP_FMAC2 soap_set_version(struct soap*, short); +SOAP_FMAC1 void SOAP_FMAC2 soap_get_version(struct soap*); SOAP_FMAC1 int SOAP_FMAC2 soap_set_namespaces(struct soap*, const struct Namespace*); SOAP_FMAC1 void SOAP_FMAC2 soap_set_local_namespaces(struct soap*); SOAP_FMAC1 void SOAP_FMAC2 soap_pop_namespace(struct soap*); SOAP_FMAC1 struct soap_nlist* SOAP_FMAC2 soap_push_namespace(struct soap*, const char *,const char *); -SOAP_FMAC1 const char* SOAP_FMAC2 soap_current_namespace(struct soap *soap, const char *tag); +SOAP_FMAC1 const char* SOAP_FMAC2 soap_current_namespace_tag(struct soap *soap, const char *tag); +SOAP_FMAC1 const char* SOAP_FMAC2 soap_current_namespace_att(struct soap *soap, const char *tag); SOAP_FMAC1 struct soap_nlist* SOAP_FMAC2 soap_lookup_ns(struct soap *soap, const char *tag, size_t n); @@ -2581,6 +3164,7 @@ SOAP_FMAC1 int SOAP_FMAC2 soap_append_lab(struct soap*, const char*, size_t); SOAP_FMAC1 struct soap_blist* SOAP_FMAC2 soap_new_block(struct soap*); SOAP_FMAC1 void* SOAP_FMAC2 soap_push_block(struct soap*, struct soap_blist*, size_t); +SOAP_FMAC1 void* SOAP_FMAC2 soap_push_block_max(struct soap*, struct soap_blist*, size_t); SOAP_FMAC1 void SOAP_FMAC2 soap_pop_block(struct soap*, struct soap_blist*); SOAP_FMAC1 size_t SOAP_FMAC2 soap_size_block(struct soap*, struct soap_blist*, size_t); SOAP_FMAC1 char* SOAP_FMAC2 soap_first_block(struct soap*, struct soap_blist*); @@ -2588,7 +3172,7 @@ SOAP_FMAC1 char* SOAP_FMAC2 soap_next_block(struct soap*, struct soap_blist*); SOAP_FMAC1 size_t SOAP_FMAC2 soap_block_size(struct soap*, struct soap_blist*); SOAP_FMAC1 char* SOAP_FMAC2 soap_save_block(struct soap*, struct soap_blist*, char*, int); SOAP_FMAC1 void SOAP_FMAC2 soap_end_block(struct soap*, struct soap_blist*); -SOAP_FMAC1 void SOAP_FMAC2 soap_update_pointers(struct soap *soap, char *start, char *end, char *p1, char *p2); +SOAP_FMAC1 void SOAP_FMAC2 soap_update_pointers(struct soap *soap, const char *dst, const char *src, size_t len); SOAP_FMAC1 int SOAP_FMAC2 soap_envelope_begin_out(struct soap*); SOAP_FMAC1 int SOAP_FMAC2 soap_envelope_end_out(struct soap*); @@ -2639,11 +3223,19 @@ SOAP_FMAC1 int SOAP_FMAC2 soap_s2unsignedShort(struct soap*, const char*, unsign SOAP_FMAC1 int SOAP_FMAC2 soap_s2unsignedInt(struct soap*, const char*, unsigned int*); SOAP_FMAC1 int SOAP_FMAC2 soap_s2unsignedLong(struct soap*, const char*, unsigned long*); SOAP_FMAC1 int SOAP_FMAC2 soap_s2ULONG64(struct soap*, const char*, ULONG64*); -SOAP_FMAC1 int SOAP_FMAC2 soap_s2string(struct soap*, const char*, char**, long minlen, long maxlen); -SOAP_FMAC1 int SOAP_FMAC2 soap_s2QName(struct soap*, const char*, char**, long minlen, long maxlen); +SOAP_FMAC1 int SOAP_FMAC2 soap_s2char(struct soap*, const char*, char**, long minlen, long maxlen, const char *pattern); +SOAP_FMAC1 int SOAP_FMAC2 soap_s2QName(struct soap*, const char*, char**, long minlen, long maxlen, const char *pattern); -#ifndef WITH_LEAN -SOAP_FMAC1 int SOAP_FMAC2 soap_s2wchar(struct soap*, const char*, wchar_t**, long minlen, long maxlen); +#ifndef WITH_COMPAT +#ifdef __cplusplus +SOAP_FMAC1 int SOAP_FMAC2 soap_s2stdQName(struct soap*, const char*, std::string*, long minlen, long maxlen, const char *pattern); +SOAP_FMAC1 int SOAP_FMAC2 soap_s2stdchar(struct soap*, const char*, std::string*, long minlen, long maxlen, const char *pattern); +SOAP_FMAC1 int SOAP_FMAC2 soap_s2stdwchar(struct soap*, const char*, std::wstring*, long minlen, long maxlen, const char *pattern); +#endif +#endif + +#if !defined(WITH_LEAN) || defined(WITH_NTLM) +SOAP_FMAC1 int SOAP_FMAC2 soap_s2wchar(struct soap*, const char*, wchar_t**, long minlen, long maxlen, const char *pattern); SOAP_FMAC1 int SOAP_FMAC2 soap_s2dateTime(struct soap*, const char*, time_t*); SOAP_FMAC1 char* SOAP_FMAC2 soap_s2base64(struct soap*, const unsigned char*, char*, int); SOAP_FMAC1 char* SOAP_FMAC2 soap_s2hex(struct soap*, const unsigned char*, char*, int); @@ -2663,7 +3255,7 @@ SOAP_FMAC1 const char* SOAP_FMAC2 soap_unsignedLong2s(struct soap*, unsigned lon SOAP_FMAC1 const char* SOAP_FMAC2 soap_ULONG642s(struct soap*, ULONG64); SOAP_FMAC1 const char* SOAP_FMAC2 soap_QName2s(struct soap*, const char*); -#ifndef WITH_LEAN +#if !defined(WITH_LEAN) || defined(WITH_NTLM) SOAP_FMAC1 const char* SOAP_FMAC2 soap_wchar2s(struct soap*, const wchar_t*); SOAP_FMAC1 const char* SOAP_FMAC2 soap_dateTime2s(struct soap*, time_t); SOAP_FMAC1 const char* SOAP_FMAC2 soap_base642s(struct soap*, const char*, char*, size_t, int*); @@ -2683,7 +3275,7 @@ SOAP_FMAC1 unsigned short* SOAP_FMAC2 soap_inunsignedShort(struct soap*, const c SOAP_FMAC1 unsigned int* SOAP_FMAC2 soap_inunsignedInt(struct soap*, const char *tag, unsigned int *p, const char *, int); SOAP_FMAC1 unsigned long* SOAP_FMAC2 soap_inunsignedLong(struct soap*, const char *tag, unsigned long *p, const char *, int); SOAP_FMAC1 ULONG64* SOAP_FMAC2 soap_inULONG64(struct soap*, const char *tag, ULONG64 *p, const char *, int); -SOAP_FMAC1 char** SOAP_FMAC2 soap_instring(struct soap*, const char *tag, char **p, const char *, int, int, long, long); +SOAP_FMAC1 char** SOAP_FMAC2 soap_instring(struct soap*, const char *tag, char **p, const char *, int, int, long, long, const char*); SOAP_FMAC1 char** SOAP_FMAC2 soap_inliteral(struct soap*, const char *tag, char **p); #ifndef WITH_LEAN @@ -2692,7 +3284,7 @@ SOAP_FMAC1 time_t SOAP_FMAC2 soap_timegm(struct tm*); #endif #ifndef WITH_LEANER -SOAP_FMAC1 wchar_t** SOAP_FMAC2 soap_inwstring(struct soap*, const char *tag, wchar_t **p, const char *, int, long, long); +SOAP_FMAC1 wchar_t** SOAP_FMAC2 soap_inwstring(struct soap*, const char *tag, wchar_t **p, const char *, int, long, long, const char*); SOAP_FMAC1 wchar_t** SOAP_FMAC2 soap_inwliteral(struct soap*, const char *tag, wchar_t **p); #endif @@ -2721,7 +3313,7 @@ SOAP_FMAC1 int SOAP_FMAC2 soap_outwliteral(struct soap*, const char *tag, wchar_ #endif #ifndef WITH_LEANER -SOAP_FMAC1 int SOAP_FMAC2 soap_attachment(struct soap *, const char*, int, const void*, const struct soap_array*, const char*, const char*, const char*, int, const char*, int); +SOAP_FMAC1 int SOAP_FMAC2 soap_attachment(struct soap *, const char*, int, const void*, const void*, int, const char*, const char*, const char*, const char*, int); SOAP_FMAC1 int SOAP_FMAC2 soap_move(struct soap*, size_t); SOAP_FMAC1 size_t SOAP_FMAC2 soap_tell(struct soap*); SOAP_FMAC1 char* SOAP_FMAC2 soap_dime_option(struct soap*, unsigned short, const char*); @@ -2752,7 +3344,8 @@ SOAP_FMAC1 const char* SOAP_FMAC2 soap_attr_value(struct soap *soap, const char SOAP_FMAC1 int SOAP_FMAC2 soap_set_attr(struct soap *soap, const char *name, const char *value, int flag); SOAP_FMAC1 void SOAP_FMAC2 soap_clr_attr(struct soap *soap); -SOAP_FMAC1 const char* SOAP_FMAC2 soap_url(struct soap *soap, const char*, const char*); +SOAP_FMAC1 const char* SOAP_FMAC2 soap_extend_url(struct soap *soap, const char*, const char*); +SOAP_FMAC1 const char* SOAP_FMAC2 soap_extend_url_query(struct soap *soap, const char*, const char*); SOAP_FMAC1 size_t SOAP_FMAC2 soap_encode_url(const char*, char*, size_t); SOAP_FMAC1 const char* SOAP_FMAC2 soap_encode_url_string(struct soap*, const char*); #ifdef WITH_COOKIES @@ -2777,4 +3370,49 @@ SOAP_FMAC1 int SOAP_FMAC2 soap_putcookies(struct soap *soap, const char *domain, } /* extern "C" */ #endif +#ifdef __cplusplus + +/* C++ templates (for generated C++ only, not needed nor used in generated C code) */ + +template<class T> +struct soap_block +{ static T *push(struct soap *soap, struct soap_blist *b) + { if (!b) + b = soap->blist; + if (!b) + return NULL; + T *p = (T*)soap_push_block_max(soap, b, sizeof(T)); + if (p) + SOAP_PLACEMENT_NEW(p, T); + return p; + } + static void pop(struct soap *soap, struct soap_blist *b) + { if (!b) + b = soap->blist; + if (!b || !b->head) + return; + ((T*)(b->head + 1))->T::~T(); + soap_pop_block(soap, b); + } + static void save(struct soap *soap, struct soap_blist *b, T *p) + { if (!b) + b = soap->blist; + for (T *q = (T*)soap_first_block(soap, b); q; q = (T*)soap_next_block(soap, b)) + { soap_update_pointers(soap, (const char*)p, (const char*)q, sizeof(T)); + *p++ = *q; + q->T::~T(); + } + soap_end_block(soap, b); + } + static void end(struct soap *soap, struct soap_blist *b) + { if (!b) + b = soap->blist; + for (T *p = (T*)soap_first_block(soap, b); p; p = (T*)soap_next_block(soap, b)) + p->T::~T(); + soap_end_block(soap, b); + } +}; + +#endif + #endif /* STDSOAP_H */ diff --git a/dep/gsoap/tc_upgrades.txt b/dep/gsoap/tc_upgrades.txt index 04298b2ae82..cda096cd0f9 100644 --- a/dep/gsoap/tc_upgrades.txt +++ b/dep/gsoap/tc_upgrades.txt @@ -1,5 +1,5 @@ * Generate new headers based on TrinityCore soap-services stub: -gsoap/bin/linux386/soapcpp2 -1 -S -L -w -x -y soap.stub +gsoap/bin/linux386/soapcpp2 -1 -S -L -w -x -y -c++11 gsoap.stub * Copy the following files from the gsoap package: gsoap/stdsoap2.h @@ -7,6 +7,5 @@ gsoap/stdsoap2.cpp * Remove the following files after generation: ns1.nsmap -soapObject.h * Test compile and see if SOAP works... |