Annotation of embedaddon/php/main/streams/php_stream_context.h, revision 1.1

1.1     ! misho       1: /*
        !             2:    +----------------------------------------------------------------------+
        !             3:    | PHP Version 5                                                        |
        !             4:    +----------------------------------------------------------------------+
        !             5:    | Copyright (c) 1997-2012 The PHP Group                                |
        !             6:    +----------------------------------------------------------------------+
        !             7:    | This source file is subject to version 3.01 of the PHP license,      |
        !             8:    | that is bundled with this package in the file LICENSE, and is        |
        !             9:    | available through the world-wide-web at the following url:           |
        !            10:    | http://www.php.net/license/3_01.txt                                  |
        !            11:    | If you did not receive a copy of the PHP license and are unable to   |
        !            12:    | obtain it through the world-wide-web, please send a note to          |
        !            13:    | license@php.net so we can mail you a copy immediately.               |
        !            14:    +----------------------------------------------------------------------+
        !            15:    | Author: Wez Furlong <wez@thebrainroom.com>                           |
        !            16:    +----------------------------------------------------------------------+
        !            17:  */
        !            18: 
        !            19: /* $Id: php_stream_context.h 321634 2012-01-01 13:15:04Z felipe $ */
        !            20: 
        !            21: /* Stream context and status notification related definitions */
        !            22: 
        !            23: /* callback for status notifications */
        !            24: typedef void (*php_stream_notification_func)(php_stream_context *context,
        !            25:                int notifycode, int severity,
        !            26:                char *xmsg, int xcode,
        !            27:                size_t bytes_sofar, size_t bytes_max,
        !            28:                void * ptr TSRMLS_DC);
        !            29: 
        !            30: #define PHP_STREAM_NOTIFIER_PROGRESS   1
        !            31: 
        !            32: /* Attempt to fetch context from the zval passed,
        !            33:    If no context was passed, use the default context
        !            34:    The default context has not yet been created, do it now. */
        !            35: #define php_stream_context_from_zval(zcontext, nocontext) ( \
        !            36:                (zcontext) ? zend_fetch_resource(&(zcontext) TSRMLS_CC, -1, "Stream-Context", NULL, 1, php_le_stream_context()) : \
        !            37:                (nocontext) ? NULL : \
        !            38:                FG(default_context) ? FG(default_context) : \
        !            39:                (FG(default_context) = php_stream_context_alloc()) )
        !            40: 
        !            41: #define php_stream_context_to_zval(context, zval) { ZVAL_RESOURCE(zval, (context)->rsrc_id); zend_list_addref((context)->rsrc_id); }
        !            42: 
        !            43: typedef struct _php_stream_notifier php_stream_notifier;
        !            44: 
        !            45: struct _php_stream_notifier {
        !            46:        php_stream_notification_func func;
        !            47:        void (*dtor)(php_stream_notifier *notifier);
        !            48:        void *ptr;
        !            49:        int mask;
        !            50:        size_t progress, progress_max; /* position for progress notification */
        !            51: };
        !            52: 
        !            53: struct _php_stream_context {
        !            54:        php_stream_notifier *notifier;
        !            55:        zval *options;  /* hash keyed by wrapper family or specific wrapper */
        !            56:        zval *links;    /* hash keyed by hostent for connection pooling */
        !            57:        int rsrc_id;    /* used for auto-cleanup */
        !            58: };
        !            59: 
        !            60: BEGIN_EXTERN_C()
        !            61: PHPAPI void php_stream_context_free(php_stream_context *context);
        !            62: PHPAPI php_stream_context *php_stream_context_alloc(void);
        !            63: PHPAPI int php_stream_context_get_option(php_stream_context *context,
        !            64:                const char *wrappername, const char *optionname, zval ***optionvalue);
        !            65: PHPAPI int php_stream_context_set_option(php_stream_context *context,
        !            66:                const char *wrappername, const char *optionname, zval *optionvalue);
        !            67: 
        !            68: PHPAPI int php_stream_context_get_link(php_stream_context *context,
        !            69:                const char *hostent, php_stream **stream);
        !            70: PHPAPI int php_stream_context_set_link(php_stream_context *context,
        !            71:                const char *hostent, php_stream *stream);
        !            72: PHPAPI int php_stream_context_del_link(php_stream_context *context,
        !            73:                php_stream *stream);
        !            74: 
        !            75: PHPAPI php_stream_notifier *php_stream_notification_alloc(void);
        !            76: PHPAPI void php_stream_notification_free(php_stream_notifier *notifier);
        !            77: END_EXTERN_C()
        !            78: 
        !            79: /* not all notification codes are implemented */
        !            80: #define PHP_STREAM_NOTIFY_RESOLVE              1
        !            81: #define PHP_STREAM_NOTIFY_CONNECT              2
        !            82: #define PHP_STREAM_NOTIFY_AUTH_REQUIRED                3
        !            83: #define PHP_STREAM_NOTIFY_MIME_TYPE_IS 4
        !            84: #define PHP_STREAM_NOTIFY_FILE_SIZE_IS 5
        !            85: #define PHP_STREAM_NOTIFY_REDIRECTED   6
        !            86: #define PHP_STREAM_NOTIFY_PROGRESS             7
        !            87: #define PHP_STREAM_NOTIFY_COMPLETED            8
        !            88: #define PHP_STREAM_NOTIFY_FAILURE              9
        !            89: #define PHP_STREAM_NOTIFY_AUTH_RESULT  10
        !            90: 
        !            91: #define PHP_STREAM_NOTIFY_SEVERITY_INFO        0
        !            92: #define PHP_STREAM_NOTIFY_SEVERITY_WARN        1
        !            93: #define PHP_STREAM_NOTIFY_SEVERITY_ERR 2
        !            94: 
        !            95: BEGIN_EXTERN_C()
        !            96: PHPAPI void php_stream_notification_notify(php_stream_context *context, int notifycode, int severity,
        !            97:                char *xmsg, int xcode, size_t bytes_sofar, size_t bytes_max, void * ptr TSRMLS_DC);
        !            98: PHPAPI php_stream_context *php_stream_context_set(php_stream *stream, php_stream_context *context);
        !            99: END_EXTERN_C()
        !           100: 
        !           101: #define php_stream_notify_info(context, code, xmsg, xcode)     do { if ((context) && (context)->notifier) { \
        !           102:        php_stream_notification_notify((context), (code), PHP_STREAM_NOTIFY_SEVERITY_INFO, \
        !           103:                                (xmsg), (xcode), 0, 0, NULL TSRMLS_CC); } } while (0)
        !           104:                        
        !           105: #define php_stream_notify_progress(context, bsofar, bmax) do { if ((context) && (context)->notifier) { \
        !           106:        php_stream_notification_notify((context), PHP_STREAM_NOTIFY_PROGRESS, PHP_STREAM_NOTIFY_SEVERITY_INFO, \
        !           107:                        NULL, 0, (bsofar), (bmax), NULL TSRMLS_CC); } } while(0)
        !           108: 
        !           109: #define php_stream_notify_progress_init(context, sofar, bmax) do { if ((context) && (context)->notifier) { \
        !           110:        (context)->notifier->progress = (sofar); \
        !           111:        (context)->notifier->progress_max = (bmax); \
        !           112:        (context)->notifier->mask |= PHP_STREAM_NOTIFIER_PROGRESS; \
        !           113:        php_stream_notify_progress((context), (sofar), (bmax)); } } while (0)
        !           114: 
        !           115: #define php_stream_notify_progress_increment(context, dsofar, dmax) do { if ((context) && (context)->notifier && (context)->notifier->mask & PHP_STREAM_NOTIFIER_PROGRESS) { \
        !           116:        (context)->notifier->progress += (dsofar); \
        !           117:        (context)->notifier->progress_max += (dmax); \
        !           118:        php_stream_notify_progress((context), (context)->notifier->progress, (context)->notifier->progress_max); } } while (0)
        !           119: 
        !           120: #define php_stream_notify_file_size(context, file_size, xmsg, xcode) do { if ((context) && (context)->notifier) { \
        !           121:        php_stream_notification_notify((context), PHP_STREAM_NOTIFY_FILE_SIZE_IS, PHP_STREAM_NOTIFY_SEVERITY_INFO, \
        !           122:                        (xmsg), (xcode), 0, (file_size), NULL TSRMLS_CC); } } while(0)
        !           123:        
        !           124: #define php_stream_notify_error(context, code, xmsg, xcode) do { if ((context) && (context)->notifier) {\
        !           125:        php_stream_notification_notify((context), (code), PHP_STREAM_NOTIFY_SEVERITY_ERR, \
        !           126:                        (xmsg), (xcode), 0, 0, NULL TSRMLS_CC); } } while(0)
        !           127:        
        !           128: 
        !           129: /*
        !           130:  * Local variables:
        !           131:  * tab-width: 4
        !           132:  * c-basic-offset: 4
        !           133:  * End:
        !           134:  * vim600: sw=4 ts=4 fdm=marker
        !           135:  * vim<600: sw=4 ts=4
        !           136:  */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>