|
| 1 | +/* |
| 2 | + +---------------------------------------------------------------------------+ |
| 3 | + | PHP Driver for MongoDB | |
| 4 | + +---------------------------------------------------------------------------+ |
| 5 | + | Copyright 2013-2015 MongoDB, Inc. | |
| 6 | + | | |
| 7 | + | Licensed under the Apache License, Version 2.0 (the "License"); | |
| 8 | + | you may not use this file except in compliance with the License. | |
| 9 | + | You may obtain a copy of the License at | |
| 10 | + | | |
| 11 | + | http://www.apache.org/licenses/LICENSE-2.0 | |
| 12 | + | | |
| 13 | + | Unless required by applicable law or agreed to in writing, software | |
| 14 | + | distributed under the License is distributed on an "AS IS" BASIS, | |
| 15 | + | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 16 | + | See the License for the specific language governing permissions and | |
| 17 | + | limitations under the License. | |
| 18 | + +---------------------------------------------------------------------------+ |
| 19 | + | Copyright (c) 2015 MongoDB, Inc. | |
| 20 | + +---------------------------------------------------------------------------+ |
| 21 | +*/ |
| 22 | + |
| 23 | +#ifndef PHONGO_COMPAT_H |
| 24 | +#define PHONGO_COMPAT_H |
| 25 | + |
| 26 | +#include <php.h> |
| 27 | +#include <Zend/zend_string.h> |
| 28 | +#if PHP_VERSION_ID >= 70000 |
| 29 | +#include <Zend/zend_portability.h> |
| 30 | +#endif |
| 31 | + |
1 | 32 | #ifdef PHP_WIN32
|
2 | 33 | # include "config.w32.h"
|
3 | 34 | #else
|
|
17 | 48 | zend_hash_copy(*_std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
|
18 | 49 | #endif
|
19 | 50 |
|
20 |
| -#if PHP_VERSION_ID < 50400 |
| 51 | +#if PHP_VERSION_ID >= 70000 |
| 52 | +# define str_efree(s) efree((char*)s) |
| 53 | +#elif PHP_VERSION_ID < 50400 |
21 | 54 | # define str_efree(s) efree((char*)s)
|
22 | 55 | #else
|
23 | 56 | # include <Zend/zend_string.h>
|
|
112 | 145 | # endif
|
113 | 146 | #endif
|
114 | 147 |
|
| 148 | +#if PHP_VERSION_ID >= 70000 |
| 149 | +# define phongo_char zend_string |
| 150 | +# define phongo_char_pdup(str) pestrdup(filename->val, 1) |
| 151 | +# define phongo_char_free(str) zend_string_release(str) |
| 152 | +# define phongo_str(str) str->val |
| 153 | +# define phongo_create_object_retval zend_object* |
| 154 | +# define PHONGO_ALLOC_OBJECT_T(_obj_t, _class_type) (_obj_t *)ecalloc(1, sizeof(_obj_t)+zend_object_properties_size(_class_type)) |
| 155 | +# define PHONGO_TSRMLS_FETCH_FROM_CTX(user_data) |
| 156 | +# define SUPPRESS_UNUSED_WARNING(x) |
| 157 | +# define DECLARE_RETURN_VALUE_USED int return_value_used = 1; |
| 158 | +# define EXCEPTION_P(_ex, _zp) ZVAL_OBJ(&_zp, _ex) |
| 159 | +# define PHONGO_STREAM_ID(stream) stream->res ? stream->res->handle : -1 |
| 160 | +# define ADD_ASSOC_STRING(_zv, _key, _value) add_assoc_string_ex(_zv, ZEND_STRL(_key), _value); |
| 161 | +# define ADD_ASSOC_STRINGL(_zv, _key, _value, _len) add_assoc_stringl_ex(_zv, ZEND_STRL(_key), _value, _len); |
| 162 | +# define ADD_ASSOC_LONG_EX(_zv, _key, _value) add_assoc_long_ex(_zv, ZEND_STRL(_key), _value); |
| 163 | +# define ADD_ASSOC_STRING_EX(_zv, _key, _key_len, _value, _value_len) add_assoc_stringl_ex(_zv, _key, _key_len, _value, _value_len); |
| 164 | +# define ADD_ASSOC_ZVAL_EX(_zv, _key, _value) add_assoc_zval_ex(_zv, ZEND_STRL(_key), _value); |
| 165 | +# define ADD_ASSOC_ZVAL(_zv, _key, _value) add_assoc_zval(_zv, _key, _value); |
| 166 | +# define ADD_ASSOC_NULL_EX(_zv, _key) add_assoc_null_ex(_zv, ZEND_STRL(_key)); |
| 167 | +# define ADD_ASSOC_BOOL_EX(_zv, _key, _value) add_assoc_bool_ex(_zv, ZEND_STRL(_key), _value); |
| 168 | +# define phongo_free_object_arg zend_object |
| 169 | +# define phongo_zpp_char_len size_t |
| 170 | +# define ZEND_HASH_APPLY_COUNT(ht) (ht)->u.v.nApplyCount |
| 171 | +# define PHONGO_RETVAL_STRINGL(s, slen) RETVAL_STRINGL(s, slen) |
| 172 | +# define PHONGO_RETURN_STRINGL(s, slen) RETURN_STRINGL(s, slen) |
| 173 | +# define PHONGO_RETURN_STRING(s) RETURN_STRING(s) |
| 174 | +#else |
| 175 | +# define phongo_char char |
| 176 | +# define phongo_char_pdup(str) pestrdup(filename, 1) |
| 177 | +# define phongo_char_free(str) _efree(str ZEND_FILE_LINE_CC ZEND_FILE_LINE_CC) |
| 178 | +# define phongo_str(str) str |
| 179 | +# define phongo_create_object_retval zend_object_value |
| 180 | +# define PHONGO_ALLOC_OBJECT_T(_obj_t, _class_type) (_obj_t *)ecalloc(1, sizeof(_obj_t)) |
| 181 | +# define PHONGO_TSRMLS_FETCH_FROM_CTX(user_data) TSRMLS_FETCH_FROM_CTX(user_data) |
| 182 | +# define SUPPRESS_UNUSED_WARNING(x) (void)x; |
| 183 | +# define DECLARE_RETURN_VALUE_USED |
| 184 | +# define EXCEPTION_P(_ex, _zp) _zp = _ex |
| 185 | +# define PHONGO_STREAM_ID(stream) stream->rsrc_id |
| 186 | +# define ADD_ASSOC_STRING(_zv, _key, _value) add_assoc_string_ex(_zv, ZEND_STRS(_key), _value, 1); |
| 187 | +# define ADD_ASSOC_STRINGL(_zv, _key, _value, _len) add_assoc_stringl_ex(_zv, ZEND_STRS(_key), _value, _len, 1); |
| 188 | +# define ADD_ASSOC_STRING_EX(_zv, _key, _key_len, _value, _value_len) add_assoc_stringl_ex(_zv, _key, _key_len+1, _value, _value_len, 1); |
| 189 | +# define ADD_ASSOC_LONG_EX(_zv, _key, _value) add_assoc_long_ex(_zv, ZEND_STRS(_key), _value); |
| 190 | +# define ADD_ASSOC_ZVAL_EX(_zv, _key, _value) add_assoc_zval_ex(_zv, ZEND_STRS(_key), _value); |
| 191 | +# define ADD_ASSOC_ZVAL(_zv, _key, _value) add_assoc_zval(_zv, _key, _value); |
| 192 | +# define ADD_ASSOC_NULL_EX(_zv, _key) add_assoc_null_ex(_zv, ZEND_STRS(_key)); |
| 193 | +# define ADD_ASSOC_BOOL_EX(_zv, _key, _value) add_assoc_bool_ex(_zv, ZEND_STRS(_key), _value); |
| 194 | +# define Z_PHPDATE_P(object) zend_object_store_get_object(object TSRMLS_CC) |
| 195 | +# define Z_ISUNDEF(x) !x |
| 196 | +# define phongo_free_object_arg void |
| 197 | +# define phongo_zpp_char_len int |
| 198 | +# define ZEND_HASH_APPLY_COUNT(ht) (ht)->nApplyCount |
| 199 | +# define PHONGO_RETVAL_STRINGL(s, slen) RETVAL_STRINGL(s, slen, 1) |
| 200 | +# define PHONGO_RETURN_STRINGL(s, slen) RETURN_STRINGL(s, slen, 1) |
| 201 | +# define PHONGO_RETURN_STRING(s) RETURN_STRING(s, 1) |
| 202 | +# define PHP_STREAM_CONTEXT(stream) ((php_stream_context*) (stream)->context) |
| 203 | +#endif |
| 204 | + |
| 205 | + |
| 206 | +void *x509_from_zval(zval *zval TSRMLS_DC); |
| 207 | +void phongo_add_exception_prop(const char *prop, int prop_len, zval *value TSRMLS_DC); |
| 208 | + |
| 209 | + |
| 210 | +#endif /* PHONGO_COMPAT_H */ |
| 211 | + |
| 212 | + |
| 213 | +/* |
| 214 | + * Local variables: |
| 215 | + * tab-width: 4 |
| 216 | + * c-basic-offset: 4 |
| 217 | + * End: |
| 218 | + * vim600: noet sw=4 ts=4 fdm=marker |
| 219 | + * vim<600: noet sw=4 ts=4 |
| 220 | + */ |
0 commit comments