diff options
author | Dmitry Stogov <dmitry@php.net> | 2004-01-09 18:22:03 +0000 |
---|---|---|
committer | Dmitry Stogov <dmitry@php.net> | 2004-01-09 18:22:03 +0000 |
commit | 9a3cdc6491872bd1fe7eba2005df06748bc12a32 (patch) | |
tree | b0192e50f3d2a17b26fd95aee0d217f297d232c7 /ext/soap/php_sdl.c | |
parent | e3baf1a07da972a81f46582b02a8c9a85cb1e16d (diff) | |
download | php-git-9a3cdc6491872bd1fe7eba2005df06748bc12a32.tar.gz |
Source cleanup.
Diffstat (limited to 'ext/soap/php_sdl.c')
-rw-r--r-- | ext/soap/php_sdl.c | 494 |
1 files changed, 238 insertions, 256 deletions
diff --git a/ext/soap/php_sdl.c b/ext/soap/php_sdl.c index fca6581685..d7ac2d8562 100644 --- a/ext/soap/php_sdl.c +++ b/ext/soap/php_sdl.c @@ -6,11 +6,12 @@ encodePtr get_encoder_from_prefix(sdlPtr sdl, xmlNodePtr data, const char *type) TSRMLS_FETCH(); enc = get_conversion_from_type(data, type); - if(enc == NULL && sdl) + if (enc == NULL && sdl) { enc = get_conversion_from_type_ex(sdl->encoders, data, type); - if(enc == NULL) + } + if (enc == NULL) { enc = get_conversion(UNKNOWN_TYPE); - + } return enc; } @@ -35,10 +36,12 @@ encodePtr get_encoder_ex(sdlPtr sdl, const char *nscat) TSRMLS_FETCH(); enc = get_conversion_from_href_type(nscat); - if(enc == NULL && sdl) + if (enc == NULL && sdl) { enc = get_conversion_from_href_type_ex(sdl->encoders, nscat, strlen(nscat)); - if(enc == NULL) + } + if (enc == NULL) { enc = get_conversion(UNKNOWN_TYPE); + } return enc; } @@ -54,10 +57,12 @@ encodePtr get_create_encoder(sdlPtr sdl, sdlTypePtr cur_type, const char *ns, co smart_str_0(&nscat); enc = get_conversion_from_href_type(nscat.c); - if(enc == NULL) + if (enc == NULL) { enc = get_conversion_from_href_type_ex(sdl->encoders, nscat.c, nscat.len); - if(enc == NULL) + } + if (enc == NULL) { enc = create_encoder(sdl, cur_type, ns, type); + } smart_str_free(&nscat); return enc; @@ -82,8 +87,7 @@ encodePtr create_encoder(sdlPtr sdl, sdlTypePtr cur_type, const char *ns, const enc->to_xml = sdl_guess_convert_xml; enc->to_zval = sdl_guess_convert_zval; - if(sdl->encoders == NULL) - { + if (sdl->encoders == NULL) { sdl->encoders = malloc(sizeof(HashTable)); zend_hash_init(sdl->encoders, 0, NULL, delete_encoder, 1); } @@ -97,8 +101,8 @@ zval *sdl_guess_convert_zval(encodeType enc, xmlNodePtr data) sdlTypePtr type; type = enc.sdl_type; - if(type->encode) { - if(type->encode->details.type == IS_ARRAY || + if (type->encode) { + if (type->encode->details.type == IS_ARRAY || type->encode->details.type == SOAP_ENC_ARRAY) { return to_zval_array(enc, data); } else if (type->encode->details.type == IS_OBJECT || @@ -128,15 +132,15 @@ xmlNodePtr sdl_guess_convert_xml(encodeType enc, zval *data, int style) if (type->restrictions) { if (type->restrictions->enumeration) { - if (Z_TYPE_P(data) == IS_STRING) { - if (!zend_hash_exists(type->restrictions->enumeration,Z_STRVAL_P(data),Z_STRLEN_P(data)+1)) { - php_error(E_WARNING,"Restriction: invalid enumeration value \"%s\".",Z_STRVAL_P(data)); - } - } + if (Z_TYPE_P(data) == IS_STRING) { + if (!zend_hash_exists(type->restrictions->enumeration,Z_STRVAL_P(data),Z_STRLEN_P(data)+1)) { + php_error(E_WARNING,"Restriction: invalid enumeration value \"%s\".",Z_STRVAL_P(data)); + } + } } } - if(type->encode) { + if (type->encode) { if (type->encode->details.type == IS_ARRAY || type->encode->details.type == SOAP_ENC_ARRAY) { ret = sdl_to_xml_array(type, data, style); @@ -152,7 +156,7 @@ xmlNodePtr sdl_guess_convert_xml(encodeType enc, zval *data, int style) } } } - else if(type->elements) { + else if (type->elements) { ret = sdl_to_xml_object(type, data, style); } else { ret = guess_xml_convert(enc, data, style); @@ -176,8 +180,7 @@ zval* sdl_to_zval_object(sdlTypePtr type, xmlNodePtr data) trav = data->children; while (trav != NULL) { - if(trav->type == XML_ELEMENT_NODE) - { + if (trav->type == XML_ELEMENT_NODE) { sdlTypePtr *element; encodePtr enc = NULL; zval *tmpVal; @@ -194,7 +197,7 @@ zval* sdl_to_zval_object(sdlTypePtr type, xmlNodePtr data) #endif add_property_zval(ret, (char *)trav->name, tmpVal); } - trav = trav->next; + trav = trav->next; } } return ret; @@ -210,23 +213,19 @@ xmlNodePtr sdl_to_xml_object(sdlTypePtr type, zval *data, int style) FIND_ZVAL_NULL(data, ret, style); zend_hash_internal_pointer_reset(type->elements); - while(zend_hash_get_current_data(type->elements, (void **)&t) != FAILURE) - { + while (zend_hash_get_current_data(type->elements, (void **)&t) != FAILURE) { zval **prop; tmp = *t; - if(zend_hash_find(Z_OBJPROP_P(data), tmp->name, strlen(tmp->name) + 1, (void **)&prop) == FAILURE) - { - if(tmp->nillable == FALSE) + if (zend_hash_find(Z_OBJPROP_P(data), tmp->name, strlen(tmp->name) + 1, (void **)&prop) == FAILURE) { + if (tmp->nillable == FALSE) php_error(E_ERROR, "Error encoding object to xml missing property \"%s\"", tmp->name); - } - else - { + } else { xmlNodePtr newNode; encodePtr enc; - + if (tmp->encode) { enc = tmp->encode; - } else { + } else { enc = get_conversion((*prop)->type); } newNode = master_to_xml(enc, (*prop), style); @@ -245,7 +244,7 @@ static void add_xml_array_elements(xmlNodePtr xmlParam, int dimension , int* dims, zval* data, - int style) + int style) { int j; @@ -288,20 +287,18 @@ xmlNodePtr sdl_to_xml_array(sdlTypePtr type, zval *data, int style) FIND_ZVAL_NULL(data, xmlParam, style); - if(Z_TYPE_P(data) == IS_ARRAY) - { + if (Z_TYPE_P(data) == IS_ARRAY) { sdlAttributePtr *arrayType; i = zend_hash_num_elements(Z_ARRVAL_P(data)); - if(style == SOAP_ENCODED) - { + if (style == SOAP_ENCODED) { xmlAttrPtr *wsdl; - if(type->attributes && + if (type->attributes && zend_hash_find(type->attributes, SOAP_ENC_NAMESPACE":arrayType", sizeof(SOAP_ENC_NAMESPACE":arrayType"), (void **)&arrayType) == SUCCESS && zend_hash_find((*arrayType)->extraAttributes, WSDL_NAMESPACE":arrayType", sizeof(WSDL_NAMESPACE":arrayType"), (void **)&wsdl) == SUCCESS) { - + char *ns = NULL, *value, *end; xmlNsPtr myNs; zval** el; @@ -311,18 +308,18 @@ xmlNodePtr sdl_to_xml_array(sdlTypePtr type, zval *data, int style) end = strrchr(value,'['); if (end) { - *end = '\0'; - end++; - while (*end != ']' && *end != '\0') { - if (*end == ',') { - dimension++; - } - end++; - } + *end = '\0'; + end++; + while (*end != ']' && *end != '\0') { + if (*end == ',') { + dimension++; + } + end++; + } } - if(myNs != NULL) { + if (myNs != NULL) { enc = get_encoder(SOAP_GLOBAL(sdl), myNs->href, value); - + if (strcmp(myNs->href,XSD_NAMESPACE) == 0) { smart_str_appendl(&array_type_and_size, XSD_NS_PREFIX, sizeof(XSD_NS_PREFIX) - 1); smart_str_appendc(&array_type_and_size, ':'); @@ -371,9 +368,10 @@ xmlNodePtr sdl_to_xml_array(sdlTypePtr type, zval *data, int style) if (ns) efree(ns); } else if (type->elements && zend_hash_num_elements(type->elements) == 1 && - (elementType = *(sdlTypePtr*)type->elements->pListHead->pData) != NULL && - elementType->encode && elementType->encode->details.type_str) { + (elementType = *(sdlTypePtr*)type->elements->pListHead->pData) != NULL && + elementType->encode && elementType->encode->details.type_str) { char* ns = elementType->encode->details.ns; + if (ns) { if (strcmp(ns,XSD_NAMESPACE) == 0) { smart_str_appendl(&array_type_and_size, XSD_NS_PREFIX, sizeof(XSD_NS_PREFIX) - 1); @@ -424,14 +422,12 @@ xmlNodePtr sdl_to_xml_array(sdlTypePtr type, zval *data, int style) } else { dims = emalloc(sizeof(int)*dimension); dims[0] = i; - } + } add_xml_array_elements(xmlParam, type, enc, dimension, dims, data, style); efree(dims); } -// if(style == SOAP_ENCODED) -// set_ns_and_type_ex(xmlParam, type->namens, type->name); return xmlParam; } @@ -442,13 +438,12 @@ sdlPtr get_sdl(char *uri) tmp = NULL; hndl = NULL; - if(zend_hash_find(SOAP_GLOBAL(sdls), uri, strlen(uri), (void **)&hndl) == FAILURE) - { + if (zend_hash_find(SOAP_GLOBAL(sdls), uri, strlen(uri), (void **)&hndl) == FAILURE) { tmp = load_wsdl(uri, NULL); zend_hash_add(SOAP_GLOBAL(sdls), uri, strlen(uri), &tmp, sizeof(sdlPtr), NULL); - } - else + } else { tmp = *hndl; + } return tmp; } @@ -461,12 +456,12 @@ sdlBindingPtr get_binding_from_type(sdlPtr sdl, int type) return NULL; } - for(zend_hash_internal_pointer_reset(sdl->bindings); + for (zend_hash_internal_pointer_reset(sdl->bindings); zend_hash_get_current_data(sdl->bindings, (void **) &binding) == SUCCESS; - zend_hash_move_forward(sdl->bindings)) - { - if((*binding)->bindingType == type) + zend_hash_move_forward(sdl->bindings)) { + if ((*binding)->bindingType == type) { return *binding; + } } return NULL; } @@ -498,10 +493,8 @@ int load_php_sdl() rootElement = SOAP_SERVER_GLOBAL(availableServices)->children; services = rootElement->children; - do - { - if(IS_ELEMENT_TYPE(services,PHP_SOAPSERVER_SERVICE)) - { + do { + if (IS_ELEMENT_TYPE(services,PHP_SOAPSERVER_SERVICE)) { phpSoapServicePtr newService; xmlNodePtr attrib, trav; HashTable *fn = NULL; @@ -521,10 +514,8 @@ int load_php_sdl() attrib = services->properties; trav = attrib; /* Get Attributes of Service */ - do - { - if(IS_ATTRIBUTE_TYPE(trav,PHP_SOAPSERVER_SERVICE_NAME)) - { + do { + if (IS_ATTRIBUTE_TYPE(trav,PHP_SOAPSERVER_SERVICE_NAME)) { char* name = ATTRIBUTE_VALUE(trav); /* Assign Service Vals */ @@ -532,42 +523,36 @@ int load_php_sdl() ZVAL_STRING(newService->serviceName,name,1); } - if(IS_ATTRIBUTE_TYPE(trav,PHP_SOAPSERVER_SERVICE_STARTED)) - { + if (IS_ATTRIBUTE_TYPE(trav,PHP_SOAPSERVER_SERVICE_STARTED)) { char* started = ATTRIBUTE_VALUE(trav); /* Assign Service Vals */ - if(!stricmp(started,"true")) + if (!stricmp(started,"true")) { newService->started = TRUE; + } } - } - while(trav = trav->next); + } while (trav = trav->next); /* Get ChildNodes of Service */ trav = services->children; - do - { + do { /* Include Files */ - if(IS_ELEMENT_TYPE(trav,PHP_SOAPSERVER_SERVICE_INCLUDE_FILE)) - { + if (IS_ELEMENT_TYPE(trav,PHP_SOAPSERVER_SERVICE_INCLUDE_FILE)) { xmlNodePtr trav1 = trav->properties; - do - { - if(IS_ATTRIBUTE_TYPE(trav1,PHP_SOAPSERVER_SERVICE_INCLUDE_FILE_NAME)) - { + do { + if (IS_ATTRIBUTE_TYPE(trav1,PHP_SOAPSERVER_SERVICE_INCLUDE_FILE_NAME)) { char* name = ATTRIBUTE_VALUE(trav1); zval* z_name; + ALLOC_INIT_ZVAL(z_name); ZVAL_STRING(z_name,name,1); zend_hash_next_index_insert(include,&z_name,sizeof(zval),NULL); } - } - while(trav1 = trav1->next); + } while (trav1 = trav1->next); } /* Functions */ - if(IS_ELEMENT_TYPE(trav,PHP_SOAPSERVER_SERVICE_FUNCTION)) - { + if (IS_ELEMENT_TYPE(trav,PHP_SOAPSERVER_SERVICE_FUNCTION)) { phpSoapServiceFunctionPtr function; xmlNodePtr trav1; HashTable *par = NULL; @@ -580,22 +565,18 @@ int load_php_sdl() trav1 = trav->properties; - do - { - if(IS_ATTRIBUTE_TYPE(trav1,PHP_SOAPSERVER_SERVICE_FUNCTION_NAME)) - { + do { + if (IS_ATTRIBUTE_TYPE(trav1,PHP_SOAPSERVER_SERVICE_FUNCTION_NAME)) { char* name = ATTRIBUTE_VALUE(trav1); + ALLOC_INIT_ZVAL(function->functionName); ZVAL_STRING(function->functionName,name,1); } - } - while(trav1 = trav1->next); + } while (trav1 = trav1->next); trav1 = trav->children; - do - { - if(IS_ELEMENT_TYPE(trav1,PHP_SOAPSERVER_SERVICE_FUNCTION_PARAM)) - { + do { + if (IS_ELEMENT_TYPE(trav1,PHP_SOAPSERVER_SERVICE_FUNCTION_PARAM)) { phpSoapServiceParamPtr param; xmlNodePtr trav2; @@ -604,55 +585,45 @@ int load_php_sdl() trav2 = trav1->properties; - do - { - if(IS_ATTRIBUTE_TYPE(trav2,PHP_SOAPSERVER_SERVICE_FUNCTION_PARAM_NAME)) - { + do { + if (IS_ATTRIBUTE_TYPE(trav2,PHP_SOAPSERVER_SERVICE_FUNCTION_PARAM_NAME)) { char* name = ATTRIBUTE_VALUE(trav2); + ALLOC_INIT_ZVAL(param->paramName); ZVAL_STRING(param->paramName,name,1); - } - else if(IS_ATTRIBUTE_TYPE(trav2,PHP_SOAPSERVER_SERVICE_FUNCTION_PARAM_TYPE)) - { + } else if (IS_ATTRIBUTE_TYPE(trav2,PHP_SOAPSERVER_SERVICE_FUNCTION_PARAM_TYPE)) { char* type = ATTRIBUTE_VALUE(trav2); ALLOC_INIT_ZVAL(param->paramType); ZVAL_STRING(param->paramType,type,1); - } - else if(IS_ATTRIBUTE_TYPE(trav2,PHP_SOAPSERVER_SERVICE_FUNCTION_PARAM_POSITION)) - { + } else if (IS_ATTRIBUTE_TYPE(trav2,PHP_SOAPSERVER_SERVICE_FUNCTION_PARAM_POSITION)) { char* val = ATTRIBUTE_VALUE(trav2); ALLOC_INIT_ZVAL(param->paramName); ZVAL_LONG(param->paramName,atoi(val)); } - } - while(trav2 = trav2->next); + } while (trav2 = trav2->next); zend_hash_add(par,Z_STRVAL_P(param->paramName),Z_STRLEN_P(param->paramName),param,sizeof(phpSoapServiceParam),NULL); } - } - while(trav1 = trav1->next); + } while (trav1 = trav1->next); zend_hash_add(fn,Z_STRVAL_P(function->functionName),Z_STRLEN_P(function->functionName),function,sizeof(phpSoapServiceFunction),NULL); } /* Classes */ - if(IS_ELEMENT_TYPE(trav,PHP_SOAPSERVER_SERVICE_CLASS)) - { + if (IS_ELEMENT_TYPE(trav,PHP_SOAPSERVER_SERVICE_CLASS)) { xmlNodePtr att, func; att = trav->properties; - if(fn == NULL) - { + if (fn == NULL) { fn = newService->functions = emalloc(sizeof(HashTable)); zend_hash_init(fn, 0, NULL, ZVAL_PTR_DTOR, 0); } } - }while(trav = trav->next); + } while (trav = trav->next); zend_hash_add(SOAP_SERVER_GLOBAL(services),Z_STRVAL_P(newService->serviceName),Z_STRLEN_P(newService->serviceName),newService,sizeof(phpSoapService),NULL); } - } - while(services = services->next); + } while (services = services->next); #endif return TRUE; } @@ -671,66 +642,65 @@ sdlPtr load_wsdl(char *struri, sdlPtr parent) sdlPtr tmpsdl; TSRMLS_FETCH(); - if(!parent) - { + if (!parent) { tmpsdl = malloc(sizeof(sdl)); memset(tmpsdl, 0, sizeof(sdl)); tmpsdl->source = strdup(struri); - } - else + } else { tmpsdl = parent; + } /* TODO: WSDL Caching */ wsdl = xmlParseFile(struri); xmlCleanupParser(); - if(!wsdl) + if (!wsdl) { php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Couldn't load from %s", struri); + } tmpsdl->doc = wsdl; root = wsdl->children; definitions = get_node(root, "definitions"); - if(!definitions) + if (!definitions) { php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Couldn't find definitions in %s", struri); + } targetNamespace = get_attribute(definitions->properties, "targetNamespace"); - if(targetNamespace) + if (targetNamespace) { tmpsdl->target_ns = strdup(targetNamespace->children->content); + } types = get_node(definitions->children, "types"); - if(types) - { + if (types) { trav = types->children; - FOREACHNODE(trav, "schema", schema) - { + FOREACHNODE(trav, "schema", schema) { load_schema(&tmpsdl, schema); } ENDFOREACH(trav); } trav = definitions->children; - FOREACHNODE(trav, "import", import) - { + FOREACHNODE(trav, "import", import) { xmlAttrPtr tmp = get_attribute(import->properties, "location"); - if(tmp) + if (tmp) { load_wsdl(tmp->children->content, tmpsdl); + } } ENDFOREACH(trav); service = get_node(definitions->children, "service"); - if(service != NULL) - { + if (service != NULL) { xmlAttrPtr name; xmlNodePtr trav, port; name = get_attribute(service->properties, "name"); - if(!name) + if (!name) { php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No name associated with service"); + } trav = service->children; - FOREACHNODE(trav, "port", port) - { + FOREACHNODE(trav, "port", port) { xmlAttrPtr type, name, bindingAttr, location; xmlNodePtr portType, operation; xmlNodePtr address; @@ -741,39 +711,45 @@ sdlPtr load_wsdl(char *struri, sdlPtr parent) memset(tmpbinding, 0, sizeof(sdlBinding)); name = get_attribute(port->properties, "name"); - if(!name) + if (!name) { php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No name associated with port"); + } bindingAttr = get_attribute(port->properties, "binding"); - if(bindingAttr == NULL) + if (bindingAttr == NULL) { php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No binding associated with port"); + } /* find address and figure out binding type */ address = get_node(port->children, "address"); - if(!address) + if (!address) { php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No address associated with port"); + } location = get_attribute(address->properties, "location"); - if(!location) + if (!location) { php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No location associated with port"); + } tmpbinding->location = strdup(location->children->content); - if(address->ns && !strcmp(address->ns->href, WSDL_SOAP_NAMESPACE)) + if (address->ns && !strcmp(address->ns->href, WSDL_SOAP_NAMESPACE)) { tmpbinding->bindingType = BINDING_SOAP; - else if(address->ns && !strcmp(address->ns->href, WSDL_HTTP_NAMESPACE)) + } else if (address->ns && !strcmp(address->ns->href, WSDL_HTTP_NAMESPACE)) { tmpbinding->bindingType = BINDING_HTTP; + } parse_namespace(bindingAttr->children->content, &ctype, &ns); binding = get_node_with_attribute(definitions->children, "binding", "name", ctype); - if(!binding) + if (!binding) { php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No binding element with name \"%s\"", ctype); + } - if(ns) efree(ns); if(ctype) efree(ctype); + if (ns) {efree(ns);} + if (ctype) {efree(ctype);} - if(tmpbinding->bindingType == BINDING_SOAP) - { + if (tmpbinding->bindingType == BINDING_SOAP) { sdlSoapBindingPtr soapBinding; xmlNodePtr soapBindingNode; xmlAttrPtr tmp; @@ -782,20 +758,19 @@ sdlPtr load_wsdl(char *struri, sdlPtr parent) memset(soapBinding, 0, sizeof(sdlSoapBinding)); soapBindingNode = get_node_ex(binding->children, "binding", WSDL_SOAP_NAMESPACE); - if(soapBindingNode) - { + if (soapBindingNode) { tmp = get_attribute(soapBindingNode->properties, "style"); - if(tmp && !strcmp(tmp->children->content, "document")) + if (tmp && !strcmp(tmp->children->content, "document")) { soapBinding->style = SOAP_DOCUMENT; - else + } else { soapBinding->style = SOAP_RPC; + } tmp = get_attribute(soapBindingNode->properties, "transport"); - if(tmp) - { - if(strcmp(tmp->children->content, WSDL_HTTP_TRANSPORT)) + if (tmp) { + if (strcmp(tmp->children->content, WSDL_HTTP_TRANSPORT)) { php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: PHP-SOAP doesn't support transport '%s'", tmp->children->content); - + } soapBinding->transport = strdup(tmp->children->content); } tmpbinding->bindingAttributes = (void *)soapBinding; @@ -803,35 +778,39 @@ sdlPtr load_wsdl(char *struri, sdlPtr parent) } name = get_attribute(binding->properties, "name"); - if(name == NULL) + if (name == NULL) { php_error(E_ERROR, "Error parsing wsdl (Missing \"name\" attribute for \"binding\")"); + } tmpbinding->name = strdup(name->children->content); type = get_attribute(binding->properties, "type"); - if(type == NULL) + if (type == NULL) { php_error(E_ERROR, "Error parsing wsdl (Missing \"type\" attribute for \"binding\")"); - + } parse_namespace(type->children->content, &ctype, &ns); portType = get_node_with_attribute(definitions->children, "portType", "name", ctype); - if(portType == NULL) + if (portType == NULL) { php_error(E_ERROR, "Error parsing wsdl (Missing \"portType\" with name \"%s\")", name->children->content); - if(ctype) efree(ctype); if(ns) efree(ns); + } + if (ctype) {efree(ctype);} + if (ns) {efree(ns);} trav2 = binding->children; - FOREACHNODE(trav2, "operation", operation) - { + FOREACHNODE(trav2, "operation", operation) { sdlFunctionPtr function; xmlNodePtr input, output, fault, portTypeOperation, portTypeInput, msgInput, msgOutput; xmlAttrPtr op_name, paramOrder; op_name = get_attribute(operation->properties, "name"); - if(op_name == NULL) + if (op_name == NULL) { php_error(E_ERROR, "Error parsing wsdl (Missing \"name\" attribute for \"operation\")"); + } portTypeOperation = get_node_with_attribute(portType->children, "operation", "name", op_name->children->content); - if(portTypeOperation == NULL) + if (portTypeOperation == NULL) { php_error(E_ERROR, "Error parsing wsdl (Missing \"portType/operation\" with name \"%s\")", op_name->children->content); + } function = malloc(sizeof(sdlFunction)); function->functionName = strdup(op_name->children->content); @@ -841,8 +820,7 @@ sdlPtr load_wsdl(char *struri, sdlPtr parent) function->bindingAttributes = NULL; function->bindingType = tmpbinding->bindingType; - if(tmpbinding->bindingType == BINDING_SOAP) - { + if (tmpbinding->bindingType == BINDING_SOAP) { sdlSoapBindingFunctionPtr soapFunctionBinding; sdlSoapBindingPtr soapBinding; xmlNodePtr soapOperation; @@ -854,33 +832,34 @@ sdlPtr load_wsdl(char *struri, sdlPtr parent) soapFunctionBinding->style = soapBinding->style; soapOperation = get_node_ex(operation->children, "operation", WSDL_SOAP_NAMESPACE); - if(soapOperation) - { + if (soapOperation) { tmp = get_attribute(soapOperation->properties, "soapAction"); - if(tmp) + if (tmp) { soapFunctionBinding->soapAction = strdup(tmp->children->content); + } tmp = get_attribute(soapOperation->properties, "style"); - if(tmp && !strcmp(tmp->children->content, "rpc")) + if (tmp && !strcmp(tmp->children->content, "rpc")) { soapFunctionBinding->style = SOAP_RPC; - else if(!soapBinding->style) + } else if (!soapBinding->style) { soapFunctionBinding->style = SOAP_DOCUMENT; + } } function->bindingAttributes = (void *)soapFunctionBinding; } input = get_node(operation->children, "input"); - if(input != NULL) - { + if (input != NULL) { xmlAttrPtr message; xmlNodePtr part; char *ns, *ctype; portTypeInput = get_node(portTypeOperation->children, "input"); message = get_attribute(portTypeInput->properties, "message"); - if(message == NULL) + if (message == NULL) { php_error(E_ERROR, "Error parsing wsdl (Missing name for \"input\" of \"%s\")", op_name->children->content); + } function->requestName = strdup(function->functionName); function->requestParameters = malloc(sizeof(HashTable)); @@ -888,42 +867,45 @@ sdlPtr load_wsdl(char *struri, sdlPtr parent) parse_namespace(message->children->content, &ctype, &ns); msgInput = get_node_with_attribute(definitions->children, "message", "name", ctype); - if(msgInput == NULL) + if (msgInput == NULL) { php_error(E_ERROR, "Error parsing wsdl (Missing \"message\" with name \"%s\")", message->children->content); - if(ctype) efree(ctype); if(ns) efree(ns); + } + if (ctype) {efree(ctype);} + if (ns) {efree(ns);} - if(tmpbinding->bindingType == BINDING_SOAP) - { + if (tmpbinding->bindingType == BINDING_SOAP) { sdlSoapBindingFunctionPtr soapFunctionBinding = function->bindingAttributes; xmlNodePtr body; xmlAttrPtr tmp; body = get_node_ex(input->children, "body", WSDL_SOAP_NAMESPACE); - if(body) - { + if (body) { tmp = get_attribute(body->properties, "use"); - if(tmp && !strcmp(tmp->children->content, "literal")) + if (tmp && !strcmp(tmp->children->content, "literal")) { soapFunctionBinding->input.use = SOAP_LITERAL; - else + } else { soapFunctionBinding->input.use = SOAP_ENCODED; + } tmp = get_attribute(body->properties, "namespace"); - if(tmp) + if (tmp) { soapFunctionBinding->input.ns = strdup(tmp->children->content); + } tmp = get_attribute(body->properties, "parts"); - if(tmp) + if (tmp) { soapFunctionBinding->input.parts = strdup(tmp->children->content); + } tmp = get_attribute(body->properties, "encodingStyle"); - if(tmp) + if (tmp) { soapFunctionBinding->input.encodingStyle = strdup(tmp->children->content); + } } } trav3 = msgInput->children; - FOREACHNODE(trav3, "part", part) - { + FOREACHNODE(trav3, "part", part) { xmlAttrPtr element, type, name; sdlParamPtr param; @@ -931,18 +913,21 @@ sdlPtr load_wsdl(char *struri, sdlPtr parent) param->order = 0; name = get_attribute(part->properties, "name"); - if(name == NULL) + if (name == NULL) { php_error(E_ERROR, "Error parsing wsdl (No name associated with part \"%s\")", msgInput->name); + } param->paramName = strdup(name->children->content); element = get_attribute(part->properties, "element"); - if(element != NULL) + if (element != NULL) { param->encode = get_encoder_from_prefix(tmpsdl, part, element->children->content); + } type = get_attribute(part->properties, "type"); - if(type != NULL) + if (type != NULL) { param->encode = get_encoder_from_prefix(tmpsdl, part, type->children->content); + } zend_hash_next_index_insert(function->requestParameters, ¶m, sizeof(sdlParamPtr), NULL); } @@ -950,66 +935,67 @@ sdlPtr load_wsdl(char *struri, sdlPtr parent) } paramOrder = get_attribute(portTypeOperation->properties, "parameterOrder"); - if(paramOrder) - { + if (paramOrder) { } output = get_node(portTypeOperation->children, "output"); - if(output != NULL) - { + if (output != NULL) { xmlAttrPtr message; xmlNodePtr part; char *ns, *ctype; - function->responseName = malloc(strlen(function->functionName) + strlen("Response") + 1); sprintf(function->responseName, "%sResponse", function->functionName); function->responseParameters = malloc(sizeof(HashTable)); zend_hash_init(function->responseParameters, 0, NULL, delete_paramater, 1); message = get_attribute(output->properties, "message"); - if(message == NULL) + if (message == NULL) { php_error(E_ERROR, "Error parsing wsdl (Missing name for \"output\" of \"%s\")", op_name->children->content); + } parse_namespace(message->children->content, &ctype, &ns); msgOutput = get_node_with_attribute(definitions->children, "message", "name", ctype); - if(msgOutput == NULL) + if (msgOutput == NULL) { php_error(E_ERROR, "Error parsing wsdl (Missing \"message\" with name \"%s\")", message->children->content); - if(ctype) efree(ctype); if(ns) efree(ns); + } + if (ctype) {efree(ctype);} + if (ns) {efree(ns);} - if(tmpbinding->bindingType == BINDING_SOAP) - { + if (tmpbinding->bindingType == BINDING_SOAP) { sdlSoapBindingFunctionPtr soapFunctionBinding = function->bindingAttributes; xmlNodePtr body; xmlAttrPtr tmp; body = get_node_ex(output->children, "body", WSDL_SOAP_NAMESPACE); - if(body) - { + if (body) { tmp = get_attribute(body->properties, "use"); - if(tmp && !strcmp(tmp->children->content, "literal")) + if (tmp && !strcmp(tmp->children->content, "literal")) { soapFunctionBinding->output.use = SOAP_LITERAL; - else + } else { soapFunctionBinding->output.use = SOAP_ENCODED; + } tmp = get_attribute(body->properties, "namespace"); - if(tmp) + if (tmp) { soapFunctionBinding->output.ns = strdup(tmp->children->content); + } tmp = get_attribute(body->properties, "parts"); - if(tmp) + if (tmp) { soapFunctionBinding->output.parts = strdup(tmp->children->content); + } tmp = get_attribute(body->properties, "encodingStyle"); - if(tmp) + if (tmp) { soapFunctionBinding->output.encodingStyle = strdup(tmp->children->content); + } } } trav3 = msgOutput->children; - FOREACHNODE(trav3, "part", part) - { + FOREACHNODE(trav3, "part", part) { sdlParamPtr param; xmlAttrPtr element, type, name; @@ -1017,18 +1003,21 @@ sdlPtr load_wsdl(char *struri, sdlPtr parent) param->order = 0; name = get_attribute(part->properties, "name"); - if(name == NULL) + if (name == NULL) { php_error(E_ERROR, "Error parsing wsdl (No name associated with part \"%s\")", msgOutput->name); + } param->paramName = strdup(name->children->content); element = get_attribute(part->properties, "element"); - if(element) + if (element) { param->encode = get_encoder_from_prefix(tmpsdl, part, element->children->content); + } type = get_attribute(part->properties, "type"); - if(type) + if (type) { param->encode = get_encoder_from_prefix(tmpsdl, part, type->children->content); + } zend_hash_next_index_insert(function->responseParameters, ¶m, sizeof(sdlParamPtr), NULL); } @@ -1036,12 +1025,10 @@ sdlPtr load_wsdl(char *struri, sdlPtr parent) } fault = get_node(operation->children, "fault"); - if(!fault) - { + if (!fault) { } - if(!tmpbinding->functions) - { + if (!tmpbinding->functions) { tmpbinding->functions = malloc(sizeof(HashTable)); zend_hash_init(tmpbinding->functions, 0, NULL, delete_function, 1); } @@ -1050,8 +1037,7 @@ sdlPtr load_wsdl(char *struri, sdlPtr parent) } ENDFOREACH(trav2); - if(!tmpsdl->bindings) - { + if (!tmpsdl->bindings) { tmpsdl->bindings = malloc(sizeof(HashTable)); zend_hash_init(tmpsdl->bindings, 0, NULL, delete_binding, 1); } @@ -1060,10 +1046,9 @@ sdlPtr load_wsdl(char *struri, sdlPtr parent) } ENDFOREACH(trav); - } - else + } else { php_error(E_ERROR, "Error parsing wsdl (\"Couldn't bind to service\")"); - + } return tmpsdl; } @@ -1082,8 +1067,7 @@ int load_ms_sdl(char *struri,int force_load) /* Commenting this out. Does anyone need it? */ #ifdef BRAD_0 - if(get_sdl(struri) == NULL || force_load) - { + if (get_sdl(struri) == NULL || force_load) { SOAP_TLS_VARS(); xmlDocPtr sdl = xmlParseFile(struri); xmlNodePtr schema,trav,trav2,req,res,paramOrd,reqRes,address,serviceAdd,service,soap,serviceDesc,root = sdl->children; @@ -1100,8 +1084,7 @@ int load_ms_sdl(char *struri,int force_load) ALLOC_INIT_ZVAL(sdlPtr->sdlUri); ZVAL_STRING(sdlPtr->sdlUri,struri,1); - FOREACHNODE(trav,"service",service) - { + FOREACHNODE(trav,"service",service) { sdlPtr->soapFunctions = emalloc(sizeof(HashTable)); sdlPtr->addresses = emalloc(sizeof(HashTable)); zend_hash_init(sdlPtr->soapFunctions, 0, NULL, delete_function, 0); @@ -1110,8 +1093,7 @@ int load_ms_sdl(char *struri,int force_load) serviceAdd = get_node(service->children,"addresses"); trav2 = serviceAdd->children; ALLOC_INIT_ZVAL(tempZval); - FOREACHNODE(trav2,"address",address) - { + FOREACHNODE(trav2,"address",address) { uri = get_attribute(address->properties,"uri"); add = uri->children->content; ZVAL_STRING(tempZval,add,1); @@ -1119,8 +1101,7 @@ int load_ms_sdl(char *struri,int force_load) } ENDFOREACH(trav2); trav2 = service->children; - FOREACHNODE(trav2,"requestResponse",reqRes) - { + FOREACHNODE(trav2,"requestResponse",reqRes) { tmpFunction = emalloc(sizeof(SoapFunction)); tmpattr = get_attribute(reqRes->properties,"name"); @@ -1136,8 +1117,7 @@ int load_ms_sdl(char *struri,int force_load) /* Request */ req = get_node(reqRes->children,"request"); tmpattr = get_attribute(req->properties,"ref"); - if(tmpattr != NULL) - { + if (tmpattr != NULL) { request = tmpattr->children->content; parse_namespace(request,&value,&namespace); ALLOC_INIT_ZVAL(tmpFunction->requestName); @@ -1151,8 +1131,7 @@ int load_ms_sdl(char *struri,int force_load) /* Response */ res = get_node(reqRes->children,"response"); tmpattr = get_attribute(res->properties,"ref"); - if(tmpattr != NULL) - { + if (tmpattr != NULL) { response = tmpattr->children->content; parse_namespace(response,&value,&namespace); ALLOC_INIT_ZVAL(tmpFunction->responseName); @@ -1165,8 +1144,7 @@ int load_ms_sdl(char *struri,int force_load) /* Parameters */ paramOrd = get_node(reqRes->children,"parameterorder"); - if(paramOrd != NULL) - { + if (paramOrd != NULL) { zval *space,*array,**strval; int count,i; ALLOC_INIT_ZVAL(space); @@ -1181,8 +1159,7 @@ int load_ms_sdl(char *struri,int force_load) zend_hash_internal_pointer_reset(array->value.ht); count = zend_hash_num_elements(array->value.ht); - for(i = 0;i < count;i++) - { + for (i = 0;i < count;i++) { SoapParamPtr param; param = emalloc(sizeof(SoapParam)); param->order = i+1; @@ -1201,8 +1178,7 @@ int load_ms_sdl(char *struri,int force_load) ENDFOREACH(trav); trav = serviceDesc->children; - FOREACHNODE(trav,"schema",schema) - { + FOREACHNODE(trav,"schema",schema) { load_schema(&sdlPtr, schema); } ENDFOREACH(trav); @@ -1217,22 +1193,21 @@ int load_ms_sdl(char *struri,int force_load) void delete_type(void *data) { sdlTypePtr type = *((sdlTypePtr*)data); - if(type->name) + if (type->name) { free(type->name); - if(type->namens) + } + if (type->namens) { free(type->namens); - if(type->elements) - { + } + if (type->elements) { zend_hash_destroy(type->elements); free(type->elements); } - if(type->attributes) - { + if (type->attributes) { zend_hash_destroy(type->attributes); free(type->attributes); } - if(type->restrictions) - { + if (type->restrictions) { delete_restriction_var_int(&type->restrictions->minExclusive); delete_restriction_var_int(&type->restrictions->minInclusive); delete_restriction_var_int(&type->restrictions->maxExclusive); @@ -1257,24 +1232,31 @@ void delete_attribute(void *attribute) { sdlAttributePtr attr = *((sdlAttributePtr*)attribute); - if(attr->def) + if (attr->def) { free(attr->def); - if(attr->fixed) + } + if (attr->fixed) { free(attr->fixed); - if(attr->form) + } + if (attr->form) { free(attr->form); - if(attr->id) + } + if (attr->id) { free(attr->id); - if(attr->name) + } + if (attr->name) { free(attr->name); - if(attr->ref) + } + if (attr->ref) { free(attr->ref); - if(attr->type) + } + if (attr->type) { free(attr->type); - if(attr->use) + } + if (attr->use) { free(attr->use); - if(attr->extraAttributes) - { + } + if (attr->extraAttributes) { zend_hash_destroy(attr->extraAttributes); free(attr->extraAttributes); } |