build and file maintenance
[m6w6/ext-http] / php_http_etag.c
index 40757f799968a000558365347f471810270e26fd..543ce5fcf4078721953e94b8edebb7e12c737972 100644 (file)
@@ -1,6 +1,18 @@
+/*
+    +--------------------------------------------------------------------+
+    | PECL :: http                                                       |
+    +--------------------------------------------------------------------+
+    | Redistribution and use in source and binary forms, with or without |
+    | modification, are permitted provided that the conditions mentioned |
+    | in the accompanying LICENSE file are met.                          |
+    +--------------------------------------------------------------------+
+    | Copyright (c) 2004-2011, Michael Wallner <mike@php.net>            |
+    +--------------------------------------------------------------------+
+*/
+
 #include "php_http.h"
 
-#ifdef PHP_HTTP_HAVE_HASH
+#if PHP_HTTP_HAVE_HASH
 #      include "php_hash.h"
 #endif
 
@@ -13,7 +25,7 @@ PHP_HTTP_API php_http_etag_t *php_http_etag_init(const char *mode TSRMLS_DC)
        void *ctx;
        php_http_etag_t *e;
 
-#ifdef PHP_HTTP_HAVE_HASH
+#if PHP_HTTP_HAVE_HASH
        const php_hash_ops *eho = NULL;
 
        if (mode && (eho = php_hash_fetch_ops(mode, strlen(mode)))) {
@@ -45,10 +57,10 @@ PHP_HTTP_API char *php_http_etag_finish(php_http_etag_t *e)
        unsigned char digest[128] = {0};
        char *etag = NULL;
 
-#ifdef PHP_HTTP_HAVE_HASH
+#if PHP_HTTP_HAVE_HASH
        const php_hash_ops *eho = NULL;
 
-       if (mode && (eho = php_hash_fetch_ops(e->mode, strlen(e->mode)))) {
+       if (e->mode && (eho = php_hash_fetch_ops(e->mode, strlen(e->mode)))) {
                eho->hash_final(digest, e->ctx);
                etag = php_http_etag_digest(digest, eho->digest_size);
        } else
@@ -72,10 +84,10 @@ PHP_HTTP_API char *php_http_etag_finish(php_http_etag_t *e)
 
 PHP_HTTP_API size_t php_http_etag_update(php_http_etag_t *e, const char *data_ptr, size_t data_len)
 {
-#ifdef PHP_HTTP_HAVE_HASH
+#if PHP_HTTP_HAVE_HASH
        const php_hash_ops *eho = NULL;
 
-       if (mode && (eho = php_hash_fetch_ops(e->mode, strlen(e->mode)))) {
+       if (e->mode && (eho = php_hash_fetch_ops(e->mode, strlen(e->mode)))) {
                eho->hash_update(e->ctx, (const unsigned char *) data_ptr, data_len);
        } else
 #endif
@@ -94,3 +106,13 @@ PHP_HTTP_API size_t php_http_etag_update(php_http_etag_t *e, const char *data_pt
        return data_len;
 }
 
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
+