From 87380c76cb1eb3644da7291d842281caaae63f2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Paw=C5=82ow?= Date: Thu, 8 Sep 2016 23:05:41 +0200 Subject: Quick and dirty PHP7 port. Using compatibility shims and macros. Compiles both on PHP5 and 7. Done in one afternoon without much testing, so use at your own risk! --- filters/php_bumpmap.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'filters/php_bumpmap.c') diff --git a/filters/php_bumpmap.c b/filters/php_bumpmap.c index 6910f82..24e548d 100644 --- a/filters/php_bumpmap.c +++ b/filters/php_bumpmap.c @@ -44,7 +44,9 @@ _php_bumpmap_exec(char* filter, HashTable* params,int index) int *paramtypes; char *script; Imlib_Image im=NULL; - HashPosition pos; + ulong num_index; + zend_string *str_index; + imlib_zval *data; paramnames=allpnames[index]; paramtypes=allptypes[index]; @@ -52,36 +54,28 @@ _php_bumpmap_exec(char* filter, HashTable* params,int index) script=estrdup(filter); script=_php_bumpmap_stradd(script,"("); - 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) + ZEND_HASH_FOREACH_KEY_VAL(params, num_index, str_index, data) + { + if (str_index) { int match=0; int index=0; while (paramnames[index]) { - if (strcmp(str_index,paramnames[index])==0) + if (strcmp(STR_VAL(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(data); /* Why is cast to Imlib_Image needed? */ + im=(Imlib_Image)_php_imlib_get_image(Z_RES_P(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_index); + script=_php_bumpmap_stradd(script,STR_VAL(str_index)); script=_php_bumpmap_stradd(script,"="); script=_php_bumpmap_stradd(script,val); break; @@ -97,8 +91,7 @@ _php_bumpmap_exec(char* filter, HashTable* params,int index) php_error(E_NOTICE,"Unknown argument %s ignored",str_index); } } - zend_hash_move_forward_ex(params,&pos); - } + } ZEND_HASH_FOREACH_END(); if (script[strlen(script)-1]==',') script[strlen(script)-1]='\0'; script=_php_bumpmap_stradd(script,");"); @@ -121,6 +114,9 @@ php_filter_deinit() return; } +int +_php_bumpmap_getfilterindex(char*); + int php_filter_exec(Imlib_Image im, char *filter, HashTable *params) { -- cgit v1.2.3