diff options
Diffstat (limited to 'php_imlib.h')
| -rw-r--r-- | php_imlib.h | 65 |
1 files changed, 53 insertions, 12 deletions
diff --git a/php_imlib.h b/php_imlib.h index 5f66094..7df29c5 100644 --- a/php_imlib.h +++ b/php_imlib.h @@ -23,6 +23,7 @@ #include "X11/Xlib.h" #include <Imlib2.h> #include "ltdl.h" +#include "php_ini.h" #include "php_config.h" #ifdef HAVE_CONFIG_H #include "config.h" @@ -154,13 +155,56 @@ typedef struct } PHP_Imlib_Color_Modifier_struct; typedef PHP_Imlib_Color_Modifier_struct *PHP_Imlib_Color_Modifier; -Imlib_Image _php_imlib_get_image(zval** im_resource); -Imlib_Filter _php_imlib_get_filter(zval** fil_resource); -Imlib_Font _php_imlib_get_font(zval** font_resource); -Imlib_TTF_Encoding _php_imlib_get_font_encoding(zval** font_resource); -Imlib_Color_Range _php_imlib_get_cr(zval** cr_resource); -ImlibPolygon _php_imlib_get_poly(zval** poly_resource); -Imlib_Color_Modifier _php_imlib_get_cm(zval** cm_resource); +#if PHP_VERSION_ID >= 70000 + typedef zval imlib_zval; + typedef zend_resource imlib_resource; +# define IMLIB_TO_ZVAL(v) v +# define Z_LVAL_PP(v) Z_LVAL_P(v) +# define Z_DVAL_PP(v) Z_DVAL_P(v) +# define STR_VAL(k) (k)->val +# define IMLIB_DELETE_RESOURCE(v) zend_list_delete(v) +# define IMLIB_RETURN_STRING(v) RETURN_STRING(v) +# define ENFORCE_SAFE_MODE 0 +# define IMLIB_FETCH_RESOURCE(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type) \ + rsrc = (rsrc_type) zend_fetch_resource(passed_id TSRMLS_CC, resource_type_name, resource_type) +# define IMLIB_REGISTER_RESOURCE(result, le_result) RETURN_RES(zend_register_resource(result, le_result)) +# define IMLIB_RSRC_DTOR_FUNC(name) ZEND_RSRC_DTOR_FUNC(name) +#else + typedef zval* imlib_zval; + typedef imlib_zval imlib_resource; + typedef char zend_string; +# define IMLIB_TO_ZVAL(v) *v +# define STR_VAL(k) (k) +# define IMLIB_DELETE_RESOURCE(v) zend_list_delete(Z_LVAL_PP(v)) +# define IMLIB_RETURN_STRING(v) RETURN_STRING(v, 1) +# define IMLIB_FETCH_RESOURCE(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type) \ + rsrc = (rsrc_type) zend_fetch_resource(passed_id TSRMLS_CC, default_id, resource_type_name, NULL, 1, resource_type) +# define IMLIB_REGISTER_RESOURCE(result, le_result) ZEND_REGISTER_RESOURCE(return_value, result, le_result) + static inline void zend_string_release(zend_string *s) + { + efree(s); + } +# define IMLIB_RSRC_DTOR_FUNC(name) void name(zend_rsrc_list_entry *res TSRMLS_DC) +# define ZEND_HASH_FOREACH_KEY_VAL(ht, _h, _key, _val) \ + HashPosition _pos; \ + zend_hash_internal_pointer_reset_ex(ht, &_pos); \ + for(; _pos; zend_hash_move_forward_ex(ht, &_pos)) \ + { \ + int _retval=zend_hash_get_current_key_ex(ht, &_key, NULL, &_h, 0, &_pos); \ + if (_retval!=HASH_KEY_IS_STRING) _key = NULL; \ + zend_hash_get_current_data_ex(ht, (void**)&_val, &_pos); +# define ZEND_HASH_FOREACH_END() \ + } +# define Z_RES_P(v) v +#endif + +Imlib_Image _php_imlib_get_image(imlib_resource *im_resource); +Imlib_Filter _php_imlib_get_filter(imlib_resource *fil_resource); +Imlib_Font _php_imlib_get_font(imlib_resource *font_resource); +Imlib_TTF_Encoding _php_imlib_get_font_encoding(imlib_resource *font_resource); +Imlib_Color_Range _php_imlib_get_cr(imlib_resource *cr_resource); +ImlibPolygon _php_imlib_get_poly(imlib_resource *poly_resource); +Imlib_Color_Modifier _php_imlib_get_cm(imlib_resource *cm_resource); struct php_imlib_filter { @@ -194,14 +238,11 @@ ZEND_END_MODULE_GLOBALS(imlib) # define IMLIBG(v) (imlib_globals.v) #endif -#else +#else /* HAVE_IMLIB */ #define phpext_imlib_ptr NULL -#endif - -#define MY_ZEND_FETCH_RESOURCE(rsrc, rsrc_type, passed_id, default_id, resource_type_name, resource_type) \ - rsrc = (rsrc_type) zend_fetch_resource(passed_id TSRMLS_CC, default_id, resource_type_name, NULL, 1, resource_type) +#endif /* HAVE_IMLIB */ #endif /* _PHP_IMLIB_H */ |
