~ubuntu-branches/ubuntu/hardy/php5/hardy-updates

« back to all changes in this revision

Viewing changes to Zend/zend_list.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-10-09 03:14:32 UTC
  • Revision ID: james.westby@ubuntu.com-20051009031432-kspik3lobxstafv9
Tags: upstream-5.0.5
ImportĀ upstreamĀ versionĀ 5.0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
   +----------------------------------------------------------------------+
 
3
   | Zend Engine                                                          |
 
4
   +----------------------------------------------------------------------+
 
5
   | Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
 
6
   +----------------------------------------------------------------------+
 
7
   | This source file is subject to version 2.00 of the Zend 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.zend.com/license/2_00.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
/* $Id: zend_list.h,v 1.47 2004/02/11 11:52:33 zeev Exp $ */
 
21
 
 
22
#ifndef ZEND_LIST_H
 
23
#define ZEND_LIST_H
 
24
 
 
25
#include "zend_hash.h"
 
26
#include "zend_globals.h"
 
27
 
 
28
BEGIN_EXTERN_C()
 
29
 
 
30
#define ZEND_RESOURCE_LIST_TYPE_STD     1
 
31
#define ZEND_RESOURCE_LIST_TYPE_EX      2
 
32
 
 
33
typedef struct _zend_rsrc_list_entry {
 
34
        void *ptr;
 
35
        int type;
 
36
        int refcount;
 
37
} zend_rsrc_list_entry;
 
38
 
 
39
typedef void (*rsrc_dtor_func_t)(zend_rsrc_list_entry *rsrc TSRMLS_DC);
 
40
#define ZEND_RSRC_DTOR_FUNC(name)               void name(zend_rsrc_list_entry *rsrc TSRMLS_DC)
 
41
 
 
42
typedef struct _zend_rsrc_list_dtors_entry {
 
43
        /* old style destructors */
 
44
        void (*list_dtor)(void *);
 
45
        void (*plist_dtor)(void *);
 
46
 
 
47
        /* new style destructors */
 
48
        rsrc_dtor_func_t list_dtor_ex;
 
49
        rsrc_dtor_func_t plist_dtor_ex;
 
50
 
 
51
        char *type_name;
 
52
 
 
53
        int module_number;
 
54
        int resource_id;
 
55
        unsigned char type;
 
56
} zend_rsrc_list_dtors_entry;
 
57
 
 
58
 
 
59
#define register_list_destructors(ld, pld) zend_register_list_destructors((void (*)(void *))ld, (void (*)(void *))pld, module_number);
 
60
ZEND_API int zend_register_list_destructors(void (*ld)(void *), void (*pld)(void *), int module_number);
 
61
ZEND_API int zend_register_list_destructors_ex(rsrc_dtor_func_t ld, rsrc_dtor_func_t pld, char *type_name, int module_number);
 
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 TSRMLS_DC);
 
67
int zend_init_rsrc_list(TSRMLS_D);
 
68
int zend_init_rsrc_plist(TSRMLS_D);
 
69
void zend_destroy_rsrc_list(HashTable *ht TSRMLS_DC);
 
70
int zend_init_rsrc_list_dtors(void);
 
71
void zend_destroy_rsrc_list_dtors(void);
 
72
 
 
73
ZEND_API int zend_list_insert(void *ptr, int type);
 
74
ZEND_API int _zend_list_addref(int id TSRMLS_DC);
 
75
ZEND_API int _zend_list_delete(int id TSRMLS_DC);
 
76
ZEND_API void *_zend_list_find(int id, int *type TSRMLS_DC);
 
77
 
 
78
#define zend_list_addref(id)            _zend_list_addref(id TSRMLS_CC)
 
79
#define zend_list_delete(id)            _zend_list_delete(id TSRMLS_CC)
 
80
#define zend_list_find(id, type)        _zend_list_find(id, type TSRMLS_CC)
 
81
 
 
82
ZEND_API int zend_register_resource(zval *rsrc_result, void *rsrc_pointer, int rsrc_type);
 
83
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, ...);
 
84
 
 
85
ZEND_API char *zend_rsrc_list_get_rsrc_type(int resource TSRMLS_DC);
 
86
ZEND_API int zend_fetch_list_dtor_id(char *type_name);
 
87
 
 
88
extern ZEND_API int le_index_ptr;  /* list entry type for index pointers */
 
89
 
 
90
#define ZEND_VERIFY_RESOURCE(rsrc)              \
 
91
        if (!rsrc) {                                            \
 
92
                RETURN_FALSE;                                   \
 
93
        }
 
94
 
 
95
#define ZEND_FETCH_RESOURCE(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type)  \
 
96
        rsrc = (rsrc_type) zend_fetch_resource(passed_id TSRMLS_CC, default_id, resource_type_name, NULL, 1, resource_type);    \
 
97
        ZEND_VERIFY_RESOURCE(rsrc);
 
98
 
 
99
#define ZEND_FETCH_RESOURCE2(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type1, resource_type2)        \
 
100
        rsrc = (rsrc_type) zend_fetch_resource(passed_id TSRMLS_CC, default_id, resource_type_name, NULL, 2, resource_type1, resource_type2);   \
 
101
        ZEND_VERIFY_RESOURCE(rsrc);
 
102
 
 
103
#define ZEND_REGISTER_RESOURCE(rsrc_result, rsrc_pointer, rsrc_type)  \
 
104
    zend_register_resource(rsrc_result, rsrc_pointer, rsrc_type);
 
105
 
 
106
#define ZEND_GET_RESOURCE_TYPE_ID(le_id, le_type_name) \
 
107
    if (le_id == 0) {                                  \
 
108
        le_id = zend_fetch_list_dtor_id(le_type_name); \
 
109
        }
 
110
END_EXTERN_C()
 
111
 
 
112
#endif
 
113
 
 
114
/*
 
115
 * Local variables:
 
116
 * tab-width: 4
 
117
 * c-basic-offset: 4
 
118
 * indent-tabs-mode: t
 
119
 * End:
 
120
 */