diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-04-23 09:13:24 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-04-23 09:13:24 -0400 |
commit | cd3fc2aa4867e89877bbfb99f4f767d761b91f25 (patch) | |
tree | 5ff12068373e17f8218907d153f67b6c8c9fcc26 /src/common | |
parent | 8c01aee2e3b8970af96f5b1a662bdf80d0e22489 (diff) | |
parent | dca36eff8fbe9307aa2f74d26841399537e11406 (diff) | |
download | tor-cd3fc2aa4867e89877bbfb99f4f767d761b91f25.tar.gz tor-cd3fc2aa4867e89877bbfb99f4f767d761b91f25.zip |
Merge remote-tracking branch 'neel/b25511-r4'
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/compat_time.c | 4 | ||||
-rw-r--r-- | src/common/compat_time.h | 2 | ||||
-rw-r--r-- | src/common/util.c | 9 | ||||
-rw-r--r-- | src/common/util.h | 1 |
4 files changed, 13 insertions, 3 deletions
diff --git a/src/common/compat_time.c b/src/common/compat_time.c index b940447b67..966216768f 100644 --- a/src/common/compat_time.c +++ b/src/common/compat_time.c @@ -71,8 +71,8 @@ tor_sleep_msec(int msec) /** Set *timeval to the current time of day. On error, log and terminate. * (Same as gettimeofday(timeval,NULL), but never returns -1.) */ -void -tor_gettimeofday(struct timeval *timeval) +MOCK_IMPL(void, +tor_gettimeofday, (struct timeval *timeval)) { #ifdef _WIN32 /* Epoch bias copied from perl: number of units between windows epoch and diff --git a/src/common/compat_time.h b/src/common/compat_time.h index 75b57f6f24..09dd6add3d 100644 --- a/src/common/compat_time.h +++ b/src/common/compat_time.h @@ -173,7 +173,7 @@ void monotime_coarse_add_msec(monotime_coarse_t *out, #define monotime_coarse_add_msec monotime_add_msec #endif /* defined(MONOTIME_COARSE_TYPE_IS_DIFFERENT) */ -void tor_gettimeofday(struct timeval *timeval); +MOCK_DECL(void, tor_gettimeofday, (struct timeval *timeval)); #ifdef TOR_UNIT_TESTS void tor_sleep_msec(int msec); diff --git a/src/common/util.c b/src/common/util.c index b14b6f3979..53e4507f1f 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -1834,6 +1834,15 @@ format_iso_time(char *buf, time_t t) strftime(buf, ISO_TIME_LEN+1, "%Y-%m-%d %H:%M:%S", tor_gmtime_r(&t, &tm)); } +/** As format_local_iso_time, but use the yyyy-mm-ddThh:mm:ss format to avoid + * embedding an internal space. */ +void +format_local_iso_time_nospace(char *buf, time_t t) +{ + format_local_iso_time(buf, t); + buf[10] = 'T'; +} + /** As format_iso_time, but use the yyyy-mm-ddThh:mm:ss format to avoid * embedding an internal space. */ void diff --git a/src/common/util.h b/src/common/util.h index c0d20e1b22..7172b7da08 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -271,6 +271,7 @@ int parse_rfc1123_time(const char *buf, time_t *t); #define ISO_TIME_USEC_LEN (ISO_TIME_LEN+7) void format_local_iso_time(char *buf, time_t t); void format_iso_time(char *buf, time_t t); +void format_local_iso_time_nospace(char *buf, time_t t); void format_iso_time_nospace(char *buf, time_t t); void format_iso_time_nospace_usec(char *buf, const struct timeval *tv); int parse_iso_time_(const char *cp, time_t *t, int strict, int nospace); |