1 /* 2 * http_date - HTTP date manipulation 3 * 4 * Copyright(c) 2015 Glenn Strauss gstrauss()gluelogic.com All rights reserved 5 * License: BSD 3-clause (same as lighttpd) 6 */ 7 #ifndef INCLUDED_HTTP_DATE_H 8 #define INCLUDED_HTTP_DATE_H 9 #include "first.h" 10 11 #include "sys-time.h" 12 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 19 #define HTTP_DATE_SZ 30 /* (IMF-fixdate is 29 chars + '\0') */ 20 21 uint32_t http_date_time_to_str (char *s, size_t sz, unix_time64_t t); 22 23 int http_date_if_modified_since (const char *ifmod, uint32_t ifmodlen, unix_time64_t lmtime); 24 25 /*(convenience macro to append IMF-fixdate to (buffer *))*/ 26 #define http_date_time_append(b, t) \ 27 do { \ 28 if (!http_date_time_to_str(buffer_extend((b), HTTP_DATE_SZ-1), \ 29 HTTP_DATE_SZ, (t))) \ 30 buffer_truncate((b), (b)->used - HTTP_DATE_SZ); /*(truncate if err)*/ \ 31 } while (0) 32 33 #ifdef __cplusplus 34 } 35 #endif 36 37 38 #endif 39