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 #ifndef PHP_HTTP_ETAG_H
14 #define PHP_HTTP_ETAG_H
16 #include "ext/hash/php_hash.h"
18 typedef struct php_http_etag
{
19 const php_hash_ops
*ops
;
23 PHP_HTTP_API php_http_etag_t
*php_http_etag_init(const char *mode
);
24 PHP_HTTP_API
size_t php_http_etag_update(php_http_etag_t
*e
, const char *data_ptr
, size_t data_len
);
25 PHP_HTTP_API
char *php_http_etag_finish(php_http_etag_t
*e
);
27 static inline char *php_http_etag_digest(const unsigned char *digest
, int len
)
29 static const char hexdigits
[17] = "0123456789abcdef";
31 char *hex
= emalloc(len
* 2 + 1);
34 for (i
= 0; i
< len
; ++i
) {
35 *ptr
++ = hexdigits
[digest
[i
] >> 4];
36 *ptr
++ = hexdigits
[digest
[i
] & 0xF];
43 #endif /* PHP_HTTP_ETAG_H */
50 * vim600: noet sw=4 ts=4 fdm=marker
51 * vim<600: noet sw=4 ts=4