aboutsummaryrefslogtreecommitdiff
path: root/seek.c
diff options
context:
space:
mode:
Diffstat (limited to 'seek.c')
-rw-r--r--seek.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/seek.c b/seek.c
index dfa3d1d..acb42e9 100644
--- a/seek.c
+++ b/seek.c
@@ -19,7 +19,7 @@
#include <errno.h>
#include "runcap.h"
-int
+off_t
runcap_seek(struct runcap *rc, int sd, off_t off, int whence)
{
struct stream_capture *cap;
@@ -32,7 +32,7 @@ runcap_seek(struct runcap *rc, int sd, off_t off, int whence)
cur = runcap_tell(rc, sd);
switch (whence) {
case SEEK_CUR:
- off = cur;
+ off = cur + off;
break;
case SEEK_END:
@@ -52,8 +52,8 @@ runcap_seek(struct runcap *rc, int sd, off_t off, int whence)
return -1;
}
- cur -= cap->sc_level;
-
+ cur -= cap->sc_cur;
+
if (cur <= off && off <= cur + cap->sc_level) {
cap->sc_cur = off - cur;
} else if (cap->sc_storfd != -1) {
@@ -65,7 +65,7 @@ runcap_seek(struct runcap *rc, int sd, off_t off, int whence)
errno = EINVAL;
return -1;
}
- return 0;
+ return off;
}

Return to:

Send suggestions and report system problems to the System administrator.