Port bumpmap filter.

Piotr Pawłow [2016-09-23 03:10:44]
Port bumpmap filter.
Filename
filters/php_bumpmap.c
diff --git a/filters/php_bumpmap.c b/filters/php_bumpmap.c
index 00a1bc7..a3c3a25 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;
+	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_index->val,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=_php_imlib_get_image(data);
 						    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);
+						    sprintf(val,"%d",(int)Z_LVAL_P(data));
+						    script=_php_bumpmap_stradd(script,str_index->val);
 						    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,");");
ViewGit