Port colormod filter.

Piotr Pawłow [2016-09-23 02:56:03]
Port colormod filter.
Filename
filters/php_colormod.c
diff --git a/filters/php_colormod.c b/filters/php_colormod.c
index c240f1f..b507488 100644
--- a/filters/php_colormod.c
+++ b/filters/php_colormod.c
@@ -32,43 +32,37 @@ _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;
+	zval *data;

-	HashPosition pos;
 	script=estrdup("colormod(");

-	zend_hash_internal_pointer_reset_ex(params,&pos);
-	while (pos)
+	ZEND_HASH_FOREACH_KEY_VAL(params, num_index, str_index, data)
 	{
-		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 (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':
 						    convert_to_long_ex(data);
-						    sprintf(val,"%d",(int)Z_LVAL_PP(data));
-				    		    script=_php_colormod_stradd(script,str_index);
+						    sprintf(val,"%d",(int)Z_LVAL_P(data));
+						    script=_php_colormod_stradd(script,str_index->val);
 						    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_index);
+						    sprintf(val,"%f",(double)Z_DVAL_P(data));
+						    script=_php_colormod_stradd(script,str_index->val);
 						    script=_php_colormod_stradd(script,"=");
 						    script=_php_colormod_stradd(script,val);
 						    break;
@@ -84,8 +78,7 @@ _php_colormod_exec(HashTable* params)
 				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_colormod_stradd(script,");");
ViewGit