aboutsummaryrefslogtreecommitdiff
path: root/src/common/compat.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/compat.c')
-rw-r--r--src/common/compat.c15
1 files changed, 15 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