add brotli encoding
[m6w6/ext-http] / src / php_http_etag.h
1 /*
2 +--------------------------------------------------------------------+
3 | PECL :: http |
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 +--------------------------------------------------------------------+
11 */
12
13 #ifndef PHP_HTTP_ETAG_H
14 #define PHP_HTTP_ETAG_H
15
16 typedef struct php_http_etag {
17 void *ctx;
18 char *mode;
19 } php_http_etag_t;
20
21 PHP_HTTP_API php_http_etag_t *php_http_etag_init(const char *mode);
22 PHP_HTTP_API size_t php_http_etag_update(php_http_etag_t *e, const char *data_ptr, size_t data_len);
23 PHP_HTTP_API char *php_http_etag_finish(php_http_etag_t *e);
24
25 static inline char *php_http_etag_digest(const unsigned char *digest, int len)
26 {
27 static const char hexdigits[17] = "0123456789abcdef";
28 int i;
29 char *hex = emalloc(len * 2 + 1);
30 char *ptr = hex;
31
32 for (i = 0; i < len; ++i) {
33 *ptr++ = hexdigits[digest[i] >> 4];
34 *ptr++ = hexdigits[digest[i] & 0xF];
35 }
36 *ptr = '\0';
37
38 return hex;
39 }
40
41 #endif /* PHP_HTTP_ETAG_H */
42
43 /*
44 * Local variables:
45 * tab-width: 4
46 * c-basic-offset: 4
47 * End:
48 * vim600: noet sw=4 ts=4 fdm=marker
49 * vim<600: noet sw=4 ts=4
50 */
51