Back to index

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

Go to the source code of this file.

Classes

struct  _php_stream_notifier
struct  _php_stream_context

Defines

#define PHP_STREAM_NOTIFIER_PROGRESS   1
#define php_stream_context_from_zval(zcontext, nocontext)
#define php_stream_context_to_zval(context, zval)   { ZVAL_RESOURCE(zval, (context)->rsrc_id); zend_list_addref((context)->rsrc_id); }
#define PHP_STREAM_NOTIFY_RESOLVE   1
#define PHP_STREAM_NOTIFY_CONNECT   2
#define PHP_STREAM_NOTIFY_AUTH_REQUIRED   3
#define PHP_STREAM_NOTIFY_MIME_TYPE_IS   4
#define PHP_STREAM_NOTIFY_FILE_SIZE_IS   5
#define PHP_STREAM_NOTIFY_REDIRECTED   6
#define PHP_STREAM_NOTIFY_PROGRESS   7
#define PHP_STREAM_NOTIFY_COMPLETED   8
#define PHP_STREAM_NOTIFY_FAILURE   9
#define PHP_STREAM_NOTIFY_AUTH_RESULT   10
#define PHP_STREAM_NOTIFY_SEVERITY_INFO   0
#define PHP_STREAM_NOTIFY_SEVERITY_WARN   1
#define PHP_STREAM_NOTIFY_SEVERITY_ERR   2
#define php_stream_notify_info(context, code, xmsg, xcode)
#define php_stream_notify_progress(context, bsofar, bmax)
#define php_stream_notify_progress_init(context, sofar, bmax)
#define php_stream_notify_progress_increment(context, dsofar, dmax)
#define php_stream_notify_file_size(context, file_size, xmsg, xcode)
#define php_stream_notify_error(context, code, xmsg, xcode)

Typedefs

typedef void(* php_stream_notification_func )(php_stream_context *context, int notifycode, int severity, char *xmsg, int xcode, size_t bytes_sofar, size_t bytes_max, void *ptr TSRMLS_DC)
typedef struct _php_stream_notifier

Functions

PHPAPI void php_stream_context_free (php_stream_context *context)
PHPAPI php_stream_context * php_stream_context_alloc (void)
PHPAPI int php_stream_context_get_option (php_stream_context *context, const char *wrappername, const char *optionname, zval ***optionvalue)
PHPAPI int php_stream_context_set_option (php_stream_context *context, const char *wrappername, const char *optionname, zval *optionvalue)
PHPAPI int php_stream_context_get_link (php_stream_context *context, const char *hostent, php_stream **stream)
PHPAPI int php_stream_context_set_link (php_stream_context *context, const char *hostent, php_stream *stream)
PHPAPI int php_stream_context_del_link (php_stream_context *context, php_stream *stream)
PHPAPI php_stream_notifier * php_stream_notification_alloc (void)
PHPAPI void php_stream_notification_free (php_stream_notifier *notifier)
PHPAPI void php_stream_notification_notify (php_stream_context *context, int notifycode, int severity, char *xmsg, int xcode, size_t bytes_sofar, size_t bytes_max, void *ptr TSRMLS_DC)
PHPAPI php_stream_context * php_stream_context_set (php_stream *stream, php_stream_context *context)

Class Documentation

struct _php_stream_context

Definition at line 53 of file php_stream_context.h.

Class Members
zval * links
php_stream_notifier * notifier
zval * options
int rsrc_id

Define Documentation

#define php_stream_context_from_zval (   zcontext,
  nocontext 
)
Value:
( \
              (zcontext) ? zend_fetch_resource(&(zcontext) TSRMLS_CC, -1, "Stream-Context", NULL, 1, php_le_stream_context()) : \
              (nocontext) ? NULL : \
              FG(default_context) ? FG(default_context) : \
              (FG(default_context) = php_stream_context_alloc()) )

Definition at line 35 of file php_stream_context.h.

#define php_stream_context_to_zval (   context,
  zval 
)    { ZVAL_RESOURCE(zval, (context)->rsrc_id); zend_list_addref((context)->rsrc_id); }

Definition at line 41 of file php_stream_context.h.

Definition at line 30 of file php_stream_context.h.

Definition at line 82 of file php_stream_context.h.

Definition at line 89 of file php_stream_context.h.

Definition at line 87 of file php_stream_context.h.

#define PHP_STREAM_NOTIFY_CONNECT   2

Definition at line 81 of file php_stream_context.h.

#define php_stream_notify_error (   context,
  code,
  xmsg,
  xcode 
)
Value:
do { if ((context) && (context)->notifier) {\
       php_stream_notification_notify((context), (code), PHP_STREAM_NOTIFY_SEVERITY_ERR, \
                     (xmsg), (xcode), 0, 0, NULL TSRMLS_CC); } } while(0)

Definition at line 124 of file php_stream_context.h.

#define PHP_STREAM_NOTIFY_FAILURE   9

Definition at line 88 of file php_stream_context.h.

#define php_stream_notify_file_size (   context,
  file_size,
  xmsg,
  xcode 
)
Value:
do { if ((context) && (context)->notifier) { \
       php_stream_notification_notify((context), PHP_STREAM_NOTIFY_FILE_SIZE_IS, PHP_STREAM_NOTIFY_SEVERITY_INFO, \
                     (xmsg), (xcode), 0, (file_size), NULL TSRMLS_CC); } } while(0)

Definition at line 120 of file php_stream_context.h.

Definition at line 84 of file php_stream_context.h.

#define php_stream_notify_info (   context,
  code,
  xmsg,
  xcode 
)
Value:
do { if ((context) && (context)->notifier) { \
       php_stream_notification_notify((context), (code), PHP_STREAM_NOTIFY_SEVERITY_INFO, \
                            (xmsg), (xcode), 0, 0, NULL TSRMLS_CC); } } while (0)

Definition at line 101 of file php_stream_context.h.

Definition at line 83 of file php_stream_context.h.

Definition at line 86 of file php_stream_context.h.

#define php_stream_notify_progress (   context,
  bsofar,
  bmax 
)
Value:
do { if ((context) && (context)->notifier) { \
       php_stream_notification_notify((context), PHP_STREAM_NOTIFY_PROGRESS, PHP_STREAM_NOTIFY_SEVERITY_INFO, \
                     NULL, 0, (bsofar), (bmax), NULL TSRMLS_CC); } } while(0)

Definition at line 105 of file php_stream_context.h.

#define php_stream_notify_progress_increment (   context,
  dsofar,
  dmax 
)
Value:
do { if ((context) && (context)->notifier && (context)->notifier->mask & PHP_STREAM_NOTIFIER_PROGRESS) { \
       (context)->notifier->progress += (dsofar); \
       (context)->notifier->progress_max += (dmax); \
       php_stream_notify_progress((context), (context)->notifier->progress, (context)->notifier->progress_max); } } while (0)

Definition at line 115 of file php_stream_context.h.

#define php_stream_notify_progress_init (   context,
  sofar,
  bmax 
)
Value:
do { if ((context) && (context)->notifier) { \
       (context)->notifier->progress = (sofar); \
       (context)->notifier->progress_max = (bmax); \
       (context)->notifier->mask |= PHP_STREAM_NOTIFIER_PROGRESS; \
       php_stream_notify_progress((context), (sofar), (bmax)); } } while (0)

Definition at line 109 of file php_stream_context.h.

Definition at line 85 of file php_stream_context.h.

#define PHP_STREAM_NOTIFY_RESOLVE   1

Definition at line 80 of file php_stream_context.h.

Definition at line 93 of file php_stream_context.h.

Definition at line 91 of file php_stream_context.h.

Definition at line 92 of file php_stream_context.h.


Typedef Documentation

typedef struct _php_stream_notifier

Definition at line 43 of file php_stream_context.h.

typedef void(* php_stream_notification_func)(php_stream_context *context, int notifycode, int severity, char *xmsg, int xcode, size_t bytes_sofar, size_t bytes_max, void *ptr TSRMLS_DC)

Definition at line 24 of file php_stream_context.h.


Function Documentation

PHPAPI php_stream_context* php_stream_context_alloc ( void  )

Definition at line 2049 of file streams.c.

{
       php_stream_context *context;

       context = ecalloc(1, sizeof(php_stream_context));
       context->notifier = NULL;
       MAKE_STD_ZVAL(context->options);
       array_init(context->options);

       context->rsrc_id = ZEND_REGISTER_RESOURCE(NULL, context, php_le_stream_context());
       return context;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PHPAPI int php_stream_context_del_link ( php_stream_context *  context,
php_stream *  stream 
)

Definition at line 2141 of file streams.c.

{
       php_stream **pstream;
       char *hostent;
       int ret = SUCCESS;

       if (!context || !context->links || !stream) {
              return FAILURE;
       }

       for(zend_hash_internal_pointer_reset(Z_ARRVAL_P(context->links));
              SUCCESS == zend_hash_get_current_data(Z_ARRVAL_P(context->links), (void**)&pstream);
              zend_hash_move_forward(Z_ARRVAL_P(context->links))) {
              if (*pstream == stream) {
                     if (SUCCESS == zend_hash_get_current_key(Z_ARRVAL_P(context->links), &hostent, NULL, 0)) {
                            if (FAILURE == zend_hash_del(Z_ARRVAL_P(context->links), (char*)hostent, strlen(hostent)+1)) {
                                   ret = FAILURE;
                            }
                     } else {
                            ret = FAILURE;
                     }
              }
       }

       return ret;
}

Here is the caller graph for this function:

PHPAPI void php_stream_context_free ( php_stream_context *  context)

Definition at line 2032 of file streams.c.

{
       if (context->options) {
              zval_ptr_dtor(&context->options);
              context->options = NULL;
       }
       if (context->notifier) {
              php_stream_notification_free(context->notifier);
              context->notifier = NULL;
       }
       if (context->links) {
              zval_ptr_dtor(&context->links);
              context->links = NULL;
       }
       efree(context);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PHPAPI int php_stream_context_get_link ( php_stream_context *  context,
const char *  hostent,
php_stream **  stream 
)

Definition at line 2109 of file streams.c.

{
       php_stream **pstream;

       if (!stream || !hostent || !context || !(context->links)) {
              return FAILURE;
       }
       if (SUCCESS == zend_hash_find(Z_ARRVAL_P(context->links), (char*)hostent, strlen(hostent)+1, (void**)&pstream)) {
              *stream = *pstream;
              return SUCCESS;
       }
       return FAILURE;
}

Here is the call graph for this function:

PHPAPI int php_stream_context_get_option ( php_stream_context *  context,
const char *  wrappername,
const char *  optionname,
zval ***  optionvalue 
)

Definition at line 2075 of file streams.c.

{
       zval **wrapperhash;

       if (FAILURE == zend_hash_find(Z_ARRVAL_P(context->options), (char*)wrappername, strlen(wrappername)+1, (void**)&wrapperhash)) {
              return FAILURE;
       }
       return zend_hash_find(Z_ARRVAL_PP(wrapperhash), (char*)optionname, strlen(optionname)+1, (void**)optionvalue);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PHPAPI php_stream_context* php_stream_context_set ( php_stream *  stream,
php_stream_context *  context 
)

Definition at line 2008 of file streams.c.

{
       php_stream_context *oldcontext = stream->context;
       TSRMLS_FETCH();

       stream->context = context;

       if (context) {
              zend_list_addref(context->rsrc_id);
       }
       if (oldcontext) {
              zend_list_delete(oldcontext->rsrc_id);
       }

       return oldcontext;
}

Here is the caller graph for this function:

PHPAPI int php_stream_context_set_link ( php_stream_context *  context,
const char *  hostent,
php_stream *  stream 
)

Definition at line 2124 of file streams.c.

{
       if (!context) {
              return FAILURE;
       }
       if (!context->links) {
              ALLOC_INIT_ZVAL(context->links);
              array_init(context->links);
       }
       if (!stream) {
              /* Delete any entry for <hostent> */
              return zend_hash_del(Z_ARRVAL_P(context->links), (char*)hostent, strlen(hostent)+1);
       }
       return zend_hash_update(Z_ARRVAL_P(context->links), (char*)hostent, strlen(hostent)+1, (void**)&stream, sizeof(php_stream *), NULL);
}
PHPAPI int php_stream_context_set_option ( php_stream_context *  context,
const char *  wrappername,
const char *  optionname,
zval *  optionvalue 
)

Definition at line 2086 of file streams.c.

{
       zval **wrapperhash;
       zval *category, *copied_val;

       ALLOC_INIT_ZVAL(copied_val);
       *copied_val = *optionvalue;
       zval_copy_ctor(copied_val);
       INIT_PZVAL(copied_val);

       if (FAILURE == zend_hash_find(Z_ARRVAL_P(context->options), (char*)wrappername, strlen(wrappername)+1, (void**)&wrapperhash)) {
              MAKE_STD_ZVAL(category);
              array_init(category);
              if (FAILURE == zend_hash_update(Z_ARRVAL_P(context->options), (char*)wrappername, strlen(wrappername)+1, (void**)&category, sizeof(zval *), NULL)) {
                     return FAILURE;
              }

              wrapperhash = &category;
       }
       return zend_hash_update(Z_ARRVAL_PP(wrapperhash), (char*)optionname, strlen(optionname)+1, (void**)&copied_val, sizeof(zval *), NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PHPAPI php_stream_notifier* php_stream_notification_alloc ( void  )

Definition at line 2062 of file streams.c.

{
       return ecalloc(1, sizeof(php_stream_notifier));
}

Here is the caller graph for this function:

PHPAPI void php_stream_notification_free ( php_stream_notifier *  notifier)

Definition at line 2067 of file streams.c.

{
       if (notifier->dtor) {
              notifier->dtor(notifier);
       }
       efree(notifier);
}

Here is the caller graph for this function:

PHPAPI void php_stream_notification_notify ( php_stream_context *  context,
int  notifycode,
int  severity,
char *  xmsg,
int  xcode,
size_t  bytes_sofar,
size_t  bytes_max,
void *ptr  TSRMLS_DC 
)

Definition at line 2025 of file streams.c.

{
       if (context && context->notifier)
              context->notifier->func(context, notifycode, severity, xmsg, xcode, bytes_sofar, bytes_max, ptr TSRMLS_CC);
}