diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-07-19 11:29:27 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-07-19 11:29:27 +0300 |
commit | 651babfefa21536112cbcd799932b3595aeb2da4 (patch) | |
tree | 6922b7ea70642f4ce7a8cb97f01e62115e97d940 /seek.c | |
parent | 3e59cfb01443a14962547ed75bbbaaefa25a7633 (diff) | |
download | runcap-651babfefa21536112cbcd799932b3595aeb2da4.tar.gz runcap-651babfefa21536112cbcd799932b3595aeb2da4.tar.bz2 |
Rename struct filecapture to stream_capture; portability fixes
Diffstat (limited to 'seek.c')
-rw-r--r-- | seek.c | 26 |
1 files changed, 13 insertions, 13 deletions
@@ -20,23 +20,23 @@ #include "runcap.h" int -runcap_seek(struct runcap *rc, int stream, off_t off, int whence) +runcap_seek(struct runcap *rc, int sd, off_t off, int whence) { - struct filecapture *fp; + struct stream_capture *cap; off_t cur; - fp = runcap_filecapture(rc, stream); - if (!fp) + cap = runcap_stream_capture(rc, sd); + if (!cap) return -1; - cur = runcap_tell(rc, stream); + cur = runcap_tell(rc, sd); switch (whence) { case SEEK_CUR: off = cur; break; case SEEK_END: - off = fp->fc_leng + off; + off = cap->sc_leng + off; break; case SEEK_SET: @@ -52,15 +52,15 @@ runcap_seek(struct runcap *rc, int stream, off_t off, int whence) return -1; } - cur -= fp->fc_level; + cur -= cap->sc_level; - if (cur <= off && off <= cur + fp->fc_level) { - fp->fc_cur = off - cur; - } else if (fp->fc_tmpfd != -1) { - if (lseek(fp->fc_tmpfd, off, SEEK_SET) == -1) + if (cur <= off && off <= cur + cap->sc_level) { + cap->sc_cur = off - cur; + } else if (cap->sc_storfd != -1) { + if (lseek(cap->sc_storfd, off, SEEK_SET) == -1) return -1; - fp->fc_level = 0; - fp->fc_cur = 0; + cap->sc_level = 0; + cap->sc_cur = 0; } else { errno = EINVAL; return -1; |