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-2011, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
13 #ifndef PHP_HTTP_ETAG_H
14 #define PHP_HTTP_ETAG_H
16 typedef struct php_http_etag
{
25 PHP_HTTP_API php_http_etag_t
*php_http_etag_init(const char *mode TSRMLS_DC
);
26 PHP_HTTP_API
size_t php_http_etag_update(php_http_etag_t
*e
, const char *data_ptr
, size_t data_len
);
27 PHP_HTTP_API
char *php_http_etag_finish(php_http_etag_t
*e
);
29 static inline char *php_http_etag_digest(const unsigned char *digest
, int len
)
31 static const char hexdigits
[17] = "0123456789abcdef";
33 char *hex
= emalloc(len
* 2 + 1);
36 for (i
= 0; i
< len
; ++i
) {
37 *ptr
++ = hexdigits
[digest
[i
] >> 4];
38 *ptr
++ = hexdigits
[digest
[i
] & 0xF];
45 #endif /* PHP_HTTP_ETAG_H */
52 * vim600: noet sw=4 ts=4 fdm=marker
53 * vim<600: noet sw=4 ts=4