diff options
| -rw-r--r-- | filters/php_bumpmap.c | 30 | ||||
| -rw-r--r-- | filters/php_colormatrix.c | 72 | ||||
| -rw-r--r-- | filters/php_colormod.c | 25 | ||||
| -rw-r--r-- | filters/php_hsbcolor.c | 42 | ||||
| -rw-r--r-- | filters/php_testfilter.c | 35 | ||||
| -rw-r--r-- | php_imlib.c | 407 | ||||
| -rw-r--r-- | php_imlib.h | 65 |
7 files changed, 334 insertions, 342 deletions
diff --git a/filters/php_bumpmap.c b/filters/php_bumpmap.c index 24e548d..6910f82 100644 --- a/filters/php_bumpmap.c +++ b/filters/php_bumpmap.c @@ -44,9 +44,7 @@ _php_bumpmap_exec(char* filter, HashTable* params,int index) int *paramtypes; char *script; Imlib_Image im=NULL; - ulong num_index; - zend_string *str_index; - imlib_zval *data; + HashPosition pos; paramnames=allpnames[index]; paramtypes=allptypes[index]; @@ -54,28 +52,36 @@ _php_bumpmap_exec(char* filter, HashTable* params,int index) script=estrdup(filter); script=_php_bumpmap_stradd(script,"("); - ZEND_HASH_FOREACH_KEY_VAL(params, num_index, str_index, data) - { - if (str_index) + zend_hash_internal_pointer_reset_ex(params,&pos); + while (pos) + { + char *str_index; + ulong num_index; + int retval; + + retval=zend_hash_get_current_key_ex(params,&str_index,NULL,&num_index,0,&pos); + if (retval==HASH_KEY_IS_STRING) { int match=0; int index=0; while (paramnames[index]) { - if (strcmp(STR_VAL(str_index),paramnames[index])==0) + if (strcmp(str_index,paramnames[index])==0) { char val[32]; + zval **data; + zend_hash_get_current_data_ex(params,(void**)&data,&pos); switch(paramtypes[index]) { case 'I': - im=(Imlib_Image)_php_imlib_get_image(Z_RES_P(data)); /* Why is cast to Imlib_Image needed? */ + im=(Imlib_Image)_php_imlib_get_image(data); /* Why is cast to Imlib_Image needed? */ script=_php_bumpmap_stradd(script,"map=[]"); break; case 'i': convert_to_long_ex(data); sprintf(val,"%d",(int)Z_LVAL_PP(data)); - script=_php_bumpmap_stradd(script,STR_VAL(str_index)); + script=_php_bumpmap_stradd(script,str_index); script=_php_bumpmap_stradd(script,"="); script=_php_bumpmap_stradd(script,val); break; @@ -91,7 +97,8 @@ _php_bumpmap_exec(char* filter, HashTable* params,int index) php_error(E_NOTICE,"Unknown argument %s ignored",str_index); } } - } ZEND_HASH_FOREACH_END(); + zend_hash_move_forward_ex(params,&pos); + } if (script[strlen(script)-1]==',') script[strlen(script)-1]='\0'; script=_php_bumpmap_stradd(script,");"); @@ -115,9 +122,6 @@ php_filter_deinit() } int -_php_bumpmap_getfilterindex(char*); - -int php_filter_exec(Imlib_Image im, char *filter, HashTable *params) { int index=_php_bumpmap_getfilterindex(filter); diff --git a/filters/php_colormatrix.c b/filters/php_colormatrix.c index f5dab0e..1cd28b2 100644 --- a/filters/php_colormatrix.c +++ b/filters/php_colormatrix.c @@ -264,36 +264,42 @@ static void _php_colormatrix_saturatemat(double mat[16], double sat) mat[15] = 1.0; } -static void _php_colormatrix_usermat(double mat[16], imlib_zval* data) +static void _php_colormatrix_usermat(double mat[16], zval** data) { HashTable* mat_ht; - ulong num_index; - zend_string *str_index; - imlib_zval *value; - - convert_to_array_ex(data); -#if PHP_VERSION_ID >= 70000 - mat_ht = HASH_OF(data); -#else + HashPosition pos; + + convert_to_array_ex(data); + mat_ht=(*data)->value.ht; // FIXME: should really use HASH_OF macro. // Filter API change needed to supply TSRMLS to filters -#endif - ZEND_HASH_FOREACH_KEY_VAL(mat_ht, num_index, str_index, value) + zend_hash_internal_pointer_reset_ex(mat_ht,&pos); + while (pos) { - if ((num_index>=0)&&(num_index<16)) + char *str_index; + ulong num_index; + int retval; + zval **value; + + retval=zend_hash_get_current_key_ex(mat_ht,&str_index,NULL,&num_index,0,&pos); + if (retval==HASH_KEY_IS_LONG) { - convert_to_double_ex(value); - mat[num_index]=Z_DVAL_PP(value); + if ((num_index>=0)&&(num_index<16)) + { + zend_hash_get_current_data_ex(mat_ht,(void**)&value,&pos); + convert_to_double_ex(value); + mat[num_index]=Z_DVAL_PP(value); + } } - } ZEND_HASH_FOREACH_END(); + + zend_hash_move_forward_ex(mat_ht,&pos); + } } static int _php_colormatrix_exec(Imlib_Image im, char* filter, HashTable* params) { - ulong num_index; - zend_string *str_index; - imlib_zval *data; + HashPosition pos; double mat[16]; int x=0,y=0,w,h,imgw,imgh; @@ -304,28 +310,38 @@ _php_colormatrix_exec(Imlib_Image im, char* filter, HashTable* params) w = imgw = imlib_image_get_width(); h = imgh = imlib_image_get_height(); - ZEND_HASH_FOREACH_KEY_VAL(params, num_index, str_index, data) + zend_hash_internal_pointer_reset_ex(params,&pos); + while (pos) { - if (str_index) + char *str_index; + ulong num_index; + int retval; + + retval=zend_hash_get_current_key_ex(params,&str_index,NULL,&num_index,0,&pos); + if (retval==HASH_KEY_IS_STRING) { - if (!strcmp(STR_VAL(str_index),"x")) { convert_to_long_ex(data); x=Z_LVAL_PP(data); }; - if (!strcmp(STR_VAL(str_index),"y")) { convert_to_long_ex(data); y=Z_LVAL_PP(data); }; - if (!strcmp(STR_VAL(str_index),"w")) { convert_to_long_ex(data); w=Z_LVAL_PP(data); }; - if (!strcmp(STR_VAL(str_index),"h")) { convert_to_long_ex(data); h=Z_LVAL_PP(data); }; + zval **data; + zend_hash_get_current_data_ex(params,(void**)&data,&pos); + + if (!strcmp(str_index,"x")) { convert_to_long_ex(data); x=Z_LVAL_PP(data); }; + if (!strcmp(str_index,"y")) { convert_to_long_ex(data); y=Z_LVAL_PP(data); }; + if (!strcmp(str_index,"w")) { convert_to_long_ex(data); w=Z_LVAL_PP(data); }; + if (!strcmp(str_index,"h")) { convert_to_long_ex(data); h=Z_LVAL_PP(data); }; if (!strcmp(filter,"cm_user")) { - if (!strcmp(STR_VAL(str_index),"matrix")) _php_colormatrix_usermat(mat,data); + if (!strcmp(str_index,"matrix")) _php_colormatrix_usermat(mat,data); } if (!strcmp(filter,"cm_saturation")) { - if (!strcmp(STR_VAL(str_index),"sat")) { convert_to_double_ex(data); _php_colormatrix_saturatemat(mat,Z_DVAL_PP(data)); }; + if (!strcmp(str_index,"sat")) { convert_to_double_ex(data); _php_colormatrix_saturatemat(mat,Z_DVAL_PP(data)); }; } if (!strcmp(filter,"cm_huerot")) { - if (!strcmp(STR_VAL(str_index),"angle")) { convert_to_double_ex(data); _php_colormatrix_huerotatemat(mat,Z_DVAL_PP(data)); }; + if (!strcmp(str_index,"angle")) { convert_to_double_ex(data); _php_colormatrix_huerotatemat(mat,Z_DVAL_PP(data)); }; } } - } ZEND_HASH_FOREACH_END(); + zend_hash_move_forward_ex(params,&pos); + } if (x<0) x=0; if (y<0) y=0; diff --git a/filters/php_colormod.c b/filters/php_colormod.c index a93ae84..c240f1f 100644 --- a/filters/php_colormod.c +++ b/filters/php_colormod.c @@ -32,37 +32,43 @@ _php_colormod_exec(HashTable* params) char *paramnames[]={"x","y","w","h","brightness","contrast","gamma","brightness_r","contrast_r","gamma_r","brightness_g","contrast_g","gamma_g","brightness_b","contrast_b","gamma_b","brightness_a","contrast_a","gamma_a","tint","tint_r","tint_g","tint_b","tint_a",0}; int paramtypes[]= {'i','i','i','i','d', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd' }; char *script; - ulong num_index; - zend_string *str_index; - imlib_zval *data; + HashPosition pos; script=estrdup("colormod("); - ZEND_HASH_FOREACH_KEY_VAL(params, num_index, str_index, data) + zend_hash_internal_pointer_reset_ex(params,&pos); + while (pos) { - if (str_index) + char *str_index; + ulong num_index; + int retval; + + retval=zend_hash_get_current_key_ex(params,&str_index,NULL,&num_index,0,&pos); + if (retval==HASH_KEY_IS_STRING) { int match=0; int index=0; while (paramnames[index]) { - if (strcmp(STR_VAL(str_index),paramnames[index])==0) + if (strcmp(str_index,paramnames[index])==0) { char val[32]; + zval **data; + zend_hash_get_current_data_ex(params,(void**)&data,&pos); switch(paramtypes[index]) { case 'i': convert_to_long_ex(data); sprintf(val,"%d",(int)Z_LVAL_PP(data)); - script=_php_colormod_stradd(script,STR_VAL(str_index)); + script=_php_colormod_stradd(script,str_index); script=_php_colormod_stradd(script,"="); script=_php_colormod_stradd(script,val); break; case 'd': convert_to_double_ex(data); sprintf(val,"%f",(double)Z_DVAL_PP(data)); - script=_php_colormod_stradd(script,STR_VAL(str_index)); + script=_php_colormod_stradd(script,str_index); script=_php_colormod_stradd(script,"="); script=_php_colormod_stradd(script,val); break; @@ -78,7 +84,8 @@ _php_colormod_exec(HashTable* params) php_error(E_NOTICE,"Unknown argument %s ignored",str_index); } } - } ZEND_HASH_FOREACH_END(); + zend_hash_move_forward_ex(params,&pos); + } if (script[strlen(script)-1]==',') script[strlen(script)-1]='\0'; script=_php_colormod_stradd(script,");"); diff --git a/filters/php_hsbcolor.c b/filters/php_hsbcolor.c index 288c7c1..577afc2 100644 --- a/filters/php_hsbcolor.c +++ b/filters/php_hsbcolor.c @@ -101,9 +101,7 @@ static void _php_hsbcolor_hsb2rgb(double hue, double saturation, double brightne static int _php_hsbcolor_exec(Imlib_Image im, HashTable* params) { - ulong num_index; - zend_string *str_index; - imlib_zval *data; + HashPosition pos; double h_add = 0, s_add = 0, b_add = 0; double h_mul = 1.0, s_mul = 1.0, b_mul = 1.0; @@ -113,23 +111,33 @@ _php_hsbcolor_exec(Imlib_Image im, HashTable* params) w = imgw = imlib_image_get_width(); h = imgh = imlib_image_get_height(); - ZEND_HASH_FOREACH_KEY_VAL(params, num_index, str_index, data) + zend_hash_internal_pointer_reset_ex(params,&pos); + while (pos) { - if (str_index) + char *str_index; + ulong num_index; + int retval; + + retval=zend_hash_get_current_key_ex(params,&str_index,NULL,&num_index,0,&pos); + if (retval==HASH_KEY_IS_STRING) { - if (!strcmp(STR_VAL(str_index),"x")) { convert_to_long_ex(data); x=Z_LVAL_PP(data); }; - if (!strcmp(STR_VAL(str_index),"y")) { convert_to_long_ex(data); y=Z_LVAL_PP(data); }; - if (!strcmp(STR_VAL(str_index),"w")) { convert_to_long_ex(data); w=Z_LVAL_PP(data); }; - if (!strcmp(STR_VAL(str_index),"h")) { convert_to_long_ex(data); h=Z_LVAL_PP(data); }; - - if (!strcmp(STR_VAL(str_index),"h_add")) { convert_to_double_ex(data); h_add=Z_DVAL_PP(data); }; - if (!strcmp(STR_VAL(str_index),"s_add")) { convert_to_double_ex(data); s_add=Z_DVAL_PP(data); }; - if (!strcmp(STR_VAL(str_index),"b_add")) { convert_to_double_ex(data); b_add=Z_DVAL_PP(data); }; - if (!strcmp(STR_VAL(str_index),"h_mul")) { convert_to_double_ex(data); h_mul=Z_DVAL_PP(data); }; - if (!strcmp(STR_VAL(str_index),"s_mul")) { convert_to_double_ex(data); s_mul=Z_DVAL_PP(data); }; - if (!strcmp(STR_VAL(str_index),"b_mul")) { convert_to_double_ex(data); b_mul=Z_DVAL_PP(data); }; + zval **data; + zend_hash_get_current_data_ex(params,(void*)&data,&pos); + + if (!strcmp(str_index,"x")) { convert_to_long_ex(data); x=Z_LVAL_PP(data); }; + if (!strcmp(str_index,"y")) { convert_to_long_ex(data); y=Z_LVAL_PP(data); }; + if (!strcmp(str_index,"w")) { convert_to_long_ex(data); w=Z_LVAL_PP(data); }; + if (!strcmp(str_index,"h")) { convert_to_long_ex(data); h=Z_LVAL_PP(data); }; + + if (!strcmp(str_index,"h_add")) { convert_to_double_ex(data); h_add=Z_DVAL_PP(data); }; + if (!strcmp(str_index,"s_add")) { convert_to_double_ex(data); s_add=Z_DVAL_PP(data); }; + if (!strcmp(str_index,"b_add")) { convert_to_double_ex(data); b_add=Z_DVAL_PP(data); }; + if (!strcmp(str_index,"h_mul")) { convert_to_double_ex(data); h_mul=Z_DVAL_PP(data); }; + if (!strcmp(str_index,"s_mul")) { convert_to_double_ex(data); s_mul=Z_DVAL_PP(data); }; + if (!strcmp(str_index,"b_mul")) { convert_to_double_ex(data); b_mul=Z_DVAL_PP(data); }; } - } ZEND_HASH_FOREACH_END(); + zend_hash_move_forward_ex(params,&pos); + } if (x<0) x=0; if (y<0) y=0; diff --git a/filters/php_testfilter.c b/filters/php_testfilter.c index c9e4b5b..ca844b3 100644 --- a/filters/php_testfilter.c +++ b/filters/php_testfilter.c @@ -14,9 +14,7 @@ _php_testfilter_tint(Imlib_Image im, HashTable* params) { Imlib_Image imge = im; Imlib_Image anoim; - ulong num_index; - zend_string *str_index; - imlib_zval *data; + HashPosition pos; Imlib_Color_Modifier cm; DATA8 atab[256]; @@ -30,21 +28,30 @@ _php_testfilter_tint(Imlib_Image im, HashTable* params) w = imlib_image_get_width(); h = imlib_image_get_height(); - ZEND_HASH_FOREACH_KEY_VAL(params, num_index, str_index, data) + zend_hash_internal_pointer_reset_ex(params,&pos); + while (pos) { - if (str_index) + char *str_index; + ulong num_index; + int retval; + + retval=zend_hash_get_current_key_ex(params,&str_index,NULL,&num_index,0,&pos); + if (retval==HASH_KEY_IS_STRING) { + zval **data; + zend_hash_get_current_data_ex(params,(void*)&data,&pos); convert_to_long_ex(data); - if (!strcmp(STR_VAL(str_index),"red")) r=Z_LVAL_PP(data); - if (!strcmp(STR_VAL(str_index),"blue")) b=Z_LVAL_PP(data); - if (!strcmp(STR_VAL(str_index),"green")) g=Z_LVAL_PP(data); - if (!strcmp(STR_VAL(str_index),"x")) x=Z_LVAL_PP(data); - if (!strcmp(STR_VAL(str_index),"y")) y=Z_LVAL_PP(data); - if (!strcmp(STR_VAL(str_index),"w")) w=Z_LVAL_PP(data); - if (!strcmp(STR_VAL(str_index),"h")) h=Z_LVAL_PP(data); - if (!strcmp(STR_VAL(str_index),"alpha")) a=Z_LVAL_PP(data); + if (!strcmp(str_index,"red")) r=Z_LVAL_PP(data); + if (!strcmp(str_index,"blue")) b=Z_LVAL_PP(data); + if (!strcmp(str_index,"green")) g=Z_LVAL_PP(data); + if (!strcmp(str_index,"x")) x=Z_LVAL_PP(data); + if (!strcmp(str_index,"y")) y=Z_LVAL_PP(data); + if (!strcmp(str_index,"w")) w=Z_LVAL_PP(data); + if (!strcmp(str_index,"h")) h=Z_LVAL_PP(data); + if (!strcmp(str_index,"alpha")) a=Z_LVAL_PP(data); } - } ZEND_HASH_FOREACH_END(); + zend_hash_move_forward_ex(params,&pos); + } /* zend_printf( "Using values red=%d,blue=%d,green=%d,x=%d,y=%d,height=%d,width=%d,alpha=%d\n", r,b,g,x,y,w,h,a ); */ diff --git a/php_imlib.c b/php_imlib.c index 2e387a1..e1a2828 100644 --- a/php_imlib.c +++ b/php_imlib.c @@ -22,7 +22,6 @@ #include "php_imlib.h" #include "php_globals.h" #include "php_open_temporary_file.h" -#include "ext/standard/info.h" /* #define IMLIB_DEBUG */ @@ -208,7 +207,7 @@ zend_module_entry imlib_module_entry = { PHP_INI_MH(OnUpdateFontCacheSize) { int size; - if (sscanf(STR_VAL(new_value),"%d",&size)==1) + if (sscanf(new_value,"%d",&size)==1) { imlib_set_font_cache_size(size); return SUCCESS; @@ -219,41 +218,41 @@ PHP_INI_MH(OnUpdateFontCacheSize) } } -IMLIB_RSRC_DTOR_FUNC(_php_imlib_free_cm) +static void _php_imlib_free_cm(zend_rsrc_list_entry *rsrc TSRMLS_DC) { - imlib_context_set_color_modifier(((PHP_Imlib_Color_Modifier)res->ptr)->cm); - efree(res->ptr); + imlib_context_set_color_modifier(((PHP_Imlib_Color_Modifier)rsrc->ptr)->cm); + efree(rsrc->ptr); imlib_free_color_modifier(); } -IMLIB_RSRC_DTOR_FUNC(_php_imlib_free_filter) +static void _php_imlib_free_filter(zend_rsrc_list_entry *rsrc TSRMLS_DC) { - imlib_context_set_filter(res->ptr); + imlib_context_set_filter(rsrc->ptr); imlib_free_filter(); } -IMLIB_RSRC_DTOR_FUNC(_php_imlib_free_cr) +static void _php_imlib_free_cr(zend_rsrc_list_entry *rsrc TSRMLS_DC) { - imlib_context_set_color_range(res->ptr); + imlib_context_set_color_range(rsrc->ptr); imlib_free_color_range(); } -IMLIB_RSRC_DTOR_FUNC(_php_imlib_free_font) +static void _php_imlib_free_font(zend_rsrc_list_entry *rsrc TSRMLS_DC) { - imlib_context_set_font(((PHP_Imlib_Font)res->ptr)->font); - efree(res->ptr); + imlib_context_set_font(((PHP_Imlib_Font)rsrc->ptr)->font); + efree(rsrc->ptr); imlib_free_font(); } -IMLIB_RSRC_DTOR_FUNC(_php_imlib_free_img) +static void _php_imlib_free_img(zend_rsrc_list_entry *rsrc TSRMLS_DC) { - imlib_context_set_image(res->ptr); + imlib_context_set_image(rsrc->ptr); imlib_free_image(); } -IMLIB_RSRC_DTOR_FUNC(_php_imlib_free_poly) +static void _php_imlib_free_poly(zend_rsrc_list_entry *rsrc TSRMLS_DC) { - imlib_polygon_free(res->ptr); + imlib_polygon_free(rsrc->ptr); } void _php_imlib_set_cache_size(int size TSRMLS_DC) @@ -486,19 +485,19 @@ struct php_imlib_filter* _php_imlib_find_filter(char *filter_name TSRMLS_DC) return NULL; } -Imlib_Image _php_imlib_get_image(imlib_resource *im_resource) +Imlib_Image _php_imlib_get_image(zval** im_resource) { Imlib_Image im; TSRMLS_FETCH(); - IMLIB_FETCH_RESOURCE(im, Imlib_Image, im_resource, -1, "Imlib Image", le_imlib_img); + MY_ZEND_FETCH_RESOURCE(im, Imlib_Image, im_resource, -1, "Imlib Image", le_imlib_img); return im; } -Imlib_Filter _php_imlib_get_filter(imlib_resource *fil_resource) +Imlib_Filter _php_imlib_get_filter(zval** fil_resource) { Imlib_Filter fil; TSRMLS_FETCH(); - IMLIB_FETCH_RESOURCE(fil, Imlib_Filter, fil_resource, -1, "Imlib Filter", le_imlib_filter); + MY_ZEND_FETCH_RESOURCE(fil, Imlib_Filter, fil_resource, -1, "Imlib Filter", le_imlib_filter); return fil; } @@ -523,37 +522,37 @@ void _php_imlib_color_modifier_synch(PHP_Imlib_Color_Modifier cm) imlib_context_set_color_modifier(NULL); } -Imlib_Color_Modifier _php_imlib_get_cm(imlib_resource *cm_resource) +Imlib_Color_Modifier _php_imlib_get_cm(zval** cm_resource) { PHP_Imlib_Color_Modifier cm; TSRMLS_FETCH(); - IMLIB_FETCH_RESOURCE(cm, Imlib_Color_Modifier, cm_resource, -1, "Imlib Color Modifier", le_imlib_cm); + MY_ZEND_FETCH_RESOURCE(cm, Imlib_Color_Modifier, cm_resource, -1, "Imlib Color Modifier", le_imlib_cm); if (cm->modified) _php_imlib_color_modifier_synch(cm); cm->valid=0; return cm->cm; } -Imlib_Font _php_imlib_get_font(imlib_resource *font_resource) +Imlib_Font _php_imlib_get_font(zval** font_resource) { PHP_Imlib_Font php_font; TSRMLS_FETCH(); - IMLIB_FETCH_RESOURCE(php_font, PHP_Imlib_Font, font_resource, -1, "Imlib Font", le_imlib_font); + MY_ZEND_FETCH_RESOURCE(php_font, PHP_Imlib_Font, font_resource, -1, "Imlib Font", le_imlib_font); return php_font->font; } -Imlib_Color_Range _php_imlib_get_cr(imlib_resource *cr_resource) +Imlib_Color_Range _php_imlib_get_cr(zval** cr_resource) { Imlib_Color_Range cr; TSRMLS_FETCH(); - IMLIB_FETCH_RESOURCE(cr, Imlib_Color_Range, cr_resource, -1, "Imlib Color Range", le_imlib_cr); + MY_ZEND_FETCH_RESOURCE(cr, Imlib_Color_Range, cr_resource, -1, "Imlib Color Range", le_imlib_cr); return cr; } -ImlibPolygon _php_imlib_get_poly(imlib_resource *poly_resource) +ImlibPolygon _php_imlib_get_poly(zval** poly_resource) { ImlibPolygon poly; TSRMLS_FETCH(); - IMLIB_FETCH_RESOURCE(poly, ImlibPolygon, poly_resource, -1, "Imlib Polygon", le_imlib_poly); + MY_ZEND_FETCH_RESOURCE(poly, ImlibPolygon, poly_resource, -1, "Imlib Polygon", le_imlib_poly); return poly; } @@ -561,9 +560,9 @@ ImlibPolygon _php_imlib_get_poly(imlib_resource *poly_resource) /* {{{ _php_imlib_free_ps_font */ -IMLIB_RSRC_DTOR_FUNC(_php_imlib_free_ps_font) +void _php_imlib_free_ps_font(zend_rsrc_list_entry *rsrc TSRMLS_DC) { - int *font = (int *)res->ptr; + int *font = (int *)rsrc->ptr; T1_DeleteFont(*font); efree(font); @@ -572,9 +571,9 @@ IMLIB_RSRC_DTOR_FUNC(_php_imlib_free_ps_font) /* {{{ _php_imlib_free_ps_enc */ -IMLIB_RSRC_DTOR_FUNC(_php_imlib_free_ps_enc) +void _php_imlib_free_ps_enc(zend_rsrc_list_entry *rsrc TSRMLS_DC) { - char **enc = (char **)res->ptr; + char **enc = (char **)rsrc->ptr; T1_DeleteEncoding(enc); } @@ -820,20 +819,24 @@ PHP_MINFO_FUNCTION(imlib) } } -static inline int zend_hash_index_find_wrapper(HashTable *ht, int index, imlib_zval **value) +static void _php_convert_four_longs(zval **zone, zval **ztwo, zval **zthree, + zval **zfour, int *one, int *two, + int *three, int *four) { -#if PHP_VERSION_ID >= 70000 - *value = zend_hash_index_find(ht, index); - return (*value != NULL ? SUCCESS : FAILURE); -#else - return zend_hash_index_find(ht, index, (void **)value); -#endif + convert_to_long_ex(zone); + convert_to_long_ex(ztwo); + convert_to_long_ex(zthree); + convert_to_long_ex(zfour); + *one = Z_LVAL_PP(zone); + *two = Z_LVAL_PP(ztwo); + *three = Z_LVAL_PP(zthree); + *four = Z_LVAL_PP(zfour); } static int _php_handle_cliprect_array(zval **dbox, char *func_name, int *x, int *y, int *w, int *h TSRMLS_DC) { - imlib_zval *element, **box_coords; + zval **element, ***box_coords; int i,arrcount; HashTable *box; @@ -850,11 +853,11 @@ static int _php_handle_cliprect_array(zval **dbox, char *func_name, return 0; } - box_coords = (imlib_zval **)emalloc(arrcount * sizeof(imlib_zval *)); + box_coords = (zval ***)emalloc(arrcount * sizeof(zval **)); for (i = 0; i < arrcount; i++) { - if (zend_hash_index_find_wrapper(box, i, &element) == SUCCESS) + if (zend_hash_index_find(box, i, (void **)&element) == SUCCESS) { convert_to_long_ex(element); box_coords[i] = element; @@ -943,8 +946,7 @@ static void _php_imlib_draw_something(INTERNAL_FUNCTION_PARAMETERS, void (*func) { int argc; int cx, cy, cw, ch; - imlib_resource img; - zval *dbox; + zval *img, *dbox; long x,y,w,h,r,g,b,a; Imlib_Image im; @@ -953,7 +955,7 @@ static void _php_imlib_draw_something(INTERNAL_FUNCTION_PARAMETERS, void (*func) return; } - IMLIB_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); imlib_context_set_image(im); imlib_context_set_color(r,g,b,a); @@ -975,12 +977,12 @@ static void _php_imlib_draw_something(INTERNAL_FUNCTION_PARAMETERS, void (*func) static void _php_imlib_single_arg(INTERNAL_FUNCTION_PARAMETERS, void (*func)()) { - imlib_resource img; + zval *img; Imlib_Image im; if (zend_parse_parameters(1 TSRMLS_CC, "r", &img) == FAILURE) return; - IMLIB_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); imlib_context_set_image(im); (*func)(); @@ -998,13 +1000,13 @@ static void _php_wrap_draw_line(int x1, int y1, int x2, int y2) Add a color to a color range at a specified distance from the previous color in the range. A distance of 0 centers it */ PHP_FUNCTION(imlib_add_color_to_color_range) { - imlib_resource crange; + zval *crange; long x,r,g,b,a; Imlib_Color_Range range; if (zend_parse_parameters(6 TSRMLS_CC, "rlllll", &crange, &x, &r, &g, &b, &a) == FAILURE) return; - IMLIB_FETCH_RESOURCE(range, Imlib_Color_Range, &crange, -1, "Imlib Color Range", le_imlib_cr); + ZEND_FETCH_RESOURCE(range, Imlib_Color_Range, &crange, -1, "Imlib Color Range", le_imlib_cr); imlib_context_set_color_range(range); imlib_context_set_color(r,g,b,a); @@ -1017,15 +1019,15 @@ PHP_FUNCTION(imlib_add_color_to_color_range) Blend a rectangular area from an image onto an area of another image, scaling as necessary */ PHP_FUNCTION(imlib_blend_image_onto_image) { - imlib_resource dstimg, srcimg; + zval *dstimg, *srcimg; Imlib_Image dst,src; long sx,sy,sw,sh,dx,dy,dw,dh; long calias, calpha, cblend, cdither; if (zend_parse_parameters(14 TSRMLS_CC, "rrllllllllllll", &dstimg, &srcimg, &calpha, &sx, &sy, &sw, &sh, &dx, &dy, &dw, &dh, &cdither, &cblend, &calias) == FAILURE) return; - IMLIB_FETCH_RESOURCE(src, Imlib_Image, &srcimg, -1, "Imlib Image", le_imlib_img); - IMLIB_FETCH_RESOURCE(dst, Imlib_Image, &dstimg, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(src, Imlib_Image, &srcimg, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(dst, Imlib_Image, &dstimg, -1, "Imlib Image", le_imlib_img); imlib_context_set_image(dst); imlib_context_set_anti_alias(calias); @@ -1041,17 +1043,17 @@ PHP_FUNCTION(imlib_blend_image_onto_image) Duplicate an image */ PHP_FUNCTION(imlib_clone_image) { - imlib_resource img; + zval *img; Imlib_Image src,dst; if (zend_parse_parameters(1 TSRMLS_CC, "r", &img) == FAILURE) return; - IMLIB_FETCH_RESOURCE(src, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(src, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); imlib_context_set_image(src); dst = imlib_clone_image(); - if (dst) IMLIB_REGISTER_RESOURCE(dst, le_imlib_img); + if (dst) ZEND_REGISTER_RESOURCE(return_value, dst, le_imlib_img); } /* }}} */ @@ -1068,7 +1070,7 @@ PHP_FUNCTION(imlib_create_color_range) cr = imlib_create_color_range(); - if (cr) IMLIB_REGISTER_RESOURCE(cr, le_imlib_cr); + if (cr) ZEND_REGISTER_RESOURCE(return_value, cr, le_imlib_cr); } /* }}} */ @@ -1095,7 +1097,7 @@ PHP_FUNCTION(imlib_create_color_modifier) RETURN_FALSE; } - IMLIB_REGISTER_RESOURCE(cm, le_imlib_cm); + ZEND_REGISTER_RESOURCE(return_value, cm, le_imlib_cm); } /* }}} */ @@ -1103,18 +1105,18 @@ PHP_FUNCTION(imlib_create_color_modifier) Create an image from a cropped region of another image */ PHP_FUNCTION(imlib_create_cropped_image) { - imlib_resource img; + zval *img; long sx,sy,sw,sh; Imlib_Image src,dst; if (zend_parse_parameters(5 TSRMLS_CC, "rllll", &img, &sx, &sy, &sw, &sh) == FAILURE) return; - IMLIB_FETCH_RESOURCE(src, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(src, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); imlib_context_set_image(src); dst = imlib_create_cropped_image(sx,sy,sw,sh); - if (dst) IMLIB_REGISTER_RESOURCE(dst, le_imlib_img); + if (dst) ZEND_REGISTER_RESOURCE(return_value, dst, le_imlib_img); } /* }}} */ @@ -1123,18 +1125,18 @@ PHP_FUNCTION(imlib_create_cropped_image) Create a scaled image from a cropped region of another image */ PHP_FUNCTION(imlib_create_cropped_scaled_image) { - imlib_resource img; + zval *img; long sx,sy,sw,sh,dw,dh; Imlib_Image src,dst; if (zend_parse_parameters(7 TSRMLS_CC, "rllllll", &img, &sx, &sy, &sw, &sh, &dw, &dh) == FAILURE) return; - IMLIB_FETCH_RESOURCE(src, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(src, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); imlib_context_set_image(src); dst = imlib_create_cropped_scaled_image(sx,sy, sw,sh, dw,dh); - if (dst) IMLIB_REGISTER_RESOURCE(dst, le_imlib_img); + if (dst) ZEND_REGISTER_RESOURCE(return_value, dst, le_imlib_img); } /* }}} */ @@ -1154,7 +1156,7 @@ PHP_FUNCTION(imlib_create_image) imlib_context_set_image(im); memset(imlib_image_get_data(), '\0', x * y * sizeof(DATA32)); - IMLIB_REGISTER_RESOURCE(im, le_imlib_img); + ZEND_REGISTER_RESOURCE(return_value, im, le_imlib_img); } } /* }}} */ @@ -1167,7 +1169,7 @@ PHP_FUNCTION(imlib_create_rotated_image) /* Contributed by Gareth Ardron */ - imlib_resource srcimg; + zval *srcimg; double angle, radians; int argc; Imlib_Image src, dst; @@ -1175,14 +1177,14 @@ PHP_FUNCTION(imlib_create_rotated_image) argc = ZEND_NUM_ARGS(); if (zend_parse_parameters(argc TSRMLS_CC, "rd|d", &srcimg, &angle, &radians) == FAILURE) return; - IMLIB_FETCH_RESOURCE(src, Imlib_Image, &srcimg, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(src, Imlib_Image, &srcimg, -1, "Imlib Image", le_imlib_img); if (argc == 2) radians = angle * M_PI/180; imlib_context_set_image(src); dst = imlib_create_rotated_image(radians); - if (dst) IMLIB_REGISTER_RESOURCE(dst, le_imlib_img); + if (dst) ZEND_REGISTER_RESOURCE(return_value, dst, le_imlib_img); } /* }}} */ @@ -1191,14 +1193,14 @@ PHP_FUNCTION(imlib_create_rotated_image) Create a scaled copy of an image. If dstw or dsth is left blank, the aspect ratio of the source image will be preserved. */ PHP_FUNCTION(imlib_create_scaled_image) { - imlib_resource img; - imlib_zval *dstw, *dsth; + zval *img; + zval **dstw, **dsth; long sw,sh,dw,dh; Imlib_Image src,dst; if (zend_parse_parameters(3 TSRMLS_CC, "rZZ", &img, &dstw, &dsth) == FAILURE) return; - IMLIB_FETCH_RESOURCE(src, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(src, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); convert_to_long_ex(dstw); convert_to_long_ex(dsth); @@ -1221,7 +1223,7 @@ PHP_FUNCTION(imlib_create_scaled_image) dst = imlib_create_cropped_scaled_image(0,0, sw,sh, dw,dh); - if (dst) IMLIB_REGISTER_RESOURCE(dst, le_imlib_img); + if (dst) ZEND_REGISTER_RESOURCE(return_value, dst, le_imlib_img); } /* }}} */ @@ -1233,9 +1235,8 @@ PHP_FUNCTION(imlib_dump_image) int argc, retval; long q; FILE *tmp; - zend_string *tmpfile; - imlib_resource img; - zval **err; + char *tmpfile; + zval *img, **err; Imlib_Image im; Imlib_Load_Error im_err; @@ -1247,7 +1248,7 @@ PHP_FUNCTION(imlib_dump_image) ZVAL_LONG(*err,0); } - IMLIB_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); tmp = php_open_temporary_file("", "", &tmpfile TSRMLS_CC); if (tmp == NULL) { @@ -1265,7 +1266,7 @@ PHP_FUNCTION(imlib_dump_image) imlib_image_attach_data_value("quality",NULL,q,NULL); } - imlib_save_image_with_error_return(STR_VAL(tmpfile),&im_err); + imlib_save_image_with_error_return(tmpfile,&im_err); if (im_err) { @@ -1274,7 +1275,7 @@ PHP_FUNCTION(imlib_dump_image) ZVAL_LONG(*err,im_err); } _php_handle_imlib_error(INTERNAL_FUNCTION_PARAM_PASSTHRU, - im_err,STR_VAL(tmpfile)); + im_err,tmpfile); fclose(tmp); VCWD_UNLINK((const char *)tmpfile); /* make sure that the temporary file is removed */ efree(tmpfile); @@ -1310,13 +1311,13 @@ PHP_FUNCTION(imlib_dump_image) Free a color range */ PHP_FUNCTION(imlib_free_color_range) { - imlib_resource fcr; + zval *fcr; Imlib_Color_Range cr; if (zend_parse_parameters(1 TSRMLS_CC, "r", &fcr) == FAILURE) return; - IMLIB_FETCH_RESOURCE(cr, Imlib_Color_Range, &fcr, -1, "Imlib Color Range", le_imlib_cr); - IMLIB_DELETE_RESOURCE(&fcr); + ZEND_FETCH_RESOURCE(cr, Imlib_Color_Range, &fcr, -1, "Imlib Color Range", le_imlib_cr); + zend_list_delete(Z_LVAL_PP(&fcr)); } /* }}} */ @@ -1325,13 +1326,13 @@ PHP_FUNCTION(imlib_free_color_range) Free a color modifier */ PHP_FUNCTION(imlib_free_color_modifier) { - imlib_resource fcm; + zval *fcm; PHP_Imlib_Color_Modifier cm; if (zend_parse_parameters(1 TSRMLS_CC, "r", &fcm) == FAILURE) return; - IMLIB_FETCH_RESOURCE(cm, PHP_Imlib_Color_Modifier, &fcm, -1, "Imlib Color Modifier", le_imlib_cm); - IMLIB_DELETE_RESOURCE(&fcm); + ZEND_FETCH_RESOURCE(cm, PHP_Imlib_Color_Modifier, &fcm, -1, "Imlib Color Modifier", le_imlib_cm); + zend_list_delete(Z_LVAL_PP(&fcm)); } /* }}} */ @@ -1339,13 +1340,13 @@ PHP_FUNCTION(imlib_free_color_modifier) Free a font */ PHP_FUNCTION(imlib_free_font) { - imlib_resource font; + zval *font; PHP_Imlib_Font fn; if (zend_parse_parameters(1 TSRMLS_CC, "r", &font) == FAILURE) return; - IMLIB_FETCH_RESOURCE(fn, PHP_Imlib_Font, &font, -1, "Imlib Font", le_imlib_font); - IMLIB_DELETE_RESOURCE(&font); + ZEND_FETCH_RESOURCE(fn, PHP_Imlib_Font, &font, -1, "Imlib Font", le_imlib_font); + zend_list_delete(Z_LVAL_PP(&font)); } /* }}} */ @@ -1354,13 +1355,13 @@ PHP_FUNCTION(imlib_free_font) Free an image */ PHP_FUNCTION(imlib_free_image) { - imlib_resource img; + zval *img; Imlib_Image im; if (zend_parse_parameters(1 TSRMLS_CC, "r", &img) == FAILURE) return; - IMLIB_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); - IMLIB_DELETE_RESOURCE(&img); + ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); + zend_list_delete(Z_LVAL_PP(&img)); } /* }}} */ @@ -1369,7 +1370,7 @@ PHP_FUNCTION(imlib_free_image) Determines the horizontal and vertical advance of a string if drawn with a given font in the specified direction*/ PHP_FUNCTION(imlib_get_text_advance) { - imlib_resource font; + zval *font; zval **thoriz_adv, **tvert_adv; PHP_Imlib_Font fn; const char *text = NULL; @@ -1378,7 +1379,7 @@ PHP_FUNCTION(imlib_get_text_advance) if (zend_parse_parameters(5 TSRMLS_CC, "rsZZl", &font, &text, &text_len, &thoriz_adv, &tvert_adv, &dir) == FAILURE) return; - IMLIB_FETCH_RESOURCE(fn, PHP_Imlib_Font, &font, -1, "Imlib Font", le_imlib_font); + ZEND_FETCH_RESOURCE(fn, PHP_Imlib_Font, &font, -1, "Imlib Font", le_imlib_font); imlib_context_set_font(fn->font); imlib_context_set_direction(dir); @@ -1396,7 +1397,7 @@ PHP_FUNCTION(imlib_get_text_advance) Determines the width and height of a string if drawn with a given font in the specified direction */ PHP_FUNCTION(imlib_get_text_size) { - imlib_resource font; + zval *font; zval **tw, **th; PHP_Imlib_Font fn; const char *text = NULL; @@ -1405,7 +1406,7 @@ PHP_FUNCTION(imlib_get_text_size) if (zend_parse_parameters(5 TSRMLS_CC, "rsZZl", &font, &text, &text_len, &tw, &th, &dir) == FAILURE) return; - IMLIB_FETCH_RESOURCE(fn, PHP_Imlib_Font, &font, -1, "Imlib Font", le_imlib_font); + ZEND_FETCH_RESOURCE(fn, PHP_Imlib_Font, &font, -1, "Imlib Font", le_imlib_font); zval_dtor(*tw); zval_dtor(*th); @@ -1424,13 +1425,13 @@ PHP_FUNCTION(imlib_get_text_size) Blur an image with a given blur radius */ PHP_FUNCTION(imlib_image_blur) { - imlib_resource img; + zval *img; long r; Imlib_Image im; if (zend_parse_parameters(2 TSRMLS_CC, "rl", &img, &r) == FAILURE) return; - IMLIB_FETCH_RESOURCE(im, Imlib |
