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,");");
@@ -114,9 +121,6 @@ php_filter_deinit()
return;
}
-int
-_php_bumpmap_getfilterindex(char*);
-
int
php_filter_exec(Imlib_Image im, char *filter, HashTable *params)
{
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_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_image_blur(r);
@@ -1462,8 +1463,7 @@ PHP_FUNCTION(imlib_image_draw_line)
Draw the defined polygon on an image */
PHP_FUNCTION(imlib_image_draw_polygon)
{
- imlib_resource img, polygon;
- zval *dbox;
+ zval *img, *polygon, *dbox;
long r,g,b,a;
int cx,cy,cw,ch,argc;
Imlib_Image im;
@@ -1473,8 +1473,8 @@ PHP_FUNCTION(imlib_image_draw_polygon)
argc = ZEND_NUM_ARGS();
if (zend_parse_parameters(argc TSRMLS_CC, "rrbllll|a", &img, &polygon, &closed, &r, &g, &b, &a, &dbox) == FAILURE) return;
- IMLIB_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img);
- IMLIB_FETCH_RESOURCE(poly, ImlibPolygon, &polygon, -1, "Imlib Polygon", le_imlib_poly);
+ ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img);
+ ZEND_FETCH_RESOURCE(poly, ImlibPolygon, &polygon, -1, "Imlib Polygon", le_imlib_poly);
imlib_context_set_image(im);
imlib_context_set_color(r,g,b,a);
@@ -1506,8 +1506,7 @@ PHP_FUNCTION(imlib_image_draw_rectangle)
Fill a rectangle with a color range at a given angle on an image */
PHP_FUNCTION(imlib_image_fill_color_range_rectangle)
{
- imlib_resource fim, fcr;
- zval *fbox;
+ zval *fim, *fcr, *fbox;
long x,y,width,height;
int argc,cx,cy,cw,ch;
double angle;
@@ -1517,8 +1516,8 @@ PHP_FUNCTION(imlib_image_fill_color_range_rectangle)
argc = ZEND_NUM_ARGS();
if (zend_parse_parameters(argc TSRMLS_CC, "rrlllld|a", &fim, &fcr, &x, &y, &width, &height, &angle, &fbox) == FAILURE) return;
- IMLIB_FETCH_RESOURCE(cr, Imlib_Color_Range, &fcr, -1, "Imlib Color Range", le_imlib_cr);
- IMLIB_FETCH_RESOURCE(im, Imlib_Image, &fim, -1, "Imlib Image", le_imlib_img);
+ ZEND_FETCH_RESOURCE(cr, Imlib_Color_Range, &fcr, -1, "Imlib Color Range", le_imlib_cr);
+ ZEND_FETCH_RESOURCE(im, Imlib_Image, &fim, -1, "Imlib Image", le_imlib_img);
imlib_context_set_color_range(cr);
imlib_context_set_image(im);
@@ -1551,8 +1550,7 @@ PHP_FUNCTION(imlib_image_fill_ellipse)
Draw and fill the defined polygon on an image */
PHP_FUNCTION(imlib_image_fill_polygon)
{
- imlib_resource img, polygon;
- zval *dbox;
+ zval *img, *polygon, *dbox;
long r,g,b,a;
int cx,cy,cw,ch,argc;
Imlib_Image im;
@@ -1561,8 +1559,8 @@ PHP_FUNCTION(imlib_image_fill_polygon)
argc = ZEND_NUM_ARGS();
if (zend_parse_parameters(argc TSRMLS_CC, "rrllll|a", &img, &polygon, &r, &g, &b, &a, &dbox) == FAILURE) return;
- IMLIB_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img);
- IMLIB_FETCH_RESOURCE(poly, ImlibPolygon, &polygon, -1, "Imlib Polygon", le_imlib_poly);
+ ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img);
+ ZEND_FETCH_RESOURCE(poly, ImlibPolygon, &polygon, -1, "Imlib Polygon", le_imlib_poly);
imlib_context_set_image(im);
imlib_context_set_color(r,g,b,a);
@@ -1625,13 +1623,13 @@ PHP_FUNCTION(imlib_image_orientate)
/* Contributed by Gareth Ardron */
- 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_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_image_orientate(r);
@@ -1643,20 +1641,20 @@ PHP_FUNCTION(imlib_image_orientate)
Returns the image format of an image */
PHP_FUNCTION(imlib_image_format)
{
- imlib_resource img;
+ zval *img;
Imlib_Image im;
char *name;
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);
name = imlib_image_format();
if (!name)
RETURN_FALSE;
- IMLIB_RETURN_STRING(name);
+ RETURN_STRING(name,strlen(name));
}
/* }}} */
@@ -1665,20 +1663,20 @@ PHP_FUNCTION(imlib_image_format)
Returns the filename of an image */
PHP_FUNCTION(imlib_image_get_filename)
{
- imlib_resource img;
+ zval *img;
Imlib_Image im;
const char *name = NULL;
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);
name = imlib_image_get_filename();
if (!name)
RETURN_FALSE;
- IMLIB_RETURN_STRING((char*)name);
+ RETURN_STRING((char*)name,strlen(name));
}
/* }}} */
@@ -1687,13 +1685,13 @@ PHP_FUNCTION(imlib_image_get_filename)
Returns the height of an image */
PHP_FUNCTION(imlib_image_get_height)
{
- imlib_resource img;
+ zval *img;
Imlib_Image im;
int height;
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);
height = imlib_image_get_height();
@@ -1707,13 +1705,13 @@ PHP_FUNCTION(imlib_image_get_height)
Returns the width of an image */
PHP_FUNCTION(imlib_image_get_width)
{
- imlib_resource img;
+ zval *img;
Imlib_Image im;
int width;
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);
width = imlib_image_get_width();
@@ -1727,12 +1725,12 @@ PHP_FUNCTION(imlib_image_get_width)
Return a boolean for whether or not an image has an alpha channel */
PHP_FUNCTION(imlib_image_has_alpha)
{
- 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);
if (imlib_image_has_alpha())
@@ -1751,7 +1749,7 @@ PHP_FUNCTION(imlib_image_has_alpha)
Set the alpha channel of an image, or modify it if one was already present */
PHP_FUNCTION(imlib_image_modify_alpha)
{
- imlib_resource img;
+ zval *img;
Imlib_Image im;
DATA8 map[256];
Imlib_Color_Modifier *cmod;
@@ -1761,7 +1759,7 @@ PHP_FUNCTION(imlib_image_modify_alpha)
if (zend_parse_parameters(2 TSRMLS_CC, "rl", &img, &malpha) == 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);
ratio = ((double)malpha) / 255;
@@ -1791,14 +1789,14 @@ PHP_FUNCTION(imlib_image_modify_alpha)
Sets the image format of an image. */
PHP_FUNCTION(imlib_image_set_format)
{
- imlib_resource img;
+ zval *img;
Imlib_Image im;
char *format;
int format_len;
if (zend_parse_parameters(2 TSRMLS_CC, "rs", &img, &format, &format_len) == 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);
imlib_image_set_format(format);
@@ -1812,13 +1810,13 @@ PHP_FUNCTION(imlib_image_set_format)
Sharpen an image with a given sharpen radius */
PHP_FUNCTION(imlib_image_sharpen)
{
- 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_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_image_sharpen(r);
@@ -1871,11 +1869,7 @@ PHP_FUNCTION(imlib_list_fonts)
for (i = 0; i < fcount; i++)
{
/* FIXME: Is 1 the right parameter here? */
-#if PHP_VERSION_ID >= 70000
- add_next_index_string(return_value, flist[i]);
-#else
add_next_index_string(return_value, flist[i], 1);
-#endif
}
imlib_free_font_list(flist,fcount);
@@ -1906,7 +1900,7 @@ PHP_FUNCTION(imlib_load_font)
RETURN_FALSE;
}
- IMLIB_REGISTER_RESOURCE(fn, le_imlib_font);
+ ZEND_REGISTER_RESOURCE(return_value, fn, le_imlib_font);
}
/* }}} */
@@ -1920,7 +1914,7 @@ PHP_FUNCTION(imlib_load_image)
Imlib_Image im;
Imlib_Load_Error im_err;
FILE* f;
- zend_string* filename;
+ char* filename;
char* img;
int img_len;
@@ -1935,10 +1929,10 @@ PHP_FUNCTION(imlib_load_image)
f = php_stream_open_wrapper_as_file(img, "rb", IGNORE_PATH | ENFORCE_SAFE_MODE | REPORT_ERRORS, &filename);
if (f == NULL) RETURN_FALSE;
- im = imlib_load_image_with_error_return(STR_VAL(filename), &im_err);
+ im = imlib_load_image_with_error_return(filename, &im_err);
fclose(f);
- zend_string_release(filename);
+ efree(filename);
if ((im_err) || (!im))
{
@@ -1951,7 +1945,7 @@ PHP_FUNCTION(imlib_load_image)
}
else
{
- IMLIB_REGISTER_RESOURCE(im, le_imlib_img);
+ ZEND_REGISTER_RESOURCE(return_value, im, le_imlib_img);
}
}
/* }}} */
@@ -1961,13 +1955,13 @@ PHP_FUNCTION(imlib_load_image)
Add a point to a given polygon */
PHP_FUNCTION(imlib_polygon_add_point)
{
- imlib_resource polygon;
+ zval *polygon;
long x,y;
ImlibPolygon poly;
if (zend_parse_parameters(3 TSRMLS_CC, "rll", &polygon, &x, &y) == FAILURE) return;
- IMLIB_FETCH_RESOURCE(poly, ImlibPolygon, &polygon, -1, "Imlib Polygon", le_imlib_poly);
+ ZEND_FETCH_RESOURCE(poly, ImlibPolygon, &polygon, -1, "Imlib Polygon", le_imlib_poly);
imlib_polygon_add_point(poly,x,y);
}
@@ -1978,14 +1972,14 @@ PHP_FUNCTION(imlib_polygon_add_point)
Check if a give point is inside a polygon */
PHP_FUNCTION(imlib_polygon_contains_point)
{
- imlib_resource polygon;
+ zval *polygon;
long x,y;
int ret;
ImlibPolygon poly;
if (zend_parse_parameters(3 TSRMLS_CC, "rll", &polygon, &x, &y) == FAILURE) return;
- IMLIB_FETCH_RESOURCE(poly, ImlibPolygon, &polygon, -1, "Imlib Polygon", le_imlib_poly);
+ ZEND_FETCH_RESOURCE(poly, ImlibPolygon, &polygon, -1, "Imlib Polygon", le_imlib_poly);
ret = imlib_polygon_contains_point(poly,x,y);
@@ -2005,13 +1999,13 @@ PHP_FUNCTION(imlib_polygon_contains_point)
Free a polygon */
PHP_FUNCTION(imlib_polygon_free)
{
- imlib_resource polygon;
+ zval *polygon;
ImlibPolygon poly;
if (zend_parse_parameters(1 TSRMLS_CC, "r", &polygon) == FAILURE) return;
- IMLIB_FETCH_RESOURCE(poly, ImlibPolygon, &polygon, -1, "Imlib Polygon", le_imlib_poly);
- IMLIB_DELETE_RESOURCE(&polygon);
+ ZEND_FETCH_RESOURCE(poly, ImlibPolygon, &polygon, -1, "Imlib Polygon", le_imlib_poly);
+ zend_list_delete(Z_LVAL_PP(&polygon));
}
/* }}} */
@@ -2020,14 +2014,14 @@ PHP_FUNCTION(imlib_polygon_free)
Get the bounding coords of a polygon */
PHP_FUNCTION(imlib_polygon_get_bounds)
{
- imlib_resource polygon;
+ zval *polygon;
zval **px1, **py1, **px2, **py2;
int x1,y1,x2,y2;
ImlibPolygon poly;
if (zend_parse_parameters(5 TSRMLS_CC, "rZZZZ", &polygon, &px1, &py1, &px2, &py2) == FAILURE) return;
- IMLIB_FETCH_RESOURCE(poly, ImlibPolygon, &polygon, -1, "Imlib Polygon", le_imlib_poly);
+ ZEND_FETCH_RESOURCE(poly, ImlibPolygon, &polygon, -1, "Imlib Polygon", le_imlib_poly);
zval_dtor(*px1);
zval_dtor(*py1);
@@ -2055,7 +2049,7 @@ PHP_FUNCTION(imlib_polygon_new)
}
poly = imlib_polygon_new();
- if (poly) IMLIB_REGISTER_RESOURCE( poly, le_imlib_poly);
+ if (poly) ZEND_REGISTER_RESOURCE(return_value, poly, le_imlib_poly);
}
/* }}} */
@@ -2064,21 +2058,20 @@ PHP_FUNCTION(imlib_polygon_new)
Save an image to a file, at an optional quality level (1-100) for jpegs. For pngs, the value will be converted to a compression level (0-9) */
PHP_FUNCTION(imlib_save_image)
{
- imlib_resource img;
- zval **err;
+ zval *img, **err;
char* name;
int name_len;
Imlib_Image im;
Imlib_Load_Error im_err;
int argc;
long q;
- zend_string* filename;
+ char* filename;
FILE* f;
argc = ZEND_NUM_ARGS();
if (zend_parse_parameters(argc TSRMLS_CC, "rs|Zl", &img, &name, &name_len, &err, &q) == 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);
@@ -2095,11 +2088,10 @@ PHP_FUNCTION(imlib_save_image)
f = php_stream_open_wrapper_as_file(name, "wb", IGNORE_PATH | ENFORCE_SAFE_MODE | REPORT_ERRORS, &filename);
if (f == NULL) RETURN_FALSE;
- imlib_save_image_with_error_return(STR_VAL(filename), &im_err);
+ imlib_save_image_with_error_return(filename, &im_err);
fclose(f);
-
- zend_string_release(filename);
+ efree(filename);
if (im_err)
{
@@ -2121,7 +2113,7 @@ PHP_FUNCTION(imlib_save_image)
Draw a text string using a font onto an image */
PHP_FUNCTION(imlib_text_draw)
{
- imlib_resource img, font;
+ zval *img, *font;
Imlib_Image im;
PHP_Imlib_Font fn;
char *text;
@@ -2130,8 +2122,8 @@ PHP_FUNCTION(imlib_text_draw)
if (zend_parse_parameters(10 TSRMLS_CC, "rrllslllll", &img, &font, &x, &y, &text, &text_len, &dir, &r, &g, &b, &a) == FAILURE) return;
- IMLIB_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img);
- IMLIB_FETCH_RESOURCE(fn, PHP_Imlib_Font, &font, -1, "Imlib Font", le_imlib_font);
+ ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img);
+ ZEND_FETCH_RESOURCE(fn, PHP_Imlib_Font, &font, -1, "Imlib Font", le_imlib_font);
imlib_context_set_image(im);
imlib_context_set_color(r,g,b,a);
@@ -2166,8 +2158,7 @@ PHP_FUNCTION(imlib_set_cache_size)
Apply external filter to an image */
PHP_FUNCTION(imlib_apply_filter)
{
- imlib_resource img;
- zval *tparams;
+ zval *img, *tparams;
Imlib_Image im;
struct php_imlib_filter* filter;
char* filter_name;
@@ -2175,7 +2166,7 @@ PHP_FUNCTION(imlib_apply_filter)
HashTable* arg_ht;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|a", &img, &filter_name, &filter_name_len, &tparams) == 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);
filter = _php_imlib_find_filter(filter_name TSRMLS_CC);
@@ -2210,7 +2201,7 @@ PHP_FUNCTION(imlib_create_filter)
fil = imlib_create_filter(0);
- if (fil) IMLIB_REGISTER_RESOURCE( fil, le_imlib_filter);
+ if (fil) ZEND_REGISTER_RESOURCE(return_value, fil, le_imlib_filter);
}
/* }}} */
@@ -2219,13 +2210,13 @@ PHP_FUNCTION(imlib_create_filter)
Free a filter */
PHP_FUNCTION(imlib_free_filter)
{
- imlib_resource filter;
+ zval *filter;
Imlib_Filter fil;
if (zend_parse_parameters(1 TSRMLS_CC, "r", &filter) == FAILURE) return;
- IMLIB_FETCH_RESOURCE(fil, Imlib_Filter, &filter, -1, "Imlib Filter", le_imlib_filter);
- IMLIB_DELETE_RESOURCE(&filter);
+ ZEND_FETCH_RESOURCE(fil, Imlib_Filter, &filter, -1, "Imlib Filter", le_imlib_filter);
+ zend_list_delete(Z_LVAL_PP(&filter));
}
/* }}} */
@@ -2233,14 +2224,14 @@ PHP_FUNCTION(imlib_free_filter)
Apply filter to an image */
PHP_FUNCTION(imlib_image_filter)
{
- imlib_resource filter, img;
+ zval *filter, *img;
Imlib_Filter fil;
Imlib_Image im;
if (zend_parse_parameters(2 TSRMLS_CC, "rr", &img, &filter) == FAILURE) return;
- IMLIB_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img);
- IMLIB_FETCH_RESOURCE(fil, Imlib_Filter, &filter, -1, "Imlib Filter", le_imlib_filter);
+ ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img);
+ ZEND_FETCH_RESOURCE(fil, Imlib_Filter, &filter, -1, "Imlib Filter", le_imlib_filter);
imlib_context_set_image(im);
imlib_context_set_filter(fil);
@@ -2250,14 +2241,14 @@ PHP_FUNCTION(imlib_image_filter)
static void _php_imlib_filter_set(INTERNAL_FUNCTION_PARAMETERS, int type)
{
- imlib_resource filter;
+ zval *filter;
int argc;
long xoff,yoff,a,r,g,b;
Imlib_Filter fil;
if (zend_parse_parameters(7 TSRMLS_CC, "rllllll", &filter, &xoff, &yoff, &a, &r, &g, &b) == FAILURE) return;
- IMLIB_FETCH_RESOURCE(fil, Imlib_Filter, &filter, -1, "Imlib Filter", le_imlib_filter);
+ ZEND_FETCH_RESOURCE(fil, Imlib_Filter, &filter, -1, "Imlib Filter", le_imlib_filter);
imlib_context_set_filter(fil);
@@ -2314,13 +2305,13 @@ PHP_FUNCTION(imlib_filter_set_alpha)
Set filter constants */
PHP_FUNCTION(imlib_filter_constants)
{
- imlib_resource filter;
+ zval *filter;
long a, r, g, b;
Imlib_Filter fil;
if (zend_parse_parameters(5 TSRMLS_CC, "rllll", &filter, &a, &r, &g, &b) == FAILURE) return;
- IMLIB_FETCH_RESOURCE(fil, Imlib_Filter, &filter, -1, "Imlib Filter", le_imlib_filter);
+ ZEND_FETCH_RESOURCE(fil, Imlib_Filter, &filter, -1, "Imlib Filter", le_imlib_filter);
imlib_context_set_filter(fil);
imlib_filter_constants(a,r,g,b);
@@ -2331,13 +2322,13 @@ PHP_FUNCTION(imlib_filter_constants)
Set filter divisors */
PHP_FUNCTION(imlib_filter_divisors)
{
- imlib_resource filter;
+ zval *filter;
long a, r, g, b;
Imlib_Filter fil;
if (zend_parse_parameters(5 TSRMLS_CC, "rllll", &filter, &a, &r, &g, &b) == FAILURE) return;
- IMLIB_FETCH_RESOURCE(fil, Imlib_Filter, &filter, -1, "Imlib Filter", le_imlib_filter);
+ ZEND_FETCH_RESOURCE(fil, Imlib_Filter, &filter, -1, "Imlib Filter", le_imlib_filter);
imlib_context_set_filter(fil);
imlib_filter_divisors(a,r,g,b);
@@ -2350,12 +2341,12 @@ PHP_FUNCTION(imlib_filter_divisors)
PHP_FUNCTION(imlib_modify_color_modifier_gamma)
{
double gamma;
- imlib_resource color_modifier;
+ zval *color_modifier;
PHP_Imlib_Color_Modifier cm;
if (zend_parse_parameters(2 TSRMLS_CC, "rd", &color_modifier, &gamma) == FAILURE) return;
- IMLIB_FETCH_RESOURCE(cm, PHP_Imlib_Color_Modifier, &color_modifier, -1, "Imlib Color Modifier", le_imlib_cm);
+ ZEND_FETCH_RESOURCE(cm, PHP_Imlib_Color_Modifier, &color_modifier, -1, "Imlib Color Modifier", le_imlib_cm);
if (cm->modified) _php_imlib_color_modifier_synch(cm);
imlib_context_set_color_modifier(cm->cm);
imlib_modify_color_modifier_gamma(gamma);
@@ -2370,12 +2361,12 @@ PHP_FUNCTION(imlib_modify_color_modifier_gamma)
PHP_FUNCTION(imlib_modify_color_modifier_brightness)
{
double brightness;
- imlib_resource color_modifier;
+ zval *color_modifier;
PHP_Imlib_Color_Modifier cm;
if (zend_parse_parameters(2 TSRMLS_CC, "rd", &color_modifier, &brightness) == FAILURE) return;
- IMLIB_FETCH_RESOURCE(cm, Imlib_Color_Modifier, &color_modifier, -1, "Imlib Color Modifier", le_imlib_cm);
+ ZEND_FETCH_RESOURCE(cm, Imlib_Color_Modifier, &color_modifier, -1, "Imlib Color Modifier", le_imlib_cm);
if (cm->modified) _php_imlib_color_modifier_synch(cm);
imlib_context_set_color_modifier(cm->cm);
imlib_modify_color_modifier_brightness(brightness);
@@ -2390,12 +2381,12 @@ PHP_FUNCTION(imlib_modify_color_modifier_brightness)
PHP_FUNCTION(imlib_modify_color_modifier_contrast)
{
double contrast;
- imlib_resource color_modifier;
+ zval *color_modifier;
PHP_Imlib_Color_Modifier cm;
if (zend_parse_parameters(2 TSRMLS_CC, "rd", &color_modifier, &contrast) == FAILURE) return;
- IMLIB_FETCH_RESOURCE(cm, PHP_Imlib_Color_Modifier, &color_modifier, -1, "Imlib Color Modifier", le_imlib_cm);
+ ZEND_FETCH_RESOURCE(cm, PHP_Imlib_Color_Modifier, &color_modifier, -1, "Imlib Color Modifier", le_imlib_cm);
if (cm->modified) _php_imlib_color_modifier_synch(cm);
imlib_context_set_color_modifier(cm->cm);
imlib_modify_color_modifier_contrast(contrast);
@@ -2409,12 +2400,12 @@ PHP_FUNCTION(imlib_modify_color_modifier_contrast)
Reset color modifier to default (one-to-one) mapping */
PHP_FUNCTION(imlib_reset_color_modifier)
{
- imlib_resource color_modifier;
+ zval *color_modifier;
PHP_Imlib_Color_Modifier cm;
if (zend_parse_parameters(1 TSRMLS_CC, "r", &color_modifier) == FAILURE) return;
- IMLIB_FETCH_RESOURCE(cm, PHP_Imlib_Color_Modifier, &color_modifier, -1, "Imlib Color Modifier", le_imlib_cm);
+ ZEND_FETCH_RESOURCE(cm, PHP_Imlib_Color_Modifier, &color_modifier, -1, "Imlib Color Modifier", le_imlib_cm);
imlib_context_set_color_modifier(cm->cm);
imlib_reset_color_modifier();
imlib_context_set_color_modifier(NULL);
@@ -2427,7 +2418,7 @@ PHP_FUNCTION(imlib_reset_color_modifier)
Apply color modifier to an image or its part */
PHP_FUNCTION(imlib_apply_color_modifier)
{
- imlib_resource color_modifier, image;
+ zval *color_modifier, *image;
long x, y, width, height;
PHP_Imlib_Color_Modifier cm;
Imlib_Image img;
@@ -2436,8 +2427,8 @@ PHP_FUNCTION(imlib_apply_color_modifier)
argc=ZEND_NUM_ARGS();
if (zend_parse_parameters(argc TSRMLS_CC, "rr|llll", &image, &color_modifier, &x, &y, &width, &height) == FAILURE) return;
- IMLIB_FETCH_RESOURCE(cm, PHP_Imlib_Color_Modifier, &color_modifier, -1, "Imlib Color Modifier", le_imlib_cm);
- IMLIB_FETCH_RESOURCE(img, Imlib_Image, &image, -1, "Imlib Image", le_imlib_img);
+ ZEND_FETCH_RESOURCE(cm, PHP_Imlib_Color_Modifier, &color_modifier, -1, "Imlib Color Modifier", le_imlib_cm);
+ ZEND_FETCH_RESOURCE(img, Imlib_Image, &image, -1, "Imlib Image", le_imlib_img);
if (cm->modified) _php_imlib_color_modifier_synch(cm);
imlib_context_set_image(img);
@@ -2456,14 +2447,14 @@ PHP_FUNCTION(imlib_apply_color_modifier)
PHP_FUNCTION(imlib_set_color_modifier)
{
- imlib_resource color_modifier;
+ zval *color_modifier;
long index, value, channels = 15;
PHP_Imlib_Color_Modifier cm;
int argc,i=0;
argc=ZEND_NUM_ARGS();
if (zend_parse_parameters(argc TSRMLS_CC, "rll|l", &color_modifier, &index, &value, &channels) == FAILURE) return;
- IMLIB_FETCH_RESOURCE(cm, PHP_Imlib_Color_Modifier, &color_modifier, -1, "Imlib Color Modifier", le_imlib_cm);
+ ZEND_FETCH_RESOURCE(cm, PHP_Imlib_Color_Modifier, &color_modifier, -1, "Imlib Color Modifier", le_imlib_cm);
if (!cm->valid) _php_imlib_color_modifier_synch(cm);
while (i<4) {
if (channels&1) {
@@ -2482,13 +2473,13 @@ PHP_FUNCTION(imlib_set_color_modifier)
PHP_FUNCTION(imlib_get_color_modifier)
{
- imlib_resource color_modifier;
+ zval *color_modifier;
zval **tred, **tgreen, **tblue, **talpha;
long index;
PHP_Imlib_Color_Modifier cm;
if (zend_parse_parameters(6 TSRMLS_CC, "rlZZZZ", &color_modifier, &index, &tred, &tgreen, &tblue, &talpha) == FAILURE) return;
- IMLIB_FETCH_RESOURCE(cm, PHP_Imlib_Color_Modifier, &color_modifier, -1, "Imlib Color Modifier", le_imlib_cm);
+ ZEND_FETCH_RESOURCE(cm, PHP_Imlib_Color_Modifier, &color_modifier, -1, "Imlib Color Modifier", le_imlib_cm);
if (!cm->valid) _php_imlib_color_modifier_synch(cm);
zval_dtor(*tred);
@@ -2513,7 +2504,7 @@ PHP_FUNCTION(imlib_pstext)
{
#if HAVE_LIBT1
- imlib_resource img, fnt;
+ zval *img, *fnt;
int i, j, argc;
long x, y, sz, r, g, b, a, space = 0, width = 0, aa_steps = 4;
unsigned long color;
@@ -2536,8 +2527,8 @@ PHP_FUNCTION(imlib_pstext)
color=(r<<16)|(g<<8)|b;
- IMLIB_FETCH_RESOURCE(bg_img, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img);
- IMLIB_FETCH_RESOURCE(f_ind, int *, &fnt, -1, "Type 1 font", le_ps_font);
+ ZEND_FETCH_RESOURCE(bg_img, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img);
+ ZEND_FETCH_RESOURCE(f_ind, int *, &fnt, -1, "Type 1 font", le_ps_font);
T1_errno = 0;
T1_AASetBitsPerPixel(32);
@@ -2640,7 +2631,7 @@ PHP_FUNCTION(imlib_psloadfont)
char* file;
int file_len;
int f_ind, *font;
- zend_string* filename;
+ char* filename;
FILE* f;
if (zend_parse_parameters(1 TSRMLS_CC, "s", &file, &file_len) == FAILURE) return;
@@ -2648,10 +2639,10 @@ PHP_FUNCTION(imlib_psloadfont)
f = php_stream_open_wrapper_as_file(file, "rb", IGNORE_PATH | ENFORCE_SAFE_MODE | REPORT_ERRORS, &filename);
if (f == NULL) RETURN_FALSE;
- f_ind = T1_AddFont(STR_VAL(filename));
+ f_ind = T1_AddFont(filename);
fclose(f);
- zend_string_release(filename);
+ efree(filename);
if (f_ind < 0) {
switch (f_ind) {
@@ -2677,7 +2668,7 @@ PHP_FUNCTION(imlib_psloadfont)
}
font = (int *) emalloc(sizeof(int));
*font = f_ind;
- IMLIB_REGISTER_RESOURCE(font, le_ps_font);
+ ZEND_REGISTER_RESOURCE(return_value, font, le_ps_font);
#else
php_error(E_WARNING, "imlib_psloadfont: No T1lib support in this PHP build");
RETURN_FALSE;
@@ -2690,14 +2681,14 @@ PHP_FUNCTION(imlib_psloadfont)
PHP_FUNCTION(imlib_psfreefont)
{
#if HAVE_LIBT1
- imlib_resource fnt;
+ zval *fnt;
int *f_ind;
if (zend_parse_parameters(1 TSRMLS_CC, "r", &fnt) == FAILURE) return;
- IMLIB_FETCH_RESOURCE(f_ind, int *, &fnt, -1, "Type 1 font", le_ps_font);
+ ZEND_FETCH_RESOURCE(f_ind, int *, &fnt, -1, "Type 1 font", le_ps_font);
- IMLIB_DELETE_RESOURCE(&fnt);
+ zend_list_delete(Z_LVAL_PP(&fnt));
RETURN_TRUE;
#else
php_error(E_WARNING, "imlib_psfreefont: No T1lib support in this PHP build");
@@ -2711,25 +2702,25 @@ PHP_FUNCTION(imlib_psfreefont)
PHP_FUNCTION(imlib_psencodefont)
{
#if HAVE_LIBT1
- imlib_resource fnt;
+ zval *fnt;
char *enc;
int enc_len;
char **enc_vector;
int *f_ind;
- zend_string* filename;
+ char* filename;
FILE* f;
if (zend_parse_parameters(2 TSRMLS_CC, "rs", &fnt, &enc, &enc_len) == FAILURE) return;
- IMLIB_FETCH_RESOURCE(f_ind, int *, &fnt, -1, "Type 1 font", le_ps_font);
+ ZEND_FETCH_RESOURCE(f_ind, int *, &fnt, -1, "Type 1 font", le_ps_font);
f = php_stream_open_wrapper_as_file(enc, "rb", IGNORE_PATH | ENFORCE_SAFE_MODE | REPORT_ERRORS, &filename);
if (f == NULL) RETURN_FALSE;
- enc_vector = T1_LoadEncoding(STR_VAL(filename));
+ enc_vector = T1_LoadEncoding(filename);
fclose(f);
- zend_string_release(filename);
+ efree(filename);
if (enc_vector == NULL) {
php_error(E_WARNING, "Couldn't load encoding vector from %s", enc);
@@ -2756,13 +2747,13 @@ PHP_FUNCTION(imlib_psencodefont)
PHP_FUNCTION(imlib_psextendfont)
{
#if HAVE_LIBT1
- imlib_resource fnt;
+ zval *fnt;
double ext;
int *f_ind;
if (zend_parse_parameters(2 TSRMLS_CC, "rd", &fnt, &ext) == FAILURE) return;
- IMLIB_FETCH_RESOURCE(f_ind, int *, &fnt, -1, "Type 1 font", le_ps_font);
+ ZEND_FETCH_RESOURCE(f_ind, int *, &fnt, -1, "Type 1 font", le_ps_font);
if (T1_ExtendFont(*f_ind, ext) != 0) RETURN_FALSE;
@@ -2779,13 +2770,13 @@ PHP_FUNCTION(imlib_psextendfont)
PHP_FUNCTION(imlib_psslantfont)
{
#if HAVE_LIBT1
- imlib_resource fnt;
+ zval *fnt;
double slt;
int *f_ind;
if (zend_parse_parameters(2 TSRMLS_CC, "rd", &fnt, &slt) == FAILURE) return;
- IMLIB_FETCH_RESOURCE(f_ind, int *, &fnt, -1, "Type 1 font", le_ps_font);
+ ZEND_FETCH_RESOURCE(f_ind, int *, &fnt, -1, "Type 1 font", le_ps_font);
if (T1_SlantFont(*f_ind, slt) != 0) RETURN_FALSE;
RETURN_TRUE;
@@ -2801,7 +2792,7 @@ PHP_FUNCTION(imlib_psslantfont)
PHP_FUNCTION(imlib_psbbox)
{
#if HAVE_LIBT1
- imlib_resource fnt;
+ zval *fnt;
char* str;
int str_len;
long sz, space = 0, add_width = 0;
@@ -2819,7 +2810,7 @@ PHP_FUNCTION(imlib_psbbox)
cos_a = cos(angle);
per_char = add_width || angle ? 1 : 0;
- IMLIB_FETCH_RESOURCE(f_ind, int *, &fnt, -1, "Type 1 font", le_ps_font);
+ ZEND_FETCH_RESOURCE(f_ind, int *, &fnt, -1, "Type 1 font", le_ps_font);
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
diff --git a/php_imlib.h b/php_imlib.h
index 7df29c5..5f66094 100644
--- a/php_imlib.h
+++ b/php_imlib.h
@@ -23,7 +23,6 @@
#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"
@@ -155,56 +154,13 @@ typedef struct
} PHP_Imlib_Color_Modifier_struct;
typedef PHP_Imlib_Color_Modifier_struct *PHP_Imlib_Color_Modifier;
-#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);
+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);
struct php_imlib_filter
{
@@ -238,11 +194,14 @@ ZEND_END_MODULE_GLOBALS(imlib)
# define IMLIBG(v) (imlib_globals.v)
#endif
-#else /* HAVE_IMLIB */
+#else
#define phpext_imlib_ptr NULL
-#endif /* HAVE_IMLIB */
+#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 /* _PHP_IMLIB_H */