projects
/
m6w6
/
ext-http
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
|
github
raw
|
patch
|
inline
| side by side (parent:
e7c1206
)
- fix etag generation without libmhash
author
Michael Wallner
<mike@php.net>
Thu, 25 Aug 2005 17:53:34 +0000
(17:53 +0000)
committer
Michael Wallner
<mike@php.net>
Thu, 25 Aug 2005 17:53:34 +0000
(17:53 +0000)
php_http_cache_api.h
patch
|
blob
|
history
diff --git
a/php_http_cache_api.h
b/php_http_cache_api.h
index bef8cc8b97d14cdf94548db85c82868e261e3ddb..be59f5702c82317b8e29103d2a07f9b8de7b168b 100644
(file)
--- a/
php_http_cache_api.h
+++ b/
php_http_cache_api.h
@@
-68,7
+68,7
@@
static inline char *_http_etag_digest(const unsigned char *digest, int len TSRML
#define http_etag_init() _http_etag_init(TSRMLS_C)
static inline void *_http_etag_init(TSRMLS_D)
{
#define http_etag_init() _http_etag_init(TSRMLS_C)
static inline void *_http_etag_init(TSRMLS_D)
{
- void *ctx;
+ void *ctx
= NULL
;
long mode = INI_INT("http.etag_mode");
switch (mode)
long mode = INI_INT("http.etag_mode");
switch (mode)
@@
-78,24
+78,19
@@
static inline void *_http_etag_init(TSRMLS_D)
break;
case HTTP_ETAG_MD5:
break;
case HTTP_ETAG_MD5:
-invalid_flag:
+#ifndef HAVE_LIBMHASH
+ default:
+#endif
PHP_MD5Init(ctx = emalloc(sizeof(PHP_MD5_CTX)));
break;
PHP_MD5Init(ctx = emalloc(sizeof(PHP_MD5_CTX)));
break;
- default:
- {
#ifdef HAVE_LIBMHASH
#ifdef HAVE_LIBMHASH
- if ((mode >= 0) && (mode <= mhash_count())) {
- ctx = mhash_init(mode);
- }
- if ((!ctx) || (ctx == MHASH_FAILED))
-#endif
- {
- HTTP_G(etag).mode = HTTP_ETAG_MD5;
- goto invalid_flag;
+ default:
+ if ((mode < 0) || (mode > mhash_count()) || (!(ctx = mhash_init(mode)))) {
+ http_error_ex(HE_ERROR, HE_RUNTIME, "Invalid ETag mode: %ld", mode);
}
}
- }
break;
break;
+#endif
}
return ctx;
}
return ctx;
@@
-117,20
+112,23
@@
static inline char *_http_etag_finish(void *ctx TSRMLS_DC)
break;
case HTTP_ETAG_MD5:
break;
case HTTP_ETAG_MD5:
+#ifndef HAVE_LIBMHASH
+ default:
+#endif
PHP_MD5Final(digest, ctx);
etag = http_etag_digest(digest, 16);
efree(ctx);
break;
PHP_MD5Final(digest, ctx);
etag = http_etag_digest(digest, 16);
efree(ctx);
break;
+#ifdef HAVE_LIBMHASH
default:
{
default:
{
-#ifdef HAVE_LIBMHASH
unsigned char *mhash_digest = mhash_end_m(ctx, http_etag_alloc_mhash_digest);
etag = http_etag_digest(mhash_digest, mhash_get_block_size(mode));
efree(mhash_digest);
unsigned char *mhash_digest = mhash_end_m(ctx, http_etag_alloc_mhash_digest);
etag = http_etag_digest(mhash_digest, mhash_get_block_size(mode));
efree(mhash_digest);
-#endif
}
break;
}
break;
+#endif
}
return etag;
}
return etag;
@@
-146,14
+144,17
@@
static inline void _http_etag_update(void *ctx, const char *data_ptr, size_t dat
break;
case HTTP_ETAG_MD5:
break;
case HTTP_ETAG_MD5:
+#ifndef HAVE_LIBMHASH
+ default:
+#endif
PHP_MD5Update(ctx, data_ptr, data_len);
break;
PHP_MD5Update(ctx, data_ptr, data_len);
break;
- default:
#ifdef HAVE_LIBMHASH
#ifdef HAVE_LIBMHASH
+ default:
mhash(ctx, data_ptr, data_len);
mhash(ctx, data_ptr, data_len);
-#endif
break;
break;
+#endif
}
}
}
}