Back to index

php5  5.3.10
Classes | Defines | Typedefs | Enumerations | Functions
php_sdl.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _sdl
struct  sdlCtx
struct  _sdlBinding
struct  _sdlSoapBinding
struct  _sdlSoapBindingFunctionHeader
struct  _sdlSoapBindingFunctionFault
struct  _sdlSoapBindingFunctionBody
struct  _sdlSoapBindingFunction
struct  _sdlRestrictionInt
struct  _sdlRestrictionChar
struct  _sdlRestrictions
struct  _sdlContentModel
struct  _sdlType
struct  _sdlParam
struct  _sdlFault
struct  _sdlFunction
struct  _sdlExtraAttribute
struct  _sdlAttribute
union  _sdlContentModel.u

Defines

#define XSD_WHITESPACE_COLLAPSE   1
#define XSD_WHITESPACE_PRESERVE   1
#define XSD_WHITESPACE_REPLACE   1

Typedefs

typedef enum _sdlBindingType sdlBindingType
typedef enum _sdlEncodingStyle sdlEncodingStyle
typedef enum _sdlRpcEncodingStyle sdlRpcEncodingStyle
typedef enum _sdlEncodingUse sdlEncodingUse
typedef enum _sdlTransport sdlTransport
typedef struct sdlCtx sdlCtx
typedef struct
_sdlSoapBindingFunctionHeader 
sdlSoapBindingFunctionHeader
typedef struct
_sdlSoapBindingFunctionHeader
sdlSoapBindingFunctionHeaderPtr
typedef struct
_sdlSoapBindingFunctionFault 
sdlSoapBindingFunctionFault
typedef struct
_sdlSoapBindingFunctionFault
sdlSoapBindingFunctionFaultPtr
typedef enum _sdlContentKind sdlContentKind
typedef struct _sdlContentModel
typedef struct * sdlContentModelPtr
typedef enum _sdlTypeKind sdlTypeKind
typedef enum _sdlUse sdlUse
typedef enum _sdlForm sdlForm
typedef struct _sdlFault sdlFault
typedef struct _sdlFaultsdlFaultPtr
typedef struct _sdlExtraAttribute sdlExtraAttribute
typedef struct _sdlExtraAttributesdlExtraAttributePtr

Enumerations

enum  _sdlBindingType { BINDING_SOAP = 1, BINDING_HTTP = 2 }
enum  _sdlEncodingStyle { SOAP_RPC = 1, SOAP_DOCUMENT = 2 }
enum  _sdlRpcEncodingStyle { SOAP_ENCODING_DEFAULT = 0, SOAP_ENCODING_1_1 = 1, SOAP_ENCODING_1_2 = 2 }
enum  _sdlEncodingUse { SOAP_ENCODED = 1, SOAP_LITERAL = 2 }
enum  _sdlTransport { SOAP_TRANSPORT_HTTP = 1 }
enum  _sdlContentKind {
  XSD_CONTENT_ELEMENT, XSD_CONTENT_SEQUENCE, XSD_CONTENT_ALL, XSD_CONTENT_CHOICE,
  XSD_CONTENT_GROUP_REF, XSD_CONTENT_GROUP, XSD_CONTENT_ANY
}
enum  _sdlTypeKind {
  XSD_TYPEKIND_SIMPLE, XSD_TYPEKIND_LIST, XSD_TYPEKIND_UNION, XSD_TYPEKIND_COMPLEX,
  XSD_TYPEKIND_RESTRICTION, XSD_TYPEKIND_EXTENSION
}
enum  _sdlUse { XSD_USE_DEFAULT, XSD_USE_OPTIONAL, XSD_USE_PROHIBITED, XSD_USE_REQUIRED }
enum  _sdlForm { XSD_FORM_DEFAULT, XSD_FORM_QUALIFIED, XSD_FORM_UNQUALIFIED }

Functions

sdlPtr get_sdl (zval *this_ptr, char *uri, long cache_wsdl TSRMLS_DC)
encodePtr get_encoder_from_prefix (sdlPtr sdl, xmlNodePtr data, const xmlChar *type)
encodePtr get_encoder (sdlPtr sdl, const char *ns, const char *type)
encodePtr get_encoder_ex (sdlPtr sdl, const char *nscat, int len)
sdlBindingPtr get_binding_from_type (sdlPtr sdl, int type)
sdlBindingPtr get_binding_from_name (sdlPtr sdl, char *name, char *ns)
void delete_sdl (void *handle)
void delete_sdl_impl (void *handle)
void sdl_set_uri_credentials (sdlCtx *ctx, char *uri TSRMLS_DC)
void sdl_restore_uri_credentials (sdlCtx *ctx TSRMLS_DC)

Class Documentation

struct _sdl

Definition at line 54 of file php_sdl.h.

Collaboration diagram for _sdl:
Class Members
HashTable * bindings
HashTable * elements
HashTable * encoders
HashTable functions
HashTable * groups
zend_bool is_persistent
HashTable * requests
char * source
char * target_ns
HashTable * types
struct sdlCtx

Definition at line 67 of file php_sdl.h.

Collaboration diagram for sdlCtx:
Class Members
HashTable * attributeGroups
HashTable * attributes
HashTable bindings
php_stream_context * context
HashTable docs
HashTable messages
zval * old_header
HashTable portTypes
sdlPtr sdl
HashTable services
struct _sdlBinding

Definition at line 83 of file php_sdl.h.

Class Members
void * bindingAttributes
sdlBindingType bindingType
char * location
char * name
struct _sdlSoapBinding

Definition at line 91 of file php_sdl.h.

Class Members
sdlEncodingStyle style
sdlTransport transport
struct _sdlSoapBindingFunctionHeader

Definition at line 96 of file php_sdl.h.

Collaboration diagram for _sdlSoapBindingFunctionHeader:
Class Members
sdlTypePtr element
encodePtr encode
sdlRpcEncodingStyle encodingStyle
HashTable * headerfaults
char * name
char * ns
sdlEncodingUse use
struct _sdlSoapBindingFunctionFault

Definition at line 106 of file php_sdl.h.

Class Members
sdlRpcEncodingStyle encodingStyle
char * ns
sdlEncodingUse use
struct _sdlSoapBindingFunctionBody

Definition at line 112 of file php_sdl.h.

Collaboration diagram for _sdlSoapBindingFunctionBody:
Class Members
sdlRpcEncodingStyle encodingStyle
HashTable * headers
char * ns
sdlEncodingUse use
struct _sdlSoapBindingFunction

Definition at line 119 of file php_sdl.h.

Class Members
sdlSoapBindingFunctionBody input
sdlSoapBindingFunctionBody output
char * soapAction
sdlEncodingStyle style
struct _sdlRestrictionInt

Definition at line 127 of file php_sdl.h.

Class Members
char fixed
int value
struct _sdlRestrictionChar

Definition at line 132 of file php_sdl.h.

Class Members
char fixed
char * value
struct _sdlRestrictions

Definition at line 137 of file php_sdl.h.

Collaboration diagram for _sdlRestrictions:
Class Members
HashTable * enumeration
sdlRestrictionIntPtr fractionDigits
sdlRestrictionIntPtr length
sdlRestrictionIntPtr maxExclusive
sdlRestrictionIntPtr maxInclusive
sdlRestrictionIntPtr maxLength
sdlRestrictionIntPtr minExclusive
sdlRestrictionIntPtr minInclusive
sdlRestrictionIntPtr minLength
sdlRestrictionCharPtr pattern
sdlRestrictionIntPtr totalDigits
sdlRestrictionCharPtr whiteSpace
struct _sdlContentModel

Definition at line 165 of file php_sdl.h.

Class Members
sdlContentKind kind
int max_occurs
int min_occurs
union _sdlContentModel u
struct _sdlType

Definition at line 199 of file php_sdl.h.

Collaboration diagram for _sdlType:
Class Members
HashTable * attributes
char * def
HashTable * elements
encodePtr encode
char * fixed
sdlForm form
sdlTypeKind kind
sdlContentModelPtr model
char * name
char * namens
char nillable
char * ref
sdlRestrictionsPtr restrictions
struct _sdlParam

Definition at line 215 of file php_sdl.h.

Class Members
sdlTypePtr element
encodePtr encode
int order
char * paramName
struct _sdlFault

Definition at line 222 of file php_sdl.h.

Collaboration diagram for _sdlFault:
Class Members
void * bindingAttributes
HashTable * details
char * name
struct _sdlFunction

Definition at line 228 of file php_sdl.h.

Collaboration diagram for _sdlFunction:
Class Members
struct _sdlBinding * binding
void * bindingAttributes
HashTable * faults
char * functionName
char * requestName
HashTable * requestParameters
char * responseName
HashTable * responseParameters
struct _sdlExtraAttribute

Definition at line 239 of file php_sdl.h.

Class Members
char * ns
char * val
struct _sdlAttribute

Definition at line 244 of file php_sdl.h.

Collaboration diagram for _sdlAttribute:
Class Members
char * def
encodePtr encode
HashTable * extraAttributes
char * fixed
sdlForm form
char * name
char * namens
char * ref
sdlUse use
union _sdlContentModel.u

Definition at line 169 of file php_sdl.h.

Class Members
HashTable * content
sdlTypePtr element
sdlTypePtr group
char * group_ref

Define Documentation

#define XSD_WHITESPACE_COLLAPSE   1

Definition at line 25 of file php_sdl.h.

#define XSD_WHITESPACE_PRESERVE   1

Definition at line 26 of file php_sdl.h.

#define XSD_WHITESPACE_REPLACE   1

Definition at line 27 of file php_sdl.h.


Typedef Documentation

typedef struct _sdlContentModel

Definition at line 163 of file php_sdl.h.

typedef struct * sdlContentModelPtr

Definition at line 163 of file php_sdl.h.

typedef struct sdlCtx sdlCtx
typedef struct _sdlFault sdlFault
typedef struct _sdlFault * sdlFaultPtr
typedef enum _sdlForm sdlForm
typedef enum _sdlTypeKind sdlTypeKind
typedef enum _sdlUse sdlUse

Enumeration Type Documentation

Enumerator:
BINDING_SOAP 
BINDING_HTTP 

Definition at line 29 of file php_sdl.h.

Enumerator:
XSD_CONTENT_ELEMENT 
XSD_CONTENT_SEQUENCE 
XSD_CONTENT_ALL 
XSD_CONTENT_CHOICE 
XSD_CONTENT_GROUP_REF 
XSD_CONTENT_GROUP 
XSD_CONTENT_ANY 

Definition at line 152 of file php_sdl.h.

Enumerator:
SOAP_RPC 
SOAP_DOCUMENT 

Definition at line 34 of file php_sdl.h.

Enumerator:
SOAP_ENCODED 
SOAP_LITERAL 

Definition at line 45 of file php_sdl.h.

enum _sdlForm
Enumerator:
XSD_FORM_DEFAULT 
XSD_FORM_QUALIFIED 
XSD_FORM_UNQUALIFIED 

Definition at line 193 of file php_sdl.h.

Enumerator:
SOAP_ENCODING_DEFAULT 
SOAP_ENCODING_1_1 
SOAP_ENCODING_1_2 

Definition at line 39 of file php_sdl.h.

Enumerator:
SOAP_TRANSPORT_HTTP 

Definition at line 50 of file php_sdl.h.

Enumerator:
XSD_TYPEKIND_SIMPLE 
XSD_TYPEKIND_LIST 
XSD_TYPEKIND_UNION 
XSD_TYPEKIND_COMPLEX 
XSD_TYPEKIND_RESTRICTION 
XSD_TYPEKIND_EXTENSION 

Definition at line 177 of file php_sdl.h.

enum _sdlUse
Enumerator:
XSD_USE_DEFAULT 
XSD_USE_OPTIONAL 
XSD_USE_PROHIBITED 
XSD_USE_REQUIRED 

Definition at line 186 of file php_sdl.h.


Function Documentation

void delete_sdl ( void *  handle)

Definition at line 3414 of file php_sdl.c.

{
       sdlPtr tmp = (sdlPtr)handle;

       if (!tmp->is_persistent) {
              delete_sdl_impl(tmp);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void delete_sdl_impl ( void *  handle)

Definition at line 3376 of file php_sdl.c.

{
       sdlPtr tmp = (sdlPtr)handle;

       zend_hash_destroy(&tmp->functions);
       if (tmp->source) {
              efree(tmp->source);
       }
       if (tmp->target_ns) {
              efree(tmp->target_ns);
       }
       if (tmp->elements) {
              zend_hash_destroy(tmp->elements);
              efree(tmp->elements);
       }
       if (tmp->encoders) {
              zend_hash_destroy(tmp->encoders);
              efree(tmp->encoders);
       }
       if (tmp->types) {
              zend_hash_destroy(tmp->types);
              efree(tmp->types);
       }
       if (tmp->groups) {
              zend_hash_destroy(tmp->groups);
              efree(tmp->groups);
       }
       if (tmp->bindings) {
              zend_hash_destroy(tmp->bindings);
              efree(tmp->bindings);
       }
       if (tmp->requests) {
              zend_hash_destroy(tmp->requests);
              efree(tmp->requests);
       }
       efree(tmp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

sdlBindingPtr get_binding_from_name ( sdlPtr  sdl,
char *  name,
char *  ns 
)

Definition at line 198 of file php_sdl.c.

{
       sdlBindingPtr binding = NULL;
       smart_str key = {0};

       smart_str_appends(&key, ns);
       smart_str_appendc(&key, ':');
       smart_str_appends(&key, name);
       smart_str_0(&key);

       zend_hash_find(sdl->bindings, key.c, key.len, (void **)&binding);

       smart_str_free(&key);
       return binding;
}

Here is the call graph for this function:

Definition at line 180 of file php_sdl.c.

{
       sdlBindingPtr *binding;

       if (sdl == NULL) {
              return NULL;
       }

       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) {
                     return *binding;
              }
       }
       return NULL;
}
encodePtr get_encoder ( sdlPtr  sdl,
const char *  ns,
const char *  type 
)

Definition at line 110 of file php_sdl.c.

{
       encodePtr enc = NULL;
       char *nscat;
       int ns_len = strlen(ns);
       int type_len = strlen(type);
       int len = ns_len + type_len + 1;

       nscat = emalloc(len + 1);
       memcpy(nscat, ns, ns_len);
       nscat[ns_len] = ':';
       memcpy(nscat+ns_len+1, type, type_len);
       nscat[len] = '\0';

       enc = get_encoder_ex(sdl, nscat, len);

       if (enc == NULL &&
           ((ns_len == sizeof(SOAP_1_1_ENC_NAMESPACE)-1 &&
             memcmp(ns, SOAP_1_1_ENC_NAMESPACE, sizeof(SOAP_1_1_ENC_NAMESPACE)-1) == 0) ||
            (ns_len == sizeof(SOAP_1_2_ENC_NAMESPACE)-1 &&
             memcmp(ns, SOAP_1_2_ENC_NAMESPACE, sizeof(SOAP_1_2_ENC_NAMESPACE)-1) == 0))) {
              char *enc_nscat;
              int enc_ns_len;
              int enc_len;

              enc_ns_len = sizeof(XSD_NAMESPACE)-1;
              enc_len = enc_ns_len + type_len + 1;
              enc_nscat = emalloc(enc_len + 1);
              memcpy(enc_nscat, XSD_NAMESPACE, sizeof(XSD_NAMESPACE)-1);
              enc_nscat[enc_ns_len] = ':';
              memcpy(enc_nscat+enc_ns_len+1, type, type_len);
              enc_nscat[enc_len] = '\0';

              enc = get_encoder_ex(NULL, enc_nscat, enc_len);
              efree(enc_nscat);
              if (enc && sdl) {
                     encodePtr new_enc    = pemalloc(sizeof(encode), sdl->is_persistent);
                     memcpy(new_enc, enc, sizeof(encode));
                     if (sdl->is_persistent) {
                            new_enc->details.ns = zend_strndup(ns, ns_len);
                            new_enc->details.type_str = strdup(new_enc->details.type_str);
                     } else {
                            new_enc->details.ns = estrndup(ns, ns_len);
                            new_enc->details.type_str = estrdup(new_enc->details.type_str);
                     }
                     if (sdl->encoders == NULL) {
                            sdl->encoders = pemalloc(sizeof(HashTable), sdl->is_persistent);
                            zend_hash_init(sdl->encoders, 0, NULL, delete_encoder, sdl->is_persistent);
                     }
                     zend_hash_update(sdl->encoders, nscat, len + 1, &new_enc, sizeof(encodePtr), NULL);
                     enc = new_enc;
              }
       }
       efree(nscat);
       return enc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

encodePtr get_encoder_ex ( sdlPtr  sdl,
const char *  nscat,
int  len 
)

Definition at line 167 of file php_sdl.c.

{
       encodePtr *enc;
       TSRMLS_FETCH();

       if (zend_hash_find(&SOAP_GLOBAL(defEnc), (char*)nscat, len + 1, (void **)&enc) == SUCCESS) {
              return (*enc);
       } else if (sdl && sdl->encoders && zend_hash_find(sdl->encoders, (char*)nscat, len + 1, (void **)&enc) == SUCCESS) {
              return (*enc);
       }
       return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

encodePtr get_encoder_from_prefix ( sdlPtr  sdl,
xmlNodePtr  data,
const xmlChar *  type 
)

Definition at line 49 of file php_sdl.c.

{
       encodePtr enc = NULL;
       xmlNsPtr nsptr;
       char *ns, *cptype;

       parse_namespace(type, &cptype, &ns);
       nsptr = xmlSearchNs(node->doc, node, BAD_CAST(ns));
       if (nsptr != NULL) {
              enc = get_encoder(sdl, (char*)nsptr->href, cptype);
              if (enc == NULL) {
                     enc = get_encoder_ex(sdl, cptype, strlen(cptype));
              }
       } else {
              enc = get_encoder_ex(sdl, (char*)type, xmlStrlen(type));
       }
       efree(cptype);
       if (ns) {efree(ns);}
       return enc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

sdlPtr get_sdl ( zval *  this_ptr,
char *  uri,
long cache_wsdl  TSRMLS_DC 
)

Definition at line 3154 of file php_sdl.c.

{
       char  fn[MAXPATHLEN];
       sdlPtr sdl = NULL;
       char* old_error_code = SOAP_GLOBAL(error_code);
       int uri_len = 0;
       php_stream_context *context=NULL;
       zval **tmp, **proxy_host, **proxy_port, *orig_context = NULL, *new_context = NULL;
       smart_str headers = {0};
       char* key = NULL;
       time_t t = time(0);

       if (strchr(uri,':') != NULL || IS_ABSOLUTE_PATH(uri, uri_len)) {
              uri_len = strlen(uri);
       } else if (VCWD_REALPATH(uri, fn) == NULL) {
              cache_wsdl = WSDL_CACHE_NONE;
       } else {
              uri = fn;
              uri_len = strlen(uri);
       }

       if ((cache_wsdl & WSDL_CACHE_MEMORY) && SOAP_GLOBAL(mem_cache)) {
              sdl_cache_bucket *p;

              if (SUCCESS == zend_hash_find(SOAP_GLOBAL(mem_cache), uri, uri_len+1, (void*)&p)) {
                     if (p->time < t - SOAP_GLOBAL(cache_ttl)) {
                            /* in-memory cache entry is expired */
                            zend_hash_del(&EG(persistent_list), uri, uri_len+1);
                     } else {
                            return p->sdl;
                     }
              }
       }

       if ((cache_wsdl & WSDL_CACHE_DISK) && (uri_len < MAXPATHLEN)) {
              time_t t = time(0);
              char md5str[33];
              PHP_MD5_CTX context;
              unsigned char digest[16];
              int len = strlen(SOAP_GLOBAL(cache_dir));
              time_t cached;
              char *user = php_get_current_user();
              int user_len = user ? strlen(user) + 1 : 0;

              md5str[0] = '\0';
              PHP_MD5Init(&context);
              PHP_MD5Update(&context, (unsigned char*)uri, uri_len);
              PHP_MD5Final(digest, &context);
              make_digest(md5str, digest);
              key = emalloc(len+sizeof("/wsdl-")-1+user_len+sizeof(md5str));
              memcpy(key,SOAP_GLOBAL(cache_dir),len);
              memcpy(key+len,"/wsdl-",sizeof("/wsdl-")-1);
              len += sizeof("/wsdl-")-1;
              if (user_len) {
                     memcpy(key+len, user, user_len-1);
                     len += user_len-1;
                     key[len++] = '-';
              }
              memcpy(key+len,md5str,sizeof(md5str));

              if ((sdl = get_sdl_from_cache(key, uri, t-SOAP_GLOBAL(cache_ttl), &cached TSRMLS_CC)) != NULL) {
                     t = cached;
                     efree(key);
                     goto cache_in_memory;
              }
       }

       if (SUCCESS == zend_hash_find(Z_OBJPROP_P(this_ptr),
                     "_stream_context", sizeof("_stream_context"), (void**)&tmp)) {
              context = php_stream_context_from_zval(*tmp, 0);
       } else {
              context = php_stream_context_alloc();
       }

       if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_proxy_host", sizeof("_proxy_host"), (void **) &proxy_host) == SUCCESS &&
           Z_TYPE_PP(proxy_host) == IS_STRING &&
           zend_hash_find(Z_OBJPROP_P(this_ptr), "_proxy_port", sizeof("_proxy_port"), (void **) &proxy_port) == SUCCESS &&
           Z_TYPE_PP(proxy_port) == IS_LONG) {
              zval str_port, *str_proxy;
              smart_str proxy = {0};
              str_port = **proxy_port;
              zval_copy_ctor(&str_port);
              convert_to_string(&str_port);
              smart_str_appends(&proxy,"tcp://");
              smart_str_appends(&proxy,Z_STRVAL_PP(proxy_host));
              smart_str_appends(&proxy,":");
              smart_str_appends(&proxy,Z_STRVAL(str_port));
              smart_str_0(&proxy);
              zval_dtor(&str_port);
              MAKE_STD_ZVAL(str_proxy);
              ZVAL_STRING(str_proxy, proxy.c, 1);
              smart_str_free(&proxy);
              
              if (!context) {
                     context = php_stream_context_alloc();
              }
              php_stream_context_set_option(context, "http", "proxy", str_proxy);
              zval_ptr_dtor(&str_proxy);

              if (uri_len < sizeof("https://")-1 ||
                  strncasecmp(uri, "https://", sizeof("https://")-1) != 0) {
                     MAKE_STD_ZVAL(str_proxy);
                     ZVAL_BOOL(str_proxy, 1);
                     php_stream_context_set_option(context, "http", "request_fulluri", str_proxy);
                     zval_ptr_dtor(&str_proxy);
              }

              proxy_authentication(this_ptr, &headers TSRMLS_CC);
       }

       basic_authentication(this_ptr, &headers TSRMLS_CC);

       /* Use HTTP/1.1 with "Connection: close" by default */
       if (php_stream_context_get_option(context, "http", "protocol_version", &tmp) == FAILURE) {
       zval *http_version;
              MAKE_STD_ZVAL(http_version);
              ZVAL_DOUBLE(http_version, 1.1);
              php_stream_context_set_option(context, "http", "protocol_version", http_version);
              zval_ptr_dtor(&http_version);
              smart_str_appendl(&headers, "Connection: close", sizeof("Connection: close")-1);
       }

       if (headers.len > 0) {
              zval *str_headers;

              if (!context) {
                     context = php_stream_context_alloc();
              }

              smart_str_0(&headers);
              MAKE_STD_ZVAL(str_headers);
              ZVAL_STRING(str_headers, headers.c, 1);
              php_stream_context_set_option(context, "http", "header", str_headers);
              smart_str_free(&headers);
              zval_ptr_dtor(&str_headers);
       }

       if (context) {
              MAKE_STD_ZVAL(new_context);
              php_stream_context_to_zval(context, new_context);
              orig_context = php_libxml_switch_context(new_context TSRMLS_CC);
       }

       SOAP_GLOBAL(error_code) = "WSDL";

       sdl = load_wsdl(this_ptr, uri TSRMLS_CC);
       if (sdl) {
              sdl->is_persistent = 0;
       }

       SOAP_GLOBAL(error_code) = old_error_code;

       if (context) {
              php_libxml_switch_context(orig_context TSRMLS_CC);
              zval_ptr_dtor(&new_context);
       }

       if ((cache_wsdl & WSDL_CACHE_DISK) && key) {
              if (sdl) {
                     add_sdl_to_cache(key, uri, t, sdl TSRMLS_CC);
              }
              efree(key);
       }

cache_in_memory:
       if (cache_wsdl & WSDL_CACHE_MEMORY) {
              if (sdl) {
                     sdlPtr psdl;
                     sdl_cache_bucket p;

                     if (SOAP_GLOBAL(mem_cache) == NULL) {
                            SOAP_GLOBAL(mem_cache) = malloc(sizeof(HashTable));
                            zend_hash_init(SOAP_GLOBAL(mem_cache), 0, NULL, delete_psdl, 1);
                     } else if (SOAP_GLOBAL(cache_limit) > 0 &&
                                SOAP_GLOBAL(cache_limit) <= zend_hash_num_elements(SOAP_GLOBAL(mem_cache))) {
                            /* in-memory cache overflow */
                            sdl_cache_bucket *q;
                            HashPosition pos;
                            time_t latest = t;
                            char *key = NULL;
                            uint key_len;
                            ulong idx;

                            for (zend_hash_internal_pointer_reset_ex(SOAP_GLOBAL(mem_cache), &pos);
                                    zend_hash_get_current_data_ex(SOAP_GLOBAL(mem_cache), (void **) &q, &pos) == SUCCESS;
                                    zend_hash_move_forward_ex(SOAP_GLOBAL(mem_cache), &pos)) {
                                   if (q->time < latest) {
                                          latest = q->time;
                                          zend_hash_get_current_key_ex(SOAP_GLOBAL(mem_cache), &key, &key_len, &idx, 0, &pos);
                                   }
                            }
                            if (key) {
                                   zend_hash_del(SOAP_GLOBAL(mem_cache), key, key_len);
                            } else {
                                   return sdl;
                            }
                     }

                     psdl = make_persistent_sdl(sdl TSRMLS_CC);
                     psdl->is_persistent = 1;
                     p.time = t;
                     p.sdl = psdl;

                     if (SUCCESS == zend_hash_update(SOAP_GLOBAL(mem_cache), uri,
                                                                             uri_len+1, (void*)&p, sizeof(sdl_cache_bucket), NULL)) {
                            /* remove non-persitent sdl structure */
                            delete_sdl_impl(sdl);
                            /* and replace it with persistent one */
                            sdl = psdl;
                     } else {
                            php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to register persistent entry");
                            /* clean up persistent sdl */
                            delete_psdl(&p);
                            /* keep non-persistent sdl and return it */
                     }
              }
       }

       return sdl;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sdl_restore_uri_credentials ( sdlCtx *ctx  TSRMLS_DC)

Definition at line 277 of file php_sdl.c.

{
       if (ctx->old_header) {
           php_stream_context_set_option(ctx->context, "http", "header", ctx->old_header);
           zval_ptr_dtor(&ctx->old_header);
              ctx->old_header = NULL;
       }
       ctx->context = NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sdl_set_uri_credentials ( sdlCtx ctx,
char *uri  TSRMLS_DC 
)

Definition at line 229 of file php_sdl.c.

{
       char *s;
       int l1, l2;
       zval *context = NULL;
       zval **header = NULL;

       /* check if we load xsd from the same server */
       s = strstr(ctx->sdl->source, "://");
       if (!s) return;
       s = strchr(s+3, '/');
       l1 = s - ctx->sdl->source;
       s = strstr((char*)uri, "://");
       if (!s) return;
       s = strchr(s+3, '/');
       l2 = s - (char*)uri;
       if (l1 != l2 || memcmp(ctx->sdl->source, uri, l1) != 0) {
              /* another server. clear authentication credentals */
              context = php_libxml_switch_context(NULL TSRMLS_CC);
              php_libxml_switch_context(context TSRMLS_CC);
              if (context) {
                     ctx->context = php_stream_context_from_zval(context, 1);

                     if (ctx->context &&
                         php_stream_context_get_option(ctx->context, "http", "header", &header) == SUCCESS) {
                            s = strstr(Z_STRVAL_PP(header), "Authorization: Basic");
                            if (s && (s == Z_STRVAL_PP(header) || *(s-1) == '\n' || *(s-1) == '\r')) {
                                   char *rest = strstr(s, "\r\n");
                                   if (rest) {
                                          zval new_header;
                                   
                                          rest += 2;
                                          Z_TYPE(new_header) = IS_STRING;
                                          Z_STRLEN(new_header) = Z_STRLEN_PP(header) - (rest - s);
                                          Z_STRVAL(new_header) = emalloc(Z_STRLEN_PP(header) + 1);
                                          memcpy(Z_STRVAL(new_header), Z_STRVAL_PP(header), s - Z_STRVAL_PP(header));
                                          memcpy(Z_STRVAL(new_header) + (s - Z_STRVAL_PP(header)), rest, Z_STRLEN_PP(header) - (rest - Z_STRVAL_PP(header)) + 1);
                                          ctx->old_header = *header;
                                          Z_ADDREF_P(ctx->old_header);
                                          php_stream_context_set_option(ctx->context, "http", "header", &new_header);
                                          zval_dtor(&new_header);
                                   }
                            }
                     }
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function: