diff options
Diffstat (limited to 'src/libunixonacid')
62 files changed, 269 insertions, 245 deletions
diff --git a/src/libunixonacid/atomic_rm_rf_tmp.c b/src/libunixonacid/atomic_rm_rf_tmp.c index 5bba785..b6a8422 100644 --- a/src/libunixonacid/atomic_rm_rf_tmp.c +++ b/src/libunixonacid/atomic_rm_rf_tmp.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <stdio.h> #include <skalibs/stralloc.h> @@ -9,8 +10,8 @@ int atomic_rm_rf_tmp (char const *filename, stralloc *tmp) { - unsigned int tmpbase = tmp->len ; - unsigned int start ; + size_t tmpbase = tmp->len ; + size_t start ; if (!stralloc_cats(tmp, ".skalibs-rmrf-") || !stralloc_cats(tmp, filename)) return -1 ; start = tmp->len ; diff --git a/src/libunixonacid/buffer_timed_fill.c b/src/libunixonacid/buffer_timed_fill.c index c6f580f..fc24bc9 100644 --- a/src/libunixonacid/buffer_timed_fill.c +++ b/src/libunixonacid/buffer_timed_fill.c @@ -1,17 +1,18 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/allreadwrite.h> #include <skalibs/buffer.h> #include <skalibs/functypes.h> #include <skalibs/tai.h> #include <skalibs/unix-timed.h> -static int get (buffer *b) +static ssize_t get (buffer *b) { return sanitize_read(buffer_fill(b)) ; } -int buffer_timed_fill (buffer *b, tain_t const *deadline, tain_t *stamp) +ssize_t buffer_timed_fill (buffer *b, tain_t const *deadline, tain_t *stamp) { - return timed_get(b, (initfunc_t_ref)&buffer_getfd, (initfunc_t_ref)&get, deadline, stamp) ; + return timed_get(b, (initfunc_t_ref)&buffer_getfd, (getfunc_t_ref)&get, deadline, stamp) ; } diff --git a/src/libunixonacid/buffer_timed_get.c b/src/libunixonacid/buffer_timed_get.c index af846ff..4eb1033 100644 --- a/src/libunixonacid/buffer_timed_get.c +++ b/src/libunixonacid/buffer_timed_get.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/buffer.h> #include <skalibs/buffer.h> #include <skalibs/tai.h> @@ -9,8 +10,8 @@ struct blah_s { buffer *b ; char *s ; - unsigned int len ; - unsigned int w ; + size_t len ; + size_t w ; } ; static int getfd (struct blah_s *blah) @@ -18,14 +19,14 @@ static int getfd (struct blah_s *blah) return buffer_fd(blah->b) ; } -static int get (struct blah_s *blah) +static ssize_t get (struct blah_s *blah) { return buffer_getall(blah->b, blah->s, blah->len, &blah->w) ; } -unsigned int buffer_timed_get (buffer *b, char *s, unsigned int len, tain_t const *deadline, tain_t *stamp) +size_t buffer_timed_get (buffer *b, char *s, size_t len, tain_t const *deadline, tain_t *stamp) { struct blah_s blah = { .b = b, .s = s, .len = len, .w = 0 } ; - timed_get(&blah, (initfunc_t_ref)&getfd, (initfunc_t_ref)&get, deadline, stamp) ; + timed_get(&blah, (initfunc_t_ref)&getfd, (getfunc_t_ref)&get, deadline, stamp) ; return blah.w ; } diff --git a/src/libunixonacid/dd_cancel.c b/src/libunixonacid/dd_cancel.c index cbd044e..f17525c 100644 --- a/src/libunixonacid/dd_cancel.c +++ b/src/libunixonacid/dd_cancel.c @@ -8,7 +8,7 @@ void dd_cancel (dirdescriptor_t *dd) { dirdescriptor_t zero = DIRDESCRIPTOR_ZERO ; - register int e = errno ; + int e = errno ; fd_close(dd->fd) ; rm_rf_in_tmp(&dd->new, 0) ; stralloc_free(&dd->new) ; diff --git a/src/libunixonacid/dd_commit.c b/src/libunixonacid/dd_commit.c index f4a7b06..b4d1511 100644 --- a/src/libunixonacid/dd_commit.c +++ b/src/libunixonacid/dd_commit.c @@ -1,17 +1,18 @@ /* ISC license. */ +#include <sys/types.h> #include <unistd.h> #include <errno.h> -#include <stdio.h> /* for rename() */ -#include <skalibs/bytestr.h> +#include <stdio.h> +#include <string.h> #include <skalibs/stralloc.h> #include <skalibs/djbunix.h> #include <skalibs/random.h> #include <skalibs/unix-transactional.h> -static char const *mybasename (char const *s, unsigned int len) +static char const *mybasename (char const *s, size_t len) { - register unsigned int i = len ; + size_t i = len ; while (i--) if (s[i] == '/') return s + i + 1 ; return s ; } @@ -19,15 +20,15 @@ static char const *mybasename (char const *s, unsigned int len) int dd_commit (dirdescriptor_t *dd) { dirdescriptor_t zero = DIRDESCRIPTOR_ZERO ; - unsigned int len = str_len(dd->lnkfn) ; - unsigned int oldbase = dd->new.len ; - unsigned int newlnkbase ; + size_t len = strlen(dd->lnkfn) ; + size_t oldbase = dd->new.len ; + size_t newlnkbase ; char const *lnkbn = mybasename(dd->lnkfn, len) ; if (!sadirname(&dd->new, dd->lnkfn, len)) return 0 ; if (!stralloc_catb(&dd->new, "/", 1)) goto fail ; if (sareadlink(&dd->new, dd->lnkfn) < 0) { - unsigned int lnkbnbase = dd->new.len ; + size_t lnkbnbase = dd->new.len ; if (errno != EINVAL) goto fail ; if (!stralloc_cats(&dd->new, lnkbn)) goto fail ; if (!random_sauniquename(&dd->new, 8)) goto fail ; @@ -36,7 +37,7 @@ int dd_commit (dirdescriptor_t *dd) /* /!\ race condition right here: there's no lnkfn in the fs */ if (symlink(dd->new.s + lnkbnbase, dd->lnkfn) < 0) /* now that's VERY BAD if it fails */ { - register int e = errno ; + int e = errno ; rename(dd->new.s + oldbase, dd->lnkfn) ; /* attempt to revert to initial situation */ errno = e ; goto fail ; /* and hope for the best */ @@ -50,7 +51,7 @@ int dd_commit (dirdescriptor_t *dd) if (symlink(dd->new.s, dd->new.s + newlnkbase) < 0) goto fail ; if (rename(dd->new.s + newlnkbase, dd->lnkfn) < 0) { - register int e = errno ; + int e = errno ; unlink(dd->new.s + newlnkbase) ; errno = e ; goto fail ; diff --git a/src/libunixonacid/dd_commit_devino.c b/src/libunixonacid/dd_commit_devino.c index 7155c7b..364e466 100644 --- a/src/libunixonacid/dd_commit_devino.c +++ b/src/libunixonacid/dd_commit_devino.c @@ -2,15 +2,15 @@ #include <sys/types.h> #include <sys/stat.h> -#include <skalibs/uint64.h> +#include <skalibs/types.h> #include <skalibs/unix-transactional.h> -int dd_commit_devino (dirdescriptor_t *dd, uint64 *dev, uint64 *ino) +int dd_commit_devino (dirdescriptor_t *dd, dev_t *dev, ino_t *ino) { struct stat st ; if (fstat(dd->fd, &st) < 0) return 0 ; if (!dd_commit(dd)) return 0 ; - *dev = (uint64)st.st_dev ; - *ino = (uint64)st.st_ino ; + *dev = st.st_dev ; + *ino = st.st_ino ; return 1 ; } diff --git a/src/libunixonacid/dd_open_write.c b/src/libunixonacid/dd_open_write.c index 90518cb..40d3443 100644 --- a/src/libunixonacid/dd_open_write.c +++ b/src/libunixonacid/dd_open_write.c @@ -20,7 +20,7 @@ int dd_open_write (dirdescriptor_t *dd, char const *lnkfn, unsigned int mode) d.fd = open_read(d.new.s) ; if (d.fd < 0) { - register int e = errno ; + int e = errno ; rmdir(d.new.s) ; errno = e ; goto fail ; diff --git a/src/libunixonacid/ipc_timed_recv.c b/src/libunixonacid/ipc_timed_recv.c index 7093c4d..acf3d48 100644 --- a/src/libunixonacid/ipc_timed_recv.c +++ b/src/libunixonacid/ipc_timed_recv.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/functypes.h> #include <skalibs/tai.h> #include <skalibs/webipc.h> @@ -9,7 +10,7 @@ struct blah_s { int fd ; char *s ; - unsigned int len ; + size_t len ; char *path ; } ; @@ -18,13 +19,13 @@ static int getfd (struct blah_s *blah) return blah->fd ; } -static int get (struct blah_s *blah) +static ssize_t get (struct blah_s *blah) { return sanitize_read(ipc_recv(blah->fd, blah->s, blah->len, blah->path)) ; } -int ipc_timed_recv (int fd, char *s, unsigned int len, char *path, tain_t const *deadline, tain_t *stamp) +ssize_t ipc_timed_recv (int fd, char *s, size_t len, char *path, tain_t const *deadline, tain_t *stamp) { struct blah_s blah = { .fd = fd, .s = s, .len = len, .path = path } ; - return timed_get(&blah, (initfunc_t_ref)&getfd, (initfunc_t_ref)&get, deadline, stamp) ; + return timed_get(&blah, (initfunc_t_ref)&getfd, (getfunc_t_ref)&get, deadline, stamp) ; } diff --git a/src/libunixonacid/ipc_timed_send.c b/src/libunixonacid/ipc_timed_send.c index 2129ec7..959c4bc 100644 --- a/src/libunixonacid/ipc_timed_send.c +++ b/src/libunixonacid/ipc_timed_send.c @@ -1,8 +1,6 @@ /* ISC license. */ - /* For OpenBSD, that still doesn't know what self-contained headers are */ #include <sys/types.h> - #include <sys/socket.h> #include <errno.h> #include <skalibs/error.h> @@ -15,20 +13,20 @@ #define MSG_NOSIGNAL 0 #endif -int ipc_timed_send (int fd, char const *s, unsigned int len, tain_t const *deadline, tain_t *stamp) +int ipc_timed_send (int fd, char const *s, size_t len, tain_t const *deadline, tain_t *stamp) { iopause_fd x = { .fd = fd, .events = IOPAUSE_WRITE, .revents = 0 } ; for (;;) { - register int r = iopause_stamp(&x, 1, deadline, stamp) ; + int r = iopause_stamp(&x, 1, deadline, stamp) ; if (r < 0) return 0 ; else if (!r) return (errno = ETIMEDOUT, 0) ; else if (x.revents & IOPAUSE_WRITE) { - if (send(fd, s, len, MSG_NOSIGNAL) == (int)len) break ; + if (send(fd, s, len, MSG_NOSIGNAL) == (ssize_t)len) break ; if (!error_isagain(errno)) return 0 ; } - else if (x.revents & IOPAUSE_EXCEPT) return (send(fd, s, len, MSG_NOSIGNAL) == (int)len) ; + else if (x.revents & IOPAUSE_EXCEPT) return (send(fd, s, len, MSG_NOSIGNAL) == (ssize_t)len) ; } return 1 ; } diff --git a/src/libunixonacid/kolbak_enqueue.c b/src/libunixonacid/kolbak_enqueue.c index 80fce01..0838e99 100644 --- a/src/libunixonacid/kolbak_enqueue.c +++ b/src/libunixonacid/kolbak_enqueue.c @@ -1,12 +1,13 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/kolbak.h> #include <skalibs/unixmessage.h> int kolbak_enqueue (kolbak_queue_t *q, unixmessage_handler_func_t *f, void *data) { - register unsigned int newtail = (q->tail + 1) % q->n ; + size_t newtail = (q->tail + 1) % q->n ; if (newtail == q->head) return (errno = ENOBUFS, 0) ; q->x[q->tail].f = f ; q->x[q->tail].data = data ; diff --git a/src/libunixonacid/kolbak_queue_init.c b/src/libunixonacid/kolbak_queue_init.c index 6d91232..d2f11da 100644 --- a/src/libunixonacid/kolbak_queue_init.c +++ b/src/libunixonacid/kolbak_queue_init.c @@ -1,9 +1,10 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/kolbak.h> -int kolbak_queue_init (kolbak_queue_t *q, kolbak_closure_t *s, unsigned int len) +int kolbak_queue_init (kolbak_queue_t *q, kolbak_closure_t *s, size_t len) { if (len < 2) return (errno = EINVAL, 0) ; q->x = s ; diff --git a/src/libunixonacid/mkdir_unique.c b/src/libunixonacid/mkdir_unique.c index 1eee4c6..83e240e 100644 --- a/src/libunixonacid/mkdir_unique.c +++ b/src/libunixonacid/mkdir_unique.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <sys/stat.h> #include <skalibs/stralloc.h> #include <skalibs/random.h> @@ -7,7 +8,7 @@ int mkdir_unique (stralloc *sa, char const *fn, unsigned int mode) { - unsigned int base = sa->len ; + size_t base = sa->len ; int wasnull = !sa->s ; if (!stralloc_cats(sa, fn)) return 0 ; if (!stralloc_cats(sa, "/mkdir_unique:")) goto fail ; diff --git a/src/libunixonacid/netstring_timed_get.c b/src/libunixonacid/netstring_timed_get.c index 04ace6c..c8c954d 100644 --- a/src/libunixonacid/netstring_timed_get.c +++ b/src/libunixonacid/netstring_timed_get.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/buffer.h> #include <skalibs/stralloc.h> @@ -11,10 +12,10 @@ int netstring_timed_get (buffer *b, stralloc *sa, tain_t const *deadline, tain_t *stamp) { iopause_fd x = { .fd = buffer_fd(b), .events = IOPAUSE_READ } ; - unsigned int w = 0 ; + size_t w = 0 ; for (;;) { - register int r = netstring_get(b, sa, &w) ; + int r = netstring_get(b, sa, &w) ; if (r > 0) return r ; if (r < 0) return 0 ; r = iopause_stamp(&x, 1, deadline, stamp) ; diff --git a/src/libunixonacid/open2_at.c b/src/libunixonacid/open2_at.c index 4deb837..625ec20 100644 --- a/src/libunixonacid/open2_at.c +++ b/src/libunixonacid/open2_at.c @@ -33,7 +33,7 @@ int open2_at (int dirfd, char const *file, int flags) if (fdhere < 0) return -1 ; if (fd_chdir(dirfd) < 0) { - register int e = errno ; + int e = errno ; fd_close(fdhere) ; errno = e ; return -1 ; @@ -41,7 +41,7 @@ int open2_at (int dirfd, char const *file, int flags) fd = open2(file, flags) ; if (fd < 0) { - register int e = errno ; + int e = errno ; fd_chdir(fdhere) ; fd_close(fdhere) ; errno = e ; @@ -49,7 +49,7 @@ int open2_at (int dirfd, char const *file, int flags) } if (fd_chdir(fdhere) < 0) { - register int e = errno ; + int e = errno ; fd_close(fdhere) ; errno = e ; return -1 ; diff --git a/src/libunixonacid/open3_at.c b/src/libunixonacid/open3_at.c index d9c7222..f92fa59 100644 --- a/src/libunixonacid/open3_at.c +++ b/src/libunixonacid/open3_at.c @@ -33,7 +33,7 @@ int open3_at (int dirfd, char const *file, int flags, unsigned int mode) if (fdhere < 0) return -1 ; if (fd_chdir(dirfd) < 0) { - register int e = errno ; + int e = errno ; fd_close(fdhere) ; errno = e ; return -1 ; @@ -41,7 +41,7 @@ int open3_at (int dirfd, char const *file, int flags, unsigned int mode) fd = open3(file, flags, mode) ; if (fd < 0) { - register int e = errno ; + int e = errno ; fd_chdir(fdhere) ; fd_close(fdhere) ; errno = e ; @@ -49,7 +49,7 @@ int open3_at (int dirfd, char const *file, int flags, unsigned int mode) } if (fd_chdir(fdhere) < 0) { - register int e = errno ; + int e = errno ; fd_close(fdhere) ; errno = e ; return -1 ; diff --git a/src/libunixonacid/opengetlnclose.c b/src/libunixonacid/opengetlnclose.c index 90940af..2615c6b 100644 --- a/src/libunixonacid/opengetlnclose.c +++ b/src/libunixonacid/opengetlnclose.c @@ -12,8 +12,8 @@ int opengetlnclose (char const *fn, stralloc *sa, int sep) { char buf[BUFFER_INSIZE] ; buffer b ; - register int r ; - register int e ; + int r ; + int e ; int fd = open_readb(fn) ; if (fd < 0) return -1 ; buffer_init(&b, &fd_readv, fd, buf, BUFFER_INSIZE) ; diff --git a/src/libunixonacid/opengetlnclose_at.c b/src/libunixonacid/opengetlnclose_at.c index e91acbf..7d2bee3 100644 --- a/src/libunixonacid/opengetlnclose_at.c +++ b/src/libunixonacid/opengetlnclose_at.c @@ -12,8 +12,8 @@ int opengetlnclose_at (int dirfd, char const *fn, stralloc *sa, int sep) { char buf[BUFFER_INSIZE] ; buffer b ; - register int r ; - register int e ; + int r ; + int e ; int fd = open_readatb(dirfd, fn) ; if (fd < 0) return -1 ; buffer_init(&b, &fd_readv, fd, buf, BUFFER_INSIZE) ; diff --git a/src/libunixonacid/openreadnclose_at.c b/src/libunixonacid/openreadnclose_at.c index 4e8209d..fb58935 100644 --- a/src/libunixonacid/openreadnclose_at.c +++ b/src/libunixonacid/openreadnclose_at.c @@ -1,14 +1,15 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/allreadwrite.h> #include <skalibs/djbunix.h> #include <skalibs/unix-transactional.h> -unsigned int openreadnclose_at (int dirfd, char const *file, char *s, unsigned int n) +size_t openreadnclose_at (int dirfd, char const *file, char *s, size_t n) { - register unsigned int r ; - register int e ; + size_t r ; + int e ; int fd = open_readatb(dirfd, file) ; if (fd < 0) return 0 ; r = allread(fd, s, n) ; diff --git a/src/libunixonacid/openslurpclose_at.c b/src/libunixonacid/openslurpclose_at.c index cf2f8ee..24a2d1c 100644 --- a/src/libunixonacid/openslurpclose_at.c +++ b/src/libunixonacid/openslurpclose_at.c @@ -11,7 +11,7 @@ int openslurpclose_at (int dirfd, char const *fn, stralloc *sa) if (fd < 0) return 0 ; if (!slurp(sa, fd)) { - register int e = errno ; + int e = errno ; fd_close(fd) ; errno = e ; return 0 ; diff --git a/src/libunixonacid/openwritenclose.c b/src/libunixonacid/openwritenclose.c index 09149e2..2c5ffb7 100644 --- a/src/libunixonacid/openwritenclose.c +++ b/src/libunixonacid/openwritenclose.c @@ -2,10 +2,11 @@ /* MT-unsafe */ +#include <sys/types.h> #include <skalibs/skamisc.h> #include <skalibs/unix-transactional.h> -int openwritenclose (char const *fn, char const *s, unsigned int len) +int openwritenclose (char const *fn, char const *s, size_t len) { return openwritenclose_tmp(fn, s, len, &satmp) ; } diff --git a/src/libunixonacid/openwritenclose_at.c b/src/libunixonacid/openwritenclose_at.c index fe92a5e..3fea94c 100644 --- a/src/libunixonacid/openwritenclose_at.c +++ b/src/libunixonacid/openwritenclose_at.c @@ -6,15 +6,15 @@ #include <skalibs/djbunix.h> #include <skalibs/unix-transactional.h> -unsigned int openwritenclose_at (int dirfd, char const *file, char const *s, unsigned int n) +size_t openwritenclose_at (int dirfd, char const *file, char const *s, size_t n) { - register unsigned int r ; + size_t r ; int fd = open_truncatb(dirfd, file) ; if (fd < 0) return 0 ; r = allwrite(fd, s, n) ; if ((r < n) || (fsync(fd) < 0)) { - register int e = errno ; + int e = errno ; fd_close(fd) ; errno = e ; return r ; diff --git a/src/libunixonacid/openwritenclose_devino.c b/src/libunixonacid/openwritenclose_devino.c index 5edc646..28e686e 100644 --- a/src/libunixonacid/openwritenclose_devino.c +++ b/src/libunixonacid/openwritenclose_devino.c @@ -2,11 +2,12 @@ /* MT-unsafe */ -#include <skalibs/uint64.h> +#include <sys/types.h> +#include <skalibs/types.h> #include <skalibs/skamisc.h> #include <skalibs/unix-transactional.h> -int openwritenclose_devino (char const *fn, char const *s, unsigned int len, uint64 *dev, uint64 *ino) +int openwritenclose_devino (char const *fn, char const *s, size_t len, dev_t *dev, ino_t *ino) { return openwritenclose_devino_tmp(fn, s, len, dev, ino, &satmp) ; } diff --git a/src/libunixonacid/openwritenclose_devino_tmp.c b/src/libunixonacid/openwritenclose_devino_tmp.c index 0fe032c..49eec93 100644 --- a/src/libunixonacid/openwritenclose_devino_tmp.c +++ b/src/libunixonacid/openwritenclose_devino_tmp.c @@ -1,25 +1,27 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <unistd.h> -#include <stdio.h> /* for rename() */ -#include <skalibs/uint64.h> +#include <stdio.h> +#include <skalibs/types.h> #include <skalibs/stralloc.h> #include <skalibs/djbunix.h> #include <skalibs/random.h> #include <skalibs/unix-transactional.h> -int openwritenclose_devino_tmp (char const *fn, char const *s, unsigned int len, uint64 *dev, uint64 *ino, stralloc *tmp) +int openwritenclose_devino_tmp (char const *fn, char const *s, size_t len, dev_t *dev, ino_t *ino, stralloc *tmp) { - uint64 tmpdev, tmpino ; - unsigned int base = tmp->len ; + dev_t tmpdev ; + ino_t tmpino ; + size_t base = tmp->len ; if (!stralloc_cats(tmp, fn)) return 0 ; if (!random_sauniquename(tmp, 8)) goto fail ; if (!stralloc_0(tmp)) goto fail ; if (!openwritenclose_unsafe_devino_sync(tmp->s + base, s, len, &tmpdev, &tmpino)) goto fail ; if (rename(tmp->s + base, fn) < 0) { - register int e = errno ; + int e = errno ; unlink(tmp->s + base) ; errno = e ; goto fail ; diff --git a/src/libunixonacid/openwritenclose_tmp.c b/src/libunixonacid/openwritenclose_tmp.c index 1ada80b..5b3fe15 100644 --- a/src/libunixonacid/openwritenclose_tmp.c +++ b/src/libunixonacid/openwritenclose_tmp.c @@ -1,11 +1,13 @@ /* ISC license. */ -#include <skalibs/uint64.h> +#include <sys/types.h> +#include <skalibs/types.h> #include <skalibs/stralloc.h> #include <skalibs/unix-transactional.h> -int openwritenclose_tmp (char const *fn, char const *s, unsigned int len, stralloc *tmp) +int openwritenclose_tmp (char const *fn, char const *s, size_t len, stralloc *tmp) { - uint64 dev, ino ; + dev_t dev ; + ino_t ino ; return openwritenclose_devino_tmp(fn, s, len, &dev, &ino, tmp) ; } diff --git a/src/libunixonacid/openwritevnclose_at.c b/src/libunixonacid/openwritevnclose_at.c index 7cff485..518187a 100644 --- a/src/libunixonacid/openwritevnclose_at.c +++ b/src/libunixonacid/openwritevnclose_at.c @@ -1,5 +1,7 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> #include <unistd.h> #include <errno.h> #include <skalibs/allreadwrite.h> @@ -7,15 +9,15 @@ #include <skalibs/djbunix.h> #include <skalibs/unix-transactional.h> -unsigned int openwritevnclose_at (int dirfd, char const *file, siovec_t const *v, unsigned int n) +size_t openwritevnclose_at (int dirfd, char const *file, struct iovec const *v, unsigned int n) { - register unsigned int r ; + size_t r ; int fd = open_truncatb(dirfd, file) ; if (fd < 0) return 0 ; r = allwritev(fd, v, n) ; if (r < siovec_len(v, n) || fsync(fd) < 0) { - register int e = errno ; + int e = errno ; fd_close(fd) ; errno = e ; return r ; diff --git a/src/libunixonacid/skaclient-internal.h b/src/libunixonacid/skaclient-internal.h index 3c73d1f..b26152b 100644 --- a/src/libunixonacid/skaclient-internal.h +++ b/src/libunixonacid/skaclient-internal.h @@ -3,11 +3,12 @@ #ifndef SKACLIENT_INTERNAL_H #define SKACLIENT_INTERNAL_H +#include <sys/types.h> #include <skalibs/kolbak.h> #include <skalibs/unixmessage.h> #include <skalibs/skaclient.h> -extern int skaclient_init (skaclient_t *, int, char *, unsigned int, char *, unsigned int, char *, unsigned int, char *, unsigned int, kolbak_closure_t *, unsigned int, char const *, unsigned int) ; +extern int skaclient_init (skaclient_t *, int, char *, size_t, char *, size_t, char *, size_t, char *, size_t, kolbak_closure_t *, size_t, char const *, size_t) ; extern int skaclient_start_cb (unixmessage_t const *, skaclient_cbdata_t *) ; #endif diff --git a/src/libunixonacid/skaclient_init.c b/src/libunixonacid/skaclient_init.c index 89ed59c..0ab4137 100644 --- a/src/libunixonacid/skaclient_init.c +++ b/src/libunixonacid/skaclient_init.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/kolbak.h> #include <skalibs/skaclient.h> #include <skalibs/unixmessage.h> @@ -9,17 +10,17 @@ int skaclient_init ( skaclient_t *a, int fd, char *bufss, - unsigned int bufsn, + size_t bufsn, char *auxbufss, - unsigned int auxbufsn, + size_t auxbufsn, char *bufas, - unsigned int bufan, + size_t bufan, char *auxbufas, - unsigned int auxbufan, + size_t auxbufan, kolbak_closure_t *q, - unsigned int qlen, + size_t qlen, char const *before, - unsigned int beforelen) + size_t beforelen) { unixmessage_t msg = { .s = (char *)before, .len = beforelen, .fds = 0, .nfds = 0 } ; if (!unixmessage_receiver_init(&a->syncin, fd, bufss, bufsn, auxbufss, auxbufsn) diff --git a/src/libunixonacid/skaclient_put.c b/src/libunixonacid/skaclient_put.c index 5e3dc92..d15c0ec 100644 --- a/src/libunixonacid/skaclient_put.c +++ b/src/libunixonacid/skaclient_put.c @@ -1,9 +1,10 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/skaclient.h> #include <skalibs/unixmessage.h> -int skaclient_put (skaclient_t *a, char const *s, unsigned int len, unixmessage_handler_func_t *cb, void *result) +int skaclient_put (skaclient_t *a, char const *s, size_t len, unixmessage_handler_func_t *cb, void *result) { unixmessage_t m = { .s = (char *)s, .len = len, .fds = 0, .nfds = 0 } ; return skaclient_putmsg(a, &m, cb, result) ; diff --git a/src/libunixonacid/skaclient_putmsg.c b/src/libunixonacid/skaclient_putmsg.c index 9dcb37d..d1cb68e 100644 --- a/src/libunixonacid/skaclient_putmsg.c +++ b/src/libunixonacid/skaclient_putmsg.c @@ -4,7 +4,7 @@ #include <skalibs/skaclient.h> #include <skalibs/unixmessage.h> -int skaclient_putmsg_and_close (skaclient_t *a, unixmessage_t const *m, unsigned char const *bits, unixmessage_handler_func_t *cb, void *result) +int skaclient_putmsg_and_close (skaclient_t *a, unixmessage_t const *m, unsigned char const *bits, unixmessage_handler_func_t_ref cb, void *result) { if (!kolbak_enqueue(&a->kq, cb, result)) return 0 ; if (!unixmessage_put_and_close(&a->syncout, m, bits)) diff --git a/src/libunixonacid/skaclient_putmsgv.c b/src/libunixonacid/skaclient_putmsgv.c index e53935a..fb0b866 100644 --- a/src/libunixonacid/skaclient_putmsgv.c +++ b/src/libunixonacid/skaclient_putmsgv.c @@ -4,7 +4,7 @@ #include <skalibs/skaclient.h> #include <skalibs/unixmessage.h> -int skaclient_putmsgv_and_close (skaclient_t *a, unixmessage_v_t const *m, unsigned char const *bits, unixmessage_handler_func_t *cb, void *result) +int skaclient_putmsgv_and_close (skaclient_t *a, unixmessage_v_t const *m, unsigned char const *bits, unixmessage_handler_func_t_ref cb, void *result) { if (!kolbak_enqueue(&a->kq, cb, result)) return 0 ; if (!unixmessage_putv_and_close(&a->syncout, m, bits)) diff --git a/src/libunixonacid/skaclient_putv.c b/src/libunixonacid/skaclient_putv.c index c41b092..8a5276e 100644 --- a/src/libunixonacid/skaclient_putv.c +++ b/src/libunixonacid/skaclient_putv.c @@ -1,11 +1,11 @@ /* ISC license. */ -#include <skalibs/siovec.h> +#include <sys/uio.h> #include <skalibs/skaclient.h> #include <skalibs/unixmessage.h> -int skaclient_putv (skaclient_t *a, siovec_t const *v, unsigned int vlen, unixmessage_handler_func_t *cb, void *result) +int skaclient_putv (skaclient_t *a, struct iovec const *v, unsigned int vlen, unixmessage_handler_func_t *cb, void *result) { - unixmessage_v_t m = { .v = (siovec_t *)v, .vlen = vlen, .fds = 0, .nfds = 0 } ; + unixmessage_v_t m = { .v = (struct iovec *)v, .vlen = vlen, .fds = 0, .nfds = 0 } ; return skaclient_putmsgv(a, &m, cb, result) ; } diff --git a/src/libunixonacid/skaclient_send.c b/src/libunixonacid/skaclient_send.c index 38dcddb..2e63c34 100644 --- a/src/libunixonacid/skaclient_send.c +++ b/src/libunixonacid/skaclient_send.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/tai.h> #include <skalibs/unixmessage.h> #include <skalibs/skaclient.h> -int skaclient_send (skaclient_t *a, char const *s, unsigned int len, unixmessage_handler_func_t *cb, void *result, tain_t const *deadline, tain_t *stamp) +int skaclient_send (skaclient_t *a, char const *s, size_t len, unixmessage_handler_func_t *cb, void *result, tain_t const *deadline, tain_t *stamp) { unixmessage_t m = { .s = (char *)s, .len = len, .fds = 0, .nfds = 0 } ; return skaclient_sendmsg(a, &m, cb, result, deadline, stamp) ; diff --git a/src/libunixonacid/skaclient_sendmsg.c b/src/libunixonacid/skaclient_sendmsg.c index 49cfbea..371e84a 100644 --- a/src/libunixonacid/skaclient_sendmsg.c +++ b/src/libunixonacid/skaclient_sendmsg.c @@ -4,7 +4,7 @@ #include <skalibs/unixmessage.h> #include <skalibs/skaclient.h> -int skaclient_sendmsg_and_close (skaclient_t *a, unixmessage_t const *m, unsigned char const *bits, unixmessage_handler_func_t *cb, void *result, tain_t const *deadline, tain_t *stamp) +int skaclient_sendmsg_and_close (skaclient_t *a, unixmessage_t const *m, unsigned char const *bits, unixmessage_handler_func_t_ref cb, void *result, tain_t const *deadline, tain_t *stamp) { return skaclient_putmsg_and_close(a, m, bits, cb, result) && skaclient_syncify(a, deadline, stamp) ; diff --git a/src/libunixonacid/skaclient_sendmsgv.c b/src/libunixonacid/skaclient_sendmsgv.c index 6584173..91467a2 100644 --- a/src/libunixonacid/skaclient_sendmsgv.c +++ b/src/libunixonacid/skaclient_sendmsgv.c @@ -4,7 +4,7 @@ #include <skalibs/unixmessage.h> #include <skalibs/skaclient.h> -int skaclient_sendmsgv_and_close (skaclient_t *a, unixmessage_v_t const *m, unsigned char const *bits, unixmessage_handler_func_t *cb, void *result, tain_t const *deadline, tain_t *stamp) +int skaclient_sendmsgv_and_close (skaclient_t *a, unixmessage_v_t const *m, unsigned char const *bits, unixmessage_handler_func_t_ref cb, void *result, tain_t const *deadline, tain_t *stamp) { return skaclient_putmsgv_and_close(a, m, bits, cb, result) && skaclient_syncify(a, deadline, stamp) ; diff --git a/src/libunixonacid/skaclient_sendv.c b/src/libunixonacid/skaclient_sendv.c index a140768..224a38a 100644 --- a/src/libunixonacid/skaclient_sendv.c +++ b/src/libunixonacid/skaclient_sendv.c @@ -1,12 +1,12 @@ /* ISC license. */ -#include <skalibs/siovec.h> +#include <sys/uio.h> #include <skalibs/skaclient.h> #include <skalibs/tai.h> #include <skalibs/unixmessage.h> -int skaclient_sendv (skaclient_t *a, siovec_t const *v, unsigned int vlen, unixmessage_handler_func_t *cb, void *result, tain_t const *deadline, tain_t *stamp) +int skaclient_sendv (skaclient_t *a, struct iovec const *v, unsigned int vlen, unixmessage_handler_func_t *cb, void *result, tain_t const *deadline, tain_t *stamp) { - unixmessage_v_t m = { .v = (siovec_t *)v, .vlen = vlen, .fds = 0, .nfds = 0 } ; + unixmessage_v_t m = { .v = (struct iovec *)v, .vlen = vlen, .fds = 0, .nfds = 0 } ; return skaclient_sendmsgv(a, &m, cb, result, deadline, stamp) ; } diff --git a/src/libunixonacid/skaclient_server_ack.c b/src/libunixonacid/skaclient_server_ack.c index 31ee9fe..6b59563 100644 --- a/src/libunixonacid/skaclient_server_ack.c +++ b/src/libunixonacid/skaclient_server_ack.c @@ -1,21 +1,22 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> -#include <skalibs/bytestr.h> +#include <string.h> #include <skalibs/djbunix.h> #include <skalibs/error.h> #include <skalibs/skaclient.h> #include <skalibs/unixmessage.h> #include <skalibs/webipc.h> -int skaclient_server_ack (unixmessage_t const *clientmsg, unixmessage_sender_t *out, unixmessage_sender_t *asyncout, char const *before, unsigned int beforelen, char const *after, unsigned int afterlen) +int skaclient_server_ack (unixmessage_t const *clientmsg, unixmessage_sender_t *out, unixmessage_sender_t *asyncout, char const *before, size_t beforelen, char const *after, size_t afterlen) { int fd[2] ; unixmessage_t m = { .s = (char *)after, .len = afterlen, .fds = fd, .nfds = 1 } ; static unsigned char const bits = 0xff ; if (clientmsg->nfds || clientmsg->len != beforelen - || byte_diff(clientmsg->s, beforelen, before)) return (errno = EPROTO, 0) ; + || memcmp(clientmsg->s, before, beforelen)) return (errno = EPROTO, 0) ; if (ipc_pair_nbcoe(fd) < 0) return 0 ; unixmessage_sender_init(asyncout, fd[1]) ; if (!unixmessage_put_and_close(out, &m, &bits)) diff --git a/src/libunixonacid/skaclient_server_bidi_ack.c b/src/libunixonacid/skaclient_server_bidi_ack.c index 1d3cdbf..0a3e5da 100644 --- a/src/libunixonacid/skaclient_server_bidi_ack.c +++ b/src/libunixonacid/skaclient_server_bidi_ack.c @@ -1,9 +1,10 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/skaclient.h> #include <skalibs/unixmessage.h> -int skaclient_server_bidi_ack (unixmessage_t const *clientmsg, unixmessage_sender_t *out, unixmessage_sender_t *asyncout, unixmessage_receiver_t *asyncin, char *mainbuf, unsigned int mainlen, char *auxbuf, unsigned int auxlen, char const *before, unsigned int beforelen, char const *after, unsigned int afterlen) +int skaclient_server_bidi_ack (unixmessage_t const *clientmsg, unixmessage_sender_t *out, unixmessage_sender_t *asyncout, unixmessage_receiver_t *asyncin, char *mainbuf, size_t mainlen, char *auxbuf, size_t auxlen, char const *before, size_t beforelen, char const *after, size_t afterlen) { if (!unixmessage_receiver_init(asyncin, -1, mainbuf, mainlen, auxbuf, auxlen)) return 0 ; if (!skaclient_server_ack(clientmsg, out, asyncout, before, beforelen, after, afterlen)) return 0 ; diff --git a/src/libunixonacid/skaclient_server_init.c b/src/libunixonacid/skaclient_server_init.c index 86eb003..ec5623a 100644 --- a/src/libunixonacid/skaclient_server_init.c +++ b/src/libunixonacid/skaclient_server_init.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/allreadwrite.h> #include <skalibs/skaclient.h> #include <skalibs/tai.h> #include <skalibs/unixmessage.h> -int skaclient_server_init (unixmessage_receiver_t *in, unixmessage_sender_t *out, unixmessage_sender_t *asyncout, char const *before, unsigned int beforelen, char const *after, unsigned int afterlen, tain_t const *deadline, tain_t *stamp) +int skaclient_server_init (unixmessage_receiver_t *in, unixmessage_sender_t *out, unixmessage_sender_t *asyncout, char const *before, size_t beforelen, char const *after, size_t afterlen, tain_t const *deadline, tain_t *stamp) { unixmessage_t m ; return (sanitize_read(unixmessage_timed_receive(in, &m, deadline, stamp)) >= 0) diff --git a/src/libunixonacid/skaclient_start.c b/src/libunixonacid/skaclient_start.c index 85021cb..7a166ae 100644 --- a/src/libunixonacid/skaclient_start.c +++ b/src/libunixonacid/skaclient_start.c @@ -1,7 +1,8 @@ /* ISC license. */ +#include <sys/types.h> +#include <stdint.h> #include <errno.h> -#include <skalibs/uint32.h> #include <skalibs/kolbak.h> #include <skalibs/skaclient.h> #include <skalibs/tai.h> @@ -10,31 +11,31 @@ int skaclient_start ( skaclient_t *a, char *bufss, - unsigned int bufsn, + size_t bufsn, char *auxbufss, - unsigned int auxbufsn, + size_t auxbufsn, char *bufas, - unsigned int bufan, + size_t bufan, char *auxbufas, - unsigned int auxbufan, + size_t auxbufan, kolbak_closure_t *q, - unsigned int qlen, + size_t qlen, char const *path, - uint32 options, + uint32_t options, char const *before, - unsigned int beforelen, + size_t beforelen, char const *after, - unsigned int afterlen, + size_t afterlen, tain_t const *deadline, tain_t *stamp) { skaclient_cbdata_t blah ; unixmessage_t m ; - register int r ; + int r ; if (!skaclient_start_async(a, bufss, bufsn, auxbufss, auxbufsn, bufas, bufan, auxbufas, auxbufan, q, qlen, path, options, before, beforelen, after, afterlen, &blah)) return 0 ; if (!skaclient_timed_flush(a, deadline, stamp)) { - register int e = errno ; + int e = errno ; skaclient_end(a) ; errno = e ; return 0 ; diff --git a/src/libunixonacid/skaclient_start_async.c b/src/libunixonacid/skaclient_start_async.c index 79ea5df..467acd9 100644 --- a/src/libunixonacid/skaclient_start_async.c +++ b/src/libunixonacid/skaclient_start_async.c @@ -1,7 +1,8 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> -#include <skalibs/uint32.h> +#include <stdint.h> #include <skalibs/error.h> #include <skalibs/kolbak.h> #include <skalibs/skaclient.h> @@ -12,21 +13,21 @@ int skaclient_start_async ( skaclient_t *a, char *bufss, - unsigned int bufsn, + size_t bufsn, char *auxbufss, - unsigned int auxbufsn, + size_t auxbufsn, char *bufas, - unsigned int bufan, + size_t bufan, char *auxbufas, - unsigned int auxbufan, + size_t auxbufan, kolbak_closure_t *q, - unsigned int qlen, + size_t qlen, char const *path, - uint32 options, + uint32_t options, char const *before, - unsigned int beforelen, + size_t beforelen, char const *after, - unsigned int afterlen, + size_t afterlen, skaclient_cbdata_t *blah) { int fd = ipc_stream_nbcoe() ; @@ -34,7 +35,7 @@ int skaclient_start_async ( if ((!ipc_connect(fd, path) && !error_isalready(errno)) || !skaclient_init(a, fd, bufss, bufsn, auxbufss, auxbufsn, bufas, bufan, auxbufas, auxbufan, q, qlen, before, beforelen)) { - register int e = errno ; + int e = errno ; fd_close(fd) ; errno = e ; return 0 ; diff --git a/src/libunixonacid/skaclient_start_cb.c b/src/libunixonacid/skaclient_start_cb.c index ff11a21..80cb6c3 100644 --- a/src/libunixonacid/skaclient_start_cb.c +++ b/src/libunixonacid/skaclient_start_cb.c @@ -1,7 +1,7 @@ /* ISC license. */ #include <errno.h> -#include <skalibs/bytestr.h> +#include <string.h> #include <skalibs/error.h> #include <skalibs/unixmessage.h> #include <skalibs/skaclient.h> @@ -10,7 +10,7 @@ int skaclient_start_cb (unixmessage_t const *m, skaclient_cbdata_t *blah) { if (m->len != blah->afterlen - || byte_diff(m->s, m->len, blah->after) + || memcmp(m->s, blah->after, m->len) || m->nfds != 1) { unixmessage_drop(m) ; diff --git a/src/libunixonacid/skaclient_startf.c b/src/libunixonacid/skaclient_startf.c index 57d6f46..755bc78 100644 --- a/src/libunixonacid/skaclient_startf.c +++ b/src/libunixonacid/skaclient_startf.c @@ -1,5 +1,7 @@ /* ISC license. */ +#include <sys/types.h> +#include <stdint.h> #include <errno.h> #include <skalibs/kolbak.h> #include <skalibs/skaclient.h> @@ -9,33 +11,33 @@ int skaclient_startf ( skaclient_t *a, char *bufss, - unsigned int bufsn, + size_t bufsn, char *auxbufss, - unsigned int auxbufsn, + size_t auxbufsn, char *bufas, - unsigned int bufan, + size_t bufan, char *auxbufas, - unsigned int auxbufan, + size_t auxbufan, kolbak_closure_t *q, - unsigned int qlen, + size_t qlen, char const *prog, char const *const *argv, char const *const *envp, - uint32 options, + uint32_t options, char const *before, - unsigned int beforelen, + size_t beforelen, char const *after, - unsigned int afterlen, + size_t afterlen, tain_t const *deadline, tain_t *stamp) { skaclient_cbdata_t blah ; unixmessage_t m ; - register int r ; + int r ; if (!skaclient_startf_async(a, bufss, bufsn, auxbufss, auxbufsn, bufas, bufan, auxbufas, auxbufan, q, qlen, prog, argv, envp, options, before, beforelen, after, afterlen, &blah)) return 0 ; if (!skaclient_timed_flush(a, deadline, stamp)) { - register int e = errno ; + int e = errno ; skaclient_end(a) ; errno = e ; return 0 ; diff --git a/src/libunixonacid/skaclient_startf_async.c b/src/libunixonacid/skaclient_startf_async.c index dd1688e..dce692e 100644 --- a/src/libunixonacid/skaclient_startf_async.c +++ b/src/libunixonacid/skaclient_startf_async.c @@ -1,34 +1,34 @@ /* ISC license. */ #include <sys/types.h> +#include <stdint.h> #include <errno.h> #include <signal.h> #include <skalibs/djbunix.h> #include <skalibs/kolbak.h> #include <skalibs/skaclient.h> -#include <skalibs/uint32.h> #include "skaclient-internal.h" int skaclient_startf_async ( skaclient_t *a, char *bufss, - unsigned int bufsn, + size_t bufsn, char *auxbufss, - unsigned int auxbufsn, + size_t auxbufsn, char *bufas, - unsigned int bufan, + size_t bufan, char *auxbufas, - unsigned int auxbufan, + size_t auxbufan, kolbak_closure_t *q, - unsigned int qlen, + size_t qlen, char const *prog, char const *const *argv, char const *const *envp, - uint32 options, + uint32_t options, char const *before, - unsigned int beforelen, + size_t beforelen, char const *after, - unsigned int afterlen, + size_t afterlen, skaclient_cbdata_t *blah) { int fd ; @@ -36,7 +36,7 @@ int skaclient_startf_async ( if (!pid) return 0 ; if (ndelay_on(fd) < 0 || !skaclient_init(a, fd, bufss, bufsn, auxbufss, auxbufsn, bufas, bufan, auxbufas, auxbufan, q, qlen, before, beforelen)) { - register int e = errno ; + int e = errno ; fd_close(fd) ; if (options & SKACLIENT_OPTION_WAITPID) { diff --git a/src/libunixonacid/skaclient_syncify.c b/src/libunixonacid/skaclient_syncify.c index 08b7b9a..ea5afb4 100644 --- a/src/libunixonacid/skaclient_syncify.c +++ b/src/libunixonacid/skaclient_syncify.c @@ -6,7 +6,7 @@ int skaclient_syncify (skaclient_t *a, tain_t const *deadline, tain_t *stamp) { - register int r ; + int r ; if (!skaclient_timed_flush(a, deadline, stamp)) return 0 ; r = skaclient_timed_supdate(a, deadline, stamp) ; return r < 0 ? 0 : !r ? (errno = EPIPE, 0) : 1 ; diff --git a/src/libunixonacid/stat_at.c b/src/libunixonacid/stat_at.c index 11f7924..3f0f1a5 100644 --- a/src/libunixonacid/stat_at.c +++ b/src/libunixonacid/stat_at.c @@ -9,7 +9,6 @@ #endif #include <skalibs/nonposix.h> -#include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <skalibs/unix-transactional.h> @@ -43,7 +42,7 @@ static int fstat_at (int dirfd, char const *file, struct stat *st, int (*dostat) if (fdhere < 0) return -1 ; if (fd_chdir(dirfd) < 0) { - register int e = errno ; + int e = errno ; fd_close(fdhere) ; errno = e ; return -1 ; @@ -51,7 +50,7 @@ static int fstat_at (int dirfd, char const *file, struct stat *st, int (*dostat) r = (*dostat)(file, st) ; if (r < 0) { - register int e = errno ; + int e = errno ; fd_chdir(fdhere) ; fd_close(fdhere) ; errno = e ; @@ -59,7 +58,7 @@ static int fstat_at (int dirfd, char const *file, struct stat *st, int (*dostat) } if (fd_chdir(fdhere) < 0) { - register int e = errno ; + int e = errno ; fd_close(fdhere) ; errno = e ; return -1 ; diff --git a/src/libunixonacid/timed_flush.c b/src/libunixonacid/timed_flush.c index 2d60256..ced60b6 100644 --- a/src/libunixonacid/timed_flush.c +++ b/src/libunixonacid/timed_flush.c @@ -13,7 +13,7 @@ int timed_flush (void *b, initfunc_t_ref getfd, initfunc_t_ref isnonempty, initf iopause_fd x = { .fd = (*getfd)(b), .events = IOPAUSE_WRITE, .revents = 0 } ; while ((*isnonempty)(b)) { - register int r = iopause_stamp(&x, 1, deadline, stamp) ; + int r = iopause_stamp(&x, 1, deadline, stamp) ; if (r < 0) return 0 ; else if (!r) return (errno = ETIMEDOUT, 0) ; else if (x.revents & IOPAUSE_WRITE) diff --git a/src/libunixonacid/timed_get.c b/src/libunixonacid/timed_get.c index 1b4e420..e93478e 100644 --- a/src/libunixonacid/timed_get.c +++ b/src/libunixonacid/timed_get.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/allreadwrite.h> #include <skalibs/functypes.h> @@ -7,10 +8,10 @@ #include <skalibs/iopause.h> #include <skalibs/unix-timed.h> -int timed_get (void *b, initfunc_t *getfd, initfunc_t *get, tain_t const *deadline, tain_t *stamp) +ssize_t timed_get (void *b, initfunc_t_ref getfd, getfunc_t_ref get, tain_t const *deadline, tain_t *stamp) { iopause_fd x = { .fd = (*getfd)(b), .events = IOPAUSE_READ, .revents = 0 } ; - register int r = (*get)(b) ; + ssize_t r = (*get)(b) ; while (!r) { r = iopause_stamp(&x, 1, deadline, stamp) ; diff --git a/src/libunixonacid/timed_getln.c b/src/libunixonacid/timed_getln.c index 0c442de..f699d97 100644 --- a/src/libunixonacid/timed_getln.c +++ b/src/libunixonacid/timed_getln.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/allreadwrite.h> #include <skalibs/buffer.h> #include <skalibs/functypes.h> @@ -20,7 +21,7 @@ static int getfd (struct blah_s *blah) return buffer_fd(blah->b) ; } -static int get (struct blah_s *blah) +static ssize_t get (struct blah_s *blah) { return sanitize_read(skagetln(blah->b, blah->sa, blah->sep)) ; } @@ -28,5 +29,5 @@ static int get (struct blah_s *blah) int timed_getln (buffer *b, stralloc *sa, char sep, tain_t const *deadline, tain_t *stamp) { struct blah_s blah = { .b = b, .sa = sa, .sep = sep } ; - return timed_get(&blah, (initfunc_t_ref)&getfd, (initfunc_t_ref)&get, deadline, stamp) ; + return timed_get(&blah, (initfunc_t_ref)&getfd, (getfunc_t_ref)&get, deadline, stamp) ; } diff --git a/src/libunixonacid/timed_getlnmax.c b/src/libunixonacid/timed_getlnmax.c index 2a8fab3..1d89d85 100644 --- a/src/libunixonacid/timed_getlnmax.c +++ b/src/libunixonacid/timed_getlnmax.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/allreadwrite.h> #include <skalibs/buffer.h> #include <skalibs/functypes.h> @@ -11,8 +12,8 @@ struct blah_s { buffer *b ; char *d ; - unsigned int max ; - unsigned int w ; + size_t max ; + size_t w ; char sep ; } ; @@ -21,15 +22,15 @@ static int getfd (struct blah_s *blah) return buffer_fd(blah->b) ; } -static int get (struct blah_s *blah) +static ssize_t get (struct blah_s *blah) { return sanitize_read(getlnmax(blah->b, blah->d, blah->max, &blah->w, blah->sep)) ; } -int timed_getlnmax (buffer *b, char *d, unsigned int max, unsigned int *w, char sep, tain_t const *deadline, tain_t *stamp) +ssize_t timed_getlnmax (buffer *b, char *d, size_t max, size_t *w, char sep, tain_t const *deadline, tain_t *stamp) { struct blah_s blah = { .b = b, .d = d, .max = max, .w = *w, .sep = sep } ; - register int r = timed_get(&blah, (initfunc_t_ref)&getfd, (initfunc_t_ref)&get, deadline, stamp) ; + ssize_t r = timed_get(&blah, (initfunc_t_ref)&getfd, (getfunc_t_ref)&get, deadline, stamp) ; *w = blah.w ; return r ; } diff --git a/src/libunixonacid/unixmessage_bits_closeall.c b/src/libunixonacid/unixmessage_bits_closeall.c index a963809..f640f48 100644 --- a/src/libunixonacid/unixmessage_bits_closeall.c +++ b/src/libunixonacid/unixmessage_bits_closeall.c @@ -3,5 +3,5 @@ #include <skalibs/bitarray.h> #include <skalibs/unixmessage.h> -static unsigned char _unixmessage_bits_closeall[bitarray_div8(UNIXMESSAGE_MAXFDS)] = "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" ; -unsigned char const *const unixmessage_bits_closeall = _unixmessage_bits_closeall ; +static unsigned char unixmessage_bits_closeall_[bitarray_div8(UNIXMESSAGE_MAXFDS)] = "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" ; +unsigned char const *const unixmessage_bits_closeall = unixmessage_bits_closeall_ ; diff --git a/src/libunixonacid/unixmessage_bits_closenone.c b/src/libunixonacid/unixmessage_bits_closenone.c index 79412a5..4d84737 100644 --- a/src/libunixonacid/unixmessage_bits_closenone.c +++ b/src/libunixonacid/unixmessage_bits_closenone.c @@ -3,5 +3,5 @@ #include <skalibs/bitarray.h> #include <skalibs/unixmessage.h> -static unsigned char _unixmessage_bits_closenone[bitarray_div8(UNIXMESSAGE_MAXFDS)] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" ; -unsigned char const *const unixmessage_bits_closenone = _unixmessage_bits_closenone ; +static unsigned char unixmessage_bits_closenone_[bitarray_div8(UNIXMESSAGE_MAXFDS)] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" ; +unsigned char const *const unixmessage_bits_closenone = unixmessage_bits_closenone_ ; diff --git a/src/libunixonacid/unixmessage_drop.c b/src/libunixonacid/unixmessage_drop.c index 7fa34fb..e51a8d0 100644 --- a/src/libunixonacid/unixmessage_drop.c +++ b/src/libunixonacid/unixmessage_drop.c @@ -7,7 +7,7 @@ void unixmessage_drop (unixmessage_t const *m) { int e = errno ; - register unsigned int i = 0 ; - for (; i < m->nfds ; i++) fd_close(m->fds[i]) ; + unsigned int i = m->nfds ; + while (i--) fd_close(m->fds[i]) ; errno = e ; } diff --git a/src/libunixonacid/unixmessage_handle.c b/src/libunixonacid/unixmessage_handle.c index 52e85cb..9d9de5c 100644 --- a/src/libunixonacid/unixmessage_handle.c +++ b/src/libunixonacid/unixmessage_handle.c @@ -2,19 +2,19 @@ #include <skalibs/unixmessage.h> -int unixmessage_handle (unixmessage_receiver_t *b, unixmessage_handler_func_t *f, void *p) +int unixmessage_handle (unixmessage_receiver_t *b, unixmessage_handler_func_t_ref f, void *p) { unsigned int n = UNIXMESSAGE_MAXREADS ; - int count = 0 ; + unsigned int count = 0 ; while (n--) { unixmessage_t m ; - register int r = unixmessage_receive(b, &m) ; + int r = unixmessage_receive(b, &m) ; if (r < 0) return -1 ; if (!r) break ; r = (*f)(&m, p) ; if (r <= 0) return r-2 ; count++ ; } - return count ; + return (int)count ; } diff --git a/src/libunixonacid/unixmessage_put.c b/src/libunixonacid/unixmessage_put.c index 43091c9..d9fe306 100644 --- a/src/libunixonacid/unixmessage_put.c +++ b/src/libunixonacid/unixmessage_put.c @@ -4,10 +4,10 @@ #ifdef SKALIBS_HASANCILAUTOCLOSE #include <unistd.h> #endif +#include <string.h> #include <errno.h> #include <skalibs/bitarray.h> -#include <skalibs/bytestr.h> -#include <skalibs/diuint.h> +#include <skalibs/disize.h> #include <skalibs/error.h> #include <skalibs/stralloc.h> #include <skalibs/genalloc.h> @@ -16,7 +16,7 @@ static inline int copyfds (char *s, int const *fds, unsigned int n, unsigned char const *bits, unixmessage_sender_closecb_func_t_ref closecb, void *closecbdata) { - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < n ; i++) { int fd = fds[i] ; @@ -32,7 +32,7 @@ static inline int copyfds (char *s, int const *fds, unsigned int n, unsigned cha while (i--) { s -= sizeof(int) ; - byte_copy((char *)fd, sizeof(int), s) ; + memcpy((char *)fd, s, sizeof(int)) ; if (fd >= 0) (*closecb)(fd, closecbdata) ; } errno = e ; @@ -40,46 +40,38 @@ static inline int copyfds (char *s, int const *fds, unsigned int n, unsigned cha } } #endif - byte_copy(s, sizeof(int), (char const *)&fd) ; + memcpy(s, (char const *)&fd, sizeof(int)) ; s += sizeof(int) ; } return 1 ; } -static int reserve_and_copy (unixmessage_sender_t *b, unsigned int len, int const *fds, unsigned int nfds, unsigned char const *bits) +static int reserve_and_copy (unixmessage_sender_t *b, size_t len, int const *fds, unsigned int nfds, unsigned char const *bits) { - diuint cur = { .left = b->data.len, .right = genalloc_len(int, &b->fds) } ; + disize cur = { .left = b->data.len, .right = genalloc_len(int, &b->fds) } ; if (len > UNIXMESSAGE_MAXSIZE || nfds > UNIXMESSAGE_MAXFDS) return (errno = EPROTO, 0) ; - if (!genalloc_readyplus(diuint, &b->offsets, 1) + if (!genalloc_readyplus(disize, &b->offsets, 1) || !genalloc_readyplus(int, &b->fds, nfds) || !stralloc_readyplus(&b->data, len)) return 0 ; if (!copyfds(b->fds.s + b->fds.len, fds, nfds, bits, b->closecb, b->closecbdata)) return 0 ; genalloc_setlen(int, &b->fds, cur.right + nfds) ; - byte_copy(b->offsets.s + b->offsets.len, sizeof(diuint), (char const *)&cur) ; - b->offsets.len += sizeof(diuint) ; - return 1 ; + return genalloc_append(disize, &b->offsets, &cur) ; } int unixmessage_put_and_close (unixmessage_sender_t *b, unixmessage_t const *m, unsigned char const *bits) { if (!reserve_and_copy(b, m->len, m->fds, m->nfds, bits)) return 0 ; - byte_copy(b->data.s + b->data.len, m->len, m->s) ; + memmove(b->data.s + b->data.len, m->s, m->len) ; b->data.len += m->len ; return 1 ; } int unixmessage_putv_and_close (unixmessage_sender_t *b, unixmessage_v_t const *m, unsigned char const *bits) { - unsigned int len = 0 ; - register unsigned int i = 0 ; - for (; i < m->vlen ; i++) len += m->v[i].len ; + size_t len = siovec_len(m->v, m->vlen) ; if (!reserve_and_copy(b, len, m->fds, m->nfds, bits)) return 0 ; - for (i = 0 ; i < m->vlen ; i++) - { - byte_copy(b->data.s + b->data.len, m->v[i].len, m->v[i].s) ; - b->data.len += m->v[i].len ; - } + siovec_gather(m->v, m->vlen, b->data.s + b->data.len, len) ; return 1 ; } diff --git a/src/libunixonacid/unixmessage_receive.c b/src/libunixonacid/unixmessage_receive.c index 885a7bc..9672b63 100644 --- a/src/libunixonacid/unixmessage_receive.c +++ b/src/libunixonacid/unixmessage_receive.c @@ -12,7 +12,6 @@ #include <skalibs/error.h> #include <skalibs/allreadwrite.h> #include <skalibs/stralloc.h> -#include <skalibs/siovec.h> #include <skalibs/unixmessage.h> static int const awesomeflags = @@ -49,14 +48,10 @@ static int unixmessage_receiver_fill (unixmessage_receiver_t *b) .msg_control = b->fds_ok & 1 ? ancilbuf : 0, .msg_controllen = b->fds_ok & 1 ? sizeof(ancilbuf) : 0 } ; - int r = -1 ; + ssize_t r = -1 ; if (cbuffer_isfull(&b->mainb) || ((b->fds_ok & 1) && cbuffer_isfull(&b->auxb))) return (errno = ENOBUFS, -1) ; - { - siovec_t v[2] ; - cbuffer_wpeek(&b->mainb, v) ; - iovec_from_siovec(iov, v, 2) ; - } + cbuffer_wpeek(&b->mainb, iov) ; while (r < 0) { r = recvmsg(b->fd, &msghdr, awesomeflags) ; @@ -67,20 +62,20 @@ static int unixmessage_receiver_fill (unixmessage_receiver_t *b) struct cmsghdr *c = CMSG_FIRSTHDR(&msghdr) ; if (c) { - unsigned int auxlen ; + size_t auxlen ; if (c->cmsg_level != SOL_SOCKET || c->cmsg_type != SCM_RIGHTS) return (errno = EPROTO, -1) ; - auxlen = (unsigned int)(c->cmsg_len - (CMSG_DATA(c) - (unsigned char *)c)) ; + auxlen = (size_t)(c->cmsg_len - (CMSG_DATA(c) - (unsigned char *)c)) ; if (auxlen && !(b->fds_ok & 2)) { - register unsigned int i = auxlen/sizeof(int) ; + size_t i = auxlen / sizeof(int) ; while (i--) fd_close(((int *)CMSG_DATA(c))[i]) ; return (errno = EPROTO, -1) ; } #ifndef SKALIBS_HASCMSGCLOEXEC { - register unsigned int i = 0 ; - for (; i < auxlen/sizeof(int) ; i++) + size_t i = 0 ; + for (; i < auxlen / sizeof(int) ; i++) if (coe(((int *)CMSG_DATA(c))[i]) < 0) { int e = errno ; @@ -93,7 +88,7 @@ static int unixmessage_receiver_fill (unixmessage_receiver_t *b) #endif if ((msghdr.msg_flags & MSG_CTRUNC) || cbuffer_put(&b->auxb, (char *)CMSG_DATA(c), auxlen) < auxlen) { - register unsigned int i = auxlen/sizeof(int) ; + size_t i = auxlen/sizeof(int) ; while (i--) fd_close(((int *)CMSG_DATA(c))[i]) ; return (errno = ENOBUFS, -1) ; } @@ -110,7 +105,7 @@ int unixmessage_receive (unixmessage_receiver_t *b, unixmessage_t *m) char pack[6] ; if (cbuffer_len(&b->mainb) < 6) { - register int r = sanitize_read(unixmessage_receiver_fill(b)) ; + ssize_t r = sanitize_read(unixmessage_receiver_fill(b)) ; if (r <= 0) return r ; if (cbuffer_len(&b->mainb) < 6) return (errno = EWOULDBLOCK, 0) ; } @@ -131,8 +126,8 @@ int unixmessage_receive (unixmessage_receiver_t *b, unixmessage_t *m) for (;;) { - register int r ; - register unsigned int n = cbuffer_len(&b->mainb) ; + ssize_t r ; + size_t n = cbuffer_len(&b->mainb) ; if (n > b->mainlen - b->maindata.len) n = b->mainlen - b->maindata.len ; b->maindata.len += cbuffer_get(&b->mainb, b->maindata.s + b->maindata.len, n) ; n = cbuffer_len(&b->auxb) ; diff --git a/src/libunixonacid/unixmessage_receiver_free.c b/src/libunixonacid/unixmessage_receiver_free.c index d9d575e..776509c 100644 --- a/src/libunixonacid/unixmessage_receiver_free.c +++ b/src/libunixonacid/unixmessage_receiver_free.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/cbuffer.h> #include <skalibs/stralloc.h> #include <skalibs/djbunix.h> @@ -7,19 +8,20 @@ void unixmessage_receiver_free (unixmessage_receiver_t *b) { - register unsigned int h = b->maindata.len ; + size_t maindatalen = b->maindata.len ; + int h ; b->fd = -1 ; stralloc_free(&b->maindata) ; - h = h != b->mainlen || b->auxdata.len != b->auxlen || cbuffer_len(&b->auxb) ; + h = maindatalen != b->mainlen || b->auxdata.len != b->auxlen || cbuffer_len(&b->auxb) ; if (h) { - register unsigned int n = b->auxdata.len / sizeof(int) ; + size_t n = b->auxdata.len / sizeof(int) ; while (n--) fd_close(((int *)b->auxdata.s)[n]) ; } stralloc_free(&b->auxdata) ; if (h) { - register unsigned int n = cbuffer_len(&b->auxb) / sizeof(int) ; + size_t n = cbuffer_len(&b->auxb) / sizeof(int) ; if (n) { int fds[n] ; diff --git a/src/libunixonacid/unixmessage_receiver_init.c b/src/libunixonacid/unixmessage_receiver_init.c index 430ccac..117512e 100644 --- a/src/libunixonacid/unixmessage_receiver_init.c +++ b/src/libunixonacid/unixmessage_receiver_init.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/cbuffer.h> #include <skalibs/stralloc.h> #include <skalibs/unixmessage.h> -int unixmessage_receiver_init (unixmessage_receiver_t *b, int fd, char *mainbuf, unsigned int mainlen, char *auxbuf, unsigned int auxlen) +int unixmessage_receiver_init (unixmessage_receiver_t *b, int fd, char *mainbuf, size_t mainlen, char *auxbuf, size_t auxlen) { if (!cbuffer_init(&b->mainb, mainbuf, mainlen) || !cbuffer_init(&b->auxb, auxbuf, auxlen)) return 0 ; diff --git a/src/libunixonacid/unixmessage_sender_flush.c b/src/libunixonacid/unixmessage_sender_flush.c index 57c5d6e..8cfb709 100644 --- a/src/libunixonacid/unixmessage_sender_flush.c +++ b/src/libunixonacid/unixmessage_sender_flush.c @@ -4,12 +4,13 @@ #include <skalibs/nonposix.h> #include <sys/socket.h> #include <sys/uio.h> +#include <stdint.h> #include <unistd.h> #include <errno.h> #include <skalibs/uint16.h> #include <skalibs/uint32.h> #include <skalibs/bytestr.h> -#include <skalibs/diuint.h> +#include <skalibs/disize.h> #include <skalibs/allreadwrite.h> #include <skalibs/genalloc.h> #include <skalibs/djbunix.h> @@ -27,28 +28,28 @@ int unixmessage_sender_flush (unixmessage_sender_t *b) { - diuint last = { .left = b->data.len, .right = genalloc_len(int, &b->fds) } ; - diuint *offsets = genalloc_s(diuint, &b->offsets) ; - unsigned int n = genalloc_len(diuint, &b->offsets) ; - register int r ; + disize last = { .left = b->data.len, .right = genalloc_len(int, &b->fds) } ; + disize *offsets = genalloc_s(disize, &b->offsets) ; + size_t n = genalloc_len(disize, &b->offsets) ; + ssize_t r ; if (b->shorty) /* we had a short write, gotta send the remainder first */ { - diuint *next = b->head+1 < n ? offsets + b->head+1 : &last ; - unsigned int len = next->left - offsets[b->head].left ; + disize *next = b->head+1 < n ? offsets + b->head+1 : &last ; + size_t len = next->left - offsets[b->head].left ; if (b->shorty <= len) r = fd_write(b->fd, b->data.s + offsets[b->head].left + (len - b->shorty), b->shorty) ; else { - unsigned int nfds = next->right - offsets[b->head].right ; + size_t nfds = next->right - offsets[b->head].right ; char pack[6] ; struct iovec v[2] = { { .iov_base = pack + 6 - (b->shorty - len), .iov_len = b->shorty - len }, { .iov_base = b->data.s + offsets[b->head].left, .iov_len = len } } ; - uint32_pack_big(pack, (uint32)len) ; - uint16_pack_big(pack + 4, (uint16)nfds) ; + uint32_pack_big(pack, (uint32_t)len) ; + uint16_pack_big(pack + 4, (uint16_t)nfds) ; r = fd_writev(b->fd, v, 2) ; } if (r <= 0) return 0 ; @@ -58,9 +59,9 @@ int unixmessage_sender_flush (unixmessage_sender_t *b) for (; b->head < n ; b->head++) { - diuint *next = b->head+1 < n ? offsets + b->head+1 : &last ; - unsigned int len = next->left - offsets[b->head].left ; - unsigned int nfds = next->right - offsets[b->head].right ; + disize *next = b->head+1 < n ? offsets + b->head+1 : &last ; + size_t len = next->left - offsets[b->head].left ; + size_t nfds = next->right - offsets[b->head].right ; char pack[6] ; struct iovec v[2] = { @@ -77,19 +78,19 @@ int unixmessage_sender_flush (unixmessage_sender_t *b) .msg_control = nfds ? ancilbuf : 0, .msg_controllen = nfds ? sizeof(ancilbuf) : 0 } ; - uint32_pack_big(pack, (uint32)len) ; - uint16_pack_big(pack + 4, (uint16)nfds) ; + uint32_pack_big(pack, (uint32_t)len) ; + uint16_pack_big(pack + 4, (uint16_t)nfds) ; if (nfds) { struct cmsghdr *cp = CMSG_FIRSTHDR(&hdr) ; - register unsigned int i = 0 ; + size_t i = 0 ; byte_zero(ancilbuf, sizeof(ancilbuf)) ; cp->cmsg_level = SOL_SOCKET ; cp->cmsg_type = SCM_RIGHTS ; cp->cmsg_len = CMSG_LEN(nfds * sizeof(int)) ; for (; i < nfds ; i++) { - register int fd = genalloc_s(int, &b->fds)[offsets[b->head].right + i] ; + int fd = genalloc_s(int, &b->fds)[offsets[b->head].right + i] ; ((int *)CMSG_DATA(cp))[i] = fd < 0 ? -(fd+1) : fd ; } } @@ -99,15 +100,15 @@ int unixmessage_sender_flush (unixmessage_sender_t *b) #ifndef SKALIBS_HASANCILAUTOCLOSE if (nfds) { - register unsigned int i = 0 ; + size_t i = 0 ; for (; i < nfds ; i++) { - register int fd = genalloc_s(int, &b->fds)[offsets[b->head].right + i] ; + int fd = genalloc_s(int, &b->fds)[offsets[b->head].right + i] ; if (fd < 0) (*b->closecb)(-(fd+1), b->closecbdata) ; } } #endif - if ((unsigned int)r < 6 + len) + if ((size_t)r < 6 + len) { b->shorty = 6 + len - r ; return (errno = EWOULDBLOCK, 0) ; @@ -115,7 +116,7 @@ int unixmessage_sender_flush (unixmessage_sender_t *b) } b->data.len = 0 ; genalloc_setlen(int, &b->fds, 0) ; - genalloc_setlen(diuint, &b->offsets, 0) ; + genalloc_setlen(disize, &b->offsets, 0) ; b->head = 0 ; return 1 ; } diff --git a/src/libunixonacid/unixmessage_sender_free.c b/src/libunixonacid/unixmessage_sender_free.c index a976827..da127c2 100644 --- a/src/libunixonacid/unixmessage_sender_free.c +++ b/src/libunixonacid/unixmessage_sender_free.c @@ -1,7 +1,8 @@ /* ISC license. */ #include <skalibs/sysdeps.h> -#include <skalibs/diuint.h> +#include <sys/types.h> +#include <skalibs/disize.h> #include <skalibs/stralloc.h> #include <skalibs/genalloc.h> #include <skalibs/djbunix.h> @@ -9,20 +10,20 @@ void unixmessage_sender_free (unixmessage_sender_t *b) { - unsigned int n = genalloc_len(int, &b->fds) ; + size_t n = genalloc_len(int, &b->fds) ; if (n) { - unsigned int i = genalloc_s(diuint, &b->offsets)[b->head].right ; + size_t i = genalloc_s(disize, &b->offsets)[b->head].right ; for (; i < n ; i++) { - register int fd = genalloc_s(int, &b->fds)[i] ; + int fd = genalloc_s(int, &b->fds)[i] ; if (fd < 0) (*b->closecb)(-(fd+1), b->closecbdata) ; #ifdef SKALIBS_HASANCILAUTOCLOSE else (*b->closecb)(fd, b->closecbdata) ; #endif } } - genalloc_free(diuint, &b->offsets) ; + genalloc_free(disize, &b->offsets) ; genalloc_free(int, &b->fds) ; stralloc_free(&b->data) ; *b = unixmessage_sender_zero ; diff --git a/src/libunixonacid/unixmessage_timed_handle.c b/src/libunixonacid/unixmessage_timed_handle.c index 5ac7ccd..ae10621 100644 --- a/src/libunixonacid/unixmessage_timed_handle.c +++ b/src/libunixonacid/unixmessage_timed_handle.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/functypes.h> #include <skalibs/tai.h> #include <skalibs/unix-timed.h> @@ -9,7 +10,7 @@ typedef struct unixmessage_handler_blah_s unixmessage_handler_blah_t, *unixmessa struct unixmessage_handler_blah_s { unixmessage_receiver_t *b ; - unixmessage_handler_func_t *f ; + unixmessage_handler_func_t_ref f ; void *p ; } ; @@ -18,13 +19,13 @@ static int getfd (unixmessage_handler_blah_t *blah) return unixmessage_receiver_fd(blah->b) ; } -static int get (unixmessage_handler_blah_t *blah) +static ssize_t get (unixmessage_handler_blah_t *blah) { return unixmessage_handle(blah->b, blah->f, blah->p) ; } -int unixmessage_timed_handle (unixmessage_receiver_t *b, unixmessage_handler_func_t *f, void *p, tain_t const *deadline, tain_t *stamp) +int unixmessage_timed_handle (unixmessage_receiver_t *b, unixmessage_handler_func_t_ref f, void *p, tain_t const *deadline, tain_t *stamp) { unixmessage_handler_blah_t blah = { .b = b, .f = f, .p = p } ; - return timed_get(&blah, (initfunc_t_ref)&getfd, (initfunc_t_ref)&get, deadline, stamp) ; + return timed_get(&blah, (initfunc_t_ref)&getfd, (getfunc_t_ref)&get, deadline, stamp) ; } diff --git a/src/libunixonacid/unixmessage_timed_receive.c b/src/libunixonacid/unixmessage_timed_receive.c index 3761d26..dc83ff7 100644 --- a/src/libunixonacid/unixmessage_timed_receive.c +++ b/src/libunixonacid/unixmessage_timed_receive.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/functypes.h> #include <skalibs/tai.h> #include <skalibs/unix-timed.h> @@ -17,7 +18,7 @@ static int getfd (unixmessage_get_t *g) return unixmessage_receiver_fd(g->b) ; } -static int get (unixmessage_get_t *g) +static ssize_t get (unixmessage_get_t *g) { return unixmessage_receive(g->b, g->m) ; } @@ -25,5 +26,5 @@ static int get (unixmessage_get_t *g) int unixmessage_timed_receive (unixmessage_receiver_t *b, unixmessage_t *m, tain_t const *deadline, tain_t *stamp) { unixmessage_get_t g = { .b = b, .m = m } ; - return timed_get(&g, (initfunc_t *)&getfd, (initfunc_t *)&get, deadline, stamp) ; + return timed_get(&g, (initfunc_t_ref)&getfd, (getfunc_t_ref)&get, deadline, stamp) ; } diff --git a/src/libunixonacid/unixmessage_unput.c b/src/libunixonacid/unixmessage_unput.c index e869110..180c5a7 100644 --- a/src/libunixonacid/unixmessage_unput.c +++ b/src/libunixonacid/unixmessage_unput.c @@ -1,18 +1,19 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/genalloc.h> -#include <skalibs/diuint.h> +#include <skalibs/disize.h> #include <skalibs/djbunix.h> #include <skalibs/unixmessage.h> int unixmessage_unput_and_maybe_drop (unixmessage_sender_t *b, int drop) { - diuint *start ; - unsigned int n = genalloc_len(diuint, &b->offsets) ; - register int *fds ; - register unsigned int i ; + disize *start ; + size_t n = genalloc_len(disize, &b->offsets) ; + size_t i ; + int *fds ; if (!n) return 0 ; - start = genalloc_s(diuint, &b->offsets) + n - 1 ; + start = genalloc_s(disize, &b->offsets) + n - 1 ; fds = genalloc_s(int, &b->fds) + start->right ; i = genalloc_len(int, &b->fds) - start->right ; while (i--) @@ -20,6 +21,6 @@ int unixmessage_unput_and_maybe_drop (unixmessage_sender_t *b, int drop) else if (drop) fd_close(fds[i]) ; b->data.len = start->left ; genalloc_setlen(int, &b->fds, start->right) ; - genalloc_setlen(diuint, &b->offsets, n-1) ; + genalloc_setlen(disize, &b->offsets, n-1) ; return 1 ; } |