diff options
author | Roger Dingledine <arma@torproject.org> | 2003-10-20 20:19:59 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2003-10-20 20:19:59 +0000 |
commit | 5f1750a2886a8c5e488fa4ecc8140d07ce5b1186 (patch) | |
tree | a637af519d5884335871832568a49a215bc30c38 /src/common | |
parent | b40d0bffa781b6e212d0ba39c5bf63039762762e (diff) | |
download | tor-5f1750a2886a8c5e488fa4ecc8140d07ce5b1186.tar.gz tor-5f1750a2886a8c5e488fa4ecc8140d07ce5b1186.zip |
include our own timegm() impl, since it's not portable
svn:r635
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/util.c | 20 | ||||
-rw-r--r-- | src/common/util.h | 6 |
2 files changed, 22 insertions, 4 deletions
diff --git a/src/common/util.c b/src/common/util.c index ccc130030e..098b201573 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -112,13 +112,29 @@ void tv_addms(struct timeval *a, long ms) { a->tv_usec %= 1000000; } +time_t tor_timegm (struct tm *tm) { + time_t ret; + char *tz; + + tz = getenv("TZ"); + setenv("TZ", "", 1); + tzset(); + ret = mktime(tm); + if (tz) + setenv("TZ", tz, 1); + else + unsetenv("TZ"); + tzset(); + return ret; +} + /* * Low-level I/O. */ /* a wrapper for write(2) that makes sure to write all count bytes. * Only use if fd is a blocking fd. */ -int write_all(int fd, const void *buf, size_t count) { +int write_all(int fd, const char *buf, size_t count) { int written = 0; int result; @@ -133,7 +149,7 @@ int write_all(int fd, const void *buf, size_t count) { /* a wrapper for read(2) that makes sure to read all count bytes. * Only use if fd is a blocking fd. */ -int read_all(int fd, void *buf, size_t count) { +int read_all(int fd, char *buf, size_t count) { int numread = 0; int result; diff --git a/src/common/util.h b/src/common/util.h index 6358654bff..01087df87d 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -44,8 +44,10 @@ void tv_addms(struct timeval *a, long ms); void tv_add(struct timeval *a, struct timeval *b); int tv_cmp(struct timeval *a, struct timeval *b); -int write_all(int fd, const void *buf, size_t count); -int read_all(int fd, void *buf, size_t count); +time_t tor_timegm (struct tm *tm); + +int write_all(int fd, const char *buf, size_t count); +int read_all(int fd, char *buf, size_t count); void set_socket_nonblocking(int socket); |