summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2004-01-09 18:22:03 +0000
committerDmitry Stogov <dmitry@php.net>2004-01-09 18:22:03 +0000
commit9a3cdc6491872bd1fe7eba2005df06748bc12a32 (patch)
treeb0192e50f3d2a17b26fd95aee0d217f297d232c7
parente3baf1a07da972a81f46582b02a8c9a85cb1e16d (diff)
downloadphp-git-9a3cdc6491872bd1fe7eba2005df06748bc12a32.tar.gz
Source cleanup.
-rw-r--r--ext/soap/php_encoding.c514
-rw-r--r--ext/soap/php_encoding.h12
-rw-r--r--ext/soap/php_http.c93
-rw-r--r--ext/soap/php_packet_soap.c58
-rw-r--r--ext/soap/php_schema.c287
-rw-r--r--ext/soap/php_sdl.c494
-rw-r--r--ext/soap/php_sdl.h36
-rw-r--r--ext/soap/php_soap.h94
-rw-r--r--ext/soap/php_xml.c117
-rw-r--r--ext/soap/soap.c843
10 files changed, 1234 insertions, 1314 deletions
diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c
index b5f3b96fe7..e549b3ec92 100644
--- a/ext/soap/php_encoding.c
+++ b/ext/soap/php_encoding.c
@@ -45,7 +45,7 @@ encode defaultEncoding[] = {
{{XSD_UNSIGNEDBYTE, XSD_UNSIGNEDBYTE_STRING, XSD_NAMESPACE, NULL}, to_zval_long, to_xml_long},
{{XSD_UNSIGNEDSHORT, XSD_UNSIGNEDSHORT_STRING, XSD_NAMESPACE, NULL}, to_zval_long, to_xml_long},
{{XSD_UNSIGNEDINT, XSD_UNSIGNEDINT_STRING, XSD_NAMESPACE, NULL}, to_zval_long, to_xml_long},
- {{XSD_UNSIGNEDLONG, XSD_UNSIGNEDLONG_STRING, XSD_NAMESPACE, NULL}, to_zval_ulong, to_xml_ulong},
+ {{XSD_UNSIGNEDLONG, XSD_UNSIGNEDLONG_STRING, XSD_NAMESPACE, NULL}, to_zval_ulong, to_xml_ulong},
{{XSD_ANYTYPE, XSD_ANYTYPE_STRING, XSD_NAMESPACE, NULL}, guess_zval_convert, guess_xml_convert},
{{XSD_ANYURI, XSD_ANYURI_STRING, XSD_NAMESPACE, NULL}, to_zval_stringc, to_xml_string},
@@ -87,35 +87,35 @@ encode defaultEncoding[] = {
void whiteSpace_replace(char* str)
{
while (*str != '\0') {
- if (*str == '\x9' || *str == '\xA' || *str == '\xD') {
- *str = ' ';
- }
- str++;
+ if (*str == '\x9' || *str == '\xA' || *str == '\xD') {
+ *str = ' ';
+ }
+ str++;
}
}
void whiteSpace_collapse(char* str)
-{
- char *orig = str;
+{
+ char *orig = str;
char *tmp = do_alloca(strlen(str)+1);
char *pos;
char old;
whiteSpace_replace(str);
while (*str == ' ') {
- str++;
+ str++;
}
pos = tmp; old = '\0';
while (*str != '\0') {
if (*str != ' ' || old != ' ') {
- *pos = *str;
- pos++;
+ *pos = *str;
+ pos++;
}
old = *str;
str++;
}
if (old == ' ') {
- --pos;
+ --pos;
}
*pos = '\0';
memcpy(orig,tmp,(pos-tmp)+1);
@@ -124,29 +124,34 @@ void whiteSpace_collapse(char* str)
xmlNodePtr master_to_xml(encodePtr encode, zval *data, int style)
{
- xmlNodePtr node;
+ xmlNodePtr node = NULL;
- if(encode->to_xml_before)
+ if (encode->to_xml_before) {
data = encode->to_xml_before(encode->details, data);
- if(encode->to_xml)
+ }
+ if (encode->to_xml) {
node = encode->to_xml(encode->details, data, style);
- if(encode->to_xml_after)
+ }
+ if (encode->to_xml_after) {
node = encode->to_xml_after(encode->details, node, style);
-
+ }
return node;
}
zval *master_to_zval(encodePtr encode, xmlNodePtr data)
{
- zval *ret;
+ zval *ret = NULL;
+
data = check_and_resolve_href(data);
- if(encode->to_zval_before)
+ if (encode->to_zval_before) {
data = encode->to_zval_before(encode->details, data, 0);
- if(encode->to_zval)
+ }
+ if (encode->to_zval) {
ret = encode->to_zval(encode->details, data);
- if(encode->to_zval_after)
+ }
+ if (encode->to_zval_after) {
ret = encode->to_zval_after(encode->details, ret);
-
+ }
return ret;
}
@@ -155,10 +160,10 @@ zval *to_xml_before_user(encodeType type, zval *data)
{
TSRMLS_FETCH();
- if(type.map->map_functions.to_xml_before)
- {
- if(call_user_function(EG(function_table), NULL, type.map->map_functions.to_xml_before, data, 1, &data TSRMLS_CC) == FAILURE)
+ if (type.map->map_functions.to_xml_before) {
+ if (call_user_function(EG(function_table), NULL, type.map->map_functions.to_xml_before, data, 1, &data TSRMLS_CC) == FAILURE) {
php_error(E_ERROR, "Error calling to_xml_before");
+ }
}
return data;
}
@@ -169,17 +174,17 @@ xmlNodePtr to_xml_user(encodeType type, zval *data, int style)
xmlNodePtr node;
TSRMLS_FETCH();
- if(type.map->map_functions.to_xml)
- {
+ if (type.map->map_functions.to_xml) {
MAKE_STD_ZVAL(ret);
- if(call_user_function(EG(function_table), NULL, type.map->map_functions.to_xml, ret, 1, &data TSRMLS_CC) == FAILURE)
+ if (call_user_function(EG(function_table), NULL, type.map->map_functions.to_xml, ret, 1, &data TSRMLS_CC) == FAILURE) {
php_error(E_ERROR, "Error calling to_xml");
+ }
- if(Z_TYPE_P(ret) != IS_OBJECT)
+ if (Z_TYPE_P(ret) != IS_OBJECT) {
php_error(E_ERROR, "Error serializing object from to_xml_user");
+ }
- if(zend_hash_index_find(Z_OBJPROP_P(ret), 1, (void **)&addr) == SUCCESS)
- {
+ if (zend_hash_index_find(Z_OBJPROP_P(ret), 1, (void **)&addr) == SUCCESS) {
node = (xmlNodePtr)Z_LVAL_PP(addr);
node = xmlCopyNode(node, 1);
set_ns_and_type(node, type);
@@ -195,16 +200,15 @@ xmlNodePtr to_xml_after_user(encodeType type, xmlNodePtr node, int style)
int found;
TSRMLS_FETCH();
- if(type.map->map_functions.to_xml_after)
- {
+ if (type.map->map_functions.to_xml_after) {
MAKE_STD_ZVAL(ret);
MAKE_STD_ZVAL(param);
param = php_domobject_new(node, &found, NULL TSRMLS_CC);
- if(call_user_function(EG(function_table), NULL, type.map->map_functions.to_xml_after, ret, 1, &param TSRMLS_CC) == FAILURE)
+ if (call_user_function(EG(function_table), NULL, type.map->map_functions.to_xml_after, ret, 1, &param TSRMLS_CC) == FAILURE) {
php_error(E_ERROR, "Error calling to_xml_after");
- if(zend_hash_index_find(Z_OBJPROP_P(ret), 1, (void **)&addr) == SUCCESS)
- {
+ }
+ if (zend_hash_index_find(Z_OBJPROP_P(ret), 1, (void **)&addr) == SUCCESS) {
node = (xmlNodePtr)Z_LVAL_PP(addr);
set_ns_and_type(node, type);
}
@@ -220,16 +224,15 @@ xmlNodePtr to_zval_before_user(encodeType type, xmlNodePtr node, int style)
int found;
TSRMLS_FETCH();
- if(type.map->map_functions.to_zval_before)
- {
+ if (type.map->map_functions.to_zval_before) {
MAKE_STD_ZVAL(ret);
MAKE_STD_ZVAL(param);
param = php_domobject_new(node, &found, NULL TSRMLS_CC);
- if(call_user_function(EG(function_table), NULL, type.map->map_functions.to_zval_before, ret, 1, &param TSRMLS_CC) == FAILURE)
+ if (call_user_function(EG(function_table), NULL, type.map->map_functions.to_zval_before, ret, 1, &param TSRMLS_CC) == FAILURE) {
php_error(E_ERROR, "Error calling to_zval_before");
- if(zend_hash_index_find(Z_OBJPROP_P(ret), 1, (void **)&addr) == SUCCESS)
- {
+ }
+ if (zend_hash_index_find(Z_OBJPROP_P(ret), 1, (void **)&addr) == SUCCESS) {
node = (xmlNodePtr)Z_LVAL_PP(addr);
set_ns_and_type(node, type);
}
@@ -245,14 +248,14 @@ zval *to_zval_user(encodeType type, xmlNodePtr node)
int found;
TSRMLS_FETCH();
- if(type.map->map_functions.to_zval)
- {
+ if (type.map->map_functions.to_zval) {
MAKE_STD_ZVAL(ret);
MAKE_STD_ZVAL(param);
param = php_domobject_new(node, &found, NULL TSRMLS_CC);
- if(call_user_function(EG(function_table), NULL, type.map->map_functions.to_zval, ret, 1, &param TSRMLS_CC) == FAILURE)
+ if (call_user_function(EG(function_table), NULL, type.map->map_functions.to_zval, ret, 1, &param TSRMLS_CC) == FAILURE) {
php_error(E_ERROR, "Error calling to_zval");
+ }
zval_ptr_dtor(&param);
efree(param);
}
@@ -263,10 +266,10 @@ zval *to_zval_after_user(encodeType type, zval *data)
{
TSRMLS_FETCH();
- if(type.map->map_functions.to_zval_after)
- {
- if(call_user_function(EG(function_table), NULL, type.map->map_functions.to_zval_after, data, 1, &data TSRMLS_CC) == FAILURE)
+ if (type.map->map_functions.to_zval_after) {
+ if (call_user_function(EG(function_table), NULL, type.map->map_functions.to_zval_after, data, 1, &data TSRMLS_CC) == FAILURE) {
php_error(E_ERROR, "Error calling to_xml_before");
+ }
}
return data;
}
@@ -279,7 +282,7 @@ zval *to_zval_string(encodeType type, xmlNodePtr data)
zval *ret;
MAKE_STD_ZVAL(ret);
FIND_XML_NULL(data, ret);
- if(data && data->children && data->children->content) {
+ if (data && data->children && data->children->content) {
ZVAL_STRING(ret, data->children->content, 1);
} else {
ZVAL_EMPTY_STRING(ret);
@@ -292,8 +295,8 @@ zval *to_zval_stringr(encodeType type, xmlNodePtr data)
zval *ret;
MAKE_STD_ZVAL(ret);
FIND_XML_NULL(data, ret);
- if(data && data->children && data->children->content) {
- whiteSpace_replace(data->children->content);
+ if (data && data->children && data->children->content) {
+ whiteSpace_replace(data->children->content);
ZVAL_STRING(ret, data->children->content, 1);
} else {
ZVAL_EMPTY_STRING(ret);
@@ -306,7 +309,7 @@ zval *to_zval_stringc(encodeType type, xmlNodePtr data)
zval *ret;
MAKE_STD_ZVAL(ret);
FIND_XML_NULL(data, ret);
- if(data && data->children && data->children->content) {
+ if (data && data->children && data->children->content) {
whiteSpace_collapse(data->children->content);
ZVAL_STRING(ret, data->children->content, 1);
} else {
@@ -328,8 +331,9 @@ xmlNodePtr to_xml_string(encodeType type, zval *data, int style)
if (Z_TYPE_P(data) == IS_STRING) {
str = php_escape_html_entities(Z_STRVAL_P(data), Z_STRLEN_P(data), &new_len, 0, 0, NULL TSRMLS_CC);
} else {
- zval tmp = *data;
- zval_copy_ctor(&tmp);
+ zval tmp = *data;
+
+ zval_copy_ctor(&tmp);
convert_to_string(&tmp);
str = php_escape_html_entities(Z_STRVAL(tmp), Z_STRLEN(tmp), &new_len, 0, 0, NULL TSRMLS_CC);
zval_dtor(&tmp);
@@ -342,8 +346,9 @@ xmlNodePtr to_xml_string(encodeType type, zval *data, int style)
xmlNodeSetContentLen(ret, pstr, new_len);
- if(style == SOAP_ENCODED)
+ if (style == SOAP_ENCODED) {
set_ns_and_type(ret, type);
+ }
return ret;
}
@@ -357,15 +362,17 @@ xmlNodePtr to_xml_stringl(encodeType type, zval *data, int style)
if (Z_TYPE_P(data) == IS_STRING) {
xmlNodeSetContentLen(ret, Z_STRVAL_P(data), Z_STRLEN_P(data));
} else {
- zval tmp = *data;
- zval_copy_ctor(&tmp);
+ zval tmp = *data;
+
+ zval_copy_ctor(&tmp);
convert_to_string(&tmp);
xmlNodeSetContentLen(ret, Z_STRVAL(tmp), Z_STRLEN(tmp));
zval_dtor(&tmp);
}
- if(style == SOAP_ENCODED)
+ if (style == SOAP_ENCODED) {
set_ns_and_type(ret, type);
+ }
return ret;
}
@@ -376,7 +383,7 @@ zval *to_zval_double(encodeType type, xmlNodePtr data)
FIND_XML_NULL(data, ret);
if (data && data->children && data->children->content) {
- whiteSpace_collapse(data->children->content);
+ whiteSpace_collapse(data->children->content);
ZVAL_DOUBLE(ret, atof(data->children->content));
} else {
ZVAL_NULL(ret);
@@ -391,7 +398,7 @@ zval *to_zval_long(encodeType type, xmlNodePtr data)
FIND_XML_NULL(data, ret);
if (data && data->children && data->children->content) {
- whiteSpace_collapse(data->children->content);
+ whiteSpace_collapse(data->children->content);
ZVAL_LONG(ret, atol(data->children->content));
} else {
ZVAL_NULL(ret);
@@ -406,8 +413,8 @@ zval *to_zval_ulong(encodeType type, xmlNodePtr data)
FIND_XML_NULL(data, ret);
if (data && data->children && data->children->content) {
- whiteSpace_collapse(data->children->content);
- /* TODO: long overflow */
+ whiteSpace_collapse(data->children->content);
+ /* TODO: long overflow */
ZVAL_LONG(ret, atol(data->children->content));
} else {
ZVAL_NULL(ret);
@@ -418,67 +425,70 @@ zval *to_zval_ulong(encodeType type, xmlNodePtr data)
xmlNodePtr to_xml_long(encodeType type, zval *data, int style)
{
xmlNodePtr ret;
- zval tmp;
+ zval tmp;
ret = xmlNewNode(NULL, "BOGUS");
FIND_ZVAL_NULL(data, ret, style);
tmp = *data;
- zval_copy_ctor(&tmp);
- if (Z_TYPE(tmp) != IS_LONG) {
+ zval_copy_ctor(&tmp);
+ if (Z_TYPE(tmp) != IS_LONG) {
convert_to_long(&tmp);
}
convert_to_string(&tmp);
xmlNodeSetContentLen(ret, Z_STRVAL(tmp), Z_STRLEN(tmp));
zval_dtor(&tmp);
- if(style == SOAP_ENCODED)
+ if (style == SOAP_ENCODED) {
set_ns_and_type(ret, type);
+ }
return ret;
}
xmlNodePtr to_xml_ulong(encodeType type, zval *data, int style)
{
xmlNodePtr ret;
- zval tmp;
+ zval tmp;
ret = xmlNewNode(NULL, "BOGUS");
FIND_ZVAL_NULL(data, ret, style);
/* TODO: long overflow */
tmp = *data;
- zval_copy_ctor(&tmp);
- if (Z_TYPE(tmp) != IS_LONG) {
+ zval_copy_ctor(&tmp);
+ if (Z_TYPE(tmp) != IS_LONG) {
convert_to_long(&tmp);
}
convert_to_string(&tmp);
xmlNodeSetContentLen(ret, Z_STRVAL(tmp), Z_STRLEN(tmp));
zval_dtor(&tmp);
- if(style == SOAP_ENCODED)
+ if (style == SOAP_ENCODED) {
set_ns_and_type(ret, type);
+ }
return ret;
}
xmlNodePtr to_xml_double(encodeType type, zval *data, int style)
{
xmlNodePtr ret;
- zval tmp;
+ zval tmp;
ret = xmlNewNode(NULL, "BOGUS");
FIND_ZVAL_NULL(data, ret, style);
tmp = *data;
- zval_copy_ctor(&tmp);
- if (Z_TYPE(tmp) != IS_DOUBLE) {
+ zval_copy_ctor(&tmp);
+ if (Z_TYPE(tmp) != IS_DOUBLE) {
convert_to_double(&tmp);
}
convert_to_string(&tmp);
xmlNodeSetContentLen(ret, Z_STRVAL(tmp), Z_STRLEN(tmp));
zval_dtor(&tmp);
- if(style == SOAP_ENCODED)
+ if (style == SOAP_ENCODED) {
set_ns_and_type(ret, type);
+ }
return ret;
}
@@ -490,14 +500,11 @@ zval *to_zval_bool(encodeType type, xmlNodePtr data)
if (data && data->children && data->children->content) {
whiteSpace_collapse(data->children->content);
- if(stricmp(data->children->content,"true") == 0 ||
+ if (stricmp(data->children->content,"true") == 0 ||
stricmp(data->children->content,"t") == 0 ||
- strcmp(data->children->content,"1") == 0)
- {
+ strcmp(data->children->content,"1") == 0) {
ZVAL_BOOL(ret, 1);
- }
- else
- {
+ } else {
ZVAL_BOOL(ret, 0);
}
} else {
@@ -515,23 +522,25 @@ xmlNodePtr to_xml_bool(encodeType type, zval *data, int style)
FIND_ZVAL_NULL(data, ret, style);
if (Z_TYPE_P(data) != IS_BOOL) {
- tmp = *data;
- zval_copy_ctor(&tmp);
+ tmp = *data;
+ zval_copy_ctor(&tmp);
convert_to_boolean(data);
- data = &tmp;
+ data = &tmp;
}
- if(data->value.lval == 1)
+ if (data->value.lval == 1) {
xmlNodeSetContent(ret, "1");
- else
+ } else {
xmlNodeSetContent(ret, "0");
+ }
if (data == &tmp) {
- zval_dtor(&tmp);
+ zval_dtor(&tmp);
}
- if(style == SOAP_ENCODED)
+ if (style == SOAP_ENCODED) {
set_ns_and_type(ret, type);
+ }
return ret;
}
@@ -551,8 +560,9 @@ xmlNodePtr to_xml_null(encodeType type, zval *data, int style)
ret = xmlNewNode(NULL, "BOGUS");
FIND_ZVAL_NULL(data, ret, style);
- if(style == SOAP_ENCODED)
+ if (style == SOAP_ENCODED) {
xmlSetProp(ret, "xsi:nil", "1");
+ }
return ret;
}
@@ -570,14 +580,14 @@ zval *to_zval_object(encodeType type, xmlNodePtr data)
sdl = SOAP_GLOBAL(sdl);
if (sdl && type.sdl_type) {
- sdlType = type.sdl_type;
+ sdlType = type.sdl_type;
}
object_init(ret);
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;
@@ -588,7 +598,7 @@ zval *to_zval_object(encodeType type, xmlNodePtr data)
}
if (enc == NULL && sdlType != NULL && sdlType->elements != NULL && trav->name != NULL &&
zend_hash_find(sdlType->elements, (char*)trav->name, strlen(trav->name)+1,(void **)&element) == SUCCESS) {
- enc = (*element)->encode;
+ enc = (*element)->encode;
}
if (enc == NULL) {
enc = get_conversion(UNKNOWN_TYPE);
@@ -600,7 +610,7 @@ zval *to_zval_object(encodeType type, xmlNodePtr data)
#endif
add_property_zval(ret, (char *)trav->name, tmpVal);
}
- trav = trav->next;
+ trav = trav->next;
}
return ret;
}
@@ -613,34 +623,36 @@ xmlNodePtr to_xml_object(encodeType type, zval *data, int style)
TSRMLS_FETCH();
/* Special handling of class SoapVar */
- if(data && Z_TYPE_P(data) == IS_OBJECT && Z_OBJCE_P(data) == soap_var_class_entry)
- {
+ if (data &&
+ Z_TYPE_P(data) == IS_OBJECT &&
+ Z_OBJCE_P(data) == soap_var_class_entry) {
zval **ztype, **zdata, **zns, **zstype, **zname, **znamens;
encodePtr enc;
- if(zend_hash_find(Z_OBJPROP_P(data), "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE)
+ if (zend_hash_find(Z_OBJPROP_P(data), "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE) {
php_error(E_ERROR, "error encoding SoapVar");
+ }
enc = get_conversion(Z_LVAL_P(*ztype));
- if(zend_hash_find(Z_OBJPROP_P(data), "enc_value", sizeof("enc_value"), (void **)&zdata) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(data), "enc_value", sizeof("enc_value"), (void **)&zdata) == FAILURE) {
xmlParam = master_to_xml(enc, NULL, style);
} else {
xmlParam = master_to_xml(enc, *zdata, style);
}
- if(zend_hash_find(Z_OBJPROP_P(data), "enc_stype", sizeof("enc_stype"), (void **)&zstype) == SUCCESS)
- {
- if(zend_hash_find(Z_OBJPROP_P(data), "enc_ns", sizeof("enc_ns"), (void **)&zns) == SUCCESS)
+ if (zend_hash_find(Z_OBJPROP_P(data), "enc_stype", sizeof("enc_stype"), (void **)&zstype) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(data), "enc_ns", sizeof("enc_ns"), (void **)&zns) == SUCCESS) {
set_ns_and_type_ex(xmlParam, Z_STRVAL_PP(zns), Z_STRVAL_PP(zstype));
- else
+ } else {
set_ns_and_type_ex(xmlParam, NULL, Z_STRVAL_PP(zstype));
+ }
}
- if(zend_hash_find(Z_OBJPROP_P(data), "enc_name", sizeof("enc_name"), (void **)&zname) == SUCCESS)
+ if (zend_hash_find(Z_OBJPROP_P(data), "enc_name", sizeof("enc_name"), (void **)&zname) == SUCCESS) {
xmlNodeSetName(xmlParam, Z_STRVAL_PP(zname));
- if(zend_hash_find(Z_OBJPROP_P(data), "enc_namens", sizeof("enc_namens"), (void **)&znamens) == SUCCESS)
- {
+ }
+ if (zend_hash_find(Z_OBJPROP_P(data), "enc_namens", sizeof("enc_namens"), (void **)&znamens) == SUCCESS) {
smart_str *ns;
xmlNsPtr nsp;
@@ -650,20 +662,16 @@ xmlNodePtr to_xml_object(encodeType type, zval *data, int style)
smart_str_free(ns);
efree(ns);
}
- }
- else
- {
+ } else {
xmlParam = xmlNewNode(NULL, "BOGUS");
FIND_ZVAL_NULL(data, xmlParam, style);
- if(Z_TYPE_P(data) == IS_OBJECT)
- {
+ if (Z_TYPE_P(data) == IS_OBJECT) {
prop = Z_OBJPROP_P(data);
i = zend_hash_num_elements(prop);
zend_hash_internal_pointer_reset(prop);
- for(;i > 0;i--)
- {
+ for (;i > 0;i--) {
xmlNodePtr property;
encodePtr enc;
zval **zprop;
@@ -681,8 +689,9 @@ xmlNodePtr to_xml_object(encodeType type, zval *data, int style)
}
}
- if(style == SOAP_ENCODED)
+ if (style == SOAP_ENCODED) {
set_ns_and_type(xmlParam, type);
+ }
}
return xmlParam;
}
@@ -693,15 +702,16 @@ xmlNodePtr guess_array_map(encodeType type, zval *data, int style)
encodePtr enc = NULL;
TSRMLS_FETCH();
- if(data && Z_TYPE_P(data) == IS_ARRAY)
- {
- if(is_map(data))
+ if (data && Z_TYPE_P(data) == IS_ARRAY) {
+ if (is_map(data)) {
enc = get_conversion(APACHE_MAP);
- else
+ } else {
enc = get_conversion(SOAP_ENC_ARRAY);
+ }
}
- if(!enc)
+ if (!enc) {
enc = get_conversion(IS_NULL);
+ }
return master_to_xml(enc, data, style);
}
@@ -717,12 +727,10 @@ xmlNodePtr to_xml_array(encodeType 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) {
i = zend_hash_num_elements(Z_ARRVAL_P(data));
- if(i > 0 && style == SOAP_ENCODED)
- {
+ if (i > 0 && style == SOAP_ENCODED) {
get_array_type(data, &array_type TSRMLS_CC);
smart_str_append(&array_type_and_size, &array_type);
smart_str_appendc(&array_type_and_size, '[');
@@ -737,8 +745,7 @@ xmlNodePtr to_xml_array(encodeType type, zval *data, int style)
}
zend_hash_internal_pointer_reset(data->value.ht);
- for(;i > 0;i--)
- {
+ for (;i > 0;i--) {
xmlNodePtr xparam;
zval **zdata;
encodePtr enc;
@@ -747,51 +754,53 @@ xmlNodePtr to_xml_array(encodeType type, zval *data, int style)
enc = get_conversion((*zdata)->type);
xparam = master_to_xml(enc, (*zdata), style);
- if(style == SOAP_LITERAL)
+ if (style == SOAP_LITERAL) {
xmlNodeSetName(xparam, enc->details.type_str);
- else
+ } else {
xmlNodeSetName(xparam, "val");
+ }
xmlAddChild(xmlParam, xparam);
zend_hash_move_forward(data->value.ht);
}
}
- if(style == SOAP_ENCODED)
+ if (style == SOAP_ENCODED) {
set_ns_and_type(xmlParam, type);
+ }
return xmlParam;
}
-static int calc_dimension(const char* str)
+static int calc_dimension(const char* str)
{
int i = 1;
- while (*str != ']' && *str != '\0') {
+ while (*str != ']' && *str != '\0') {
if (*str == ',') {
- i++;
- }
- str++;
- }
- return i;
+ i++;
+ }
+ str++;
+ }
+ return i;
}
-static void get_position_ex(int dimension, const char* str, int** pos)
+static void get_position_ex(int dimension, const char* str, int** pos)
{
- int i = 0;
-
+ int i = 0;
+
memset(*pos,0,sizeof(int)*dimension);
- while (*str != ']' && *str != '\0' && i < dimension) {
- if (*str >= '0' && *str <= '9') {
- (*pos)[i] = ((*pos)[i]*10)+(*str-'0');
- } else if (*str == ',') {
- i++;
- }
- str++;
+ while (*str != ']' && *str != '\0' && i < dimension) {
+ if (*str >= '0' && *str <= '9') {
+ (*pos)[i] = ((*pos)[i]*10)+(*str-'0');
+ } else if (*str == ',') {
+ i++;
+ }
+ str++;
}
}
-static int* get_position(int dimension, const char* str)
+static int* get_position(int dimension, const char* str)
{
int *pos;
-
+
pos = emalloc(sizeof(int)*dimension);
get_position_ex(dimension, str, &pos);
return pos;
@@ -816,8 +825,8 @@ zval *to_zval_array(encodeType type, xmlNodePtr data)
sdl = SOAP_GLOBAL(sdl);
if (data &&
- (arrayTypeAttr = get_attribute(data->properties,"arrayType")) &&
- arrayTypeAttr->children &&
+ (arrayTypeAttr = get_attribute(data->properties,"arrayType")) &&
+ arrayTypeAttr->children &&
arrayTypeAttr->children->content) {
char *type, *end, *ns;
xmlNsPtr nsptr;
@@ -827,15 +836,15 @@ zval *to_zval_array(encodeType type, xmlNodePtr data)
end = strrchr(type,'[');
if (end) {
- *end = '\0';
- dimension = calc_dimension(end+1);
- dims = get_position(dimension, end+1);
+ *end = '\0';
+ dimension = calc_dimension(end+1);
+ dims = get_position(dimension, end+1);
}
- if(nsptr != NULL) {
+ if (nsptr != NULL) {
enc = get_encoder(SOAP_GLOBAL(sdl), nsptr->href, type);
}
efree(type);
- if (ns) efree(ns);
+ if (ns) {efree(ns);}
}
if (dims == NULL) {
dims = emalloc(sizeof(int));
@@ -844,10 +853,11 @@ zval *to_zval_array(encodeType type, xmlNodePtr data)
pos = emalloc(sizeof(int)*dimension);
memset(pos,0,sizeof(int)*dimension);
if (data &&
- (offsetAttr = get_attribute(data->properties,"offset")) &&
- offsetAttr->children &&
+ (offsetAttr = get_attribute(data->properties,"offset")) &&
+ offsetAttr->children &&
offsetAttr->children->content) {
char* tmp = strrchr(offsetAttr->children->content,'[');
+
if (tmp == NULL) {
tmp = offsetAttr->children->content;
}
@@ -859,8 +869,8 @@ zval *to_zval_array(encodeType type, xmlNodePtr data)
array_init(ret);
trav = data->children;
- while(trav) {
- if(trav->type == XML_ELEMENT_NODE) {
+ while (trav) {
+ if (trav->type == XML_ELEMENT_NODE) {
int i;
zval *tmpVal, *ar;
encodePtr typeEnc = NULL;
@@ -888,14 +898,14 @@ zval *to_zval_array(encodeType type, xmlNodePtr data)
while (i < dimension-1) {
zval** ar2;
if (zend_hash_index_find(Z_ARRVAL_P(ar), pos[i], (void**)&ar2) == SUCCESS) {
- ar = *ar2;
+ ar = *ar2;
} else {
zval *tmpAr;
MAKE_STD_ZVAL(tmpAr);
array_init(tmpAr);
zend_hash_index_update(Z_ARRVAL_P(ar), pos[i], &tmpAr, sizeof(zval*), (void**)&ar2);
ar = *ar2;
- }
+ }
i++;
}
zend_hash_index_update(Z_ARRVAL_P(ar), pos[i], &tmpVal, sizeof(zval *), NULL);
@@ -907,7 +917,7 @@ zval *to_zval_array(encodeType type, xmlNodePtr data)
pos[i]++;
if (pos[i] >= dims[i]) {
if (i > 0) {
- pos[i] = 0;
+ pos[i] = 0;
} else {
/* TODO: Array index overflow */
}
@@ -918,8 +928,8 @@ zval *to_zval_array(encodeType type, xmlNodePtr data)
}
trav = trav->next;
}
- efree(dims);
- efree(pos);
+ efree(dims);
+ efree(pos);
return ret;
}
@@ -933,14 +943,12 @@ xmlNodePtr to_xml_map(encodeType type, zval *data, int style)
xmlParam = xmlNewNode(NULL, "BOGUS");
FIND_ZVAL_NULL(data, xmlParam, style);
- if(Z_TYPE_P(data) == IS_ARRAY)
- {
+ if (Z_TYPE_P(data) == IS_ARRAY) {
i = zend_hash_num_elements(Z_ARRVAL_P(data));
/* TODO: Register namespace...??? */
xmlSetProp(xmlParam, "xmlns:apache", "http://xml.apache.org/xml-soap");
zend_hash_internal_pointer_reset(data->value.ht);
- for(;i > 0;i--)
- {
+ for (;i > 0;i--) {
xmlNodePtr xparam, item;
xmlNodePtr key;
zval **temp_data;
@@ -949,24 +957,22 @@ xmlNodePtr to_xml_map(encodeType type, zval *data, int style)
encodePtr enc;
zend_hash_get_current_data(data->value.ht, (void **)&temp_data);
- if(Z_TYPE_PP(temp_data) != IS_NULL)
- {
+ if (Z_TYPE_PP(temp_data) != IS_NULL) {
item = xmlNewNode(NULL, "item");
key = xmlNewNode(NULL, "key");
- if(zend_hash_get_current_key(data->value.ht, &key_val, (long *)&int_val, FALSE) == HASH_KEY_IS_STRING)
- {
- if(style == SOAP_ENCODED)
+ if (zend_hash_get_current_key(data->value.ht, &key_val, (long *)&int_val, FALSE) == HASH_KEY_IS_STRING) {
+ if (style == SOAP_ENCODED) {
xmlSetProp(key, "xsi:type", "xsd:string");
+ }
xmlNodeSetContent(key, key_val);
- }
- else
- {
+ } else {
smart_str tmp = {0};
smart_str_append_long(&tmp, int_val);
smart_str_0(&tmp);
- if(style == SOAP_ENCODED)
+ if (style == SOAP_ENCODED) {
xmlSetProp(key, "xsi:type", "xsd:int");
+ }
xmlNodeSetContentLen(key, tmp.c, tmp.len);
smart_str_free(&tmp);
@@ -984,8 +990,9 @@ xmlNodePtr to_xml_map(encodeType type, zval *data, int style)
zend_hash_move_forward(data->value.ht);
}
}
- if(style == SOAP_ENCODED)
+ if (style == SOAP_ENCODED) {
set_ns_and_type(xmlParam, type);
+ }
return xmlParam;
}
@@ -1006,25 +1013,27 @@ zval *to_zval_map(encodeType type, xmlNodePtr data)
enc = get_conversion(UNKNOWN_TYPE);
trav = data->children;
- FOREACHNODE(trav, "item", item)
- {
+ FOREACHNODE(trav, "item", item) {
xmlKey = get_node(item->children, "key");
- if(!xmlKey)
+ if (!xmlKey) {
php_error(E_ERROR, "Error encoding apache map, missing key");
+ }
xmlValue = get_node(item->children, "value");
- if(!xmlKey)
+ if (!xmlKey) {
php_error(E_ERROR, "Error encoding apache map, missing value");
+ }
key = master_to_zval(enc, xmlKey);
value = master_to_zval(enc, xmlValue);
- if(Z_TYPE_P(key) == IS_STRING)
+ if (Z_TYPE_P(key) == IS_STRING) {
zend_hash_update(Z_ARRVAL_P(ret), Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &value, sizeof(zval *), NULL);
- else if(Z_TYPE_P(key) == IS_LONG)
+ } else if (Z_TYPE_P(key) == IS_LONG) {
zend_hash_index_update(Z_ARRVAL_P(ret), Z_LVAL_P(key), &value, sizeof(zval *), NULL);
- else
+ } else {
php_error(E_ERROR, "Error encoding apache map, only Strings or Longs are allowd as keys");
+ }
}
ENDFOREACH(trav);
} else {
@@ -1039,10 +1048,11 @@ xmlNodePtr guess_xml_convert(encodeType type, zval *data, int style)
encodePtr enc;
TSRMLS_FETCH();
- if(data)
+ if (data) {
enc = get_conversion(data->type);
- else
+ } else {
enc = get_conversion(IS_NULL);
+ }
return master_to_xml(enc, data, style);
}
@@ -1058,38 +1068,32 @@ zval *guess_zval_convert(encodeType type, xmlNodePtr data)
enc = get_conversion(IS_NULL);
} else if (data->properties && get_attribute(data->properties, "nil")) {
enc = get_conversion(IS_NULL);
- }
- else
- {
+ } else {
tmpattr = get_attribute(data->properties,"type");
- if(tmpattr != NULL)
- {
+ if (tmpattr != NULL) {
if (tmpattr->children) {
enc = get_conversion_from_type(data, tmpattr->children->content);
} else {
enc = get_conversion_from_type(data, "");
}
/*
- if(enc == NULL)
+ if (enc == NULL)
php_error(E_ERROR, "Error (Don't know how to encode/decode \"%s\")", tmpattr->children->content);
*/
}
- if(enc == NULL)
- {
+ if (enc == NULL) {
/* Didn't have a type, totally guess here */
/* Logic: has children = IS_OBJECT else IS_STRING */
xmlNodePtr trav;
- if(get_attribute(data->properties, "arrayType"))
+ if (get_attribute(data->properties, "arrayType")) {
enc = get_conversion(SOAP_ENC_ARRAY);
- else
- {
+ } else {
enc = get_conversion(XSD_STRING);
trav = data->children;
while (trav != NULL) {
- if(trav->type == XML_ELEMENT_NODE)
- {
+ if (trav->type == XML_ELEMENT_NODE) {
enc = get_conversion(SOAP_ENC_OBJECT);
break;
}
@@ -1121,11 +1125,10 @@ xmlNodePtr to_xml_datetime_ex(encodeType type, zval *data, char *format, int sty
ta = php_localtime_r(&timestamp, &tmbuf);
buf = (char *) emalloc(buf_len);
- while ((real_len = strftime(buf, buf_len, format, ta)) == buf_len || real_len == 0)
- {
+ while ((real_len = strftime(buf, buf_len, format, ta)) == buf_len || real_len == 0) {
buf_len *= 2;
buf = (char *) erealloc(buf, buf_len);
- if(!--max_reallocs) break;
+ if (!--max_reallocs) break;
}
xmlNodeSetContent(xmlParam, buf);
@@ -1139,8 +1142,9 @@ xmlNodePtr to_xml_datetime_ex(encodeType type, zval *data, char *format, int sty
xmlSetProp(xmlParam, "xsi:nil", "1");
}
- if(style == SOAP_ENCODED)
+ if (style == SOAP_ENCODED) {
set_ns_and_type(xmlParam, type);
+ }
return xmlParam;
}
@@ -1206,25 +1210,21 @@ void set_ns_and_type(xmlNodePtr node, encodeType type)
void set_ns_and_type_ex(xmlNodePtr node, char *ns, char *type)
{
- if(ns != NULL)
- {
+ if (ns != NULL) {
char *sprefix;
smart_str *prefix;
smart_str xmlns = {0}, nstype = {0};
TSRMLS_FETCH();
- if(zend_hash_find(SOAP_GLOBAL(defEncNs), ns, strlen(ns) + 1, (void **)&sprefix) == FAILURE)
- {
+ if (zend_hash_find(SOAP_GLOBAL(defEncNs), ns, strlen(ns) + 1, (void **)&sprefix) == FAILURE) {
prefix = encode_new_ns();
smart_str_appendl(&xmlns, "xmlns:", 6);
smart_str_append(&xmlns, prefix);
smart_str_0(&xmlns);
xmlSetProp(node, xmlns.c, ns);
- }
- else
- {
+ } else {
prefix = emalloc(sizeof(smart_str));
memset(prefix, 0, sizeof(smart_str));
smart_str_appends(prefix, sprefix);
@@ -1239,9 +1239,9 @@ void set_ns_and_type_ex(xmlNodePtr node, char *ns, char *type)
smart_str_free(&xmlns);
smart_str_free(prefix);
efree(prefix);
- }
- else
+ } else {
xmlSetProp(node, "xsi:type", type);
+ }
}
smart_str *encode_new_ns()
@@ -1270,11 +1270,11 @@ encodePtr get_conversion_ex(HashTable *encoding, int encode)
encodePtr *enc;
TSRMLS_FETCH();
- if(zend_hash_index_find(encoding, encode, (void **)&enc) == FAILURE)
+ if (zend_hash_index_find(encoding, encode, (void **)&enc) == FAILURE) {
php_error(E_ERROR, "Cannot find encoding");
+ }
- if(SOAP_GLOBAL(overrides))
- {
+ if (SOAP_GLOBAL(overrides)) {
smart_str nscat = {0};
smart_str_appendl(&nscat, (*enc)->details.ns, strlen((*enc)->details.ns));
@@ -1293,11 +1293,13 @@ encodePtr get_conversion_from_href_type_ex(HashTable *encoding, const char *type
{
encodePtr *enc = NULL;
- if(encoding == NULL)
+ if (encoding == NULL) {
return NULL;
+ }
- if(zend_hash_find(encoding, (char*)type, len + 1, (void **)&enc) == FAILURE)
+ if (zend_hash_find(encoding, (char*)type, len + 1, (void **)&enc) == FAILURE) {
return NULL;
+ }
return (*enc);
}
@@ -1309,47 +1311,48 @@ encodePtr get_conversion_from_type_ex(HashTable *encoding, xmlNodePtr node, cons
char *ns, *cptype;
smart_str nscat = {0};
- if(encoding == NULL)
+ if (encoding == NULL) {
return NULL;
+ }
parse_namespace(type, &cptype, &ns);
nsptr = xmlSearchNs(node->doc, node, ns);
- if(nsptr != NULL)
- {
+ if (nsptr != NULL) {
smart_str_appends(&nscat, nsptr->href);
smart_str_appendc(&nscat, ':');
smart_str_appends(&nscat, cptype);
smart_str_0(&nscat);
- if(zend_hash_find(encoding, nscat.c, nscat.len + 1, (void **)&enc) == FAILURE)
- {
- if(zend_hash_find(encoding, (char*)type, strlen(type) + 1, (void **)&enc) == FAILURE)
+ if (zend_hash_find(encoding, nscat.c, nscat.len + 1, (void **)&enc) == FAILURE) {
+ if (zend_hash_find(encoding, (char*)type, strlen(type) + 1, (void **)&enc) == FAILURE) {
enc = NULL;
+ }
}
smart_str_free(&nscat);
- }
- else
- {
- if(zend_hash_find(encoding, (char*)type, strlen(type) + 1, (void **)&enc) == FAILURE)
+ } else {
+ if (zend_hash_find(encoding, (char*)type, strlen(type) + 1, (void **)&enc) == FAILURE) {
enc = NULL;
+ }
}
- if(cptype) efree(cptype);
- if(ns) efree(ns);
- if(enc == NULL)
+ if (cptype) {efree(cptype);}
+ if (ns) {efree(ns);}
+ if (enc == NULL) {
return NULL;
- else
+ } else {
return (*enc);
+ }
}
int is_map(zval *array)
{
int i, count = zend_hash_num_elements(Z_ARRVAL_P(array));
+
zend_hash_internal_pointer_reset(Z_ARRVAL_P(array));
- for(i = 0;i < count;i++)
- {
- if(zend_hash_get_current_key_type(Z_ARRVAL_P(array)) == HASH_KEY_IS_STRING)
+ for (i = 0;i < count;i++) {
+ if (zend_hash_get_current_key_type(Z_ARRVAL_P(array)) == HASH_KEY_IS_STRING) {
return TRUE;
+ }
zend_hash_move_forward(Z_ARRVAL_P(array));
}
return FALSE;
@@ -1360,37 +1363,35 @@ void get_array_type(zval *array, smart_str *type TSRMLS_DC)
HashTable *ht = HASH_OF(array);
int i, count, cur_type, prev_type, different;
zval **tmp;
-/* TSRMLS_FETCH();*/
- if(!array || Z_TYPE_P(array) != IS_ARRAY)
+ if (!array || Z_TYPE_P(array) != IS_ARRAY) {
smart_str_appendl(type, "xsd:anyType", 11);
+ }
different = FALSE;
cur_type = prev_type = 0;
count = zend_hash_num_elements(ht);
zend_hash_internal_pointer_reset(ht);
- for(i = 0;i < count;i++)
- {
+ for (i = 0;i < count;i++) {
zend_hash_get_current_data(ht, (void **)&tmp);
- if(Z_TYPE_PP(tmp) == IS_OBJECT && Z_OBJCE_PP(tmp) == soap_var_class_entry)
- {
+ if (Z_TYPE_PP(tmp) == IS_OBJECT &&
+ Z_OBJCE_PP(tmp) == soap_var_class_entry) {
zval **ztype;
- if(zend_hash_find(Z_OBJPROP_PP(tmp), "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE)
+ if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE) {
php_error(E_ERROR, "error encoding SoapVar");
+ }
cur_type = Z_LVAL_P(*ztype);
- }
- else if(Z_TYPE_PP(tmp) == IS_ARRAY && is_map(*tmp))
+ } else if (Z_TYPE_PP(tmp) == IS_ARRAY && is_map(*tmp)) {
cur_type = APACHE_MAP;
- else
+ } else {
cur_type = Z_TYPE_PP(tmp);
+ }
- if(i > 0)
- {
- if(cur_type != prev_type)
- {
+ if (i > 0) {
+ if (cur_type != prev_type) {
different = TRUE;
break;
}
@@ -1400,27 +1401,26 @@ void get_array_type(zval *array, smart_str *type TSRMLS_DC)
zend_hash_move_forward(ht);
}
- if(different)
+ if (different) {
smart_str_appendl(type, "xsd:anyType", 11);
- else
- {
+ } else {
encodePtr enc;
char *prefix;
enc = get_conversion(cur_type);
- if(enc->details.ns != NULL)
- {
- if(zend_hash_find(SOAP_GLOBAL(defEncNs), enc->details.ns, strlen(enc->details.ns) + 1, (void **)&prefix) == FAILURE)
+ if (enc->details.ns != NULL) {
+ if (zend_hash_find(SOAP_GLOBAL(defEncNs), enc->details.ns, strlen(enc->details.ns) + 1, (void **)&prefix) == FAILURE) {
php_error(E_ERROR, "fix me");
+ }
smart_str_appendl(type, prefix, strlen(prefix));
smart_str_appendc(type, ':');
smart_str_appendl(type, enc->details.type_str, strlen(enc->details.type_str));
smart_str_0(type);
- }
- else
+ } else {
smart_str_appendl(type, enc->details.type_str, strlen(enc->details.type_str));
+ }
}
}
@@ -1434,8 +1434,9 @@ smart_str *build_soap_action(zval *this_ptr, char *soapaction)
tmp = emalloc(sizeof(smart_str));
memset(tmp, 0, sizeof(smart_str));
- if(zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE)
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE) {
php_error(E_ERROR, "Error finding uri");
+ }
smart_str_appendl(tmp, Z_STRVAL_PP(uri), Z_STRLEN_PP(uri));
smart_str_appends(tmp, "#");
@@ -1448,11 +1449,14 @@ smart_str *build_soap_action(zval *this_ptr, char *soapaction)
void delete_encoder(void *encode)
{
encodePtr t = *((encodePtr*)encode);
- if(t->details.ns)
+ if (t->details.ns) {
free(t->details.ns);
- if(t->details.type_str)
+ }
+ if (t->details.type_str) {
free(t->details.type_str);
- if(t->details.map)
+ }
+ if (t->details.map) {
delete_mapping(t->details.map);
+ }
free(t);
}
diff --git a/ext/soap/php_encoding.h b/ext/soap/php_encoding.h
index 88a02bffad..85710ba8cf 100644
--- a/ext/soap/php_encoding.h
+++ b/ext/soap/php_encoding.h
@@ -243,16 +243,13 @@ extern encode defaultEncoding[];
#define FIND_XML_NULL(xml,zval) \
{ \
xmlAttrPtr null; \
- if(!xml) \
- { \
+ if (!xml) { \
ZVAL_NULL(zval); \
return zval; \
} \
- if(xml->properties) \
- { \
+ if (xml->properties) { \
null = get_attribute(xml->properties, "nil"); \
- if(null) \
- { \
+ if (null) { \
ZVAL_NULL(zval); \
return zval; \
} \
@@ -261,8 +258,7 @@ extern encode defaultEncoding[];
#define FIND_ZVAL_NULL(zval, xml, style) \
{ \
- if(!zval || Z_TYPE_P(zval) == IS_NULL) \
- { \
+ if (!zval || Z_TYPE_P(zval) == IS_NULL) { \
if (style == SOAP_ENCODED) {\
xmlSetProp(xml, "xsi:nil", "1"); \
}\
diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c
index 5d7415b5b0..c8d18095dc 100644
--- a/ext/soap/php_http.c
+++ b/ext/soap/php_http.c
@@ -23,12 +23,12 @@ int send_http_soap_request(zval *this_ptr, xmlDoc *doc, char *soapaction TSRMLS_
FETCH_THIS_SDL(sdl);
xmlDocDumpMemory(doc, &buf, &buf_size);
- if(!buf) {
+ if (!buf) {
add_soap_fault(this_ptr, "SOAP-ENV:Client", "Error build soap request", NULL, NULL TSRMLS_CC);
return FALSE;
}
- if(zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS
- && Z_LVAL_PP(trace) > 0) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
+ Z_LVAL_PP(trace) > 0) {
add_property_stringl(this_ptr, "__last_request", buf, buf_size, 1);
}
@@ -38,24 +38,24 @@ int send_http_soap_request(zval *this_ptr, xmlDoc *doc, char *soapaction TSRMLS_
tv.tv_sec = 0;
tv.tv_usec = 1;
php_stream_set_option(stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &tv);
- if (php_stream_set_option(stream, PHP_STREAM_OPTION_CHECK_LIVENESS, 0, NULL) != PHP_STREAM_OPTION_RETURN_OK) {
- php_stream_close(stream);
+ if (php_stream_set_option(stream, PHP_STREAM_OPTION_CHECK_LIVENESS, 0, NULL) != PHP_STREAM_OPTION_RETURN_OK) {
+ php_stream_close(stream);
zend_hash_del(Z_OBJPROP_P(this_ptr), "httpsocket", sizeof("httpsocket"));
- stream = NULL;
- } else {
+ stream = NULL;
+ } else {
tv.tv_sec = FG(default_socket_timeout);;
tv.tv_usec = 0;
php_stream_set_option(stream, PHP_STREAM_OPTION_READ_TIMEOUT, 0, &tv);
}
}
- if(!stream) {
+ if (!stream) {
char *url;
int use_ssl;
- if(!sdl) {
+ if (!sdl) {
zval **location;
- if(zend_hash_find(Z_OBJPROP_P(this_ptr), "location", sizeof("location"),(void **) &location) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "location", sizeof("location"),(void **) &location) == FAILURE) {
xmlFree(buf);
add_soap_fault(this_ptr, "SOAP-ENV:Client", "Error could not find location", NULL, NULL TSRMLS_CC);
return FALSE;
@@ -95,11 +95,11 @@ int send_http_soap_request(zval *this_ptr, xmlDoc *doc, char *soapaction TSRMLS_
reslen = spprintf(&res, 0, "%s://%s:%d", use_ssl ? "ssl" : "tcp", phpurl->host, phpurl->port);
- stream = php_stream_xport_create(res, reslen,
+ stream = php_stream_xport_create(res, reslen,
ENFORCE_SAFE_MODE | REPORT_ERRORS,
- STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT,
- NULL /*persistent_id*/,
- NULL /*timeout*/,
+ STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT,
+ NULL /*persistent_id*/,
+ NULL /*timeout*/,
NULL, NULL, NULL);
efree(res);
@@ -116,7 +116,7 @@ int send_http_soap_request(zval *this_ptr, xmlDoc *doc, char *soapaction TSRMLS_
}
#endif
- if(stream) {
+ if (stream) {
php_stream_auto_cleanup(stream);
add_property_resource(this_ptr, "httpsocket", php_stream_get_resource_id(stream));
ret = zend_list_insert(phpurl, le_url);
@@ -140,9 +140,11 @@ int send_http_soap_request(zval *this_ptr, xmlDoc *doc, char *soapaction TSRMLS_
smart_str_appends(&soap_headers, phpurl->host);
smart_str_append_const(&soap_headers, "\r\n"
"Connection: Keep-Alive\r\n"
-// "Connection: close\r\n"
-// "Accept: text/html; text/xml; text/plain\r\n"
-// "User-Agent: PHP SOAP 0.1\r\n"
+/*
+ "Connection: close\r\n"
+ "Accept: text/html; text/xml; text/plain\r\n"
+ "User-Agent: PHP SOAP 0.1\r\n"
+*/
"Content-Type: text/xml; charset=\"utf-8\"\r\n"
"Content-Length: ");
smart_str_append_long(&soap_headers, buf_size);
@@ -153,14 +155,14 @@ int send_http_soap_request(zval *this_ptr, xmlDoc *doc, char *soapaction TSRMLS_
smart_str_append_const(&soap_headers, "\"\r\n");
/* HTTP Authentication */
- if(zend_hash_find(Z_OBJPROP_P(this_ptr), "_login", sizeof("_login"), (void **)&login) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_login", sizeof("_login"), (void **)&login) == SUCCESS) {
char* buf;
int len;
smart_str auth = {0};
smart_str_appendl(&auth, Z_STRVAL_PP(login), Z_STRLEN_PP(login));
smart_str_appendc(&auth, ':');
- if(zend_hash_find(Z_OBJPROP_P(this_ptr), "_password", sizeof("_password"), (void **)&password) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_password", sizeof("_password"), (void **)&password) == SUCCESS) {
smart_str_appendl(&auth, Z_STRVAL_PP(password), Z_STRLEN_PP(password));
}
smart_str_0(&auth);
@@ -173,14 +175,14 @@ int send_http_soap_request(zval *this_ptr, xmlDoc *doc, char *soapaction TSRMLS_
}
/* Send cookies along with request */
- if(zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
zval **data;
char *key;
int index, i;
smart_str_append_const(&soap_headers, "Cookie: ");
zend_hash_internal_pointer_reset(Z_ARRVAL_PP(cookies));
- for(i = 0;i < (int)Z_ARRVAL_PP(cookies)->nNumOfElements;i++) {
+ for (i = 0;i < (int)Z_ARRVAL_PP(cookies)->nNumOfElements;i++) {
zend_hash_get_current_data(Z_ARRVAL_PP(cookies), (void **)&data);
zend_hash_get_current_key(Z_ARRVAL_PP(cookies), &key, (long *)&index, FALSE);
@@ -198,7 +200,7 @@ int send_http_soap_request(zval *this_ptr, xmlDoc *doc, char *soapaction TSRMLS_
smart_str_0(&soap_headers);
err = php_stream_write(stream, soap_headers.c, soap_headers.len);
- if(err != soap_headers.len) {
+ if (err != soap_headers.len) {
xmlFree(buf);
smart_str_free(&soap_headers);
php_stream_close(stream);
@@ -223,11 +225,11 @@ int get_http_soap_response(zval *this_ptr, char **buffer, int *buffer_len TSRMLS
char* connection;
int http_1_1 = 0;
- if(FIND_SOCKET_PROPERTY(this_ptr, socket_ref) != FAILURE) {
+ if (FIND_SOCKET_PROPERTY(this_ptr, socket_ref) != FAILURE) {
FETCH_SOCKET_RES(stream, socket_ref);
}
- if(!get_http_headers(stream, &http_headers, &http_header_size TSRMLS_CC)) {
+ if (!get_http_headers(stream, &http_headers, &http_header_size TSRMLS_CC)) {
php_stream_close(stream);
zend_hash_del(Z_OBJPROP_P(this_ptr), "httpsocket", sizeof("httpsocket"));
add_soap_fault(this_ptr, "SOAP-ENV:Client", "Error Fetching http headers", NULL, NULL TSRMLS_CC);
@@ -236,12 +238,12 @@ int get_http_soap_response(zval *this_ptr, char **buffer, int *buffer_len TSRMLS
/* Check to see what HTTP status was sent */
http_version = get_http_header_value(http_headers,"HTTP/");
- if(http_version) {
+ if (http_version) {
char *tmp;
tmp = strstr(http_version," ");
- if(tmp != NULL) {
+ if (tmp != NULL) {
tmp++;
strncpy(http_status,tmp,4);
http_status[3] = '\0';
@@ -253,7 +255,7 @@ int get_http_soap_response(zval *this_ptr, char **buffer, int *buffer_len TSRMLS
Maybe try and test for some of the 300's 400's specfics but not
right now.
- if(strcmp(http_status,"200"))
+ if (strcmp(http_status,"200"))
{
zval *err;
char *http_err;
@@ -268,30 +270,30 @@ int get_http_soap_response(zval *this_ptr, char **buffer, int *buffer_len TSRMLS
}*/
/* Try and get headers again */
- if(!strcmp(http_status, "100")) {
- if(!get_http_headers(stream, &http_headers, &http_header_size TSRMLS_CC)) {
+ if (!strcmp(http_status, "100")) {
+ if (!get_http_headers(stream, &http_headers, &http_header_size TSRMLS_CC)) {
php_stream_close(stream);
zend_hash_del(Z_OBJPROP_P(this_ptr), "httpsocket", sizeof("httpsocket"));
add_soap_fault(this_ptr, "SOAP-ENV:Client", "Error Fetching http headers", NULL, NULL TSRMLS_CC);
return FALSE;
}
}
-
+
if (strncmp(http_version,"1.1", 3)) {
http_1_1 = 1;
}
efree(http_version);
}
- if(!get_http_body(stream, http_headers, &http_body, &http_body_size TSRMLS_CC)) {
+ if (!get_http_body(stream, http_headers, &http_body, &http_body_size TSRMLS_CC)) {
php_stream_close(stream);
zend_hash_del(Z_OBJPROP_P(this_ptr), "httpsocket", sizeof("httpsocket"));
add_soap_fault(this_ptr, "SOAP-ENV:Client", "Error Fetching http body", NULL, NULL TSRMLS_CC);
return FALSE;
}
- if(zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS
- && Z_LVAL_PP(trace) > 0) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
+ Z_LVAL_PP(trace) > 0) {
add_property_stringl(this_ptr, "__last_response", http_body, http_body_size, 1);
}
@@ -301,8 +303,8 @@ int get_http_soap_response(zval *this_ptr, char **buffer, int *buffer_len TSRMLS
/* See if the server requested a close */
http_close = TRUE;
connection = get_http_header_value(http_headers,"Connection: ");
- if(connection) {
- if(!strcmp(connection, "Keep-Alive")) {
+ if (connection) {
+ if (!strcmp(connection, "Keep-Alive")) {
http_close = FALSE;
}
efree(connection);
@@ -317,18 +319,18 @@ int get_http_soap_response(zval *this_ptr, char **buffer, int *buffer_len TSRMLS
/* Check and see if the server even sent a xml document */
content_type = get_http_header_value(http_headers,"Content-Type: ");
- if(content_type) {
+ if (content_type) {
char *pos = NULL;
int cmplen;
pos = strstr(content_type,";");
- if(pos != NULL) {
+ if (pos != NULL) {
cmplen = pos - content_type;
} else {
cmplen = strlen(content_type);
}
- if(strncmp(content_type, "text/xml", cmplen)) {
- if(strncmp(http_body, "<?xml", 5)) {
+ if (strncmp(content_type, "text/xml", cmplen)) {
+ if (strncmp(http_body, "<?xml", 5)) {
zval *err;
MAKE_STD_ZVAL(err);
ZVAL_STRINGL(err, http_body, http_body_size, 1);
@@ -349,13 +351,13 @@ int get_http_soap_response(zval *this_ptr, char **buffer, int *buffer_len TSRMLS
matter too much
*/
cookie_itt = strstr(http_headers,"Set-Cookie: ");
- while(cookie_itt) {
+ while (cookie_itt) {
char *end_pos, *cookie;
char *eqpos, *sempos;
smart_str name = {0}, value = {0};
zval **cookies, *z_cookie;
- if(zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) {
zval *tmp_cookies;
MAKE_STD_ZVAL(tmp_cookies);
array_init(tmp_cookies);
@@ -420,8 +422,9 @@ static char *get_http_header_value(char *headers, char *type)
/* find next line */
pos = strstr(pos, "\r\n");
- if (pos)
+ if (pos) {
pos += 2;
+ }
} while (pos);
@@ -476,7 +479,7 @@ static int get_http_body(php_stream *stream, char *headers, char **response, in
size = atoi(content_length);
http_buf = emalloc(size + 1);
- while(http_buf_size < size) {
+ while (http_buf_size < size) {
http_buf_size += php_stream_read(stream, http_buf + http_buf_size, size - http_buf_size);
}
http_buf[size] = '\0';
@@ -497,7 +500,7 @@ static int get_http_headers(php_stream *stream, char **response, int *out_size T
smart_str tmp_response = {0};
char headerbuf[8192];
- while(!done) {
+ while (!done) {
if (!php_stream_gets(stream, headerbuf, sizeof(headerbuf))) {
break;
}
diff --git a/ext/soap/php_packet_soap.c b/ext/soap/php_packet_soap.c
index b8cda52f5e..4b7044ba30 100644
--- a/ext/soap/php_packet_soap.c
+++ b/ext/soap/php_packet_soap.c
@@ -23,19 +23,19 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction
trav = response->children;
while (trav != NULL) {
if (trav->type == XML_ELEMENT_NODE) {
- if (env == NULL && node_is_equal_ex(trav,"Envelope",SOAP_1_1_ENV)) {
- env = trav;
- envelope_ns = SOAP_1_1_ENV;
- } else if (env == NULL && node_is_equal_ex(trav,"Envelope",SOAP_1_2_ENV)) {
- env = trav;
- envelope_ns = SOAP_1_2_ENV;
- } else {
+ if (env == NULL && node_is_equal_ex(trav,"Envelope",SOAP_1_1_ENV)) {
+ env = trav;
+ envelope_ns = SOAP_1_1_ENV;
+ } else if (env == NULL && node_is_equal_ex(trav,"Envelope",SOAP_1_2_ENV)) {
+ env = trav;
+ envelope_ns = SOAP_1_2_ENV;
+ } else {
add_soap_fault(this_ptr, "SOAP-ENV:Client", "looks like we got bad SOAP response\n", NULL, NULL TSRMLS_CC);
xmlFreeDoc(response);
return FALSE;
- }
- }
- trav = trav->next;
+ }
+ }
+ trav = trav->next;
}
if (env == NULL) {
add_soap_fault(this_ptr, "SOAP-ENV:Client", "looks like we got XML without \"Envelope\" element\n", NULL, NULL TSRMLS_CC);
@@ -47,26 +47,26 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction
head = NULL;
trav = env->children;
while (trav != NULL && trav->type != XML_ELEMENT_NODE) {
- trav = trav->next;
+ trav = trav->next;
}
if (trav != NULL && node_is_equal_ex(trav,"Header",envelope_ns)) {
- head = trav;
- trav = trav->next;
+ head = trav;
+ trav = trav->next;
}
/* Get <Body> element */
body = NULL;
while (trav != NULL) {
if (trav->type == XML_ELEMENT_NODE) {
- if (body == NULL && node_is_equal_ex(trav,"Body",envelope_ns)) {
- body = trav;
- } else {
+ if (body == NULL && node_is_equal_ex(trav,"Body",envelope_ns)) {
+ body = trav;
+ } else {
add_soap_fault(this_ptr, "SOAP-ENV:Client", "looks like we got bad SOAP response\n", NULL, NULL TSRMLS_CC);
xmlFreeDoc(response);
return FALSE;
- }
- }
- trav = trav->next;
+ }
+ }
+ trav = trav->next;
}
if (body == NULL) {
add_soap_fault(this_ptr, "SOAP-ENV:Client", "looks like we got \"Envelope\" without \"Body\" element\n", NULL, NULL TSRMLS_CC);
@@ -76,7 +76,7 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction
/* Check if <Body> contains <Fault> element */
fault = get_node_ex(body->children,"Fault",envelope_ns);
- if(fault != NULL) {
+ if (fault != NULL) {
char *faultcode = NULL, *faultstring = NULL, *faultactor = NULL;
zval *details = NULL;
xmlNodePtr tmp;
@@ -182,14 +182,14 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction
/* Function hasn't WSDL description */
cur = resp;
array_init(return_value);
- while(cur && cur->type != XML_ELEMENT_NODE) {
+ while (cur && cur->type != XML_ELEMENT_NODE) {
cur = cur->next;
}
if (cur != NULL) {
xmlNodePtr val;
val = cur->children;
while (val != NULL) {
- while(val && val->type != XML_ELEMENT_NODE) {
+ while (val && val->type != XML_ELEMENT_NODE) {
val = val->next;
}
if (val != NULL) {
@@ -211,14 +211,14 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction
if (Z_TYPE_P(return_value) == IS_ARRAY) {
if (param_count == 0) {
- zval_dtor(return_value);
- ZVAL_NULL(return_value);
+ zval_dtor(return_value);
+ ZVAL_NULL(return_value);
} else if (param_count == 1) {
- zval *tmp = *(zval**)Z_ARRVAL_P(return_value)->pListHead->pData;
- tmp->refcount++;
- zval_dtor(return_value);
- *return_value = *tmp;
- FREE_ZVAL(tmp);
+ zval *tmp = *(zval**)Z_ARRVAL_P(return_value)->pListHead->pData;
+ tmp->refcount++;
+ zval_dtor(return_value);
+ *return_value = *tmp;
+ FREE_ZVAL(tmp);
}
}
diff --git a/ext/soap/php_schema.c b/ext/soap/php_schema.c
index e0921e3d03..4659039d27 100644
--- a/ext/soap/php_schema.c
+++ b/ext/soap/php_schema.c
@@ -46,7 +46,7 @@ int load_schema(sdlPtr *sdl,xmlNodePtr schema)
xmlNodePtr trav, element, compType, simpleType, attribute;
xmlAttrPtr tns;
- if(!(*sdl)->types) {
+ if (!(*sdl)->types) {
(*sdl)->types = malloc(sizeof(HashTable));
zend_hash_init((*sdl)->types, 0, NULL, delete_type, 1);
}
@@ -93,12 +93,12 @@ static int schema_simpleType(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr simpleType,
xmlAttrPtr name, ns;
ns = get_attribute(simpleType->properties, "targetNamespace");
- if(ns == NULL) {
+ if (ns == NULL) {
ns = tsn;
}
name = get_attribute(simpleType->properties, "name");
- if(name != NULL) {
+ if (name != NULL) {
HashTable *ht;
smart_str key = {0};
sdlTypePtr newType, *ptr;
@@ -108,14 +108,14 @@ static int schema_simpleType(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr simpleType,
newType->name = strdup(name->children->content);
newType->namens = strdup(ns->children->content);
- if(cur_type == NULL) {
+ if (cur_type == NULL) {
ht = (*sdl)->types;
smart_str_appends(&key, newType->namens);
smart_str_appendc(&key, ':');
smart_str_appends(&key, newType->name);
smart_str_0(&key);
} else {
- if(cur_type->elements == NULL) {
+ if (cur_type->elements == NULL) {
cur_type->elements = malloc(sizeof(HashTable));
zend_hash_init(cur_type->elements, 0, NULL, delete_type, 1);
}
@@ -131,19 +131,19 @@ static int schema_simpleType(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr simpleType,
}
content = get_node(simpleType->children, "restriction");
- if(content != NULL) {
+ if (content != NULL) {
schema_restriction_simpleType(sdl, tsn, content, cur_type);
return TRUE;
}
content = get_node(simpleType->children, "list");
- if(content != NULL) {
+ if (content != NULL) {
schema_list(sdl, tsn, content, cur_type);
return TRUE;
}
content = get_node(simpleType->children, "union");
- if(content != NULL) {
+ if (content != NULL) {
schema_union(sdl, tsn, content, cur_type);
return TRUE;
}
@@ -189,15 +189,14 @@ static int schema_simpleContent(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr simpComp
xmlNodePtr content;
content = get_node(simpCompType->children, "restriction");
- if(content != NULL) {
+ if (content != NULL) {
schema_restriction_simpleContent(sdl, tsn, content, cur_type);
return TRUE;
}
content = get_node(simpCompType->children, "extension");
- if(content != NULL) {
+ if (content != NULL) {
schema_extension_simpleContent(sdl, tsn, content, cur_type);
-// php_error(E_ERROR, "Error parsing schema (doesn't support extensions on simpleContent)");
return TRUE;
}
@@ -219,60 +218,60 @@ static int schema_restriction_simpleType(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr
xmlAttrPtr base;
content = get_node(restType->children, "simpleType");
- if(content != NULL) {
+ if (content != NULL) {
schema_simpleType(sdl, tsn, content, cur_type);
return TRUE;
}
base = get_attribute(restType->properties, "base");
- if(base != NULL) {
+ if (base != NULL) {
char *type, *ns;
xmlNsPtr nsptr;
parse_namespace(base->children->content, &type, &ns);
nsptr = xmlSearchNs(restType->doc, restType, ns);
- if(nsptr != NULL) {
+ if (nsptr != NULL) {
cur_type->encode = get_encoder((*sdl), (char *)nsptr->href, type);
}
- if(type) {efree(type);}
- if(ns) {efree(ns);}
+ if (type) {efree(type);}
+ if (ns) {efree(ns);}
}
- if(cur_type->restrictions == NULL) {
+ if (cur_type->restrictions == NULL) {
cur_type->restrictions = malloc(sizeof(sdlRestrictions));
memset(cur_type->restrictions, 0, sizeof(sdlRestrictions));
}
trav = restType->children;
while (trav != NULL) {
- if(trav->type == XML_ELEMENT_NODE) {
- if(!strcmp(trav->name, "minExclusive")) {
+ if (trav->type == XML_ELEMENT_NODE) {
+ if (!strcmp(trav->name, "minExclusive")) {
schema_restriction_var_int(trav, &cur_type->restrictions->minExclusive);
- } else if(!strcmp(trav->name, "minInclusive")) {
+ } else if (!strcmp(trav->name, "minInclusive")) {
schema_restriction_var_int(trav, &cur_type->restrictions->minInclusive);
- } else if(!strcmp(trav->name, "maxExclusive")) {
+ } else if (!strcmp(trav->name, "maxExclusive")) {
schema_restriction_var_int(trav, &cur_type->restrictions->maxExclusive);
- } else if(!strcmp(trav->name, "maxInclusive")) {
+ } else if (!strcmp(trav->name, "maxInclusive")) {
schema_restriction_var_int(trav, &cur_type->restrictions->maxInclusive);
- } else if(!strcmp(trav->name, "totalDigits")) {
+ } else if (!strcmp(trav->name, "totalDigits")) {
schema_restriction_var_int(trav, &cur_type->restrictions->totalDigits);
- } else if(!strcmp(trav->name, "fractionDigits")) {
+ } else if (!strcmp(trav->name, "fractionDigits")) {
schema_restriction_var_int(trav, &cur_type->restrictions->fractionDigits);
- } else if(!strcmp(trav->name, "length")) {
+ } else if (!strcmp(trav->name, "length")) {
schema_restriction_var_int(trav, &cur_type->restrictions->length);
- } else if(!strcmp(trav->name, "minLength")) {
+ } else if (!strcmp(trav->name, "minLength")) {
schema_restriction_var_int(trav, &cur_type->restrictions->minLength);
- } else if(!strcmp(trav->name, "maxLength")) {
+ } else if (!strcmp(trav->name, "maxLength")) {
schema_restriction_var_int(trav, &cur_type->restrictions->maxLength);
- } else if(!strcmp(trav->name, "whiteSpace")) {
+ } else if (!strcmp(trav->name, "whiteSpace")) {
schema_restriction_var_char(trav, &cur_type->restrictions->whiteSpace);
- } else if(!strcmp(trav->name, "pattern")) {
+ } else if (!strcmp(trav->name, "pattern")) {
schema_restriction_var_char(trav, &cur_type->restrictions->pattern);
- } else if(!strcmp(trav->name, "enumeration")) {
+ } else if (!strcmp(trav->name, "enumeration")) {
sdlRestrictionCharPtr enumval = NULL;
schema_restriction_var_char(trav, &enumval);
- if(cur_type->restrictions->enumeration == NULL) {
+ if (cur_type->restrictions->enumeration == NULL) {
cur_type->restrictions->enumeration = malloc(sizeof(HashTable));
zend_hash_init(cur_type->restrictions->enumeration, 0, NULL, delete_schema_restriction_var_char, 1);
}
@@ -299,47 +298,47 @@ static int schema_restriction_complexContent(sdlPtr *sdl, xmlAttrPtr tsn, xmlNod
xmlNodePtr trav;
base = get_attribute(restType->properties, "base");
- if(base != NULL) {
+ if (base != NULL) {
char *type, *ns;
xmlNsPtr nsptr;
parse_namespace(base->children->content, &type, &ns);
nsptr = xmlSearchNs(restType->doc, restType, ns);
- if(nsptr != NULL) {
+ if (nsptr != NULL) {
cur_type->encode = get_encoder((*sdl), (char *)nsptr->href, type);
}
- if(type) {efree(type);}
- if(ns) {efree(ns);}
+ if (type) {efree(type);}
+ if (ns) {efree(ns);}
}
trav = restType->children;
while (trav != NULL) {
- if(trav->type == XML_ELEMENT_NODE) {
- if(!strcmp(trav->name, "group")) {
+ if (trav->type == XML_ELEMENT_NODE) {
+ if (!strcmp(trav->name, "group")) {
schema_group(sdl, tsn, trav, cur_type);
break;
- } else if(!strcmp(trav->name, "all")) {
+ } else if (!strcmp(trav->name, "all")) {
schema_all(sdl, tsn, trav, cur_type);
break;
- } else if(!strcmp(trav->name, "choice")) {
+ } else if (!strcmp(trav->name, "choice")) {
schema_choice(sdl, tsn, trav, cur_type);
break;
- } else if(!strcmp(trav->name, "sequence")) {
+ } else if (!strcmp(trav->name, "sequence")) {
schema_sequence(sdl, tsn, trav, cur_type);
break;
- } else if(!strcmp(trav->name, "attribute")) {
+ } else if (!strcmp(trav->name, "attribute")) {
schema_attribute(sdl, tsn, trav, cur_type);
}
}
trav = trav->next;
}
while (trav != NULL) {
- if(trav->type == XML_ELEMENT_NODE) {
- if(!strcmp(trav->name, "attribute")) {
+ if (trav->type == XML_ELEMENT_NODE) {
+ if (!strcmp(trav->name, "attribute")) {
schema_attribute(sdl, tsn, trav, cur_type);
}
}
- trav = trav->next;
+ trav = trav->next;
}
return TRUE;
@@ -359,58 +358,57 @@ static int schema_restriction_simpleContent(sdlPtr *sdl, xmlAttrPtr tsn, xmlNode
xmlAttrPtr base;
base = get_attribute(restType->properties, "base");
- if(base != NULL)
+ if (base != NULL)
cur_type->encode = get_encoder_from_prefix((*sdl), restType, base->children->content);
content = get_node(restType->children, "simpleType");
- if(content != NULL) {
+ if (content != NULL) {
schema_simpleType(sdl, tsn, content, cur_type);
return TRUE;
}
- if(cur_type->restrictions == NULL) {
+ if (cur_type->restrictions == NULL) {
cur_type->restrictions = malloc(sizeof(sdlRestrictions));
memset(cur_type->restrictions, 0, sizeof(sdlRestrictions));
}
trav = restType->children;
while (trav != NULL) {
- if(trav->type == XML_ELEMENT_NODE) {
- if(!strcmp(trav->name, "minExclusive")) {
+ if (trav->type == XML_ELEMENT_NODE) {
+ if (!strcmp(trav->name, "minExclusive")) {
schema_restriction_var_int(trav, &cur_type->restrictions->minExclusive);
- } else if(!strcmp(trav->name, "minInclusive")) {
+ } else if (!strcmp(trav->name, "minInclusive")) {
schema_restriction_var_int(trav, &cur_type->restrictions->minInclusive);
- } else if(!strcmp(trav->name, "maxExclusive")) {
+ } else if (!strcmp(trav->name, "maxExclusive")) {
schema_restriction_var_int(trav, &cur_type->restrictions->maxExclusive);
- } else if(!strcmp(trav->name, "maxInclusive")) {
+ } else if (!strcmp(trav->name, "maxInclusive")) {
schema_restriction_var_int(trav, &cur_type->restrictions->maxInclusive);
- } else if(!strcmp(trav->name, "totalDigits")) {
+ } else if (!strcmp(trav->name, "totalDigits")) {
schema_restriction_var_int(trav, &cur_type->restrictions->totalDigits);
- } else if(!strcmp(trav->name, "fractionDigits")) {
+ } else if (!strcmp(trav->name, "fractionDigits")) {
schema_restriction_var_int(trav, &cur_type->restrictions->fractionDigits);
- } else if(!strcmp(trav->name, "length")) {
+ } else if (!strcmp(trav->name, "length")) {
schema_restriction_var_int(trav, &cur_type->restrictions->length);
- } else if(!strcmp(trav->name, "minLength")) {
+ } else if (!strcmp(trav->name, "minLength")) {
schema_restriction_var_int(trav, &cur_type->restrictions->minLength);
- } else if(!strcmp(trav->name, "maxLength")) {
+ } else if (!strcmp(trav->name, "maxLength")) {
schema_restriction_var_int(trav, &cur_type->restrictions->maxLength);
- } else if(!strcmp(trav->name, "whiteSpace")) {
+ } else if (!strcmp(trav->name, "whiteSpace")) {
schema_restriction_var_char(trav, &cur_type->restrictions->whiteSpace);
- } else if(!strcmp(trav->name, "pattern")) {
+ } else if (!strcmp(trav->name, "pattern")) {
schema_restriction_var_char(trav, &cur_type->restrictions->pattern);
- } else if(!strcmp(trav->name, "enumeration")) {
+ } else if (!strcmp(trav->name, "enumeration")) {
sdlRestrictionCharPtr enumval = NULL;
schema_restriction_var_char(trav, &enumval);
- if(cur_type->restrictions->enumeration == NULL) {
+ if (cur_type->restrictions->enumeration == NULL) {
cur_type->restrictions->enumeration = malloc(sizeof(HashTable));
zend_hash_init(cur_type->restrictions->enumeration, 0, NULL, delete_schema_restriction_var_char, 1);
}
zend_hash_add(cur_type->restrictions->enumeration, enumval->value, strlen(enumval->value)+1, &enumval, sizeof(sdlRestrictionCharPtr), NULL);
-// zend_hash_next_index_insert(cur_type->restrictions->enumeration, &enumval, sizeof(sdlRestrictionCharPtr), NULL);
}
}
- trav = trav->next;
+ trav = trav->next;
}
return TRUE;
@@ -420,26 +418,26 @@ static int schema_restriction_var_int(xmlNodePtr val, sdlRestrictionIntPtr *valp
{
xmlAttrPtr fixed, value, id;
- if((*valptr) == NULL) {
+ if ((*valptr) == NULL) {
(*valptr) = malloc(sizeof(sdlRestrictionInt));
}
memset((*valptr), 0, sizeof(sdlRestrictionInt));
fixed = get_attribute(val->properties, "fixed");
(*valptr)->fixed = FALSE;
- if(fixed != NULL) {
- if(!strcmp(fixed->children->content, "true") ||
+ if (fixed != NULL) {
+ if (!strcmp(fixed->children->content, "true") ||
!strcmp(fixed->children->content, "1"))
(*valptr)->fixed = TRUE;
}
id = get_attribute(val->properties, "id");
- if(id != NULL) {
+ if (id != NULL) {
(*valptr)->id = strdup(id->children->content);
}
value = get_attribute(val->properties, "value");
- if(value == NULL) {
+ if (value == NULL) {
php_error(E_ERROR, "Error parsing wsdl schema \"missing restriction value\"");
}
@@ -463,27 +461,27 @@ static int schema_restriction_var_char(xmlNodePtr val, sdlRestrictionCharPtr *va
{
xmlAttrPtr fixed, value, id;
- if((*valptr) == NULL) {
+ if ((*valptr) == NULL) {
(*valptr) = malloc(sizeof(sdlRestrictionChar));
}
memset((*valptr), 0, sizeof(sdlRestrictionChar));
fixed = get_attribute(val->properties, "fixed");
(*valptr)->fixed = FALSE;
- if(fixed != NULL) {
- if(!strcmp(fixed->children->content, "true") ||
- !strcmp(fixed->children->content, "1")) {
+ if (fixed != NULL) {
+ if (!strcmp(fixed->children->content, "true") ||
+ !strcmp(fixed->children->content, "1")) {
(*valptr)->fixed = TRUE;
}
}
id = get_attribute(val->properties, "id");
- if(id != NULL) {
+ if (id != NULL) {
(*valptr)->id = strdup(id->children->content);
}
value = get_attribute(val->properties, "value");
- if(value == NULL) {
+ if (value == NULL) {
php_error(E_ERROR, "Error parsing wsdl schema \"missing restriction value\"");
}
@@ -495,10 +493,10 @@ void delete_schema_restriction_var_char(void *srvc)
{
sdlRestrictionCharPtr ptr = *((sdlRestrictionCharPtr*)srvc);
if (ptr) {
- if(ptr->id) {
+ if (ptr->id) {
free(ptr->id);
}
- if(ptr->value) {
+ if (ptr->value) {
free(ptr->value);
}
free(ptr);
@@ -536,25 +534,25 @@ static int schema_extension_complexContent(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodeP
base = get_attribute(extType->properties, "base");
content = get_node(extType->children, "group");
- if(content != NULL) {
+ if (content != NULL) {
schema_group(sdl, tsn, content, cur_type);
return TRUE;
}
content = get_node(extType->children, "all");
- if(content != NULL) {
+ if (content != NULL) {
schema_all(sdl, tsn, content, cur_type);
return TRUE;
}
content = get_node(extType->children, "choice");
- if(content != NULL) {
+ if (content != NULL) {
schema_choice(sdl, tsn, content, cur_type);
return TRUE;
}
content = get_node(extType->children, "sequence");
- if(content != NULL) {
+ if (content != NULL) {
schema_sequence(sdl, tsn, content, cur_type);
return TRUE;
}
@@ -594,24 +592,24 @@ static int schema_group(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr groupType, sdlTy
xmlAttrPtr name;
name = get_attribute(groupType->properties, "name");
- if(name != NULL) {
+ if (name != NULL) {
}
content = get_node(groupType->children, "all");
- if(content != NULL) {
+ if (content != NULL) {
schema_all(sdl, tsn, content, cur_type);
return TRUE;
}
content = get_node(groupType->children, "choice");
- if(content != NULL) {
+ if (content != NULL) {
schema_choice(sdl, tsn, content, cur_type);
return TRUE;
}
content = get_node(groupType->children, "sequence");
- if(content != NULL) {
+ if (content != NULL) {
schema_sequence(sdl, tsn, content, cur_type);
return TRUE;
}
@@ -682,16 +680,16 @@ static int schema_sequence(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr seqType, sdlT
trav = seqType->children;
while (trav != NULL) {
- if(trav->type == XML_ELEMENT_NODE) {
- if(!strcmp(trav->name, "element")) {
+ if (trav->type == XML_ELEMENT_NODE) {
+ if (!strcmp(trav->name, "element")) {
schema_element(sdl, tsn, trav, cur_type);
- } else if(!strcmp(trav->name, "group")) {
+ } else if (!strcmp(trav->name, "group")) {
schema_group(sdl, tsn, trav, cur_type);
- } else if(!strcmp(trav->name, "choice")) {
+ } else if (!strcmp(trav->name, "choice")) {
schema_choice(sdl, tsn, trav, cur_type);
- } else if(!strcmp(trav->name, "sequence")) {
+ } else if (!strcmp(trav->name, "sequence")) {
schema_sequence(sdl, tsn, trav, cur_type);
- } else if(!strcmp(trav->name, "any")) {
+ } else if (!strcmp(trav->name, "any")) {
schema_any(sdl, tsn, trav, cur_type);
}
}
@@ -719,14 +717,13 @@ static int schema_complexContent(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr compCon
xmlNodePtr content;
content = get_node(compCont->children, "restriction");
- if(content != NULL) {
+ if (content != NULL) {
schema_restriction_complexContent(sdl, tsn, content, cur_type);
return TRUE;
}
content = get_node(compCont->children, "extension");
- if(content != NULL) {
-// php_error(E_ERROR, "Error parsing schema (doesn't support extensions on complexContent)");
+ if (content != NULL) {
schema_extension_complexContent(sdl, tsn, content, cur_type);
return TRUE;
}
@@ -754,12 +751,12 @@ static int schema_complexType(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr compType,
attrs = compType->properties;
ns = get_attribute(attrs, "targetNamespace");
- if(ns == NULL) {
+ if (ns == NULL) {
ns = tsn;
}
name = get_attribute(attrs, "name");
- if(name) {
+ if (name) {
HashTable *ht;
sdlTypePtr newType, *ptr;
smart_str key = {0};
@@ -769,14 +766,14 @@ static int schema_complexType(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr compType,
newType->name = strdup(name->children->content);
newType->namens = strdup(ns->children->content);
- if(cur_type == NULL) {
+ if (cur_type == NULL) {
ht = (*sdl)->types;
smart_str_appends(&key, newType->namens);
smart_str_appendc(&key, ':');
smart_str_appends(&key, newType->name);
smart_str_0(&key);
} else {
- if(cur_type->elements == NULL) {
+ if (cur_type->elements == NULL) {
cur_type->elements = malloc(sizeof(HashTable));
zend_hash_init(cur_type->elements, 0, NULL, delete_type, 1);
}
@@ -795,38 +792,38 @@ static int schema_complexType(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr compType,
}
content = get_node(compType->children, "simpleContent");
- if(content != NULL) {
+ if (content != NULL) {
schema_simpleContent(sdl, tsn, content, cur_type);
return TRUE;
}
content = get_node(compType->children, "complexContent");
- if(content != NULL) {
+ if (content != NULL) {
schema_complexContent(sdl, tsn, content, cur_type);
return TRUE;
}
/* (group | all | choice | sequence) */
content = get_node(compType->children, "group");
- if(content != NULL) {
+ if (content != NULL) {
schema_group(sdl, tsn, content, cur_type);
return TRUE;
}
content = get_node(compType->children, "all");
- if(content != NULL) {
+ if (content != NULL) {
schema_all(sdl, tsn, content, cur_type);
return TRUE;
}
content = get_node(compType->children, "choice");
- if(content != NULL) {
+ if (content != NULL) {
schema_choice(sdl, tsn, content, cur_type);
return TRUE;
}
content = get_node(compType->children, "sequence");
- if(content != NULL) {
+ if (content != NULL) {
schema_sequence(sdl, tsn, content, cur_type);
}
@@ -860,7 +857,7 @@ static int schema_element(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr element, sdlTy
attrs = element->properties;
ns = get_attribute(attrs, "targetNamespace");
- if(ns == NULL) {
+ if (ns == NULL) {
ns = tsn;
}
@@ -869,7 +866,7 @@ static int schema_element(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr element, sdlTy
name = get_attribute(attrs, "ref");
}
- if(name) {
+ if (name) {
HashTable *addHash;
sdlTypePtr newType, *tmp;
smart_str key = {0};
@@ -883,13 +880,13 @@ static int schema_element(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr element, sdlTy
newType->min_occurs = 1;
newType->max_occurs = 1;
- if(cur_type == NULL) {
+ if (cur_type == NULL) {
addHash = (*sdl)->types;
smart_str_appends(&key, newType->namens);
smart_str_appendc(&key, ':');
smart_str_appends(&key, newType->name);
} else {
- if(cur_type->elements == NULL) {
+ if (cur_type->elements == NULL) {
cur_type->elements = malloc(sizeof(HashTable));
zend_hash_init(cur_type->elements, 0, NULL, delete_type, 1);
}
@@ -900,13 +897,15 @@ static int schema_element(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr element, sdlTy
smart_str_0(&key);
zend_hash_add(addHash, key.c, key.len + 1, &newType, sizeof(sdlTypePtr), (void **)&tmp);
cur_type = (*tmp);
-// create_encoder((*sdl), cur_type, ns->children->content, name->children->content);
+/*
+ create_encoder((*sdl), cur_type, ns->children->content, name->children->content);
+*/
smart_str_free(&key);
}
curattr = get_attribute(attrs, "maxOccurs");
- if(curattr) {
- if(!strcmp(curattr->children->content, "unbounded")) {
+ if (curattr) {
+ if (!strcmp(curattr->children->content, "unbounded")) {
cur_type->max_occurs = -1;
} else {
cur_type->max_occurs = atoi(curattr->children->content);
@@ -914,15 +913,15 @@ static int schema_element(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr element, sdlTy
}
curattr = get_attribute(attrs, "minOccurs");
- if(curattr) {
+ if (curattr) {
cur_type->min_occurs = atoi(curattr->children->content);
}
/* nillable = boolean : false */
attrs = element->properties;
curattr = get_attribute(attrs, "nillable");
- if(curattr) {
- if(!stricmp(curattr->children->content, "true") ||
+ if (curattr) {
+ if (!stricmp(curattr->children->content, "true") ||
!stricmp(curattr->children->content, "1")) {
cur_type->nillable = TRUE;
} else {
@@ -934,34 +933,42 @@ static int schema_element(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr element, sdlTy
/* type = QName */
curattr = get_attribute(attrs, "type");
- if(!curattr) {
+ if (!curattr) {
curattr = name;
}
- if(curattr) {
+ if (curattr) {
char *cptype, *str_ns;
xmlNsPtr nsptr;
parse_namespace(curattr->children->content, &cptype, &str_ns);
-// if(str_ns)
+/*
+ if (str_ns) {
+*/
nsptr = xmlSearchNs(element->doc, element, str_ns);
-// else
-// nsptr = xmlSearchNsByHref(element->doc, element, ns->children->content);
+/*
+ } else {
+ nsptr = xmlSearchNsByHref(element->doc, element, ns->children->content);
+ }
+*/
cur_type->encode = get_create_encoder((*sdl), cur_type, (char *)nsptr->href, (char *)cptype);
- if(str_ns) {efree(str_ns);}
- if(cptype) {efree(cptype);}
+ if (str_ns) {efree(str_ns);}
+ if (cptype) {efree(cptype);}
}
-// if(cur_type->max_occurs == -1 || cur_type->max_occurs > 1)
-// cur_type->encode = get_conversion(SOAP_ENC_ARRAY);
+/*
+ if (cur_type->max_occurs == -1 || cur_type->max_occurs > 1) {
+ cur_type->encode = get_conversion(SOAP_ENC_ARRAY);
+ }
+*/
content = get_node(element->children, "simpleType");
- if(content) {
+ if (content) {
schema_simpleType(sdl, tsn, content, cur_type);
}
content = get_node(element->children, "complexType");
- if(content) {
+ if (content) {
schema_complexType(sdl, tsn, content, cur_type);
}
@@ -992,36 +999,36 @@ static int schema_attribute(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr attrType, sd
newAttr = malloc(sizeof(sdlAttribute));
memset(newAttr, 0, sizeof(sdlAttribute));
- if(cur_type->attributes == NULL) {
+ if (cur_type->attributes == NULL) {
cur_type->attributes = malloc(sizeof(HashTable));
zend_hash_init(cur_type->attributes, 0, NULL, delete_attribute, 1);
}
trav = attrType->properties;
FOREACHATTRNODE(trav, NULL, attr) {
- if(attr_is_equal_ex(trav, "default", SCHEMA_NAMESPACE)) {
+ if (attr_is_equal_ex(trav, "default", SCHEMA_NAMESPACE)) {
newAttr->def = strdup(attr->children->content);
- } else if(attr_is_equal_ex(trav, "fixed", SCHEMA_NAMESPACE)) {
+ } else if (attr_is_equal_ex(trav, "fixed", SCHEMA_NAMESPACE)) {
newAttr->fixed = strdup(attr->children->content);
- } else if(attr_is_equal_ex(trav, "form", SCHEMA_NAMESPACE)) {
+ } else if (attr_is_equal_ex(trav, "form", SCHEMA_NAMESPACE)) {
newAttr->form = strdup(attr->children->content);
- } else if(attr_is_equal_ex(trav, "id", SCHEMA_NAMESPACE)) {
+ } else if (attr_is_equal_ex(trav, "id", SCHEMA_NAMESPACE)) {
newAttr->id = strdup(attr->children->content);
- } else if(attr_is_equal_ex(trav, "name", SCHEMA_NAMESPACE)) {
+ } else if (attr_is_equal_ex(trav, "name", SCHEMA_NAMESPACE)) {
newAttr->name = strdup(attr->children->content);
- } else if(attr_is_equal_ex(trav, "ref", SCHEMA_NAMESPACE)) {
+ } else if (attr_is_equal_ex(trav, "ref", SCHEMA_NAMESPACE)) {
newAttr->ref= strdup(attr->children->content);
- } else if(attr_is_equal_ex(trav, "type", SCHEMA_NAMESPACE)) {
+ } else if (attr_is_equal_ex(trav, "type", SCHEMA_NAMESPACE)) {
newAttr->type = strdup(attr->children->content);
- } else if(attr_is_equal_ex(trav, "use", SCHEMA_NAMESPACE)) {
+ } else if (attr_is_equal_ex(trav, "use", SCHEMA_NAMESPACE)) {
newAttr->use = strdup(attr->children->content);
} else {
xmlNsPtr nsPtr = attr_find_ns(trav);
- if(strcmp(nsPtr->href, SCHEMA_NAMESPACE)) {
+ if (strcmp(nsPtr->href, SCHEMA_NAMESPACE)) {
smart_str key2 = {0};
- if(!newAttr->extraAttributes) {
+ if (!newAttr->extraAttributes) {
newAttr->extraAttributes = malloc(sizeof(HashTable));
zend_hash_init(newAttr->extraAttributes, 0, NULL, NULL, 1);
}
@@ -1038,10 +1045,10 @@ static int schema_attribute(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr attrType, sd
ENDFOREACH(trav);
- if(newAttr->ref || newAttr->name) {
+ if (newAttr->ref || newAttr->name) {
xmlNsPtr ns;
- if(newAttr->ref) {
+ if (newAttr->ref) {
char *value, *prefix = NULL;
parse_namespace(newAttr->ref, &value, &prefix);
@@ -1050,8 +1057,8 @@ static int schema_attribute(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr attrType, sd
smart_str_appendc(&key, ':');
smart_str_appends(&key, value);
- if(value) {efree(value);}
- if(prefix) {efree(prefix);}
+ if (value) {efree(value);}
+ if (prefix) {efree(prefix);}
} else {
ns = node_find_ns(attrType);
smart_str_appends(&key, ns->href);
@@ -1059,7 +1066,7 @@ static int schema_attribute(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr attrType, sd
smart_str_appends(&key, newAttr->name);
}
- if(ns) {
+ if (ns) {
smart_str_0(&key);
zend_hash_add(cur_type->attributes, key.c, key.len + 1, &newAttr, sizeof(sdlAttributePtr), NULL);
smart_str_free(&key);
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, &param, 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, &param, 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);
}
diff --git a/ext/soap/php_sdl.h b/ext/soap/php_sdl.h
index fd0e1ef77b..1d37882e3c 100644
--- a/ext/soap/php_sdl.h
+++ b/ext/soap/php_sdl.h
@@ -14,8 +14,7 @@
#define SOAP_ENCODED 1
#define SOAP_LITERAL 2
-struct _sdl
-{
+struct _sdl {
xmlDocPtr doc; /* pointer to the parsed xml file */
HashTable *types; /* array of sdlTypesPtr */
HashTable *encoders; /* array of encodePtr */
@@ -24,8 +23,7 @@ struct _sdl
char *source;
};
-struct _sdlBinding
-{
+struct _sdlBinding {
char *name;
HashTable *functions;
char *location;
@@ -34,22 +32,19 @@ struct _sdlBinding
};
/* Soap Binding Specfic stuff */
-struct _sdlSoapBinding
-{
+struct _sdlSoapBinding {
char *transport;
int style;
};
-struct _sdlSoapBindingFunctionBody
-{
+struct _sdlSoapBindingFunctionBody {
char *ns;
int use;
char *parts; /* not implemented yet */
char *encodingStyle; /* not implemented yet */
};
-struct _sdlSoapBindingFunction
-{
+struct _sdlSoapBindingFunction {
char *soapAction;
int style;
@@ -66,22 +61,19 @@ struct _sdlHttpBinding
};
*********************************************/
-struct _sdlRestrictionInt
-{
+struct _sdlRestrictionInt {
int value;
char fixed;
char *id;
};
-struct _sdlRestrictionChar
-{
+struct _sdlRestrictionChar {
char *value;
char fixed;
char *id;
};
-struct _sdlRestrictions
-{
+struct _sdlRestrictions {
HashTable *enumeration; /* array of sdlRestrictionCharPtr */
sdlRestrictionIntPtr minExclusive;
sdlRestrictionIntPtr minInclusive;
@@ -96,8 +88,7 @@ struct _sdlRestrictions
sdlRestrictionCharPtr pattern;
};
-struct _sdlType
-{
+struct _sdlType {
char *name;
char *namens;
int nillable;
@@ -109,15 +100,13 @@ struct _sdlType
encodePtr encode;
};
-struct _sdlParam
-{
+struct _sdlParam {
int order;
encodePtr encode;
char *paramName;
};
-struct _sdlFunction
-{
+struct _sdlFunction {
char *functionName;
char *requestName;
char *responseName;
@@ -127,8 +116,7 @@ struct _sdlFunction
void *bindingAttributes;
};
-struct _sdlAttribute
-{
+struct _sdlAttribute {
char *def;
char *fixed;
char *form;
diff --git a/ext/soap/php_soap.h b/ext/soap/php_soap.h
index d65dcfdbaf..b5da35ca86 100644
--- a/ext/soap/php_soap.h
+++ b/ext/soap/php_soap.h
@@ -58,31 +58,26 @@ extern int le_url;
extern int le_service;
-struct _soapHeaderHandler
-{
+struct _soapHeaderHandler {
char *ns;
int type;
- struct _function_handler
- {
+ struct _function_handler {
char *functionName;
char *type;
} function_handler;
- struct _class_handler
- {
+ struct _class_handler {
zend_class_entry *ce;
} class_handler;
};
-struct _soapMapping
-{
+struct _soapMapping {
char *ns;
char *ctype;
int type;
- struct _map_functions
- {
+ struct _map_functions {
zval *to_xml_before;
zval *to_xml;
zval *to_xml_after;
@@ -91,25 +86,21 @@ struct _soapMapping
zval *to_zval_after;
} map_functions;
- struct _map_class
- {
+ struct _map_class {
int type;
zend_class_entry *ce;
} map_class;
};
-struct _soapService
-{
+struct _soapService {
sdlPtr sdl;
- struct _soap_functions
- {
+ struct _soap_functions {
HashTable *ft;
int functions_all;
} soap_functions;
- struct _soap_class
- {
+ struct _soap_class {
zend_class_entry *ce;
zval **argv;
int argc;
@@ -228,29 +219,29 @@ int my_call_user_function(HashTable *function_table, zval **object_pp, zval *fun
#define FOREACHATTRNODE(n,c,i) \
- do \
- { \
- if(n == NULL) \
+ do { \
+ if (n == NULL) { \
break; \
- if(c) \
+ } \
+ if (c) { \
i = get_attribute(n,c); \
- else \
+ } else { \
i = n; \
- if(i != NULL) \
- { \
+ } \
+ if (i != NULL) { \
n = i;
#define FOREACHNODE(n,c,i) \
- do \
- { \
- if(n == NULL) \
+ do { \
+ if (n == NULL) { \
break; \
- if(c) \
+ } \
+ if (c) { \
i = get_node(n,c); \
- else \
+ } else { \
i = n; \
- if(i != NULL) \
- { \
+ } \
+ if(i != NULL) { \
n = i;
#define ENDFOREACH(n) \
@@ -258,19 +249,19 @@ int my_call_user_function(HashTable *function_table, zval **object_pp, zval *fun
} while ((n = n->next));
#define ZERO_PARAM() \
- if(ZEND_NUM_ARGS() != 0) \
+ if (ZEND_NUM_ARGS() != 0) \
WRONG_PARAM_COUNT;
#define ONE_PARAM(p) \
- if(ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &p) == FAILURE) \
+ if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &p) == FAILURE) \
WRONG_PARAM_COUNT;
#define TWO_PARAM(p,p1) \
- if(ZEND_NUM_ARGS() != 1 || getParameters(ht, 2, &p, &p1) == FAILURE) \
+ if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 2, &p, &p1) == FAILURE) \
WRONG_PARAM_COUNT;
#define THREE_PARAM(p,p1,p2) \
- if(ZEND_NUM_ARGS() != 1 || getParameters(ht, 3, &p, &p1, &p2) == FAILURE) \
+ if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 3, &p, &p1, &p2) == FAILURE) \
WRONG_PARAM_COUNT;
#define FETCH_THIS_PORT(ss) \
@@ -291,12 +282,11 @@ int my_call_user_function(HashTable *function_table, zval **object_pp, zval *fun
{ \
zval *__thisObj,**__tmp; \
GET_THIS_OBJECT(__thisObj) \
- if(FIND_SDL_PROPERTY(__thisObj,__tmp) != FAILURE) \
- { \
+ if(FIND_SDL_PROPERTY(__thisObj,__tmp) != FAILURE) { \
FETCH_SDL_RES(ss,__tmp); \
- } \
- else \
+ } else { \
ss = NULL; \
+ } \
}
#define FIND_SDL_PROPERTY(ss,tmp) zend_hash_find(Z_OBJPROP_P(ss), "sdl", sizeof("sdl"), (void **)&tmp)
@@ -306,12 +296,11 @@ int my_call_user_function(HashTable *function_table, zval **object_pp, zval *fun
{ \
zval *__thisObj,**__tmp; \
GET_THIS_OBJECT(__thisObj) \
- if(FIND_SERVICE_PROPERTY(__thisObj,__tmp) != FAILURE) \
- { \
+ if(FIND_SERVICE_PROPERTY(__thisObj,__tmp) != FAILURE) { \
FETCH_SERVICE_RES(ss,__tmp); \
- } \
- else \
+ } else { \
ss = NULL; \
+ } \
}
#define FIND_SERVICE_PROPERTY(ss,tmp) zend_hash_find(Z_OBJPROP_P(ss), "service", sizeof("service"), (void **)&tmp)
@@ -321,12 +310,11 @@ int my_call_user_function(HashTable *function_table, zval **object_pp, zval *fun
{ \
zval *__thisObj,**__tmp; \
GET_THIS_OBJECT(__thisObj) \
- if(FIND_URL_PROPERTY(__thisObj,__tmp) != FAILURE) \
- { \
+ if(FIND_URL_PROPERTY(__thisObj,__tmp) != FAILURE) { \
FETCH_URL_RES(ss,__tmp); \
- } \
- else \
+ } else { \
ss = NULL; \
+ } \
}
#define FIND_URL_PROPERTY(ss,tmp) zend_hash_find(Z_OBJPROP_P(ss), "httpurl", sizeof("httpurl"), (void **)&tmp)
@@ -336,12 +324,11 @@ int my_call_user_function(HashTable *function_table, zval **object_pp, zval *fun
{ \
zval *__thisObj,**__tmp; \
GET_THIS_OBJECT(__thisObj) \
- if(FIND_SOCKET_PROPERTY(__thisObj,__tmp) != FAILURE) \
- { \
+ if(FIND_SOCKET_PROPERTY(__thisObj,__tmp) != FAILURE) { \
FETCH_SOCKET_RES(ss,__tmp); \
- } \
- else \
+ } else { \
ss = NULL; \
+ } \
}
#define FIND_SOCKET_PROPERTY(ss,tmp) zend_hash_find(Z_OBJPROP_P(ss), "httpsocket", sizeof("httpsocket"), (void **)&tmp)
@@ -349,8 +336,7 @@ int my_call_user_function(HashTable *function_table, zval **object_pp, zval *fun
#define GET_THIS_OBJECT(o) \
o = getThis(); \
- if (!o) \
- { \
+ if (!o) { \
php_error(E_WARNING, "Cannot Get Class Info"); \
return; \
}
diff --git a/ext/soap/php_xml.c b/ext/soap/php_xml.c
index b2b2b03786..4ccfce4917 100644
--- a/ext/soap/php_xml.c
+++ b/ext/soap/php_xml.c
@@ -29,37 +29,39 @@ int php_stream_xmlIO_close(void *context)
xmlNsPtr attr_find_ns(xmlAttrPtr node)
{
- if(node->ns)
+ if (node->ns) {
return node->ns;
- else if(node->parent->ns)
+ } else if (node->parent->ns) {
return node->parent->ns;
- else
+ } else {
return xmlSearchNs(node->doc, node->parent, NULL);
+ }
}
xmlNsPtr node_find_ns(xmlNodePtr node)
{
- if(node->ns)
+ if (node->ns) {
return node->ns;
- else
+ } else {
return xmlSearchNs(node->doc, node, NULL);
+ }
}
int attr_is_equal_ex(xmlAttrPtr node, char *name, char *ns)
{
- if(!strcmp(node->name, name))
- {
- if(ns)
- {
+ if (!strcmp(node->name, name)) {
+ if (ns) {
xmlNsPtr nsPtr;
- if(node->ns)
+ if (node->ns) {
nsPtr = node->ns;
- else if(node->parent->ns)
+ } else if (node->parent->ns) {
nsPtr = node->parent->ns;
- else
+ } else {
nsPtr = xmlSearchNs(node->doc, node->parent, NULL);
- if(!strcmp(nsPtr->href, ns))
+ }
+ if (!strcmp(nsPtr->href, ns)) {
return TRUE;
+ }
return FALSE;
}
return TRUE;
@@ -69,17 +71,17 @@ int attr_is_equal_ex(xmlAttrPtr node, char *name, char *ns)
int node_is_equal_ex(xmlNodePtr node, char *name, char *ns)
{
- if(!strcmp(node->name, name))
- {
- if(ns)
- {
+ if (!strcmp(node->name, name)) {
+ if (ns) {
xmlNsPtr nsPtr;
- if(node->ns)
+ if (node->ns) {
nsPtr = node->ns;
- else
+ } else {
nsPtr = xmlSearchNs(node->doc, node, NULL);
- if(!strcmp(nsPtr->href, ns))
+ }
+ if (!strcmp(nsPtr->href, ns)) {
return TRUE;
+ }
return FALSE;
}
return TRUE;
@@ -91,8 +93,9 @@ xmlAttrPtr get_attribute_ex(xmlAttrPtr node, char *name, char *ns)
{
xmlAttrPtr trav = node;
while (trav!=NULL) {
- if(attr_is_equal_ex(trav, name, ns))
+ if (attr_is_equal_ex(trav, name, ns)) {
return trav;
+ }
trav = trav->next;
}
return NULL;
@@ -102,8 +105,9 @@ xmlNodePtr get_node_ex(xmlNodePtr node, char *name, char *ns)
{
xmlNodePtr trav = node;
while (trav!=NULL) {
- if(node_is_equal_ex(trav, name, ns))
+ if (node_is_equal_ex(trav, name, ns)) {
return trav;
+ }
trav = trav->next;
}
return NULL;
@@ -113,16 +117,15 @@ xmlNodePtr get_node_recurisve_ex(xmlNodePtr node, char *name, char *ns)
{
xmlNodePtr trav = node;
while (trav != NULL) {
- if(node_is_equal_ex(trav, name, ns))
+ if (node_is_equal_ex(trav, name, ns)) {
return trav;
- else
- {
- if(node->children != NULL)
- {
+ } else {
+ if (node->children != NULL) {
xmlNodePtr tmp;
tmp = get_node_recurisve_ex(node->children, name, ns);
- if(tmp)
+ if (tmp) {
return tmp;
+ }
}
}
trav = trav->next;
@@ -136,26 +139,25 @@ xmlNodePtr get_node_with_attribute_ex(xmlNodePtr node, char *name, char *name_ns
xmlAttrPtr attr;
while (trav != NULL) {
- if(name != NULL)
- {
+ if (name != NULL) {
cur = get_node_ex(trav, name, name_ns);
- if(!cur)
+ if (!cur) {
return cur;
- }
- else
+ }
+ } else {
cur = trav;
+ }
attr = get_attribute_ex(cur->properties, attribute, attr_ns);
- if(attr != NULL && strcmp(attr->children->content, value) == 0)
+ if (attr != NULL && strcmp(attr->children->content, value) == 0) {
return cur;
- else
- {
- if(cur->children != NULL)
- {
+ } else {
+ if (cur->children != NULL) {
xmlNodePtr tmp;
tmp = get_node_with_attribute_ex(cur->children, name, name_ns, attribute, value, attr_ns);
- if(tmp)
+ if (tmp) {
return tmp;
+ }
}
}
trav = trav->next;
@@ -169,26 +171,25 @@ xmlNodePtr get_node_with_attribute_recursive_ex(xmlNodePtr node, char *name, cha
xmlAttrPtr attr;
while (trav != NULL) {
- if(name != NULL)
- {
+ if (name != NULL) {
cur = get_node_recurisve_ex(trav, name, name_ns);
- if(!cur)
+ if (!cur) {
return cur;
- }
- else
+ }
+ } else {
cur = trav;
+ }
attr = get_attribute_ex(cur->properties, attribute, attr_ns);
- if(attr != NULL && strcmp(attr->children->content, value) == 0)
+ if (attr != NULL && strcmp(attr->children->content, value) == 0) {
return cur;
- else
- {
- if(cur->children != NULL)
- {
+ } else {
+ if (cur->children != NULL) {
xmlNodePtr tmp;
tmp = get_node_with_attribute_recursive_ex(cur->children, name, name_ns, attribute, value, attr_ns);
- if(tmp)
+ if (tmp) {
return tmp;
+ }
}
}
trav = trav->next;
@@ -201,15 +202,14 @@ xmlNodePtr check_and_resolve_href(xmlNodePtr data)
xmlAttrPtr href;
xmlNodePtr ret = data;
- if(!data || !data->properties)
+ if (!data || !data->properties) {
return ret;
+ }
href = get_attribute(data->properties, "href");
- if(href)
- {
+ if (href) {
/* Internal href try and find node */
- if(href->children->content[0] == '#')
- {
+ if (href->children->content[0] == '#') {
ret = get_node_with_attribute_recursive(data->doc->children, NULL, "id", &href->children->content[1]);
}
/* External href....? */
@@ -222,13 +222,10 @@ int parse_namespace(const char *inval, char **value, char **namespace)
{
char *found = strchr(inval, ':');
- if(found != NULL && found != inval)
- {
+ if (found != NULL && found != inval) {
(*namespace) = estrndup(inval, found - inval);
(*value) = estrdup(++found);
- }
- else
- {
+ } else {
(*value) = estrdup(inval);
(*namespace) = NULL;
}
diff --git a/ext/soap/soap.c b/ext/soap/soap.c
index f34984d7d4..8755754208 100644
--- a/ext/soap/soap.c
+++ b/ext/soap/soap.c
@@ -200,31 +200,25 @@ static void php_soap_init_globals(zend_soap_globals *soap_globals)
soap_globals->overrides = NULL;
i = 0;
- do
- {
+ do {
enc = (long)&defaultEncoding[i];
/* If has a ns and a str_type then index it */
- if(defaultEncoding[i].details.type_str)
- {
- if(defaultEncoding[i].details.ns != NULL)
- {
+ if (defaultEncoding[i].details.type_str) {
+ if (defaultEncoding[i].details.ns != NULL) {
char *ns_type;
ns_type = emalloc(strlen(defaultEncoding[i].details.ns) + strlen(defaultEncoding[i].details.type_str) + 2);
sprintf(ns_type, "%s:%s", defaultEncoding[i].details.ns, defaultEncoding[i].details.type_str);
zend_hash_add(soap_globals->defEnc, ns_type, strlen(ns_type) + 1, &enc, sizeof(encodePtr), NULL);
efree(ns_type);
- }
- else
- {
+ } else {
zend_hash_add(soap_globals->defEnc, defaultEncoding[i].details.type_str, strlen(defaultEncoding[i].details.type_str) + 1, &enc, sizeof(encodePtr), NULL);
}
}
/* Index everything by number */
zend_hash_index_update(soap_globals->defEncIndex, defaultEncoding[i].details.type, &enc, sizeof(encodePtr), NULL);
i++;
- }
- while(defaultEncoding[i].details.type != END_KNOWN_TYPES);
+ } while (defaultEncoding[i].details.type != END_KNOWN_TYPES);
/* hash by namespace */
zend_hash_add(soap_globals->defEncNs, XSD_1999_NAMESPACE, sizeof(XSD_1999_NAMESPACE), XSD_NS_PREFIX, sizeof(XSD_NS_PREFIX), NULL);
@@ -279,7 +273,8 @@ PHP_MINIT_FUNCTION(soap)
*/
#ifdef ZEND_ENGINE_2
{
- zend_internal_function fe;
+ zend_internal_function fe;
+
fe.type = ZEND_INTERNAL_FUNCTION;
fe.handler = zif_soapobject___call;
fe.function_name = NULL;
@@ -290,7 +285,7 @@ PHP_MINIT_FUNCTION(soap)
fe.arg_info = NULL;
fe.pass_rest_by_reference = 0;
- INIT_OVERLOADED_CLASS_ENTRY(ce, PHP_SOAP_CLASSNAME, soap_client_functions,
+ INIT_OVERLOADED_CLASS_ENTRY(ce, PHP_SOAP_CLASSNAME, soap_client_functions,
(zend_function *)&fe, NULL, NULL);
soap_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
}
@@ -397,9 +392,9 @@ PHP_MINIT_FUNCTION(soap)
PS_SERIALIZER_ENCODE_FUNC(soap)
{
/*
- char *key; \
- uint key_length; \
- ulong num_key; \
+ char *key;
+ uint key_length;
+ ulong num_key;
zval **struc;
wddx_packet *packet;
@@ -489,8 +484,9 @@ PHP_FUNCTION(soap_encode_to_xml)
char *name;
int found, name_len;
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", &name, &name_len, &pzval) == FAILURE)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", &name, &name_len, &pzval) == FAILURE) {
php_error(E_ERROR, "wrong number of parameters to soap_encode_to_xml");
+ }
enc = get_conversion(Z_TYPE_P(pzval));
ret = php_domobject_new(seralize_zval(pzval, NULL, name, SOAP_ENCODED), &found, NULL TSRMLS_CC);
@@ -504,11 +500,13 @@ PHP_FUNCTION(soap_encode_to_zval)
zval *dom, **addr, *ret;
xmlNodePtr node;
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &dom) == FAILURE)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &dom) == FAILURE) {
php_error(E_ERROR, "wrong number of parameters to soap_encode_to_zval");
+ }
- if(zend_hash_index_find(Z_OBJPROP_P(dom), 1, (void **)&addr) == FAILURE)
+ if (zend_hash_index_find(Z_OBJPROP_P(dom), 1, (void **)&addr) == FAILURE) {
php_error(E_ERROR, "Cannot find domaddress to parameter passed to soap_encode_to_zval");
+ }
node = (xmlNodePtr)Z_LVAL_PP(addr);
ret = master_to_zval(get_conversion(UNKNOWN_TYPE), node);
@@ -523,8 +521,9 @@ PHP_METHOD(soapparam,soapparam)
char *name;
int name_length;
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs", &data, &name, &name_length) == FAILURE)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs", &data, &name, &name_length) == FAILURE) {
php_error(E_ERROR, "Invalid arguments to SoapParam constructor");
+ }
GET_THIS_OBJECT(thisObj);
@@ -542,9 +541,10 @@ PHP_METHOD(soapfault,soapfault)
int fault_string_len, fault_code_len, fault_actor_len;
zval *thisObj, *details = NULL;
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|zs", &fault_string, &fault_string_len,
- &fault_code, &fault_code_len, &details, &fault_actor, &fault_actor_len) == FAILURE)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|zs", &fault_string, &fault_string_len,
+ &fault_code, &fault_code_len, &details, &fault_actor, &fault_actor_len) == FAILURE) {
php_error(E_ERROR, "Invalid arguments to SoapFault constructor");
+ }
GET_THIS_OBJECT(thisObj);
@@ -559,17 +559,18 @@ PHP_METHOD(soapvar,soapvar)
int stype_len, ns_len, name_len, namens_len;
GET_THIS_OBJECT(thisObj);
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z!z|ssss", &data, &type, &stype, &stype_len, &ns, &ns_len, &name, &name_len, &namens, &namens_len) == FAILURE)
- php_error(E_ERROR, "Invalid arguments to SoapVar constructor");
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z!z|ssss", &data, &type, &stype, &stype_len, &ns, &ns_len, &name, &name_len, &namens, &namens_len) == FAILURE) {
+ php_error(E_ERROR, "Invalid arguments to SoapVar constructor");
+ }
- if(Z_TYPE_P(type) == IS_NULL)
+ if (Z_TYPE_P(type) == IS_NULL) {
add_property_long(thisObj, "enc_type", UNKNOWN_TYPE);
- else
- {
- if(zend_hash_index_exists(SOAP_GLOBAL(defEncIndex), Z_LVAL_P(type)))
+ } else {
+ if (zend_hash_index_exists(SOAP_GLOBAL(defEncIndex), Z_LVAL_P(type))) {
add_property_long(thisObj, "enc_type", Z_LVAL_P(type));
- else
+ } else {
php_error(E_ERROR, "Cannot find encoding for SoapVar");
+ }
}
if (data) {
@@ -579,14 +580,18 @@ PHP_METHOD(soapvar,soapvar)
add_property_zval(thisObj, "enc_value", data);
}
- if(stype && strlen(stype) > 0)
+ if (stype && strlen(stype) > 0) {
add_property_stringl(thisObj, "enc_stype", stype, stype_len, 1);
- if(ns && strlen(ns) > 0)
+ }
+ if (ns && strlen(ns) > 0) {
add_property_stringl(thisObj, "enc_ns", ns, ns_len, 1);
- if(name && strlen(name) > 0)
+ }
+ if (name && strlen(name) > 0) {
add_property_stringl(thisObj, "enc_name", name, name_len, 1);
- if(namens && strlen(namens) > 0)
+ }
+ if (namens && strlen(namens) > 0) {
add_property_stringl(thisObj, "enc_namens", namens, namens_len, 1);
+ }
}
/* SoapServer functions */
@@ -599,7 +604,7 @@ PHP_METHOD(soapserver,soapserver)
SOAP_SERVER_BEGIN_CODE();
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &uri, &uri_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &uri, &uri_len) == FAILURE) {
php_error(E_ERROR, "Invalid arguments to SoapServer constructor");
}
@@ -639,12 +644,12 @@ PHP_FUNCTION(SoapServer,map)
SOAP_SERVER_BEGIN_CODE();
- if(zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "sz|zzzzz",
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "sz|zzzzz",
&type, &type_len, &to_xml_before, &to_xml, &to_xml_after, &to_zval_before, &to_zval,
&to_zval_after) == SUCCESS && NULL_OR_STRING(to_xml_before) && NULL_OR_STRING(to_xml) &&
NULL_OR_STRING(to_xml_after) && NULL_OR_STRING(to_zval_before) && NULL_OR_STRING(to_zval) &&
- NULL_OR_STRING(to_zval_after))
- {
+ NULL_OR_STRING(to_zval_after)) {
+
soapMappingPtr map;
encodePtr enc, new_enc;
smart_str resloved_ns = {0};
@@ -655,7 +660,7 @@ PHP_FUNCTION(SoapServer,map)
memset(new_enc, 0, sizeof(encode));
ctype = strrchr(type, ':');
- if(ctype) {
+ if (ctype) {
smart_str_appendl(&resloved_ns, type, ctype - type);
smart_str_0(&resloved_ns);
ctype++;
@@ -663,10 +668,8 @@ PHP_FUNCTION(SoapServer,map)
ns = NULL;
}
- if(ns)
- {
- if(zend_hash_find(SOAP_GLOBAL(defEncPrefix), resloved_ns.c, resloved_ns.len + 1, &ns) == SUCCESS)
- {
+ if (ns) {
+ if (zend_hash_find(SOAP_GLOBAL(defEncPrefix), resloved_ns.c, resloved_ns.len + 1, &ns) == SUCCESS) {
enc = get_encoder(service->sdl, ns, ctype);
smart_str_free(&resloved_ns);
smart_str_appendl(&resloved_ns, ns, strlen(ns));
@@ -675,12 +678,12 @@ PHP_FUNCTION(SoapServer,map)
smart_str_0(&resloved_ns);
type = resloved_ns.c;
type_len = resloved_ns.len;
- }
- else
+ } else {
enc = get_encoder_ex(service->sdl, type);
- }
- else
+ }
+ } else {
enc = get_encoder_ex(service->sdl, type);
+ }
new_enc->details.type = enc->details.type;
new_enc->details.ns = strdup(enc->details.ns);
@@ -697,38 +700,32 @@ PHP_FUNCTION(SoapServer,map)
memset(map, 0, sizeof(soapMapping));
map->type = SOAP_MAP_FUNCTION;
- if(IS_VALID_FUNCTION(to_xml_before))
- {
+ if (IS_VALID_FUNCTION(to_xml_before)) {
zval_add_ref(&to_xml_before);
map->map_functions.to_xml_before = to_xml_before;
new_enc->to_xml_before = to_xml_before_user;
}
- if(IS_VALID_FUNCTION(to_xml))
- {
+ if (IS_VALID_FUNCTION(to_xml)) {
zval_add_ref(&to_xml);
map->map_functions.to_xml = to_xml;
new_enc->to_xml = to_xml_user;
}
- if(IS_VALID_FUNCTION(to_xml_after))
- {
+ if (IS_VALID_FUNCTION(to_xml_after)) {
zval_add_ref(&to_xml_after);
map->map_functions.to_xml_after = to_xml_after;
new_enc->to_xml_after = to_xml_after_user;
}
- if(IS_VALID_FUNCTION(to_zval_before))
- {
+ if (IS_VALID_FUNCTION(to_zval_before)) {
zval_add_ref(&to_zval_before);
map->map_functions.to_zval_before = to_zval_before;
new_enc->to_zval_before = to_zval_before_user;
}
- if(IS_VALID_FUNCTION(to_zval))
- {
+ if (IS_VALID_FUNCTION(to_zval)) {
zval_add_ref(&to_zval);
map->map_functions.to_zval = to_zval;
new_enc->to_zval = to_zval_user;
}
- if(IS_VALID_FUNCTION(to_zval_after))
- {
+ if (IS_VALID_FUNCTION(to_zval_after)) {
zval_add_ref(&to_zval_after);
map->map_functions.to_zval_after = to_zval_after;
new_enc->to_zval_after = to_zval_after_user;
@@ -736,19 +733,16 @@ PHP_FUNCTION(SoapServer,map)
new_enc->details.map = map;
- if(!service->mapping)
- {
+ if (!service->mapping) {
service->mapping = emalloc(sizeof(HashTable));
zend_hash_init(service->mapping, 0, NULL, delete_encoder, 0);
}
zend_hash_update(service->mapping, type, type_len + 1, &new_enc, sizeof(encodePtr), NULL);
smart_str_free(&resloved_ns);
- }
- else if(zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &type, &type_len, &class_name, &class_name_len, &type) == SUCCESS)
- {
- }
- else
+ } else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &type, &type_len, &class_name, &class_name_len, &type) == SUCCESS) {
+ } else {
php_error(E_ERROR, "Wrong number of parameters to SoapServer->map");
+ }
}
#endif
@@ -760,8 +754,9 @@ PHP_METHOD(soapserver,bind)
SOAP_SERVER_BEGIN_CODE();
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &wsdl, &wsdl_len) == FAILURE)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &wsdl, &wsdl_len) == FAILURE) {
php_error(E_ERROR, "Wrong number of parameters to SoapServer->bind");
+ }
FETCH_THIS_SERVICE(service);
service->sdl = get_sdl(wsdl);
@@ -778,18 +773,17 @@ PHP_METHOD(soapserver,setpersistence)
FETCH_THIS_SERVICE(service);
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &value) != FAILURE)
- {
- if(service->type == SOAP_CLASS)
- {
- if(value == SOAP_PERSISTENCE_SESSION ||
- value == SOAP_PERSISTENCE_REQUEST)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &value) != FAILURE) {
+ if (service->type == SOAP_CLASS) {
+ if (value == SOAP_PERSISTENCE_SESSION ||
+ value == SOAP_PERSISTENCE_REQUEST) {
service->soap_class.persistance = value;
- else
+ } else {
php_error(E_ERROR, "Tried to set persistence with bogus value (%d)", value);
- }
- else
+ }
+ } else {
php_error(E_ERROR, "Tried to set persistence when you are using you SOAP SERVER in function mode, no persistence needed");
+ }
}
SOAP_SERVER_END_CODE();
@@ -810,20 +804,17 @@ PHP_METHOD(soapserver,setclass)
argc = ZEND_NUM_ARGS();
argv = emalloc(argc * sizeof(zval **));
- if (argc < 1 || zend_get_parameters_array_ex(argc, argv) == FAILURE)
- {
+ if (argc < 1 || zend_get_parameters_array_ex(argc, argv) == FAILURE) {
efree(argv);
WRONG_PARAM_COUNT;
}
- if(Z_TYPE_PP(argv[0]) == IS_STRING)
- {
+ if (Z_TYPE_PP(argv[0]) == IS_STRING) {
class_name = estrdup(Z_STRVAL_PP(argv[0]));
found = zend_hash_find(EG(class_table), php_strtolower(class_name, Z_STRLEN_PP(argv[0])), Z_STRLEN_PP(argv[0]) + 1, (void **)&ce);
efree(class_name);
- if(found != FAILURE)
- {
+ if (found != FAILURE) {
service->type = SOAP_CLASS;
#ifdef ZEND_ENGINE_2
service->soap_class.ce = *(zend_class_entry**)ce;
@@ -832,22 +823,20 @@ PHP_METHOD(soapserver,setclass)
#endif
service->soap_class.persistance = SOAP_PERSISTENCE_REQUEST;
service->soap_class.argc = argc - 1;
- if(service->soap_class.argc > 0)
- {
+ if (service->soap_class.argc > 0) {
int i;
service->soap_class.argv = emalloc(sizeof(zval) * service->soap_class.argc);
- for(i = 0;i < service->soap_class.argc;i++)
- {
+ for (i = 0;i < service->soap_class.argc;i++) {
service->soap_class.argv[i] = *(argv[i + 1]);
zval_add_ref(&service->soap_class.argv[i]);
}
}
- }
- else
+ } else {
php_error(E_ERROR, "Tried to set a non existant class (%s)", Z_STRVAL_PP(argv[0]));
- }
- else
+ }
+ } else {
php_error(E_ERROR, "You must pass in a string to setclass");
+ }
efree(argv);
@@ -874,8 +863,7 @@ PHP_METHOD(soapserver,getfunctions)
HashPosition pos;
zend_hash_internal_pointer_reset_ex(service->soap_functions.ft, &pos);
- while(zend_hash_get_current_data_ex(service->soap_functions.ft, (void **)&name, &pos) != FAILURE)
- {
+ while (zend_hash_get_current_data_ex(service->soap_functions.ft, (void **)&name, &pos) != FAILURE) {
add_next_index_string(return_value, Z_STRVAL_PP(name), 1);
zend_hash_move_forward_ex(service->soap_functions.ft, &pos);
}
@@ -884,8 +872,7 @@ PHP_METHOD(soapserver,getfunctions)
zend_function *f;
HashPosition pos;
zend_hash_internal_pointer_reset_ex(ft, &pos);
- while(zend_hash_get_current_data_ex(ft, (void **)&f, &pos) != FAILURE)
- {
+ while (zend_hash_get_current_data_ex(ft, (void **)&f, &pos) != FAILURE) {
add_next_index_string(return_value, f->common.function_name, 1);
zend_hash_move_forward_ex(ft, &pos);
}
@@ -904,40 +891,39 @@ PHP_METHOD(soapserver, addfunction)
FETCH_THIS_SERVICE(service);
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &function_name) == FAILURE)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &function_name) == FAILURE) {
php_error(E_ERROR, "Invalid parameters passed to addfunction");
+ }
/* TODO: could use zend_is_callable here */
- if(function_name->type == IS_ARRAY)
- {
- if(service->type == SOAP_FUNCTIONS)
- {
+ if (function_name->type == IS_ARRAY) {
+ if (service->type == SOAP_FUNCTIONS) {
zval **tmp_function, *function_copy;
- if(service->soap_functions.ft == NULL)
- {
+ if (service->soap_functions.ft == NULL) {
service->soap_functions.functions_all = FALSE;
service->soap_functions.ft = emalloc(sizeof(HashTable));
zend_hash_init(service->soap_functions.ft, 0, NULL, ZVAL_PTR_DTOR, 0);
}
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(function_name), &pos);
- while(zend_hash_get_current_data_ex(Z_ARRVAL_P(function_name), (void **)&tmp_function, &pos) != FAILURE)
- {
+ while (zend_hash_get_current_data_ex(Z_ARRVAL_P(function_name), (void **)&tmp_function, &pos) != FAILURE) {
char *key;
int key_len;
zend_function *f;
- if(Z_TYPE_PP(tmp_function) != IS_STRING)
+ if (Z_TYPE_PP(tmp_function) != IS_STRING) {
php_error(E_ERROR, "Tried to add a function that isn't a string");
+ }
key_len = Z_STRLEN_PP(tmp_function);
key = emalloc(key_len + 1);
zend_str_tolower_copy(key, Z_STRVAL_PP(tmp_function), key_len);
- if(zend_hash_find(EG(function_table), key, key_len+1, (void**)&f) == FAILURE)
+ if (zend_hash_find(EG(function_table), key, key_len+1, (void**)&f) == FAILURE) {
php_error(E_ERROR, "Tried to add a non existant function (\"%s\")", Z_STRVAL_PP(tmp_function));
+ }
MAKE_STD_ZVAL(function_copy);
ZVAL_STRING(function_copy, f->common.function_name, 1);
@@ -947,9 +933,7 @@ PHP_METHOD(soapserver, addfunction)
zend_hash_move_forward_ex(Z_ARRVAL_P(function_name), &pos);
}
}
- }
- else if(function_name->type == IS_STRING)
- {
+ } else if (function_name->type == IS_STRING) {
char *key;
int key_len;
zend_function *f;
@@ -958,10 +942,10 @@ PHP_METHOD(soapserver, addfunction)
key = emalloc(key_len + 1);
zend_str_tolower_copy(key, Z_STRVAL_P(function_name), key_len);
- if(zend_hash_find(EG(function_table), key, key_len+1, (void**)&f) == FAILURE)
+ if (zend_hash_find(EG(function_table), key, key_len+1, (void**)&f) == FAILURE) {
php_error(E_ERROR, "Tried to add a non existant function (\"%s\")", Z_STRVAL_P(function_name));
- if(service->soap_functions.ft == NULL)
- {
+ }
+ if (service->soap_functions.ft == NULL) {
service->soap_functions.functions_all = FALSE;
service->soap_functions.ft = emalloc(sizeof(HashTable));
zend_hash_init(service->soap_functions.ft, 0, NULL, ZVAL_PTR_DTOR, 0);
@@ -971,21 +955,17 @@ PHP_METHOD(soapserver, addfunction)
ZVAL_STRING(function_copy, f->common.function_name, 1);
zend_hash_update(service->soap_functions.ft, key, key_len+1, &function_copy, sizeof(zval *), NULL);
efree(key);
- }
- else if(function_name->type == IS_LONG)
- {
- if(Z_LVAL_P(function_name) == SOAP_FUNCTIONS_ALL)
- {
- if(service->soap_functions.ft != NULL)
- {
+ } else if (function_name->type == IS_LONG) {
+ if (Z_LVAL_P(function_name) == SOAP_FUNCTIONS_ALL) {
+ if (service->soap_functions.ft != NULL) {
zend_hash_destroy(service->soap_functions.ft);
efree(service->soap_functions.ft);
service->soap_functions.ft = NULL;
}
service->soap_functions.functions_all = TRUE;
- }
- else
+ } else {
php_error(E_ERROR, "Invalid value passed to addfunction (%ld)", Z_LVAL_P(function_name));
+ }
}
SOAP_SERVER_END_CODE();
@@ -1008,18 +988,13 @@ PHP_METHOD(soapserver, handle)
ZERO_PARAM();
INIT_ZVAL(retval);
- if(zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void **)&server_vars) == SUCCESS)
- {
+ if (zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void **)&server_vars) == SUCCESS) {
zval **req_method, **query_string;
- if(zend_hash_find(Z_ARRVAL_PP(server_vars), "REQUEST_METHOD", sizeof("REQUEST_METHOD"), (void **)&req_method) == SUCCESS)
- {
- if(!strcmp(Z_STRVAL_PP(req_method), "GET") && zend_hash_find(Z_ARRVAL_PP(server_vars), "QUERY_STRING", sizeof("QUERY_STRING"), (void **)&query_string) == SUCCESS)
- {
- if(strstr(Z_STRVAL_PP(query_string), "wsdl") != NULL ||
- strstr(Z_STRVAL_PP(query_string), "WSDL") != NULL)
- {
- if(service->sdl)
- {
+ if (zend_hash_find(Z_ARRVAL_PP(server_vars), "REQUEST_METHOD", sizeof("REQUEST_METHOD"), (void **)&req_method) == SUCCESS) {
+ if (!strcmp(Z_STRVAL_PP(req_method), "GET") && zend_hash_find(Z_ARRVAL_PP(server_vars), "QUERY_STRING", sizeof("QUERY_STRING"), (void **)&query_string) == SUCCESS) {
+ if (strstr(Z_STRVAL_PP(query_string), "wsdl") != NULL ||
+ strstr(Z_STRVAL_PP(query_string), "WSDL") != NULL) {
+ if (service->sdl) {
/*
char *hdr = emalloc(sizeof("Location: ")+strlen(service->sdl->source));
strcpy(hdr,"Location: ");
@@ -1036,8 +1011,9 @@ PHP_METHOD(soapserver, handle)
sapi_add_header("Content-Type: text/xml; charset=\"utf-8\"", sizeof("Content-Type: text/xml; charset=\"utf-8\""), 1);
ZVAL_STRING(param, service->sdl->source, 1);
ZVAL_STRING(&readfile, "readfile", 1);
- if(call_user_function(EG(function_table), NULL, &readfile, &readfile_ret, 1, &param TSRMLS_CC) == FAILURE)
+ if (call_user_function(EG(function_table), NULL, &readfile, &readfile_ret, 1, &param TSRMLS_CC) == FAILURE) {
php_error(E_ERROR, "Couldn't find WSDL");
+ }
zval_ptr_dtor(&param);
zval_dtor(&readfile);
@@ -1066,16 +1042,16 @@ PHP_METHOD(soapserver, handle)
/* Turn on output buffering... we don't want people print in their methods
#if PHP_API_VERSION <= 20010901
- if(php_start_ob_buffer(NULL, 0 TSRMLS_CC) != SUCCESS)
+ if (php_start_ob_buffer(NULL, 0 TSRMLS_CC) != SUCCESS)
#else
*/
- if(php_start_ob_buffer(NULL, 0, 0 TSRMLS_CC) != SUCCESS)
+ if (php_start_ob_buffer(NULL, 0, 0 TSRMLS_CC) != SUCCESS) {
/* #endif */
php_error(E_ERROR,"ob_start failed");
+ }
if (zend_hash_find(&EG(symbol_table), HTTP_RAW_POST_DATA, sizeof(HTTP_RAW_POST_DATA), (void **) &raw_post)!=FAILURE
- && ((*raw_post)->type==IS_STRING))
- {
+ && ((*raw_post)->type==IS_STRING)) {
doc_request = xmlParseMemory(Z_STRVAL_PP(raw_post),Z_STRLEN_PP(raw_post));
xmlCleanupParser();
@@ -1091,13 +1067,11 @@ PHP_METHOD(soapserver, handle)
response_name = emalloc(Z_STRLEN(function_name) + strlen("Response") + 1);
sprintf(response_name,"%sResponse",fn_name);
- if(service->type == SOAP_CLASS)
- {
+ if (service->type == SOAP_CLASS) {
soap_obj = NULL;
#if HAVE_PHP_SESSION
/* If persistent then set soap_obj from from the previous created session (if available) */
- if(service->soap_class.persistance == SOAP_PERSISTENCE_SESSION)
- {
+ if (service->soap_class.persistance == SOAP_PERSISTENCE_SESSION) {
zval **tmp_soap;
if (PS(session_status) != php_session_active &&
@@ -1112,73 +1086,72 @@ PHP_METHOD(soapserver, handle)
}
#endif
/* If new session or something wierd happned */
- if(soap_obj == NULL)
- {
+ if (soap_obj == NULL) {
zval *tmp_soap;
MAKE_STD_ZVAL(tmp_soap);
object_init_ex(tmp_soap, service->soap_class.ce);
/* Call constructor */
- if(zend_hash_exists(&Z_OBJCE_P(tmp_soap)->function_table, service->soap_class.ce->name, strlen(service->soap_class.ce->name) + 1))
- {
+ if (zend_hash_exists(&Z_OBJCE_P(tmp_soap)->function_table, service->soap_class.ce->name, strlen(service->soap_class.ce->name) + 1)) {
zval c_ret, constructor;
INIT_ZVAL(c_ret);
INIT_ZVAL(constructor);
ZVAL_STRING(&constructor, service->soap_class.ce->name, 1);
- if(call_user_function(NULL, &tmp_soap, &constructor, &c_ret, service->soap_class.argc, service->soap_class.argv TSRMLS_CC) == FAILURE)
+ if (call_user_function(NULL, &tmp_soap, &constructor, &c_ret, service->soap_class.argc, service->soap_class.argv TSRMLS_CC) == FAILURE) {
php_error(E_ERROR, "Error calling constructor");
+ }
zval_dtor(&constructor);
zval_dtor(&c_ret);
}
#if HAVE_PHP_SESSION
/* If session then update session hash with new object */
- if(service->soap_class.persistance == SOAP_PERSISTENCE_SESSION)
- {
+ if (service->soap_class.persistance == SOAP_PERSISTENCE_SESSION) {
zval **tmp_soap_pp;
- if(zend_hash_update(Z_ARRVAL_P(PS(http_session_vars)), "_bogus_session_name", sizeof("_bogus_session_name"), &tmp_soap, sizeof(zval *), (void **)&tmp_soap_pp) == SUCCESS)
+ if (zend_hash_update(Z_ARRVAL_P(PS(http_session_vars)), "_bogus_session_name", sizeof("_bogus_session_name"), &tmp_soap, sizeof(zval *), (void **)&tmp_soap_pp) == SUCCESS) {
soap_obj = *tmp_soap_pp;
+ }
+ } else {
+ soap_obj = tmp_soap;
}
- else
+#else
+ soap_obj = tmp_soap;
#endif
- soap_obj = tmp_soap;
+
}
/* function_table = &(soap_obj->value.obj.ce->function_table);*/
function_table = &((Z_OBJCE_P(soap_obj))->function_table);
- }
- else
- {
- if(service->soap_functions.functions_all == TRUE)
+ } else {
+ if (service->soap_functions.functions_all == TRUE) {
function_table = EG(function_table);
- else
+ } else {
function_table = service->soap_functions.ft;
+ }
}
doc_return = NULL;
- if(zend_hash_exists(function_table, php_strtolower(Z_STRVAL(function_name), Z_STRLEN(function_name)), Z_STRLEN(function_name) + 1))
- {
- if(service->type == SOAP_CLASS)
- {
+ if (zend_hash_exists(function_table, php_strtolower(Z_STRVAL(function_name), Z_STRLEN(function_name)), Z_STRLEN(function_name) + 1)) {
+ if (service->type == SOAP_CLASS) {
call_status = call_user_function(NULL, &soap_obj, &function_name, &retval, num_params, params TSRMLS_CC);
- if(service->soap_class.persistance != SOAP_PERSISTENCE_SESSION)
+ if (service->soap_class.persistance != SOAP_PERSISTENCE_SESSION) {
zval_ptr_dtor(&soap_obj);
- }
- else
+ }
+ } else {
call_status = call_user_function(EG(function_table), NULL, &function_name, &retval, num_params, params TSRMLS_CC);
- }
- else
+ }
+ } else {
php_error(E_ERROR, "Function (%s) doesn't exist", Z_STRVAL(function_name));
+ }
- if(call_status == SUCCESS)
- {
+ if (call_status == SUCCESS) {
sdlFunctionPtr function;
function = get_function(get_binding_from_type(service->sdl, BINDING_SOAP), Z_STRVAL(function_name));
SOAP_GLOBAL(overrides) = service->mapping;
doc_return = seralize_response_call(function, response_name, service->uri, &retval, soap_version TSRMLS_CC);
SOAP_GLOBAL(overrides) = NULL;
- }
- else
+ } else {
php_error(E_ERROR, "Function (%s) call failed", Z_STRVAL(function_name));
+ }
SOAP_GLOBAL(sdl) = NULL;
@@ -1188,18 +1161,19 @@ PHP_METHOD(soapserver, handle)
/* xmlDocDumpMemoryEnc(doc_return, &buf, &size, XML_CHAR_ENCODING_UTF8); */
xmlDocDumpMemory(doc_return, &buf, &size);
- if(size == 0)
+ if (size == 0) {
php_error(E_ERROR, "Dump memory failed");
+ }
sprintf(cont_len, "Content-Length: %d", size);
sapi_add_header("Content-Type: text/xml; charset=\"utf-8\"", sizeof("Content-Type: text/xml; charset=\"utf-8\""), 1);
sapi_add_header(cont_len, strlen(cont_len) + 1, 1);
/* Free Memory */
- if(num_params > 0)
- {
- for(i = 0; i < num_params;i++)
+ if (num_params > 0) {
+ for (i = 0; i < num_params;i++) {
zval_ptr_dtor(&params[i]);
+ }
efree(params);
}
@@ -1210,11 +1184,10 @@ PHP_METHOD(soapserver, handle)
php_write(buf, size TSRMLS_CC);
xmlFree(buf);
- }
- else
- {
- if(!zend_ini_long("always_populate_raw_post_data", sizeof("always_populate_raw_post_data"), 0))
+ } else {
+ if (!zend_ini_long("always_populate_raw_post_data", sizeof("always_populate_raw_post_data"), 0)) {
php_error(E_ERROR, "PHP-SOAP requires 'always_populate_raw_post_data' to be on please check your php.ini file");
+ }
php_error(E_ERROR, "Couln't find HTTP_RAW_POST_DATA");
}
@@ -1236,7 +1209,7 @@ void soap_error_handler(int error_num, const char *error_filename, const uint er
}
buffer_len = vsnprintf(buffer, sizeof(buffer)-1, format, args);
buffer[sizeof(buffer)-1]=0;
- if(buffer_len > sizeof(buffer) - 1 || buffer_len < 0) {
+ if (buffer_len > sizeof(buffer) - 1 || buffer_len < 0) {
buffer_len = sizeof(buffer) - 1;
}
@@ -1245,9 +1218,8 @@ void soap_error_handler(int error_num, const char *error_filename, const uint er
What do do with these warnings
E_WARNING, E_NOTICE, E_CORE_WARNING, E_COMPILE_WARNING, E_USER_WARNING, E_USER_NOTICE
*/
- if(error_num == E_USER_ERROR || error_num == E_COMPILE_ERROR || error_num == E_CORE_ERROR ||
- error_num == E_ERROR || error_num == E_PARSE)
- {
+ if (error_num == E_USER_ERROR || error_num == E_COMPILE_ERROR || error_num == E_CORE_ERROR ||
+ error_num == E_ERROR || error_num == E_PARSE) {
zval outbuf, outbuflen, ret;
xmlChar *buf, cont_len[30];
int size;
@@ -1258,8 +1230,9 @@ void soap_error_handler(int error_num, const char *error_filename, const uint er
INIT_ZVAL(ret);
/* Get output buffer and send as fault detials */
- if(php_ob_get_length(&outbuflen TSRMLS_CC) != FAILURE && Z_LVAL(outbuflen) != 0)
+ if (php_ob_get_length(&outbuflen TSRMLS_CC) != FAILURE && Z_LVAL(outbuflen) != 0) {
php_ob_get_buffer(&outbuf TSRMLS_CC);
+ }
php_end_ob_buffer(0, 0 TSRMLS_CC);
set_soap_fault(&ret, "SOAP-ENV:Server", buffer, NULL, &outbuf TSRMLS_CC);
@@ -1286,8 +1259,9 @@ void soap_error_handler(int error_num, const char *error_filename, const uint er
zval_dtor(&outbuf);
zval_dtor(&outbuflen);
-// zval_dtor(&ret);
-
+/* ???
+ zval_dtor(&ret);
+*/
zend_bailout();
}
}
@@ -1296,8 +1270,7 @@ PHP_FUNCTION(use_soap_error_handler)
{
zend_bool handler = 1;
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &handler) == SUCCESS)
- {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &handler) == SUCCESS) {
SOAP_GLOBAL(use_soap_error_handler) = handler;
}
}
@@ -1312,16 +1285,12 @@ PHP_METHOD(soapobject, soapobject)
GET_THIS_OBJECT(thisObj);
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &location, &location_len, &uri, &uri_len) == SUCCESS)
- {
- if(uri)
- {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &location, &location_len, &uri, &uri_len) == SUCCESS) {
+ if (uri) {
/* if two parameters assume 'proxy' and 'uri' */
add_property_stringl(thisObj, "location", location, location_len, 1);
add_property_stringl(thisObj, "uri", uri, uri_len, 1);
- }
- else
- {
+ } else {
/* if one parameter assume 'wsdl' */
sdlPtr sdl;
int ret;
@@ -1344,11 +1313,11 @@ PHP_METHOD(soapobject, __use)
GET_THIS_OBJECT(thisObj);
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &use) == FAILURE)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &use) == FAILURE) {
php_error(E_ERROR, "Invalid arguments to SoapObject->__use");
+ }
- if(use == SOAP_ENCODED || use == SOAP_LITERAL)
- {
+ if (use == SOAP_ENCODED || use == SOAP_LITERAL) {
add_property_long(thisObj, "use", use);
RETURN_TRUE;
}
@@ -1362,11 +1331,11 @@ PHP_METHOD(soapobject, __style)
GET_THIS_OBJECT(thisObj);
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &style))
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &style)) {
php_error(E_ERROR, "Invalid arguments to SoapObject->__style");
+ }
- if(style == SOAP_RPC || style == SOAP_DOCUMENT)
- {
+ if (style == SOAP_RPC || style == SOAP_DOCUMENT) {
add_property_long(thisObj, "style", style);
RETURN_TRUE;
}
@@ -1380,8 +1349,9 @@ PHP_METHOD(soapobject, __trace)
GET_THIS_OBJECT(thisObj);
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &level))
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &level)) {
php_error(E_ERROR, "Invalid arguments to SoapObject->__trace");
+ }
add_property_long(thisObj, "trace", level);
RETURN_TRUE;
@@ -1395,7 +1365,7 @@ static void do_soap_call(zval* thisObj,
zval* return_value
TSRMLS_DC)
{
- zval **tmp;
+ zval **tmp;
zval **trace;
sdlPtr sdl = NULL;
sdlFunctionPtr fn;
@@ -1405,12 +1375,12 @@ static void do_soap_call(zval* thisObj,
int ret = FALSE;
int soap_version;
- if(zend_hash_find(Z_OBJPROP_P(thisObj), "trace", sizeof("trace"), (void **) &trace) == SUCCESS
+ if (zend_hash_find(Z_OBJPROP_P(thisObj), "trace", sizeof("trace"), (void **) &trace) == SUCCESS
&& Z_LVAL_PP(trace) > 0) {
zend_hash_del(Z_OBJPROP_P(thisObj), "__last_request", sizeof("__last_request"));
zend_hash_del(Z_OBJPROP_P(thisObj), "__last_response", sizeof("__last_response"));
}
- if(zend_hash_find(Z_OBJPROP_P(thisObj), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS
+ if (zend_hash_find(Z_OBJPROP_P(thisObj), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS
&& Z_LVAL_PP(tmp) == SOAP_1_2) {
soap_version = SOAP_1_2;
} else {
@@ -1426,15 +1396,15 @@ static void do_soap_call(zval* thisObj,
zend_try {
SOAP_GLOBAL(sdl) = sdl;
if (sdl != NULL) {
- sdlBindingPtr binding;
+ sdlBindingPtr binding;
zval* this_ptr = thisObj;
FETCH_THIS_PORT(binding);
php_strtolower(function, function_len);
fn = get_function(binding, function);
- if(fn != NULL) {
- if(binding->bindingType == BINDING_SOAP) {
+ if (fn != NULL) {
+ if (binding->bindingType == BINDING_SOAP) {
sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)fn->bindingAttributes;
request = seralize_function_call(thisObj, fn, NULL, fnb->input.ns, real_args, arg_count, soap_version TSRMLS_CC);
ret = send_http_soap_request(thisObj, request, fnb->soapAction TSRMLS_CC);
@@ -1443,54 +1413,55 @@ zend_try {
ret = send_http_soap_request(thisObj, request, NULL TSRMLS_CC);
}
- xmlFreeDoc(request);
-
- if (ret) {
- ret = get_http_soap_response(thisObj, &buffer, &len TSRMLS_CC);
- if (ret) {
- parse_packet_soap(thisObj, buffer, len, fn, NULL, return_value TSRMLS_CC);
- efree(buffer);
- }
- }
- } else {
- php_error(E_WARNING,"Function (\"%s\") not is not a valid method for this service", function);
- }
- } else {
- zval **uri;
- smart_str *action;
-
- if(zend_hash_find(Z_OBJPROP_P(thisObj), "uri", sizeof("uri"), (void *)&uri) == FAILURE)
- php_error(E_ERROR, "Error finding uri in soap_call_function_handler");
-
- request = seralize_function_call(thisObj, NULL, function, Z_STRVAL_PP(uri), real_args, arg_count, soap_version TSRMLS_CC);
- action = build_soap_action(thisObj, function);
- ret = send_http_soap_request(thisObj, request, action->c TSRMLS_CC);
-
- smart_str_free(action);
- efree(action);
xmlFreeDoc(request);
if (ret) {
- ret = get_http_soap_response(thisObj, &buffer, &len TSRMLS_CC);
+ ret = get_http_soap_response(thisObj, &buffer, &len TSRMLS_CC);
if (ret) {
- ret = parse_packet_soap(thisObj, buffer, len, NULL, function, return_value TSRMLS_CC);
+ parse_packet_soap(thisObj, buffer, len, fn, NULL, return_value TSRMLS_CC);
efree(buffer);
- }
- }
- }
- } zend_catch {
- ret = FALSE;
- } zend_end_try();
+ }
+ }
+ } else {
+ php_error(E_WARNING,"Function (\"%s\") not is not a valid method for this service", function);
+ }
+ } else {
+ zval **uri;
+ smart_str *action;
+
+ if (zend_hash_find(Z_OBJPROP_P(thisObj), "uri", sizeof("uri"), (void *)&uri) == FAILURE) {
+ php_error(E_ERROR, "Error finding uri in soap_call_function_handler");
+ }
+
+ request = seralize_function_call(thisObj, NULL, function, Z_STRVAL_PP(uri), real_args, arg_count, soap_version TSRMLS_CC);
+ action = build_soap_action(thisObj, function);
+ ret = send_http_soap_request(thisObj, request, action->c TSRMLS_CC);
+
+ smart_str_free(action);
+ efree(action);
+ xmlFreeDoc(request);
+
+ if (ret) {
+ ret = get_http_soap_response(thisObj, &buffer, &len TSRMLS_CC);
+ if (ret) {
+ ret = parse_packet_soap(thisObj, buffer, len, NULL, function, return_value TSRMLS_CC);
+ efree(buffer);
+ }
+ }
+ }
+} zend_catch {
+ ret = FALSE;
+} zend_end_try();
if (!ret) {
- zval** fault;
- if(zend_hash_find(Z_OBJPROP_P(thisObj), "__soap_fault", sizeof("__soap_fault"), (void **) &fault) == SUCCESS) {
+ zval** fault;
+ if (zend_hash_find(Z_OBJPROP_P(thisObj), "__soap_fault", sizeof("__soap_fault"), (void **) &fault) == SUCCESS) {
*return_value = **fault;
} else {
*return_value = *add_soap_fault(thisObj, "SOAP-ENV:Client", "Unknown Error", NULL, NULL TSRMLS_CC);
}
} else {
- zval** fault;
- if(zend_hash_find(Z_OBJPROP_P(thisObj), "__soap_fault", sizeof("__soap_fault"), (void **) &fault) == SUCCESS) {
+ zval** fault;
+ if (zend_hash_find(Z_OBJPROP_P(thisObj), "__soap_fault", sizeof("__soap_fault"), (void **) &fault) == SUCCESS) {
*return_value = **fault;
}
}
@@ -1504,12 +1475,11 @@ PHP_METHOD(soapobject, __soapversion)
GET_THIS_OBJECT(thisObj);
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &version)) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &version)) {
return;
}
- if(version == SOAP_1_1 || version == SOAP_1_2)
- {
+ if (version == SOAP_1_1 || version == SOAP_1_2) {
add_property_long(thisObj, "_soap_version", version);
RETURN_TRUE;
}
@@ -1546,17 +1516,17 @@ PHP_METHOD(soapobject, __call)
HashPosition pos;
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sa|ss",
- &function, &function_len, &args, &soap_action, &soap_action_len, &uri, &uri_len) == FAILURE)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sa|ss",
+ &function, &function_len, &args, &soap_action, &soap_action_len, &uri, &uri_len) == FAILURE) {
php_error(E_ERROR, "Invalid arguments to SoapObject->__call");
+ }
arg_count = zend_hash_num_elements(Z_ARRVAL_P(args));
real_args = emalloc(sizeof(zval *) * arg_count);
- for(zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(args), &pos);
+ for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(args), &pos);
zend_hash_get_current_data_ex(Z_ARRVAL_P(args), (void **) &param, &pos) == SUCCESS;
- zend_hash_move_forward_ex(Z_ARRVAL_P(args), &pos))
- {
+ zend_hash_move_forward_ex(Z_ARRVAL_P(args), &pos)) {
/*zval_add_ref(param);*/
real_args[i++] = *param;
}
@@ -1572,10 +1542,11 @@ PHP_METHOD(soapobject, __isfault)
GET_THIS_OBJECT(thisObj);
- if(zend_hash_exists(Z_OBJPROP_P(thisObj), "__soap_fault", sizeof("__soap_fault")))
+ if (zend_hash_exists(Z_OBJPROP_P(thisObj), "__soap_fault", sizeof("__soap_fault"))) {
RETURN_TRUE
- else
+ } else {
RETURN_FALSE
+ }
}
PHP_METHOD(soapobject, __getfault)
@@ -1585,8 +1556,7 @@ PHP_METHOD(soapobject, __getfault)
GET_THIS_OBJECT(thisObj);
- if(zend_hash_find(Z_OBJPROP_P(thisObj), "__soap_fault", sizeof("__soap_fault"), (void **)&tmp) == SUCCESS)
- {
+ if (zend_hash_find(Z_OBJPROP_P(thisObj), "__soap_fault", sizeof("__soap_fault"), (void **)&tmp) == SUCCESS) {
*return_value = *(*tmp);
zval_copy_ctor(return_value);
return;
@@ -1604,8 +1574,7 @@ PHP_METHOD(soapobject, __getfunctions)
FETCH_THIS_SDL(sdl);
- if(sdl)
- {
+ if (sdl) {
smart_str buf = {0};
sdlFunctionPtr *function;
sdlBindingPtr binding;
@@ -1614,8 +1583,7 @@ PHP_METHOD(soapobject, __getfunctions)
array_init(return_value);
zend_hash_internal_pointer_reset_ex(binding->functions, &pos);
- while(zend_hash_get_current_data_ex(binding->functions, (void **)&function, &pos) != FAILURE)
- {
+ while (zend_hash_get_current_data_ex(binding->functions, (void **)&function, &pos) != FAILURE) {
function_to_string((*function), &buf);
add_next_index_stringl(return_value, buf.c, buf.len, 1);
zend_hash_move_forward_ex(binding->functions, &pos);
@@ -1634,17 +1602,14 @@ PHP_METHOD(soapobject, __gettypes)
FETCH_THIS_SDL(sdl);
- if(sdl)
- {
+ if (sdl) {
sdlTypePtr *type;
smart_str buf = {0};
array_init(return_value);
- if(sdl->types)
- {
+ if (sdl->types) {
zend_hash_internal_pointer_reset_ex(sdl->types, &pos);
- while(zend_hash_get_current_data_ex(sdl->types, (void **)&type, &pos) != FAILURE)
- {
+ while (zend_hash_get_current_data_ex(sdl->types, (void **)&type, &pos) != FAILURE) {
type_to_string((*type), &buf, 0);
add_next_index_stringl(return_value, buf.c, buf.len, 1);
zend_hash_move_forward_ex(sdl->types, &pos);
@@ -1661,8 +1626,7 @@ PHP_METHOD(soapobject, __getlastrequest)
GET_THIS_OBJECT(thisObj);
- if(zend_hash_find(Z_OBJPROP_P(thisObj), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS)
- {
+ if (zend_hash_find(Z_OBJPROP_P(thisObj), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -1675,8 +1639,7 @@ PHP_METHOD(soapobject, __getlastresponse)
GET_THIS_OBJECT(thisObj);
- if(zend_hash_find(Z_OBJPROP_P(thisObj), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS)
- {
+ if (zend_hash_find(Z_OBJPROP_P(thisObj), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS) {
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
}
RETURN_NULL();
@@ -1697,12 +1660,9 @@ void soap_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_refe
Find if the function being called is already defined...
( IMHO: zend should handle this functionality )
*/
- if(zend_hash_find(&Z_OBJCE_P(thisObj)->function_table, function, Z_STRLEN(function_name->element) + 1, (void **) &builtin_function) == SUCCESS)
- {
+ if (zend_hash_find(&Z_OBJCE_P(thisObj)->function_table, function, Z_STRLEN(function_name->element) + 1, (void **) &builtin_function) == SUCCESS) {
builtin_function->internal_function.handler(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- }
- else
- {
+ } else {
int arg_count = ZEND_NUM_ARGS();
zval **arguments = (zval **) emalloc(sizeof(zval *) * arg_count);
@@ -1716,7 +1676,7 @@ void soap_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_refe
void clear_soap_fault(zval *obj TSRMLS_DC)
{
- if(obj != NULL && obj->type == IS_OBJECT) {
+ if (obj != NULL && obj->type == IS_OBJECT) {
/* zend_hash_del(obj->value.obj.properties, "__soap_fault", sizeof("__soap_fault"));*/
zend_hash_del(Z_OBJPROP_P(obj), "__soap_fault", sizeof("__soap_fault"));
}
@@ -1736,22 +1696,21 @@ zval* add_soap_fault(zval *obj, char *fault_code, char *fault_string, char *faul
void set_soap_fault(zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail TSRMLS_DC)
{
- if(Z_TYPE_P(obj) != IS_OBJECT)
+ if (Z_TYPE_P(obj) != IS_OBJECT) {
object_init_ex(obj, soap_fault_class_entry);
-
- if(fault_string != NULL)
+ }
+ if (fault_string != NULL) {
add_property_string(obj, "faultstring", fault_string, 1);
-
- if(fault_code != NULL)
+ }
+ if (fault_code != NULL) {
add_property_string(obj, "faultcode", fault_code, 1);
-
- if(fault_actor != NULL)
+ }
+ if (fault_actor != NULL) {
add_property_string(obj, "faultactor", fault_actor, 1);
-
- if(fault_detail != NULL)
- {
+ }
+ if (fault_detail != NULL) {
#ifdef ZEND_ENGINE_2
- fault_detail->refcount--;
+ fault_detail->refcount--;
#endif
add_property_zval(obj, "detail", fault_detail);
}
@@ -1774,18 +1733,18 @@ void deseralize_function_call(sdlPtr sdl, xmlDocPtr request, zval *function_name
while (trav != NULL) {
if (trav->type == XML_ELEMENT_NODE) {
if (env == NULL && node_is_equal_ex(trav,"Envelope",SOAP_1_1_ENV)) {
- env = trav;
- *version = SOAP_1_1;
- envelope_ns = SOAP_1_1_ENV;
- } else if (env == NULL && node_is_equal_ex(trav,"Envelope",SOAP_1_2_ENV)) {
- env = trav;
- *version = SOAP_1_2;
- envelope_ns = SOAP_1_2_ENV;
- } else {
- php_error(E_ERROR,"looks like we got bad SOAP request\n");
- }
- }
- trav = trav->next;
+ env = trav;
+ *version = SOAP_1_1;
+ envelope_ns = SOAP_1_1_ENV;
+ } else if (env == NULL && node_is_equal_ex(trav,"Envelope",SOAP_1_2_ENV)) {
+ env = trav;
+ *version = SOAP_1_2;
+ envelope_ns = SOAP_1_2_ENV;
+ } else {
+ php_error(E_ERROR,"looks like we got bad SOAP request\n");
+ }
+ }
+ trav = trav->next;
}
if (env == NULL) {
php_error(E_ERROR,"looks like we got XML without \"Envelope\" element\n");
@@ -1795,11 +1754,11 @@ void deseralize_function_call(sdlPtr sdl, xmlDocPtr request, zval *function_name
head = NULL;
trav = env->children;
while (trav != NULL && trav->type != XML_ELEMENT_NODE) {
- trav = trav->next;
+ trav = trav->next;
}
if (trav != NULL && node_is_equal_ex(trav,"Header",envelope_ns)) {
- head = trav;
- trav = trav->next;
+ head = trav;
+ trav = trav->next;
}
/* Get <Body> element */
@@ -1807,27 +1766,27 @@ void deseralize_function_call(sdlPtr sdl, xmlDocPtr request, zval *function_name
while (trav != NULL) {
if (trav->type == XML_ELEMENT_NODE) {
if (body == NULL && node_is_equal_ex(trav,"Body",envelope_ns)) {
- body = trav;
- } else {
+ body = trav;
+ } else {
php_error(E_ERROR,"looks like we got bad SOAP request\n");
- }
- }
- trav = trav->next;
+ }
+ }
+ trav = trav->next;
}
if (body == NULL) {
php_error(E_ERROR,"looks like we got \"Envelope\" without \"Body\" element\n");
}
func = NULL;
- trav = body->children;
+ trav = body->children;
while (trav != NULL) {
if (trav->type == XML_ELEMENT_NODE) {
- if (func != NULL) {
+ if (func != NULL) {
php_error(E_ERROR,"looks like we got \"Body\" with several functions call\n");
- }
- func = trav;
+ }
+ func = trav;
}
- trav = trav->next;
+ trav = trav->next;
}
if (func == NULL) {
php_error(E_ERROR,"looks like we got \"Body\" without function call\n");
@@ -1842,15 +1801,15 @@ void deseralize_function_call(sdlPtr sdl, xmlDocPtr request, zval *function_name
(*function_name) = tmp_function_name;
function = get_function(binding, php_strtolower((char *)func->name, strlen(func->name)));
- if(sdl != NULL && function == NULL) {
+ if (sdl != NULL && function == NULL) {
php_error(E_ERROR, "Error function \"%s\" doesn't exists for this service \"%s\"", func->name, binding->location);
}
- if(func->children) {
+ if (func->children) {
trav = func->children;
if (function == NULL) {
do {
- if(trav->type == XML_ELEMENT_NODE) {
+ if (trav->type == XML_ELEMENT_NODE) {
num_of_params++;
}
} while ((trav = trav->next));
@@ -1861,14 +1820,14 @@ void deseralize_function_call(sdlPtr sdl, xmlDocPtr request, zval *function_name
tmp_parameters = emalloc(num_of_params * sizeof(zval *));
trav = func->children;
do {
- if(trav->type == XML_ELEMENT_NODE) {
+ if (trav->type == XML_ELEMENT_NODE) {
encodePtr enc;
sdlParamPtr *param = NULL;
- if (function != NULL &&
+ if (function != NULL &&
zend_hash_index_find(function->requestParameters, cur_param, (void **)&param) == FAILURE) {
php_error(E_ERROR, "Error cannot find parameter");
}
- if(param == NULL) {
+ if (param == NULL) {
enc = get_conversion(UNKNOWN_TYPE);
} else {
enc = (*param)->encode;
@@ -1902,15 +1861,23 @@ xmlDocPtr seralize_response_call(sdlFunctionPtr function, char *function_name, c
/*TODO: if use="literal" SOAP-ENV:encodingStyle is not need */
if (version == SOAP_1_1) {
-//???if($style == 'rpc' && $use == 'encoded') {
- xmlSetProp(envelope, "SOAP-ENV:encodingStyle", SOAP_1_1_ENC);
-//???}
+/*
+ if ($style == 'rpc' && $use == 'encoded') {
+*/
+ xmlSetProp(envelope, "SOAP-ENV:encodingStyle", SOAP_1_1_ENC);
+/*
+ }
+*/
xmlSetProp(envelope, "xmlns:SOAP-ENC", SOAP_1_1_ENC);
ns = xmlNewNs(envelope, SOAP_1_1_ENV,"SOAP-ENV");
} else if (version == SOAP_1_2) {
-//???if($style == 'rpc' && $use == 'encoded') {
- xmlSetProp(envelope, "SOAP-ENV:encodingStyle", SOAP_1_2_ENC);
-//???}
+/*
+ if ($style == 'rpc' && $use == 'encoded') {
+*/
+ xmlSetProp(envelope, "SOAP-ENV:encodingStyle", SOAP_1_2_ENC);
+/*
+ }
+*/
xmlSetProp(envelope, "xmlns:SOAP-ENC", SOAP_1_2_ENC);
ns = xmlNewNs(envelope, SOAP_1_2_ENV,"SOAP-ENV");
} else {
@@ -1922,30 +1889,30 @@ xmlDocPtr seralize_response_call(sdlFunctionPtr function, char *function_name, c
body = xmlNewChild(envelope, ns, "Body", NULL);
- if(Z_TYPE_P(ret) == IS_OBJECT &&
- Z_OBJCE_P(ret) == soap_fault_class_entry)
- {
+ if (Z_TYPE_P(ret) == IS_OBJECT &&
+ Z_OBJCE_P(ret) == soap_fault_class_entry) {
param = seralize_zval(ret, NULL, "SOAP-ENV:Fault", SOAP_ENCODED TSRMLS_CC);
xmlAddChild(body, param);
- }
- else
- {
+ } else {
gen_ns = encode_new_ns();
ns = xmlNewNs(envelope, uri, gen_ns->c);
- if(function != NULL)
+ if (function != NULL) {
method = xmlNewChild(body, ns, function->responseName , NULL);
- else
+ } else {
method = xmlNewChild(body, ns, function_name, NULL);
+ }
- if(uri)
+ if (uri) {
ns = xmlNewNs(method, uri, NULL);
+ }
if (function != NULL) {
param_count = zend_hash_num_elements(function->responseParameters);
} else {
param_count = 1;
}
+
if (param_count == 1) {
parameter = get_param(function, NULL, 0, TRUE);
@@ -1957,13 +1924,12 @@ xmlDocPtr seralize_response_call(sdlFunctionPtr function, char *function_name, c
int i = 0;
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(ret), &pos);
- while(zend_hash_get_current_data_ex(Z_ARRVAL_P(ret), (void **)&data, &pos) != FAILURE)
- {
- char *param_name;
- int param_name_len;
- long param_index;
+ while (zend_hash_get_current_data_ex(Z_ARRVAL_P(ret), (void **)&data, &pos) != FAILURE) {
+ char *param_name;
+ int param_name_len;
+ long param_index;
- zend_hash_get_current_key_ex(Z_ARRVAL_P(ret), &param_name, &param_name_len, &param_index, 0, &pos);
+ zend_hash_get_current_key_ex(Z_ARRVAL_P(ret), &param_name, &param_name_len, &param_index, 0, &pos);
parameter = get_param(function, param_name, param_index, TRUE);
param = seralize_parameter(parameter, *data, i, param_name, SOAP_ENCODED TSRMLS_CC);
@@ -2008,7 +1974,7 @@ xmlDocPtr seralize_function_call(zval *this_ptr, sdlFunctionPtr function, char *
xmlSetProp(envelope, "SOAP-ENV:encodingStyle", SOAP_1_2_ENC);
xmlSetProp(envelope, "xmlns:SOAP-ENC", SOAP_1_2_ENC);
} else {
- php_error(E_ERROR, "Unknown SOAP version");
+ php_error(E_ERROR, "Unknown SOAP version");
}
xmlSetProp(envelope, "xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
xmlSetProp(envelope, "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
@@ -2017,35 +1983,29 @@ xmlDocPtr seralize_function_call(zval *this_ptr, sdlFunctionPtr function, char *
gen_ns = encode_new_ns();
- if(function)
- {
- if(function->bindingType == BINDING_SOAP)
- {
+ if (function) {
+ if (function->bindingType == BINDING_SOAP) {
sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)function->bindingAttributes;
style = fnb->style;
use = fnb->input.use;
- if(style == SOAP_RPC)
- {
+ if (style == SOAP_RPC) {
ns = xmlNewNs(body, fnb->input.ns, gen_ns->c);
method = xmlNewChild(body, ns, function->requestName , NULL);
}
}
- }
- else
- {
- if(zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS)
+ } else {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS) {
style = Z_LVAL_PP(zstyle);
- else
+ } else {
style = SOAP_RPC;
-
- if(style == SOAP_RPC)
- {
+ }
+ if (style == SOAP_RPC) {
ns = xmlNewNs(body, uri, gen_ns->c);
method = xmlNewChild(body, ns, function_name, NULL);
}
- if(zend_hash_find(Z_OBJPROP_P(this_ptr), "use", sizeof("use"), (void **)&zuse) == SUCCESS) {
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "use", sizeof("use"), (void **)&zuse) == SUCCESS) {
if (Z_LVAL_PP(zuse) == SOAP_LITERAL) {
use = SOAP_LITERAL;
} else {
@@ -2056,8 +2016,7 @@ xmlDocPtr seralize_function_call(zval *this_ptr, sdlFunctionPtr function, char *
}
}
- for(i = 0;i < arg_count;i++)
- {
+ for (i = 0;i < arg_count;i++) {
xmlNodePtr param;
sdlParamPtr parameter = get_param(function, NULL, i, FALSE);
@@ -2066,12 +2025,10 @@ xmlDocPtr seralize_function_call(zval *this_ptr, sdlFunctionPtr function, char *
if (style == SOAP_RPC) {
xmlAddChild(method, param);
} else if (style == SOAP_DOCUMENT) {
- if(function && function->bindingType == BINDING_SOAP)
- {
+ if (function && function->bindingType == BINDING_SOAP) {
sdlParamPtr *sparam;
- if(zend_hash_index_find(function->requestParameters, 0, (void **)&sparam) == SUCCESS)
- {
+ if (zend_hash_index_find(function->requestParameters, 0, (void **)&sparam) == SUCCESS) {
ns = xmlNewNs(param, (*sparam)->encode->details.ns, gen_ns->c);
xmlNodeSetName(param, (*sparam)->encode->details.type_str);
xmlSetNs(param, ns);
@@ -2091,29 +2048,27 @@ xmlNodePtr seralize_parameter(sdlParamPtr param, zval *param_val, int index, cha
char *paramName;
xmlNodePtr xmlParam;
- if(Z_TYPE_P(param_val) == IS_OBJECT &&
+ if (Z_TYPE_P(param_val) == IS_OBJECT &&
Z_OBJCE_P(param_val) == soap_param_class_entry) {
zval **param_name;
zval **param_data;
- if(zend_hash_find(Z_OBJPROP_P(param_val), "param_name", sizeof("param_name"), (void **)&param_name) == SUCCESS &&
+ if (zend_hash_find(Z_OBJPROP_P(param_val), "param_name", sizeof("param_name"), (void **)&param_name) == SUCCESS &&
zend_hash_find(Z_OBJPROP_P(param_val), "param_data", sizeof("param_data"), (void **)&param_data) == SUCCESS) {
param_val = *param_data;
name = Z_STRVAL_PP(param_name);
}
}
- if(param != NULL && param->paramName != NULL)
+ if (param != NULL && param->paramName != NULL) {
paramName = estrdup(param->paramName);
- else
- {
- if(name == NULL)
- {
+ } else {
+ if (name == NULL) {
paramName = emalloc(10);
sprintf(paramName,"param%d",index);
- }
- else
+ } else {
paramName = estrdup(name);
+ }
}
xmlParam = seralize_zval(param_val, param, paramName, style TSRMLS_CC);
@@ -2128,15 +2083,16 @@ xmlNodePtr seralize_zval(zval *val, sdlParamPtr param, char *paramName, int styl
xmlNodePtr xmlParam;
encodePtr enc;
- if(param != NULL)
+ if (param != NULL) {
enc = param->encode;
- else
+ } else {
enc = get_conversion(val->type);
+ }
xmlParam = master_to_xml(enc, val, style);
- if(!strcmp(xmlParam->name, "BOGUS"))
+ if (!strcmp(xmlParam->name, "BOGUS")) {
xmlNodeSetName(xmlParam, paramName);
-
+ }
return xmlParam;
}
@@ -2145,22 +2101,22 @@ sdlParamPtr get_param(sdlFunctionPtr function, char *param_name, int index, int
sdlParamPtr *tmp;
HashTable *ht;
- if(function == NULL) {
+ if (function == NULL) {
return NULL;
}
- if(response == FALSE) {
+ if (response == FALSE) {
ht = function->requestParameters;
} else {
ht = function->responseParameters;
}
if (param_name != NULL) {
- if (zend_hash_find(ht, param_name, strlen(param_name), (void **)&tmp) != FAILURE) {
- return *tmp;
- }
+ if (zend_hash_find(ht, param_name, strlen(param_name), (void **)&tmp) != FAILURE) {
+ return *tmp;
+ }
} else {
- if(zend_hash_index_find(ht, index, (void **)&tmp) != FAILURE) {
+ if (zend_hash_index_find(ht, index, (void **)&tmp) != FAILURE) {
return (*tmp);
}
}
@@ -2170,7 +2126,7 @@ sdlParamPtr get_param(sdlFunctionPtr function, char *param_name, int index, int
sdlFunctionPtr get_function(sdlBindingPtr sdl, char *function_name)
{
sdlFunctionPtr *tmp;
- if(sdl != NULL) {
+ if (sdl != NULL) {
if (zend_hash_find(sdl->functions, function_name, strlen(function_name), (void **)&tmp) != FAILURE) {
return (*tmp);
}
@@ -2183,33 +2139,31 @@ static void function_to_string(sdlFunctionPtr function, smart_str *buf)
int i = 0;
HashPosition pos;
- if(function->responseParameters && function->responseParameters->pListHead)
- {
+ if (function->responseParameters && function->responseParameters->pListHead) {
sdlParamPtr *param;
param = function->responseParameters->pListHead->pData;
smart_str_appendl(buf, (*param)->encode->details.type_str, strlen((*param)->encode->details.type_str));
smart_str_appendc(buf, ' ');
- }
- else
+ } else {
smart_str_appendl(buf, "void ", 5);
+ }
smart_str_appendl(buf, function->functionName, strlen(function->functionName));
smart_str_appendc(buf, '(');
- if(function->requestParameters)
- {
+ if (function->requestParameters) {
sdlParamPtr *param;
i = 0;
zend_hash_internal_pointer_reset_ex(function->requestParameters, &pos);
- while(zend_hash_get_current_data_ex(function->requestParameters, (void **)&param, &pos) != FAILURE)
- {
+ while (zend_hash_get_current_data_ex(function->requestParameters, (void **)&param, &pos) != FAILURE) {
smart_str_appendl(buf, (*param)->encode->details.type_str, strlen((*param)->encode->details.type_str));
smart_str_appendc(buf, ' ');
smart_str_appendc(buf, '$');
smart_str_appendl(buf, (*param)->paramName, strlen((*param)->paramName));
- if(zend_hash_num_elements(function->requestParameters) > i + 1)
+ if (zend_hash_num_elements(function->requestParameters) > i + 1) {
smart_str_appendl(buf, ", ", 2);
+ }
zend_hash_move_forward_ex(function->requestParameters, &pos);
i++;
}
@@ -2224,13 +2178,12 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level)
smart_str spaces = {0};
HashPosition pos;
- for(i = 0;i < level;i++)
+ for (i = 0;i < level;i++) {
smart_str_appendc(&spaces, ' ');
-
+ }
smart_str_appendl(buf, spaces.c, spaces.len);
- if(type->elements)
- {
+ if (type->elements) {
sdlTypePtr *t_type;
smart_str_appendl(buf, "struct ", 7);
@@ -2241,17 +2194,14 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level)
zend_hash_internal_pointer_reset_ex(type->elements, &pos);
level++;
- while(zend_hash_get_current_data_ex(type->elements, (void **)&t_type, &pos) != FAILURE)
- {
+ while (zend_hash_get_current_data_ex(type->elements, (void **)&t_type, &pos) != FAILURE) {
type_to_string((*t_type), buf, level);
zend_hash_move_forward_ex(type->elements, &pos);
}
smart_str_appendl(buf, spaces.c, spaces.len);
smart_str_appendl(buf, "}\n", 2);
- }
- else
- {
+ } else {
smart_str_appendl(buf, type->encode->details.type_str, strlen(type->encode->details.type_str));
smart_str_appendc(buf, ' ');
smart_str_appendl(buf, type->name, strlen(type->name));
@@ -2267,22 +2217,21 @@ void delete_sdl(void *handle)
sdlPtr tmp = *((sdlPtr*)handle);
xmlFreeDoc(tmp->doc);
- if(tmp->source)
+ if (tmp->source) {
free(tmp->source);
- if(tmp->target_ns)
+ }
+ if (tmp->target_ns) {
free(tmp->target_ns);
- if(tmp->encoders)
- {
+ }
+ if (tmp->encoders) {
zend_hash_destroy(tmp->encoders);
free(tmp->encoders);
}
- if(tmp->types)
- {
+ if (tmp->types) {
zend_hash_destroy(tmp->types);
free(tmp->types);
}
- if(tmp->bindings)
- {
+ if (tmp->bindings) {
zend_hash_destroy(tmp->bindings);
free(tmp->bindings);
}
@@ -2298,23 +2247,21 @@ void delete_service(void *data)
{
soapServicePtr service = (soapServicePtr)data;
- if(service->soap_functions.ft)
- {
+ if (service->soap_functions.ft) {
zend_hash_destroy(service->soap_functions.ft);
efree(service->soap_functions.ft);
}
- if(service->mapping)
- {
+ if (service->mapping) {
zend_hash_destroy(service->mapping);
efree(service->mapping);
}
- if(service->soap_class.argc)
- {
+ if (service->soap_class.argc) {
int i;
- for(i = 0; i < service->soap_class.argc;i++)
+ for (i = 0; i < service->soap_class.argc;i++) {
zval_ptr_dtor(&service->soap_class.argv[i]);
+ }
efree(service->soap_class.argv);
}
@@ -2326,19 +2273,19 @@ void delete_binding(void *data)
{
sdlBindingPtr binding = *((sdlBindingPtr*)data);
- if(binding->functions)
- {
+ if (binding->functions) {
zend_hash_destroy(binding->functions);
free(binding->functions);
}
- if(binding->location)
+ if (binding->location) {
free(binding->location);
- if(binding->name)
+ }
+ if (binding->name) {
free(binding->name);
+ }
- if(binding->bindingType == BINDING_SOAP)
- {
+ if (binding->bindingType == BINDING_SOAP) {
sdlSoapBindingPtr soapBind = binding->bindingAttributes;
free(soapBind->transport);
}
@@ -2348,29 +2295,29 @@ void delete_function(void *data)
{
sdlFunctionPtr function = *((sdlFunctionPtr*)data);
- if(function->functionName)
+ if (function->functionName) {
free(function->functionName);
- if(function->requestName)
+ }
+ if (function->requestName) {
free(function->requestName);
- if(function->responseName)
+ }
+ if (function->responseName) {
free(function->responseName);
-
- if(function->requestParameters)
- {
+ }
+ if (function->requestParameters) {
zend_hash_destroy(function->requestParameters);
free(function->requestParameters);
}
- if(function->responseParameters)
- {
+ if (function->responseParameters) {
zend_hash_destroy(function->responseParameters);
free(function->responseParameters);
}
- if(function->bindingType == BINDING_SOAP)
- {
+ if (function->bindingType == BINDING_SOAP) {
sdlSoapBindingFunctionPtr soapFunction = function->bindingAttributes;
- if(soapFunction->soapAction)
+ if (soapFunction->soapAction) {
free(soapFunction->soapAction);
+ }
delete_sdl_soap_binding_function_body(soapFunction->input);
delete_sdl_soap_binding_function_body(soapFunction->output);
delete_sdl_soap_binding_function_body(soapFunction->falut);
@@ -2379,19 +2326,23 @@ void delete_function(void *data)
void delete_sdl_soap_binding_function_body(sdlSoapBindingFunctionBody body)
{
- if(body.ns)
+ if (body.ns) {
free(body.ns);
- if(body.parts)
+ }
+ if (body.parts) {
free(body.parts);
- if(body.encodingStyle)
+ }
+ if (body.encodingStyle) {
free(body.encodingStyle);
+ }
}
void delete_paramater(void *data)
{
sdlParamPtr param = *((sdlParamPtr*)data);
- if(param->paramName)
+ if (param->paramName) {
free(param->paramName);
+ }
free(param);
}
@@ -2399,26 +2350,32 @@ void delete_mapping(void *data)
{
soapMappingPtr map = (soapMappingPtr)data;
- if(map->ns)
+ if (map->ns) {
efree(map->ns);
- if(map->ctype)
+ }
+ if (map->ctype) {
efree(map->ctype);
+ }
- if(map->type == SOAP_MAP_FUNCTION)
- {
- if(map->map_functions.to_xml_before)
+ if (map->type == SOAP_MAP_FUNCTION) {
+ if (map->map_functions.to_xml_before) {
zval_ptr_dtor(&map->map_functions.to_xml_before);
- if(map->map_functions.to_xml)
+ }
+ if (map->map_functions.to_xml) {
zval_ptr_dtor(&map->map_functions.to_xml);
- if(map->map_functions.to_xml_after)
+ }
+ if (map->map_functions.to_xml_after) {
zval_ptr_dtor(&map->map_functions.to_xml_after);
-
- if(map->map_functions.to_zval_before)
+ }
+ if (map->map_functions.to_zval_before) {
zval_ptr_dtor(&map->map_functions.to_zval_before);
- if(map->map_functions.to_zval)
+ }
+ if (map->map_functions.to_zval) {
zval_ptr_dtor(&map->map_functions.to_zval);
- if(map->map_functions.to_zval_after)
+ }
+ if (map->map_functions.to_zval_after) {
zval_ptr_dtor(&map->map_functions.to_zval_after);
+ }
}
efree(map);
}