eb3b5e35b11527f30a84b305c4308b17354c3b7b
2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2004-2014, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
13 #include "php_http_api.h"
15 #include "ext/hash/php_hash.h"
16 #include "ext/standard/crc32.h"
17 #include "ext/standard/sha1.h"
18 #include "ext/standard/md5.h"
20 php_http_etag_t
*php_http_etag_init(const char *mode
)
23 zend_string
*mode_str
= zend_string_init(mode
, strlen(mode
), 0);
24 const php_hash_ops
*eho
= php_hash_fetch_ops(mode_str
);
27 zend_string_release(mode_str
);
30 zend_string_release(mode_str
);
32 e
= emalloc(sizeof(*e
) + eho
->context_size
- 1);
34 eho
->hash_init(e
->ctx
);
39 char *php_http_etag_finish(php_http_etag_t
*e
)
41 unsigned char digest
[128] = {0};
44 e
->ops
->hash_final(digest
, e
->ctx
);
45 etag
= php_http_etag_digest(digest
, e
->ops
->digest_size
);
51 size_t php_http_etag_update(php_http_etag_t
*e
, const char *data_ptr
, size_t data_len
)
53 e
->ops
->hash_update(e
->ctx
, (const unsigned char *) data_ptr
, data_len
);
64 * vim600: noet sw=4 ts=4 fdm=marker
65 * vim<600: noet sw=4 ts=4