optimization

This commit is contained in:
Dmitry Stogov 2004-02-06 16:52:14 +00:00
parent 9415013456
commit 59ab20b23b
4 changed files with 46 additions and 32 deletions

View File

@ -1990,7 +1990,7 @@ static int schema_attributeGroup(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr attrGrou
return TRUE; return TRUE;
} }
static void copy_extra_attribute(void *attribute) static void copy_extra_attribute(void *attribute)
{ {
sdlExtraAttributePtr *attr = (sdlExtraAttributePtr*)attribute; sdlExtraAttributePtr *attr = (sdlExtraAttributePtr*)attribute;
sdlExtraAttributePtr new_attr; sdlExtraAttributePtr new_attr;
@ -2040,11 +2040,12 @@ static void schema_attribute_fixup(sdlCtx *ctx, sdlAttributePtr attr)
} }
} }
if (attr->name == NULL && attr->ref != NULL) { if (attr->name == NULL && attr->ref != NULL) {
char *name, *ns; char *name = strrchr(attr->ref, ':');
parse_namespace(attr->ref, &name, &ns); if (*name) {
attr->name = sdl_strdup(name); attr->name = sdl_strdup(name+1);
if (name) {efree(name);} } else{
if (ns) {efree(ns);} attr->name = sdl_strdup(attr->ref);
}
} }
efree(attr->ref); efree(attr->ref);
attr->ref = NULL; attr->ref = NULL;

View File

@ -72,7 +72,7 @@ static sdlTypePtr get_element(sdlPtr sdl, xmlNodePtr node, const char *type)
} }
} }
if (cptype) {efree(cptype);} efree(cptype);
if (ns) {efree(ns);} if (ns) {efree(ns);}
} }
return ret; return ret;
@ -303,12 +303,16 @@ static void wsdl_soap_binding_body(sdlCtx* ctx, xmlNodePtr node, char* wsdl_soap
if (!tmp) { if (!tmp) {
php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Missing message attribute for <header>"); php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Missing message attribute for <header>");
} }
parse_namespace(tmp->children->content, &ctype, &ns);
ctype = strrchr(tmp->children->content,':');
if (ctype == NULL) {
ctype = tmp->children->content;
} else {
++ctype;
}
if (zend_hash_find(&ctx->messages, ctype, strlen(ctype)+1, (void**)&message) != SUCCESS) { if (zend_hash_find(&ctx->messages, ctype, strlen(ctype)+1, (void**)&message) != SUCCESS) {
php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Missing <message> with name '%s'", tmp->children->content); php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Missing <message> with name '%s'", tmp->children->content);
} }
if (ctype) {efree(ctype);}
if (ns) {efree(ns);}
tmp = get_attribute(header->properties, "part"); tmp = get_attribute(header->properties, "part");
if (!tmp) { if (!tmp) {
@ -387,13 +391,16 @@ static HashTable* wsdl_message(sdlCtx *ctx, char* message_name)
HashTable* parameters = NULL; HashTable* parameters = NULL;
char *ns, *ctype; char *ns, *ctype;
parse_namespace(message_name, &ctype, &ns); ctype = strrchr(message_name,':');
if (ctype == NULL) {
ctype = message_name;
} else {
++ctype;
}
if (zend_hash_find(&ctx->messages, ctype, strlen(ctype)+1, (void**)&tmp) != SUCCESS) { if (zend_hash_find(&ctx->messages, ctype, strlen(ctype)+1, (void**)&tmp) != SUCCESS) {
php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Missing <message> with name '%s'", message->children->content); php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Missing <message> with name '%s'", message->children->content);
} }
message = *tmp; message = *tmp;
if (ctype) {efree(ctype);}
if (ns) {efree(ns);}
parameters = sdl_malloc(sizeof(HashTable)); parameters = sdl_malloc(sizeof(HashTable));
zend_hash_init(parameters, 0, NULL, delete_paramater, SDL_PERSISTENT); zend_hash_init(parameters, 0, NULL, delete_paramater, SDL_PERSISTENT);
@ -514,15 +521,17 @@ static sdlPtr load_wsdl(char *struri)
php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Unknown binding type"); php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Unknown binding type");
} }
parse_namespace(bindingAttr->children->content, &ctype, &ns); ctype = strrchr(bindingAttr->children->content,':');
if (ctype == NULL) {
ctype = bindingAttr->children->content;
} else {
++ctype;
}
if (zend_hash_find(&ctx.bindings, ctype, strlen(ctype)+1, (void*)&tmp) != SUCCESS) { if (zend_hash_find(&ctx.bindings, ctype, strlen(ctype)+1, (void*)&tmp) != SUCCESS) {
php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No <binding> element with name '%s'", ctype); php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No <binding> element with name '%s'", ctype);
} }
binding = *tmp; binding = *tmp;
if (ns) {efree(ns);}
if (ctype) {efree(ctype);}
if (tmpbinding->bindingType == BINDING_SOAP) { if (tmpbinding->bindingType == BINDING_SOAP) {
sdlSoapBindingPtr soapBinding; sdlSoapBindingPtr soapBinding;
xmlNodePtr soapBindingNode; xmlNodePtr soapBindingNode;
@ -560,16 +569,18 @@ static sdlPtr load_wsdl(char *struri)
if (type == NULL) { if (type == NULL) {
php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Missing 'type' attribute for <binding>"); php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Missing 'type' attribute for <binding>");
} }
parse_namespace(type->children->content, &ctype, &ns);
ctype = strrchr(type->children->content,':');
if (ctype == NULL) {
ctype = type->children->content;
} else {
++ctype;
}
if (zend_hash_find(&ctx.portTypes, ctype, strlen(ctype)+1, (void**)&tmp) != SUCCESS) { if (zend_hash_find(&ctx.portTypes, ctype, strlen(ctype)+1, (void**)&tmp) != SUCCESS) {
php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Missing <portType> with name '%s'", name->children->content); php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Missing <portType> with name '%s'", name->children->content);
} }
portType = *tmp; portType = *tmp;
if (ctype) {efree(ctype);}
if (ns) {efree(ns);}
trav2 = binding->children; trav2 = binding->children;
FOREACHNODE(trav2, "operation", operation) { FOREACHNODE(trav2, "operation", operation) {
sdlFunctionPtr function; sdlFunctionPtr function;
@ -669,8 +680,10 @@ static sdlPtr load_wsdl(char *struri)
} else if (input == NULL) { } else if (input == NULL) {
function->responseName = sdl_strdup(function->functionName); function->responseName = sdl_strdup(function->functionName);
} else { } else {
function->responseName = sdl_malloc(strlen(function->functionName) + sizeof("Response")); int len = strlen(function->functionName);
sprintf(function->responseName, "%sResponse", function->functionName); function->responseName = sdl_malloc(len + sizeof("Response"));
memcpy(function->responseName, function->functionName, len);
memcpy(function->responseName+len, "Response", sizeof("Response"));
} }
if (tmpbinding->bindingType == BINDING_SOAP) { if (tmpbinding->bindingType == BINDING_SOAP) {

View File

@ -46,7 +46,6 @@ static void cleanup_xml_node(xmlNodePtr node)
trav = node->children; trav = node->children;
while (trav != NULL) { while (trav != NULL) {
if (del != NULL) { if (del != NULL) {
fprintf(stderr,"***garbage\n");
xmlUnlinkNode(del); xmlUnlinkNode(del);
xmlFreeNode(del); xmlFreeNode(del);
del = NULL; del = NULL;

View File

@ -1271,7 +1271,8 @@ PHP_METHOD(soapserver, handle)
response_name = estrdup(function->responseName); response_name = estrdup(function->responseName);
} else { } else {
response_name = emalloc(Z_STRLEN(function_name) + sizeof("Response")); response_name = emalloc(Z_STRLEN(function_name) + sizeof("Response"));
sprintf(response_name,"%sResponse",Z_STRVAL(function_name)); memcpy(response_name,Z_STRVAL(function_name),Z_STRLEN(function_name));
memcpy(response_name+Z_STRLEN(function_name),"Response",sizeof("Response"));
} }
SOAP_GLOBAL(overrides) = service->mapping; SOAP_GLOBAL(overrides) = service->mapping;
doc_return = seralize_response_call(function, response_name, service->uri, &retval, soap_headers, soap_version TSRMLS_CC); doc_return = seralize_response_call(function, response_name, service->uri, &retval, soap_headers, soap_version TSRMLS_CC);
@ -1494,7 +1495,7 @@ PHP_METHOD(soapclient, soapclient)
php_error(E_ERROR, "Can't create SoapClient. 'location' option is requred in nonWSDL mode."); php_error(E_ERROR, "Can't create SoapClient. 'location' option is requred in nonWSDL mode.");
return; return;
} }
if (zend_hash_find(ht, "uri", sizeof("uri"), (void**)&tmp) == SUCCESS && if (zend_hash_find(ht, "uri", sizeof("uri"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_STRING) { Z_TYPE_PP(tmp) == IS_STRING) {
add_property_stringl(this_ptr, "uri", Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1); add_property_stringl(this_ptr, "uri", Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
@ -1502,15 +1503,15 @@ PHP_METHOD(soapclient, soapclient)
php_error(E_ERROR, "Can't create SoapClient. 'uri' option is requred in nonWSDL mode."); php_error(E_ERROR, "Can't create SoapClient. 'uri' option is requred in nonWSDL mode.");
return; return;
} }
if (zend_hash_find(ht, "style", sizeof("style"), (void**)&tmp) == SUCCESS && if (zend_hash_find(ht, "style", sizeof("style"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_LONG && Z_TYPE_PP(tmp) == IS_LONG &&
(Z_LVAL_PP(tmp) == SOAP_RPC || Z_LVAL_PP(tmp) == SOAP_DOCUMENT)) { (Z_LVAL_PP(tmp) == SOAP_RPC || Z_LVAL_PP(tmp) == SOAP_DOCUMENT)) {
add_property_long(this_ptr, "style", Z_LVAL_PP(tmp)); add_property_long(this_ptr, "style", Z_LVAL_PP(tmp));
} }
if (zend_hash_find(ht, "use", sizeof("use"), (void**)&tmp) == SUCCESS && if (zend_hash_find(ht, "use", sizeof("use"), (void**)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_LONG && Z_TYPE_PP(tmp) == IS_LONG &&
(Z_LVAL_PP(tmp) == SOAP_LITERAL || Z_LVAL_PP(tmp) == SOAP_ENCODED)) { (Z_LVAL_PP(tmp) == SOAP_LITERAL || Z_LVAL_PP(tmp) == SOAP_ENCODED)) {
add_property_long(this_ptr, "use", Z_LVAL_PP(tmp)); add_property_long(this_ptr, "use", Z_LVAL_PP(tmp));
} }
@ -1547,7 +1548,7 @@ PHP_METHOD(soapclient, soapclient)
} }
} }
if (zend_hash_find(ht, "trace", sizeof("trace"), (void**)&tmp) == SUCCESS && if (zend_hash_find(ht, "trace", sizeof("trace"), (void**)&tmp) == SUCCESS &&
(Z_TYPE_PP(tmp) == IS_BOOL || Z_TYPE_PP(tmp) == IS_LONG) && (Z_TYPE_PP(tmp) == IS_BOOL || Z_TYPE_PP(tmp) == IS_LONG) &&
Z_LVAL_PP(tmp) == 1) { Z_LVAL_PP(tmp) == 1) {
add_property_long(this_ptr, "trace", 1); add_property_long(this_ptr, "trace", 1);
} }
@ -1739,7 +1740,7 @@ PHP_METHOD(soapclient, __call)
} }
if (options) { if (options) {
if (Z_TYPE_P(options) == IS_ARRAY) { if (Z_TYPE_P(options) == IS_ARRAY) {
HashTable *ht = Z_ARRVAL_P(options); HashTable *ht = Z_ARRVAL_P(options);
zval **tmp; zval **tmp;
@ -1752,7 +1753,7 @@ PHP_METHOD(soapclient, __call)
Z_TYPE_PP(tmp) == IS_STRING) { Z_TYPE_PP(tmp) == IS_STRING) {
soap_action = Z_STRVAL_PP(tmp); soap_action = Z_STRVAL_PP(tmp);
} }
} else if (Z_TYPE_P(options) != IS_NULL) { } else if (Z_TYPE_P(options) != IS_NULL) {
php_error(E_ERROR, "Invalid arguments to SoapClient->__call"); php_error(E_ERROR, "Invalid arguments to SoapClient->__call");
} }
} }