home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 15 / AACD15.ISO / AACD / Magazine / HomeAutomation / Apache / include / php / Zend / zend_list.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-15  |  4.0 KB  |  105 lines

  1. /*
  2.    +----------------------------------------------------------------------+
  3.    | Zend Engine                                                          |
  4.    +----------------------------------------------------------------------+
  5.    | Copyright (c) 1998-2000 Zend Technologies Ltd. (http://www.zend.com) |
  6.    +----------------------------------------------------------------------+
  7.    | This source file is subject to version 0.92 of the Zend license,     |
  8.    | that is bundled with this package in the file LICENSE, and is        | 
  9.    | available at through the world-wide-web at                           |
  10.    | http://www.zend.com/license/0_92.txt.                                |
  11.    | If you did not receive a copy of the Zend license and are unable to  |
  12.    | obtain it through the world-wide-web, please send a note to          |
  13.    | license@zend.com so we can mail you a copy immediately.              |
  14.    +----------------------------------------------------------------------+
  15.    | Authors: Andi Gutmans <andi@zend.com>                                |
  16.    |          Zeev Suraski <zeev@zend.com>                                |
  17.    +----------------------------------------------------------------------+
  18. */
  19.  
  20.  
  21. #ifndef _LIST_H
  22. #define _LIST_H
  23.  
  24. #include "zend_hash.h"
  25. #include "zend_globals.h"
  26.  
  27.  
  28. #define ZEND_RESOURCE_LIST_TYPE_STD    1
  29. #define ZEND_RESOURCE_LIST_TYPE_EX    2
  30.  
  31. typedef struct _zend_rsrc_list_entry {
  32.     void *ptr;
  33.     int type;
  34.     int refcount;
  35.     zend_bool valid;
  36. } zend_rsrc_list_entry;
  37.  
  38. typedef void (*rsrc_dtor_func_t)(zend_rsrc_list_entry *le);
  39.  
  40. typedef struct _zend_rsrc_list_dtors_entry {
  41.     /* old style destructors */
  42.     void (*list_dtor)(void *);
  43.     void (*plist_dtor)(void *);
  44.  
  45.     /* new style destructors */
  46.     rsrc_dtor_func_t list_dtor_ex;
  47.     rsrc_dtor_func_t plist_dtor_ex;
  48.  
  49.     int module_number;
  50.     int resource_id;
  51.     unsigned char type;
  52. } zend_rsrc_list_dtors_entry;
  53.  
  54.  
  55. #define register_list_destructors(ld, pld) zend_register_list_destructors((void (*)(void *))ld, (void (*)(void *))pld, module_number);
  56. ZEND_API int zend_register_list_destructors(void (*ld)(void *), void (*pld)(void *), int module_number);
  57. ZEND_API int zend_register_list_destructors_ex(rsrc_dtor_func_t ld, rsrc_dtor_func_t pld, int module_number);
  58.  
  59. enum list_entry_type {
  60.     LE_DB=1000
  61. };
  62.  
  63. void list_entry_destructor(void *ptr);
  64. void plist_entry_destructor(void *ptr);
  65.  
  66. void zend_clean_module_rsrc_dtors(int module_number);
  67. int zend_init_rsrc_list(ELS_D);
  68. int zend_init_rsrc_plist(ELS_D);
  69. void zend_destroy_rsrc_list(ELS_D);
  70. void zend_destroy_rsrc_plist(ELS_D);
  71. int zend_init_rsrc_list_dtors();
  72. void zend_destroy_rsrc_list_dtors();
  73.  
  74. ZEND_API int zend_list_insert(void *ptr, int type);
  75. ZEND_API int zend_plist_insert(void *ptr, int type);
  76. ZEND_API int zend_list_addref(int id);
  77. ZEND_API int zend_list_delete(int id);
  78. ZEND_API int zend_plist_delete(int id);
  79. ZEND_API int zend_list_convert_to_number(int id);
  80. ZEND_API void *zend_list_find(int id, int *type);
  81. ZEND_API void *zend_plist_find(int id, int *type);
  82.  
  83. ZEND_API int zend_register_resource(zval *rsrc_result, void *rsrc_pointer, int rsrc_type);
  84. ZEND_API void *zend_fetch_resource(zval **passed_id, int default_id, char *resource_type_name, int *found_resource_type, int num_resource_types, ...);
  85.  
  86. extern ZEND_API int le_index_ptr;  /* list entry type for index pointers */
  87.  
  88. #define ZEND_VERIFY_RESOURCE(rsrc)        \
  89.     if (!rsrc) {                        \
  90.         RETURN_NULL();                    \
  91.     }
  92.  
  93. #define ZEND_FETCH_RESOURCE(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type)    \
  94.     rsrc = (rsrc_type) zend_fetch_resource(passed_id, default_id, resource_type_name, NULL, 1, resource_type);    \
  95.     ZEND_VERIFY_RESOURCE(rsrc);
  96.  
  97. #define ZEND_FETCH_RESOURCE2(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type1,resource_type2)    \
  98.     rsrc = (rsrc_type) zend_fetch_resource(passed_id, default_id, resource_type_name, NULL, 2, resource_type1, resource_type2);    \
  99.     ZEND_VERIFY_RESOURCE(rsrc);
  100.  
  101. #define ZEND_REGISTER_RESOURCE(rsrc_result, rsrc_pointer, rsrc_type)  \
  102.     zend_register_resource(rsrc_result, rsrc_pointer, rsrc_type);
  103.  
  104. #endif
  105.