-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathphp7_wrapper.h
222 lines (187 loc) · 7.47 KB
/
php7_wrapper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/*
+----------------------------------------------------------------------+
| SeasClick |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: SeasX Group <[email protected]> |
+----------------------------------------------------------------------+
*/
// PHP7.4 +
#if !defined(ZEND_ACC_IMPLICIT_PUBLIC)
# define ZEND_ACC_IMPLICIT_PUBLIC ZEND_ACC_PUBLIC
#endif
// PHP8+
#if !defined(ZEND_ACC_DTOR)
#define ZEND_ACC_DTOR 0x4000
#endif
// PHP5+
#if PHP_MAJOR_VERSION <7
#if PHP_VERSION_ID < 50500
#define sc_zend_throw_exception(a, b, c) zend_throw_exception(a, (char *)b, c)
#else
#define sc_zend_throw_exception zend_throw_exception
#endif
#define sc_zend_throw_exception_tsrmls_cc sc_zend_throw_exception
#define IS_TRUE 1
#define SC_MAKE_STD_ZVAL(p) MAKE_STD_ZVAL(p)
#define SC_RETURN_STRINGL(k, l) RETURN_STRINGL(k, l, 1)
#define sc_zval_ptr_dtor zval_ptr_dtor
#define sc_zval_add_ref(a) zval_add_ref(&a)
static inline int sc_add_assoc_long_ex(zval *arg, const char *key, size_t key_len, long value)
{
return add_assoc_long_ex(arg, key, key_len + 1, value);
}
static inline int sc_add_assoc_double_ex(zval *arg, const char *key, size_t key_len, double value)
{
return add_assoc_double_ex(arg, key, key_len + 1, value);
}
static inline int sc_add_assoc_zval_ex(zval *arg, const char *key, size_t key_len, zval* value)
{
return add_assoc_zval_ex(arg, key, key_len + 1, value);
}
static inline int sc_add_assoc_stringl_ex(zval *arg, const char *key, size_t key_len, char *str, size_t length, int __duplicate)
{
return add_assoc_stringl_ex(arg, key, key_len + 1, str, length, __duplicate);
}
static inline int sc_add_assoc_null_ex(zval *arg, const char *key, size_t key_len)
{
return add_assoc_null_ex(arg, key, key_len + 1);
}
static inline zval *sc_zend_hash_find(HashTable *ht, char *k, int len)
{
zval **tmp = NULL;
if (zend_hash_find(ht, k, len + 1, (void **) &tmp) == SUCCESS)
{
return *tmp;
}
else
{
return NULL;
}
}
static inline zval *sc_zend_hash_index_find(HashTable *ht, ulong h)
{
zval **tmp = NULL;
if (zend_hash_index_find(ht, h, (void **) &tmp) == SUCCESS)
{
return *tmp;
}
else
{
return NULL;
}
}
#define sc_zend_update_property_string zend_update_property_string
#define sc_zend_read_property(a, b, c, d, e) zend_read_property(a, b, c, d, e TSRMLS_CC)
#define SC_HASHTABLE_FOREACH_START2(ht, k, klen, ktype, entry)\
zval **tmp = NULL; ulong_t idx;\
for (zend_hash_internal_pointer_reset(ht); \
(ktype = zend_hash_get_current_key_ex(ht, &k, &klen, &idx, 0, NULL)) != HASH_KEY_NON_EXISTANT; \
zend_hash_move_forward(ht)\
) { \
if (zend_hash_get_current_data(ht, (void**)&tmp) == FAILURE) {\
continue;\
}\
entry = *tmp;\
klen --;
#define SC_HASHTABLE_FOREACH_END() }
#define sc_add_next_index_stringl add_next_index_stringl
#define sc_zend_hash_get_current_data zend_hash_get_current_data
#else
// PHP7
#define sc_zend_throw_exception zend_throw_exception
#define sc_zend_hash_find zend_hash_str_find
#define sc_zend_hash_index_find zend_hash_index_find
#define SC_MAKE_STD_ZVAL(p) zval _stack_zval_##p; p = &(_stack_zval_##p)
#define SC_RETURN_STRINGL(k, l) RETURN_STRINGL(k, l)
#define sc_zval_ptr_dtor(p) zval_ptr_dtor(*p)
#define sc_zval_add_ref(p) Z_TRY_ADDREF_P(p)
#define sc_add_assoc_long_ex add_assoc_long_ex
#define sc_add_assoc_double_ex add_assoc_double_ex
#define sc_add_assoc_zval_ex add_assoc_zval_ex
#define sc_add_assoc_stringl_ex(a, b, c, d, e, f) add_assoc_stringl_ex(a, b, c, d, e)
#define sc_add_assoc_null_ex(a, b, c) add_assoc_null_ex(a, b, c)
#if PHP_VERSION_ID < 80000
#define sc_zend_throw_exception_tsrmls_cc(a, b, c) sc_zend_throw_exception(a, b, c TSRMLS_CC)
#else
#define sc_zend_throw_exception_tsrmls_cc(a, b, c) sc_zend_throw_exception(a, b, c)
#endif
static inline zval* sc_zend_read_property(zend_class_entry *class_ptr, zval *obj, const char *s, int len, int silent)
{
zval rv;
#if PHP_VERSION_ID < 80000
return zend_read_property(class_ptr, obj, s, len, silent, &rv);
#else
zend_object *zendObject;
zendObject=Z_OBJ_P(obj);
return zend_read_property(class_ptr, zendObject, s, len, silent, &rv);
#endif
}
static inline void sc_zend_update_property_string( zend_class_entry *scope, zval *object, const char *name, size_t name_length, const char *value)
{
#if PHP_VERSION_ID < 80000
return zend_update_property_string(scope, object, name, name_length, value TSRMLS_CC);
#else
zend_object *zendObject;
zendObject=Z_OBJ_P(object);
return zend_update_property_string(scope, zendObject, name, name_length, value);
#endif
}
static inline void sc_zend_update_property_long(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_long value)
{
#if PHP_VERSION_ID < 80000
return zend_update_property_long(scope, object, name, name_length, value TSRMLS_CC);
#else
zend_object *zendObject;
zendObject=Z_OBJ_P(object);
return zend_update_property_long(scope, zendObject, name, name_length, value);
#endif
}
static inline void sc_zend_update_property_bool(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_long value) /* {{{ */
{
#if PHP_VERSION_ID < 80000
return zend_update_property_bool(scope, object, name, name_length, value TSRMLS_CC);
#else
zend_object *zendObject;
zendObject=Z_OBJ_P(object);
return zend_update_property_bool(scope, zendObject, name, name_length, value);
#endif
}
#define SC_HASHTABLE_FOREACH_START2(ht, k, klen, ktype, _val) zend_string *_foreach_key;\
ZEND_HASH_FOREACH_STR_KEY_VAL(ht, _foreach_key, _val);\
if (!_foreach_key) {k = NULL; klen = 0; ktype = 0;}\
else {k = _foreach_key->val, klen=_foreach_key->len; ktype = 1;} {
#define SC_HASHTABLE_FOREACH_END() } ZEND_HASH_FOREACH_END();
#define sc_add_next_index_stringl(arr, str, len, dup) add_next_index_stringl(arr, str, len)
static inline int sc_zend_hash_get_current_data(HashTable *ht, void **v)
{
zval *value = zend_hash_get_current_data(ht);
if (value == NULL)
{
return FAILURE;
}
else
{
*v = (void *) value;
return SUCCESS;
}
}
#endif
#define php_array_get_value(ht, str, v) ((v = sc_zend_hash_find(ht, (char *)str, sizeof(str)-1)) && !ZVAL_IS_NULL(v))
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/