diff options
author | Daniel Stenberg <daniel@haxx.se> | 2011-02-07 15:00:48 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2011-02-07 15:00:48 +0100 |
commit | 54d9f060b4b0a8fb5fa006813e4db1ca5c1a07e8 (patch) | |
tree | 119331774fece19f0d5b727c1be50184b87298df /lib/file.c | |
parent | 2cacd82661b4a46ea52a23099ce0b23046a1f172 (diff) | |
download | curl-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/file.c')
-rw-r--r-- | lib/file.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/file.c b/lib/file.c index aaeed7075..a627a8129 100644 --- a/lib/file.c +++ b/lib/file.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 @@ -487,14 +487,13 @@ static CURLcode file_do(struct connectdata *conn, bool *done) return result; if(fstated) { - const struct tm *tm; time_t filetime = (time_t)statbuf.st_mtime; -#ifdef HAVE_GMTIME_R struct tm buffer; - tm = (const struct tm *)gmtime_r(&filetime, &buffer); -#else - tm = gmtime(&filetime); -#endif + const struct tm *tm = &buffer; + result = Curl_gmtime(filetime, &buffer); + if(result) + return result; + /* format: "Tue, 15 Nov 1994 12:45:26 GMT" */ snprintf(buf, BUFSIZE-1, "Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n", |