mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
include our own timegm() impl, since it's not portable
svn:r635
This commit is contained in:
parent
b40d0bffa7
commit
5f1750a288
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -599,7 +599,7 @@ int router_get_dir_from_string_impl(char *s, directory_t **dest,
|
||||
if (!strptime(tok.val.cmd.args[0], "%Y-%m-%d %H:%M:%S", &published)) {
|
||||
log_fn(LOG_WARN, "Published time was unparseable"); goto err;
|
||||
}
|
||||
published_on = timegm(&published);
|
||||
published_on = tor_timegm(&published);
|
||||
|
||||
NEXT_TOK();
|
||||
TOK_IS(K_RECOMMENDED_SOFTWARE, "recommended-software");
|
||||
@ -857,7 +857,7 @@ routerinfo_t *router_get_entry_from_string(char**s) {
|
||||
if (!strptime(ARGS[0], "%Y-%m-%d %H:%M:%S", &published)) {
|
||||
log_fn(LOG_WARN, "Published time was unparseable"); goto err;
|
||||
}
|
||||
router->published_on = timegm(&published);
|
||||
router->published_on = tor_timegm(&published);
|
||||
|
||||
NEXT_TOKEN();
|
||||
if (tok->tp != K_ONION_KEY) {
|
||||
|
Loading…
Reference in New Issue
Block a user