diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2014-12-20 12:34:14 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2014-12-20 12:34:14 +0000 |
commit | 0d82edd9f8bebb396a9154d4e1003340dbf6b967 (patch) | |
tree | 0659c834f387f3504944a610ed6858b9e268e6c7 /src/libstddjb | |
parent | 2436785702b47996e9f0e281df0d6027660ec914 (diff) | |
download | skalibs-0d82edd9f8bebb396a9154d4e1003340dbf6b967.tar.xz |
Lots of cosmetic fixes.
sha256 documented.
Diffstat (limited to 'src/libstddjb')
29 files changed, 44 insertions, 46 deletions
diff --git a/src/libstddjb/alloc.c b/src/libstddjb/alloc.c index e3f89dd..31e3e05 100644 --- a/src/libstddjb/alloc.c +++ b/src/libstddjb/alloc.c @@ -13,9 +13,9 @@ # define PLM(...) (bprintf(buffer_2, "%s: debug_alloc: ", PROG), bprintf(buffer_2, __VA_ARGS__), buffer_putflush(buffer_2, "\n", 1)) #endif -aligned_char_ref alloc (unsigned int n) +aligned_char *alloc (unsigned int n) { - register aligned_char_ref p = n ? (aligned_char_ref)malloc(n) : (aligned_char_ref)alloc_0 ; + register aligned_char *p = n ? (aligned_char *)malloc(n) : (aligned_char *)alloc_0 ; #ifdef DEBUG_ALLOC static unsigned int counter = 0 ; PLM("alloc(%u): %p. Allocated: %u", n, p, ++counter) ; @@ -37,9 +37,9 @@ void alloc_free (void *p) errno = e ; } -int alloc_realloc (aligned_char_ref *x, unsigned int n) +int alloc_realloc (aligned_char **x, unsigned int n) { - aligned_char_ref y = n ? (aligned_char_ref)realloc(*x, n) : (free(*x), alloc_0) ; + aligned_char *y = n ? (aligned_char *)realloc(*x, n) : (free(*x), alloc_0) ; #ifdef DEBUG_ALLOC PLM("alloc_realloc(&%p) -> new address = %p", *x, y) ; #endif diff --git a/src/libstddjb/alloc_0.c b/src/libstddjb/alloc_0.c index 2175262..bdd42a4 100644 --- a/src/libstddjb/alloc_0.c +++ b/src/libstddjb/alloc_0.c @@ -8,6 +8,6 @@ #define ALIGNMENT 16 static union { unsigned char blah[ALIGNMENT] ; long double ld ; } const zeroblock ; -aligned_char_ref alloc_0 = (aligned_char_ref)(&zeroblock) ; +aligned_char *alloc_0 = (aligned_char_ref)(&zeroblock) ; #endif diff --git a/src/libstddjb/bufalloc_1.c b/src/libstddjb/bufalloc_1.c index 6e636ca..08fbf06 100644 --- a/src/libstddjb/bufalloc_1.c +++ b/src/libstddjb/bufalloc_1.c @@ -5,5 +5,4 @@ #include <skalibs/allreadwrite.h> #include <skalibs/bufalloc.h> -static bufalloc b = BUFALLOC_INIT(&fd_write, 1) ; -bufalloc_ref bufalloc_1 = &b ; +bufalloc bufalloc_1_ = BUFALLOC_INIT(&fd_write, 1) ; diff --git a/src/libstddjb/bufalloc_2.c b/src/libstddjb/bufalloc_2.c index bcf97da..563b64a 100644 --- a/src/libstddjb/bufalloc_2.c +++ b/src/libstddjb/bufalloc_2.c @@ -5,5 +5,4 @@ #include <skalibs/allreadwrite.h> #include <skalibs/bufalloc.h> -static bufalloc b = BUFALLOC_INIT(&fd_write, 2) ; -bufalloc_ref bufalloc_2 = &b ; +bufalloc bufalloc_2_ = BUFALLOC_INIT(&fd_write, 2) ; diff --git a/src/libstddjb/bufalloc_clean.c b/src/libstddjb/bufalloc_clean.c index 28bd35e..79b5880 100644 --- a/src/libstddjb/bufalloc_clean.c +++ b/src/libstddjb/bufalloc_clean.c @@ -3,7 +3,7 @@ #include <skalibs/bytestr.h> #include <skalibs/bufalloc.h> -void bufalloc_clean (register bufalloc_ref ba) +void bufalloc_clean (register bufalloc *ba) { if (ba->p) { diff --git a/src/libstddjb/bufalloc_flush.c b/src/libstddjb/bufalloc_flush.c index 49b2eb1..e6ddfc2 100644 --- a/src/libstddjb/bufalloc_flush.c +++ b/src/libstddjb/bufalloc_flush.c @@ -3,7 +3,7 @@ #include <skalibs/allreadwrite.h> #include <skalibs/bufalloc.h> -int bufalloc_flush (bufalloc_ref ba) +int bufalloc_flush (bufalloc *ba) { ba->p += allreadwrite((iofunc_t_ref)ba->op, ba->fd, ba->x.s + ba->p, ba->x.len - ba->p) ; bufalloc_clean(ba) ; diff --git a/src/libstddjb/bufalloc_init.c b/src/libstddjb/bufalloc_init.c index ddb6b6b..921dc3d 100644 --- a/src/libstddjb/bufalloc_init.c +++ b/src/libstddjb/bufalloc_init.c @@ -3,7 +3,7 @@ #include <skalibs/stralloc.h> #include <skalibs/bufalloc.h> -void bufalloc_init (bufalloc_ref ba, int (*op)(int, char const *, unsigned int), int fd) +void bufalloc_init (bufalloc *ba, int (*op)(int, char const *, unsigned int), int fd) { ba->x.len = 0 ; ba->op = op ; diff --git a/src/libstddjb/buffer_getall.c b/src/libstddjb/buffer_getall.c index 34db9df..4f1490b 100644 --- a/src/libstddjb/buffer_getall.c +++ b/src/libstddjb/buffer_getall.c @@ -4,7 +4,7 @@ #include <skalibs/allreadwrite.h> #include <skalibs/buffer.h> -int buffer_getall (buffer_ref b, char *buf, unsigned int len, unsigned int *w) +int buffer_getall (buffer *b, char *buf, unsigned int len, unsigned int *w) { if (*w > len) return (errno = EINVAL, -1) ; *w += buffer_getnofill(b, buf + *w, len - *w) ; diff --git a/src/libstddjb/buffer_getallnf.c b/src/libstddjb/buffer_getallnf.c index 8a97a31..be46196 100644 --- a/src/libstddjb/buffer_getallnf.c +++ b/src/libstddjb/buffer_getallnf.c @@ -3,7 +3,7 @@ #include <errno.h> #include <skalibs/buffer.h> -int buffer_getallnofill (buffer_ref b, char *s, unsigned int len) +int buffer_getallnofill (buffer *b, char *s, unsigned int len) { register unsigned int r = buffer_getnofill(b, s, len) ; if (r < len) diff --git a/src/libstddjb/buffer_getvallnf.c b/src/libstddjb/buffer_getvallnf.c index 2f4b82d..15f6c3d 100644 --- a/src/libstddjb/buffer_getvallnf.c +++ b/src/libstddjb/buffer_getvallnf.c @@ -4,7 +4,7 @@ #include <skalibs/buffer.h> #include <skalibs/siovec.h> -int buffer_getvallnofill (buffer_ref b, siovec_t const *v, unsigned int n) +int buffer_getvallnofill (buffer *b, siovec_t const *v, unsigned int n) { register unsigned int r = buffer_getvnofill(b, v, n) ; if (r < siovec_len(v, n)) diff --git a/src/libstddjb/iobuffer_flush.c b/src/libstddjb/iobuffer_flush.c index 543744b..93efc9d 100644 --- a/src/libstddjb/iobuffer_flush.c +++ b/src/libstddjb/iobuffer_flush.c @@ -3,7 +3,7 @@ #include <errno.h> #include <skalibs/iobuffer.h> -int iobuffer_flush (iobuffer_ref b) +int iobuffer_flush (iobuffer *b) { if (b->isk) { diff --git a/src/libstddjb/iobuffer_init.c b/src/libstddjb/iobuffer_init.c index 561379a..fc699a0 100644 --- a/src/libstddjb/iobuffer_init.c +++ b/src/libstddjb/iobuffer_init.c @@ -2,7 +2,7 @@ #include <skalibs/iobuffer.h> -int iobuffer_init (iobuffer_ref b, int fdin, int fdout) +int iobuffer_init (iobuffer *b, int fdin, int fdout) { if (!iobufferk_init(&b->x.k, fdin, fdout)) goto user ; if (!iobufferk_isworking(&b->x.k)) goto fk ; diff --git a/src/libstddjb/iobuffer_kfromu.c b/src/libstddjb/iobuffer_kfromu.c index 28785e6..7f2feda 100644 --- a/src/libstddjb/iobuffer_kfromu.c +++ b/src/libstddjb/iobuffer_kfromu.c @@ -11,7 +11,7 @@ #include <skalibs/iobuffer.h> #include <skalibs/siovec.h> -int iobuffer_kfromu (iobufferk_ref k, iobufferu_ref u) +int iobuffer_kfromu (iobufferk *k, iobufferu *u) { struct iovec iov[2] ; siovec_t v[2] ; @@ -31,7 +31,7 @@ int iobuffer_kfromu (iobufferk_ref k, iobufferu_ref u) #include <errno.h> #include <skalibs/iobuffer.h> -int iobuffer_kfromu (iobufferk_ref k, iobufferu_ref u) +int iobuffer_kfromu (iobufferk *k, iobufferu *u) { (void)k ; (void)u ; diff --git a/src/libstddjb/iobuffer_salvage.c b/src/libstddjb/iobuffer_salvage.c index b434568..6f2c5d8 100644 --- a/src/libstddjb/iobuffer_salvage.c +++ b/src/libstddjb/iobuffer_salvage.c @@ -2,7 +2,7 @@ #include <skalibs/iobuffer.h> -int iobuffer_salvage (iobuffer_ref b) +int iobuffer_salvage (iobuffer *b) { iobufferu u ; if (!b->isk) return 1 ; diff --git a/src/libstddjb/iobuffer_ufromk.c b/src/libstddjb/iobuffer_ufromk.c index efb0368..778ddf2 100644 --- a/src/libstddjb/iobuffer_ufromk.c +++ b/src/libstddjb/iobuffer_ufromk.c @@ -6,7 +6,7 @@ #include <skalibs/iobuffer.h> -int iobuffer_ufromk (iobufferu_ref u, iobufferk_ref k) +int iobuffer_ufromk (iobufferu *u, iobufferk *k) { int in = u->b[0].fd ; u->b[0].fd = k->p[0] ; @@ -29,7 +29,7 @@ int iobuffer_ufromk (iobufferu_ref u, iobufferk_ref k) #include <errno.h> #include <skalibs/iobuffer.h> -int iobuffer_ufromk (iobufferu_ref u, iobufferk_ref k) +int iobuffer_ufromk (iobufferu *u, iobufferk *k) { (void)u ; (void)k ; diff --git a/src/libstddjb/iobufferk_fill.c b/src/libstddjb/iobufferk_fill.c index 50ac403..c811c24 100644 --- a/src/libstddjb/iobufferk_fill.c +++ b/src/libstddjb/iobufferk_fill.c @@ -9,14 +9,14 @@ #include <errno.h> #include <skalibs/iobuffer.h> -static int iobufferk_tee (iobufferk_ref k) +static int iobufferk_tee (iobufferk *k) { register int r = tee(k->fd[0], k->fd[1], IOBUFFERK_SIZE - k->n, k->nb & 1 ? SPLICE_F_NONBLOCK : 0) ; if (r > 0) k->n += r ; return r ; } -static int iobufferk_splice (iobufferk_ref k) +static int iobufferk_splice (iobufferk *k) { register int r = splice(k->fd[0], 0, k->fd[1], 0, IOBUFFERK_SIZE, k->nb ? SPLICE_F_NONBLOCK : 0) ; if (r > 0) k->n += r ; @@ -24,7 +24,7 @@ static int iobufferk_splice (iobufferk_ref k) return r ; } -static int iobufferk_fill_3 (iobufferk_ref k) +static int iobufferk_fill_3 (iobufferk *k) { register int r = splice(k->fd[0], 0, k->p[1], 0, IOBUFFERK_SIZE - k->n, k->nb & 1 ? SPLICE_F_NONBLOCK : 0) ; if (r > 0) k->n += r ; diff --git a/src/libstddjb/iobufferk_finish.c b/src/libstddjb/iobufferk_finish.c index ef20d57..f743328 100644 --- a/src/libstddjb/iobufferk_finish.c +++ b/src/libstddjb/iobufferk_finish.c @@ -8,19 +8,19 @@ #include <skalibs/djbunix.h> #include <skalibs/iobuffer.h> -static void iobufferk_nop (iobufferk_ref k) +static void iobufferk_nop (iobufferk *k) { (void)k ; } -static void iobufferk_finish_0 (iobufferk_ref k) +static void iobufferk_finish_0 (iobufferk *k) { register int e = errno ; fd_close(k->p[1]) ; errno = e ; } -static void iobufferk_finish_3 (iobufferk_ref k) +static void iobufferk_finish_3 (iobufferk *k) { register int e = errno ; fd_close(k->p[1]) ; @@ -37,7 +37,7 @@ iobufferk_finish_func_t_ref const iobufferk_finish_f[4] = #include <skalibs/iobuffer.h> -static void iobufferk_nop (iobufferk_ref k) +static void iobufferk_nop (iobufferk *k) { (void)k ; } diff --git a/src/libstddjb/iobufferk_init.c b/src/libstddjb/iobufferk_init.c index 03f7fae..7affabd 100644 --- a/src/libstddjb/iobufferk_init.c +++ b/src/libstddjb/iobufferk_init.c @@ -9,7 +9,7 @@ #include <skalibs/djbunix.h> #include <skalibs/iobuffer.h> -static int iobufferk_init_0 (iobufferk_ref k) +static int iobufferk_init_0 (iobufferk *k) { register int fd = open_write("/dev/null") ; if (fd < 0) return 0 ; @@ -23,13 +23,13 @@ static int iobufferk_init_0 (iobufferk_ref k) return 1 ; } -static int iobufferk_nofd (iobufferk_ref k) +static int iobufferk_nofd (iobufferk *k) { k->p[0] = k->p[1] = -1 ; return 1 ; } -static int iobufferk_init_3 (iobufferk_ref k) +static int iobufferk_init_3 (iobufferk *k) { return (pipenbcoe(k->p) >= 0) ; } @@ -39,7 +39,7 @@ static iobufferk_io_func_t_ref iobufferk_init_f[4] = &iobufferk_init_0, &iobufferk_nofd, &iobufferk_nofd, &iobufferk_init_3 } ; -int iobufferk_init (iobufferk_ref k, int fdin, int fdout) +int iobufferk_init (iobufferk *k, int fdin, int fdout) { iobufferk tmp ; struct stat st ; @@ -67,7 +67,7 @@ int iobufferk_init (iobufferk_ref k, int fdin, int fdout) #include <errno.h> #include <skalibs/iobuffer.h> -int iobufferk_init (iobufferk_ref k, int fdin, int fdout) +int iobufferk_init (iobufferk *k, int fdin, int fdout) { (void)k ; (void)fdin ; diff --git a/src/libstddjb/iobufferk_isworking.c b/src/libstddjb/iobufferk_isworking.c index f02b7e0..f671f81 100644 --- a/src/libstddjb/iobufferk_isworking.c +++ b/src/libstddjb/iobufferk_isworking.c @@ -9,7 +9,7 @@ #include <fcntl.h> #include <skalibs/iobuffer.h> -int iobufferk_isworking (iobufferk_ref k) +int iobufferk_isworking (iobufferk *k) { /* for now splice() with a length of 0 returns 0 no matter what, so this */ /* test is useless. splice() should test the underlying filesystems even */ @@ -38,7 +38,7 @@ int iobufferk_isworking (iobufferk_ref k) #include <skalibs/iobuffer.h> -int iobufferk_isworking (iobufferk_ref k) +int iobufferk_isworking (iobufferk *k) { (void)k ; return 0 ; diff --git a/src/libstddjb/iobufferk_nosys.c b/src/libstddjb/iobufferk_nosys.c index 46f8be4..363e400 100644 --- a/src/libstddjb/iobufferk_nosys.c +++ b/src/libstddjb/iobufferk_nosys.c @@ -3,7 +3,7 @@ #include <errno.h> #include <skalibs/iobuffer.h> -int iobufferk_nosys (iobufferk_ref k) +int iobufferk_nosys (iobufferk *k) { (void)k ; return (errno = ENOSYS, -1) ; diff --git a/src/libstddjb/iobufferu_fill.c b/src/libstddjb/iobufferu_fill.c index 7ebb67c..de1a56c 100644 --- a/src/libstddjb/iobufferu_fill.c +++ b/src/libstddjb/iobufferu_fill.c @@ -3,7 +3,7 @@ #include <skalibs/buffer.h> #include <skalibs/iobuffer.h> -int iobufferu_fill (iobufferu_ref b) +int iobufferu_fill (iobufferu *b) { register int r = buffer_fill(&b->b[0]) ; b->b[1].c.n = b->b[0].c.n ; diff --git a/src/libstddjb/iobufferu_finish.c b/src/libstddjb/iobufferu_finish.c index eb3749e..612ec18 100644 --- a/src/libstddjb/iobufferu_finish.c +++ b/src/libstddjb/iobufferu_finish.c @@ -3,7 +3,7 @@ #include <skalibs/alloc.h> #include <skalibs/iobuffer.h> -void iobufferu_finish (iobufferu_ref b) +void iobufferu_finish (iobufferu *b) { alloc_free(b->buf) ; } diff --git a/src/libstddjb/ip46_scanlist.c b/src/libstddjb/ip46_scanlist.c index 37f2e18..6462da7 100644 --- a/src/libstddjb/ip46_scanlist.c +++ b/src/libstddjb/ip46_scanlist.c @@ -5,7 +5,7 @@ #include <skalibs/bytestr.h> #include <skalibs/fmtscan.h> -unsigned int ip46full_scanlist (ip46full_t_ref out, unsigned int max, char const *s, unsigned int *num) +unsigned int ip46full_scanlist (ip46full_t *out, unsigned int max, char const *s, unsigned int *num) { unsigned int n = 0, w = 0 ; for (; s[w] && (n < max) ; n++) diff --git a/src/libstddjb/localtmn_from_sysclock.c b/src/libstddjb/localtmn_from_sysclock.c index 2d4e4fd..08e64b7 100644 --- a/src/libstddjb/localtmn_from_sysclock.c +++ b/src/libstddjb/localtmn_from_sysclock.c @@ -3,7 +3,7 @@ #include <skalibs/tai.h> #include <skalibs/djbtime.h> -int localtmn_from_sysclock (localtmn_t_ref l, tain_t const *a, int tz) +int localtmn_from_sysclock (localtmn_t *l, tain_t const *a, int tz) { struct tm t ; if (!localtm_from_sysclock(&t, a->sec.x, tz)) return 0 ; diff --git a/src/libstddjb/localtmn_from_tain.c b/src/libstddjb/localtmn_from_tain.c index a3d3f6e..78cc051 100644 --- a/src/libstddjb/localtmn_from_tain.c +++ b/src/libstddjb/localtmn_from_tain.c @@ -3,7 +3,7 @@ #include <skalibs/tai.h> #include <skalibs/djbtime.h> -int localtmn_from_tain (localtmn_t_ref l, tain_t const *a, int tz) +int localtmn_from_tain (localtmn_t *l, tain_t const *a, int tz) { struct tm t ; if (!localtm_from_tai(&t, tain_secp(a), tz)) return 0 ; diff --git a/src/libstddjb/localtmn_scan.c b/src/libstddjb/localtmn_scan.c index f33ab51..087c642 100644 --- a/src/libstddjb/localtmn_scan.c +++ b/src/libstddjb/localtmn_scan.c @@ -3,7 +3,7 @@ #include <skalibs/uint32.h> #include <skalibs/djbtime.h> -unsigned int localtmn_scan (char const *s, localtmn_t_ref l) +unsigned int localtmn_scan (char const *s, localtmn_t *l) { localtmn_t m ; unsigned int n = localtm_scan(s, &m.tm) ; diff --git a/src/libstddjb/socket_local46.c b/src/libstddjb/socket_local46.c index a53bcac..6235527 100644 --- a/src/libstddjb/socket_local46.c +++ b/src/libstddjb/socket_local46.c @@ -10,7 +10,7 @@ #ifdef SKALIBS_IPV6_ENABLED -int socket_local46 (int s, ip46_t_ref ip, uint16 *port) +int socket_local46 (int s, ip46_t *ip, uint16 *port) { struct sockaddr sa ; socklen_t dummy = sizeof sa ; diff --git a/src/libstddjb/socket_remote46.c b/src/libstddjb/socket_remote46.c index 835b7c9..bf6b934 100644 --- a/src/libstddjb/socket_remote46.c +++ b/src/libstddjb/socket_remote46.c @@ -10,7 +10,7 @@ #ifdef SKALIBS_IPV6_ENABLED -int socket_remote46 (int s, ip46_t_ref ip, uint16 *port) +int socket_remote46 (int s, ip46_t *ip, uint16 *port) { struct sockaddr sa ; socklen_t dummy = sizeof sa ; diff --git a/src/libstddjb/subgetopt.c b/src/libstddjb/subgetopt.c index 69201c6..67cdfa1 100644 --- a/src/libstddjb/subgetopt.c +++ b/src/libstddjb/subgetopt.c @@ -3,7 +3,7 @@ #undef SUBGETOPT_SHORT #include <skalibs/sgetopt.h> -int subgetopt_r (int argc, char const *const *argv, char const *opts, subgetopt_t_ref o) +int subgetopt_r (int argc, char const *const *argv, char const *opts, subgetopt_t *o) { o->arg = 0 ; if ((o->ind >= argc) || !argv[o->ind]) return -1 ; |