diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-06-13 21:58:36 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-06-13 21:58:36 -0400 |
commit | 72f775e18416300bd230f5784dc779db6138537b (patch) | |
tree | b372abd590396a719461ac9a4da8872ea30fb46d /src/common | |
parent | 25dddf7a8f30699242b52fce115f29401f63ee9c (diff) | |
parent | 2338681efbdc8070c0cdfd0b9226fcdeb37f0538 (diff) | |
download | tor-72f775e18416300bd230f5784dc779db6138537b.tar.gz tor-72f775e18416300bd230f5784dc779db6138537b.zip |
Merge branch 'bug9047' into maint-0.2.4
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/compat.c | 15 | ||||
-rw-r--r-- | src/common/compat.h | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/common/compat.c b/src/common/compat.c index c97a4545c9..69eb0643d0 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -870,6 +870,9 @@ tor_lockfile_unlock(tor_lockfile_t *lockfile) /** @{ */ /** Some old versions of Unix didn't define constants for these values, * and instead expect you to say 0, 1, or 2. */ +#ifndef SEEK_SET +#define SEEK_SET 0 +#endif #ifndef SEEK_CUR #define SEEK_CUR 1 #endif @@ -900,6 +903,18 @@ tor_fd_seekend(int fd) #endif } +/** Move <b>fd</b> to position <b>pos</b> in the file. Return -1 on error, 0 + * on success. */ +int +tor_fd_setpos(int fd, off_t pos) +{ +#ifdef _WIN32 + return _lseek(fd, pos, SEEK_SET) < 0 ? -1 : 0; +#else + return lseek(fd, pos, SEEK_SET) < 0 ? -1 : 0; +#endif +} + #undef DEBUG_SOCKET_COUNTING #ifdef DEBUG_SOCKET_COUNTING /** A bitarray of all fds that should be passed to tor_socket_close(). Only diff --git a/src/common/compat.h b/src/common/compat.h index f0a34aae41..8ab7190526 100644 --- a/src/common/compat.h +++ b/src/common/compat.h @@ -411,6 +411,7 @@ tor_lockfile_t *tor_lockfile_lock(const char *filename, int blocking, void tor_lockfile_unlock(tor_lockfile_t *lockfile); off_t tor_fd_getpos(int fd); +int tor_fd_setpos(int fd, off_t pos); int tor_fd_seekend(int fd); #ifdef _WIN32 |