forked from SeasX/SeasClick
-
Notifications
You must be signed in to change notification settings - Fork 0
/
php7_wrapper.h
133 lines (116 loc) · 4.96 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
/*
+----------------------------------------------------------------------+
| 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 |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: SeasX Group <ahhhh.wang@gmail.com> |
+----------------------------------------------------------------------+
*/
// PHP7+
#if PHP_MAJOR_VERSION < 7
#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_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_EXISTENT; \
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
#else
// PHP5
#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)
static inline zval* sc_zend_read_property(zend_class_entry *class_ptr, zval *obj, const char *s, int len, int silent)
{
zval rv;
return zend_read_property(class_ptr, obj, s, len, silent, &rv);
}
#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)
#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
*/