1 /*
2   +----------------------------------------------------------------------+
3   | PHP Version 5                                                        |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 1997-2007 The PHP Group                                |
6   +----------------------------------------------------------------------+
7   | This source file is subject to version 3.01 of the PHP 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.php.net/license/3_01.txt                                  |
11   | If you did not receive a copy of the PHP license and are unable to   |
12   | obtain it through the world-wide-web, please send a note to          |
13   | license@php.net so we can mail you a copy immediately.               |
14   +----------------------------------------------------------------------+
15   | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 |
16   | Lead:                                                                |
17   | - Pieter de Zwart                                                    |
18   | Maintainers:                                                         |
19   | - Brad Rodriguez                                                     |
20   | - Jonathan Tansavatdi                                                |
21   +----------------------------------------------------------------------+
22 */
23 
24 #ifndef PHP_AMQP_PHP5_SUPPORT_H
25 #define PHP_AMQP_PHP5_SUPPORT_H
26 
27 typedef int PHP5to7_param_str_len_type_t;
28 typedef long PHP5to7_param_long_type_t;
29 typedef zval* PHP5to7_zval_t;
30 
31 #define PHP5to7_MAYBE_SET_TO_NULL = NULL
32 
33 #define PHP5to7_MAYBE_DEREF(zv) (*(zv))
34 #define PHP5to7_MAYBE_PTR(zv) (zv)
35 #define PHP5to7_MAYBE_PTR_TYPE PHP5to7_zval_t
36 #define PHP5to7_MAYBE_PARAM_PTR(zv) (&(zv))
37 
38 #define PHP5to7_MAYBE_INIT(zv) MAKE_STD_ZVAL(zv);
39 #define PHP5to7_ARRAY_INIT(zv) array_init(zv);
40 #define PHP5to7_MAYBE_DESTROY(zv) zval_ptr_dtor(&(zv));
41 #define PHP5to7_MAYBE_DESTROY2(zv, pzv) zval_ptr_dtor(&pzv);
42 
43 #define PHP5to7_ZVAL_STRINGL_DUP(z, s, l) ZVAL_STRINGL((z), (s), (l), 1)
44 
45 #define PHP5to7_ADD_NEXT_INDEX_STRINGL_DUP(arg, str, length) add_next_index_stringl((arg), (str), (unsigned)(length), 1)
46 
47 #define PHP5to7_ZEND_HASH_FIND(ht, str, len, res) \
48         (zend_hash_find((ht), (str), (unsigned)(len), (void **) &(res)) != FAILURE)
49 
50 #define PHP5to7_ZEND_HASH_STRLEN(len) (unsigned)((len) + 1)
51 #define PHP5to7_ZEND_HASH_DEL(ht, key, len) zend_hash_del_key_or_index((ht), (key), (unsigned)(len), 0, HASH_DEL_KEY);
52 #define PHP5to7_ZEND_HASH_ADD(ht, key, len, pData, nDataSize) (zend_hash_add((ht), (key), (unsigned)(len), &(pData), nDataSize, NULL) != FAILURE)
53 #define PHP5to7_ZEND_HASH_STR_UPD_MEM(ht, key, len, pData, nDataSize) PHP5to7_ZEND_HASH_ADD((ht), (key), (len), (pData), (nDataSize))
54 #define PHP5to7_ZEND_HASH_STR_FIND_PTR(ht, key, len, res) PHP5to7_ZEND_HASH_FIND((ht), (key), (len), (res))
55 #define PHP5to7_ZEND_HASH_STR_DEL(ht, key, len) PHP5to7_ZEND_HASH_DEL((ht), (key), (len))
56 
57 #define PHP5to7_SET_FCI_RETVAL_PTR(fci, pzv) (fci).retval_ptr_ptr = &(pzv);
58 #define PHP5to7_CHECK_FCI_RETVAL_PTR(fci) ((fci).retval_ptr_ptr && *(fci).retval_ptr_ptr)
59 
60 #define PHP5to7_IS_FALSE_P(pzv) ((Z_TYPE_P(pzv) == IS_BOOL && !Z_BVAL_P(pzv)))
61 
62 #define PHP5to7_obj_free_zend_object void
63 #define PHP5to7_zend_object_value zend_object_value
64 #define PHP5to7_zend_register_internal_class_ex(ce, parent_ce) zend_register_internal_class_ex((ce), (parent_ce), NULL TSRMLS_CC)
65 
66 #define PHP5to7_ECALLOC_CONNECTION_OBJECT(ce) (amqp_connection_object*)ecalloc(1, sizeof(amqp_connection_object))
67 #define PHP5to7_ECALLOC_CHANNEL_OBJECT(ce) (amqp_channel_object*)ecalloc(1, sizeof(amqp_channel_object))
68 
69 #define PHP5to7_CASE_IS_BOOL case IS_BOOL
70 
71 #define PHP5to7_READ_PROP_RV_PARAM_DECL
72 #define PHP5to7_READ_PROP_RV_PARAM_CC
73 
74 
75 #define PHP5to7_ZEND_REAL_HASH_KEY_T void
76 
77 #define PHP5to7_ZEND_HASH_FOREACH_KEY_VAL(ht, num_key, real_key, key, key_len, data, val, pos) \
78   for ( \
79       zend_hash_internal_pointer_reset_ex((ht), &(pos)); \
80       zend_hash_get_current_data_ex((ht), (void**) &(data), &(pos)) == SUCCESS && ((value) = *(data)); \
81       zend_hash_move_forward_ex((ht), &(pos)) \
82   )
83 
84 #define PHP5to7_ZEND_HASH_KEY_IS_STRING(ht, real_key, key, key_len, num_key, pos) \
85     (zend_hash_get_current_key_ex((ht), &(key), &(key_len), &(num_key), 0, &(pos)) == HASH_KEY_IS_STRING)
86 
87 #define PHP5to7_ZEND_HASH_KEY_MAYBE_UNPACK(real_key, key, key_len)
88 
89 #define PHP5to7_ZEND_HASH_FOREACH_END()
90 
91 #define Z_TRY_ADDREF_P(pz) Z_ADDREF_P(pz)
92 
93 /* Resources stuff */
94 
95 typedef int PHP5to7_zend_resource_t;
96 typedef zend_rsrc_list_entry PHP5to7_zend_resource_store_t;
97 typedef zend_rsrc_list_entry PHP5to7_zend_resource_le_t;
98 
99 #define PHP5to7_ZEND_RESOURCE_DTOR_ARG rsrc
100 #define Z_RES_P(le) (le)
101 
102 #define PHP5to7_ZEND_RESOURCE_EMPTY 0
103 #define PHP5to7_ZEND_RESOURCE_LE_EMPTY NULL
104 #define PHP5to7_ZEND_RSRC_TYPE_P(le) Z_TYPE_P(le)
105 #define PHP5to7_ZEND_REGISTER_RESOURCE(rsrc_pointer, rsrc_type) ZEND_REGISTER_RESOURCE(NULL, (rsrc_pointer), (rsrc_type))
106 
107 #define PHP5to7_PARENT_CLASS_NAME_C(name) , (name)
108 
109 #define ZEND_ULONG_FMT "%" PRIu64
110 #define PHP5to7_ZEND_ACC_FINAL_CLASS ZEND_ACC_FINAL_CLASS
111 
112 #endif //PHP_AMQP_PHP5_SUPPORT_H
113 
114 /*
115 *Local variables:
116 *tab-width: 4
117 *c-basic-offset: 4
118 *End:
119 *vim600: noet sw=4 ts=4 fdm=marker
120 *vim<600: noet sw=4 ts=4
121 */
122