]> granicus.if.org Git - php/commitdiff
- version agnosticism (PECL/HEAD)
authorMichael Wallner <mike@php.net>
Wed, 30 May 2007 07:10:25 +0000 (07:10 +0000)
committerMichael Wallner <mike@php.net>
Wed, 30 May 2007 07:10:25 +0000 (07:10 +0000)
- release 1.4
# you ignorants shall burn in hell

ext/hash/hash.c
ext/hash/package.xml
ext/hash/package2.xml
ext/hash/php_hash.h

index 2b96fc73c5faff00d58b1bf083e2193a86d8d495..d7403215bd2de5b1bed01dee780157bc786a4fa3 100644 (file)
@@ -364,6 +364,7 @@ PHP_FUNCTION(hash_init)
                RETURN_FALSE;
        }
 
+#if PHP_MAJOR_VERSION >= 6
        if (key_type == IS_UNICODE) {
                key = zend_unicode_to_ascii((UChar*)key, key_len TSRMLS_CC);
                if (!key) {
@@ -372,6 +373,7 @@ PHP_FUNCTION(hash_init)
                        RETURN_FALSE;
                }
        }
+#endif
 
        context = emalloc(ops->context_size);
        ops->hash_init(context);
@@ -406,9 +408,11 @@ PHP_FUNCTION(hash_init)
                hash->key = (unsigned char *) K;
        }
 
+#if PHP_MAJOR_VERSION >= 6
        if (key_type == IS_UNICODE) {
                efree(key);
        }
+#endif
 
        ZEND_REGISTER_RESOURCE(return_value, hash, php_hash_le_hash);
 }
@@ -498,7 +502,7 @@ PHP_FUNCTION(hash_update_file)
 {
        zval *zhash, *zcontext = NULL;
        php_hash_data *hash;
-       php_stream_context *context;
+       void *stream_context;
        php_stream *stream;
        char *filename, buf[1024];
        int filename_len, n;
@@ -509,24 +513,29 @@ PHP_FUNCTION(hash_update_file)
                return;
        }
 
-       context = php_stream_context_from_zval(zcontext, 0);
+       stream_context = php_stream_context_from_zval(zcontext, 0);
 
        if (filename_type == IS_UNICODE) {
-               if (php_stream_path_encode(NULL, &filename, &filename_len, (UChar *)filename, filename_len, REPORT_ERRORS, context) == FAILURE) {
+               if (php_stream_path_encode(NULL, &filename, &filename_len, (UChar *)filename, filename_len, REPORT_ERRORS, stream_context) == FAILURE) {
                        RETURN_FALSE;
                }
        }
-#else
+#elif defined(php_stream_context_from_zval)
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|r", &zhash, &filename, &filename_len, &zcontext) == FAILURE) {
                return;
        }
 
-       context = php_stream_context_from_zval(zcontext, 0);
+       stream_context = php_stream_context_from_zval(zcontext, 0);
+#else
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &zhash, &filename, &filename_len) == FAILURE) {
+               return;
+       }
+       stream_context = NULL;
 #endif
 
        ZEND_FETCH_RESOURCE(hash, php_hash_data*, &zhash, -1, PHP_HASH_RESNAME, php_hash_le_hash);
 
-       stream = php_stream_open_wrapper_ex(filename, "rb", REPORT_ERRORS, NULL, context);
+       stream = php_stream_open_wrapper_ex(filename, "rb", REPORT_ERRORS, NULL, stream_context);
        if (filename_type != IS_STRING) {
                /* Original filename was UNICODE, this string is a converted copy */
                efree(filename);
@@ -766,6 +775,7 @@ PHP_MINFO_FUNCTION(hash)
 /* }}} */
 
 /* {{{ arginfo */
+#if PHP_MAJOR_VERSION >= 5
 static
 ZEND_BEGIN_ARG_INFO_EX(arginfo_hash, 0, 0, 2)
        ZEND_ARG_INFO(0, algo)
@@ -833,24 +843,28 @@ static
 ZEND_BEGIN_ARG_INFO(arginfo_hash_algos, 0)
 ZEND_END_ARG_INFO()
 
+#      define PHP_HASH_FE(n) PHP_FE(n,arginfo_##n)
+#else
+#      define PHP_HASH_FE(n) PHP_FE(n,NULL)
+#endif
 /* }}} */
 
 /* {{{ hash_functions[]
  */
 zend_function_entry hash_functions[] = {
-       PHP_FE(hash,                                                                    arginfo_hash)
-       PHP_FE(hash_file,                                                               arginfo_hash_file)
+       PHP_HASH_FE(hash)
+       PHP_HASH_FE(hash_file)
 
-       PHP_FE(hash_hmac,                                                               arginfo_hash_hmac)
-       PHP_FE(hash_hmac_file,                                                  arginfo_hash_hmac_file)
+       PHP_HASH_FE(hash_hmac)
+       PHP_HASH_FE(hash_hmac_file)
 
-       PHP_FE(hash_init,                                                               arginfo_hash_init)
-       PHP_FE(hash_update,                                                             arginfo_hash_update)
-       PHP_FE(hash_update_stream,                                              arginfo_hash_update_stream)
-       PHP_FE(hash_update_file,                                                arginfo_hash_update_file)
-       PHP_FE(hash_final,                                                              arginfo_hash_final)
+       PHP_HASH_FE(hash_init)
+       PHP_HASH_FE(hash_update)
+       PHP_HASH_FE(hash_update_stream)
+       PHP_HASH_FE(hash_update_file)
+       PHP_HASH_FE(hash_final)
 
-       PHP_FE(hash_algos,                                                              arginfo_hash_algos)
+       PHP_HASH_FE(hash_algos)
 
        {NULL, NULL, NULL}
 };
index 6f14e75cabba58a0cdde18ca8f1f6f5c80c56526..988d099c8158334eab9943bbb73115c9d9cc2186 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0">
-<package version="1.0" packagerversion="1.4.6">
+<package version="1.0" packagerversion="1.5.1">
  <name>hash</name>
  <summary>HASH Message Digest Framework</summary>
  <description>Native implementations of common message digest algorithms using a generic factory method
   </maintainer>
   </maintainers>
  <release>
-  <version>1.3</version>
-  <date>2006-04-25</date>
+  <version>1.4</version>
+  <date>2007-05-30</date>
   <license>PHP</license>
   <state>stable</state>
-  <notes>* Fixed PHP bug #37192 - cc may complain about non-constant initializers in hash_adler.c
+  <notes>* Fix builds (PHP 4 only)
+* Added ripemd256, and ripemd320 to supported algorithms
+* Added function reflection information (PHP5+ only)
   </notes>
   <deps>
    <dep type="php" rel="ge" version="4.0.0"/>
index 33c51ef9d4527d93b84f5c00d1fbd881d62b75cf..a09845ef66c6145347c67a51f5e5e49bb5d3b7b8 100644 (file)
@@ -26,9 +26,9 @@
   <email>mike@php.net</email>
   <active>yes</active>
  </lead>
- <date>2006-00-00</date>
+ <date>2007-05-30</date>
  <version>
-  <release>1.3</release>
+  <release>1.4</release>
   <api>1.0</api>
  </version>
  <stability>
@@ -37,7 +37,9 @@
  </stability>
  <license uri="http://www.php.net/license">PHP</license>
  <notes><![CDATA[
-* Fixed PHP bug #37192 - cc may complain about non-constant initializers in hash_adler.c
+* Fix builds (PHP 4 only)
+* Added ripemd256, and ripemd320 to supported algorithms
+* Added function reflection information (PHP5+ only)
 ]]>
  </notes>
  <contents>
index 16d4046af9168162bbb2e9a0594c933c586fd08d..468508882c2eee78a5a49838c891382f0c25aed3 100644 (file)
 #include "php.h"
 #include "php_hash_types.h"
 
+#ifndef slprintf
+#      define slprintf snprintf
+#endif
+
 #define PHP_HASH_EXTNAME       "hash"
 #define PHP_HASH_EXTVER                "1.0"
 #define PHP_HASH_RESNAME       "Hash Context"