summaryrefslogtreecommitdiff
path: root/lib/parsedate.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2011-02-07 15:00:48 +0100
committerDaniel Stenberg <daniel@haxx.se>2011-02-07 15:00:48 +0100
commit54d9f060b4b0a8fb5fa006813e4db1ca5c1a07e8 (patch)
tree119331774fece19f0d5b727c1be50184b87298df /lib/parsedate.c
parent2cacd82661b4a46ea52a23099ce0b23046a1f172 (diff)
downloadcurl-54d9f060b4b0a8fb5fa006813e4db1ca5c1a07e8.tar.gz
Curl_gmtime: added a portable gmtime
Instead of polluting many places with #ifdefs, we create a single place for this function, and also check return code properly so that a NULL pointer returned won't cause problems.
Diffstat (limited to 'lib/parsedate.c')
-rw-r--r--lib/parsedate.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/parsedate.c b/lib/parsedate.c
index 3e003db31..ea1f36e73 100644
--- a/lib/parsedate.c
+++ b/lib/parsedate.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -514,3 +514,20 @@ time_t curl_getdate(const char *p, const time_t *now)
/* everything else is fail */
return -1;
}
+
+CURLcode Curl_gmtime(time_t intime, struct tm *store)
+{
+ const struct tm *tm;
+#ifdef HAVE_GMTIME_R
+ /* thread-safe version */
+ tm = (struct tm *)(gmtime_r)(&intime, store);
+#else
+ tm = (gmtime)(&intime);
+ if(tm)
+ *store = *tm; /* copy the pointed struct to the local copy */
+#endif
+
+ if(!tm)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ return CURLE_OK;
+}