#include "ext/standard/md5.h"
#include "ext/standard/sha1.h"
+#include "ext/standard/crc32.h"
#include "php_http_std_defs.h"
#include "php_http.h"
extern STATUS _http_cache_global_init(INIT_FUNC_ARGS);
typedef enum {
+ HTTP_ETAG_CRC32 = -3,
HTTP_ETAG_MD5 = -2,
HTTP_ETAG_SHA1 = -1,
} http_etag_mode;
switch (mode)
{
+ case HTTP_ETAG_CRC32:
+ ctx = emalloc(sizeof(unsigned int));
+ memset(ctx, 1, sizeof(unsigned int));
+ break;
+
case HTTP_ETAG_SHA1:
PHP_SHA1Init(ctx = emalloc(sizeof(PHP_SHA1_CTX)));
break;
switch (mode)
{
+ case HTTP_ETAG_CRC32:
+ *((unsigned int *) ctx) = ~*((unsigned int *) ctx);
+ etag = http_etag_digest((const unsigned char *) ctx, sizeof(unsigned int));
+ efree(ctx);
+ break;
+
case HTTP_ETAG_SHA1:
PHP_SHA1Final(digest, ctx);
etag = http_etag_digest(digest, 20);
{
switch (INI_INT("http.etag_mode"))
{
+ case HTTP_ETAG_CRC32:
+ {
+ unsigned int i, c = *((unsigned int *) ctx);
+
+ for (i = 0; i < data_len; ++i) {
+ c = CRC32(c, data_ptr[i]);
+ }
+ *((unsigned int *)ctx) = c;
+ }
+ break;
+
case HTTP_ETAG_SHA1:
PHP_SHA1Update(ctx, (const unsigned char *) data_ptr, data_len);
break;