Back to index

php5  5.3.10
zend_list.h
Go to the documentation of this file.
00001 /*
00002    +----------------------------------------------------------------------+
00003    | Zend Engine                                                          |
00004    +----------------------------------------------------------------------+
00005    | Copyright (c) 1998-2012 Zend Technologies Ltd. (http://www.zend.com) |
00006    +----------------------------------------------------------------------+
00007    | This source file is subject to version 2.00 of the Zend license,     |
00008    | that is bundled with this package in the file LICENSE, and is        | 
00009    | available through the world-wide-web at the following url:           |
00010    | http://www.zend.com/license/2_00.txt.                                |
00011    | If you did not receive a copy of the Zend license and are unable to  |
00012    | obtain it through the world-wide-web, please send a note to          |
00013    | license@zend.com so we can mail you a copy immediately.              |
00014    +----------------------------------------------------------------------+
00015    | Authors: Andi Gutmans <andi@zend.com>                                |
00016    |          Zeev Suraski <zeev@zend.com>                                |
00017    +----------------------------------------------------------------------+
00018 */
00019 
00020 /* $Id: zend_list.h 321634 2012-01-01 13:15:04Z felipe $ */
00021 
00022 #ifndef ZEND_LIST_H
00023 #define ZEND_LIST_H
00024 
00025 #include "zend_hash.h"
00026 #include "zend_globals.h"
00027 
00028 BEGIN_EXTERN_C()
00029 
00030 #define ZEND_RESOURCE_LIST_TYPE_STD       1
00031 #define ZEND_RESOURCE_LIST_TYPE_EX 2
00032 
00033 typedef struct _zend_rsrc_list_entry {
00034        void *ptr;
00035        int type;
00036        int refcount;
00037 } zend_rsrc_list_entry;
00038 
00039 typedef void (*rsrc_dtor_func_t)(zend_rsrc_list_entry *rsrc TSRMLS_DC);
00040 #define ZEND_RSRC_DTOR_FUNC(name)         void name(zend_rsrc_list_entry *rsrc TSRMLS_DC)
00041 
00042 typedef struct _zend_rsrc_list_dtors_entry {
00043        /* old style destructors */
00044        void (*list_dtor)(void *);
00045        void (*plist_dtor)(void *);
00046 
00047        /* new style destructors */
00048        rsrc_dtor_func_t list_dtor_ex;
00049        rsrc_dtor_func_t plist_dtor_ex;
00050 
00051        char *type_name;
00052 
00053        int module_number;
00054        int resource_id;
00055        unsigned char type;
00056 } zend_rsrc_list_dtors_entry;
00057 
00058 
00059 #define register_list_destructors(ld, pld) zend_register_list_destructors((void (*)(void *))ld, (void (*)(void *))pld, module_number);
00060 ZEND_API int zend_register_list_destructors(void (*ld)(void *), void (*pld)(void *), int module_number);
00061 ZEND_API int zend_register_list_destructors_ex(rsrc_dtor_func_t ld, rsrc_dtor_func_t pld, char *type_name, int module_number);
00062 
00063 void list_entry_destructor(void *ptr);
00064 void plist_entry_destructor(void *ptr);
00065 
00066 void zend_clean_module_rsrc_dtors(int module_number TSRMLS_DC);
00067 int zend_init_rsrc_list(TSRMLS_D);
00068 int zend_init_rsrc_plist(TSRMLS_D);
00069 void zend_destroy_rsrc_list(HashTable *ht TSRMLS_DC);
00070 int zend_init_rsrc_list_dtors(void);
00071 void zend_destroy_rsrc_list_dtors(void);
00072 
00073 ZEND_API int zend_list_insert(void *ptr, int type);
00074 ZEND_API int _zend_list_addref(int id TSRMLS_DC);
00075 ZEND_API int _zend_list_delete(int id TSRMLS_DC);
00076 ZEND_API void *_zend_list_find(int id, int *type TSRMLS_DC);
00077 
00078 #define zend_list_addref(id)              _zend_list_addref(id TSRMLS_CC)
00079 #define zend_list_delete(id)              _zend_list_delete(id TSRMLS_CC)
00080 #define zend_list_find(id, type)   _zend_list_find(id, type TSRMLS_CC)
00081 
00082 ZEND_API int zend_register_resource(zval *rsrc_result, void *rsrc_pointer, int rsrc_type);
00083 ZEND_API void *zend_fetch_resource(zval **passed_id TSRMLS_DC, int default_id, char *resource_type_name, int *found_resource_type, int num_resource_types, ...);
00084 
00085 ZEND_API char *zend_rsrc_list_get_rsrc_type(int resource TSRMLS_DC);
00086 ZEND_API int zend_fetch_list_dtor_id(char *type_name);
00087 
00088 extern ZEND_API int le_index_ptr;  /* list entry type for index pointers */
00089 
00090 #define ZEND_VERIFY_RESOURCE(rsrc)        \
00091        if (!rsrc) {                                     \
00092               RETURN_FALSE;                             \
00093        }
00094 
00095 #define ZEND_FETCH_RESOURCE(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type)   \
00096        rsrc = (rsrc_type) zend_fetch_resource(passed_id TSRMLS_CC, default_id, resource_type_name, NULL, 1, resource_type);   \
00097        ZEND_VERIFY_RESOURCE(rsrc);
00098        
00099 #define ZEND_FETCH_RESOURCE_NO_RETURN(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type)       \
00100        (rsrc = (rsrc_type) zend_fetch_resource(passed_id TSRMLS_CC, default_id, resource_type_name, NULL, 1, resource_type))
00101 
00102 #define ZEND_FETCH_RESOURCE2(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type1, resource_type2)      \
00103        rsrc = (rsrc_type) zend_fetch_resource(passed_id TSRMLS_CC, default_id, resource_type_name, NULL, 2, resource_type1, resource_type2);       \
00104        ZEND_VERIFY_RESOURCE(rsrc);
00105        
00106 #define ZEND_FETCH_RESOURCE2_NO_RETURN(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type1, resource_type2)   \
00107        (rsrc = (rsrc_type) zend_fetch_resource(passed_id TSRMLS_CC, default_id, resource_type_name, NULL, 2, resource_type1, resource_type2))
00108 
00109 #define ZEND_REGISTER_RESOURCE(rsrc_result, rsrc_pointer, rsrc_type)  \
00110     zend_register_resource(rsrc_result, rsrc_pointer, rsrc_type);
00111 
00112 #define ZEND_GET_RESOURCE_TYPE_ID(le_id, le_type_name) \
00113     if (le_id == 0) {                                  \
00114         le_id = zend_fetch_list_dtor_id(le_type_name); \
00115        }
00116 END_EXTERN_C()
00117 
00118 #endif
00119 
00120 /*
00121  * Local variables:
00122  * tab-width: 4
00123  * c-basic-offset: 4
00124  * indent-tabs-mode: t
00125  * End:
00126  */