add CURLINFO_RETRY_AFTER
[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 #include "ext/hash/php_hash.h"
17
18 typedef struct php_http_etag {
19 const php_hash_ops *ops;
20 char ctx[1];
21 } php_http_etag_t;
22
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);
26
27 static inline char *php_http_etag_digest(const unsigned char *digest, int len)
28 {
29 static const char hexdigits[17] = "0123456789abcdef";
30 int i;
31 char *hex = emalloc(len * 2 + 1);
32 char *ptr = hex;
33
34 for (i = 0; i < len; ++i) {
35 *ptr++ = hexdigits[digest[i] >> 4];
36 *ptr++ = hexdigits[digest[i] & 0xF];
37 }
38 *ptr = '\0';
39
40 return hex;
41 }
42
43 #endif /* PHP_HTTP_ETAG_H */
44
45 /*
46 * Local variables:
47 * tab-width: 4
48 * c-basic-offset: 4
49 * End:
50 * vim600: noet sw=4 ts=4 fdm=marker
51 * vim<600: noet sw=4 ts=4
52 */
53