From 67e036a6ee5c46ed24c1b2aa2ebcd4115930c814 Mon Sep 17 00:00:00 2001 From: Henrik Blidh Date: Fri, 11 Oct 2024 15:05:43 +0200 Subject: [PATCH] Handling building on Windows --- ngx_http_sticky_misc.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ngx_http_sticky_misc.c b/ngx_http_sticky_misc.c index d1ee110..dd1ae63 100644 --- a/ngx_http_sticky_misc.c +++ b/ngx_http_sticky_misc.c @@ -31,6 +31,17 @@ // /* - bugfix for compiling on sles11 - needs gcc4.6 or later*/ // #pragma GCC diagnostic ignored "-Wuninitialized" +#ifdef _WIN32 +static ngx_int_t cookie_expires(char *str, size_t size, time_t t) +{ + char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; + char *wdays[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; + struct tm e; + gmtime_s(&e, &t); + return snprintf(str, size, "%s, %02d-%s-%04d %02d:%02d:%02d GMT", + wdays[e.tm_wday], e.tm_mday, months[e.tm_mon], e.tm_year + 1900, e.tm_hour, e.tm_min, e.tm_sec); +} +#else static ngx_int_t cookie_expires(char *str, size_t size, time_t t) { char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; @@ -40,7 +51,7 @@ static ngx_int_t cookie_expires(char *str, size_t size, time_t t) return snprintf(str, size, "%s, %02d-%s-%04d %02d:%02d:%02d GMT", wdays[e.tm_wday], e.tm_mday, months[e.tm_mon], e.tm_year + 1900, e.tm_hour,e.tm_min,e.tm_sec); } - +#endif ngx_int_t ngx_http_sticky_misc_set_cookie(ngx_http_request_t *r, ngx_str_t *name, ngx_str_t *value, ngx_str_t *domain, ngx_str_t *path, time_t expires, unsigned secure, unsigned httponly) {