diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2014-09-18 18:55:44 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2014-09-18 18:55:44 +0000 |
commit | 3534b428629be185e096be99e3bd5fdfe32d5544 (patch) | |
tree | 210ef3198ed66bc7f7b7bf6a85e4579f455e5a36 /src/libstddjb/siovec_seek.c | |
download | skalibs-3534b428629be185e096be99e3bd5fdfe32d5544.tar.xz |
initial commit with rc for skalibs-2.0.0.0
Diffstat (limited to 'src/libstddjb/siovec_seek.c')
-rw-r--r-- | src/libstddjb/siovec_seek.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/libstddjb/siovec_seek.c b/src/libstddjb/siovec_seek.c new file mode 100644 index 0000000..34a8918 --- /dev/null +++ b/src/libstddjb/siovec_seek.c @@ -0,0 +1,25 @@ +/* ISC license. */ + +#include <skalibs/bytestr.h> +#include <skalibs/siovec.h> + +unsigned int siovec_seek (siovec_t *v, unsigned int n, unsigned int len) +{ + unsigned int w = 0 ; + register unsigned int i = 0 ; + for (; i < n ; i++) + { + if (len < v[i].len) break ; + w += v[i].len ; + len -= v[i].len ; + v[i].s = 0 ; + v[i].len = 0 ; + } + if (i < n) + { + v[i].s += len ; + v[i].len -= len ; + w += len ; + } + return w ; +} |