]> granicus.if.org Git - php/commitdiff
optimization
authorDmitry Stogov <dmitry@php.net>
Fri, 6 Feb 2004 16:52:14 +0000 (16:52 +0000)
committerDmitry Stogov <dmitry@php.net>
Fri, 6 Feb 2004 16:52:14 +0000 (16:52 +0000)
ext/soap/php_schema.c
ext/soap/php_sdl.c
ext/soap/php_xml.c
ext/soap/soap.c

index dbe229733d301113095f7dfc1440c857cb54f192..9c219da0c69cf2e5e0c5af257fd6b515714185dd 100644 (file)
@@ -1990,7 +1990,7 @@ static int schema_attributeGroup(sdlPtr sdl, xmlAttrPtr tsn, xmlNodePtr attrGrou
        return TRUE;
 }
 
-static void copy_extra_attribute(void *attribute) 
+static void copy_extra_attribute(void *attribute)
 {
        sdlExtraAttributePtr *attr = (sdlExtraAttributePtr*)attribute;
        sdlExtraAttributePtr new_attr;
@@ -2040,11 +2040,12 @@ static void schema_attribute_fixup(sdlCtx *ctx, sdlAttributePtr attr)
                        }
                }
                if (attr->name == NULL && attr->ref != NULL) {
-                       char *name, *ns;
-                       parse_namespace(attr->ref, &name, &ns);
-                       attr->name = sdl_strdup(name);
-                       if (name) {efree(name);}
-                       if (ns) {efree(ns);}
+                       char *name = strrchr(attr->ref, ':');
+                       if (*name) {
+                               attr->name = sdl_strdup(name+1);
+                       } else{
+                               attr->name = sdl_strdup(attr->ref);
+                       }
                }
                efree(attr->ref);
                attr->ref = NULL;
index 88785da83be23a836f477485252523692cb810fb..a7636dd622924d7127d445b2166f1a0ad53f3ea7 100644 (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);}
        }
        return ret;
@@ -303,12 +303,16 @@ static void wsdl_soap_binding_body(sdlCtx* ctx, xmlNodePtr node, char* wsdl_soap
                if (!tmp) {
                        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) {
                        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");
                if (!tmp) {
@@ -387,13 +391,16 @@ static HashTable* wsdl_message(sdlCtx *ctx, char* message_name)
        HashTable* parameters = NULL;
        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) {
                php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Missing <message> with name '%s'", message->children->content);
        }
        message = *tmp;
-       if (ctype) {efree(ctype);}
-       if (ns) {efree(ns);}
 
        parameters = sdl_malloc(sizeof(HashTable));
        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");
                                }
 
-                               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) {
                                        php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No <binding> element with name '%s'", ctype);
                                }
                                binding = *tmp;
 
-                               if (ns) {efree(ns);}
-                               if (ctype) {efree(ctype);}
-
                                if (tmpbinding->bindingType == BINDING_SOAP) {
                                        sdlSoapBindingPtr soapBinding;
                                        xmlNodePtr soapBindingNode;
@@ -560,16 +569,18 @@ static sdlPtr load_wsdl(char *struri)
                                if (type == NULL) {
                                        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) {
                                        php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Missing <portType> with name '%s'", name->children->content);
                                }
                                portType = *tmp;
 
-                               if (ctype) {efree(ctype);}
-                               if (ns) {efree(ns);}
-
                                trav2 = binding->children;
                                FOREACHNODE(trav2, "operation", operation) {
                                        sdlFunctionPtr function;
@@ -669,8 +680,10 @@ static sdlPtr load_wsdl(char *struri)
                                                } else if (input == NULL) {
                                                        function->responseName = sdl_strdup(function->functionName);
                                                } else {
-                                                       function->responseName = sdl_malloc(strlen(function->functionName) + sizeof("Response"));
-                                                       sprintf(function->responseName, "%sResponse", function->functionName);
+                                                       int len = strlen(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) {
index 6fc82ec44e5854f270a387ce129033b289bf5443..c3ae5ffb815c2d9c28961df04fa86785c5afbe12 100644 (file)
@@ -46,7 +46,6 @@ static void cleanup_xml_node(xmlNodePtr node)
        trav = node->children;
        while (trav != NULL) {
                if (del != NULL) {
-fprintf(stderr,"***garbage\n");
                        xmlUnlinkNode(del);
                        xmlFreeNode(del);
                        del = NULL;
index b57d2df9a2334de3a6ac4cc302d5e92907663fa0..0febecad4d32a0ea403990c69ae09776c5d846f8 100644 (file)
@@ -1271,7 +1271,8 @@ PHP_METHOD(soapserver, handle)
                                response_name = estrdup(function->responseName);
                        } else {
                                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;
                        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.");
                                return;
                        }
-                       
+
                        if (zend_hash_find(ht, "uri", sizeof("uri"), (void**)&tmp) == SUCCESS &&
                            Z_TYPE_PP(tmp) == IS_STRING) {
                                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.");
                                return;
                        }
-                       
+
                        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)) {
                                add_property_long(this_ptr, "style", Z_LVAL_PP(tmp));
                        }
 
                        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)) {
                                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 &&
-                   (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) {
                        add_property_long(this_ptr, "trace", 1);
                }
@@ -1739,7 +1740,7 @@ PHP_METHOD(soapclient, __call)
        }
 
        if (options) {
-               if (Z_TYPE_P(options) == IS_ARRAY) {            
+               if (Z_TYPE_P(options) == IS_ARRAY) {
                        HashTable *ht = Z_ARRVAL_P(options);
                        zval **tmp;
 
@@ -1752,7 +1753,7 @@ PHP_METHOD(soapclient, __call)
                            Z_TYPE_PP(tmp) == IS_STRING) {
                                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");
                }
        }