Browse Source

Source cleanup.

PEAR_1_4DEV
Dmitry Stogov 22 years ago
parent
commit
9a3cdc6491
  1. 514
      ext/soap/php_encoding.c
  2. 12
      ext/soap/php_encoding.h
  3. 93
      ext/soap/php_http.c
  4. 58
      ext/soap/php_packet_soap.c
  5. 287
      ext/soap/php_schema.c
  6. 494
      ext/soap/php_sdl.c
  7. 36
      ext/soap/php_sdl.h
  8. 94
      ext/soap/php_soap.h
  9. 117
      ext/soap/php_xml.c
  10. 843
      ext/soap/soap.c

514
ext/soap/php_encoding.c
File diff suppressed because it is too large
View File

12
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"); \
}\

93
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;
}

58
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);
}
}

287
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);

494
ext/soap/php_sdl.c
File diff suppressed because it is too large
View File

36
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;

94
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; \
}

117
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;
}

843
ext/soap/soap.c
File diff suppressed because it is too large
View File

Loading…
Cancel
Save