branch off v1 as R_1_7
[m6w6/ext-http] / php_http_cache_api.h
index 7ca8998dd1d5453aa4706e1ad7d3647ad4bfcff6..8df20a0cce159931d5adf339c643044937c628f4 100644 (file)
@@ -6,7 +6,7 @@
     | modification, are permitted provided that the conditions mentioned |
     | in the accompanying LICENSE file are met.                          |
     +--------------------------------------------------------------------+
-    | Copyright (c) 2004-2006, Michael Wallner <mike@php.net>            |
+    | Copyright (c) 2004-2010, Michael Wallner <mike@php.net>            |
     +--------------------------------------------------------------------+
 */
 
 #include "ext/standard/crc32.h"
 #include "ext/standard/sha1.h"
 #include "ext/standard/md5.h"
-#if defined(HTTP_HAVE_EXT_HASH)
+
+#ifdef HTTP_HAVE_HASH
 #      include "php_hash.h"
-#elif defined(HTTP_HAVE_HASH_EXT_HASH)
-#      define HTTP_HAVE_EXT_HASH
-#      include "hash/php_hash.h"
-#elif defined(HTTP_HAVE_EXT_HASH_EXT_HASH)
-#      define HTTP_HAVE_EXT_HASH
-#      include "ext/hash/php_hash.h"
 #endif
 
 #define http_etag_digest(d, l) _http_etag_digest((d), (l))
 static inline char *_http_etag_digest(const unsigned char *digest, int len)
 {
-       static const char hexdigits[16] = "0123456789abcdef";
+       static const char hexdigits[17] = "0123456789abcdef";
        int i;
        char *hex = emalloc(len * 2 + 1);
        char *ptr = hex;
@@ -51,10 +46,10 @@ static inline char *_http_etag_digest(const unsigned char *digest, int len)
 static inline void *_http_etag_init(TSRMLS_D)
 {
        void *ctx = NULL;
-       char *mode = HTTP_G(etag).mode;
+       char *mode = HTTP_G->etag.mode;
        
-#ifdef HTTP_HAVE_EXT_HASH
-       php_hash_ops *eho = NULL;
+#ifdef HTTP_HAVE_HASH
+       const php_hash_ops *eho = NULL;
        
        if (mode && (eho = php_hash_fetch_ops(mode, strlen(mode)))) {
                ctx = emalloc(eho->context_size);
@@ -77,10 +72,10 @@ static inline void *_http_etag_init(TSRMLS_D)
 static inline char *_http_etag_finish(void *ctx TSRMLS_DC)
 {
        unsigned char digest[128] = {0};
-       char *etag = NULL, *mode = HTTP_G(etag).mode;
+       char *etag = NULL, *mode = HTTP_G->etag.mode;
        
-#ifdef HTTP_HAVE_EXT_HASH
-       php_hash_ops *eho = NULL;
+#ifdef HTTP_HAVE_HASH
+       const php_hash_ops *eho = NULL;
        
        if (mode && (eho = php_hash_fetch_ops(mode, strlen(mode)))) {
                eho->hash_final(digest, ctx);
@@ -105,9 +100,9 @@ static inline char *_http_etag_finish(void *ctx TSRMLS_DC)
 #define http_etag_update(c, d, l) _http_etag_update((c), (d), (l) TSRMLS_CC)
 static inline void _http_etag_update(void *ctx, const char *data_ptr, size_t data_len TSRMLS_DC)
 {
-       char *mode = HTTP_G(etag).mode;
-#ifdef HTTP_HAVE_EXT_HASH
-       php_hash_ops *eho = NULL;
+       char *mode = HTTP_G->etag.mode;
+#ifdef HTTP_HAVE_HASH
+       const php_hash_ops *eho = NULL;
        
        if (mode && (eho = php_hash_fetch_ops(mode, strlen(mode)))) {
                eho->hash_update(ctx, (const unsigned char *) data_ptr, data_len);
@@ -116,7 +111,7 @@ static inline void _http_etag_update(void *ctx, const char *data_ptr, size_t dat
        if (mode && ((!strcasecmp(mode, "crc32")) || (!strcasecmp(mode, "crc32b")))) {
                uint i, c = *((uint *) ctx);
                for (i = 0; i < data_len; ++i) {
-                       c = CRC32(c, data_ptr[i]);
+                       CRC32(c, data_ptr[i]);
                }
                *((uint *)ctx) = c;
        } else if (mode && (!strcasecmp(mode, "sha1"))) {