From 73ed69f60daf8415422e365ef94c274dfe720df9 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Fri, 3 Mar 2006 20:44:05 +0000 Subject: [PATCH] - version agnosticism (PECL/HEAD) --- ext/hash/hash.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/ext/hash/hash.c b/ext/hash/hash.c index a03890e3779..040c2fd2b51 100644 --- a/ext/hash/hash.c +++ b/ext/hash/hash.c @@ -471,16 +471,24 @@ PHP_FUNCTION(hash_final) Return a list of registered hashing algorithms */ PHP_FUNCTION(hash_algos) { - HashPosition pos; +#if (PHP_MAJOR_VERSION >= 6) zstr str; +#else + char *str; +#endif int str_len; long idx, type; + HashPosition pos; array_init(return_value); for(zend_hash_internal_pointer_reset_ex(&php_hash_hashtable, &pos); (type = zend_hash_get_current_key_ex(&php_hash_hashtable, &str, &str_len, &idx, 0, &pos)) != HASH_KEY_NON_EXISTANT; zend_hash_move_forward_ex(&php_hash_hashtable, &pos)) { - add_next_index_stringl(return_value, str.s, str_len-1, 1); +#if (PHP_MAJOR_VERSION >= 6) + add_next_index_stringl(return_value, str.s, str_len-1, 1); +#else + add_next_index_stringl(return_value, str, str_len-1, 1); +#endif } } /* }}} */ @@ -579,13 +587,21 @@ PHP_MINFO_FUNCTION(hash) HashPosition pos; char buffer[2048]; char *s = buffer, *e = s + sizeof(buffer); - zstr str; long idx, type; +#if (PHP_MAJOR_VERSION >= 6) + zstr str; +#else + char *str; +#endif for(zend_hash_internal_pointer_reset_ex(&php_hash_hashtable, &pos); (type = zend_hash_get_current_key_ex(&php_hash_hashtable, &str, NULL, &idx, 0, &pos)) != HASH_KEY_NON_EXISTANT; zend_hash_move_forward_ex(&php_hash_hashtable, &pos)) { +#if (PHP_MAJOR_VERSION >= 6) s += snprintf(s, e - s, "%s ", str.s); +#else + s += snprintf(s, e - s, "%s ", str); +#endif } *s = 0;