diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-02-17 22:30:53 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-02-17 22:30:53 +0000 |
commit | fdffefb8032922ce7ffe4c00816072a8ff2148fc (patch) | |
tree | bc7313151a429c45d8bab8ad8b9dd32f4e51335f /src/libstddjb/netstring_get.c | |
parent | a896ca2a8c617e5e00ffd5fc9e69331ad754e5b3 (diff) | |
download | skalibs-fdffefb8032922ce7ffe4c00816072a8ff2148fc.tar.xz |
More types changes
New disize
Add size_t to the autotypes list
Delete redundant and replace-libc files
dev_t/ino_t pass
Big size_t pass
More things missing, still not operational yet
Diffstat (limited to 'src/libstddjb/netstring_get.c')
-rw-r--r-- | src/libstddjb/netstring_get.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/libstddjb/netstring_get.c b/src/libstddjb/netstring_get.c index c2f8b05..dee6821 100644 --- a/src/libstddjb/netstring_get.c +++ b/src/libstddjb/netstring_get.c @@ -2,7 +2,7 @@ #include <sys/types.h> #include <errno.h> -#include <skalibs/uint64.h> +#include <skalibs/types.h> #include <skalibs/allreadwrite.h> #include <skalibs/bytestr.h> #include <skalibs/buffer.h> @@ -16,20 +16,20 @@ int netstring_okeof (buffer *b, size_t w) return (errno == EPIPE) && !w && buffer_isempty(b) ? (errno = 0, 1) : 0 ; } -ssize_t netstring_get (buffer *b, stralloc *sa, size_t *state) +int netstring_get (buffer *b, stralloc *sa, size_t *state) { if (!*state) { size_t n ; size_t len ; - char buf[UINT64_FMT] ; - if (b->c.a < UINT64_FMT+1) return (errno = EINVAL, -1) ; + char buf[SIZE_FMT] ; + if (b->c.a < SIZE_FMT+1) return (errno = EINVAL, -1) ; for (;;) { - register int r ; - len = buffer_getnofill(b, buf, UINT64_FMT) ; + ssize_t r ; + len = buffer_getnofill(b, buf, SIZE_FMT) ; n = byte_chr(buf, len, ':') ; /* XXX: accepts :, as a valid netstring */ - if (n >= UINT64_FMT) + if (n >= SIZE_FMT) { buffer_unget(b, len) ; return (errno = EPROTO, -1) ; @@ -40,13 +40,13 @@ ssize_t netstring_get (buffer *b, stralloc *sa, size_t *state) if (r <= 0) return r ; } buffer_unget(b, len - n - 1) ; - if (!n || n != uint64_scan(buf, &len)) return (errno = EPROTO, -1) ; + if (!n || n != size_scan(buf, &len)) return (errno = EPROTO, -1) ; if (!stralloc_readyplus(sa, len + 1)) return -1 ; *state = len + 1 ; } { size_t w = 0 ; - register ssize_t r = buffer_getall(b, sa->s + sa->len, *state, &w) ; + int r = buffer_getall(b, sa->s + sa->len, *state, &w) ; sa->len += w ; *state -= w ; if (r <= 0) return r ; |