From 345bba3ef105969c8f8644818918165db936ccd7 Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Fri, 9 Dec 2016 19:23:22 -0200 Subject: [PATCH] efl_net_dialer_http: fix build on windows. Windows time_t is not a long, but long-long, then stick with int64_t so it works everywhere (converts to time_t internally). And there is no gmtime_r(), then use the gmtime() if not detected. --- configure.ac | 1 + src/lib/ecore_con/efl_net_dialer_http.c | 14 ++++++++++---- src/lib/ecore_con/efl_net_dialer_http.eo | 4 ++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index d81b0c5..06946b2 100644 --- a/configure.ac +++ b/configure.ac @@ -669,6 +669,7 @@ strlcpy \ geteuid \ getuid \ pause \ +gmtime_r \ ]) AC_FUNC_ALLOCA diff --git a/src/lib/ecore_con/efl_net_dialer_http.c b/src/lib/ecore_con/efl_net_dialer_http.c index ffd1e46..341fd1e 100644 --- a/src/lib/ecore_con/efl_net_dialer_http.c +++ b/src/lib/ecore_con/efl_net_dialer_http.c @@ -2347,7 +2347,7 @@ _efl_net_dialer_http_ssl_certificate_revogation_list_get(Eo *o EINA_UNUSED, Efl_ return pd->ssl.crl; } -EOLIAN static long +EOLIAN static int64_t _efl_net_dialer_http_date_parse(Efl_Class *cls EINA_UNUSED, void *cd EINA_UNUSED, const char *str) { EINA_SAFETY_ON_NULL_RETURN_VAL(str, 0); @@ -2355,14 +2355,20 @@ _efl_net_dialer_http_date_parse(Efl_Class *cls EINA_UNUSED, void *cd EINA_UNUSED } EOLIAN static char * -_efl_net_dialer_http_date_serialize(Efl_Class *cls EINA_UNUSED, void *cd EINA_UNUSED, long t) +_efl_net_dialer_http_date_serialize(Efl_Class *cls EINA_UNUSED, void *cd EINA_UNUSED, int64_t ts) { static const char *const wkday[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; static const char * const month[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; char buf[128]; - struct tm *tm, storage; - + time_t t = ts; + struct tm *tm; +#ifdef HAVE_GMTIME_R + struct tm storage; tm = gmtime_r(&t, &storage); +#else + tm = gmtime(&t); +#endif + EINA_SAFETY_ON_NULL_RETURN_VAL(tm, NULL); snprintf(buf, sizeof(buf), diff --git a/src/lib/ecore_con/efl_net_dialer_http.eo b/src/lib/ecore_con/efl_net_dialer_http.eo index 894a765..f7a063b 100644 --- a/src/lib/ecore_con/efl_net_dialer_http.eo +++ b/src/lib/ecore_con/efl_net_dialer_http.eo @@ -372,7 +372,7 @@ class Efl.Net.Dialer.Http (Efl.Loop_User, Efl.Net.Dialer, Efl.Io.Sizer) { params { str: string; [[String in HTTP text format: Tue, 15 Nov 1994 12:45:26 GMT]] } - return: long; [[Seconds since 1/1/1970]] + return: int64; [[Seconds since 1/1/1970]] } date_serialize @class { @@ -381,7 +381,7 @@ class Efl.Net.Dialer.Http (Efl.Loop_User, Efl.Net.Dialer, Efl.Io.Sizer) { The timezone must be GMT (ie: gmtime()). ]] params { - epochtime: long; [[UNIX Epoch time - seconds since 1/1/1970]] + epochtime: int64; [[UNIX Epoch time - seconds since 1/1/1970]] } return: free(own(ptr(char)), free) @warn_unused; [[Newly allocated null-terminated string on success or NULL on errors]] } -- 2.7.4