diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2021-07-28 23:45:20 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2021-07-28 23:45:20 +0000 |
commit | 9592bfd0dda7c575de07bce2c7a81b8432d845a4 (patch) | |
tree | 57c66c3e0dfeb63cfd3ebfef18e30a2145ae3f88 /src | |
parent | c15bccec3fd551583ff838673ba284ee6c7e788a (diff) | |
download | skalibs-9592bfd0dda7c575de07bce2c7a81b8432d845a4.tar.xz |
Huge incompatible changes.
- Obsolete skalibs/environ.h and skalibs/getpeereid.h removed.
- rc4 and md5 removed.
- All *_t types renamed to avoid treading on POSIX namespace.
- subgetopt() renamed to lgetopt().
- signal functions reworked; skasigaction removed; sig_stack removed
- Various functions removed: skaoffsetof(), selfpipe_untrap()
- New posixplz function: munmap_void.
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src')
364 files changed, 1068 insertions, 1690 deletions
diff --git a/src/headers/bits-header b/src/headers/bits-header index e96eecc..96c422a 100644 --- a/src/headers/bits-header +++ b/src/headers/bits-header @@ -1,7 +1,7 @@ /* ISC license. */ -#ifndef UINT@BITS@_H -#define UINT@BITS@_H +#ifndef SKALIBS_UINT@BITS@_H +#define SKALIBS_UINT@BITS@_H #include <stddef.h> #include <stdint.h> diff --git a/src/headers/ip46-footer b/src/headers/ip46-footer index 4be22b5..a1062bf 100644 --- a/src/headers/ip46-footer +++ b/src/headers/ip46-footer @@ -4,7 +4,7 @@ #define socket_recvnb46_g(fd, buf, len, i, port, deadline) socket_recvnb46(fd, buf, len, i, port, (deadline), &STAMP) #define socket_sendnb46_g(fd, buf, len, i, port, deadline) socket_sendnb46(fd, buf, len, i, port, (deadline), &STAMP) -extern int socket_deadlineconnstamp46 (int, ip46_t const *, uint16_t, tain_t const *, tain_t *) ; +extern int socket_deadlineconnstamp46 (int, ip46 const *, uint16_t, tain const *, tain *) ; #define socket_deadlineconnstamp46_g(fd, ip, port, deadline) socket_deadlineconnstamp46(fd, ip, port, (deadline), &STAMP) #endif diff --git a/src/headers/ip46-header b/src/headers/ip46-header index 3f872be..82c5e81 100644 --- a/src/headers/ip46-header +++ b/src/headers/ip46-header @@ -1,11 +1,12 @@ /* ISC license. */ -#ifndef IP46_H -#define IP46_H +#ifndef SKALIBS_IP46_H +#define SKALIBS_IP46_H #include <string.h> #include <stdint.h> #include <errno.h> + #include <skalibs/fmtscan.h> #include <skalibs/socket.h> @@ -15,7 +16,7 @@ #define IP4_LOCAL "\177\0\0\1" #define IP6_LOCAL "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1" -typedef struct ip46full_s ip46full_t, *ip46full_t_ref ; +typedef struct ip46full_s ip46full, *ip46full_ref ; struct ip46full_s { @@ -26,8 +27,8 @@ struct ip46full_s #define ip46full_is6(i) ((i)->is6) #define ip46full_fmt(s, i) ((i)->is6 ? ip6_fmt(s, (i)->ip) : ip4_fmt(s, (i)->ip)) -extern size_t ip46full_scan (char const *, ip46full_t *) ; -extern size_t ip46full_scanlist (ip46full_t *, size_t, char const *, size_t *) ; +extern size_t ip46full_scan (char const *, ip46full *) ; +extern size_t ip46full_scanlist (ip46full *, size_t, char const *, size_t *) ; #define ip46full_from_ip4(i, ip4) (memcpy((i)->ip, ip4, 4), memset((i)->ip + 4, 0, 12), (i)->is6 = 0) #define ip46full_from_ip6(i, ip6) (memcpy((i)->ip, ip6, 16), (i)->is6 = 1) diff --git a/src/headers/ip46-with b/src/headers/ip46-with index 9570ffa..14ac5bd 100644 --- a/src/headers/ip46-with +++ b/src/headers/ip46-with @@ -1,4 +1,4 @@ -typedef ip46full_t ip46_t, *ip46_t_ref ; +typedef ip46full ip46, *ip46_ref ; #define IP46_ZERO IP46FULL_ZERO #define SKALIBS_IPV6_ENABLED @@ -17,8 +17,8 @@ typedef ip46full_t ip46_t, *ip46_t_ref ; #define socket_udp46(h) ((h) ? socket_udp6() : socket_udp4()) #define socket_recv46(fd, s, len, i, port) ((i)->is6 ? socket_recv6(fd, s, len, (i)->ip, port) : socket_recv4(fd, s, len, (i)->ip, port)) #define socket_send46(fd, s, len, i, port) ((i)->is6 ? socket_send6(fd, s, len, (i)->ip, port) : socket_send4(fd, s, len, (i)->ip, port)) -extern int socket_local46 (int, ip46_t *, uint16_t *) ; -extern int socket_remote46 (int, ip46_t *, uint16_t *) ; +extern int socket_local46 (int, ip46 *, uint16_t *) ; +extern int socket_remote46 (int, ip46 *, uint16_t *) ; #define socket_recvnb46(fd, buf, len, i, port, deadline, stamp) ((i)->is6 ? socket_recvnb6(fd, buf, len, (i)->ip, port, deadline, stamp) : socket_recvnb4(fd, buf, len, (i)->ip, port, deadline, stamp)) #define socket_sendnb46(fd, buf, len, i, port, deadline, stamp) ((i)->is6 ? socket_sendnb6(fd, buf, len, (i)->ip, port, deadline, stamp) : socket_sendnb4(fd, buf, len, (i)->ip, port, deadline, stamp)) diff --git a/src/headers/ip46-without b/src/headers/ip46-without index c06106b..43d3038 100644 --- a/src/headers/ip46-without +++ b/src/headers/ip46-without @@ -1,4 +1,4 @@ -typedef struct ip46_s ip46_t, *ip46_t_ref ; +typedef struct ip46_s ip46, *ip46_ref ; struct ip46_s { char ip[4] ; diff --git a/src/headers/types-header b/src/headers/types-header index 015bb08..c3b3e76 100644 --- a/src/headers/types-header +++ b/src/headers/types-header @@ -5,6 +5,7 @@ #include <sys/types.h> #include <stdint.h> + #include <skalibs/uint16.h> #include <skalibs/uint32.h> #include <skalibs/uint64.h> diff --git a/src/include/skalibs/alarm.h b/src/include/skalibs/alarm.h index 9c2951a..22f8d4c 100644 --- a/src/include/skalibs/alarm.h +++ b/src/include/skalibs/alarm.h @@ -1,13 +1,13 @@ /* ISC license. */ -#ifndef ALARM_H -#define ALARM_H +#ifndef SKALIBS_ALARM_H +#define SKALIBS_ALARM_H #include <skalibs/tai.h> extern int alarm_milliseconds (unsigned int) ; -extern int alarm_timeout (tain_t const *) ; -extern int alarm_deadline (tain_t const *) ; +extern int alarm_timeout (tain const *) ; +extern int alarm_deadline (tain const *) ; extern void alarm_disable (void) ; #endif diff --git a/src/include/skalibs/alloc.h b/src/include/skalibs/alloc.h index 642dc65..b5c0cec 100644 --- a/src/include/skalibs/alloc.h +++ b/src/include/skalibs/alloc.h @@ -1,9 +1,10 @@ /* ISC license. */ -#ifndef ALLOC_H -#define ALLOC_H +#ifndef SKALIBS_ALLOC_H +#define SKALIBS_ALLOC_H #include <stdlib.h> + #include <skalibs/gccattributes.h> extern void *alloc (size_t) ; diff --git a/src/include/skalibs/allreadwrite.h b/src/include/skalibs/allreadwrite.h index 3df1ed1..c0a97fb 100644 --- a/src/include/skalibs/allreadwrite.h +++ b/src/include/skalibs/allreadwrite.h @@ -1,16 +1,17 @@ /* ISC license. */ -#ifndef ALLREADWRITE_H -#define ALLREADWRITE_H +#ifndef SKALIBS_ALLREADWRITE_H +#define SKALIBS_ALLREADWRITE_H #include <sys/uio.h> + #include <skalibs/functypes.h> extern ssize_t sanitize_read (ssize_t) ; extern ssize_t unsanitize_read (ssize_t) ; -extern size_t allreadwrite (iofunc_t_ref, int, char *, size_t) ; -extern size_t allreadwritev (iovfunc_t_ref, int, struct iovec const *, unsigned int) ; +extern size_t allreadwrite (io_func_ref, int, char *, size_t) ; +extern size_t allreadwritev (iov_func_ref, int, struct iovec const *, unsigned int) ; extern ssize_t fd_read (int, char *, size_t) ; extern ssize_t fd_write (int, char const *, size_t) ; diff --git a/src/include/skalibs/avlnode.h b/src/include/skalibs/avlnode.h index 554a185..42c544b 100644 --- a/src/include/skalibs/avlnode.h +++ b/src/include/skalibs/avlnode.h @@ -1,17 +1,18 @@ /* ISC license. */ -#ifndef AVLNODE_H -#define AVLNODE_H +#ifndef SKALIBS_AVLNODE_H +#define SKALIBS_AVLNODE_H #include <stdint.h> + #include <skalibs/gccattributes.h> #include <skalibs/functypes.h> #define AVLNODE_MAXDEPTH 49 /* enough for 2^32 nodes in the worst case */ -typedef int avliterfunc_t (uint32_t, unsigned int, void *) ; -typedef avliterfunc_t *avliterfunc_t_ref ; +typedef int avliter_func (uint32_t, unsigned int, void *) ; +typedef avliter_func *avliter_func_ref ; typedef struct avlnode_s avlnode, *avlnode_ref ; struct avlnode_s @@ -24,8 +25,8 @@ struct avlnode_s #define AVLNODE_ZERO { .data = 0, .child = { UINT32_MAX, UINT32_MAX }, .balance = 0 } extern avlnode const avlnode_zero ; -extern uint32_t avlnode_searchnode (avlnode const *, uint32_t, uint32_t, void const *, dtokfunc_t_ref, cmpfunc_t_ref, void *) ; -extern int avlnode_search (avlnode const *, uint32_t, uint32_t, void const *, uint32_t *, dtokfunc_t_ref, cmpfunc_t_ref, void *) ; +extern uint32_t avlnode_searchnode (avlnode const *, uint32_t, uint32_t, void const *, dtok_func_ref, cmp_func_ref, void *) ; +extern int avlnode_search (avlnode const *, uint32_t, uint32_t, void const *, uint32_t *, dtok_func_ref, cmp_func_ref, void *) ; extern unsigned int avlnode_height (avlnode const *, uint32_t, uint32_t) gccattr_pure ; extern uint32_t avlnode_extremenode (avlnode const *, uint32_t, uint32_t, int) gccattr_pure ; @@ -36,11 +37,11 @@ extern int avlnode_extreme (avlnode const *, uint32_t, uint32_t, int, uint32_t * #define avlnode_min(s, max, r, data) avlnode_extreme(s, max, (r), 0, data) #define avlnode_max(s, max, r, data) avlnode_extreme(s, max, (r), 1, data) -extern uint32_t avlnode_insertnode (avlnode *, uint32_t, uint32_t, uint32_t, dtokfunc_t_ref, cmpfunc_t_ref, void *) ; -extern uint32_t avlnode_delete (avlnode *, uint32_t, uint32_t *, void const *, dtokfunc_t_ref, cmpfunc_t_ref, void *) ; +extern uint32_t avlnode_insertnode (avlnode *, uint32_t, uint32_t, uint32_t, dtok_func_ref, cmp_func_ref, void *) ; +extern uint32_t avlnode_delete (avlnode *, uint32_t, uint32_t *, void const *, dtok_func_ref, cmp_func_ref, void *) ; -extern uint32_t avlnode_iter_nocancel (avlnode *, uint32_t, uint32_t, uint32_t, avliterfunc_t_ref, void *) ; +extern uint32_t avlnode_iter_nocancel (avlnode *, uint32_t, uint32_t, uint32_t, avliter_func_ref, void *) ; #define avlnode_iter(tree, max, root, f, stuff) (avlnode_iter_nocancel(tree, max, max, root, f, stuff) == (max)) -extern int avlnode_iter_withcancel (avlnode *, uint32_t, uint32_t, avliterfunc_t_ref, avliterfunc_t_ref, void *) ; +extern int avlnode_iter_withcancel (avlnode *, uint32_t, uint32_t, avliter_func_ref, avliter_func_ref, void *) ; #endif diff --git a/src/include/skalibs/avltree.h b/src/include/skalibs/avltree.h index fe8be43..5840395 100644 --- a/src/include/skalibs/avltree.h +++ b/src/include/skalibs/avltree.h @@ -1,9 +1,10 @@ /* ISC license. */ -#ifndef AVLTREE_H -#define AVLTREE_H +#ifndef SKALIBS_AVLTREE_H +#define SKALIBS_AVLTREE_H #include <stdint.h> + #include <skalibs/functypes.h> #include <skalibs/gensetdyn.h> #include <skalibs/avlnode.h> @@ -13,8 +14,8 @@ struct avltree_s { gensetdyn x ; uint32_t root ; - dtokfunc_t_ref dtok ; - cmpfunc_t_ref kcmp ; + dtok_func_ref dtok ; + cmp_func_ref kcmp ; void *external ; } ; @@ -28,7 +29,7 @@ extern avltree const avltree_zero ; #define avltree_setroot(t, r) ((t)->root = (r)) extern void avltree_free (avltree *) ; -extern void avltree_init (avltree *, uint32_t, uint32_t, uint32_t, dtokfunc_t_ref, cmpfunc_t_ref, void *) ; +extern void avltree_init (avltree *, uint32_t, uint32_t, uint32_t, dtok_func_ref, cmp_func_ref, void *) ; #define AVLTREE_INIT(b, num, den, dtk, f, p) { .x = GENSETDYN_INIT(avlnode, (b), num, den), .root = UINT32_MAX, .dtok = (dtk), .kcmp = (f), .external = (p) } #define avltree_searchnode(t, k) avlnode_searchnode(avltree_nodes(t), avltree_totalsize(t), avltree_root(t), k, (t)->dtok, (t)->kcmp, (t)->external) diff --git a/src/include/skalibs/avltreen.h b/src/include/skalibs/avltreen.h index 51e8fd0..511452d 100644 --- a/src/include/skalibs/avltreen.h +++ b/src/include/skalibs/avltreen.h @@ -1,9 +1,10 @@ /* ISC license. */ -#ifndef AVLTREEN_H -#define AVLTREEN_H +#ifndef SKALIBS_AVLTREEN_H +#define SKALIBS_AVLTREEN_H #include <stdint.h> + #include <skalibs/functypes.h> #include <skalibs/genset.h> #include <skalibs/avlnode.h> @@ -21,8 +22,8 @@ struct avltreen_s { genset x ; uint32_t root ; - dtokfunc_t_ref dtok ; - cmpfunc_t_ref kcmp ; + dtok_func_ref dtok ; + cmp_func_ref kcmp ; void *external ; } ; @@ -33,7 +34,7 @@ struct avltreen_s #define avltreen_data(t, i) (avltreen_nodes(t)[i].data) #define avltreen_root(t) ((t)->root) #define avltreen_setroot(t, r) ((t)->root = (r)) -extern void avltreen_init (avltreen *, avlnode *, uint32_t *, uint32_t, dtokfunc_t_ref, cmpfunc_t_ref, void *) ; +extern void avltreen_init (avltreen *, avlnode *, uint32_t *, uint32_t, dtok_func_ref, cmp_func_ref, void *) ; #define AVLTREEN_DECLARE_AND_INIT(name, size, dtk, cmp, p) \ avlnode name##_storage[size] ; \ diff --git a/src/include/skalibs/bigkv.h b/src/include/skalibs/bigkv.h index 1b6229b..b45211a 100644 --- a/src/include/skalibs/bigkv.h +++ b/src/include/skalibs/bigkv.h @@ -10,7 +10,7 @@ #include <skalibs/genalloc.h> #include <skalibs/avltree.h> -typedef struct bigkv_node_s bigkv_node_t, *bigkv_node_t_ref ; +typedef struct bigkv_node_s bigkv_node, *bigkv_node_ref ; struct bigkv_node_s { size_t k ; @@ -18,25 +18,25 @@ struct bigkv_node_s } ; #define BIGKV_NODE_ZERO { .k = 0, .v = 0 } -typedef struct bigkv_s bigkv_t, *bigkv_t_ref ; +typedef struct bigkv_s bigkv, *bigkv_ref ; struct bigkv_s { stralloc storage ; - genalloc nodes ; /* bigkv_node_t */ + genalloc nodes ; /* bigkv_node */ avltree map ; } ; #define BIGKV_ZERO { .storage = STRALLOC_ZERO, .nodes = GENALLOC_ZERO, .map = AVLTREE_ZERO } -extern bigkv_t const bigkv_zero ; +extern bigkv const bigkv_zero ; #define BIGKV_OPTIONS_NODUP 0x00000001u #define bigkv_len(b) avltree_len(&(b)->map) #define bigkv_init(b) (*(b) = bigkv_zero) -extern int bigkv_fill (bigkv_t *, char const *const *, char, char const *, char const *, uint32_t) ; +extern int bigkv_fill (bigkv *, char const *const *, char, char const *, char const *, uint32_t) ; #define bigkv_fill_argv(b, argv) bigkv_fill(b, (argv), '=', "--", "--", 0) #define bigkv_fill_envp(b, envp) bigkv_fill(b, (envp), '=', 0, 0, 0) -extern char const *bigkv_search (bigkv_t const *, char const *) ; -extern void bigkv_free (bigkv_t *) ; +extern char const *bigkv_search (bigkv const *, char const *) ; +extern void bigkv_free (bigkv *) ; #endif diff --git a/src/include/skalibs/biguint.h b/src/include/skalibs/biguint.h deleted file mode 100644 index 66dbd1d..0000000 --- a/src/include/skalibs/biguint.h +++ /dev/null @@ -1,47 +0,0 @@ -/* ISC license. */ - -#ifndef BIGUINT_H -#define BIGUINT_H - -#include <sys/types.h> -#include <stdint.h> -#include <skalibs/gccattributes.h> - -extern void bu_pack (char *, uint32_t const *, unsigned int) ; -extern void bu_unpack (char const *, uint32_t *, unsigned int) ; -extern void bu_pack_big (char *, uint32_t const *, unsigned int) ; -extern void bu_unpack_big (char const *, uint32_t *, unsigned int) ; -extern size_t bu_fmt (char *, uint32_t const *, unsigned int) ; -extern size_t bu_scanlen (char const *, size_t *) ; -extern int bu_scan (char const *, size_t, uint32_t *, unsigned int, size_t) ; - -extern unsigned int bu_len (uint32_t const *, unsigned int) gccattr_pure ; -extern void bu_zero (uint32_t *, unsigned int) ; -extern int bu_copy (uint32_t *, unsigned int, uint32_t const *, unsigned int) ; -extern int bu_cmp (uint32_t const *, unsigned int, uint32_t const *, unsigned int) gccattr_pure ; - -#define bu_add(c, cn, a, an, b, bn) bu_addc(c, cn, a, an, b, (bn), 0) -extern int bu_addc (uint32_t *, unsigned int, uint32_t const *, unsigned int, uint32_t const *, unsigned int, int) ; -#define bu_sub(c, cn, a, an, b, bn) bu_subc(c, cn, a, an, b, (bn), 0) -extern int bu_subc (uint32_t *, unsigned int, uint32_t const *, unsigned int, uint32_t const *, unsigned int, int) ; -extern int bu_mul (uint32_t *, unsigned int, uint32_t const *, unsigned int, uint32_t const *, unsigned int) ; -extern int bu_div (uint32_t const *, unsigned int, uint32_t const *, unsigned int, uint32_t *, unsigned int, uint32_t *, unsigned int) ; -extern int bu_mod (uint32_t *, unsigned int, uint32_t const *, unsigned int) ; -extern int bu_gcd (uint32_t *, unsigned int, uint32_t const *, unsigned int, uint32_t const *, unsigned int) ; - -#define bu_slb(a, n) bu_slbc(a, n, 0) -extern int bu_slbc (uint32_t *, unsigned int, int) ; -#define bu_srb(a, n) bu_srbc(a, n, 0) -extern int bu_srbc (uint32_t *, unsigned int, int) ; - -extern int bu_addmod (uint32_t *, unsigned int, uint32_t const *, unsigned int, uint32_t const *, unsigned int, uint32_t const *, unsigned int) ; -extern int bu_submod (uint32_t *, unsigned int, uint32_t const *, unsigned int, uint32_t const *, unsigned int, uint32_t const *, unsigned int) ; -extern int bu_invmod (uint32_t *, unsigned int, uint32_t const *, unsigned int) ; -extern int bu_divmod (uint32_t *, unsigned int, uint32_t const *, unsigned int, uint32_t const *, unsigned int, uint32_t const *, unsigned int) ; - -extern void bu_scan_internal (char const *, size_t, uint32_t *) ; -extern void bu_copy_internal (uint32_t *, uint32_t const *, unsigned int) ; -extern void bu_div_internal (uint32_t *, unsigned int, uint32_t const *, unsigned int, uint32_t *, unsigned int) ; -extern void bu_divmod_internal (uint32_t *, uint32_t *, uint32_t const *, unsigned int) ; - -#endif diff --git a/src/include/skalibs/bitarray.h b/src/include/skalibs/bitarray.h index b333425..3ce7fc2 100644 --- a/src/include/skalibs/bitarray.h +++ b/src/include/skalibs/bitarray.h @@ -1,9 +1,10 @@ /* ISC license. */ -#ifndef BITARRAY_H -#define BITARRAY_H +#ifndef SKALIBS_BITARRAY_H +#define SKALIBS_BITARRAY_H #include <string.h> + #include <skalibs/gccattributes.h> #define bitarray_div8(n) ((n) ? 1U + (((n) - 1) >> 3) : 0U) diff --git a/src/include/skalibs/bufalloc.h b/src/include/skalibs/bufalloc.h index b87f125..9b66dff 100644 --- a/src/include/skalibs/bufalloc.h +++ b/src/include/skalibs/bufalloc.h @@ -1,24 +1,26 @@ /* ISC license. */ -#ifndef BUFALLOC_H -#define BUFALLOC_H +#ifndef SKALIBS_BUFALLOC_H +#define SKALIBS_BUFALLOC_H #include <sys/types.h> + #include <skalibs/gccattributes.h> +#include <skalibs/functypes.h> #include <skalibs/stralloc.h> -typedef struct bufalloc bufalloc, *bufalloc_ref ; -struct bufalloc +typedef struct bufalloc_s bufalloc, *bufalloc_ref ; +struct bufalloc_s { stralloc x ; size_t p ; int fd ; - ssize_t (*op) (int, char const *, size_t) ; + iow_func_ref op ; } ; #define BUFALLOC_ZERO { STRALLOC_ZERO, 0, -1, 0 } #define BUFALLOC_INIT(f, d) { STRALLOC_ZERO, 0, (d), (f) } -extern void bufalloc_init (bufalloc *, ssize_t (*)(int, char const *, size_t), int) ; +extern void bufalloc_init (bufalloc *, iow_func_ref, int) ; #define bufalloc_shrink(ba) stralloc_shrink(&(ba)->x) #define bufalloc_free(ba) stralloc_free(&(ba)->x) #define bufalloc_put(ba, s, n) stralloc_catb(&(ba)->x, s, n) diff --git a/src/include/skalibs/buffer.h b/src/include/skalibs/buffer.h index 63d8176..fe38120 100644 --- a/src/include/skalibs/buffer.h +++ b/src/include/skalibs/buffer.h @@ -1,20 +1,21 @@ /* ISC license. */ -#ifndef BUFFER_H -#define BUFFER_H +#ifndef SKALIBS_BUFFER_H +#define SKALIBS_BUFFER_H #include <sys/uio.h> + #include <skalibs/gccattributes.h> #include <skalibs/allreadwrite.h> #include <skalibs/cbuffer.h> #include <skalibs/functypes.h> -typedef struct buffer_s buffer, buffer_t, *buffer_ref, *buffer_t_ref ; +typedef struct buffer_s buffer, *buffer_ref ; struct buffer_s { - iovfunc_t_ref op ; + iov_func_ref op ; int fd ; - cbuffer_t c ; + cbuffer c ; } ; #define BUFFER_ZERO { 0, -1, CBUFFER_ZERO } @@ -31,7 +32,7 @@ struct buffer_s #define BUFFER_OUTSIZE_SMALL 512 #define BUFFER_INIT(f, d, buf, len) { (f), (d), CBUFFER_INIT(buf, len) } -extern int buffer_init (buffer *, iovfunc_t_ref, int, char *, size_t) ; +extern int buffer_init (buffer *, iov_func_ref, int, char *, size_t) ; /* Writing */ @@ -105,7 +106,7 @@ extern int buffer_getfd (buffer const *) gccattr_pure ; #define buffer_read fd_readv #define buffer_write fd_writev -extern iovfunc_t buffer_flush1read ; +extern iov_func buffer_flush1read ; extern buffer buffer_0_ ; #define buffer_0 (&buffer_0_) diff --git a/src/include/skalibs/bytestr.h b/src/include/skalibs/bytestr.h index 4483e2c..78fb8a1 100644 --- a/src/include/skalibs/bytestr.h +++ b/src/include/skalibs/bytestr.h @@ -1,9 +1,8 @@ /* ISC license. */ -#ifndef BYTESTR_H -#define BYTESTR_H +#ifndef SKALIBS_BYTESTR_H +#define SKALIBS_BYTESTR_H -#include <skalibs/gccattributes.h> /* for Alphas and other archs where char != 8bit */ #define T8(x) ((x) & 0xffU) @@ -11,6 +10,8 @@ #include <string.h> #include <strings.h> +#include <skalibs/gccattributes.h> + #define byte_copy(to, n, from) memmove(to, (from), n) #define byte_copyr(to, n, from) memmove(to, (from), n) #define byte_diff(a, n, b) memcmp(a, (b), n) diff --git a/src/include/skalibs/cbuffer.h b/src/include/skalibs/cbuffer.h index a0615dc..2e960e2 100644 --- a/src/include/skalibs/cbuffer.h +++ b/src/include/skalibs/cbuffer.h @@ -1,13 +1,14 @@ /* ISC license. */ -#ifndef CBUFFER_H -#define CBUFFER_H +#ifndef SKALIBS_CBUFFER_H +#define SKALIBS_CBUFFER_H #include <sys/uio.h> #include <string.h> + #include <skalibs/gccattributes.h> -typedef struct cbuffer_s cbuffer_t, *cbuffer_t_ref ; +typedef struct cbuffer_s cbuffer, *cbuffer_ref ; struct cbuffer_s { char *x ; @@ -23,32 +24,32 @@ struct cbuffer_s */ #define CBUFFER_INIT(buf, len) { (buf), (len), 0, 0 } -extern int cbuffer_init (cbuffer_t *, char *, size_t) ; +extern int cbuffer_init (cbuffer *, char *, size_t) ; /* Writing */ -extern size_t cbuffer_put (cbuffer_t *, char const *, size_t) ; -extern size_t cbuffer_putv (cbuffer_t *, struct iovec const *, unsigned int) ; +extern size_t cbuffer_put (cbuffer *, char const *, size_t) ; +extern size_t cbuffer_putv (cbuffer *, struct iovec const *, unsigned int) ; #define cbuffer_puts(b, s) cbuffer_put(b, (s), strlen(s)) #define cbuffer_UNPUT(b, w) ((b)->n = ((b)->a + (b)->n - w) % (b)->a, w) ; -extern size_t cbuffer_unput (cbuffer_t *, size_t) ; -extern void cbuffer_wpeek (cbuffer_t const *, struct iovec *) ; +extern size_t cbuffer_unput (cbuffer *, size_t) ; +extern void cbuffer_wpeek (cbuffer const *, struct iovec *) ; #define cbuffer_WSEEK(b, w) ((b)->n = ((b)->n + (w)) % (b)->a, w) -extern size_t cbuffer_wseek (cbuffer_t *, size_t) ; +extern size_t cbuffer_wseek (cbuffer *, size_t) ; /* Reading */ -extern size_t cbuffer_get (cbuffer_t *, char *, size_t) ; -extern size_t cbuffer_getv (cbuffer_t *, struct iovec const *, unsigned int) ; +extern size_t cbuffer_get (cbuffer *, char *, size_t) ; +extern size_t cbuffer_getv (cbuffer *, struct iovec const *, unsigned int) ; #define cbuffer_UNGET(b, n) ((b)->p = ((b)->a + (b)->p - n) % (b)->a, n) ; -extern size_t cbuffer_unget (cbuffer_t *, size_t) ; -extern void cbuffer_rpeek (cbuffer_t const *, struct iovec *) ; +extern size_t cbuffer_unget (cbuffer *, size_t) ; +extern void cbuffer_rpeek (cbuffer const *, struct iovec *) ; #define cbuffer_RSEEK(b, n) ((b)->p = ((b)->p + (n)) % (b)->a, n) -extern size_t cbuffer_rseek (cbuffer_t *, size_t) ; +extern size_t cbuffer_rseek (cbuffer *, size_t) ; /* Utility */ diff --git a/src/include/skalibs/cdbmake.h b/src/include/skalibs/cdbmake.h index bf03ad6..26fcba5 100644 --- a/src/include/skalibs/cdbmake.h +++ b/src/include/skalibs/cdbmake.h @@ -4,6 +4,7 @@ #define SKALIBS_CDBMAKE_H #include <stdint.h> + #include <skalibs/diuint32.h> #include <skalibs/allreadwrite.h> #include <skalibs/genalloc.h> diff --git a/src/include/skalibs/datastruct.h b/src/include/skalibs/datastruct.h index 0f6c0f7..9b3091b 100644 --- a/src/include/skalibs/datastruct.h +++ b/src/include/skalibs/datastruct.h @@ -1,7 +1,7 @@ /* ISC license. */ -#ifndef DATASTRUCT_H -#define DATASTRUCT_H +#ifndef SKALIBS_DATASTRUCT_H +#define SKALIBS_DATASTRUCT_H #include <skalibs/genqdyn.h> #include <skalibs/genset.h> diff --git a/src/include/skalibs/direntry.h b/src/include/skalibs/direntry.h index 9f4615c..90201d1 100644 --- a/src/include/skalibs/direntry.h +++ b/src/include/skalibs/direntry.h @@ -1,11 +1,11 @@ /* ISC license. */ -#ifndef DIRENTRY_H -#define DIRENTRY_H +#ifndef SKALIBS_DIRENTRY_H +#define SKALIBS_DIRENTRY_H #include <dirent.h> -typedef struct dirent direntry, direntry_t, *direntry_ref, *direntry_t_ref ; +typedef struct dirent direntry, *direntry_ref ; extern void dir_close (DIR *) ; extern int dir_fd (DIR *) ; /* Solaris doesn't have dirfd() */ diff --git a/src/include/skalibs/disize.h b/src/include/skalibs/disize.h index 418b518..0b3cd23 100644 --- a/src/include/skalibs/disize.h +++ b/src/include/skalibs/disize.h @@ -1,7 +1,7 @@ /* ISC license. */ -#ifndef DISIZE_H -#define DISIZE_H +#ifndef SKALIBS_DISIZE_H +#define SKALIBS_DISIZE_H #include <sys/types.h> diff --git a/src/include/skalibs/diuint.h b/src/include/skalibs/diuint.h index 1c13bd8..ab7d19b 100644 --- a/src/include/skalibs/diuint.h +++ b/src/include/skalibs/diuint.h @@ -1,7 +1,7 @@ /* ISC license. */ -#ifndef DIUINT_H -#define DIUINT_H +#ifndef SKALIBS_DIUINT_H +#define SKALIBS_DIUINT_H typedef struct diuint diuint, *diuint_ref ; struct diuint diff --git a/src/include/skalibs/diuint32.h b/src/include/skalibs/diuint32.h index fb0a2de..71d9ccc 100644 --- a/src/include/skalibs/diuint32.h +++ b/src/include/skalibs/diuint32.h @@ -1,7 +1,7 @@ /* ISC license. */ -#ifndef DIUINT32_H -#define DIUINT32_H +#ifndef SKALIBS_DIUINT32_H +#define SKALIBS_DIUINT32_H #include <stdint.h> diff --git a/src/include/skalibs/djbtime.h b/src/include/skalibs/djbtime.h index 2f924c7..980f3b2 100644 --- a/src/include/skalibs/djbtime.h +++ b/src/include/skalibs/djbtime.h @@ -1,10 +1,11 @@ /* ISC license. */ -#ifndef DJBTIME_H -#define DJBTIME_H +#ifndef SKALIBS_DJBTIME_H +#define SKALIBS_DJBTIME_H #include <stdint.h> #include <time.h> + #include <skalibs/uint64.h> #include <skalibs/tai.h> @@ -12,8 +13,8 @@ /* UTC <--> TAI conversions */ /* sysclock can be either TAI-10 or UTC */ -extern int utc_from_tai (uint64_t *, tai_t const *) ; -extern int tai_from_utc (tai_t *, uint64_t) ; +extern int utc_from_tai (uint64_t *, tai const *) ; +extern int tai_from_utc (tai *, uint64_t) ; extern int utc_from_sysclock (uint64_t *) ; extern int sysclock_from_utc (uint64_t *) ; @@ -21,9 +22,9 @@ extern int sysclock_from_utc (uint64_t *) ; /* NTP internal format */ #define NTP_OFFSET 2208988800UL -extern int ntp_from_tain (uint64_t *, tain_t const *) ; +extern int ntp_from_tain (uint64_t *, tain const *) ; #define ntp_from_tain_g(u) ntp_from_tain((u), &STAMP) -extern int tain_from_ntp (tain_t *, uint64_t) ; +extern int tain_from_ntp (tain *, uint64_t) ; /* localtime handling - replaces caltimedate functions */ @@ -31,15 +32,15 @@ extern int tain_from_ntp (tain_t *, uint64_t) ; /* normally ltm64 is the same as sysclock, but we allow it to be different */ /* for instance for musl TAI-10 systems */ -typedef struct localtmn_s localtmn_t, *localtmn_t_ref ; +typedef struct localtmn_s localtmn, *localtmn_ref ; struct localtmn_s { struct tm tm ; uint32_t nano ; } ; -extern int ltm64_from_tai (uint64_t *, tai_t const *) ; -extern int tai_from_ltm64 (tai_t *, uint64_t) ; +extern int ltm64_from_tai (uint64_t *, tai const *) ; +extern int tai_from_ltm64 (tai *, uint64_t) ; extern int ltm64_from_utc (uint64_t *) ; extern int utc_from_ltm64 (uint64_t *) ; extern int ltm64_from_sysclock (uint64_t *) ; @@ -51,21 +52,21 @@ extern int localtm_from_sysclock (struct tm *, uint64_t, int) ; extern int sysclock_from_localtm (uint64_t *, struct tm const *) ; extern int localtm_from_utc (struct tm *, uint64_t, int) ; extern int utc_from_localtm (uint64_t *, struct tm const *) ; -extern int localtm_from_tai (struct tm *, tai_t const *, int) ; -extern int tai_from_localtm (tai_t *, struct tm const *) ; +extern int localtm_from_tai (struct tm *, tai const *, int) ; +extern int tai_from_localtm (tai *, struct tm const *) ; -extern int localtmn_from_tain (localtmn_t *, tain_t const *, int) ; +extern int localtmn_from_tain (localtmn *, tain const *, int) ; #define localtmn_from_tain_g(l, h) localtmn_from_tain(l, &STAMP, h) -extern int tain_from_localtmn (tain_t *, localtmn_t const *) ; -extern int localtmn_from_sysclock (localtmn_t *, tain_t const *, int) ; -extern int sysclock_from_localtmn (tain_t *, localtmn_t const *) ; +extern int tain_from_localtmn (tain *, localtmn const *) ; +extern int localtmn_from_sysclock (localtmn *, tain const *, int) ; +extern int sysclock_from_localtmn (tain *, localtmn const *) ; #define LOCALTM_FMT 21 extern size_t localtm_fmt (char *, struct tm const *) ; extern size_t localtm_scan (char const *, struct tm *) ; #define LOCALTMN_FMT 31 -extern size_t localtmn_fmt (char *, localtmn_t const *) ; -extern size_t localtmn_scan (char const *, localtmn_t *) ; +extern size_t localtmn_fmt (char *, localtmn const *) ; +extern size_t localtmn_scan (char const *, localtmn *) ; #endif diff --git a/src/include/skalibs/djbunix.h b/src/include/skalibs/djbunix.h index d0775fe..45c5eb0 100644 --- a/src/include/skalibs/djbunix.h +++ b/src/include/skalibs/djbunix.h @@ -1,7 +1,7 @@ /* ISC license. */ -#ifndef DJBUNIX_H -#define DJBUNIX_H +#ifndef SKALIBS_DJBUNIX_H +#define SKALIBS_DJBUNIX_H #include <sys/types.h> #include <sys/uio.h> diff --git a/src/include/skalibs/envalloc.h b/src/include/skalibs/envalloc.h index aba6dca..7967ee8 100644 --- a/src/include/skalibs/envalloc.h +++ b/src/include/skalibs/envalloc.h @@ -1,9 +1,10 @@ /* ISC license. */ -#ifndef ENVALLOC_H -#define ENVALLOC_H +#ifndef SKALIBS_ENVALLOC_H +#define SKALIBS_ENVALLOC_H #include <sys/types.h> + #include <skalibs/genalloc.h> #define ENVALLOC_ZERO GENALLOC_ZERO diff --git a/src/include/skalibs/environ.h b/src/include/skalibs/environ.h deleted file mode 100644 index 0d4494b..0000000 --- a/src/include/skalibs/environ.h +++ /dev/null @@ -1,5 +0,0 @@ -/* ISC license. */ - -/* This header is being deprecated */ - -#include <skalibs/posixplz.h> diff --git a/src/include/skalibs/fmtscan.h b/src/include/skalibs/fmtscan.h index f820b42..a0d654c 100644 --- a/src/include/skalibs/fmtscan.h +++ b/src/include/skalibs/fmtscan.h @@ -1,10 +1,11 @@ /* ISC license. */ -#ifndef FMTSCAN_H -#define FMTSCAN_H +#ifndef SKALIBS_FMTSCAN_H +#define SKALIBS_FMTSCAN_H #include <sys/types.h> #include <stdint.h> + #include <skalibs/gccattributes.h> diff --git a/src/include/skalibs/functypes.h b/src/include/skalibs/functypes.h index bd2b1e1..f839877 100644 --- a/src/include/skalibs/functypes.h +++ b/src/include/skalibs/functypes.h @@ -7,49 +7,55 @@ #include <sys/stat.h> #include <sys/uio.h> -typedef int uintcmpfunc_t (unsigned int, unsigned int, void *) ; -typedef uintcmpfunc_t *uintcmpfunc_t_ref ; +typedef int uintcmp_func (unsigned int, unsigned int, void *) ; +typedef uintcmp_func *uintcmp_func_ref ; -typedef int uint32cmpfunc_t (uint32_t, uint32_t, void *) ; -typedef uint32cmpfunc_t *uint32cmpfunc_t_ref ; +typedef int uint32cmp_func (uint32_t, uint32_t, void *) ; +typedef uint32cmp_func *uint32cmp_func_ref ; -typedef int cmpfunc_t (void const *, void const *, void *) ; -typedef cmpfunc_t *cmpfunc_t_ref ; +typedef int cmp_func (void const *, void const *, void *) ; +typedef cmp_func *cmp_func_ref ; -typedef void *dtokfunc_t (uint32_t, void *) ; -typedef dtokfunc_t *dtokfunc_t_ref ; +typedef void *dtok_func (uint32_t, void *) ; +typedef dtok_func *dtok_func_ref ; -typedef int iterfunc_t (char *, void *) ; -typedef iterfunc_t *iterfunc_t_ref ; +typedef int iter_func (char *, void *) ; +typedef iter_func *iter_func_ref ; -typedef void freefunc_t (void *) ; -typedef freefunc_t *freefunc_t_ref ; +typedef void free_func (void *) ; +typedef free_func *free_func_ref ; -typedef int initfunc_t (void *) ; -typedef initfunc_t *initfunc_t_ref ; +typedef int init_func (void *) ; +typedef init_func *init_func_ref ; -typedef ssize_t getfunc_t (void *) ; -typedef getfunc_t *getfunc_t_ref ; +typedef ssize_t get_func (void *) ; +typedef get_func *get_func_ref ; -typedef size_t ugetfunc_t (void *) ; -typedef ugetfunc_t *ugetfunc_t_ref ; +typedef size_t uget_func (void *) ; +typedef uget_func *uget_func_ref ; -typedef ssize_t iofunc_t (int, char *, size_t) ; -typedef iofunc_t *iofunc_t_ref ; +typedef ssize_t io_func (int, char *, size_t) ; +typedef io_func *io_func_ref ; -typedef ssize_t iovfunc_t (int, struct iovec const *, unsigned int) ; -typedef iovfunc_t *iovfunc_t_ref ; +typedef ssize_t iow_func (int, char const *, size_t) ; +typedef iow_func *iow_func_ref ; -typedef size_t alliofunc_t (int, char *, size_t) ; -typedef alliofunc_t *alliofunc_t_ref ; +typedef ssize_t iov_func (int, struct iovec const *, unsigned int) ; +typedef iov_func *iov_func_ref ; -typedef size_t alliovfunc_t (int, struct iovec const *, unsigned int) ; -typedef alliovfunc_t *alliovfunc_t_ref ; +typedef size_t allio_func (int, char *, size_t) ; +typedef allio_func *allio_func_ref ; -typedef int createfunc_t (char const *, mode_t, void *) ; -typedef createfunc_t *createfunc_t_ref ; +typedef size_t alliow_func (int, char const *, size_t) ; +typedef alliow_func *alliow_func_ref ; -typedef int linkfunc_t (char const *, char const *) ; -typedef linkfunc_t *linkfunc_t_ref ; +typedef size_t alliov_func (int, struct iovec const *, unsigned int) ; +typedef alliov_func *alliov_func_ref ; + +typedef int create_func (char const *, mode_t, void *) ; +typedef create_func *create_func_ref ; + +typedef int link_func (char const *, char const *) ; +typedef link_func *link_func_ref ; #endif diff --git a/src/include/skalibs/gccattributes.h b/src/include/skalibs/gccattributes.h index 7892687..2797bb1 100644 --- a/src/include/skalibs/gccattributes.h +++ b/src/include/skalibs/gccattributes.h @@ -1,7 +1,7 @@ /* ISC license. */ -#ifndef GCCATTRIBUTES_H -#define GCCATTRIBUTES_H +#ifndef SKALIBS_GCCATTRIBUTES_H +#define SKALIBS_GCCATTRIBUTES_H #ifdef __GNUC__ @@ -46,19 +46,4 @@ #endif -#ifdef GCCATTR_COMPAT_0_22 -#define _a_noreturn gccattr_noreturn -#define _a_returns_twice gccattr_returns_twice -#define _a_noinline gccattr_noinline -#define _a_inline gccattr_inline -#define _a_const gccattr_const -#define _a_unused gccattr_unused -#define _a_used gccattr_used -#define _a_weak gccattr_weak -#define _a_aligned gccattr_aligned -#define _a_malloc gccattr_malloc -#define _a_pure gccattr_pure -#define _a_deprecated gccattr_deprecated -#endif - #endif diff --git a/src/include/skalibs/genalloc.h b/src/include/skalibs/genalloc.h index da83c2f..0681246 100644 --- a/src/include/skalibs/genalloc.h +++ b/src/include/skalibs/genalloc.h @@ -1,10 +1,10 @@ /* ISC license. */ -#ifndef GENALLOC_H -#define GENALLOC_H +#ifndef SKALIBS_GENALLOC_H +#define SKALIBS_GENALLOC_H -#include <skalibs/stralloc.h> #include <skalibs/functypes.h> +#include <skalibs/stralloc.h> typedef stralloc genalloc, *genalloc_ref ; @@ -29,7 +29,7 @@ typedef stralloc genalloc, *genalloc_ref ; #define genalloc_insertb(type, g, offset, s, n) stralloc_insertb((g), (offset)*sizeof(type), (char const *)(s), (n)*sizeof(type)) #define genalloc_insert(type, g1, offset, g2) stralloc_insert((g1), (offset)*sizeof(type), (g2)) -#define genalloc_deepfree(type, g, f) genalloc_deepfree_size(g, (freefunc_t_ref)(f), sizeof(type)) -extern void genalloc_deepfree_size (genalloc *, freefunc_t_ref, size_t) ; +#define genalloc_deepfree(type, g, f) genalloc_deepfree_size(g, (free_func_ref)(f), sizeof(type)) +extern void genalloc_deepfree_size (genalloc *, free_func_ref, size_t) ; #endif diff --git a/src/include/skalibs/genqdyn.h b/src/include/skalibs/genqdyn.h index b53af83..33859e0 100644 --- a/src/include/skalibs/genqdyn.h +++ b/src/include/skalibs/genqdyn.h @@ -4,6 +4,7 @@ #define SKALIBS_GENQDYN_H #include <sys/types.h> + #include <skalibs/stralloc.h> typedef struct genqdyn_s genqdyn, *genqdyn_ref ; diff --git a/src/include/skalibs/genset.h b/src/include/skalibs/genset.h index fc14d24..83a65a0 100644 --- a/src/include/skalibs/genset.h +++ b/src/include/skalibs/genset.h @@ -1,9 +1,10 @@ /* ISC license. */ -#ifndef GENSET_H -#define GENSET_H +#ifndef SKALIBS_GENSET_H +#define SKALIBS_GENSET_H #include <stdint.h> + #include <skalibs/functypes.h> typedef struct genset_s genset, *genset_ref ; @@ -24,10 +25,10 @@ extern void genset_init (genset *, void *, uint32_t *, uint32_t, uint32_t) ; extern uint32_t genset_new (genset *) ; extern int genset_delete (genset *, uint32_t) ; #define genset_n(g) ((g)->max - (g)->sp) -extern uint32_t genset_iter_nocancel (genset *, uint32_t, iterfunc_t_ref, void *) ; +extern uint32_t genset_iter_nocancel (genset *, uint32_t, iter_func_ref, void *) ; #define genset_iter(g, f, stuff) genset_iter_nocancel(g, (g)->max, f, stuff) -extern int genset_iter_withcancel (genset *, iterfunc_t_ref, iterfunc_t_ref, void *) ; -extern void genset_deepfree (genset *, freefunc_t_ref) ; +extern int genset_iter_withcancel (genset *, iter_func_ref, iter_func_ref, void *) ; +extern void genset_deepfree (genset *, free_func_ref) ; #define GENSETB_TYPE(type, size) struct { type storage[size] ; uint32_t freelist[size] ; genset info ; } #define GENSETB_init(type, g, size) GENSET_init(&(g)->info, type, (g)->storage, (g)->freelist, size) diff --git a/src/include/skalibs/gensetdyn.h b/src/include/skalibs/gensetdyn.h index c91a435..c8c1073 100644 --- a/src/include/skalibs/gensetdyn.h +++ b/src/include/skalibs/gensetdyn.h @@ -1,9 +1,10 @@ /* ISC license. */ -#ifndef GENSETDYN_H -#define GENSETDYN_H +#ifndef SKALIBS_GENSETDYN_H +#define SKALIBS_GENSETDYN_H #include <stdint.h> + #include <skalibs/stralloc.h> #include <skalibs/genalloc.h> #include <skalibs/functypes.h> @@ -29,7 +30,7 @@ extern void gensetdyn_init (gensetdyn *, uint32_t, uint32_t, uint32_t, uint32_t) extern int gensetdyn_ready (gensetdyn *, uint32_t) ; #define gensetdyn_readyplus(x, n) gensetdyn_ready(x, gensetdyn_n(x) + (n)) extern void gensetdyn_free (gensetdyn *) ; -extern void gensetdyn_deepfree (gensetdyn *, freefunc_t_ref) ; +extern void gensetdyn_deepfree (gensetdyn *, free_func_ref) ; extern int gensetdyn_new (gensetdyn *, uint32_t *) ; extern int gensetdyn_delete (gensetdyn *, uint32_t) ; @@ -37,8 +38,8 @@ extern int gensetdyn_delete (gensetdyn *, uint32_t) ; #define gensetdyn_p(g, i) ((g)->storage.s + (i) * (g)->esize) #define GENSETDYN_P(type, g, i) ((type *)gensetdyn_p(g, i)) -extern uint32_t gensetdyn_iter_nocancel (gensetdyn *, uint32_t, iterfunc_t_ref, void *) ; +extern uint32_t gensetdyn_iter_nocancel (gensetdyn *, uint32_t, iter_func_ref, void *) ; #define gensetdyn_iter(g, f, stuff) gensetdyn_iter_nocancel(g, gensetdyn_n(g), f, stuff) -extern int gensetdyn_iter_withcancel (gensetdyn *, iterfunc_t_ref, iterfunc_t_ref, void *) ; +extern int gensetdyn_iter_withcancel (gensetdyn *, iter_func_ref, iter_func_ref, void *) ; #endif diff --git a/src/include/skalibs/genwrite.h b/src/include/skalibs/genwrite.h index 0b3af87..a7eeaec 100644 --- a/src/include/skalibs/genwrite.h +++ b/src/include/skalibs/genwrite.h @@ -1,37 +1,37 @@ /* ISC license. */ -#ifndef GENWRITE_H -#define GENWRITE_H +#ifndef SKALIBS_GENWRITE_H +#define SKALIBS_GENWRITE_H #include <sys/types.h> -typedef ssize_t genwrite_put_func_t (void *, char const *, size_t) ; -typedef genwrite_put_func_t *genwrite_put_func_t_ref ; +typedef ssize_t genwrite_put_func (void *, char const *, size_t) ; +typedef genwrite_put_func *genwrite_put_func_ref ; -typedef int genwrite_flush_func_t (void *) ; -typedef genwrite_flush_func_t *genwrite_flush_func_t_ref ; +typedef int genwrite_flush_func (void *) ; +typedef genwrite_flush_func *genwrite_flush_func_ref ; -typedef struct genwrite_s genwrite_t, *genwrite_t_ref ; +typedef struct genwrite_s genwrite, *genwrite_ref ; struct genwrite_s { - genwrite_put_func_t_ref put ; - genwrite_flush_func_t_ref flush ; + genwrite_put_func_ref put ; + genwrite_flush_func_ref flush ; void *target ; } ; #define GENWRITE_ZERO { .put = 0, .flush = 0, .target = 0 } -extern genwrite_put_func_t genwrite_put_stralloc ; -extern genwrite_flush_func_t genwrite_flush_stralloc ; -extern genwrite_put_func_t genwrite_put_buffer ; -extern genwrite_flush_func_t genwrite_flush_buffer ; -extern genwrite_put_func_t genwrite_put_bufalloc ; -extern genwrite_flush_func_t genwrite_flush_bufalloc ; +extern genwrite_put_func genwrite_put_stralloc ; +extern genwrite_flush_func genwrite_flush_stralloc ; +extern genwrite_put_func genwrite_put_buffer ; +extern genwrite_flush_func genwrite_flush_buffer ; +extern genwrite_put_func genwrite_put_bufalloc ; +extern genwrite_flush_func genwrite_flush_bufalloc ; #define GENWRITE_STRALLOC_INIT(sa) { .put = &genwrite_put_stralloc, .flush = &genwrite_flush_stralloc, .target = (sa) } #define GENWRITE_BUFFER_INIT(b) { .put = &genwrite_put_buffer, .flush = &genwrite_flush_buffer, .target = (b) } #define GENWRITE_BUFALLOC_INIT(ba) { .put = &genwrite_put_bufalloc, .flush = &genwrite_flush_bufalloc, .target = (ba) } -extern genwrite_t genwrite_stdout ; -extern genwrite_t genwrite_stderr ; +extern genwrite genwrite_stdout ; +extern genwrite genwrite_stderr ; #endif diff --git a/src/include/skalibs/getpeereid.h b/src/include/skalibs/getpeereid.h deleted file mode 100644 index 0d4494b..0000000 --- a/src/include/skalibs/getpeereid.h +++ /dev/null @@ -1,5 +0,0 @@ -/* ISC license. */ - -/* This header is being deprecated */ - -#include <skalibs/posixplz.h> diff --git a/src/include/skalibs/iobuffer.h b/src/include/skalibs/iobuffer.h index 84a8b6d..3259c03 100644 --- a/src/include/skalibs/iobuffer.h +++ b/src/include/skalibs/iobuffer.h @@ -1,13 +1,14 @@ /* ISC license. */ -#ifndef IOBUFFER_H -#define IOBUFFER_H +#ifndef SKALIBS_IOBUFFER_H +#define SKALIBS_IOBUFFER_H #define IOBUFFER_SIZE 65536U /* iobufferu */ #include <sys/types.h> + #include <skalibs/buffer.h> #include <skalibs/djbunix.h> @@ -51,19 +52,19 @@ struct iobufferk_s unsigned int nb : 2 ; } ; -typedef int iobufferk_output_func_t (iobufferk *) ; -typedef iobufferk_output_func_t *iobufferk_output_func_t_ref ; -typedef ssize_t iobufferk_input_func_t (iobufferk *) ; -typedef iobufferk_input_func_t *iobufferk_input_func_t_ref ; -typedef void iobufferk_finish_func_t (iobufferk *) ; -typedef iobufferk_finish_func_t *iobufferk_finish_func_t_ref ; +typedef int iobufferk_output_func (iobufferk *) ; +typedef iobufferk_output_func *iobufferk_output_func_ref ; +typedef ssize_t iobufferk_input_func (iobufferk *) ; +typedef iobufferk_input_func *iobufferk_input_func_ref ; +typedef void iobufferk_finish_func (iobufferk *) ; +typedef iobufferk_finish_func *iobufferk_finish_func_ref ; -extern iobufferk_output_func_t iobufferk_isworking ; +extern iobufferk_output_func iobufferk_isworking ; extern int iobufferk_init (iobufferk *, int, int) ; -extern iobufferk_input_func_t_ref const iobufferk_fill_f[4] ; -extern iobufferk_output_func_t_ref const iobufferk_flush_f[4] ; -extern iobufferk_finish_func_t_ref const iobufferk_finish_f[4] ; +extern iobufferk_input_func_ref const iobufferk_fill_f[4] ; +extern iobufferk_output_func_ref const iobufferk_flush_f[4] ; +extern iobufferk_finish_func_ref const iobufferk_finish_f[4] ; #define iobufferk_fill(k) (*iobufferk_fill_f[(k)->type])(k) #define iobufferk_flush(k) (*iobufferk_flush_f[(k)->type])(k) diff --git a/src/include/skalibs/iopause.h b/src/include/skalibs/iopause.h index 8c8fddc..36521d7 100644 --- a/src/include/skalibs/iopause.h +++ b/src/include/skalibs/iopause.h @@ -1,9 +1,10 @@ /* ISC license. */ -#ifndef IOPAUSE_H -#define IOPAUSE_H +#ifndef SKALIBS_IOPAUSE_H +#define SKALIBS_IOPAUSE_H #include <poll.h> + #include <skalibs/tai.h> typedef struct pollfd iopause_fd, *iopause_fd_ref ; @@ -12,20 +13,20 @@ typedef struct pollfd iopause_fd, *iopause_fd_ref ; #define IOPAUSE_WRITE POLLOUT #define IOPAUSE_EXCEPT (POLLERR|POLLHUP|POLLNVAL) -typedef int iopause_func_t (iopause_fd *, unsigned int, tain_t const *, tain_t const *) ; -typedef iopause_func_t *iopause_func_t_ref ; +typedef int iopause_func (iopause_fd *, unsigned int, tain const *, tain const *) ; +typedef iopause_func *iopause_func_ref ; -extern iopause_func_t iopause_select ; -extern iopause_func_t iopause_poll ; -extern iopause_func_t iopause_ppoll ; +extern iopause_func iopause_select ; +extern iopause_func iopause_poll ; +extern iopause_func iopause_ppoll ; -extern iopause_func_t_ref const iopause_ ; +extern iopause_func_ref const iopause_ ; #define iopause (*iopause_) -extern int iopause_stamp (iopause_fd *, unsigned int, tain_t const *, tain_t *) ; +extern int iopause_stamp (iopause_fd *, unsigned int, tain const *, tain *) ; #define iopause_g(x, n, deadline) iopause_stamp(x, n, (deadline), &STAMP) -extern void deepsleepuntil (tain_t const *, tain_t *) ; +extern void deepsleepuntil (tain const *, tain *) ; #define deepsleepuntil_g(deadline) deepsleepuntil((deadline), &STAMP) #endif diff --git a/src/include/skalibs/kolbak.h b/src/include/skalibs/kolbak.h index 566f065..aa01b44 100644 --- a/src/include/skalibs/kolbak.h +++ b/src/include/skalibs/kolbak.h @@ -1,23 +1,24 @@ /* ISC license. */ -#ifndef KOLBAK_H -#define KOLBAK_H +#ifndef SKALIBS_KOLBAK_H +#define SKALIBS_KOLBAK_H #include <sys/types.h> + #include <skalibs/unixmessage.h> -typedef struct kolbak_closure_s kolbak_closure_t, *kolbak_closure_t_ref ; +typedef struct kolbak_closure_s kolbak_closure, *kolbak_closure_ref ; struct kolbak_closure_s { - unixmessage_handler_func_t_ref f ; + unixmessage_handler_func_ref f ; void *data ; } ; #define KOLBAK_CLOSURE_ZERO { .f = 0, .data = 0 } -typedef struct kolbak_queue_s kolbak_queue_t, *kolbak_queue_t_ref ; +typedef struct kolbak_queue_s kolbak_queue, *kolbak_queue_ref ; struct kolbak_queue_s { - kolbak_closure_t *x ; + kolbak_closure *x ; size_t n ; size_t head ; size_t tail ; @@ -25,9 +26,9 @@ struct kolbak_queue_s #define KOLBAK_QUEUE_ZERO { .x = 0, .n = 0, .head = 0, .tail = 0 } #define KOLBAK_QUEUE_INIT(s, len) { .x = (s), .n = (len), .head = 0, .tail = 0 } -extern int kolbak_queue_init (kolbak_queue_t *, kolbak_closure_t *, size_t) ; -extern int kolbak_enqueue (kolbak_queue_t *, unixmessage_handler_func_t_ref, void *) ; -extern int kolbak_unenqueue (kolbak_queue_t *) ; -extern int kolbak_call (unixmessage_t const *, kolbak_queue_t *) ; +extern int kolbak_queue_init (kolbak_queue *, kolbak_closure *, size_t) ; +extern int kolbak_enqueue (kolbak_queue *, unixmessage_handler_func_ref, void *) ; +extern int kolbak_unenqueue (kolbak_queue *) ; +extern int kolbak_call (unixmessage const *, kolbak_queue *) ; #endif diff --git a/src/include/skalibs/lolstdio.h b/src/include/skalibs/lolstdio.h index ec66da2..58689cf 100644 --- a/src/include/skalibs/lolstdio.h +++ b/src/include/skalibs/lolstdio.h @@ -1,9 +1,10 @@ /* ISC license. */ -#ifndef LOLSTDIO_H -#define LOLSTDIO_H +#ifndef SKALIBS_LOLSTDIO_H +#define SKALIBS_LOLSTDIO_H #include <stdarg.h> + #include <skalibs/buffer.h> #include <skalibs/bufalloc.h> #include <skalibs/strerr2.h> diff --git a/src/include/skalibs/md5.h b/src/include/skalibs/md5.h deleted file mode 100644 index 5e31b1f..0000000 --- a/src/include/skalibs/md5.h +++ /dev/null @@ -1,22 +0,0 @@ -/* ISC license. */ - -#ifndef MD5_H -#define MD5_H - -#include <sys/types.h> -#include <stdint.h> - -typedef struct MD5Schedule MD5Schedule, *MD5Schedule_ref ; -struct MD5Schedule -{ - uint32_t buf[4] ; - uint32_t bits[2] ; - unsigned char in[64] ; -} ; - -#define MD5_INIT() { .buf = { 0x67452301U, 0xefcdab89U, 0x98badcfeU, 0x10325476U }, .bits = { 0, 0 }, .in = "\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\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\0" } -extern void md5_init (MD5Schedule *) ; -extern void md5_update (MD5Schedule *, char const *, size_t) ; -extern void md5_final (MD5Schedule *, char * /* 16 chars */) ; - -#endif diff --git a/src/include/skalibs/netstring.h b/src/include/skalibs/netstring.h index d41d1dd..24879c2 100644 --- a/src/include/skalibs/netstring.h +++ b/src/include/skalibs/netstring.h @@ -1,10 +1,11 @@ /* ISC license. */ -#ifndef NETSTRING_H -#define NETSTRING_H +#ifndef SKALIBS_NETSTRING_H +#define SKALIBS_NETSTRING_H -#include <sys/uio.h> #include <string.h> +#include <sys/uio.h> + #include <skalibs/buffer.h> #include <skalibs/stralloc.h> diff --git a/src/include/skalibs/nsig.h b/src/include/skalibs/nsig.h index 3b3fb32..6dbddea 100644 --- a/src/include/skalibs/nsig.h +++ b/src/include/skalibs/nsig.h @@ -1,27 +1,34 @@ /* ISC license. */ /* - This header MUST be paired with skalibs/nonposix.h - which must be included before system headers. + This header MUST be paired with skalibs/nonposix.h AND + skalibs/bsdsnowflake.h, both of which must be included + before system headers. */ -#ifndef NSIG_H +#ifndef SKALIBS_NSIG_H +#define SKALIBS_NSIG_H #include <signal.h> -#define SKALIBS_DEFAULT_NSIG 65 - #ifndef NSIG -# define NSIG SKALIBS_DEFAULT_NSIG +# ifdef _NSIG +# define NSIG _NSIG +# elif defined(SIGMAX) +# define NSIG (SIGMAX + 1) +# elif defined(_SIGMAX) +# define NSIG(_SIGMAX + 1) +# elif defined(SKALIBS_BSD_SUCKS) +# define NSIG 64 +# else +# define NSIG 65 +# endif #endif - - /* OpenBSD is a fucking snowflake */ - -#ifdef __OpenBSD__ -#define SKALIBS_NSIG (NSIG-1) +#ifdef SKALIBS_BSD_SUCKS +# define SKALIBS_NSIG (NSIG+1) #else -#define SKALIBS_NSIG NSIG +# define SKALIBS_NSIG NSIG #endif #endif diff --git a/src/include/skalibs/posixplz.h b/src/include/skalibs/posixplz.h index 2c972c8..6dfe954 100644 --- a/src/include/skalibs/posixplz.h +++ b/src/include/skalibs/posixplz.h @@ -38,8 +38,8 @@ extern void munmap_void (void *, size_t) ; extern pid_t doublefork (void) ; extern int touch (char const *) ; -extern int mkfiletemp (char *, createfunc_t_ref, mode_t, void *) ; -extern int mklinktemp (char const *, char *, linkfunc_t_ref) ; +extern int mkfiletemp (char *, create_func_ref, mode_t, void *) ; +extern int mklinktemp (char const *, char *, link_func_ref) ; extern int mkptemp (char *) ; extern int mkptemp2 (char *, unsigned int) ; extern int mkltemp (char const *, char *) ; diff --git a/src/include/skalibs/random.h b/src/include/skalibs/random.h index 254a1c0..6c9dee0 100644 --- a/src/include/skalibs/random.h +++ b/src/include/skalibs/random.h @@ -1,10 +1,11 @@ /* ISC license. */ -#ifndef RANDOM_H -#define RANDOM_H +#ifndef SKALIBS_RANDOM_H +#define SKALIBS_RANDOM_H #include <sys/types.h> #include <stdint.h> + #include <skalibs/stralloc.h> extern void random_makeseed (char *) ; /* fills 160 bytes */ diff --git a/src/include/skalibs/rc4.h b/src/include/skalibs/rc4.h deleted file mode 100644 index c4fde53..0000000 --- a/src/include/skalibs/rc4.h +++ /dev/null @@ -1,21 +0,0 @@ -/* ISC license. */ - -#ifndef RC4_H -#define RC4_H - -#include <sys/types.h> - -#define RC4_THROWAWAY 128 - -typedef struct RC4Schedule RC4Schedule, *RC4Schedule_ref ; - -struct RC4Schedule -{ - unsigned char tab[256] ; - unsigned char x, y ; -} ; - -extern void rc4_init (RC4Schedule *, char const *, size_t) ; -extern void rc4 (RC4Schedule *, char const *, char *, size_t) ; - -#endif diff --git a/src/include/skalibs/segfault.h b/src/include/skalibs/segfault.h index 732ad4f..c238eaf 100644 --- a/src/include/skalibs/segfault.h +++ b/src/include/skalibs/segfault.h @@ -1,7 +1,7 @@ /* ISC license. */ -#ifndef SEGFAULT_H -#define SEGFAULT_H +#ifndef SKALIBS_SEGFAULT_H +#define SKALIBS_SEGFAULT_H extern int sigsegv (void) ; extern int sigfpe (void) ; diff --git a/src/include/skalibs/selfpipe.h b/src/include/skalibs/selfpipe.h index 849db4a..980af90 100644 --- a/src/include/skalibs/selfpipe.h +++ b/src/include/skalibs/selfpipe.h @@ -1,13 +1,12 @@ /* ISC license. */ -#ifndef SELFPIPE_H -#define SELFPIPE_H +#ifndef SKALIBS_SELFPIPE_H +#define SKALIBS_SELFPIPE_H #include <signal.h> extern int selfpipe_init (void) ; extern int selfpipe_trap (int) ; -extern int selfpipe_untrap (int) ; extern int selfpipe_trapset (sigset_t const *) ; extern int selfpipe_read (void) ; extern void selfpipe_finish (void) ; diff --git a/src/include/skalibs/sgetopt.h b/src/include/skalibs/sgetopt.h index 3c7a393..355f820 100644 --- a/src/include/skalibs/sgetopt.h +++ b/src/include/skalibs/sgetopt.h @@ -1,12 +1,12 @@ /* ISC license. */ -#ifndef SGETOPT_H -#define SGETOPT_H +#ifndef SKALIBS_SGETOPT_H +#define SKALIBS_SGETOPT_H /* reentrant */ -typedef struct subgetopt_s subgetopt_t, *subgetopt_t_ref ; +typedef struct subgetopt_s subgetopt, *subgetopt_ref ; struct subgetopt_s { int ind ; @@ -19,16 +19,16 @@ struct subgetopt_s #define SUBGETOPT_ZERO { .ind = 1, .err = 1, .problem = 0, .arg = 0, .pos = 0, .prog = 0 } -extern int subgetopt_r (int, char const *const *, char const *, subgetopt_t *) ; +extern int subgetopt_r (int, char const *const *, char const *, subgetopt *) ; /* non-reentrant */ -extern int sgetopt_r (int, char const *const *, char const *, subgetopt_t *) ; +extern int sgetopt_r (int, char const *const *, char const *, subgetopt *) ; -extern subgetopt_t subgetopt_here ; +extern subgetopt subgetopt_here ; -#define subgetopt(argc, argv, opts) subgetopt_r((argc), (argv), (opts), &subgetopt_here) +#define lgetopt(argc, argv, opts) subgetopt_r((argc), (argv), (opts), &subgetopt_here) #define sgetopt(argc, argv, opts) sgetopt_r((argc), (argv), (opts), &subgetopt_here) #define sgetopt_prog() (subgetopt_here.prog = PROG) diff --git a/src/include/skalibs/sha1.h b/src/include/skalibs/sha1.h index 2d41275..781c70d 100644 --- a/src/include/skalibs/sha1.h +++ b/src/include/skalibs/sha1.h @@ -1,7 +1,7 @@ /* ISC license. */ -#ifndef SHA1_H -#define SHA1_H +#ifndef SKALIBS_SHA1_H +#define SKALIBS_SHA1_H #include <sys/types.h> #include <stdint.h> diff --git a/src/include/skalibs/sha256.h b/src/include/skalibs/sha256.h index 8ef7d0b..77bbdb7 100644 --- a/src/include/skalibs/sha256.h +++ b/src/include/skalibs/sha256.h @@ -1,14 +1,7 @@ /* ISC license. */ -/* SHA256 routines */ -/* Written by David Madore (<URL: http://www.madore.org/~david/ >) */ -/* Adapted by Laurent Bercot. */ -/* This version last modified 2010-01-08 */ - -/* Note: these routines do not depend on endianness. */ - -#ifndef SHA256_H -#define SHA256_H +#ifndef SKALIBS_SHA256_H +#define SKALIBS_SHA256_H #include <sys/types.h> #include <stdint.h> @@ -16,10 +9,10 @@ typedef struct SHA256Schedule_s SHA256Schedule, *SHA256Schedule_ref ; struct SHA256Schedule_s { - uint32_t buf[8] ; /* The eight chaining variables */ - uint32_t bits[2] ; /* Count number of message bits */ - uint32_t in[16] ; /* Data being fed in */ - unsigned int b ; /* Our position within the 512 bits (always between 0 and 63) */ + uint32_t buf[8] ; + uint32_t bits[2] ; + uint32_t in[16] ; + uint32_t b ; } ; #define SHA256_INIT() { .buf = { 0x6a09e667U, 0xbb67ae85U, 0x3c6ef372U, 0xa54ff53aU, 0x510e527fU, 0x9b05688cU, 0x1f83d9abU, 0x5be0cd19U }, .bits = { 0, 0 }, .in = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, .b = 0 } diff --git a/src/include/skalibs/sha512.h b/src/include/skalibs/sha512.h index 12ddbcb..2f51e47 100644 --- a/src/include/skalibs/sha512.h +++ b/src/include/skalibs/sha512.h @@ -1,9 +1,10 @@ /* ISC license. */ -#ifndef SHA512_H -#define SHA512_H +#ifndef SKALIBS_SHA512_H +#define SKALIBS_SHA512_H #include <sys/types.h> + #include <skalibs/uint64.h> typedef struct SHA512Schedule_s SHA512Schedule, *SHA512Schedule_ref ; diff --git a/src/include/skalibs/sig.h b/src/include/skalibs/sig.h index eb33ed4..ccf5dac 100644 --- a/src/include/skalibs/sig.h +++ b/src/include/skalibs/sig.h @@ -1,48 +1,25 @@ /* ISC license. */ -#ifndef SIG_H -#define SIG_H +#ifndef SKALIBS_SIG_H +#define SKALIBS_SIG_H #include <sys/types.h> #include <signal.h> -#include <skalibs/gccattributes.h> - -typedef void skasighandler_t (int) ; -typedef skasighandler_t *skasighandler_t_ref ; - -struct skasigaction -{ - skasighandler_t_ref handler ; - unsigned int flags : 2 ; -} ; -#define SKASA_MASKALL 0x01 -#define SKASA_NOCLDSTOP 0x02 +#include <skalibs/gccattributes.h> -extern struct skasigaction const SKASIG_DFL ; -extern struct skasigaction const SKASIG_IGN ; -extern int skasigaction (int, struct skasigaction const *, struct skasigaction *) ; +typedef void sig_func (int) ; +typedef sig_func *sig_func_ref ; -#define sig_catcha(sig, ac) skasigaction(sig, (ac), 0) -#define sig_restore(sig) skasigaction((sig), &SKASIG_DFL, 0) +extern int sig_catch (int, sig_func_ref) ; +#define sig_restore(sig) sig_catch((sig), SIG_DFL) +#define sig_ignore(sig) sig_catch((sig), SIG_IGN) extern void sig_restoreto (sigset_t const *, unsigned int) ; -extern int sig_catch (int, skasighandler_t_ref) ; -#define sig_ignore(sig) sig_catcha((sig), &SKASIG_IGN) -#define sig_uncatch(sig) sig_restore(sig) - -#define SIGSTACKSIZE 16 -extern int sig_pusha (int, struct skasigaction const *) ; -extern int sig_pop (int) ; -extern int sig_push (int, skasighandler_t_ref) ; extern void sig_block (int) ; -extern void sig_blockset (sigset_t const *) ; extern void sig_unblock (int) ; extern void sig_blocknone (void) ; -extern void sig_pause (void) ; -extern void sig_shield (void) ; -extern void sig_unshield (void) ; extern char const *sig_name (int) ; extern int sig_number (char const *) ; diff --git a/src/include/skalibs/siovec.h b/src/include/skalibs/siovec.h index 2fb987f..46d9a81 100644 --- a/src/include/skalibs/siovec.h +++ b/src/include/skalibs/siovec.h @@ -1,9 +1,10 @@ /* ISC license. */ -#ifndef SIOVEC_H -#define SIOVEC_H +#ifndef SKALIBS_SIOVEC_H +#define SKALIBS_SIOVEC_H #include <sys/uio.h> + #include <skalibs/gccattributes.h> extern size_t siovec_len (struct iovec const *, unsigned int) gccattr_pure ; diff --git a/src/include/skalibs/skaclient.h b/src/include/skalibs/skaclient.h index 1209ca5..cd5916c 100644 --- a/src/include/skalibs/skaclient.h +++ b/src/include/skalibs/skaclient.h @@ -6,6 +6,7 @@ #include <sys/types.h> #include <sys/uio.h> #include <stdint.h> + #include <skalibs/kolbak.h> #include <skalibs/tai.h> #include <skalibs/unixmessage.h> @@ -13,9 +14,9 @@ /* Server part */ -extern int skaclient_server_ack (unixmessage_t const *, unixmessage_sender_t *, unixmessage_sender_t *, char const *, size_t, char const *, size_t) ; -extern int skaclient_server_bidi_ack (unixmessage_t const *, unixmessage_sender_t *, unixmessage_sender_t *, unixmessage_receiver_t *, char *, size_t, char *, size_t, char const *, size_t, char const *, size_t) ; -extern int skaclient_server_init (unixmessage_receiver_t *, unixmessage_sender_t *, unixmessage_sender_t *, char const *, size_t, char const *, size_t, tain_t const *, tain_t *) ; +extern int skaclient_server_ack (unixmessage const *, unixmessage_sender *, unixmessage_sender *, char const *, size_t, char const *, size_t) ; +extern int skaclient_server_bidi_ack (unixmessage const *, unixmessage_sender *, unixmessage_sender *, unixmessage_receiver *, char *, size_t, char *, size_t, char const *, size_t, char const *, size_t) ; +extern int skaclient_server_init (unixmessage_receiver *, unixmessage_sender *, unixmessage_sender *, char const *, size_t, char const *, size_t, tain const *, tain *) ; #define skaclient_server_init_g(in, out, asyncout, before, beforelen, after, afterlen, deadline) skaclient_server_init(in, out, asyncout, before, beforelen, after, afterlen, (deadline), &STAMP) #define skaclient_server_01x_init(before, beforelen, after, afterlen, deadline, stamp) skaclient_server_init(unixmessage_receiver_0, unixmessage_sender_1, unixmessage_sender_x, before, beforelen, after, afterlen, deadline, stamp) #define skaclient_server_01x_init_g(before, beforelen, after, afterlen, deadline) skaclient_server_01x_init(before, beforelen, after, afterlen, (deadline), &STAMP) @@ -28,33 +29,33 @@ extern int skaclient_server_init (unixmessage_receiver_t *, unixmessage_sender_t #define SKACLIENT_OPTION_ASYNC_ACCEPT_FDS 0x00000002U #define SKACLIENT_OPTION_SYNC_ACCEPT_FDS 0x00000004U -#define skaclient_buffer_type(bufsn, auxbufsn, bufan, auxbufan, qlen) struct { char bufs[bufsn] ; char auxbufs[auxbufsn] ; char bufa[bufan] ; char auxbufa[auxbufan] ; kolbak_closure_t q[qlen] ; } -typedef skaclient_buffer_type(UNIXMESSAGE_BUFSIZE, UNIXMESSAGE_AUXBUFSIZE, UNIXMESSAGE_BUFSIZE, UNIXMESSAGE_AUXBUFSIZE, SKACLIENT_KOLBAK_SIZE) skaclient_buffer_t, *skaclient_buffer_t_ref ; +#define skaclient_buffer_type(bufsn, auxbufsn, bufan, auxbufan, qlen) struct { char bufs[bufsn] ; char auxbufs[auxbufsn] ; char bufa[bufan] ; char auxbufa[auxbufan] ; kolbak_closure q[qlen] ; } +typedef skaclient_buffer_type(UNIXMESSAGE_BUFSIZE, UNIXMESSAGE_AUXBUFSIZE, UNIXMESSAGE_BUFSIZE, UNIXMESSAGE_AUXBUFSIZE, SKACLIENT_KOLBAK_SIZE) skaclient_buffer, *skaclient_buffer_ref ; /* User structure */ -typedef struct skaclient_s skaclient_t, *skaclient_t_ref ; +typedef struct skaclient_s skaclient, *skaclient_ref ; struct skaclient_s { - unixmessage_receiver_t syncin ; - unixmessage_sender_t syncout ; - kolbak_queue_t kq ; - unixmessage_receiver_t asyncin ; - unixmessage_sender_t asyncout ; + unixmessage_receiver syncin ; + unixmessage_sender syncout ; + kolbak_queue kq ; + unixmessage_receiver asyncin ; + unixmessage_sender asyncout ; pid_t pid ; uint32_t options ; } ; #define SKACLIENT_ZERO { .syncin = UNIXMESSAGE_RECEIVER_ZERO, .syncout = UNIXMESSAGE_SENDER_ZERO, .kq = KOLBAK_QUEUE_ZERO, .asyncin = UNIXMESSAGE_RECEIVER_ZERO, .asyncout = UNIXMESSAGE_SENDER_ZERO, .pid = 0, .options = 0 } -extern skaclient_t const skaclient_zero ; +extern skaclient const skaclient_zero ; /* Callback data for init */ -typedef struct skaclient_cbdata_s skaclient_cbdata_t, *skaclient_cbdata_t_ref ; +typedef struct skaclient_cbdata_s skaclient_cbdata, *skaclient_cbdata_ref ; struct skaclient_cbdata_s { - skaclient_t *a ; + skaclient *a ; char const *after ; size_t afterlen ; } ; @@ -62,50 +63,50 @@ struct skaclient_cbdata_s /* Starting and ending */ -extern void skaclient_end (skaclient_t *) ; +extern void skaclient_end (skaclient *) ; -extern int skaclient_start_async (skaclient_t *, char *, size_t, char *, size_t, char *, size_t, char *, size_t, kolbak_closure_t *, size_t, char const *, uint32_t, char const *, size_t, char const *, size_t, skaclient_cbdata_t *) ; +extern int skaclient_start_async (skaclient *, char *, size_t, char *, size_t, char *, size_t, char *, size_t, kolbak_closure *, size_t, char const *, uint32_t, char const *, size_t, char const *, size_t, skaclient_cbdata *) ; #define skaclient_start_async_b(a, sb, path, options, before, beforelen, after, afterlen, blah) skaclient_start_async(a, (sb)->bufs, sizeof((sb)->bufs), (sb)->auxbufs, sizeof((sb)->auxbufs), (sb)->bufa, sizeof((sb)->bufa), (sb)->auxbufa, sizeof((sb)->auxbufa), (sb)->q, sizeof((sb)->q), path, options, before, beforelen, after, afterlen, blah) -extern int skaclient_startf_async (skaclient_t *, char *, size_t, char *, size_t, char *, size_t, char *, size_t, kolbak_closure_t *, size_t, char const *, char const *const *, char const *const *, uint32_t, char const *, size_t, char const *, size_t, skaclient_cbdata_t *) ; -#define skaclient_startf_async_b(a, sb, prog, argv, envp, options, before, beforelen, after, afterlen, blah) skaclient_startf_async(a, (sb)->bufs, sizeof((sb)->bufs), (sb)->auxbufs, sizeof((sb)->auxbufs), (sb)->bufa, sizeof((sb)->bufa), (sb)->auxbufa, sizeof((sb)->auxbufa), (sb)->q, sizeof((sb)->q) / sizeof(kolbak_closure_t), prog, argv, envp, options, before, beforelen, after, afterlen, blah) +extern int skaclient_startf_async (skaclient *, char *, size_t, char *, size_t, char *, size_t, char *, size_t, kolbak_closure *, size_t, char const *, char const *const *, char const *const *, uint32_t, char const *, size_t, char const *, size_t, skaclient_cbdata *) ; +#define skaclient_startf_async_b(a, sb, prog, argv, envp, options, before, beforelen, after, afterlen, blah) skaclient_startf_async(a, (sb)->bufs, sizeof((sb)->bufs), (sb)->auxbufs, sizeof((sb)->auxbufs), (sb)->bufa, sizeof((sb)->bufa), (sb)->auxbufa, sizeof((sb)->auxbufa), (sb)->q, sizeof((sb)->q) / sizeof(kolbak_closure), prog, argv, envp, options, before, beforelen, after, afterlen, blah) -extern int skaclient_start (skaclient_t *, char *, size_t, char *, size_t, char *, size_t, char *, size_t, kolbak_closure_t *, size_t, char const *, uint32_t, char const *, size_t, char const *, size_t, tain_t const *, tain_t *) ; -#define skaclient_start_b(a, sb, path, options, before, beforelen, after, afterlen, deadline, stamp) skaclient_start(a, (sb)->bufs, sizeof((sb)->bufs), (sb)->auxbufs, sizeof((sb)->auxbufs), (sb)->bufa, sizeof((sb)->bufa), (sb)->auxbufa, sizeof((sb)->auxbufa), (sb)->q, sizeof((sb)->q) / sizeof(kolbak_closure_t), path, options, before, beforelen, after, afterlen, deadline, stamp) +extern int skaclient_start (skaclient *, char *, size_t, char *, size_t, char *, size_t, char *, size_t, kolbak_closure *, size_t, char const *, uint32_t, char const *, size_t, char const *, size_t, tain const *, tain *) ; +#define skaclient_start_b(a, sb, path, options, before, beforelen, after, afterlen, deadline, stamp) skaclient_start(a, (sb)->bufs, sizeof((sb)->bufs), (sb)->auxbufs, sizeof((sb)->auxbufs), (sb)->bufa, sizeof((sb)->bufa), (sb)->auxbufa, sizeof((sb)->auxbufa), (sb)->q, sizeof((sb)->q) / sizeof(kolbak_closure), path, options, before, beforelen, after, afterlen, deadline, stamp) #define skaclient_start_g(a, bufs, bufsn, auxbufs, auxbufsn, bufa, bufan, auxbufa, auxbufan, q, qlen, path, options, before, beforelen, after, afterlen, deadline) skaclient_start(a, bufs, bufsn, auxbufs, auxbufsn, bufa, bufan, auxbufa, auxbufan, q, qlen, path, options, before, beforelen, after, afterlen, (deadline), &STAMP) #define skaclient_start_b_g(a, sb, path, options, before, beforelen, after, afterlen, deadline) skaclient_start_b(a, sb, path, options, before, beforelen, after, afterlen, (deadline), &STAMP) -extern int skaclient_startf (skaclient_t *, char *, size_t, char *, size_t, char *, size_t, char *, size_t, kolbak_closure_t *, size_t, char const *, char const *const *, char const *const *, uint32_t, char const *, size_t, char const *, size_t, tain_t const *, tain_t *) ; -#define skaclient_startf_b(a, sb, prog, argv, envp, options, before, beforelen, after, afterlen, deadline, stamp) skaclient_startf(a, (sb)->bufs, sizeof((sb)->bufs), (sb)->auxbufs, sizeof((sb)->auxbufs), (sb)->bufa, sizeof((sb)->bufa), (sb)->auxbufa, sizeof((sb)->auxbufa), (sb)->q, sizeof((sb)->q) / sizeof(kolbak_closure_t), prog, argv, envp, options, before, beforelen, after, afterlen, deadline, stamp) +extern int skaclient_startf (skaclient *, char *, size_t, char *, size_t, char *, size_t, char *, size_t, kolbak_closure *, size_t, char const *, char const *const *, char const *const *, uint32_t, char const *, size_t, char const *, size_t, tain const *, tain *) ; +#define skaclient_startf_b(a, sb, prog, argv, envp, options, before, beforelen, after, afterlen, deadline, stamp) skaclient_startf(a, (sb)->bufs, sizeof((sb)->bufs), (sb)->auxbufs, sizeof((sb)->auxbufs), (sb)->bufa, sizeof((sb)->bufa), (sb)->auxbufa, sizeof((sb)->auxbufa), (sb)->q, sizeof((sb)->q) / sizeof(kolbak_closure), prog, argv, envp, options, before, beforelen, after, afterlen, deadline, stamp) #define skaclient_startf_g(a, bufs, bufsn, auxbufs, auxbufsn, bufa, bufan, auxbufa, auxbufan, q, qlen, prog, argv, envp, options, before, beforelen, after, afterlen, deadline) skaclient_startf(a, bufs, bufsn, auxbufs, auxbufsn, bufa, bufan, auxbufa, auxbufan, q, qlen, prog, argv, envp, options, before, beforelen, after, afterlen, (deadline), &STAMP) #define skaclient_startf_b_g(a, sb, prog, argv, envp, options, before, beforelen, after, afterlen, deadline) skaclient_startf_b(a, sb, prog, argv, envp, options, before, beforelen, after, afterlen, (deadline), &STAMP) /* Writing */ -extern int skaclient_putmsg_and_close (skaclient_t *, unixmessage_t const *, unsigned char const *, unixmessage_handler_func_t *, void *) ; +extern int skaclient_putmsg_and_close (skaclient *, unixmessage const *, unsigned char const *, unixmessage_handler_func_ref, void *) ; #define skaclient_putmsg(a, m, cb, result) skaclient_putmsg_and_close(a, m, unixmessage_bits_closenone, cb, result) -extern int skaclient_putmsgv_and_close (skaclient_t *, unixmessage_v_t const *, unsigned char const *, unixmessage_handler_func_t *, void *) ; +extern int skaclient_putmsgv_and_close (skaclient *, unixmessagev const *, unsigned char const *, unixmessage_handler_func_ref, void *) ; #define skaclient_putmsgv(a, m, cb, result) skaclient_putmsgv_and_close(a, m, unixmessage_bits_closenone, cb, result) -extern int skaclient_put (skaclient_t *, char const *, size_t, unixmessage_handler_func_t *, void *) ; -extern int skaclient_putv (skaclient_t *, struct iovec const *, unsigned int, unixmessage_handler_func_t *, void *) ; +extern int skaclient_put (skaclient *, char const *, size_t, unixmessage_handler_func_ref, void *) ; +extern int skaclient_putv (skaclient *, struct iovec const *, unsigned int, unixmessage_handler_func_ref, void *) ; /* Writing and flushing */ -extern int skaclient_sendmsg_and_close (skaclient_t *, unixmessage_t const *, unsigned char const *, unixmessage_handler_func_t *, void *, tain_t const *, tain_t *) ; +extern int skaclient_sendmsg_and_close (skaclient *, unixmessage const *, unsigned char const *, unixmessage_handler_func_ref, void *, tain const *, tain *) ; #define skaclient_sendmsg_and_close_g(a, m, bits, cb, result, deadline) skaclient_sendmsg_and_close(a, m, bits, cb, result, (deadline), &STAMP) #define skaclient_sendmsg(a, m, cb, result, deadline, stamp) skaclient_sendmsg_and_close(a, m, unixmessage_bits_closenone, cb, result, deadline, stamp) #define skaclient_sendmsg_g(a, m, cb, result, deadline) skaclient_sendmsg(a, m, cb, result, (deadline), &STAMP) -extern int skaclient_sendmsgv_and_close (skaclient_t *, unixmessage_v_t const *, unsigned char const *, unixmessage_handler_func_t *, void *, tain_t const *, tain_t *) ; +extern int skaclient_sendmsgv_and_close (skaclient *, unixmessagev const *, unsigned char const *, unixmessage_handler_func_ref, void *, tain const *, tain *) ; #define skaclient_sendmsgv_and_close_g(a, m, bits, cb, result, deadline) skaclient_sendmsgv_and_close(a, m, bits, cb, result, (deadline), &STAMP) #define skaclient_sendmsgv(a, m, cb, result, deadline, stamp) skaclient_sendmsgv_and_close(a, m, unixmessage_bits_closenone, cb, result, deadline, stamp) #define skaclient_sendmsgv_g(a, m, cb, result, deadline) skaclient_sendmsgv(a, m, cb, result, (deadline), &STAMP) -extern int skaclient_send (skaclient_t *, char const *, size_t, unixmessage_handler_func_t *, void *, tain_t const *, tain_t *) ; +extern int skaclient_send (skaclient *, char const *, size_t, unixmessage_handler_func_ref, void *, tain const *, tain *) ; #define skaclient_send_g(a, s, len, cb, result, deadline) skaclient_send(a, s, len, cb, result, (deadline), &STAMP) -extern int skaclient_sendv (skaclient_t *, struct iovec const *, unsigned int, unixmessage_handler_func_t *, void *, tain_t const *, tain_t *) ; +extern int skaclient_sendv (skaclient *, struct iovec const *, unsigned int, unixmessage_handler_func_ref, void *, tain const *, tain *) ; #define skaclient_sendv_g(a, v, vlen, cb, result, deadline) skaclient_sendv(a, v, vlen, cb, result, (deadline), &STAMP) @@ -117,18 +118,18 @@ extern int skaclient_sendv (skaclient_t *, struct iovec const *, unsigned int, u #define skaclient_timed_flush(a, deadline, stamp) unixmessage_sender_timed_flush(&(a)->syncout, deadline, stamp) #define skaclient_timed_flush_g(a, deadline) skaclient_timed_flush(a, (deadline), &STAMP) -#define skaclient_supdate(a) unixmessage_handle(&(a)->syncin, (unixmessage_handler_func_t *)&kolbak_call, &(a)->kq) -#define skaclient_timed_supdate(a, deadline, stamp) unixmessage_timed_handle(&(a)->syncin, (unixmessage_handler_func_t *)&kolbak_call, &(a)->kq, deadline, stamp) +#define skaclient_supdate(a) unixmessage_handle(&(a)->syncin, (unixmessage_handler_func_ref)&kolbak_call, &(a)->kq) +#define skaclient_timed_supdate(a, deadline, stamp) unixmessage_timed_handle(&(a)->syncin, (unixmessage_handler_func_ref)&kolbak_call, &(a)->kq, deadline, stamp) #define skaclient_timed_supdate_g(a, deadline) skaclient_timed_supdate(a, (deadline), &STAMP) -extern int skaclient_syncify (skaclient_t *, tain_t const *, tain_t *) ; +extern int skaclient_syncify (skaclient *, tain const *, tain *) ; #define skaclient_fd(a) skaclient_afd(a) #define skaclient_afd(a) unixmessage_receiver_fd(&(a)->asyncin) #define skaclient_update(a, f, p) skaclient_aupdate(a, f, p) #define skaclient_aupdate(a, f, p) unixmessage_handle(&(a)->asyncin, f, p) -extern unixmessage_handler_func_t skaclient_default_cb ; +extern unixmessage_handler_func skaclient_default_cb ; /* When asyncout is actually used (skabus...) */ diff --git a/src/include/skalibs/skalibs.h b/src/include/skalibs/skalibs.h index ceaad27..5e24fe2 100644 --- a/src/include/skalibs/skalibs.h +++ b/src/include/skalibs/skalibs.h @@ -8,7 +8,9 @@ - skalibs/config.h: package configuration - skalibs/sysdeps.h: system-dependent feature test macros - skalibs/nonposix.h: pre-system headers definitions for POSIX extensions - - skalibs/posixishard.h: workarounds for failures to respect POSIX + - skalibs/bsdsnowflake.h: pre-system headers BSD-specific workarounds + - skalibs/nsig.h: SKALIBS_NSIG definition, requires nonposix+bsdsnowflake + - skalibs/posixishard.h: post-system headers workarounds for conformance failures */ #include <skalibs/posixplz.h> @@ -16,7 +18,6 @@ #include <skalibs/stdcrypto.h> #include <skalibs/random.h> #include <skalibs/datastruct.h> -#include <skalibs/biguint.h> #include <skalibs/unixonacid.h> #endif diff --git a/src/include/skalibs/skamisc.h b/src/include/skalibs/skamisc.h index 7e8ab3d..a266c3e 100644 --- a/src/include/skalibs/skamisc.h +++ b/src/include/skalibs/skamisc.h @@ -1,9 +1,10 @@ /* ISC license. */ -#ifndef SKAMISC_H -#define SKAMISC_H +#ifndef SKALIBS_SKAMISC_H +#define SKALIBS_SKAMISC_H #include <sys/types.h> + #include <skalibs/buffer.h> #include <skalibs/stralloc.h> @@ -29,6 +30,4 @@ extern int string_unquote_withdelim (char *, size_t *, char const *, size_t, siz extern int string_format (stralloc *, char const *, char const *, char const *const *) ; -#define skaoffsetof(n, s, field) do { s sofoftmp ; *(n) = (unsigned char *)&sofoftmp->field - (unsigned char *)&sofoftmp ; } while (0) - #endif diff --git a/src/include/skalibs/socket.h b/src/include/skalibs/socket.h index a114f29..1ee9970 100644 --- a/src/include/skalibs/socket.h +++ b/src/include/skalibs/socket.h @@ -1,7 +1,7 @@ /* ISC license. */ -#ifndef SOCKET_H -#define SOCKET_H +#ifndef SKALIBS_SOCKET_H +#define SKALIBS_SOCKET_H #include <stddef.h> #include <stdint.h> @@ -11,8 +11,11 @@ #include <skalibs/posixplz.h> #include <skalibs/tai.h> -typedef ssize_t socket_io_func_t (int, char *, size_t, char *, uint16_t *) ; -typedef socket_io_func_t *socket_io_func_t_ref ; +typedef ssize_t socket_io_func (int, char *, size_t, char *, uint16_t *) ; +typedef socket_io_func *socket_io_func_ref ; + +typedef ssize_t socket_iow_func (int, char const *, size_t, char const *, uint16_t) ; +typedef socket_iow_func *socket_iow_func_ref ; extern int socket_internal (int, int, int, unsigned int) ; extern int socketpair_internal (int, int, int, unsigned int, int *) ; @@ -58,7 +61,7 @@ extern int ipc_local (int, char *, size_t, int *) ; extern int ipc_connect (int, char const *) ; extern int ipc_connected (int) ; -extern int ipc_timed_connect (int, char const *, tain_t const *, tain_t *) ; +extern int ipc_timed_connect (int, char const *, tain const *, tain *) ; #define ipc_timed_connect_g(fd, path, deadline) ipc_timed_connect(fd, path, (deadline), &STAMP) extern ssize_t ipc_send (int, char const *, size_t, char const *) ; @@ -107,12 +110,12 @@ extern int socket_udp4_internal (unsigned int) ; #define socket_udp6_nbcoe() socket_udp6_internal(O_NONBLOCK|O_CLOEXEC) extern int socket_udp6_internal (unsigned int) ; -extern int socket_waitconn (int, tain_t const *, tain_t *) ; +extern int socket_waitconn (int, tain const *, tain *) ; #define socket_waitconn_g(fd, deadline) socket_waitconn(fd, (deadline), &STAMP) -extern int socket_deadlineconnstamp4 (int, char const *, uint16_t, tain_t const *, tain_t *) ; +extern int socket_deadlineconnstamp4 (int, char const *, uint16_t, tain const *, tain *) ; #define socket_deadlineconnstamp(s, ip, port, deadline, stamp) socket_deadlineconnstamp4(s, ip, port, deadline, stamp) #define socket_deadlineconnstamp4_g(fd, ip, port, deadline) socket_deadlineconnstamp4(fd, ip, port, (deadline), &STAMP) -extern int socket_deadlineconnstamp4_u32 (int, uint32_t, uint16_t, tain_t const *, tain_t *) ; +extern int socket_deadlineconnstamp4_u32 (int, uint32_t, uint16_t, tain const *, tain *) ; #define socket_deadlineconnstamp4_u32_g(fd, ip, port, deadline) socket_deadlineconnstamp4_u32(fd, ip, port, (deadline), &STAMP) extern int socket_timeoutconn (int, char const *, uint16_t, unsigned int) ; @@ -124,7 +127,7 @@ extern int socket_bind4_reuse (int, char const *, uint16_t) ; #define socket_listen(fd, b) ipc_listen(fd, b) extern int socket_connect6 (int, char const *, uint16_t) ; -extern int socket_deadlineconnstamp6 (int, char const *, uint16_t, tain_t const *, tain_t *) ; +extern int socket_deadlineconnstamp6 (int, char const *, uint16_t, tain const *, tain *) ; #define socket_deadlineconnstamp6_g(fd, ip6, port, deadline) socket_deadlineconnstamp6(fd, ip6, port, (deadline), &STAMP) extern int socket_bind6 (int, char const *, uint16_t) ; extern int socket_bind6_reuse (int, char const *, uint16_t) ; @@ -134,9 +137,8 @@ extern int socket_bind6_reuse (int, char const *, uint16_t) ; #define socket_accept4_coe(s, ip, port) socket_accept4_internal(s, ip, (port), O_CLOEXEC) #define socket_accept4_nbcoe(s, ip, port) socket_accept4_internal(s, ip, (port), O_NONBLOCK|O_CLOEXEC) extern int socket_accept4_internal (int, char *, uint16_t *, unsigned int) ; -extern socket_io_func_t socket_recv4 ; -extern ssize_t socket_send4 (int, char const *, size_t, char const *, uint16_t) ; -extern socket_io_func_t socket_ioloop_send4 ; +extern socket_io_func socket_recv4 ; +extern socket_iow_func socket_send4 ; extern int socket_local4 (int, char *, uint16_t *) ; extern int socket_remote4 (int, char *, uint16_t *) ; @@ -145,9 +147,8 @@ extern int socket_remote4 (int, char *, uint16_t *) ; #define socket_accept6_coe(s, ip6, port) socket_accept6_internal(s, ip6, (port), O_CLOEXEC) #define socket_accept6_nbcoe(s, ip6, port) socket_accept6_internal(s, ip6, (port), O_NONBLOCK|O_CLOEXEC) extern int socket_accept6_internal (int, char *, uint16_t *, unsigned int) ; -extern socket_io_func_t socket_recv6 ; -extern ssize_t socket_send6 (int, char const *, size_t, char const *, uint16_t) ; -extern socket_io_func_t socket_ioloop_send6 ; +extern socket_io_func socket_recv6 ; +extern socket_iow_func socket_send6 ; extern int socket_local6 (int, char *, uint16_t *) ; extern int socket_remote6 (int, char *, uint16_t *) ; @@ -158,7 +159,9 @@ extern void socket_tryreservein (int, unsigned int) ; /* Timed send and recv operations (for dgram sockets) */ -extern ssize_t socket_ioloop (int, char *, size_t, char *, uint16_t *, socket_io_func_t_ref, int, tain_t const *, tain_t *) ; +extern ssize_t socket_ioloop (int, char *, size_t, char *, uint16_t *, socket_io_func_ref, int, tain const *, tain *) ; +extern socket_io_func socket_ioloop_send4 ; +extern socket_io_func socket_ioloop_send6 ; #define socket_sendnb4(fd, buf, len, ip4, port, deadline, stamp) socket_ioloop(fd, buf, len, (char *)ip4, &(port), &socket_ioloop_send4, 1, deadline, stamp) #define socket_sendnb4_g(fd, buf, len, ip4, port, deadline) socket_sendnb4(fd, buf, len, ip4, port, (deadline), &STAMP) diff --git a/src/include/skalibs/stdcrypto.h b/src/include/skalibs/stdcrypto.h index dd40d0d..c04407b 100644 --- a/src/include/skalibs/stdcrypto.h +++ b/src/include/skalibs/stdcrypto.h @@ -1,10 +1,8 @@ /* ISC license. */ -#ifndef STDCRYPTO_H -#define STDCRYPTO_H +#ifndef SKALIBS_STDCRYPTO_H +#define SKALIBS_STDCRYPTO_H -#include <skalibs/rc4.h> -#include <skalibs/md5.h> #include <skalibs/sha1.h> #include <skalibs/sha256.h> #include <skalibs/sha512.h> diff --git a/src/include/skalibs/stddjb.h b/src/include/skalibs/stddjb.h index b2b1d32..ad80a66 100644 --- a/src/include/skalibs/stddjb.h +++ b/src/include/skalibs/stddjb.h @@ -38,7 +38,6 @@ #include <skalibs/iopause.h> #include <skalibs/lolstdio.h> #include <skalibs/netstring.h> -#include <skalibs/nsig.h> #include <skalibs/segfault.h> #include <skalibs/selfpipe.h> #include <skalibs/setgroups.h> diff --git a/src/include/skalibs/stralloc.h b/src/include/skalibs/stralloc.h index 9572251..ebd5715 100644 --- a/src/include/skalibs/stralloc.h +++ b/src/include/skalibs/stralloc.h @@ -1,7 +1,7 @@ /* ISC license. */ -#ifndef STRALLOC_H -#define STRALLOC_H +#ifndef SKALIBS_STRALLOC_H +#define SKALIBS_STRALLOC_H #include <string.h> #include <sys/uio.h> diff --git a/src/include/skalibs/strerr.h b/src/include/skalibs/strerr.h index 64665b5..34b0d3c 100644 --- a/src/include/skalibs/strerr.h +++ b/src/include/skalibs/strerr.h @@ -1,7 +1,7 @@ /* ISC license. */ -#ifndef STRERR_H -#define STRERR_H +#ifndef SKALIBS_STRERR_H +#define SKALIBS_STRERR_H #include <skalibs/gccattributes.h> diff --git a/src/include/skalibs/strerr2.h b/src/include/skalibs/strerr2.h index fa7cc02..5ccfca9 100644 --- a/src/include/skalibs/strerr2.h +++ b/src/include/skalibs/strerr2.h @@ -1,13 +1,12 @@ /* ISC license. */ -#ifndef STRERR2_H -#define STRERR2_H +#ifndef SKALIBS_STRERR2_H +#define SKALIBS_STRERR2_H #include <skalibs/strerr.h> extern char const *PROG ; - #define strerr_warnw1x(x1) \ strerr_warn3x(PROG, ": warning: ", (x1)) #define strerr_warnw2x(x1, x2) \ diff --git a/src/include/skalibs/surf.h b/src/include/skalibs/surf.h index 15e9215..d856d71 100644 --- a/src/include/skalibs/surf.h +++ b/src/include/skalibs/surf.h @@ -6,16 +6,16 @@ #include <sys/types.h> #include <stdint.h> -typedef struct SURFSchedule SURFSchedule, *SURFSchedule_ref, **SURFSchedule_ref_ref ; +typedef struct SURFSchedule SURFSchedule, *SURFSchedule_ref ; struct SURFSchedule { uint32_t seed[32] ; uint32_t in[12] ; + uint32_t pos ; char out[32] ; - unsigned int pos ; } ; -#define SURFSCHEDULE_ZERO { .seed = { 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, 0 }, .in = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, .out = "\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", .pos = 32 } +#define SURFSCHEDULE_ZERO { .seed = { 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, 0 }, .in = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, .pos = 32, .out = "\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" } extern void surf_init (SURFSchedule *, char const *) ; /* 160 chars */ extern void surf (SURFSchedule *, char *, size_t) ; diff --git a/src/include/skalibs/tai.h b/src/include/skalibs/tai.h index 82f665f..bb75972 100644 --- a/src/include/skalibs/tai.h +++ b/src/include/skalibs/tai.h @@ -1,15 +1,16 @@ /* ISC license. */ -#ifndef TAI_H -#define TAI_H +#ifndef SKALIBS_TAI_H +#define SKALIBS_TAI_H #include <stdint.h> #include <time.h> #include <sys/time.h> + #include <skalibs/gccattributes.h> #include <skalibs/uint64.h> -typedef struct tai_s tai_t, *tai_t_ref ; +typedef struct tai_s tai, *tai_ref ; struct tai_s { uint64_t x ; @@ -22,38 +23,38 @@ struct tai_s #define TAI_INFINITE { TAI_MAGIC + ((uint64_t)1 << 61) } #define tai_sec(t) ((t)->x) -extern int tai_u64 (tai_t *, uint64_t) ; +extern int tai_u64 (tai *, uint64_t) ; #define tai_unix(t, u) tai_u64(t, (TAI_MAGIC + (u))) #define tai_uint(t, u) tai_u64(t, (uint64_t)(u)) -extern int tai_now (tai_t *) ; +extern int tai_now (tai *) ; #define tai_relative_from_time(t, u) ((t)->x = (uint64_t)(u), 1) #define tai_from_time(t, u) tai_unix(t, u) #define tai_from_time_sysclock(t, u) tai_from_sysclock(t, (uint64_t)(u) + TAI_MAGIC) -extern int time_from_tai_relative (time_t *, tai_t const *) ; -extern int time_from_tai (time_t *, tai_t const *) ; -extern int time_sysclock_from_tai(time_t *, tai_t const *) ; +extern int time_from_tai_relative (time_t *, tai const *) ; +extern int time_from_tai (time_t *, tai const *) ; +extern int time_sysclock_from_tai(time_t *, tai const *) ; -extern int tai_from_sysclock (tai_t *, uint64_t) ; -extern int sysclock_from_tai (uint64_t *, tai_t const *) ; +extern int tai_from_sysclock (tai *, uint64_t) ; +extern int sysclock_from_tai (uint64_t *, tai const *) ; #define tai_approx(t) ((double)(tai_sec(t))) -extern int tai_add (tai_t *, tai_t const *, tai_t const *) ; -extern int tai_sub (tai_t *, tai_t const *, tai_t const *) ; +extern int tai_add (tai *, tai const *, tai const *) ; +extern int tai_sub (tai *, tai const *, tai const *) ; #define tai_less(t,u) (tai_sec(t) < tai_sec(u)) #define TAI_PACK 8 -extern void tai_pack (char *, tai_t const *) ; -extern void tai_unpack (char const *, tai_t *) ; -extern void tai_pack_little (char *, tai_t const *) ; -extern void tai_unpack_little (char const *, tai_t *) ; +extern void tai_pack (char *, tai const *) ; +extern void tai_unpack (char const *, tai *) ; +extern void tai_pack_little (char *, tai const *) ; +extern void tai_unpack_little (char const *, tai *) ; -typedef struct tain_s tain_t, *tain_t_ref ; +typedef struct tain_s tain, *tain_ref ; struct tain_s { - tai_t sec ; + tai sec ; uint32_t nano ; /* 0..999999999U */ } ; @@ -63,87 +64,87 @@ struct tain_s #define TAIN_INFINITE_RELATIVE { TAI_INFINITE_RELATIVE, 0 } #define TAIN_NANO500 { TAI_ZERO, 500 } -extern tain_t STAMP ; /* the global process wallclock */ -extern tain_t const tain_zero ; -extern tain_t const tain_infinite_relative ; -extern tain_t const tain_nano500 ; +extern tain STAMP ; /* the global process wallclock */ +extern tain const tain_zero ; +extern tain const tain_infinite_relative ; +extern tain const tain_nano500 ; #define tain_sec(a) ((a)->sec) #define tain_secp(a) (&(a)->sec) #define tain_nano(a) ((a)->nano) -extern int tain_relative_from_timeval (tain_t *, struct timeval const *) ; -extern int tain_from_timeval (tain_t *, struct timeval const *) ; -extern int tain_from_timeval_sysclock (tain_t *, struct timeval const *) ; -extern int timeval_from_tain_relative (struct timeval *, tain_t const *) ; -extern int timeval_from_tain (struct timeval *, tain_t const *) ; -extern int timeval_sysclock_from_tain (struct timeval *, tain_t const *) ; - -extern int tain_relative_from_timespec (tain_t *, struct timespec const *) ; -extern int tain_from_timespec (tain_t *, struct timespec const *) ; -extern int tain_from_timespec_sysclock (tain_t *, struct timespec const *) ; -extern int timespec_from_tain_relative (struct timespec *, tain_t const *) ; -extern int timespec_from_tain (struct timespec *, tain_t const *) ; -extern int timespec_sysclock_from_tain (struct timespec *, tain_t const *) ; - -typedef int tain_clockread_func_t (tain_t *) ; -typedef tain_clockread_func_t *tain_clockread_func_t_ref ; - -extern int tain_from_sysclock (tain_t *, tain_t const *) ; -extern int sysclock_from_tain (tain_t *, tain_t const *) ; -extern tain_clockread_func_t sysclock_get ; -extern tain_clockread_func_t tain_wallclock_read ; +extern int tain_relative_from_timeval (tain *, struct timeval const *) ; +extern int tain_from_timeval (tain *, struct timeval const *) ; +extern int tain_from_timeval_sysclock (tain *, struct timeval const *) ; +extern int timeval_from_tain_relative (struct timeval *, tain const *) ; +extern int timeval_from_tain (struct timeval *, tain const *) ; +extern int timeval_sysclock_from_tain (struct timeval *, tain const *) ; + +extern int tain_relative_from_timespec (tain *, struct timespec const *) ; +extern int tain_from_timespec (tain *, struct timespec const *) ; +extern int tain_from_timespec_sysclock (tain *, struct timespec const *) ; +extern int timespec_from_tain_relative (struct timespec *, tain const *) ; +extern int timespec_from_tain (struct timespec *, tain const *) ; +extern int timespec_sysclock_from_tain (struct timespec *, tain const *) ; + +typedef int tain_clockread_func (tain *) ; +typedef tain_clockread_func *tain_clockread_func_ref ; + +extern int tain_from_sysclock (tain *, tain const *) ; +extern int sysclock_from_tain (tain *, tain const *) ; +extern tain_clockread_func sysclock_get ; +extern tain_clockread_func tain_wallclock_read ; #define tain_wallclock_read_g() tain_wallclock_read(&STAMP) -extern int tain_stopwatch_init (tain_t *, clock_t, tain_t *) ; -extern int tain_stopwatch_read (tain_t *, clock_t, tain_t const *) ; +extern int tain_stopwatch_init (tain *, clock_t, tain *) ; +extern int tain_stopwatch_read (tain *, clock_t, tain const *) ; #define tain_stopwatch_read_g(cl, offset) tain_stopwatch_read(&STAMP, (cl), offset) -extern tain_clockread_func_t_ref tain_now ; +extern tain_clockread_func_ref tain_now ; #define tain_now_g() (*tain_now)(&STAMP) #define tain_copynow(t) (*(t) = STAMP) -extern tain_clockread_func_t tain_now_set_wallclock ; +extern tain_clockread_func tain_now_set_wallclock ; #define tain_now_set_wallclock_g() tain_now_set_wallclock(&STAMP) -extern tain_clockread_func_t tain_now_set_stopwatch ; +extern tain_clockread_func tain_now_set_stopwatch ; #define tain_now_set_stopwatch_g() tain_now_set_stopwatch(&STAMP) -extern int sysclock_set (tain_t const *) ; -extern int tain_setnow (tain_t const *) ; +extern int sysclock_set (tain const *) ; +extern int tain_setnow (tain const *) ; -extern double tain_approx (tain_t const *) gccattr_pure ; -extern double tain_frac (tain_t const *) gccattr_pure ; +extern double tain_approx (tain const *) gccattr_pure ; +extern double tain_frac (tain const *) gccattr_pure ; -extern int tain_from_millisecs (tain_t *, int) ; -extern int tain_to_millisecs (tain_t const *) gccattr_pure ; +extern int tain_from_millisecs (tain *, int) ; +extern int tain_to_millisecs (tain const *) gccattr_pure ; -extern int tain_add (tain_t *, tain_t const *, tain_t const *) ; +extern int tain_add (tain *, tain const *, tain const *) ; #define tain_add_g(deadline, tto) tain_add(deadline, &STAMP, tto) -extern int tain_addsec (tain_t *, tain_t const *, int) ; +extern int tain_addsec (tain *, tain const *, int) ; #define tain_addsec_g(deadline, n) tain_addsec(deadline, &STAMP, n) -extern int tain_sub (tain_t *, tain_t const *, tain_t const *) ; -extern int tain_less (tain_t const *, tain_t const *) gccattr_pure ; +extern int tain_sub (tain *, tain const *, tain const *) ; +extern int tain_less (tain const *, tain const *) gccattr_pure ; #define tain_future(deadline) tain_less(&STAMP, (deadline)) #define TAIN_PACK 12 -extern void tain_pack (char *, tain_t const *) ; -extern void tain_unpack (char const *, tain_t *) ; -extern void tain_pack_little (char *, tain_t const *) ; -extern void tain_unpack_little (char const *, tain_t *) ; +extern void tain_pack (char *, tain const *) ; +extern void tain_unpack (char const *, tain *) ; +extern void tain_pack_little (char *, tain const *) ; +extern void tain_unpack_little (char const *, tain *) ; #define TAIN_FMT 25 -extern size_t tain_fmt (char *, tain_t const *) ; -extern size_t tain_scan (char const *, tain_t *) ; +extern size_t tain_fmt (char *, tain const *) ; +extern size_t tain_scan (char const *, tain *) ; #define TAIN_FMTFRAC 19 -extern size_t tain_fmtfrac (char *, tain_t const *) ; +extern size_t tain_fmtfrac (char *, tain const *) ; #define tain_uint(a, u) tain_ulong(a, u) -extern int tain_ulong (tain_t *, unsigned long) ; -extern void tain_half (tain_t *, tain_t const *) ; +extern int tain_ulong (tain *, unsigned long) ; +extern void tain_half (tain *, tain const *) ; #define TIMESTAMP (1 + (TAIN_PACK << 1)) -extern size_t timestamp_fmt (char *, tain_t const *) ; -extern size_t timestamp_scan (char const *, tain_t *) ; -extern int timestamp_r (char *, tain_t *) ; +extern size_t timestamp_fmt (char *, tain const *) ; +extern size_t timestamp_scan (char const *, tain *) ; +extern int timestamp_r (char *, tain *) ; extern int timestamp (char *) ; #define timestamp_g(s) timestamp_fmt((s), &STAMP) diff --git a/src/include/skalibs/textclient.h b/src/include/skalibs/textclient.h index 17d4fff..970fadd 100644 --- a/src/include/skalibs/textclient.h +++ b/src/include/skalibs/textclient.h @@ -6,6 +6,7 @@ #include <sys/types.h> #include <sys/uio.h> #include <stdint.h> + #include <skalibs/allreadwrite.h> #include <skalibs/tai.h> #include <skalibs/textmessage.h> @@ -25,9 +26,9 @@ /* Server-side functions */ -extern int textclient_server_init (textmessage_receiver_t *, textmessage_sender_t *, textmessage_sender_t *, char const *, size_t, char const *, size_t, tain_t const *, tain_t *) ; -extern int textclient_server_init_frompipe (textmessage_receiver_t *, textmessage_sender_t *, textmessage_sender_t *, char const *, size_t, char const *, size_t, tain_t const *, tain_t *) ; -extern int textclient_server_init_fromsocket (textmessage_receiver_t *, textmessage_sender_t *, textmessage_sender_t *, char const *, size_t, char const *, size_t, tain_t const *, tain_t *) ; +extern int textclient_server_init (textmessage_receiver *, textmessage_sender *, textmessage_sender *, char const *, size_t, char const *, size_t, tain const *, tain *) ; +extern int textclient_server_init_frompipe (textmessage_receiver *, textmessage_sender *, textmessage_sender *, char const *, size_t, char const *, size_t, tain const *, tain *) ; +extern int textclient_server_init_fromsocket (textmessage_receiver *, textmessage_sender *, textmessage_sender *, char const *, size_t, char const *, size_t, tain const *, tain *) ; #define textclient_server_init_g(in, syncout, asyncout, before, beforelen, after, afterlen, deadline) textclient_server_init(in, syncout, asyncout, before, beforelen, after, afterlen, (deadline), &STAMP) #define textclient_server_init_frompipe_g(in, syncout, asyncout, before, beforelen, after, afterlen, deadline) textclient_server_init_frompipe(in, syncout, asyncout, before, beforelen, after, afterlen, (deadline), &STAMP) #define textclient_server_init_fromsocket_g(in, syncout, asyncout, before, beforelen, after, afterlen, deadline) textclient_server_init_fromsocket(in, syncout, asyncout, before, beforelen, after, afterlen, (deadline), &STAMP) @@ -41,27 +42,27 @@ extern int textclient_server_init_fromsocket (textmessage_receiver_t *, textmess /* User structure */ -typedef struct textclient_s textclient_t, *textclient_t_ref ; +typedef struct textclient_s textclient, *textclient_ref ; struct textclient_s { - textmessage_sender_t syncout ; - textmessage_receiver_t syncin ; - textmessage_receiver_t asyncin ; + textmessage_sender syncout ; + textmessage_receiver syncin ; + textmessage_receiver asyncin ; pid_t pid ; uint32_t options ; char syncbuf[TEXTCLIENT_BUFSIZE] ; char asyncbuf[TEXTCLIENT_BUFSIZE] ; } ; #define TEXTCLIENT_ZERO { .syncout = TEXTMESSAGE_SENDER_ZERO, .syncin = TEXTMESSAGE_RECEIVER_ZERO, .asyncin = TEXTMESSAGE_RECEIVER_ZERO, .pid = 0, .options = 0 } -extern textclient_t const textclient_zero ; +extern textclient const textclient_zero ; /* Starting and ending */ -extern void textclient_end (textclient_t *) ; +extern void textclient_end (textclient *) ; -extern int textclient_start (textclient_t *, char const *, uint32_t, char const *, size_t, char const *, size_t, tain_t const *, tain_t *) ; -extern int textclient_startf (textclient_t *, char const *const *, char const *const *, uint32_t, char const *, size_t, char const *, size_t, tain_t const *, tain_t *) ; +extern int textclient_start (textclient *, char const *, uint32_t, char const *, size_t, char const *, size_t, tain const *, tain *) ; +extern int textclient_startf (textclient *, char const *const *, char const *const *, uint32_t, char const *, size_t, char const *, size_t, tain const *, tain *) ; #define textclient_start_g(a, path, options, before, beforelen, after, afterlen, deadline) textclient_start(a, path, options, before, beforelen, after, afterlen, (deadline), &STAMP) #define textclient_startf_g(a, argv, envp, options, before, beforelen, after, afterlen, deadline) textclient_startf_b(a, argv, envp, options, before, beforelen, after, afterlen, (deadline), &STAMP) @@ -96,8 +97,8 @@ extern int textclient_startf (textclient_t *, char const *const *, char const *c #define textclient_exchange_g(a, s, len, ans, deadline) textclient_exchange(a, s, len, ans, (deadline), &STAMP) #define textclient_exchangev_g(a, v, n, ans, deadline) textclient_exchangev(a, v, n, ans, (deadline), &STAMP) -extern int textclient_command (textclient_t *, char const *, size_t, tain_t const *, tain_t *) ; -extern int textclient_commandv (textclient_t *, struct iovec const *, unsigned int, tain_t const *, tain_t *) ; +extern int textclient_command (textclient *, char const *, size_t, tain const *, tain *) ; +extern int textclient_commandv (textclient *, struct iovec const *, unsigned int, tain const *, tain *) ; #define textclient_command_g(a, s, len, deadline) textclient_command(a, s, len, (deadline), &STAMP) #define textclient_commandv_g(a, v, n, deadline) textclient_commandv(a, v, n, (deadline), &STAMP) diff --git a/src/include/skalibs/textmessage.h b/src/include/skalibs/textmessage.h index b7df659..9e645e2 100644 --- a/src/include/skalibs/textmessage.h +++ b/src/include/skalibs/textmessage.h @@ -5,6 +5,7 @@ #include <sys/uio.h> #include <stdint.h> + #include <skalibs/gccattributes.h> #include <skalibs/allreadwrite.h> #include <skalibs/bufalloc.h> @@ -18,26 +19,26 @@ /* Sender */ -typedef struct textmessage_sender_s textmessage_sender_t, *textmessage_sender_t_ref ; +typedef struct textmessage_sender_s textmessage_sender, *textmessage_sender_ref ; struct textmessage_sender_s { bufalloc out ; } ; #define TEXTMESSAGE_SENDER_ZERO { BUFALLOC_ZERO } -extern textmessage_sender_t const textmessage_sender_zero ; +extern textmessage_sender const textmessage_sender_zero ; #define TEXTMESSAGE_SENDER_INIT(fd) { BUFALLOC_INIT(&fd_write, (fd)) } #define textmessage_sender_init(ts, fd) bufalloc_init(&(ts)->out, &fd_write, fd) #define textmessage_sender_free(ts) bufalloc_free(&(ts)->out) #define textmessage_sender_fd(ts) bufalloc_fd(&(ts)->out) -extern int textmessage_sender_getfd (textmessage_sender_t const *) gccattr_pure ; +extern int textmessage_sender_getfd (textmessage_sender const *) gccattr_pure ; #define textmessage_sender_isempty(ts) bufalloc_isempty(&(ts)->out) -extern int textmessage_put (textmessage_sender_t *, char const *, size_t) ; -extern int textmessage_putv (textmessage_sender_t *, struct iovec const *, unsigned int) ; +extern int textmessage_put (textmessage_sender *, char const *, size_t) ; +extern int textmessage_putv (textmessage_sender *, struct iovec const *, unsigned int) ; -extern int textmessage_sender_flush (textmessage_sender_t *) ; -extern int textmessage_sender_timed_flush (textmessage_sender_t *, tain_t const *, tain_t *) ; +extern int textmessage_sender_flush (textmessage_sender *) ; +extern int textmessage_sender_timed_flush (textmessage_sender *, tain const *, tain *) ; #define textmessage_sender_timed_flush_g(ts, deadline) textmessage_sender_timed_flush(ts, (deadline), &STAMP) #define textmessage_send(ts, s, len) (textmessage_put(ts, s, len) && textmessage_sender_flush(ts)) @@ -50,7 +51,7 @@ extern int textmessage_sender_timed_flush (textmessage_sender_t *, tain_t const /* Receiver */ -typedef struct textmessage_receiver_s textmessage_receiver_t, *textmessage_receiver_t_ref ; +typedef struct textmessage_receiver_s textmessage_receiver, *textmessage_receiver_ref ; struct textmessage_receiver_s { buffer in ; @@ -59,44 +60,44 @@ struct textmessage_receiver_s uint32_t max ; } ; #define TEXTMESSAGE_RECEIVER_ZERO { BUFFER_ZERO, STRALLOC_ZERO, 0, 0 } -extern textmessage_receiver_t const textmessage_receiver_zero ; +extern textmessage_receiver const textmessage_receiver_zero ; #define TEXTMESSAGE_RECEIVER_INIT(fd, buf, len, n) { BUFFER_INIT(&buffer_read, (fd), buf, len), STRALLOC_ZERO, 0, n } -extern int textmessage_receiver_init (textmessage_receiver_t *, int, char *, size_t, uint32_t) ; -extern void textmessage_receiver_free (textmessage_receiver_t *) ; +extern int textmessage_receiver_init (textmessage_receiver *, int, char *, size_t, uint32_t) ; +extern void textmessage_receiver_free (textmessage_receiver *) ; #define textmessage_receiver_fd(tr) buffer_fd(&(tr)->in) #define textmessage_receiver_isempty(tr) buffer_isempty(&(tr)->in) #define textmessage_receiver_isfull(tr) buffer_isfull(&(tr)->in) -extern int textmessage_receiver_hasmsginbuf (textmessage_receiver_t const *) gccattr_pure ; +extern int textmessage_receiver_hasmsginbuf (textmessage_receiver const *) gccattr_pure ; -extern int textmessage_receive (textmessage_receiver_t *, struct iovec *) ; -extern int textmessage_timed_receive (textmessage_receiver_t *, struct iovec *, tain_t const *, tain_t *) ; +extern int textmessage_receive (textmessage_receiver *, struct iovec *) ; +extern int textmessage_timed_receive (textmessage_receiver *, struct iovec *, tain const *, tain *) ; #define textmessage_timed_receive_g(tr, v, deadline) textmessage_timed_receive(tr, v, (deadline), &STAMP) -typedef int textmessage_handler_func_t (struct iovec const *, void *) ; -typedef textmessage_handler_func_t *textmessage_handler_func_t_ref ; +typedef int textmessage_handler_func (struct iovec const *, void *) ; +typedef textmessage_handler_func *textmessage_handler_func_ref ; -extern int textmessage_handle (textmessage_receiver_t *, textmessage_handler_func_t_ref, void *) ; -extern int textmessage_timed_handle (textmessage_receiver_t *, textmessage_handler_func_t_ref, void *, tain_t const *, tain_t *) ; +extern int textmessage_handle (textmessage_receiver *, textmessage_handler_func_ref, void *) ; +extern int textmessage_timed_handle (textmessage_receiver *, textmessage_handler_func_ref, void *, tain const *, tain *) ; #define textmessage_timed_handle_g(tr, f, p, deadline) textmessage_timed_handle(tr, f, p, (deadline), &STAMP) /* Creating new textmessage channels via fd-passing over a socket */ -extern int textmessage_create_send_channel (int, textmessage_sender_t *, char const *, size_t, tain_t const *, tain_t *) ; -extern int textmessage_recv_channel (int, textmessage_receiver_t *, char *, size_t, char const *, size_t, tain_t const *, tain_t *) ; +extern int textmessage_create_send_channel (int, textmessage_sender *, char const *, size_t, tain const *, tain *) ; +extern int textmessage_recv_channel (int, textmessage_receiver *, char *, size_t, char const *, size_t, tain const *, tain *) ; /* Globals */ -extern textmessage_receiver_t textmessage_receiver_0_ ; +extern textmessage_receiver textmessage_receiver_0_ ; #define textmessage_receiver_0 (&textmessage_receiver_0_) -extern textmessage_sender_t textmessage_sender_1_ ; +extern textmessage_sender textmessage_sender_1_ ; #define textmessage_sender_1 (&textmessage_sender_1_) -extern textmessage_sender_t textmessage_sender_x_ ; +extern textmessage_sender textmessage_sender_x_ ; #define textmessage_sender_x (&textmessage_sender_x_) #endif diff --git a/src/include/skalibs/unix-timed.h b/src/include/skalibs/unix-timed.h index 86563d2..ffff5c3 100644 --- a/src/include/skalibs/unix-timed.h +++ b/src/include/skalibs/unix-timed.h @@ -1,10 +1,11 @@ /* ISC license. */ -#ifndef UNIX_TIMED_H -#define UNIX_TIMED_H +#ifndef SKALIBS_UNIX_TIMED_H +#define SKALIBS_UNIX_TIMED_H #include <sys/types.h> #include <sys/uio.h> + #include <skalibs/bufalloc.h> #include <skalibs/buffer.h> #include <skalibs/functypes.h> @@ -14,32 +15,32 @@ /* Timed "blocking" operations (the fd must still be non-blocking) */ -extern int timed_flush (void *, initfunc_t_ref, initfunc_t_ref, initfunc_t_ref, tain_t const *, tain_t *) ; +extern int timed_flush (void *, init_func_ref, init_func_ref, init_func_ref, tain const *, tain *) ; #define timed_flush_g(b, getfd, isnonempty, flush, deadline) timed_flush(b, getfd, isnonempty, flush, (deadline_), &STAMP) -extern ssize_t timed_get (void *, initfunc_t_ref, getfunc_t_ref, tain_t const *, tain_t *) ; +extern ssize_t timed_get (void *, init_func_ref, get_func_ref, tain const *, tain *) ; #define timed_get_g (b, getfd, get, deadline) timed_get(b, getfd, get, (deadline), &STAMP) -extern ssize_t buffer_timed_fill (buffer *, tain_t const *, tain_t *) ; +extern ssize_t buffer_timed_fill (buffer *, tain const *, tain *) ; #define buffer_timed_fill_g(b, deadline) buffer_timed_fill(b, (deadline), &STAMP) -extern int bufalloc_timed_flush (bufalloc *, tain_t const *, tain_t *) ; +extern int bufalloc_timed_flush (bufalloc *, tain const *, tain *) ; #define bufalloc_timed_flush_g(ba, deadline) bufalloc_timed_flush(ba, (deadline), &STAMP) -extern int buffer_timed_flush (buffer *, tain_t const *, tain_t *) ; +extern int buffer_timed_flush (buffer *, tain const *, tain *) ; #define buffer_timed_flush_g(b, deadline) buffer_timed_flush(b, (deadline), &STAMP) -extern size_t buffer_timed_get (buffer *, char *, size_t, tain_t const *, tain_t *) ; +extern size_t buffer_timed_get (buffer *, char *, size_t, tain const *, tain *) ; #define buffer_timed_get_g(b, buf, buflen, deadline) buffer_timed_get(b, buf, buflen, (deadline), &STAMP) -extern int timed_getln (buffer *, stralloc *, char, tain_t const *, tain_t *) ; +extern int timed_getln (buffer *, stralloc *, char, tain const *, tain *) ; #define timed_getln_g(b, sa, sep, deadline) timed_getln(b, sa, sep, (deadline), &STAMP) -extern ssize_t timed_getlnmax (buffer *, char *, size_t, size_t *, char, tain_t const *, tain_t *) ; +extern ssize_t timed_getlnmax (buffer *, char *, size_t, size_t *, char, tain const *, tain *) ; #define timed_getlnmax_g(b, max, maxlen, len, sep, deadline) timed_getlnmax(b, max, maxlen, len, sep, (deadline), &STAMP) -extern int netstring_timed_get (buffer *, stralloc *, tain_t const *, tain_t *) ; +extern int netstring_timed_get (buffer *, stralloc *, tain const *, tain *) ; #define netstring_timed_get_g(b, sa, deadline) netstring_timed_get(b, sa, (deadline), &STAMP) -extern int ipc_timed_send (int, char const *, size_t, tain_t const *, tain_t *) ; +extern int ipc_timed_send (int, char const *, size_t, tain const *, tain *) ; #define ipc_timed_send_g(fd, s, len, deadline) ipc_timed_send(fd, s, len, (deadline), &STAMP) -extern int ipc_timed_sendv (int, struct iovec const *, unsigned int, tain_t const *, tain_t *) ; +extern int ipc_timed_sendv (int, struct iovec const *, unsigned int, tain const *, tain *) ; #define ipc_timed_sendv_g(fd, v, n, deadline) ipc_timed_sendv(fd, v, n, (deadline), &STAMP) -extern ssize_t ipc_timed_recv (int, char *, size_t, char *, tain_t const *, tain_t *) ; +extern ssize_t ipc_timed_recv (int, char *, size_t, char *, tain const *, tain *) ; #define ipc_timed_recv_g(fd, s, len, path, deadline) ipc_timed_recv(fd, s, len, path, (deadline), &STAMP) #endif diff --git a/src/include/skalibs/unix-transactional.h b/src/include/skalibs/unix-transactional.h index bf4b636..a5e14b3 100644 --- a/src/include/skalibs/unix-transactional.h +++ b/src/include/skalibs/unix-transactional.h @@ -1,11 +1,12 @@ /* ISC license. */ -#ifndef UNIX_TRANSACTIONAL_H -#define UNIX_TRANSACTIONAL_H +#ifndef SKALIBS_UNIX_TRANSACTIONAL_H +#define SKALIBS_UNIX_TRANSACTIONAL_H #include <sys/types.h> #include <sys/stat.h> #include <sys/uio.h> + #include <skalibs/uint64.h> #include <skalibs/stralloc.h> @@ -40,27 +41,4 @@ extern int atomic_rm_rf (char const *) ; extern int atomic_rm_rf_tmp (char const *, stralloc *) ; extern int atomic_symlink (char const *, char const *, char const *) ; - -typedef struct dirdescriptor_s dirdescriptor_t, *dirdescriptor_t_ref ; -struct dirdescriptor_s -{ - int fd ; - char const *lnkfn ; - stralloc new ; -} ; - -#define DIRDESCRIPTOR_ZERO { .fd = 0, .lnkfn = 0, .new = STRALLOC_ZERO } - -extern int dd_open_read (dirdescriptor_t *, char const *) ; -extern int dd_open_write (dirdescriptor_t *, char const *, unsigned int) ; -extern void dd_close (dirdescriptor_t *) ; /* after dd_open_read */ -extern void dd_cancel (dirdescriptor_t *) ; /* after dd_open_write */ -extern int dd_commit (dirdescriptor_t *) ; /* after dd_open_write */ -extern int dd_commit_devino (dirdescriptor_t *, dev_t *, ino_t *) ; /* after dd_open_write */ - -#define dd_openreadnclose(blah, file, s, len) openreadnclose_at((blah)->fd, file, s, len) -#define dd_openslurpclose(blah, file, sa) openslurpclose_at((blah)->fd, file, sa) -#define dd_opengetlnclose(blah, file, sa, sep) opengetlnclose_at((blah)->fd, file, sa, sep) -#define dd_openwritenclose(blah, file, s, len) openwritenclose_at((blah)->fd, file, s, len) - #endif diff --git a/src/include/skalibs/unixconnection.h b/src/include/skalibs/unixconnection.h index 093d7c0..bc4fd79 100644 --- a/src/include/skalibs/unixconnection.h +++ b/src/include/skalibs/unixconnection.h @@ -1,24 +1,24 @@ /* ISC license. */ -#ifndef UNIXCONNECTION_H -#define UNIXCONNECTION_H +#ifndef SKALIBS_UNIXCONNECTION_H +#define SKALIBS_UNIXCONNECTION_H #include <skalibs/unixmessage.h> -typedef struct unixconnection_s unixconnection_t, *unixconnection_t_ref ; +typedef struct unixconnection_s unixconnection, *unixconnection_ref ; struct unixconnection_s { - unixmessage_sender_t out ; - unixmessage_receiver_t in ; + unixmessage_sender out ; + unixmessage_receiver in ; char mainbuf[UNIXMESSAGE_BUFSIZE] ; char auxbuf[UNIXMESSAGE_AUXBUFSIZE] ; } ; #define UNIXCONNECTION_ZERO { .out = UNIXMESSAGE_SENDER_ZERO, .in = UNIXMESSAGE_RECEIVER_ZERO } -extern unixconnection_t const unixconnection_zero ; +extern unixconnection const unixconnection_zero ; -extern void unixconnection_init (unixconnection_t *, int, int) ; -extern void unixconnection_init_withclosecb (unixconnection_t *, int, int, unixmessage_sender_closecb_func_t_ref, void *) ; -extern void unixconnection_free (unixconnection_t *) ; +extern void unixconnection_init (unixconnection *, int, int) ; +extern void unixconnection_init_withclosecb (unixconnection *, int, int, unixmessage_sender_closecb_func_ref, void *) ; +extern void unixconnection_free (unixconnection *) ; #define unixconnection_flush(io) unixmessage_sender_flush(&(io)->out) #define unixconnection_receive(io, m) unixmessage_receive(&(io)->in, m) diff --git a/src/include/skalibs/unixmessage.h b/src/include/skalibs/unixmessage.h index a246cd6..4ea6342 100644 --- a/src/include/skalibs/unixmessage.h +++ b/src/include/skalibs/unixmessage.h @@ -1,10 +1,11 @@ /* ISC license. */ -#ifndef UNIXMESSAGE_H -#define UNIXMESSAGE_H +#ifndef SKALIBS_UNIXMESSAGE_H +#define SKALIBS_UNIXMESSAGE_H #include <sys/uio.h> #include <stdint.h> + #include <skalibs/gccattributes.h> #include <skalibs/buffer.h> #include <skalibs/cbuffer.h> @@ -15,7 +16,7 @@ /* Message */ -typedef struct unixmessage_s unixmessage_t, *unixmessage_t_ref ; +typedef struct unixmessage_s unixmessage, *unixmessage_ref ; struct unixmessage_s { char *s ; @@ -24,20 +25,20 @@ struct unixmessage_s unsigned int nfds ; } ; #define UNIXMESSAGE_ZERO { .s = 0, .len = 0, .fds = 0, .nfds = 0 } -extern unixmessage_t const unixmessage_zero ; +extern unixmessage const unixmessage_zero ; -extern void unixmessage_drop (unixmessage_t const *) ; +extern void unixmessage_drop (unixmessage const *) ; -typedef struct unixmessage_v_s unixmessage_v_t, *unixmessage_v_t_ref ; -struct unixmessage_v_s +typedef struct unixmessagev_s unixmessagev, *unixmessagev_ref ; +struct unixmessagev_s { struct iovec *v ; unsigned int vlen ; int *fds ; unsigned int nfds ; } ; -#define UNIXMESSAGE_V_ZERO { .v = 0, .vlen = 0, .fds = 0, .nfds = 0 } -extern unixmessage_v_t const unixmessage_v_zero ; +#define UNIXMESSAGEV_ZERO { .v = 0, .vlen = 0, .fds = 0, .nfds = 0 } +extern unixmessagev const unixmessagev_zero ; #define UNIXMESSAGE_MAXSIZE (1U << 28) #define UNIXMESSAGE_MAXFDS 255 @@ -48,10 +49,10 @@ extern unixmessage_v_t const unixmessage_v_zero ; /* Sender */ -typedef void unixmessage_sender_closecb_func_t (int, void *) ; -typedef unixmessage_sender_closecb_func_t *unixmessage_sender_closecb_func_t_ref ; +typedef void unixmessage_sender_closecb_func (int, void *) ; +typedef unixmessage_sender_closecb_func *unixmessage_sender_closecb_func_ref ; -typedef struct unixmessage_sender_s unixmessage_sender_t, *unixmessage_sender_t_ref ; +typedef struct unixmessage_sender_s unixmessage_sender, *unixmessage_sender_ref ; struct unixmessage_sender_s { int fd ; @@ -60,47 +61,47 @@ struct unixmessage_sender_s genalloc offsets ; /* disize */ size_t head ; size_t shorty ; - unixmessage_sender_closecb_func_t_ref closecb ; + unixmessage_sender_closecb_func_ref closecb ; void *closecbdata ; } ; #define UNIXMESSAGE_SENDER_ZERO UNIXMESSAGE_SENDER_INIT(-1) #define UNIXMESSAGE_SENDER_INIT(s) UNIXMESSAGE_SENDER_INIT_WITHCLOSECB((s), &unixmessage_sender_closecb, 0) #define UNIXMESSAGE_SENDER_INIT_WITHCLOSECB(s, f, p) { .fd = (s), .data = STRALLOC_ZERO, .fds = GENALLOC_ZERO, .offsets = GENALLOC_ZERO, .head = 0, .shorty = 0, .closecb = (f), .closecbdata = (p) } -extern unixmessage_sender_t const unixmessage_sender_zero ; -extern unixmessage_sender_closecb_func_t unixmessage_sender_closecb ; -extern void unixmessage_sender_init (unixmessage_sender_t *, int) ; -extern void unixmessage_sender_init_withclosecb (unixmessage_sender_t *, int, unixmessage_sender_closecb_func_t_ref, void *) ; -extern void unixmessage_sender_free (unixmessage_sender_t *) ; +extern unixmessage_sender const unixmessage_sender_zero ; +extern unixmessage_sender_closecb_func unixmessage_sender_closecb ; +extern void unixmessage_sender_init (unixmessage_sender *, int) ; +extern void unixmessage_sender_init_withclosecb (unixmessage_sender *, int, unixmessage_sender_closecb_func_ref, void *) ; +extern void unixmessage_sender_free (unixmessage_sender *) ; #define unixmessage_sender_fd(b) ((b)->fd) -extern int unixmessage_sender_getfd (unixmessage_sender_t const *) gccattr_pure ; +extern int unixmessage_sender_getfd (unixmessage_sender const *) gccattr_pure ; #define unixmessage_sender_isempty(b) (!genalloc_len(unsigned int, &(b)->offsets)) -extern int unixmessage_put_and_close (unixmessage_sender_t *, unixmessage_t const *, unsigned char const *) ; +extern int unixmessage_put_and_close (unixmessage_sender *, unixmessage const *, unsigned char const *) ; #define unixmessage_put(b, m) unixmessage_put_and_close(b, m, unixmessage_bits_closenone) -extern int unixmessage_putv_and_close (unixmessage_sender_t *, unixmessage_v_t const *, unsigned char const *) ; +extern int unixmessage_putv_and_close (unixmessage_sender *, unixmessagev const *, unsigned char const *) ; #define unixmessage_putv(b, m) unixmessage_putv_and_close(b, m, unixmessage_bits_closenone) -extern int unixmessage_unput_and_maybe_drop (unixmessage_sender_t *, int) ; +extern int unixmessage_unput_and_maybe_drop (unixmessage_sender *, int) ; #define unixmessage_unput(b) unixmessage_unput_and_maybe_drop((b), 0) #define unixmessage_unput_and_drop(b) unixmessage_unput_and_maybe_drop((b), 1) extern unsigned char const *const unixmessage_bits_closenone ; extern unsigned char const *const unixmessage_bits_closeall ; -extern int unixmessage_sender_flush (unixmessage_sender_t *) ; -extern int unixmessage_sender_timed_flush (unixmessage_sender_t *, tain_t const *, tain_t *) ; +extern int unixmessage_sender_flush (unixmessage_sender *) ; +extern int unixmessage_sender_timed_flush (unixmessage_sender *, tain const *, tain *) ; #define unixmessage_sender_timed_flush_g(sender, deadline) unixmessage_sender_timed_flush(sender, (deadline), &STAMP) /* Receiver */ -typedef struct unixmessage_receiver_s unixmessage_receiver_t, *unixmessage_receiver_t_ref ; +typedef struct unixmessage_receiver_s unixmessage_receiver, *unixmessage_receiver_ref ; struct unixmessage_receiver_s { int fd ; - cbuffer_t mainb ; - cbuffer_t auxb ; + cbuffer mainb ; + cbuffer auxb ; stralloc maindata ; stralloc auxdata ; uint32_t mainlen ; @@ -119,40 +120,39 @@ struct unixmessage_receiver_s .auxlen = 0, \ .fds_ok = 3 \ } -extern int unixmessage_receiver_init (unixmessage_receiver_t *, int, char *, size_t, char *, size_t) ; -extern void unixmessage_receiver_free (unixmessage_receiver_t *) ; +extern int unixmessage_receiver_init (unixmessage_receiver *, int, char *, size_t, char *, size_t) ; +extern void unixmessage_receiver_free (unixmessage_receiver *) ; #define unixmessage_receiver_fd(b) ((b)->fd) #define unixmessage_receiver_isempty(b) (cbuffer_isempty(&(b)->mainb) && cbuffer_isempty(&(b)->auxb)) #define unixmessage_receiver_isfull(b) (cbuffer_isfull(&(b)->mainb) || cbuffer_isfull(&(b)->auxb)) -extern int unixmessage_receiver_hasmsginbuf (unixmessage_receiver_t const *) ; +extern int unixmessage_receiver_hasmsginbuf (unixmessage_receiver const *) ; -extern int unixmessage_receive (unixmessage_receiver_t *, unixmessage_t *) ; -extern int unixmessage_timed_receive (unixmessage_receiver_t *, unixmessage_t *, tain_t const *, tain_t *) ; +extern int unixmessage_receive (unixmessage_receiver *, unixmessage *) ; +extern int unixmessage_timed_receive (unixmessage_receiver *, unixmessage *, tain const *, tain *) ; #define unixmessage_timed_receive_g(receiver, msg, deadline) unixmessage_timed_receive(receiver, msg, (deadline), &STAMP) #define unixmessage_receiver_accept_fds(b) ((b)->fds_ok = 3) #define unixmessage_receiver_refuse_fds(b) ((b)->fds_ok = 1) #define unixmessage_receiver_ignore_fds(b) ((b)->fds_ok = 0) -typedef int unixmessage_handler_func_t (unixmessage_t const *, void *) ; -typedef unixmessage_handler_func_t *unixmessage_handler_func_t_ref ; +typedef int unixmessage_handler_func (unixmessage const *, void *) ; +typedef unixmessage_handler_func *unixmessage_handler_func_ref ; -extern int unixmessage_handle (unixmessage_receiver_t *, unixmessage_handler_func_t_ref, void *) ; -extern int unixmessage_timed_handle (unixmessage_receiver_t *, unixmessage_handler_func_t_ref, void *, tain_t const *, tain_t *) ; +extern int unixmessage_handle (unixmessage_receiver *, unixmessage_handler_func_ref, void *) ; +extern int unixmessage_timed_handle (unixmessage_receiver *, unixmessage_handler_func_ref, void *, tain const *, tain *) ; #define unixmessage_timed_handle_g(b, f, p, deadline) unixmessage_timed_handle(b, f, p, (deadline), &STAMP) - /* Globals */ -extern unixmessage_receiver_t unixmessage_receiver_0_ ; +extern unixmessage_receiver unixmessage_receiver_0_ ; #define unixmessage_receiver_0 (&unixmessage_receiver_0_) -extern unixmessage_sender_t unixmessage_sender_1_ ; +extern unixmessage_sender unixmessage_sender_1_ ; #define unixmessage_sender_1 (&unixmessage_sender_1_) -extern unixmessage_sender_t unixmessage_sender_x_ ; +extern unixmessage_sender unixmessage_sender_x_ ; #define unixmessage_sender_x (&unixmessage_sender_x_) #endif diff --git a/src/include/skalibs/unixonacid.h b/src/include/skalibs/unixonacid.h index 76aca9d..d9f952c 100644 --- a/src/include/skalibs/unixonacid.h +++ b/src/include/skalibs/unixonacid.h @@ -1,7 +1,7 @@ /* ISC license. */ -#ifndef UNIXONACID_H -#define UNIXONACID_H +#ifndef SKALIBS_UNIXONACID_H +#define SKALIBS_UNIXONACID_H #include <skalibs/unix-transactional.h> #include <skalibs/unix-timed.h> diff --git a/src/libdatastruct/avlnode_delete.c b/src/libdatastruct/avlnode_delete.c index 8e57bf8..e75e0cc 100644 --- a/src/libdatastruct/avlnode_delete.c +++ b/src/libdatastruct/avlnode_delete.c @@ -3,7 +3,7 @@ #include <skalibs/avlnode.h> #include "avlnode-internal.h" -uint32_t avlnode_delete (avlnode *s, uint32_t max, uint32_t *root, void const *k, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p) +uint32_t avlnode_delete (avlnode *s, uint32_t max, uint32_t *root, void const *k, dtok_func_ref dtok, cmp_func_ref f, void *p) { uint32_t stack[AVLNODE_MAXDEPTH] ; int spin[AVLNODE_MAXDEPTH] ; diff --git a/src/libdatastruct/avlnode_insertnode.c b/src/libdatastruct/avlnode_insertnode.c index fa94811..cfeb6d4 100644 --- a/src/libdatastruct/avlnode_insertnode.c +++ b/src/libdatastruct/avlnode_insertnode.c @@ -3,7 +3,7 @@ #include <skalibs/avlnode.h> #include "avlnode-internal.h" -uint32_t avlnode_insertnode (avlnode *s, uint32_t max, uint32_t r, uint32_t i, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p) +uint32_t avlnode_insertnode (avlnode *s, uint32_t max, uint32_t r, uint32_t i, dtok_func_ref dtok, cmp_func_ref f, void *p) { uint32_t stack[AVLNODE_MAXDEPTH] ; int spin[AVLNODE_MAXDEPTH] ; diff --git a/src/libdatastruct/avlnode_iter.c b/src/libdatastruct/avlnode_iter.c index 47813f2..50e1b3a 100644 --- a/src/libdatastruct/avlnode_iter.c +++ b/src/libdatastruct/avlnode_iter.c @@ -8,7 +8,7 @@ struct avlnode_iter_s avlnode const *s ; uint32_t max ; uint32_t cut ; - avliterfunc_t_ref f ; + avliter_func_ref f ; void *p ; } ; @@ -24,7 +24,7 @@ static uint32_t avlnode_iter_rec (struct avlnode_iter_s const *blah, uint32_t r, return avlnode_iter_rec(blah, blah->s[r].child[1], h+1) ; } -uint32_t avlnode_iter_nocancel (avlnode *s, uint32_t max, uint32_t cut, uint32_t r, avliterfunc_t_ref f, void *p) +uint32_t avlnode_iter_nocancel (avlnode *s, uint32_t max, uint32_t cut, uint32_t r, avliter_func_ref f, void *p) { struct avlnode_iter_s blah = { .s = s, .max = max, .cut = cut, .f = f, .p = p } ; return avlnode_iter_rec(&blah, r, 0) ; diff --git a/src/libdatastruct/avlnode_iter_withcancel.c b/src/libdatastruct/avlnode_iter_withcancel.c index c029799..a9e7802 100644 --- a/src/libdatastruct/avlnode_iter_withcancel.c +++ b/src/libdatastruct/avlnode_iter_withcancel.c @@ -3,7 +3,7 @@ #include <errno.h> #include <skalibs/avlnode.h> -int avlnode_iter_withcancel (avlnode *tree, uint32_t max, uint32_t root, avliterfunc_t_ref f, avliterfunc_t_ref cancelf, void *stuff) +int avlnode_iter_withcancel (avlnode *tree, uint32_t max, uint32_t root, avliter_func_ref f, avliter_func_ref cancelf, void *stuff) { uint32_t cut = avlnode_iter_nocancel(tree, max, max, root, f, stuff) ; if (cut != max) diff --git a/src/libdatastruct/avlnode_search.c b/src/libdatastruct/avlnode_search.c index dca53ee..373f255 100644 --- a/src/libdatastruct/avlnode_search.c +++ b/src/libdatastruct/avlnode_search.c @@ -3,7 +3,7 @@ #include <errno.h> #include <skalibs/avlnode.h> -int avlnode_search (avlnode const *s, uint32_t max, uint32_t r, void const *k, uint32_t *data, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p) +int avlnode_search (avlnode const *s, uint32_t max, uint32_t r, void const *k, uint32_t *data, dtok_func_ref dtok, cmp_func_ref f, void *p) { uint32_t i = avlnode_searchnode(s, max, r, k, dtok, f, p) ; if (i >= max) return (errno = ESRCH, 0) ; diff --git a/src/libdatastruct/avlnode_searchnode.c b/src/libdatastruct/avlnode_searchnode.c index f655561..044d18d 100644 --- a/src/libdatastruct/avlnode_searchnode.c +++ b/src/libdatastruct/avlnode_searchnode.c @@ -3,7 +3,7 @@ #include <skalibs/avlnode.h> #include "avlnode-internal.h" -uint32_t avlnode_searchnode (avlnode const *s, uint32_t max, uint32_t r, void const *k, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p) +uint32_t avlnode_searchnode (avlnode const *s, uint32_t max, uint32_t r, void const *k, dtok_func_ref dtok, cmp_func_ref f, void *p) { while (r < max) { diff --git a/src/libdatastruct/avltree_init.c b/src/libdatastruct/avltree_init.c index fd14a3a..a9ead6e 100644 --- a/src/libdatastruct/avltree_init.c +++ b/src/libdatastruct/avltree_init.c @@ -6,7 +6,7 @@ #include <skalibs/avlnode.h> #include <skalibs/avltree.h> -void avltree_init (avltree *t, uint32_t base, uint32_t fracnum, uint32_t fracden, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p) +void avltree_init (avltree *t, uint32_t base, uint32_t fracnum, uint32_t fracden, dtok_func_ref dtok, cmp_func_ref f, void *p) { gensetdyn_init(&t->x, sizeof(avlnode), base, fracnum, fracden) ; t->root = UINT32_MAX ; diff --git a/src/libdatastruct/avltreen_init.c b/src/libdatastruct/avltreen_init.c index 3ac4482..8d1dfa1 100644 --- a/src/libdatastruct/avltreen_init.c +++ b/src/libdatastruct/avltreen_init.c @@ -4,7 +4,7 @@ #include <skalibs/avlnode.h> #include <skalibs/avltreen.h> -void avltreen_init (avltreen *t, avlnode *storage, uint32_t *freelist, uint32_t size, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p) +void avltreen_init (avltreen *t, avlnode *storage, uint32_t *freelist, uint32_t size, dtok_func_ref dtok, cmp_func_ref f, void *p) { GENSET_init(&t->x, avlnode, storage, freelist, size) ; t->root = size ; diff --git a/src/libdatastruct/bigkv_fill.c b/src/libdatastruct/bigkv_fill.c index 06747c6..249a300 100644 --- a/src/libdatastruct/bigkv_fill.c +++ b/src/libdatastruct/bigkv_fill.c @@ -12,8 +12,8 @@ static void *bigkv_dtok (uint32_t d, void *p) { - bigkv_t *b = p ; - return b->storage.s + genalloc_s(bigkv_node_t, &b->nodes)[d].k ; + bigkv *b = p ; + return b->storage.s + genalloc_s(bigkv_node, &b->nodes)[d].k ; } static int bigkv_cmp (void const *a, void const *b, void *p) @@ -22,14 +22,14 @@ static int bigkv_cmp (void const *a, void const *b, void *p) return strcmp((char const *)a, (char const *)b) ; } -int bigkv_fill (bigkv_t *b, char const *const *argv, char delim, char const *prefix, char const *stop, uint32_t options) +int bigkv_fill (bigkv *b, char const *const *argv, char delim, char const *prefix, char const *stop, uint32_t options) { int i = 0 ; size_t prefixlen = prefix ? strlen(prefix) : 0 ; avltree_init(&b->map, 3, 3, 8, &bigkv_dtok, &bigkv_cmp, b) ; for (; argv[i] && !(stop && !strcmp(argv[i], stop)) ; i++) { - bigkv_node_t node = { .k = b->storage.len } ; + bigkv_node node = { .k = b->storage.len } ; char const *s = argv[i] ; size_t len = strlen(s) ; size_t pos ; @@ -56,11 +56,11 @@ int bigkv_fill (bigkv_t *b, char const *const *argv, char delim, char const *pre if (!stralloc_catb(&b->storage, s + pos + 1, len - pos)) goto err ; } else node.v = b->storage.len - 1 ; - if (isdup) genalloc_s(bigkv_node_t, &b->nodes)[d].v = node.v ; + if (isdup) genalloc_s(bigkv_node, &b->nodes)[d].v = node.v ; else { - d = genalloc_len(bigkv_node_t, &b->nodes) ; - if (!genalloc_append(bigkv_node_t, &b->nodes, &node)) goto err ; + d = genalloc_len(bigkv_node, &b->nodes) ; + if (!genalloc_append(bigkv_node, &b->nodes, &node)) goto err ; if (!avltree_insert(&b->map, d)) goto err ; } } diff --git a/src/libdatastruct/bigkv_free.c b/src/libdatastruct/bigkv_free.c index 848c614..68dbad5 100644 --- a/src/libdatastruct/bigkv_free.c +++ b/src/libdatastruct/bigkv_free.c @@ -5,10 +5,10 @@ #include <skalibs/avltree.h> #include <skalibs/bigkv.h> -void bigkv_free (bigkv_t *b) +void bigkv_free (bigkv *b) { avltree_free(&b->map) ; - genalloc_free(bigkv_node_t, &b->nodes) ; + genalloc_free(bigkv_node, &b->nodes) ; stralloc_free(&b->storage) ; *b = bigkv_zero ; } diff --git a/src/libdatastruct/bigkv_search.c b/src/libdatastruct/bigkv_search.c index bb91e3a..e9efe7a 100644 --- a/src/libdatastruct/bigkv_search.c +++ b/src/libdatastruct/bigkv_search.c @@ -4,9 +4,9 @@ #include <skalibs/avltree.h> #include <skalibs/bigkv.h> -char const *bigkv_search (bigkv_t const *b, char const *k) +char const *bigkv_search (bigkv const *b, char const *k) { uint32_t i ; if (!avltree_search(&b->map, k, &i)) return 0 ; - return b->storage.s + genalloc_s(bigkv_node_t, &b->nodes)[i].v ; + return b->storage.s + genalloc_s(bigkv_node, &b->nodes)[i].v ; } diff --git a/src/libdatastruct/bigkv_zero.c b/src/libdatastruct/bigkv_zero.c index 5fc262f..e0eca64 100644 --- a/src/libdatastruct/bigkv_zero.c +++ b/src/libdatastruct/bigkv_zero.c @@ -2,4 +2,4 @@ #include <skalibs/bigkv.h> -bigkv_t const bigkv_zero = BIGKV_ZERO ; +bigkv const bigkv_zero = BIGKV_ZERO ; diff --git a/src/libdatastruct/genset_deepfree.c b/src/libdatastruct/genset_deepfree.c index e219344..c58a5f9 100644 --- a/src/libdatastruct/genset_deepfree.c +++ b/src/libdatastruct/genset_deepfree.c @@ -5,12 +5,12 @@ static int freeiter (char *s, void *aux) { - freefunc_t_ref f = aux ; + free_func_ref f = aux ; (*f)((void *)s) ; return 1 ; } -void genset_deepfree (genset *g, freefunc_t_ref f) +void genset_deepfree (genset *g, free_func_ref f) { genset_iter(g, &freeiter, f) ; } diff --git a/src/libdatastruct/genset_iter_nocancel.c b/src/libdatastruct/genset_iter_nocancel.c index a7248a9..339f4b6 100644 --- a/src/libdatastruct/genset_iter_nocancel.c +++ b/src/libdatastruct/genset_iter_nocancel.c @@ -3,7 +3,7 @@ #include <skalibs/bitarray.h> #include <skalibs/genset.h> -uint32_t genset_iter_nocancel (genset *g, uint32_t n, iterfunc_t_ref f, void *stuff) +uint32_t genset_iter_nocancel (genset *g, uint32_t n, iter_func_ref f, void *stuff) { unsigned char bits[bitarray_div8(n)] ; uint32_t i = 0, j = 0, m = genset_n(g) ; diff --git a/src/libdatastruct/genset_iter_withcancel.c b/src/libdatastruct/genset_iter_withcancel.c index 1583cb4..1220dbc 100644 --- a/src/libdatastruct/genset_iter_withcancel.c +++ b/src/libdatastruct/genset_iter_withcancel.c @@ -4,7 +4,7 @@ #include <errno.h> #include <skalibs/genset.h> -int genset_iter_withcancel (genset *g, iterfunc_t_ref f, iterfunc_t_ref cancelf, void *stuff) +int genset_iter_withcancel (genset *g, iter_func_ref f, iter_func_ref cancelf, void *stuff) { uint32_t n = genset_iter(g, f, stuff) ; if (n < g->max) diff --git a/src/libdatastruct/gensetdyn_deepfree.c b/src/libdatastruct/gensetdyn_deepfree.c index 8822bc3..2b0c87c 100644 --- a/src/libdatastruct/gensetdyn_deepfree.c +++ b/src/libdatastruct/gensetdyn_deepfree.c @@ -5,12 +5,12 @@ static int freeiter (char *s, void *aux) { - freefunc_t_ref f = aux ; + free_func_ref f = aux ; (*f)((void *)s) ; return 1 ; } -void gensetdyn_deepfree (gensetdyn *g, freefunc_t_ref f) +void gensetdyn_deepfree (gensetdyn *g, free_func_ref f) { gensetdyn_iter(g, &freeiter, f) ; gensetdyn_free(g) ; diff --git a/src/libdatastruct/gensetdyn_iter.c b/src/libdatastruct/gensetdyn_iter.c index 7943ab0..8470adf 100644 --- a/src/libdatastruct/gensetdyn_iter.c +++ b/src/libdatastruct/gensetdyn_iter.c @@ -4,7 +4,7 @@ #include <skalibs/bitarray.h> #include <skalibs/gensetdyn.h> -uint32_t gensetdyn_iter_nocancel (gensetdyn *g, uint32_t n, iterfunc_t_ref f, void *stuff) +uint32_t gensetdyn_iter_nocancel (gensetdyn *g, uint32_t n, iter_func_ref f, void *stuff) { /* XXX: we may be called by a freeing function, so we cannot alloc - diff --git a/src/libdatastruct/gensetdyn_iter_withcancel.c b/src/libdatastruct/gensetdyn_iter_withcancel.c index 0c5c35d..0a250ce 100644 --- a/src/libdatastruct/gensetdyn_iter_withcancel.c +++ b/src/libdatastruct/gensetdyn_iter_withcancel.c @@ -4,7 +4,7 @@ #include <errno.h> #include <skalibs/gensetdyn.h> -int gensetdyn_iter_withcancel (gensetdyn *g, iterfunc_t_ref f, iterfunc_t_ref cancelf, void *stuff) +int gensetdyn_iter_withcancel (gensetdyn *g, iter_func_ref f, iter_func_ref cancelf, void *stuff) { uint32_t n = gensetdyn_iter_nocancel(g, gensetdyn_n(g), f, stuff) ; if (n < gensetdyn_n(g)) diff --git a/src/libposixplz/mkfiletemp.c b/src/libposixplz/mkfiletemp.c index 4eaf151..ac8426c 100644 --- a/src/libposixplz/mkfiletemp.c +++ b/src/libposixplz/mkfiletemp.c @@ -6,7 +6,7 @@ #include <skalibs/surf.h> #include <skalibs/posixplz.h> -int mkfiletemp (char *s, createfunc_t_ref f, mode_t mode, void *data) +int mkfiletemp (char *s, create_func_ref f, mode_t mode, void *data) { size_t len = strlen(s) ; size_t xlen = 0 ; diff --git a/src/libposixplz/mklinktemp.c b/src/libposixplz/mklinktemp.c index d1bee4b..a96ab45 100644 --- a/src/libposixplz/mklinktemp.c +++ b/src/libposixplz/mklinktemp.c @@ -9,13 +9,13 @@ static int f (char const *dst, mode_t mode, void *data) { - linkarg_t *la = data ; + linkarg *la = data ; (void)mode ; return (*la->lf)(la->src, dst) ; } -int mklinktemp (char const *src, char *dst, linkfunc_t_ref lf) +int mklinktemp (char const *src, char *dst, link_func_ref lf) { - linkarg_t la = { .lf = lf, .src = src } ; + linkarg la = { .lf = lf, .src = src } ; return mkfiletemp(dst, &f, 0600, &la) ; } diff --git a/src/libposixplz/posixplz-internal.h b/src/libposixplz/posixplz-internal.h index 544b020..060875e 100644 --- a/src/libposixplz/posixplz-internal.h +++ b/src/libposixplz/posixplz-internal.h @@ -1,12 +1,12 @@ /* ISC license. */ -#ifndef POSIXPLZ_INTERNAL_H -#define POSIXPLZ_INTERNAL_H +#ifndef SKALIBS_POSIXPLZ_INTERNAL_H +#define SKALIBS_POSIXPLZ_INTERNAL_H -typedef struct linkarg_s linkarg_t, *linkarg_t_ref ; +typedef struct linkarg_s linkarg, *linkarg_ref ; struct linkarg_s { - linkfunc_t_ref lf ; + link_func_ref lf ; char const *src ; } ; diff --git a/src/librandom/random_makeseed.c b/src/librandom/random_makeseed.c index 61244c6..c15ad5a 100644 --- a/src/librandom/random_makeseed.c +++ b/src/librandom/random_makeseed.c @@ -18,7 +18,7 @@ void random_makeseed (char *s) { SHA1Schedule bak = SHA1_INIT() ; { - tain_t now ; + tain now ; char tmp[256] ; uint32_t x = getpid() ; uint32_pack(tmp, x) ; diff --git a/src/librandom/surf.c b/src/librandom/surf.c index d226249..166f3c4 100644 --- a/src/librandom/surf.c +++ b/src/librandom/surf.c @@ -2,6 +2,7 @@ #include <string.h> #include <stdint.h> + #include <skalibs/uint32.h> #include <skalibs/surf.h> @@ -14,7 +15,7 @@ static void surfit (SURFSchedule *ctx) uint32_t z[8] ; uint32_t x ; uint32_t sum = 0 ; - unsigned int i = 0, loop = 0 ; ; + uint32_t i = 0, loop = 0 ; ; if (!++ctx->in[0] && !++ctx->in[1] && !++ctx->in[2]) ++ctx->in[3] ; for (; i < 12 ; i++) t[i] = ctx->in[i] ^ ctx->seed[12+i] ; diff --git a/src/librandom/surf_init.c b/src/librandom/surf_init.c index 53abdcc..49abe51 100644 --- a/src/librandom/surf_init.c +++ b/src/librandom/surf_init.c @@ -1,13 +1,14 @@ /* ISC license. */ +#include <stdint.h> + #include <skalibs/uint32.h> #include <skalibs/surf.h> void surf_init (SURFSchedule *ctx, char const *s) { - SURFSchedule zero = SURFSCHEDULE_ZERO ; - unsigned int i = 4 ; - *ctx = zero ; - for (; i < 12 ; i++) uint32_unpack(s + (i<<2) - 16, ctx->in + i) ; - for (i = 0 ; i < 32 ; i++) uint32_unpack(s + 32 + (i<<2), ctx->seed + i) ; + SURFSchedule z = SURFSCHEDULE_ZERO ; + for (uint32_t i = 4 ; i < 12 ; i++) uint32_unpack(s + (i<<2) - 16, z.in + i) ; + for (uint32_t i = 0 ; i < 32 ; i++) uint32_unpack(s + 32 + (i<<2), z.seed + i) ; + *ctx = z ; } diff --git a/src/libstdcrypto/md5-internal.h b/src/libstdcrypto/md5-internal.h deleted file mode 100644 index 59ffeea..0000000 --- a/src/libstdcrypto/md5-internal.h +++ /dev/null @@ -1,11 +0,0 @@ -/* ISC license. */ - -#ifndef MD5_INTERNAL_H -#define MD5_INTERNAL_H - -#include <stdint.h> -#include <skalibs/md5.h> - -extern void md5_transform (uint32_t * /* 4 uint32s */, uint32_t const * /* 16 uint32s */) ; - -#endif diff --git a/src/libstdcrypto/md5_final.c b/src/libstdcrypto/md5_final.c deleted file mode 100644 index 72d6529..0000000 --- a/src/libstdcrypto/md5_final.c +++ /dev/null @@ -1,30 +0,0 @@ -/* ISC license. */ - -#include <string.h> -#include <skalibs/uint32.h> -#include <skalibs/md5.h> -#include "md5-internal.h" - -void md5_final (MD5Schedule *ctx, char *digest /* 16 chars */) -{ - unsigned int count = (ctx->bits[0] >> 3) & 0x3F ; - unsigned char *p = ctx->in + count ; - *p++ = 0x80; - count = 63 - count ; - if (count < 8) - { - memset(p, 0, count) ; - uint32_little_endian((char *)ctx->in, 16) ; - md5_transform(ctx->buf, (uint32_t *)ctx->in) ; - memset(ctx->in, 0, 56) ; - } - else memset(p, 0, count - 8) ; - uint32_little_endian((char *)ctx->in, 14) ; - - memcpy(ctx->in + 56, &ctx->bits[0], 4) ; - memcpy(ctx->in + 60, &ctx->bits[1], 4) ; - - md5_transform(ctx->buf, (uint32_t *)ctx->in) ; - uint32_little_endian((char *)ctx->buf, 4) ; - memcpy(digest, ctx->buf, 16) ; -} diff --git a/src/libstdcrypto/md5_init.c b/src/libstdcrypto/md5_init.c deleted file mode 100644 index eac96b0..0000000 --- a/src/libstdcrypto/md5_init.c +++ /dev/null @@ -1,13 +0,0 @@ -/* ISC license. */ - -#include <skalibs/md5.h> - -void md5_init (MD5Schedule *ctx) -{ - ctx->buf[0] = 0x67452301U ; - ctx->buf[1] = 0xefcdab89U ; - ctx->buf[2] = 0x98badcfeU ; - ctx->buf[3] = 0x10325476U ; - ctx->bits[0] = 0 ; - ctx->bits[1] = 0 ; -} diff --git a/src/libstdcrypto/md5_transform.c b/src/libstdcrypto/md5_transform.c deleted file mode 100644 index 90be9ab..0000000 --- a/src/libstdcrypto/md5_transform.c +++ /dev/null @@ -1,90 +0,0 @@ -/* ISC license. */ - -#include "md5-internal.h" - -/* #define F1(x, y, z) (x & y | ~x & z) */ -#define F1(x, y, z) (z ^ (x & (y ^ z))) -#define F2(x, y, z) F1(z, x, y) -#define F3(x, y, z) (x ^ y ^ z) -#define F4(x, y, z) (y ^ (x | ~z)) - -#define MD5STEP(f, w, x, y, z, data, s) \ - ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x ) - -void md5_transform (uint32_t *buf /* 4 uint32s */, uint32_t const *in /* 16 uint32s */) -{ - uint32_t a = buf[0], b = buf[1], c = buf[2], d = buf[3] ; - - MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478U, 7) ; - MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756U, 12) ; - MD5STEP(F1, c, d, a, b, in[2] + 0x242070dbU, 17) ; - MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceeeU, 22) ; - MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0fafU, 7) ; - MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62aU, 12) ; - MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613U, 17) ; - MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501U, 22) ; - MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8U, 7) ; - MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7afU, 12) ; - MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1U, 17) ; - MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7beU, 22) ; - MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122U, 7) ; - MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193U, 12) ; - MD5STEP(F1, c, d, a, b, in[14] + 0xa679438eU, 17) ; - MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821U, 22) ; - - MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562U, 5) ; - MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340U, 9) ; - MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51U, 14) ; - MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aaU, 20) ; - MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105dU, 5) ; - MD5STEP(F2, d, a, b, c, in[10] + 0x02441453U, 9) ; - MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681U, 14) ; - MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8U, 20) ; - MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6U, 5) ; - MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6U, 9) ; - MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87U, 14) ; - MD5STEP(F2, b, c, d, a, in[8] + 0x455a14edU, 20) ; - MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905U, 5) ; - MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8U, 9) ; - MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9U, 14) ; - MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8aU, 20) ; - - MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942U, 4) ; - MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681U, 11) ; - MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122U, 16) ; - MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380cU, 23) ; - MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44U, 4) ; - MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9U, 11) ; - MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60U, 16) ; - MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70U, 23) ; - MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6U, 4) ; - MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127faU, 11) ; - MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085U, 16) ; - MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05U, 23) ; - MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039U, 4) ; - MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5U, 11) ; - MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8U, 16) ; - MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665U, 23) ; - - MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244U, 6) ; - MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97U, 10) ; - MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7U, 15) ; - MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039U, 21) ; - MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3U, 6) ; - MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92U, 10) ; - MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47dU, 15) ; - MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1U, 21) ; - MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4fU, 6) ; - MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0U, 10) ; - MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314U, 15) ; - MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1U, 21) ; - MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82U, 6) ; - MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235U, 10) ; - MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bbU, 15) ; - MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391U, 21) ; - - buf[0] += a ; - buf[1] += b ; - buf[2] += c ; - buf[3] += d ; -} diff --git a/src/libstdcrypto/md5_update.c b/src/libstdcrypto/md5_update.c deleted file mode 100644 index d61cd3f..0000000 --- a/src/libstdcrypto/md5_update.c +++ /dev/null @@ -1,37 +0,0 @@ -/* ISC license. */ - -#include <string.h> -#include <skalibs/uint32.h> -#include <skalibs/md5.h> -#include "md5-internal.h" - -void md5_update (MD5Schedule *ctx, char const *s, size_t len) -{ - uint32_t t = ctx->bits[0] ; - if ((ctx->bits[0] = t + (len << 3)) < t) - ctx->bits[1]++ ; - ctx->bits[1] += len >> 29 ; - t = (t >> 3) & 0x3f ; - if (t) - { - unsigned char *p = ctx->in + t ; - t = 64 - t ; - if (len < t) - { - memcpy(p, s, len) ; - return ; - } - memcpy(p, s, t) ; - uint32_little_endian((char *)ctx->in, 16) ; - md5_transform(ctx->buf, (uint32_t *)ctx->in) ; - s += t ; len -= t ; - } - while (len >= 64) - { - memcpy(ctx->in, s, 64) ; - uint32_little_endian((char *)ctx->in, 16) ; - md5_transform(ctx->buf, (uint32_t *)ctx->in) ; - s += 64 ; len -= 64 ; - } - memcpy(ctx->in, s, len) ; -} diff --git a/src/libstdcrypto/rc4.c b/src/libstdcrypto/rc4.c deleted file mode 100644 index 482c31a..0000000 --- a/src/libstdcrypto/rc4.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ISC license. */ -/* Thanks to Thomas Pornin <pornin@bolet.org> */ - -#include <skalibs/bytestr.h> -#include <skalibs/rc4.h> - -void rc4 (RC4Schedule *r, char const *in, char *out, size_t n) -{ - size_t i = 0 ; - for (; i < n ; i++) - { - unsigned char t ; - r->x = T8(r->x + 1) ; - t = r->tab[r->x] ; - r->y = T8(r->y + t) ; - r->tab[r->x] = r->tab[r->y] ; - r->tab[r->y] = t ; - out[i] = (unsigned char)in[i] ^ T8(r->tab[r->x] + r->tab[r->y]) ; - } -} diff --git a/src/libstdcrypto/rc4_init.c b/src/libstdcrypto/rc4_init.c deleted file mode 100644 index bbcefda..0000000 --- a/src/libstdcrypto/rc4_init.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ISC license. */ -/* Thanks to Thomas Pornin <pornin@bolet.org> */ - -#include <skalibs/bytestr.h> -#include <skalibs/rc4.h> - -void rc4_init (RC4Schedule *r, char const *key, size_t ksize) -{ - size_t j = 0 ; - unsigned int i = 0 ; - unsigned char c = 0; - - r->x = r->y = 0 ; - for (; i < 256 ; i++) r->tab[i] = i ; - for (i = 0 ; i < 256 ; i++) - { - unsigned char t = r->tab[i] ; - c = T8(c + (unsigned char)key[j] + t) ; - r->tab[i] = r->tab[c] ; - r->tab[c] = t ; - if (++j == ksize) j = 0 ; - } - { - char tmp[RC4_THROWAWAY] ; - rc4(r, tmp, tmp, RC4_THROWAWAY) ; - } -} diff --git a/src/libstdcrypto/sha1_feed.c b/src/libstdcrypto/sha1_feed.c index cb00852..0ca6f85 100644 --- a/src/libstdcrypto/sha1_feed.c +++ b/src/libstdcrypto/sha1_feed.c @@ -12,10 +12,9 @@ void sha1_feed (SHA1Schedule *ctx, unsigned char inb) ctx->in[ctx->b>>2] |= T8(inb) ; if (++ctx->b >= 64) { - unsigned int i = 0 ; sha1_transform(ctx->buf, ctx->in) ; ctx->b = 0 ; - for (i = 0 ; i < 16 ; i++) ctx->in[i] = 0 ; + for (uint32_t i = 0 ; i < 16 ; i++) ctx->in[i] = 0 ; } tmp = ctx->bits[0] ; ctx->bits[0] += 8 ; diff --git a/src/libstdcrypto/sha1_final.c b/src/libstdcrypto/sha1_final.c index d29a621..7205ed3 100644 --- a/src/libstdcrypto/sha1_final.c +++ b/src/libstdcrypto/sha1_final.c @@ -7,12 +7,11 @@ void sha1_final (SHA1Schedule *ctx, char *digest) { char pack[8] ; - unsigned int i = 0 ; uint32_pack_big(pack, ctx->bits[1]) ; uint32_pack_big(pack+4, ctx->bits[0]) ; sha1_feed(ctx, 0x80) ; while (ctx->b != 56) sha1_feed(ctx, 0) ; sha1_update(ctx, pack, 8) ; - for (; i < 5 ; i++) + for (unsigned int i = 0 ; i < 5 ; i++) uint32_pack_big(digest + (i<<2), ctx->buf[i]) ; } diff --git a/src/libstdcrypto/sha1_init.c b/src/libstdcrypto/sha1_init.c index 589230d..f8ca1f2 100644 --- a/src/libstdcrypto/sha1_init.c +++ b/src/libstdcrypto/sha1_init.c @@ -4,13 +4,12 @@ void sha1_init (SHA1Schedule *ctx) { - unsigned int i = 16 ; ctx->buf[0] = 0x67452301U ; ctx->buf[1] = 0xefcdab89U ; ctx->buf[2] = 0x98badcfeU ; ctx->buf[3] = 0x10325476U ; ctx->buf[4] = 0xc3d2e1f0U ; ctx->bits[0] = ctx->bits[1] = 0 ; - while (i--) ctx->in[i] = 0 ; + for (unsigned int i = 0 ; i < 16 ; i++) ctx->in[i] = 0 ; ctx->b = 0 ; } diff --git a/src/libstdcrypto/sha1_transform.c b/src/libstdcrypto/sha1_transform.c index c323c66..78f5137 100644 --- a/src/libstdcrypto/sha1_transform.c +++ b/src/libstdcrypto/sha1_transform.c @@ -1,5 +1,7 @@ /* ISC license. */ +#include <stdint.h> + #include "sha1-internal.h" #define F1(x, y, z) ((x & y) | ((~x) & z)) diff --git a/src/libstdcrypto/sha256_feed.c b/src/libstdcrypto/sha256_feed.c index 197b8f0..335f4ea 100644 --- a/src/libstdcrypto/sha256_feed.c +++ b/src/libstdcrypto/sha256_feed.c @@ -1,6 +1,7 @@ /* ISC license. */ #include <stdint.h> + #include <skalibs/bytestr.h> #include <skalibs/sha256.h> #include "sha256-internal.h" @@ -12,10 +13,9 @@ void sha256_feed (SHA256Schedule *ctx, unsigned char inb) ctx->in[ctx->b>>2] |= T8(inb) ; if (++ctx->b >= 64) { - unsigned int i = 0 ; sha256_transform(ctx->buf, ctx->in) ; ctx->b = 0 ; - for (; i < 16 ; i++) ctx->in[i] = 0 ; + for (uint32_t i = 0; i < 16 ; i++) ctx->in[i] = 0 ; } tmp = ctx->bits[0] ; ctx->bits[0] += 8 ; diff --git a/src/libstdcrypto/sha256_final.c b/src/libstdcrypto/sha256_final.c index ba4b5ea..67fc100 100644 --- a/src/libstdcrypto/sha256_final.c +++ b/src/libstdcrypto/sha256_final.c @@ -1,13 +1,13 @@ /* ISC license. */ #include <stdint.h> + #include <skalibs/bytestr.h> #include <skalibs/sha256.h> #include "sha256-internal.h" void sha256_final (SHA256Schedule *ctx, char *digest) { - unsigned int i = 0 ; unsigned char *p = (unsigned char *)digest ; uint32_t bits[2] = { ctx->bits[0], ctx->bits[1] } ; @@ -21,7 +21,7 @@ void sha256_final (SHA256Schedule *ctx, char *digest) sha256_feed(ctx, T8(bits[0]>>16)) ; sha256_feed(ctx, T8(bits[0]>>8)) ; sha256_feed(ctx, T8(bits[0])) ; - for (; i < 8 ; i++) + for (uint32_t i = 0 ; i < 8 ; i++) { *p++ = T8(ctx->buf[i]>>24) ; *p++ = T8(ctx->buf[i]>>16) ; diff --git a/src/libstdcrypto/sha256_update.c b/src/libstdcrypto/sha256_update.c index 70322ee..4eb44fc 100644 --- a/src/libstdcrypto/sha256_update.c +++ b/src/libstdcrypto/sha256_update.c @@ -5,6 +5,5 @@ void sha256_update (SHA256Schedule *ctx, char const *buf, size_t len) { - size_t i = 0 ; - for (; i < len ; i++) sha256_feed(ctx, (unsigned char)buf[i]) ; + for (size_t i = 0 ; i < len ; i++) sha256_feed(ctx, (unsigned char)buf[i]) ; } diff --git a/src/libstdcrypto/sha512-internal.h b/src/libstdcrypto/sha512-internal.h index cd6bcbd..16d1e93 100644 --- a/src/libstdcrypto/sha512-internal.h +++ b/src/libstdcrypto/sha512-internal.h @@ -5,6 +5,6 @@ #include <skalibs/sha512.h> -extern void sha512_transform (SHA512Schedule *ctx, unsigned char const *block) ; +extern void sha512_transform (SHA512Schedule *, unsigned char const *) ; #endif diff --git a/src/libstdcrypto/sha512_final.c b/src/libstdcrypto/sha512_final.c index ebda597..a24a03c 100644 --- a/src/libstdcrypto/sha512_final.c +++ b/src/libstdcrypto/sha512_final.c @@ -1,25 +1,25 @@ /* ISC license. */ -#include <skalibs/bytestr.h> +#include <string.h> + #include <skalibs/uint64.h> #include <skalibs/sha512.h> #include "sha512-internal.h" void sha512_final (SHA512Schedule *ctx, char *digest) { - unsigned int i = 0 ; - unsigned int pad = ctx->len % 128; + unsigned int pad = ctx->len & 0x7fU ; ctx->buf[pad++] = 0x80 ; if (pad > 112) { - byte_zero(ctx->buf + pad, 128 - pad) ; + memset(ctx->buf + pad, 0, 128 - pad) ; sha512_transform(ctx, ctx->buf) ; pad = 0 ; } - byte_zero(ctx->buf + pad, 120 - pad) ; + memset(ctx->buf + pad, 0, 120 - pad) ; uint64_pack_big((char *)ctx->buf + 120, ctx->len << 3) ; sha512_transform(ctx, ctx->buf) ; - for (; i < 8 ; i++) uint64_pack_big(digest + (i << 3), ctx->h[i]) ; + for (unsigned int i = 0 ; i < 8 ; i++) uint64_pack_big(digest + (i << 3), ctx->h[i]) ; } diff --git a/src/libstdcrypto/sha512_update.c b/src/libstdcrypto/sha512_update.c index a6c004f..7235226 100644 --- a/src/libstdcrypto/sha512_update.c +++ b/src/libstdcrypto/sha512_update.c @@ -1,6 +1,7 @@ /* ISC license. */ #include <string.h> + #include <skalibs/sha512.h> #include "sha512-internal.h" diff --git a/src/libstddjb/alarm_deadline.c b/src/libstddjb/alarm_deadline.c index 768ee5c..1844c8c 100644 --- a/src/libstddjb/alarm_deadline.c +++ b/src/libstddjb/alarm_deadline.c @@ -18,7 +18,7 @@ # define MYCLOCK CLOCK_REALTIME #endif -int alarm_deadline (tain_t const *deadline) +int alarm_deadline (tain const *deadline) { struct itimerspec it = { .it_interval = { .tv_sec = 0, .tv_nsec = 0 } } ; struct sigevent se = { .sigev_notify = SIGEV_SIGNAL, .sigev_signo = SIGALRM, .sigev_value = { .sival_int = 0 }, .sigev_notify_function = 0, .sigev_notify_attributes = 0 } ; @@ -36,9 +36,9 @@ int alarm_deadline (tain_t const *deadline) #else -int alarm_deadline (tain_t const *deadline) +int alarm_deadline (tain const *deadline) { - tain_t tto ; + tain tto ; tain_now(&tto) ; tain_sub(&tto, deadline, &tto) ; return alarm_timeout(&tto) ; diff --git a/src/libstddjb/alarm_timeout.c b/src/libstddjb/alarm_timeout.c index 630b524..1c1b865 100644 --- a/src/libstddjb/alarm_timeout.c +++ b/src/libstddjb/alarm_timeout.c @@ -18,7 +18,7 @@ # define MYCLOCK CLOCK_REALTIME #endif -int alarm_timeout (tain_t const *tto) +int alarm_timeout (tain const *tto) { struct itimerspec it = { .it_interval = { .tv_sec = 0, .tv_nsec = 0 } } ; struct sigevent se = { .sigev_notify = SIGEV_SIGNAL, .sigev_signo = SIGALRM, .sigev_value = { .sival_int = 0 }, .sigev_notify_function = 0, .sigev_notify_attributes = 0 } ; @@ -39,7 +39,7 @@ int alarm_timeout (tain_t const *tto) #include <sys/time.h> -int alarm_timeout (tain_t const *tto) +int alarm_timeout (tain const *tto) { struct itimerval it = { .it_interval = { .tv_sec = 0, .tv_usec = 0 } } ; if (!timeval_from_tain_relative(&it.it_value, tto)) return 0 ; @@ -52,7 +52,7 @@ int alarm_timeout (tain_t const *tto) #include <unistd.h> #include <limits.h> -int alarm_timeout (tain_t const *tto) +int alarm_timeout (tain const *tto) { int t = tain_to_millisecs(tto) ; if (t < 0 || t > INT_MAX - 999) return 0 ; diff --git a/src/libstddjb/allreadwrite.c b/src/libstddjb/allreadwrite.c index f377cf0..0e9351a 100644 --- a/src/libstddjb/allreadwrite.c +++ b/src/libstddjb/allreadwrite.c @@ -3,7 +3,7 @@ #include <errno.h> #include <skalibs/allreadwrite.h> -size_t allreadwrite (iofunc_t_ref op, int fd, char *buf, size_t len) +size_t allreadwrite (io_func_ref op, int fd, char *buf, size_t len) { size_t written = 0 ; while (len) diff --git a/src/libstddjb/allreadwritev.c b/src/libstddjb/allreadwritev.c index 9d10361..41d6eef 100644 --- a/src/libstddjb/allreadwritev.c +++ b/src/libstddjb/allreadwritev.c @@ -4,7 +4,7 @@ #include <skalibs/siovec.h> #include <skalibs/allreadwrite.h> -size_t allreadwritev (iovfunc_t_ref op, int fd, struct iovec const *v, unsigned int vlen) +size_t allreadwritev (iov_func_ref op, int fd, struct iovec const *v, unsigned int vlen) { size_t written = 0 ; struct iovec vv[vlen ? vlen : 1] ; diff --git a/src/libstddjb/allwrite.c b/src/libstddjb/allwrite.c index 66bc5d2..c23025c 100644 --- a/src/libstddjb/allwrite.c +++ b/src/libstddjb/allwrite.c @@ -5,5 +5,5 @@ size_t allwrite (int fd, char const *buf, size_t len) { - return allreadwrite((iofunc_t_ref)&fd_write, fd, (char *)buf, len) ; + return allreadwrite((io_func_ref)&fd_write, fd, (char *)buf, len) ; } diff --git a/src/libstddjb/bufalloc_flush.c b/src/libstddjb/bufalloc_flush.c index b6de51e..23a91d6 100644 --- a/src/libstddjb/bufalloc_flush.c +++ b/src/libstddjb/bufalloc_flush.c @@ -6,7 +6,7 @@ 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) ; + ba->p += allreadwrite((io_func_ref)ba->op, ba->fd, ba->x.s + ba->p, ba->x.len - ba->p) ; bufalloc_clean(ba) ; return !ba->x.len ; } diff --git a/src/libstddjb/buffer_init.c b/src/libstddjb/buffer_init.c index e143d70..d016cfb 100644 --- a/src/libstddjb/buffer_init.c +++ b/src/libstddjb/buffer_init.c @@ -4,7 +4,7 @@ #include <skalibs/cbuffer.h> #include <skalibs/buffer.h> -int buffer_init (buffer *b, iovfunc_t_ref op, int fd, char *s, size_t len) +int buffer_init (buffer *b, iov_func_ref op, int fd, char *s, size_t len) { if (!cbuffer_init(&b->c, s, len)) return 0 ; b->fd = fd ; diff --git a/src/libstddjb/cbuffer_get.c b/src/libstddjb/cbuffer_get.c index 315751a..a331799 100644 --- a/src/libstddjb/cbuffer_get.c +++ b/src/libstddjb/cbuffer_get.c @@ -4,7 +4,7 @@ #include <skalibs/siovec.h> #include <skalibs/cbuffer.h> -size_t cbuffer_get (cbuffer_t *b, char *s, size_t len) +size_t cbuffer_get (cbuffer *b, char *s, size_t len) { struct iovec v[2] ; size_t w ; diff --git a/src/libstddjb/cbuffer_getv.c b/src/libstddjb/cbuffer_getv.c index afdf8f9..99808fd 100644 --- a/src/libstddjb/cbuffer_getv.c +++ b/src/libstddjb/cbuffer_getv.c @@ -4,7 +4,7 @@ #include <skalibs/siovec.h> #include <skalibs/cbuffer.h> -size_t cbuffer_getv (cbuffer_t *b, struct iovec const *v, unsigned int n) +size_t cbuffer_getv (cbuffer *b, struct iovec const *v, unsigned int n) { struct iovec vsrc[2] ; size_t w ; diff --git a/src/libstddjb/cbuffer_init.c b/src/libstddjb/cbuffer_init.c index b4cb1bc..722ca4a 100644 --- a/src/libstddjb/cbuffer_init.c +++ b/src/libstddjb/cbuffer_init.c @@ -3,7 +3,7 @@ #include <errno.h> #include <skalibs/cbuffer.h> -int cbuffer_init (cbuffer_t *b, char *s, size_t len) +int cbuffer_init (cbuffer *b, char *s, size_t len) { if (len < 2) return (errno = EINVAL, 0) ; b->x = s ; diff --git a/src/libstddjb/cbuffer_put.c b/src/libstddjb/cbuffer_put.c index 428a430..6d57087 100644 --- a/src/libstddjb/cbuffer_put.c +++ b/src/libstddjb/cbuffer_put.c @@ -4,7 +4,7 @@ #include <skalibs/siovec.h> #include <skalibs/cbuffer.h> -size_t cbuffer_put (cbuffer_t *b, char const *s, size_t len) +size_t cbuffer_put (cbuffer *b, char const *s, size_t len) { struct iovec v[2] ; size_t w ; diff --git a/src/libstddjb/cbuffer_putv.c b/src/libstddjb/cbuffer_putv.c index 62af494..8afbee6 100644 --- a/src/libstddjb/cbuffer_putv.c +++ b/src/libstddjb/cbuffer_putv.c @@ -4,7 +4,7 @@ #include <skalibs/siovec.h> #include <skalibs/cbuffer.h> -size_t cbuffer_putv (cbuffer_t *b, struct iovec const *v, unsigned int n) +size_t cbuffer_putv (cbuffer *b, struct iovec const *v, unsigned int n) { struct iovec vdest[2] ; size_t w ; diff --git a/src/libstddjb/cbuffer_rpeek.c b/src/libstddjb/cbuffer_rpeek.c index 8592d00..c58a464 100644 --- a/src/libstddjb/cbuffer_rpeek.c +++ b/src/libstddjb/cbuffer_rpeek.c @@ -3,7 +3,7 @@ #include <sys/uio.h> #include <skalibs/cbuffer.h> -void cbuffer_rpeek (cbuffer_t const *b, struct iovec *v) +void cbuffer_rpeek (cbuffer const *b, struct iovec *v) { v[0].iov_base = b->x + b->p ; if (b->n >= b->p) diff --git a/src/libstddjb/cbuffer_rseek.c b/src/libstddjb/cbuffer_rseek.c index 9454c71..f53dc1b 100644 --- a/src/libstddjb/cbuffer_rseek.c +++ b/src/libstddjb/cbuffer_rseek.c @@ -2,7 +2,7 @@ #include <skalibs/cbuffer.h> -size_t cbuffer_rseek (cbuffer_t *b, size_t len) +size_t cbuffer_rseek (cbuffer *b, size_t len) { size_t max = cbuffer_len(b) ; if (len > max) len = max ; diff --git a/src/libstddjb/cbuffer_unget.c b/src/libstddjb/cbuffer_unget.c index 97a066c..07ddbbe 100644 --- a/src/libstddjb/cbuffer_unget.c +++ b/src/libstddjb/cbuffer_unget.c @@ -2,7 +2,7 @@ #include <skalibs/cbuffer.h> -size_t cbuffer_unget (cbuffer_t *b, size_t len) +size_t cbuffer_unget (cbuffer *b, size_t len) { size_t max = cbuffer_available(b) ; if (len > max) len = max ; diff --git a/src/libstddjb/cbuffer_unput.c b/src/libstddjb/cbuffer_unput.c index 0d9faa0..2801624 100644 --- a/src/libstddjb/cbuffer_unput.c +++ b/src/libstddjb/cbuffer_unput.c @@ -2,7 +2,7 @@ #include <skalibs/cbuffer.h> -size_t cbuffer_unput (cbuffer_t *b, size_t len) +size_t cbuffer_unput (cbuffer *b, size_t len) { size_t max = cbuffer_len(b) ; if (len > max) len = max ; diff --git a/src/libstddjb/cbuffer_wpeek.c b/src/libstddjb/cbuffer_wpeek.c index d023294..cb3fc5e 100644 --- a/src/libstddjb/cbuffer_wpeek.c +++ b/src/libstddjb/cbuffer_wpeek.c @@ -3,7 +3,7 @@ #include <sys/uio.h> #include <skalibs/cbuffer.h> -void cbuffer_wpeek (cbuffer_t const *b, struct iovec *v) +void cbuffer_wpeek (cbuffer const *b, struct iovec *v) { size_t last = (b->a - 1 + b->p) % b->a ; v[0].iov_base = b->x + b->n ; diff --git a/src/libstddjb/cbuffer_wseek.c b/src/libstddjb/cbuffer_wseek.c index a36ae62..35860a8 100644 --- a/src/libstddjb/cbuffer_wseek.c +++ b/src/libstddjb/cbuffer_wseek.c @@ -2,7 +2,7 @@ #include <skalibs/cbuffer.h> -size_t cbuffer_wseek (cbuffer_t *b, size_t len) +size_t cbuffer_wseek (cbuffer *b, size_t len) { size_t max = cbuffer_available(b) ; if (len > max) len = max ; diff --git a/src/libstddjb/deepsleepuntil.c b/src/libstddjb/deepsleepuntil.c index 77ac080..825014a 100644 --- a/src/libstddjb/deepsleepuntil.c +++ b/src/libstddjb/deepsleepuntil.c @@ -3,7 +3,7 @@ #include <skalibs/tai.h> #include <skalibs/iopause.h> -void deepsleepuntil (tain_t const *deadline, tain_t *stamp) +void deepsleepuntil (tain const *deadline, tain *stamp) { iopause_fd x ; while (tain_less(stamp, deadline)) iopause_stamp(&x, 0, deadline, stamp) ; diff --git a/src/libstddjb/genalloc_deepfree.c b/src/libstddjb/genalloc_deepfree.c index 2688047..17cdf3a 100644 --- a/src/libstddjb/genalloc_deepfree.c +++ b/src/libstddjb/genalloc_deepfree.c @@ -3,7 +3,7 @@ #include <skalibs/stralloc.h> #include <skalibs/genalloc.h> -void genalloc_deepfree_size (genalloc *g, freefunc_t_ref f, size_t size) +void genalloc_deepfree_size (genalloc *g, free_func_ref f, size_t size) { size_t len = g->len / size ; size_t i = 0 ; diff --git a/src/libstddjb/genwrite_stderr.c b/src/libstddjb/genwrite_stderr.c index 1d6bae3..cd8268a 100644 --- a/src/libstddjb/genwrite_stderr.c +++ b/src/libstddjb/genwrite_stderr.c @@ -3,4 +3,4 @@ #include <skalibs/buffer.h> #include <skalibs/genwrite.h> -genwrite_t genwrite_stderr = GENWRITE_BUFFER_INIT(buffer_2) ; +genwrite genwrite_stderr = GENWRITE_BUFFER_INIT(buffer_2) ; diff --git a/src/libstddjb/genwrite_stdout.c b/src/libstddjb/genwrite_stdout.c index 4fec080..d4dcf4c 100644 --- a/src/libstddjb/genwrite_stdout.c +++ b/src/libstddjb/genwrite_stdout.c @@ -3,4 +3,4 @@ #include <skalibs/buffer.h> #include <skalibs/genwrite.h> -genwrite_t genwrite_stdout = GENWRITE_BUFFER_INIT(buffer_1) ; +genwrite genwrite_stdout = GENWRITE_BUFFER_INIT(buffer_1) ; diff --git a/src/libstddjb/iobufferk_fill.c b/src/libstddjb/iobufferk_fill.c index 2117c45..c24ceba 100644 --- a/src/libstddjb/iobufferk_fill.c +++ b/src/libstddjb/iobufferk_fill.c @@ -32,7 +32,7 @@ static ssize_t iobufferk_fill_3 (iobufferk *k) return r ; } -iobufferk_input_func_t_ref const iobufferk_fill_f[4] = +iobufferk_input_func_ref const iobufferk_fill_f[4] = { &iobufferk_tee, &iobufferk_splice, &iobufferk_splice, &iobufferk_fill_3 } ; @@ -48,7 +48,7 @@ static ssize_t iobufferk_inosys (iobufferk *k) return (errno = ENOSYS, -1) ; } -iobufferk_input_func_t_ref const iobufferk_fill_f[4] = +iobufferk_input_func_ref const iobufferk_fill_f[4] = { &iobufferk_inosys, &iobufferk_inosys, &iobufferk_inosys, &iobufferk_inosys } ; diff --git a/src/libstddjb/iobufferk_finish.c b/src/libstddjb/iobufferk_finish.c index 4e4a73c..1640836 100644 --- a/src/libstddjb/iobufferk_finish.c +++ b/src/libstddjb/iobufferk_finish.c @@ -23,7 +23,7 @@ static void iobufferk_finish_3 (iobufferk *k) fd_close(k->p[0]) ; } -iobufferk_finish_func_t_ref const iobufferk_finish_f[4] = +iobufferk_finish_func_ref const iobufferk_finish_f[4] = { &iobufferk_finish_0, &iobufferk_nop, &iobufferk_nop, &iobufferk_finish_3 } ; @@ -37,7 +37,7 @@ static void iobufferk_nop (iobufferk *k) (void)k ; } -iobufferk_finish_func_t_ref const iobufferk_finish_f[4] = +iobufferk_finish_func_ref const iobufferk_finish_f[4] = { &iobufferk_nop, &iobufferk_nop, &iobufferk_nop, &iobufferk_nop } ; diff --git a/src/libstddjb/iobufferk_flush.c b/src/libstddjb/iobufferk_flush.c index 3c906dd..3f8d657 100644 --- a/src/libstddjb/iobufferk_flush.c +++ b/src/libstddjb/iobufferk_flush.c @@ -43,7 +43,7 @@ static int iobufferk_flush_3 (iobufferk *k) return 1 ; } -iobufferk_output_func_t_ref const iobufferk_flush_f[4] = +iobufferk_output_func_ref const iobufferk_flush_f[4] = { &iobufferk_flush_0, &fakeflush, &fakeflush, &iobufferk_flush_3 } ; @@ -59,7 +59,7 @@ static int iobufferk_onosys (iobufferk *k) return (errno = ENOSYS, -1) ; } -iobufferk_output_func_t_ref const iobufferk_flush_f[4] = +iobufferk_output_func_ref const iobufferk_flush_f[4] = { &iobufferk_onosys, &iobufferk_onosys, &iobufferk_onosys, &iobufferk_onosys } ; diff --git a/src/libstddjb/iobufferk_init.c b/src/libstddjb/iobufferk_init.c index 12a2822..b7a91d7 100644 --- a/src/libstddjb/iobufferk_init.c +++ b/src/libstddjb/iobufferk_init.c @@ -30,7 +30,7 @@ static int iobufferk_init_3 (iobufferk *k) return (pipecoe(k->p) >= 0) ; } -static iobufferk_output_func_t_ref iobufferk_init_f[4] = +static iobufferk_output_func_ref iobufferk_init_f[4] = { &iobufferk_init_0, &iobufferk_nofd, &iobufferk_nofd, &iobufferk_init_3 } ; diff --git a/src/libstddjb/iopause.c b/src/libstddjb/iopause.c index 38e3b54..7c62420 100644 --- a/src/libstddjb/iopause.c +++ b/src/libstddjb/iopause.c @@ -5,7 +5,7 @@ #ifdef SKALIBS_HASPPOLL -iopause_func_t_ref const iopause_ = &iopause_ppoll ; +iopause_func_ref const iopause_ = &iopause_ppoll ; #else @@ -13,11 +13,11 @@ iopause_func_t_ref const iopause_ = &iopause_ppoll ; #ifdef SKALIBS_FLAG_PREFERSELECT -iopause_func_t_ref const iopause_ = &iopause_select ; +iopause_func_ref const iopause_ = &iopause_select ; #else -iopause_func_t_ref const iopause_ = &iopause_poll ; +iopause_func_ref const iopause_ = &iopause_poll ; #endif diff --git a/src/libstddjb/iopause_poll.c b/src/libstddjb/iopause_poll.c index 396122b..0c7c681 100644 --- a/src/libstddjb/iopause_poll.c +++ b/src/libstddjb/iopause_poll.c @@ -2,16 +2,17 @@ #include <errno.h> #include <poll.h> + #include <skalibs/tai.h> #include <skalibs/iopause.h> -int iopause_poll (iopause_fd *x, unsigned int len, tain_t const *deadline, tain_t const *stamp) +int iopause_poll (iopause_fd *x, unsigned int len, tain const *deadline, tain const *stamp) { int millisecs = 0 ; if (!deadline) millisecs = -1 ; else if (tain_less(stamp, deadline)) { - tain_t t ; + tain t ; tain_sub(&t, deadline, stamp) ; millisecs = tain_to_millisecs(&t) ; } diff --git a/src/libstddjb/iopause_ppoll.c b/src/libstddjb/iopause_ppoll.c index 0c571e1..336bf8e 100644 --- a/src/libstddjb/iopause_ppoll.c +++ b/src/libstddjb/iopause_ppoll.c @@ -11,12 +11,12 @@ #include <skalibs/tai.h> #include <skalibs/iopause.h> -int iopause_ppoll (iopause_fd *x, unsigned int len, tain_t const *deadline, tain_t const *stamp) +int iopause_ppoll (iopause_fd *x, unsigned int len, tain const *deadline, tain const *stamp) { struct timespec ts = { .tv_sec = 0, .tv_nsec = 0 } ; if (deadline && tain_less(stamp, deadline)) { - tain_t delta ; + tain delta ; tain_sub(&delta, deadline, stamp) ; if (!timespec_from_tain_relative(&ts, &delta)) { @@ -32,7 +32,7 @@ int iopause_ppoll (iopause_fd *x, unsigned int len, tain_t const *deadline, tain #include <errno.h> #include <skalibs/iopause.h> -int iopause_ppoll (iopause_fd *x, unsigned int len, tain_t const *deadline, tain_t const *stamp) +int iopause_ppoll (iopause_fd *x, unsigned int len, tain const *deadline, tain const *stamp) { (void)x ; (void)len ; diff --git a/src/libstddjb/iopause_select.c b/src/libstddjb/iopause_select.c index a98767c..ec439d6 100644 --- a/src/libstddjb/iopause_select.c +++ b/src/libstddjb/iopause_select.c @@ -7,7 +7,7 @@ #include <skalibs/tai.h> #include <skalibs/iopause.h> -int iopause_select (iopause_fd *x, unsigned int len, tain_t const *deadline, tain_t const *stamp) +int iopause_select (iopause_fd *x, unsigned int len, tain const *deadline, tain const *stamp) { struct timeval tv = { .tv_sec = 0, .tv_usec = 0 } ; int nfds = 0 ; @@ -19,7 +19,7 @@ int iopause_select (iopause_fd *x, unsigned int len, tain_t const *deadline, tai FD_ZERO(&xfds) ; if (deadline && tain_less(stamp, deadline)) { - tain_t delta ; + tain delta ; tain_sub(&delta, deadline, stamp) ; if (!timeval_from_tain_relative(&tv, &delta)) { diff --git a/src/libstddjb/iopause_stamp.c b/src/libstddjb/iopause_stamp.c index 81056f4..a2ac8fa 100644 --- a/src/libstddjb/iopause_stamp.c +++ b/src/libstddjb/iopause_stamp.c @@ -4,7 +4,7 @@ #include <skalibs/tai.h> #include <skalibs/iopause.h> -int iopause_stamp (iopause_fd *x, unsigned int n, tain_t const *deadline, tain_t *stamp) +int iopause_stamp (iopause_fd *x, unsigned int n, tain const *deadline, tain *stamp) { int r ; do diff --git a/src/libstddjb/ip46_scan.c b/src/libstddjb/ip46_scan.c index 3e2f645..8b30fc1 100644 --- a/src/libstddjb/ip46_scan.c +++ b/src/libstddjb/ip46_scan.c @@ -1,9 +1,11 @@ /* ISC license. */ +#include <stddef.h> + #include <skalibs/fmtscan.h> #include <skalibs/ip46.h> -size_t ip46full_scan (char const *s, ip46full_t *ip) +size_t ip46full_scan (char const *s, ip46full *ip) { size_t len = ip6_scan(s, ip->ip) ; if (len) ip->is6 = 1 ; diff --git a/src/libstddjb/ip46_scanlist.c b/src/libstddjb/ip46_scanlist.c index d6d5cbc..1211ac3 100644 --- a/src/libstddjb/ip46_scanlist.c +++ b/src/libstddjb/ip46_scanlist.c @@ -1,15 +1,16 @@ /* ISC license. */ #include <string.h> + #include <skalibs/fmtscan.h> #include <skalibs/ip46.h> -size_t ip46full_scanlist (ip46full_t *out, size_t max, char const *s, size_t *num) +size_t ip46full_scanlist (ip46full *out, size_t max, char const *s, size_t *num) { size_t n = 0, w = 0 ; for (; s[w] && (n < max) ; n++) { - ip46full_t z ; + ip46full z ; size_t i = ip6_scan(s + w, z.ip) ; if (i) z.is6 = 1 ; else diff --git a/src/libstddjb/ipc_timed_connect.c b/src/libstddjb/ipc_timed_connect.c index ff88018..495f9e6 100644 --- a/src/libstddjb/ipc_timed_connect.c +++ b/src/libstddjb/ipc_timed_connect.c @@ -6,7 +6,7 @@ #include <skalibs/iopause.h> #include <skalibs/socket.h> -int ipc_timed_connect (int s, char const *path, tain_t const *deadline, tain_t *stamp) +int ipc_timed_connect (int s, char const *path, tain const *deadline, tain *stamp) { if (!ipc_connect(s, path)) { diff --git a/src/libstddjb/localtm_from_tai.c b/src/libstddjb/localtm_from_tai.c index c11131c..8b7fa22 100644 --- a/src/libstddjb/localtm_from_tai.c +++ b/src/libstddjb/localtm_from_tai.c @@ -4,7 +4,7 @@ #include <skalibs/uint64.h> #include <skalibs/djbtime.h> -int localtm_from_tai (struct tm *l, tai_t const *t, int tz) +int localtm_from_tai (struct tm *l, tai const *t, int tz) { uint64_t u ; int h = ltm64_from_tai(&u, t) ; diff --git a/src/libstddjb/localtmn_fmt.c b/src/libstddjb/localtmn_fmt.c index 25d5786..00147ec 100644 --- a/src/libstddjb/localtmn_fmt.c +++ b/src/libstddjb/localtmn_fmt.c @@ -3,7 +3,7 @@ #include <skalibs/uint32.h> #include <skalibs/djbtime.h> -size_t localtmn_fmt (char *s, localtmn_t const *l) +size_t localtmn_fmt (char *s, localtmn const *l) { char *p = s ; p += localtm_fmt(p, &l->tm) ; *p++ = '.' ; diff --git a/src/libstddjb/localtmn_from_sysclock.c b/src/libstddjb/localtmn_from_sysclock.c index f02927e..19f724b 100644 --- a/src/libstddjb/localtmn_from_sysclock.c +++ b/src/libstddjb/localtmn_from_sysclock.c @@ -1,9 +1,10 @@ /* ISC license. */ #include <time.h> + #include <skalibs/djbtime.h> -int localtmn_from_sysclock (localtmn_t *l, tain_t const *a, int tz) +int localtmn_from_sysclock (localtmn *l, tain 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 f94f294..9860895 100644 --- a/src/libstddjb/localtmn_from_tain.c +++ b/src/libstddjb/localtmn_from_tain.c @@ -3,7 +3,7 @@ #include <time.h> #include <skalibs/djbtime.h> -int localtmn_from_tain (localtmn_t *l, tain_t const *a, int tz) +int localtmn_from_tain (localtmn *l, tain 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 4ecfdd7..caacd6a 100644 --- a/src/libstddjb/localtmn_scan.c +++ b/src/libstddjb/localtmn_scan.c @@ -3,9 +3,9 @@ #include <skalibs/uint32.h> #include <skalibs/djbtime.h> -size_t localtmn_scan (char const *s, localtmn_t *l) +size_t localtmn_scan (char const *s, localtmn *l) { - localtmn_t m ; + localtmn m ; size_t n = localtm_scan(s, &m.tm) ; if (!n) return 0 ; s += n ; diff --git a/src/libstddjb/ltm64_from_sysclock.c b/src/libstddjb/ltm64_from_sysclock.c index 4804b39..648ac3b 100644 --- a/src/libstddjb/ltm64_from_sysclock.c +++ b/src/libstddjb/ltm64_from_sysclock.c @@ -9,7 +9,7 @@ int ltm64_from_sysclock (uint64_t *u) { - tai_t t = { .x = *u + 10U } ; + tai t = { .x = *u + 10U } ; return ltm64_from_tai(u, &t) ; } diff --git a/src/libstddjb/ltm64_from_tai.c b/src/libstddjb/ltm64_from_tai.c index 39e6205..01709fa 100644 --- a/src/libstddjb/ltm64_from_tai.c +++ b/src/libstddjb/ltm64_from_tai.c @@ -3,7 +3,7 @@ #include <skalibs/djbtime.h> #include "djbtime-internal.h" -int ltm64_from_tai (uint64_t *u, tai_t const *t) +int ltm64_from_tai (uint64_t *u, tai const *t) { switch (skalibs_tzisright()) { diff --git a/src/libstddjb/ntp_from_tain.c b/src/libstddjb/ntp_from_tain.c index 276a775..85a338a 100644 --- a/src/libstddjb/ntp_from_tain.c +++ b/src/libstddjb/ntp_from_tain.c @@ -5,7 +5,7 @@ #include <skalibs/tai.h> #include <skalibs/djbtime.h> -int ntp_from_tain (uint64_t *u, tain_t const *a) +int ntp_from_tain (uint64_t *u, tain const *a) { uint64_t secs, frac ; if (!utc_from_tai(&secs, tain_secp(a))) return 0 ; diff --git a/src/libstddjb/selfpipe-internal.h b/src/libstddjb/selfpipe-internal.h index 994c179..08d5738 100644 --- a/src/libstddjb/selfpipe-internal.h +++ b/src/libstddjb/selfpipe-internal.h @@ -21,7 +21,7 @@ extern int selfpipe_fd ; extern int selfpipe[2] ; #define selfpipe_fd selfpipe[0] -extern struct skasigaction const selfpipe_ssa ; +extern sig_func_ref selfpipe_tophalf ; #endif diff --git a/src/libstddjb/selfpipe_finish.c b/src/libstddjb/selfpipe_finish.c index 60899eb..db42430 100644 --- a/src/libstddjb/selfpipe_finish.c +++ b/src/libstddjb/selfpipe_finish.c @@ -6,36 +6,48 @@ #ifdef SKALIBS_HASSIGNALFD +#include <errno.h> #include <signal.h> + #include <skalibs/djbunix.h> -#include "selfpipe-internal.h" #include <skalibs/selfpipe.h> +#include "selfpipe-internal.h" void selfpipe_finish (void) { + int e = errno ; + fd_close(selfpipe_fd) ; sigprocmask(SIG_UNBLOCK, &selfpipe_caught, 0) ; sigemptyset(&selfpipe_caught) ; - fd_close(selfpipe_fd) ; selfpipe_fd = -1 ; + errno = e ; } #else #include <skalibs/nonposix.h> +#include <skalibs/bsdsnowflake.h> + +#include <errno.h> #include <signal.h> -#include <skalibs/sig.h> + #include <skalibs/nsig.h> +#include <skalibs/sig.h> #include <skalibs/djbunix.h> -#include "selfpipe-internal.h" #include <skalibs/selfpipe.h> +#include "selfpipe-internal.h" void selfpipe_finish (void) { - sig_restoreto(&selfpipe_caught, SKALIBS_NSIG-1) ; - sigemptyset(&selfpipe_caught) ; + int e = errno ; + sigprocmask(SIG_BLOCK, &selfpipe_caught, 0) ; + sig_restoreto(&selfpipe_caught, SKALIBS_NSIG) ; fd_close(selfpipe[1]) ; fd_close(selfpipe[0]) ; + sigprocmask(SIG_UNBLOCK, &selfpipe_caught, 0) ; + sigemptyset(&selfpipe_caught) ; selfpipe[0] = selfpipe[1] = -1 ; + errno = e ; } #endif diff --git a/src/libstddjb/selfpipe_init.c b/src/libstddjb/selfpipe_init.c index bd26d2f..8dcdcca 100644 --- a/src/libstddjb/selfpipe_init.c +++ b/src/libstddjb/selfpipe_init.c @@ -2,26 +2,35 @@ /* MT-unsafe */ -#include <errno.h> #include <signal.h> + #include <skalibs/sysdeps.h> -#include "selfpipe-internal.h" +#include <skalibs/sig.h> #include <skalibs/selfpipe.h> +#include "selfpipe-internal.h" #ifdef SKALIBS_HASSIGNALFD + #include <sys/signalfd.h> + +int selfpipe_init (void) +{ + sigemptyset(&selfpipe_caught) ; + selfpipe_fd = signalfd(selfpipe_fd, &selfpipe_caught, SFD_NONBLOCK | SFD_CLOEXEC) ; + sig_blocknone() ; + return selfpipe_fd ; +} + #else + #include <skalibs/djbunix.h> -#endif int selfpipe_init (void) { - if (selfpipe_fd >= 0) return (errno = EBUSY, -1) ; + if (selfpipe_fd >= 0) selfpipe_finish() ; sigemptyset(&selfpipe_caught) ; -#ifdef SKALIBS_HASSIGNALFD - selfpipe_fd = signalfd(-1, &selfpipe_caught, SFD_NONBLOCK | SFD_CLOEXEC) ; -#else - if (pipenbcoe(selfpipe) < 0) return -1 ; -#endif - return selfpipe_fd ; + sig_blocknone() ; + return pipenbcoe(selfpipe) < 0 ? -1 : selfpipe_fd ; } + +#endif diff --git a/src/libstddjb/selfpipe_internal.c b/src/libstddjb/selfpipe_internal.c index f65e07a..34bdd51 100644 --- a/src/libstddjb/selfpipe_internal.c +++ b/src/libstddjb/selfpipe_internal.c @@ -3,6 +3,7 @@ /* MT-unsafe */ #include <signal.h> + #include <skalibs/sysdeps.h> #include "selfpipe-internal.h" @@ -14,18 +15,16 @@ int selfpipe_fd = -1 ; #else -#include <errno.h> +#include <unistd.h> + #include <skalibs/allreadwrite.h> -#include <skalibs/djbunix.h> int selfpipe[2] = { -1, -1 } ; -static void selfpipe_trigger (int s) +void selfpipe_tophalf (int s) { unsigned char c = (unsigned char)s ; - fd_write(selfpipe[1], (char *)&c, 1) ; + write(selfpipe[1], (char *)&c, 1) ; } -struct skasigaction const selfpipe_ssa = { &selfpipe_trigger, SKASA_NOCLDSTOP | SKASA_MASKALL } ; - #endif diff --git a/src/libstddjb/selfpipe_read.c b/src/libstddjb/selfpipe_read.c index cd7098f..4bf1988 100644 --- a/src/libstddjb/selfpipe_read.c +++ b/src/libstddjb/selfpipe_read.c @@ -4,8 +4,8 @@ #include <skalibs/sysdeps.h> #include <skalibs/allreadwrite.h> -#include "selfpipe-internal.h" #include <skalibs/selfpipe.h> +#include "selfpipe-internal.h" #ifdef SKALIBS_HASSIGNALFD diff --git a/src/libstddjb/selfpipe_trap.c b/src/libstddjb/selfpipe_trap.c index 1dd4320..6ff8f09 100644 --- a/src/libstddjb/selfpipe_trap.c +++ b/src/libstddjb/selfpipe_trap.c @@ -4,9 +4,10 @@ #include <errno.h> #include <signal.h> + #include <skalibs/sysdeps.h> -#include "selfpipe-internal.h" #include <skalibs/selfpipe.h> +#include "selfpipe-internal.h" #ifdef SKALIBS_HASSIGNALFD @@ -16,18 +17,17 @@ int selfpipe_trap (int sig) { sigset_t ss = selfpipe_caught ; sigset_t old ; - if (selfpipe_fd < 0) return (errno = EBADF, -1) ; - if ((sigaddset(&ss, sig) < 0) || (sigprocmask(SIG_BLOCK, &ss, &old) < 0)) - return -1 ; + if (selfpipe_fd < 0) return (errno = EBADF, 0) ; + if ((sigaddset(&ss, sig) < 0) || (sigprocmask(SIG_BLOCK, &ss, &old) < 0)) return 0 ; if (signalfd(selfpipe_fd, &ss, SFD_NONBLOCK | SFD_CLOEXEC) < 0) { int e = errno ; sigprocmask(SIG_SETMASK, &old, 0) ; errno = e ; - return -1 ; + return 0 ; } selfpipe_caught = ss ; - return 0 ; + return 1 ; } #else @@ -36,16 +36,12 @@ int selfpipe_trap (int sig) int selfpipe_trap (int sig) { - if (selfpipe_fd < 0) return (errno = EBADF, -1) ; - if (sig_catcha(sig, &selfpipe_ssa) < 0) return -1 ; - if (sigaddset(&selfpipe_caught, sig) < 0 || sigprocmask(SIG_UNBLOCK, &selfpipe_caught, 0) < 0) - { - int e = errno ; - sig_restore(sig) ; - errno = e ; - return -1 ; - } - return 0 ; + sigset_t set ; + if (selfpipe_fd < 0) return (errno = EBADF, 0) ; + if (!sig_catch(sig, &selfpipe_tophalf)) return 0 ; + sigaddset(&selfpipe_caught, sig) ; + sig_unblock(sig) ; + return 1 ; } #endif diff --git a/src/libstddjb/selfpipe_trapset.c b/src/libstddjb/selfpipe_trapset.c index 542ad10..9559c07 100644 --- a/src/libstddjb/selfpipe_trapset.c +++ b/src/libstddjb/selfpipe_trapset.c @@ -7,60 +7,66 @@ #include <errno.h> #include <signal.h> #include <sys/signalfd.h> + #include <skalibs/selfpipe.h> #include "selfpipe-internal.h" int selfpipe_trapset (sigset_t const *set) { sigset_t old ; - if (selfpipe_fd < 0) return (errno = EBADF, -1) ; - if (sigprocmask(SIG_BLOCK, set, &old) < 0) return -1 ; + if (selfpipe_fd < 0) return (errno = EBADF, 0) ; + if (sigprocmask(SIG_SETMASK, set, &old) < 0) return 0 ; if (signalfd(selfpipe_fd, set, SFD_NONBLOCK | SFD_CLOEXEC) < 0) { int e = errno ; sigprocmask(SIG_SETMASK, &old, 0) ; errno = e ; - return -1 ; + return 0 ; } selfpipe_caught = *set ; - return 0 ; + return 1 ; } #else #include <skalibs/nonposix.h> +#include <skalibs/bsdsnowflake.h> + #include <errno.h> #include <signal.h> -#include <skalibs/sig.h> + #include <skalibs/nsig.h> +#include <skalibs/sig.h> #include <skalibs/selfpipe.h> #include "selfpipe-internal.h" int selfpipe_trapset (sigset_t const *set) { unsigned int i = 1 ; - if (selfpipe_fd < 0) return (errno = EBADF, -1) ; + if (selfpipe_fd < 0) return (errno = EBADF, 0) ; for (; i < SKALIBS_NSIG ; i++) { int h = sigismember(set, i) ; if (h < 0) continue ; if (h) { - if (sig_catcha(i, &selfpipe_ssa) < 0) break ; + if (!sig_catch(i, &selfpipe_tophalf)) goto err ; } else if (sigismember(&selfpipe_caught, i)) { - if (sig_restore(i) < 0) break ; + if (!sig_restore(i)) goto err ; } } - if (i < SKALIBS_NSIG || sigprocmask(SIG_UNBLOCK, set, 0) < 0) + sig_blocknone() ; + selfpipe_caught = *set ; + return 1 ; + + err: { int e = errno ; sig_restoreto(set, i) ; errno = e ; - return -1 ; } - selfpipe_caught = *set ; return 0 ; } diff --git a/src/libstddjb/selfpipe_untrap.c b/src/libstddjb/selfpipe_untrap.c deleted file mode 100644 index 7d82cf4..0000000 --- a/src/libstddjb/selfpipe_untrap.c +++ /dev/null @@ -1,54 +0,0 @@ -/* ISC license. */ - -/* MT-unsafe */ - -#include <errno.h> -#include <signal.h> -#include <skalibs/sysdeps.h> -#include "selfpipe-internal.h" -#include <skalibs/selfpipe.h> - -#ifdef SKALIBS_HASSIGNALFD - -#include <sys/signalfd.h> - -int selfpipe_untrap (int sig) -{ - sigset_t ss = selfpipe_caught ; - sigset_t blah ; - int r = sigismember(&selfpipe_caught, sig) ; - if (selfpipe_fd < 0) return (errno = EBADF, -1) ; - if (r < 0) return -1 ; - if (!r) return (errno = EINVAL, -1) ; - if ((sigdelset(&ss, sig) < 0) - || (signalfd(selfpipe_fd, &ss, SFD_NONBLOCK | SFD_CLOEXEC) < 0)) - return -1 ; - sigemptyset(&blah) ; - sigaddset(&blah, sig) ; - if (sigprocmask(SIG_UNBLOCK, &blah, 0) < 0) - { - int e = errno ; - signalfd(selfpipe_fd, &selfpipe_caught, SFD_NONBLOCK | SFD_CLOEXEC) ; - errno = e ; - return -1 ; - } - selfpipe_caught = ss ; - return 0 ; -} - -#else - -#include <skalibs/sig.h> - -int selfpipe_untrap (int sig) -{ - int r = sigismember(&selfpipe_caught, sig) ; - if (selfpipe_fd < 0) return (errno = EBADF, -1) ; - if (r < 0) return -1 ; - if (!r) return (errno = EINVAL, -1) ; - if (sig_restore(sig) < 0) return -1 ; - sigdelset(&selfpipe_caught, sig) ; - return 0 ; -} - -#endif diff --git a/src/libstddjb/sgetopt.c b/src/libstddjb/sgetopt.c index f576689..31ea28f 100644 --- a/src/libstddjb/sgetopt.c +++ b/src/libstddjb/sgetopt.c @@ -7,7 +7,7 @@ #include <skalibs/buffer.h> #include <skalibs/sgetopt.h> -int sgetopt_r (int argc, char const *const *argv, char const *opts, subgetopt_t *o) +int sgetopt_r (int argc, char const *const *argv, char const *opts, subgetopt *o) { int c = subgetopt_r(argc, argv, opts, o) ; if (o->err && ((c == '?') || (c == ':'))) diff --git a/src/libstddjb/sig-internal.h b/src/libstddjb/sig-internal.h index 9b540fa..573fbfa 100644 --- a/src/libstddjb/sig-internal.h +++ b/src/libstddjb/sig-internal.h @@ -1,15 +1,15 @@ /* ISC license. */ -#ifndef SIG_INTERNAL -#define SIG_INTERNAL +#ifndef SKALIBS_SIG_INTERNAL_H +#define SKALIBS_SIG_INTERNAL_H -typedef struct sigtable_s sigtable_t, *sigtable_t_ref ; +typedef struct sigtable_s sigtable, *sigtable_ref ; struct sigtable_s { int number ; char const *name ; } ; -extern sigtable_t const skalibs_sigtable[] ; +extern sigtable const skalibs_sigtable[] ; #endif diff --git a/src/libstddjb/sig0_scan.c b/src/libstddjb/sig0_scan.c index d6b2b90..453c527 100644 --- a/src/libstddjb/sig0_scan.c +++ b/src/libstddjb/sig0_scan.c @@ -2,6 +2,7 @@ #include <string.h> #include <strings.h> + #include <skalibs/types.h> #include <skalibs/sig.h> diff --git a/src/libstddjb/sig_block.c b/src/libstddjb/sig_block.c index 89ae51f..fc67390 100644 --- a/src/libstddjb/sig_block.c +++ b/src/libstddjb/sig_block.c @@ -1,6 +1,7 @@ /* ISC license. */ #include <signal.h> + #include <skalibs/sig.h> void sig_block (int sig) diff --git a/src/libstddjb/sig_blocknone.c b/src/libstddjb/sig_blocknone.c index 8498f0f..a8d1fbc 100644 --- a/src/libstddjb/sig_blocknone.c +++ b/src/libstddjb/sig_blocknone.c @@ -1,11 +1,15 @@ /* ISC license. */ +#include <errno.h> #include <signal.h> + #include <skalibs/sig.h> void sig_blocknone (void) { + int e = errno ; sigset_t ss ; sigemptyset(&ss) ; sigprocmask(SIG_SETMASK, &ss, 0) ; + errno = e ; } diff --git a/src/libstddjb/sig_blockset.c b/src/libstddjb/sig_blockset.c deleted file mode 100644 index 206c157..0000000 --- a/src/libstddjb/sig_blockset.c +++ /dev/null @@ -1,9 +0,0 @@ -/* ISC license. */ - -#include <signal.h> -#include <skalibs/sig.h> - -void sig_blockset (sigset_t const *set) -{ - sigprocmask(SIG_SETMASK, set, 0) ; -} diff --git a/src/libstddjb/sig_catch.c b/src/libstddjb/sig_catch.c index d0a72df..5195d4b 100644 --- a/src/libstddjb/sig_catch.c +++ b/src/libstddjb/sig_catch.c @@ -2,10 +2,14 @@ /* MT-unsafe */ +#include <signal.h> + +#include <skalibs/functypes.h> #include <skalibs/sig.h> -int sig_catch (int sig, skasighandler_t_ref f) +int sig_catch (int sig, sig_func_ref f) { - struct skasigaction ssa = { f, SKASA_MASKALL | SKASA_NOCLDSTOP } ; - return sig_catcha(sig, &ssa) ; + struct sigaction action = { .sa_handler = f, .sa_flags = SA_RESTART | SA_NOCLDSTOP } ; + sigfillset(&action.sa_mask) ; + return sigaction(sig, &action, 0) >= 0 ; } diff --git a/src/libstddjb/sig_name.c b/src/libstddjb/sig_name.c index 0679055..c8d7b6f 100644 --- a/src/libstddjb/sig_name.c +++ b/src/libstddjb/sig_name.c @@ -5,7 +5,7 @@ char const *sig_name (int sig) { - sigtable_t const *p = skalibs_sigtable ; + sigtable const *p = skalibs_sigtable ; for (; p->number ; p++) if (sig == p->number) break ; return p->number ? p->name : "???" ; } diff --git a/src/libstddjb/sig_number.c b/src/libstddjb/sig_number.c index a588abd..d234185 100644 --- a/src/libstddjb/sig_number.c +++ b/src/libstddjb/sig_number.c @@ -1,12 +1,13 @@ /* ISC license. */ #include <strings.h> + #include <skalibs/sig.h> #include "sig-internal.h" int sig_number (char const *name) { - sigtable_t const *p = skalibs_sigtable ; + sigtable const *p = skalibs_sigtable ; for (; p->name ; p++) if (!strcasecmp(name, p->name)) break ; return p->number ; } diff --git a/src/libstddjb/sig_pause.c b/src/libstddjb/sig_pause.c deleted file mode 100644 index 7de8ff5..0000000 --- a/src/libstddjb/sig_pause.c +++ /dev/null @@ -1,11 +0,0 @@ -/* ISC license. */ - -#include <signal.h> -#include <skalibs/sig.h> - -void sig_pause (void) -{ - sigset_t ss ; - sigemptyset(&ss) ; - sigsuspend(&ss) ; -} diff --git a/src/libstddjb/sig_push.c b/src/libstddjb/sig_push.c deleted file mode 100644 index 96e5fb2..0000000 --- a/src/libstddjb/sig_push.c +++ /dev/null @@ -1,11 +0,0 @@ -/* ISC license. */ - -/* MT-unsafe */ - -#include <skalibs/sig.h> - -int sig_push (int sig, skasighandler_t_ref f) -{ - struct skasigaction ssa = { f, SKASA_MASKALL | SKASA_NOCLDSTOP } ; - return sig_pusha(sig, &ssa) ; -} diff --git a/src/libstddjb/sig_restoreto.c b/src/libstddjb/sig_restoreto.c index 580ba32..1a9250e 100644 --- a/src/libstddjb/sig_restoreto.c +++ b/src/libstddjb/sig_restoreto.c @@ -3,12 +3,13 @@ /* MT-unsafe */ #include <signal.h> + #include <skalibs/sig.h> void sig_restoreto (sigset_t const *set, unsigned int n) { unsigned int i = 1 ; - for (; i <= n ; i++) + for (; i < n ; i++) { int h = sigismember(set, i) ; if (h < 0) continue ; diff --git a/src/libstddjb/sig_shield.c b/src/libstddjb/sig_shield.c deleted file mode 100644 index ee5d9a9..0000000 --- a/src/libstddjb/sig_shield.c +++ /dev/null @@ -1,17 +0,0 @@ -/* ISC license. */ - -#include <signal.h> -#include <skalibs/sig.h> - -void sig_shield (void) -{ - sigset_t ss ; - sigemptyset(&ss) ; - sigaddset(&ss, SIGTERM) ; - sigaddset(&ss, SIGQUIT) ; - sigaddset(&ss, SIGABRT) ; - sigaddset(&ss, SIGINT) ; - sigaddset(&ss, SIGPIPE) ; - sigaddset(&ss, SIGHUP) ; - sigprocmask(SIG_BLOCK, &ss, 0) ; -} diff --git a/src/libstddjb/sig_stack.c b/src/libstddjb/sig_stack.c deleted file mode 100644 index 88c78ec..0000000 --- a/src/libstddjb/sig_stack.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ISC license. */ - -#include <skalibs/nonposix.h> -#include <errno.h> -#include <signal.h> -#include <skalibs/sig.h> -#include <skalibs/nsig.h> - -static struct skasigaction skasigstack[SKALIBS_NSIG-1][SIGSTACKSIZE] ; -static unsigned int sigsp[SKALIBS_NSIG-1] ; - -int sig_pusha (int sig, struct skasigaction const *ssa) -{ - if ((sig <= 0) || (sig >= SKALIBS_NSIG)) return (errno = EINVAL, -1) ; - if (sigsp[sig-1] >= SIGSTACKSIZE) return (errno = ENOBUFS, -1) ; - if (skasigaction(sig, ssa, &skasigstack[sig-1][sigsp[sig-1]]) == -1) - return -1 ; - return ++sigsp[sig-1] ; -} - -int sig_pop (int sig) -{ - if ((sig <= 0) || (sig >= SKALIBS_NSIG)) return (errno = EINVAL, -1) ; - if (!sigsp[sig-1]) return (errno = EFAULT, -1); - if (skasigaction(sig, &skasigstack[sig-1][sigsp[sig-1]-1], 0) == -1) - return -1 ; - return --sigsp[sig-1] ; -} diff --git a/src/libstddjb/sig_table.c b/src/libstddjb/sig_table.c index d097cb5..9858695 100644 --- a/src/libstddjb/sig_table.c +++ b/src/libstddjb/sig_table.c @@ -1,9 +1,10 @@ /* ISC license. */ #include <signal.h> + #include "sig-internal.h" -sigtable_t const skalibs_sigtable[] = +sigtable const skalibs_sigtable[] = { { SIGABRT, "ABRT" }, { SIGALRM, "ALRM" }, diff --git a/src/libstddjb/sig_unblock.c b/src/libstddjb/sig_unblock.c index 26d5c1b..9a15175 100644 --- a/src/libstddjb/sig_unblock.c +++ b/src/libstddjb/sig_unblock.c @@ -1,6 +1,7 @@ /* ISC license. */ #include <signal.h> + #include <skalibs/sig.h> void sig_unblock (int sig) diff --git a/src/libstddjb/sig_unshield.c b/src/libstddjb/sig_unshield.c deleted file mode 100644 index 24918b4..0000000 --- a/src/libstddjb/sig_unshield.c +++ /dev/null @@ -1,17 +0,0 @@ -/* ISC license. */ - -#include <signal.h> -#include <skalibs/sig.h> - -void sig_unshield (void) -{ - sigset_t ss ; - sigemptyset(&ss) ; - sigaddset(&ss, SIGTERM) ; - sigaddset(&ss, SIGQUIT) ; - sigaddset(&ss, SIGABRT) ; - sigaddset(&ss, SIGINT) ; - sigaddset(&ss, SIGPIPE) ; - sigaddset(&ss, SIGHUP) ; - sigprocmask(SIG_UNBLOCK, &ss, 0) ; -} diff --git a/src/libstddjb/skasig_dfl.c b/src/libstddjb/skasig_dfl.c deleted file mode 100644 index ca97b4f..0000000 --- a/src/libstddjb/skasig_dfl.c +++ /dev/null @@ -1,7 +0,0 @@ -/* ISC license. */ - -#include <signal.h> -#include <skalibs/sig.h> - -struct skasigaction const SKASIG_DFL = { SIG_DFL, 0 } ; -struct skasigaction const SKASIG_IGN = { SIG_IGN, 0 } ; diff --git a/src/libstddjb/skasigaction.c b/src/libstddjb/skasigaction.c deleted file mode 100644 index e86cc0c..0000000 --- a/src/libstddjb/skasigaction.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ISC license. */ - -#include <skalibs/config.h> -#include <signal.h> -#include <skalibs/sig.h> - -int skasigaction (int sig, struct skasigaction const *new, struct skasigaction *old) -{ - struct sigaction sanew, saold ; - if (((new->flags & SKASA_MASKALL) ? sigfillset(&sanew.sa_mask) : sigemptyset(&sanew.sa_mask)) == -1) return -1 ; - sanew.sa_handler = new->handler ; - sanew.sa_flags = (new->flags & SKASA_NOCLDSTOP) ? SA_NOCLDSTOP : 0 ; -#ifndef SKALIBS_FLAG_PREFERSELECT - sanew.sa_flags |= SA_RESTART ; -#endif - if (sigaction(sig, &sanew, &saold) < 0) return -1 ; - if (old) - { - int r = sigismember(&saold.sa_mask, (sig == SIGTERM) ? SIGPIPE : SIGTERM) ; - if (r < 0) return -1 ; - old->flags = 0 ; - if (r) old->flags |= SKASA_MASKALL ; - if (saold.sa_flags & SA_NOCLDSTOP) old->flags |= SKASA_NOCLDSTOP ; - old->handler = saold.sa_handler ; - } - return 0 ; -} diff --git a/src/libstddjb/socket_deadlineconnstamp4.c b/src/libstddjb/socket_deadlineconnstamp4.c index 5691932..da6aa22 100644 --- a/src/libstddjb/socket_deadlineconnstamp4.c +++ b/src/libstddjb/socket_deadlineconnstamp4.c @@ -4,7 +4,7 @@ #include <skalibs/error.h> #include <skalibs/socket.h> -int socket_deadlineconnstamp (int s, char const *ip, uint16_t port, tain_t const *deadline, tain_t *stamp) +int socket_deadlineconnstamp (int s, char const *ip, uint16_t port, tain const *deadline, tain *stamp) { int e = errno ; if (socket_connect4(s, ip, port) >= 0) return 1 ; diff --git a/src/libstddjb/socket_deadlineconnstamp46.c b/src/libstddjb/socket_deadlineconnstamp46.c index ac1160c..04d1a51 100644 --- a/src/libstddjb/socket_deadlineconnstamp46.c +++ b/src/libstddjb/socket_deadlineconnstamp46.c @@ -1,11 +1,12 @@ /* ISC license. */ #include <errno.h> + #include <skalibs/error.h> #include <skalibs/socket.h> #include <skalibs/ip46.h> -int socket_deadlineconnstamp46 (int s, ip46_t const *i, uint16_t port, tain_t const *deadline, tain_t *stamp) +int socket_deadlineconnstamp46 (int s, ip46 const *i, uint16_t port, tain const *deadline, tain *stamp) { int e = errno ; if (socket_connect46(s, i, port) >= 0) return 1 ; diff --git a/src/libstddjb/socket_deadlineconnstamp4_u32.c b/src/libstddjb/socket_deadlineconnstamp4_u32.c index 655c379..5287100 100644 --- a/src/libstddjb/socket_deadlineconnstamp4_u32.c +++ b/src/libstddjb/socket_deadlineconnstamp4_u32.c @@ -3,7 +3,7 @@ #include <skalibs/uint32.h> #include <skalibs/socket.h> -int socket_deadlineconnstamp4_u32 (int s, uint32_t ip, uint16_t port, tain_t const *deadline, tain_t *stamp) +int socket_deadlineconnstamp4_u32 (int s, uint32_t ip, uint16_t port, tain const *deadline, tain *stamp) { char pack[4] ; uint32_pack_big(pack, ip) ; diff --git a/src/libstddjb/socket_deadlineconnstamp6.c b/src/libstddjb/socket_deadlineconnstamp6.c index d03fabe..7e63b52 100644 --- a/src/libstddjb/socket_deadlineconnstamp6.c +++ b/src/libstddjb/socket_deadlineconnstamp6.c @@ -4,7 +4,7 @@ #include <skalibs/error.h> #include <skalibs/socket.h> -int socket_deadlineconnstamp6 (int s, char const *ip, uint16_t port, tain_t const *deadline, tain_t *stamp) +int socket_deadlineconnstamp6 (int s, char const *ip, uint16_t port, tain const *deadline, tain *stamp) { int e = errno ; if (socket_connect6(s, ip, port) >= 0) return 1 ; diff --git a/src/libstddjb/socket_ioloop.c b/src/libstddjb/socket_ioloop.c index 0a61a8c..aa674b0 100644 --- a/src/libstddjb/socket_ioloop.c +++ b/src/libstddjb/socket_ioloop.c @@ -5,7 +5,7 @@ #include <skalibs/iopause.h> #include <skalibs/socket.h> -ssize_t socket_ioloop (int s, char *buf, size_t len, char *ip, uint16_t *port, socket_io_func_t_ref f, int w, tain_t const *deadline, tain_t *stamp) +ssize_t socket_ioloop (int s, char *buf, size_t len, char *ip, uint16_t *port, socket_io_func_ref f, int w, tain const *deadline, tain *stamp) { iopause_fd x = { .fd = s, .events = w ? IOPAUSE_WRITE : IOPAUSE_READ, .revents = 0 } ; for (;;) diff --git a/src/libstddjb/socket_local46.c b/src/libstddjb/socket_local46.c index e913634..aaf1da0 100644 --- a/src/libstddjb/socket_local46.c +++ b/src/libstddjb/socket_local46.c @@ -1,16 +1,18 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <errno.h> #include <sys/socket.h> #include <netinet/in.h> #include <string.h> + #include <skalibs/uint16.h> #include <skalibs/ip46.h> #ifdef SKALIBS_IPV6_ENABLED -int socket_local46 (int s, ip46_t *ip, uint16_t *port) +int socket_local46 (int s, ip46 *ip, uint16_t *port) { struct sockaddr_storage sa ; socklen_t dummy = sizeof sa ; diff --git a/src/libstddjb/socket_remote46.c b/src/libstddjb/socket_remote46.c index 5681ce3..d0f1548 100644 --- a/src/libstddjb/socket_remote46.c +++ b/src/libstddjb/socket_remote46.c @@ -1,16 +1,18 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <errno.h> #include <sys/socket.h> #include <netinet/in.h> #include <string.h> + #include <skalibs/uint16.h> #include <skalibs/ip46.h> #ifdef SKALIBS_IPV6_ENABLED -int socket_remote46 (int s, ip46_t *ip, uint16_t *port) +int socket_remote46 (int s, ip46 *ip, uint16_t *port) { struct sockaddr_storage sa ; socklen_t dummy = sizeof sa ; diff --git a/src/libstddjb/socket_timeoutconn.c b/src/libstddjb/socket_timeoutconn.c index 5f9f0cd..854a635 100644 --- a/src/libstddjb/socket_timeoutconn.c +++ b/src/libstddjb/socket_timeoutconn.c @@ -5,7 +5,7 @@ int socket_timeoutconn (int s, char const *ip, uint16_t port, unsigned int timeout) { - tain_t stamp, deadline ; + tain stamp, deadline ; tain_now(&stamp) ; tain_addsec(&deadline, &stamp, timeout) ; return socket_deadlineconnstamp4(s, ip, port, &deadline, &stamp) ; diff --git a/src/libstddjb/socket_waitconn.c b/src/libstddjb/socket_waitconn.c index 35eb526..a69fed8 100644 --- a/src/libstddjb/socket_waitconn.c +++ b/src/libstddjb/socket_waitconn.c @@ -5,7 +5,7 @@ #include <skalibs/iopause.h> #include <skalibs/socket.h> -int socket_waitconn (int s, tain_t const *deadline, tain_t *stamp) +int socket_waitconn (int s, tain const *deadline, tain *stamp) { iopause_fd x = { s, IOPAUSE_WRITE, 0 } ; for (;;) diff --git a/src/libstddjb/stamp.c b/src/libstddjb/stamp.c index 65becc6..7504bfe 100644 --- a/src/libstddjb/stamp.c +++ b/src/libstddjb/stamp.c @@ -4,4 +4,4 @@ #include <skalibs/tai.h> -tain_t STAMP = TAIN_EPOCH ; +tain STAMP = TAIN_EPOCH ; diff --git a/src/libstddjb/subgetopt.c b/src/libstddjb/subgetopt.c index 67cdfa1..940eb6a 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 *o) +int subgetopt_r (int argc, char const *const *argv, char const *opts, subgetopt *o) { o->arg = 0 ; if ((o->ind >= argc) || !argv[o->ind]) return -1 ; diff --git a/src/libstddjb/subgetopt_here.c b/src/libstddjb/subgetopt_here.c index e0be29a..7d69248 100644 --- a/src/libstddjb/subgetopt_here.c +++ b/src/libstddjb/subgetopt_here.c @@ -4,4 +4,4 @@ #include <skalibs/sgetopt.h> -subgetopt_t subgetopt_here = SUBGETOPT_ZERO ; +subgetopt subgetopt_here = SUBGETOPT_ZERO ; diff --git a/src/libstddjb/sysclock_from_localtmn.c b/src/libstddjb/sysclock_from_localtmn.c index 2b9dbb9..5dcbc5a 100644 --- a/src/libstddjb/sysclock_from_localtmn.c +++ b/src/libstddjb/sysclock_from_localtmn.c @@ -2,7 +2,7 @@ #include <skalibs/djbtime.h> -int sysclock_from_localtmn (tain_t *a, localtmn_t const *l) +int sysclock_from_localtmn (tain *a, localtmn const *l) { if (!sysclock_from_localtm(&a->sec.x, &l->tm)) return 0 ; a->nano = l->nano ; diff --git a/src/libstddjb/sysclock_from_ltm64.c b/src/libstddjb/sysclock_from_ltm64.c index 8e951d5..a1f5444 100644 --- a/src/libstddjb/sysclock_from_ltm64.c +++ b/src/libstddjb/sysclock_from_ltm64.c @@ -8,7 +8,7 @@ int sysclock_from_ltm64 (uint64_t *u) { - tai_t t ; + tai t ; if (!tai_from_ltm64(&t, *u)) return 0 ; *u = t.x - 10U ; return 1 ; diff --git a/src/libstddjb/sysclock_from_tai.c b/src/libstddjb/sysclock_from_tai.c index 003e962..f08ad71 100644 --- a/src/libstddjb/sysclock_from_tai.c +++ b/src/libstddjb/sysclock_from_tai.c @@ -6,7 +6,7 @@ #ifdef SKALIBS_FLAG_CLOCKISTAI -int sysclock_from_tai (uint64_t *u, tai_t const *t) +int sysclock_from_tai (uint64_t *u, tai const *t) { if (t->x < 10U) return (errno = EINVAL, 0) ; *u = t->x - 10U ; @@ -17,7 +17,7 @@ int sysclock_from_tai (uint64_t *u, tai_t const *t) #include <skalibs/djbtime.h> -int sysclock_from_tai (uint64_t *u, tai_t const *t) +int sysclock_from_tai (uint64_t *u, tai const *t) { return utc_from_tai(u, t) ; } diff --git a/src/libstddjb/sysclock_from_tain.c b/src/libstddjb/sysclock_from_tain.c index 8a2bd12..c53eaee 100644 --- a/src/libstddjb/sysclock_from_tain.c +++ b/src/libstddjb/sysclock_from_tain.c @@ -2,7 +2,7 @@ #include <skalibs/tai.h> -int sysclock_from_tain (tain_t *u, tain_t const *t) +int sysclock_from_tain (tain *u, tain const *t) { if (!sysclock_from_tai(&u->sec.x, &t->sec)) return 0 ; u->nano = t->nano ; diff --git a/src/libstddjb/sysclock_from_utc.c b/src/libstddjb/sysclock_from_utc.c index 49fe558..c3f8df1 100644 --- a/src/libstddjb/sysclock_from_utc.c +++ b/src/libstddjb/sysclock_from_utc.c @@ -9,7 +9,7 @@ int sysclock_from_utc (uint64_t *u) { - tai_t t ; + tai t ; if (!tai_from_utc(&t, *u)) return 0 ; if (t.x < 10) return (errno = EINVAL, 0) ; *u = t.x - 10 ; diff --git a/src/libstddjb/sysclock_get.c b/src/libstddjb/sysclock_get.c index 6c5041d..1325903 100644 --- a/src/libstddjb/sysclock_get.c +++ b/src/libstddjb/sysclock_get.c @@ -7,9 +7,9 @@ #include <time.h> -int sysclock_get (tain_t *a) +int sysclock_get (tain *a) { - tain_t aa ; + tain aa ; struct timespec now ; if (clock_gettime(CLOCK_REALTIME, &now) < 0) return 0 ; if (!tain_from_timespec(&aa, &now)) return 0 ; @@ -21,9 +21,9 @@ int sysclock_get (tain_t *a) #include <sys/time.h> -int sysclock_get (tain_t *a) +int sysclock_get (tain *a) { - tain_t aa ; + tain aa ; struct timeval now ; if (gettimeofday(&now, 0) < 0) return 0 ; if (!tain_from_timeval(&aa, &now)) return 0 ; diff --git a/src/libstddjb/sysclock_set.c b/src/libstddjb/sysclock_set.c index 76917af..de638db 100644 --- a/src/libstddjb/sysclock_set.c +++ b/src/libstddjb/sysclock_set.c @@ -9,10 +9,10 @@ #include <time.h> #include <skalibs/tai.h> -int sysclock_set (tain_t const *a) +int sysclock_set (tain const *a) { struct timespec now ; - tain_t aa ; + tain aa ; tain_add(&aa, a, &tain_nano500) ; if (!timespec_from_tain(&now, &aa)) return 0 ; if (clock_settime(CLOCK_REALTIME, &now) < 0) return 0 ; @@ -26,10 +26,10 @@ int sysclock_set (tain_t const *a) #include <sys/time.h> #include <skalibs/tai.h> -int sysclock_set (tain_t const *a) +int sysclock_set (tain const *a) { struct timeval now ; - tain_t aa ; + tain aa ; tain_add(&aa, a, &tain_nano500) ; if (!timeval_from_tain(&now, &aa)) return 0 ; if (settimeofday(&now, 0) < 0) return 0 ; diff --git a/src/libstddjb/tai_add.c b/src/libstddjb/tai_add.c index 5a3d47a..8f13c26 100644 --- a/src/libstddjb/tai_add.c +++ b/src/libstddjb/tai_add.c @@ -2,7 +2,7 @@ #include <skalibs/tai.h> -int tai_add (tai_t *t, tai_t const *u, tai_t const *v) +int tai_add (tai *t, tai const *u, tai const *v) { t->x = u->x + v->x ; return 1 ; diff --git a/src/libstddjb/tai_from_localtm.c b/src/libstddjb/tai_from_localtm.c index b2dfbc6..d2dc276 100644 --- a/src/libstddjb/tai_from_localtm.c +++ b/src/libstddjb/tai_from_localtm.c @@ -4,7 +4,7 @@ #include <skalibs/uint64.h> #include <skalibs/djbtime.h> -int tai_from_localtm (tai_t *t, struct tm const *l) +int tai_from_localtm (tai *t, struct tm const *l) { uint64_t u ; if (!ltm64_from_localtm(&u, l)) return 0 ; diff --git a/src/libstddjb/tai_from_ltm64.c b/src/libstddjb/tai_from_ltm64.c index be3a11b..c59a9e3 100644 --- a/src/libstddjb/tai_from_ltm64.c +++ b/src/libstddjb/tai_from_ltm64.c @@ -3,7 +3,7 @@ #include <skalibs/djbtime.h> #include "djbtime-internal.h" -int tai_from_ltm64 (tai_t *t, uint64_t u) +int tai_from_ltm64 (tai *t, uint64_t u) { switch (skalibs_tzisright()) { diff --git a/src/libstddjb/tai_from_sysclock.c b/src/libstddjb/tai_from_sysclock.c index b813108..006c859 100644 --- a/src/libstddjb/tai_from_sysclock.c +++ b/src/libstddjb/tai_from_sysclock.c @@ -6,7 +6,7 @@ #ifdef SKALIBS_FLAG_CLOCKISTAI -int tai_from_sysclock (tai_t *t, uint64_t u) +int tai_from_sysclock (tai *t, uint64_t u) { return tai_u64(t, u + 10U) ; } @@ -15,7 +15,7 @@ int tai_from_sysclock (tai_t *t, uint64_t u) #include <skalibs/djbtime.h> -int tai_from_sysclock (tai_t *t, uint64_t u) +int tai_from_sysclock (tai *t, uint64_t u) { return tai_from_utc(t, u) ; } diff --git a/src/libstddjb/tai_from_utc.c b/src/libstddjb/tai_from_utc.c index f1cea31..5eb6308 100644 --- a/src/libstddjb/tai_from_utc.c +++ b/src/libstddjb/tai_from_utc.c @@ -4,7 +4,7 @@ #include <skalibs/djbtime.h> #include "djbtime-internal.h" -int tai_from_utc (tai_t *t, uint64_t u) +int tai_from_utc (tai *t, uint64_t u) { leapsecs_add(&u, 0) ; return tai_u64(t, u + 10) ; diff --git a/src/libstddjb/tai_now.c b/src/libstddjb/tai_now.c index a9710d4..ca67bb7 100644 --- a/src/libstddjb/tai_now.c +++ b/src/libstddjb/tai_now.c @@ -5,7 +5,7 @@ #include <time.h> #include <skalibs/tai.h> -int tai_now (tai_t *t) +int tai_now (tai *t) { time_t u = time(0) ; if (u == (time_t)-1) return 0 ; diff --git a/src/libstddjb/tai_pack.c b/src/libstddjb/tai_pack.c index f81afe2..94ee363 100644 --- a/src/libstddjb/tai_pack.c +++ b/src/libstddjb/tai_pack.c @@ -3,7 +3,7 @@ #include <skalibs/uint64.h> #include <skalibs/tai.h> -void tai_pack (char *s, tai_t const *t) +void tai_pack (char *s, tai const *t) { uint64_pack_big(s, tai_sec(t)) ; } diff --git a/src/libstddjb/tai_pack_little.c b/src/libstddjb/tai_pack_little.c index 41e552a..e47286e 100644 --- a/src/libstddjb/tai_pack_little.c +++ b/src/libstddjb/tai_pack_little.c @@ -3,7 +3,7 @@ #include <skalibs/uint64.h> #include <skalibs/tai.h> -void tai_pack_little (char *s, tai_t const *t) +void tai_pack_little (char *s, tai const *t) { uint64_pack(s, tai_sec(t)) ; } diff --git a/src/libstddjb/tai_sub.c b/src/libstddjb/tai_sub.c index b85f1f2..c61c736 100644 --- a/src/libstddjb/tai_sub.c +++ b/src/libstddjb/tai_sub.c @@ -2,7 +2,7 @@ #include <skalibs/tai.h> -int tai_sub (tai_t *t, tai_t const *u, tai_t const *v) +int tai_sub (tai *t, tai const *u, tai const *v) { t->x = u->x - v->x ; return 1 ; diff --git a/src/libstddjb/tai_u64.c b/src/libstddjb/tai_u64.c index 1d7eabe..55d5b40 100644 --- a/src/libstddjb/tai_u64.c +++ b/src/libstddjb/tai_u64.c @@ -5,7 +5,7 @@ #include <skalibs/uint64.h> #include <skalibs/tai.h> -int tai_u64 (tai_t *t, uint64_t u) +int tai_u64 (tai *t, uint64_t u) { if (u & ((uint64_t)1 << 63)) return (errno = EOVERFLOW, 0) ; t->x = u ; diff --git a/src/libstddjb/tai_unpack.c b/src/libstddjb/tai_unpack.c index a733c4a..36c2e35 100644 --- a/src/libstddjb/tai_unpack.c +++ b/src/libstddjb/tai_unpack.c @@ -3,7 +3,7 @@ #include <skalibs/uint64.h> #include <skalibs/tai.h> -void tai_unpack (char const *s, tai_t *t) +void tai_unpack (char const *s, tai *t) { uint64_unpack_big(s, &t->x) ; } diff --git a/src/libstddjb/tai_unpack_little.c b/src/libstddjb/tai_unpack_little.c index 71804a5..b2bafbf 100644 --- a/src/libstddjb/tai_unpack_little.c +++ b/src/libstddjb/tai_unpack_little.c @@ -3,7 +3,7 @@ #include <skalibs/uint64.h> #include <skalibs/tai.h> -void tai_unpack_little (char const *s, tai_t *t) +void tai_unpack_little (char const *s, tai *t) { uint64_unpack(s, &t->x) ; } diff --git a/src/libstddjb/tain_add.c b/src/libstddjb/tain_add.c index b119270..2c0f98d 100644 --- a/src/libstddjb/tain_add.c +++ b/src/libstddjb/tain_add.c @@ -2,7 +2,7 @@ #include <skalibs/tai.h> -int tain_add (tain_t *t, tain_t const *u, tain_t const *v) +int tain_add (tain *t, tain const *u, tain const *v) { t->sec.x = u->sec.x + v->sec.x ; t->nano = u->nano + v->nano ; diff --git a/src/libstddjb/tain_addsec.c b/src/libstddjb/tain_addsec.c index cd22b18..c580444 100644 --- a/src/libstddjb/tain_addsec.c +++ b/src/libstddjb/tain_addsec.c @@ -3,16 +3,16 @@ #include <skalibs/uint64.h> #include <skalibs/tai.h> -int tain_addsec (tain_t *b, tain_t const *a, int c) +int tain_addsec (tain *b, tain const *a, int c) { if (c >= 0) { - tai_t t = { .x = (uint64_t)c } ; + tai t = { .x = (uint64_t)c } ; tai_add(&b->sec, &a->sec, &t) ; } else { - tai_t t = { .x = (uint64_t)-c } ; + tai t = { .x = (uint64_t)-c } ; tai_sub(&b->sec, &a->sec, &t) ; } b->nano = a->nano ; diff --git a/src/libstddjb/tain_approx.c b/src/libstddjb/tain_approx.c index d749cdf..c1f6023 100644 --- a/src/libstddjb/tain_approx.c +++ b/src/libstddjb/tain_approx.c @@ -2,7 +2,7 @@ #include <skalibs/tai.h> -double tain_approx (tain_t const *t) +double tain_approx (tain const *t) { return tai_approx(&t->sec) + tain_frac(t) ; } diff --git a/src/libstddjb/tain_fmt.c b/src/libstddjb/tain_fmt.c index 54f0e6a..9b98b59 100644 --- a/src/libstddjb/tain_fmt.c +++ b/src/libstddjb/tain_fmt.c @@ -3,7 +3,7 @@ #include <skalibs/fmtscan.h> #include <skalibs/tai.h> -size_t tain_fmt (char *s, tain_t const *a) +size_t tain_fmt (char *s, tain const *a) { char pack[TAIN_PACK] ; tain_pack(pack, a) ; diff --git a/src/libstddjb/tain_frac.c b/src/libstddjb/tain_frac.c index 45ee3b4..ff6bbd3 100644 --- a/src/libstddjb/tain_frac.c +++ b/src/libstddjb/tain_frac.c @@ -2,7 +2,7 @@ #include <skalibs/tai.h> -double tain_frac (tain_t const *t) +double tain_frac (tain const *t) { return t->nano * 0.000000001 ; } diff --git a/src/libstddjb/tain_from_localtmn.c b/src/libstddjb/tain_from_localtmn.c index 3a71889..a9a669f 100644 --- a/src/libstddjb/tain_from_localtmn.c +++ b/src/libstddjb/tain_from_localtmn.c @@ -2,9 +2,9 @@ #include <skalibs/djbtime.h> -int tain_from_localtmn (tain_t *a, localtmn_t const *l) +int tain_from_localtmn (tain *a, localtmn const *l) { - tai_t t ; + tai t ; if (!tai_from_localtm(&t, &l->tm)) return 0 ; a->sec = t ; a->nano = l->nano ; diff --git a/src/libstddjb/tain_from_millisecs.c b/src/libstddjb/tain_from_millisecs.c index e6bfca4..8978aa3 100644 --- a/src/libstddjb/tain_from_millisecs.c +++ b/src/libstddjb/tain_from_millisecs.c @@ -3,7 +3,7 @@ #include <errno.h> #include <skalibs/tai.h> -int tain_from_millisecs (tain_t *a, int millisecs) +int tain_from_millisecs (tain *a, int millisecs) { if (millisecs < 0) return (errno = EINVAL, 0) ; a->sec.x = millisecs / 1000 ; diff --git a/src/libstddjb/tain_from_ntp.c b/src/libstddjb/tain_from_ntp.c index 68fa699..d6e3248 100644 --- a/src/libstddjb/tain_from_ntp.c +++ b/src/libstddjb/tain_from_ntp.c @@ -4,9 +4,9 @@ #include <skalibs/tai.h> #include <skalibs/djbtime.h> -int tain_from_ntp (tain_t *a, uint64_t u) +int tain_from_ntp (tain *a, uint64_t u) { - tai_t secs = { .x = u >> 32 } ; + tai secs = { .x = u >> 32 } ; if (secs.x <= 0x7FFFFFFFUL) secs.x |= ((uint64_t)1 << 32) ; secs.x += TAI_MAGIC ; secs.x -= NTP_OFFSET ; diff --git a/src/libstddjb/tain_from_sysclock.c b/src/libstddjb/tain_from_sysclock.c index 468c248..4328564 100644 --- a/src/libstddjb/tain_from_sysclock.c +++ b/src/libstddjb/tain_from_sysclock.c @@ -2,7 +2,7 @@ #include <skalibs/tai.h> -int tain_from_sysclock (tain_t *a, tain_t const *u) +int tain_from_sysclock (tain *a, tain const *u) { if (!tai_from_sysclock(&a->sec, u->sec.x)) return 0 ; a->nano = u->nano ; diff --git a/src/libstddjb/tain_from_timespec.c b/src/libstddjb/tain_from_timespec.c index e471b95..174f055 100644 --- a/src/libstddjb/tain_from_timespec.c +++ b/src/libstddjb/tain_from_timespec.c @@ -3,7 +3,7 @@ #include <time.h> #include <skalibs/tai.h> -int tain_from_timespec (tain_t *t, struct timespec const *ts) +int tain_from_timespec (tain *t, struct timespec const *ts) { if (!tai_from_time(&t->sec, ts->tv_sec)) return 0 ; t->nano = ts->tv_nsec ; diff --git a/src/libstddjb/tain_from_timespec_sysclock.c b/src/libstddjb/tain_from_timespec_sysclock.c index b79cda8..2dff04b 100644 --- a/src/libstddjb/tain_from_timespec_sysclock.c +++ b/src/libstddjb/tain_from_timespec_sysclock.c @@ -3,7 +3,7 @@ #include <time.h> #include <skalibs/tai.h> -int tain_from_timespec_sysclock (tain_t *t, struct timespec const *ts) +int tain_from_timespec_sysclock (tain *t, struct timespec const *ts) { if (!tai_from_time_sysclock(&t->sec, ts->tv_sec)) return 0 ; t->nano = ts->tv_nsec ; diff --git a/src/libstddjb/tain_from_timeval.c b/src/libstddjb/tain_from_timeval.c index 0536070..6f2616d 100644 --- a/src/libstddjb/tain_from_timeval.c +++ b/src/libstddjb/tain_from_timeval.c @@ -3,7 +3,7 @@ #include <sys/time.h> #include <skalibs/tai.h> -int tain_from_timeval (tain_t *t, struct timeval const *tv) +int tain_from_timeval (tain *t, struct timeval const *tv) { if (!tai_from_time(&t->sec, tv->tv_sec)) return 0 ; t->nano = 1000 * tv->tv_usec ; diff --git a/src/libstddjb/tain_from_timeval_sysclock.c b/src/libstddjb/tain_from_timeval_sysclock.c index 625c4cd..2f50418 100644 --- a/src/libstddjb/tain_from_timeval_sysclock.c +++ b/src/libstddjb/tain_from_timeval_sysclock.c @@ -3,7 +3,7 @@ #include <sys/time.h> #include <skalibs/tai.h> -int tain_from_timeval_sysclock (tain_t *t, struct timeval const *tv) +int tain_from_timeval_sysclock (tain *t, struct timeval const *tv) { if (!tai_from_time_sysclock(&t->sec, tv->tv_sec)) return 0 ; t->nano = 1000 * tv->tv_usec ; diff --git a/src/libstddjb/tain_half.c b/src/libstddjb/tain_half.c index 4b8f404..8d3e199 100644 --- a/src/libstddjb/tain_half.c +++ b/src/libstddjb/tain_half.c @@ -2,7 +2,7 @@ #include <skalibs/tai.h> -void tain_half (tain_t *t, tain_t const *u) +void tain_half (tain *t, tain const *u) { t->nano = u->nano >> 1 ; if (u->sec.x & 1) t->nano += 500000000U ; diff --git a/src/libstddjb/tain_infinite_relative.c b/src/libstddjb/tain_infinite_relative.c index 89d750c..7640588 100644 --- a/src/libstddjb/tain_infinite_relative.c +++ b/src/libstddjb/tain_infinite_relative.c @@ -2,4 +2,4 @@ #include <skalibs/tai.h> -tain_t const tain_infinite_relative = TAIN_INFINITE_RELATIVE ; +tain const tain_infinite_relative = TAIN_INFINITE_RELATIVE ; diff --git a/src/libstddjb/tain_less.c b/src/libstddjb/tain_less.c index e52c058..a316fe0 100644 --- a/src/libstddjb/tain_less.c +++ b/src/libstddjb/tain_less.c @@ -2,7 +2,7 @@ #include <skalibs/tai.h> -int tain_less (tain_t const *t, tain_t const *u) +int tain_less (tain const *t, tain const *u) { if (tai_sec(&t->sec) < tai_sec(&u->sec)) return 1 ; if (tai_sec(&t->sec) > tai_sec(&u->sec)) return 0 ; diff --git a/src/libstddjb/tain_nano500.c b/src/libstddjb/tain_nano500.c index 70d86c5..22b0f9c 100644 --- a/src/libstddjb/tain_nano500.c +++ b/src/libstddjb/tain_nano500.c @@ -2,4 +2,4 @@ #include <skalibs/tai.h> -tain_t const tain_nano500 = TAIN_NANO500 ; +tain const tain_nano500 = TAIN_NANO500 ; diff --git a/src/libstddjb/tain_now.c b/src/libstddjb/tain_now.c index d6625d6..5e66fc7 100644 --- a/src/libstddjb/tain_now.c +++ b/src/libstddjb/tain_now.c @@ -4,4 +4,4 @@ #include <skalibs/tai.h> -tain_clockread_func_t_ref tain_now = &tain_wallclock_read ; +tain_clockread_func_ref tain_now = &tain_wallclock_read ; diff --git a/src/libstddjb/tain_now_set_stopwatch.c b/src/libstddjb/tain_now_set_stopwatch.c index a770141..fd31950 100644 --- a/src/libstddjb/tain_now_set_stopwatch.c +++ b/src/libstddjb/tain_now_set_stopwatch.c @@ -15,14 +15,14 @@ # define SKALIBS_STOPWATCH CLOCK_BOOTTIME #endif -static tain_t offset ; +static tain offset ; -static int tain_now_stopwatch (tain_t *now) +static int tain_now_stopwatch (tain *now) { return tain_stopwatch_read(now, SKALIBS_STOPWATCH, &offset) ; } -int tain_now_set_stopwatch (tain_t *now) +int tain_now_set_stopwatch (tain *now) { if (!tain_stopwatch_init(now, SKALIBS_STOPWATCH, &offset)) return tain_now_set_wallclock(now) ; @@ -32,7 +32,7 @@ int tain_now_set_stopwatch (tain_t *now) #else -int tain_now_set_stopwatch (tain_t *now) +int tain_now_set_stopwatch (tain *now) { return tain_now_set_wallclock(now) ; } diff --git a/src/libstddjb/tain_now_set_wallclock.c b/src/libstddjb/tain_now_set_wallclock.c index 34a44cc..80c5fd6 100644 --- a/src/libstddjb/tain_now_set_wallclock.c +++ b/src/libstddjb/tain_now_set_wallclock.c @@ -4,7 +4,7 @@ #include <skalibs/tai.h> -int tain_now_set_wallclock (tain_t *now) +int tain_now_set_wallclock (tain *now) { tain_now = &tain_wallclock_read ; return tain_wallclock_read(now) ; diff --git a/src/libstddjb/tain_pack.c b/src/libstddjb/tain_pack.c index cb1918a..da8a92f 100644 --- a/src/libstddjb/tain_pack.c +++ b/src/libstddjb/tain_pack.c @@ -3,7 +3,7 @@ #include <skalibs/uint32.h> #include <skalibs/tai.h> -void tain_pack (char *s, tain_t const *t) +void tain_pack (char *s, tain const *t) { tai_pack(s, &t->sec) ; uint32_pack_big(s+8, t->nano) ; diff --git a/src/libstddjb/tain_pack_little.c b/src/libstddjb/tain_pack_little.c index 170da28..b4c6bff 100644 --- a/src/libstddjb/tain_pack_little.c +++ b/src/libstddjb/tain_pack_little.c @@ -3,7 +3,7 @@ #include <skalibs/uint32.h> #include <skalibs/tai.h> -void tain_pack_little (char *s, tain_t const *t) +void tain_pack_little (char *s, tain const *t) { uint32_pack(s, t->nano) ; tai_pack_little(s+4, &t->sec) ; diff --git a/src/libstddjb/tain_relative_from_timespec.c b/src/libstddjb/tain_relative_from_timespec.c index 5f492ff..394785b 100644 --- a/src/libstddjb/tain_relative_from_timespec.c +++ b/src/libstddjb/tain_relative_from_timespec.c @@ -3,7 +3,7 @@ #include <time.h> #include <skalibs/tai.h> -int tain_relative_from_timespec (tain_t *a, struct timespec const *ts) +int tain_relative_from_timespec (tain *a, struct timespec const *ts) { tai_relative_from_time(&a->sec, ts->tv_sec) ; a->nano = ts->tv_nsec ; diff --git a/src/libstddjb/tain_relative_from_timeval.c b/src/libstddjb/tain_relative_from_timeval.c index eafb57a..6fa67e5 100644 --- a/src/libstddjb/tain_relative_from_timeval.c +++ b/src/libstddjb/tain_relative_from_timeval.c @@ -3,7 +3,7 @@ #include <sys/time.h> #include <skalibs/tai.h> -int tain_relative_from_timeval (tain_t *a, struct timeval const *tv) +int tain_relative_from_timeval (tain *a, struct timeval const *tv) { tai_relative_from_time(&a->sec, tv->tv_sec) ; a->nano = 1000 * tv->tv_usec ; diff --git a/src/libstddjb/tain_scan.c b/src/libstddjb/tain_scan.c index 2522726..fab0ba4 100644 --- a/src/libstddjb/tain_scan.c +++ b/src/libstddjb/tain_scan.c @@ -3,7 +3,7 @@ #include <skalibs/fmtscan.h> #include <skalibs/tai.h> -size_t tain_scan (char const *s, tain_t *a) +size_t tain_scan (char const *s, tain *a) { char pack[TAIN_PACK] ; size_t r = ucharn_scan(s, pack, TAIN_PACK) ; diff --git a/src/libstddjb/tain_setnow.c b/src/libstddjb/tain_setnow.c index a8b372f..a6ed337 100644 --- a/src/libstddjb/tain_setnow.c +++ b/src/libstddjb/tain_setnow.c @@ -4,9 +4,9 @@ #include <skalibs/tai.h> -int tain_setnow (tain_t const *a) +int tain_setnow (tain const *a) { - tain_t aa ; + tain aa ; if (!sysclock_from_tai(&aa.sec.x, &a->sec)) return 0 ; aa.nano = a->nano ; return sysclock_set(&aa) ; diff --git a/src/libstddjb/tain_stopwatch.c b/src/libstddjb/tain_stopwatch.c index adcaace..a5f3ef7 100644 --- a/src/libstddjb/tain_stopwatch.c +++ b/src/libstddjb/tain_stopwatch.c @@ -7,9 +7,9 @@ #include <time.h> -int tain_stopwatch_init (tain_t *now, clock_t cl, tain_t *offset) +int tain_stopwatch_init (tain *now, clock_t cl, tain *offset) { - tain_t a, b ; + tain a, b ; struct timespec ts ; if (clock_gettime(cl, &ts) < 0) return 0 ; if (!tain_from_timespec(&b, &ts)) return 0 ; @@ -19,12 +19,12 @@ int tain_stopwatch_init (tain_t *now, clock_t cl, tain_t *offset) return 1 ; } -int tain_stopwatch_read (tain_t *a, clock_t cl, tain_t const *offset) +int tain_stopwatch_read (tain *now, clock_t cl, tain const *offset) { struct timespec ts ; if (clock_gettime(cl, &ts) < 0) return 0 ; - if (!tain_from_timespec(a, &ts)) return 0 ; - tain_add(a, a, offset) ; + if (!tain_from_timespec(now, &ts)) return 0 ; + tain_add(now, now, offset) ; return 1 ; } @@ -32,7 +32,7 @@ int tain_stopwatch_read (tain_t *a, clock_t cl, tain_t const *offset) #include <errno.h> -int tain_stopwatch_init (tain_t *now, clock_t cl, tain_t *offset) +int tain_stopwatch_init (tain *now, clock_t cl, tain *offset) { (void)now ; (void)cl ; @@ -40,7 +40,7 @@ int tain_stopwatch_init (tain_t *now, clock_t cl, tain_t *offset) return (errno = ENOSYS, 0) ; } -int tain_stopwatch_read (tain_t *now, clock_t cl, tain_t const *offset) +int tain_stopwatch_read (tain *now, clock_t cl, tain const *offset) { (void)now ; (void)cl ; diff --git a/src/libstddjb/tain_sub.c b/src/libstddjb/tain_sub.c index 0d756e7..12bc98e 100644 --- a/src/libstddjb/tain_sub.c +++ b/src/libstddjb/tain_sub.c @@ -2,9 +2,9 @@ #include <skalibs/tai.h> -int tain_sub (tain_t *t, tain_t const *u, tain_t const *v) +int tain_sub (tain *t, tain const *u, tain const *v) { - tain_t tt ; + tain tt ; tt.sec.x = u->sec.x - v->sec.x ; tt.nano = u->nano - v->nano ; if (tt.nano > u->nano) diff --git a/src/libstddjb/tain_to_millisecs.c b/src/libstddjb/tain_to_millisecs.c index 0854c49..0ccf641 100644 --- a/src/libstddjb/tain_to_millisecs.c +++ b/src/libstddjb/tain_to_millisecs.c @@ -3,7 +3,7 @@ #include <skalibs/uint64.h> #include <skalibs/tai.h> -int tain_to_millisecs (tain_t const *a) +int tain_to_millisecs (tain const *a) { if (a->sec.x > (uint64_t)2147483) return -1 ; if ((a->sec.x == (uint64_t)2147483) && (a->nano > 646000000U)) return -1 ; diff --git a/src/libstddjb/tain_ulong.c b/src/libstddjb/tain_ulong.c index 8eb890b..b9b885d 100644 --- a/src/libstddjb/tain_ulong.c +++ b/src/libstddjb/tain_ulong.c @@ -2,7 +2,7 @@ #include <skalibs/tai.h> -int tain_ulong (tain_t *t, unsigned long s) +int tain_ulong (tain *t, unsigned long s) { if (!tai_u64(&t->sec, s)) return 0 ; t->nano = 0 ; diff --git a/src/libstddjb/tain_unpack.c b/src/libstddjb/tain_unpack.c index a62dc29..9c31e4a 100644 --- a/src/libstddjb/tain_unpack.c +++ b/src/libstddjb/tain_unpack.c @@ -3,7 +3,7 @@ #include <skalibs/uint32.h> #include <skalibs/tai.h> -void tain_unpack (char const *s, tain_t *t) +void tain_unpack (char const *s, tain *t) { tai_unpack(s, &t->sec) ; uint32_unpack_big(s+8, &t->nano) ; diff --git a/src/libstddjb/tain_unpack_little.c b/src/libstddjb/tain_unpack_little.c index 278d494..3d370c8 100644 --- a/src/libstddjb/tain_unpack_little.c +++ b/src/libstddjb/tain_unpack_little.c @@ -3,7 +3,7 @@ #include <skalibs/uint32.h> #include <skalibs/tai.h> -void tain_unpack_little (char const *s, tain_t *t) +void tain_unpack_little (char const *s, tain *t) { uint32_unpack(s, &t->nano) ; tai_unpack_little(s+4, &t->sec) ; diff --git a/src/libstddjb/tain_wallclock_read.c b/src/libstddjb/tain_wallclock_read.c index 96ed861..57222d0 100644 --- a/src/libstddjb/tain_wallclock_read.c +++ b/src/libstddjb/tain_wallclock_read.c @@ -2,9 +2,9 @@ #include <skalibs/tai.h> -int tain_wallclock_read (tain_t *a) +int tain_wallclock_read (tain *a) { - tain_t aa ; + tain aa ; if (!sysclock_get(&aa)) return 0 ; return tain_from_sysclock(a, &aa) ; } diff --git a/src/libstddjb/tain_zero.c b/src/libstddjb/tain_zero.c index 4a82f08..38f530d 100644 --- a/src/libstddjb/tain_zero.c +++ b/src/libstddjb/tain_zero.c @@ -2,4 +2,4 @@ #include <skalibs/tai.h> -tain_t const tain_zero = TAIN_ZERO ; +tain const tain_zero = TAIN_ZERO ; diff --git a/src/libstddjb/time_from_tai.c b/src/libstddjb/time_from_tai.c index f3f9538..33ab888 100644 --- a/src/libstddjb/time_from_tai.c +++ b/src/libstddjb/time_from_tai.c @@ -7,7 +7,7 @@ #include <skalibs/uint64.h> #include <skalibs/tai.h> -int time_from_tai (time_t *u, tai_t const *t) +int time_from_tai (time_t *u, tai const *t) { uint64_t uu = t->x - TAI_MAGIC ; #if SKALIBS_SIZEOFTIME < 8 diff --git a/src/libstddjb/time_from_tai_relative.c b/src/libstddjb/time_from_tai_relative.c index 598d80b..88b928f 100644 --- a/src/libstddjb/time_from_tai_relative.c +++ b/src/libstddjb/time_from_tai_relative.c @@ -6,7 +6,7 @@ #include <errno.h> #include <skalibs/tai.h> -int time_from_tai_relative (time_t *u, tai_t const *t) +int time_from_tai_relative (time_t *u, tai const *t) { #if SKALIBS_SIZEOFTIME < 8 if ((t->x >> 32) && (t->x >> 32) != 0xffffffffUL) diff --git a/src/libstddjb/time_sysclock_from_tai.c b/src/libstddjb/time_sysclock_from_tai.c index b0fd689..afa2456 100644 --- a/src/libstddjb/time_sysclock_from_tai.c +++ b/src/libstddjb/time_sysclock_from_tai.c @@ -7,7 +7,7 @@ #include <skalibs/uint64.h> #include <skalibs/tai.h> -int time_sysclock_from_tai (time_t *u, tai_t const *t) +int time_sysclock_from_tai (time_t *u, tai const *t) { uint64_t uu ; if (!sysclock_from_tai(&uu, t)) return 0 ; diff --git a/src/libstddjb/timespec_from_tain.c b/src/libstddjb/timespec_from_tain.c index cd63547..1feb34d 100644 --- a/src/libstddjb/timespec_from_tain.c +++ b/src/libstddjb/timespec_from_tain.c @@ -3,7 +3,7 @@ #include <time.h> #include <skalibs/tai.h> -int timespec_from_tain (struct timespec *ts, tain_t const *t) +int timespec_from_tain (struct timespec *ts, tain const *t) { if (!time_from_tai(&ts->tv_sec, &t->sec)) return 0 ; ts->tv_nsec = t->nano ; diff --git a/src/libstddjb/timespec_from_tain_relative.c b/src/libstddjb/timespec_from_tain_relative.c index 8ef34e8..36b58fd 100644 --- a/src/libstddjb/timespec_from_tain_relative.c +++ b/src/libstddjb/timespec_from_tain_relative.c @@ -3,7 +3,7 @@ #include <time.h> #include <skalibs/tai.h> -int timespec_from_tain_relative (struct timespec *ts, tain_t const *t) +int timespec_from_tain_relative (struct timespec *ts, tain const *t) { if (!time_from_tai_relative(&ts->tv_sec, &t->sec)) return 0 ; ts->tv_nsec = t->nano ; diff --git a/src/libstddjb/timespec_sysclock_from_tain.c b/src/libstddjb/timespec_sysclock_from_tain.c index 5544511..4e9513c 100644 --- a/src/libstddjb/timespec_sysclock_from_tain.c +++ b/src/libstddjb/timespec_sysclock_from_tain.c @@ -3,7 +3,7 @@ #include <time.h> #include <skalibs/tai.h> -int timespec_sysclock_from_tain (struct timespec *ts, tain_t const *t) +int timespec_sysclock_from_tain (struct timespec *ts, tain const *t) { if (!time_sysclock_from_tai(&ts->tv_sec, &t->sec)) return 0 ; ts->tv_nsec = t->nano ; diff --git a/src/libstddjb/timestamp.c b/src/libstddjb/timestamp.c index 7feb7c2..064946b 100644 --- a/src/libstddjb/timestamp.c +++ b/src/libstddjb/timestamp.c @@ -4,6 +4,6 @@ int timestamp (char *s) { - tain_t now ; + tain now ; return timestamp_r(s, &now) ; } diff --git a/src/libstddjb/timestamp_fmt.c b/src/libstddjb/timestamp_fmt.c index 78d2dc2..537f61d 100644 --- a/src/libstddjb/timestamp_fmt.c +++ b/src/libstddjb/timestamp_fmt.c @@ -2,7 +2,7 @@ #include <skalibs/tai.h> -size_t timestamp_fmt (char *s, tain_t const *a) +size_t timestamp_fmt (char *s, tain const *a) { *s = '@' ; return 1 + tain_fmt(s+1, a) ; diff --git a/src/libstddjb/timestamp_r.c b/src/libstddjb/timestamp_r.c index 46be7a4..4c8ac58 100644 --- a/src/libstddjb/timestamp_r.c +++ b/src/libstddjb/timestamp_r.c @@ -2,7 +2,7 @@ #include <skalibs/tai.h> -int timestamp_r (char *s, tain_t *stamp) +int timestamp_r (char *s, tain *stamp) { if (!tain_wallclock_read(stamp)) return 0 ; timestamp_fmt(s, stamp) ; diff --git a/src/libstddjb/timestamp_scan.c b/src/libstddjb/timestamp_scan.c index 677cf09..3557a2f 100644 --- a/src/libstddjb/timestamp_scan.c +++ b/src/libstddjb/timestamp_scan.c @@ -2,7 +2,7 @@ #include <skalibs/tai.h> -size_t timestamp_scan (char const *s, tain_t *a) +size_t timestamp_scan (char const *s, tain *a) { size_t r ; if (*s != '@') return 0 ; diff --git a/src/libstddjb/timeval_from_tain.c b/src/libstddjb/timeval_from_tain.c index 2b4d577..b178bba 100644 --- a/src/libstddjb/timeval_from_tain.c +++ b/src/libstddjb/timeval_from_tain.c @@ -3,7 +3,7 @@ #include <sys/time.h> #include <skalibs/tai.h> -int timeval_from_tain (struct timeval *tv, tain_t const *t) +int timeval_from_tain (struct timeval *tv, tain const *t) { if (!time_from_tai(&tv->tv_sec, &t->sec)) return 0 ; tv->tv_usec = (t->nano + 500) / 1000 ; diff --git a/src/libstddjb/timeval_from_tain_relative.c b/src/libstddjb/timeval_from_tain_relative.c index de775fd..f340f3f 100644 --- a/src/libstddjb/timeval_from_tain_relative.c +++ b/src/libstddjb/timeval_from_tain_relative.c @@ -3,7 +3,7 @@ #include <sys/time.h> #include <skalibs/tai.h> -int timeval_from_tain_relative (struct timeval *tv, tain_t const *t) +int timeval_from_tain_relative (struct timeval *tv, tain const *t) { if (!time_from_tai_relative(&tv->tv_sec, &t->sec)) return 0 ; tv->tv_usec = (t->nano + 500) / 1000 ; diff --git a/src/libstddjb/timeval_sysclock_from_tain.c b/src/libstddjb/timeval_sysclock_from_tain.c index c41b133..ff94c2c 100644 --- a/src/libstddjb/timeval_sysclock_from_tain.c +++ b/src/libstddjb/timeval_sysclock_from_tain.c @@ -3,7 +3,7 @@ #include <sys/time.h> #include <skalibs/tai.h> -int timeval_sysclock_from_tain (struct timeval *tv, tain_t const *t) +int timeval_sysclock_from_tain (struct timeval *tv, tain const *t) { if (!time_sysclock_from_tai(&tv->tv_sec, &t->sec)) return 0 ; tv->tv_usec = (t->nano + 500) / 1000 ; diff --git a/src/libstddjb/utc_from_sysclock.c b/src/libstddjb/utc_from_sysclock.c index 7310a10..8eb5d53 100644 --- a/src/libstddjb/utc_from_sysclock.c +++ b/src/libstddjb/utc_from_sysclock.c @@ -10,7 +10,7 @@ int utc_from_sysclock (uint64_t *u) { - tai_t t = { .x = *u + 10U } ; + tai t = { .x = *u + 10U } ; return utc_from_tai(u, &t) ; } diff --git a/src/libstddjb/utc_from_tai.c b/src/libstddjb/utc_from_tai.c index a0e087e..1413b38 100644 --- a/src/libstddjb/utc_from_tai.c +++ b/src/libstddjb/utc_from_tai.c @@ -4,7 +4,7 @@ #include <skalibs/djbtime.h> #include "djbtime-internal.h" -int utc_from_tai (uint64_t *u, tai_t const *t) +int utc_from_tai (uint64_t *u, tai const *t) { int r = 1 ; uint64_t tt = t->x - 10 ; diff --git a/src/libunixonacid/access_at.c b/src/libunixonacid/access_at.c index 03cac7d..ebe6dd7 100644 --- a/src/libunixonacid/access_at.c +++ b/src/libunixonacid/access_at.c @@ -9,8 +9,10 @@ #endif #include <skalibs/nonposix.h> + #include <fcntl.h> #include <unistd.h> + #include <skalibs/unix-transactional.h> int access_at (int dirfd, char const *file, int amode, unsigned int flag) @@ -22,6 +24,7 @@ int access_at (int dirfd, char const *file, int amode, unsigned int flag) #include <errno.h> #include <unistd.h> + #include <skalibs/djbunix.h> #include <skalibs/unix-transactional.h> diff --git a/src/libunixonacid/bufalloc_timed_flush.c b/src/libunixonacid/bufalloc_timed_flush.c index 7ebb70e..1f14606 100644 --- a/src/libunixonacid/bufalloc_timed_flush.c +++ b/src/libunixonacid/bufalloc_timed_flush.c @@ -9,7 +9,7 @@ static int bufalloc_isnonempty (bufalloc *ba) return !!bufalloc_len(ba) ; } -int bufalloc_timed_flush (bufalloc *ba, tain_t const *deadline, tain_t *stamp) +int bufalloc_timed_flush (bufalloc *ba, tain const *deadline, tain *stamp) { - return timed_flush(ba, (initfunc_t_ref)&bufalloc_getfd, (initfunc_t_ref)&bufalloc_isnonempty, (initfunc_t_ref)&bufalloc_flush, deadline, stamp) ; + return timed_flush(ba, (init_func_ref)&bufalloc_getfd, (init_func_ref)&bufalloc_isnonempty, (init_func_ref)&bufalloc_flush, deadline, stamp) ; } diff --git a/src/libunixonacid/buffer_timed_fill.c b/src/libunixonacid/buffer_timed_fill.c index eb41b5b..6ec3e30 100644 --- a/src/libunixonacid/buffer_timed_fill.c +++ b/src/libunixonacid/buffer_timed_fill.c @@ -10,7 +10,7 @@ static ssize_t get (buffer *b) return sanitize_read(buffer_fill(b)) ; } -ssize_t buffer_timed_fill (buffer *b, tain_t const *deadline, tain_t *stamp) +ssize_t buffer_timed_fill (buffer *b, tain const *deadline, tain *stamp) { - return timed_get(b, (initfunc_t_ref)&buffer_getfd, (getfunc_t_ref)&get, deadline, stamp) ; + return timed_get(b, (init_func_ref)&buffer_getfd, (get_func_ref)&get, deadline, stamp) ; } diff --git a/src/libunixonacid/buffer_timed_flush.c b/src/libunixonacid/buffer_timed_flush.c index 4de467a..d688243 100644 --- a/src/libunixonacid/buffer_timed_flush.c +++ b/src/libunixonacid/buffer_timed_flush.c @@ -9,7 +9,7 @@ static int buffer_isnonempty (buffer *b) return !buffer_isempty(b) ; } -int buffer_timed_flush (buffer *b, tain_t const *deadline, tain_t *stamp) +int buffer_timed_flush (buffer *b, tain const *deadline, tain *stamp) { - return timed_flush(b, (initfunc_t_ref)&buffer_getfd, (initfunc_t_ref)&buffer_isnonempty, (initfunc_t_ref)&buffer_flush, deadline, stamp) ; + return timed_flush(b, (init_func_ref)&buffer_getfd, (init_func_ref)&buffer_isnonempty, (init_func_ref)&buffer_flush, deadline, stamp) ; } diff --git a/src/libunixonacid/buffer_timed_get.c b/src/libunixonacid/buffer_timed_get.c index 8dee2c2..e87c956 100644 --- a/src/libunixonacid/buffer_timed_get.c +++ b/src/libunixonacid/buffer_timed_get.c @@ -22,9 +22,9 @@ static ssize_t get (struct blah_s *blah) return buffer_getall(blah->b, blah->s, blah->len, &blah->w) ; } -size_t buffer_timed_get (buffer *b, char *s, size_t len, tain_t const *deadline, tain_t *stamp) +size_t buffer_timed_get (buffer *b, char *s, size_t len, tain const *deadline, tain *stamp) { struct blah_s blah = { .b = b, .s = s, .len = len, .w = 0 } ; - timed_get(&blah, (initfunc_t_ref)&getfd, (getfunc_t_ref)&get, deadline, stamp) ; + timed_get(&blah, (init_func_ref)&getfd, (get_func_ref)&get, deadline, stamp) ; return blah.w ; } diff --git a/src/libunixonacid/dd_cancel.c b/src/libunixonacid/dd_cancel.c deleted file mode 100644 index 34b6014..0000000 --- a/src/libunixonacid/dd_cancel.c +++ /dev/null @@ -1,14 +0,0 @@ -/* ISC license. */ - -#include <skalibs/stralloc.h> -#include <skalibs/djbunix.h> -#include <skalibs/unix-transactional.h> - -void dd_cancel (dirdescriptor_t *dd) -{ - dirdescriptor_t zero = DIRDESCRIPTOR_ZERO ; - fd_close(dd->fd) ; - rm_rf_in_tmp(&dd->new, 0) ; - stralloc_free(&dd->new) ; - *dd = zero ; -} diff --git a/src/libunixonacid/dd_close.c b/src/libunixonacid/dd_close.c deleted file mode 100644 index be5bdd9..0000000 --- a/src/libunixonacid/dd_close.c +++ /dev/null @@ -1,9 +0,0 @@ -/* ISC license. */ - -#include <skalibs/djbunix.h> -#include <skalibs/unix-transactional.h> - -void dd_close (dirdescriptor_t *dd) -{ - fd_close(dd->fd) ; -} diff --git a/src/libunixonacid/dd_commit.c b/src/libunixonacid/dd_commit.c deleted file mode 100644 index 1c940d2..0000000 --- a/src/libunixonacid/dd_commit.c +++ /dev/null @@ -1,68 +0,0 @@ -/* ISC license. */ - -#include <unistd.h> -#include <errno.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, size_t len) -{ - size_t i = len ; - while (i--) if (s[i] == '/') return s + i + 1 ; - return s ; -} - -int dd_commit (dirdescriptor_t *dd) -{ - dirdescriptor_t zero = DIRDESCRIPTOR_ZERO ; - 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) - { - 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 ; - if (!stralloc_0(&dd->new)) goto fail ; - if (rename(dd->lnkfn, dd->new.s + oldbase) < 0) goto fail ; - /* /!\ 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 */ - { - 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 */ - } - } - if (!stralloc_0(&dd->new)) goto fail ; - newlnkbase = dd->new.len ; - if (!stralloc_catb(&dd->new, dd->lnkfn, len)) goto fail ; - if (!random_sauniquename(&dd->new, 8)) goto fail ; - if (!stralloc_0(&dd->new)) goto fail ; - if (symlink(dd->new.s, dd->new.s + newlnkbase) < 0) goto fail ; - if (rename(dd->new.s + newlnkbase, dd->lnkfn) < 0) - { - int e = errno ; - unlink(dd->new.s + newlnkbase) ; - errno = e ; - goto fail ; - } - fd_close(dd->fd) ; - dd->new.len = newlnkbase ; - rm_rf_in_tmp(&dd->new, oldbase) ; - stralloc_free(&dd->new) ; - *dd = zero ; - return 1 ; - - fail: - dd->new.len = oldbase ; - return 0 ; -} diff --git a/src/libunixonacid/dd_commit_devino.c b/src/libunixonacid/dd_commit_devino.c deleted file mode 100644 index 96713fe..0000000 --- a/src/libunixonacid/dd_commit_devino.c +++ /dev/null @@ -1,14 +0,0 @@ -/* ISC license. */ - -#include <sys/stat.h> -#include <skalibs/unix-transactional.h> - -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 = st.st_dev ; - *ino = st.st_ino ; - return 1 ; -} diff --git a/src/libunixonacid/dd_open_read.c b/src/libunixonacid/dd_open_read.c deleted file mode 100644 index 9189582..0000000 --- a/src/libunixonacid/dd_open_read.c +++ /dev/null @@ -1,14 +0,0 @@ -/* ISC license. */ - -#include <skalibs/djbunix.h> -#include <skalibs/unix-transactional.h> - -int dd_open_read (dirdescriptor_t *dd, char const *path) -{ - dirdescriptor_t d = DIRDESCRIPTOR_ZERO ; - d.fd = open_read(path) ; - if (d.fd < 0) return 0 ; - d.lnkfn = path ; - *dd = d ; - return 1 ; -} diff --git a/src/libunixonacid/dd_open_write.c b/src/libunixonacid/dd_open_write.c deleted file mode 100644 index fbaf28e..0000000 --- a/src/libunixonacid/dd_open_write.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ISC license. */ - -#include <sys/stat.h> -#include <unistd.h> -#include <errno.h> -#include <skalibs/stralloc.h> -#include <skalibs/djbunix.h> -#include <skalibs/random.h> -#include <skalibs/unix-transactional.h> - -int dd_open_write (dirdescriptor_t *dd, char const *lnkfn, unsigned int mode) -{ - dirdescriptor_t d = DIRDESCRIPTOR_ZERO ; - d.lnkfn = lnkfn ; - if (!stralloc_cats(&d.new, lnkfn)) return 0 ; - if (!random_sauniquename(&d.new, 8)) goto fail ; - if (!stralloc_0(&d.new)) goto fail ; - if (mkdir(d.new.s, mode) < 0) goto fail ; - d.fd = open_read(d.new.s) ; - if (d.fd < 0) - { - int e = errno ; - rmdir(d.new.s) ; - errno = e ; - goto fail ; - } - *dd = d ; - return 1 ; - - fail: - stralloc_free(&d.new) ; - return 0 ; -} diff --git a/src/libunixonacid/ipc_timed_recv.c b/src/libunixonacid/ipc_timed_recv.c index 5710a8c..d108f5d 100644 --- a/src/libunixonacid/ipc_timed_recv.c +++ b/src/libunixonacid/ipc_timed_recv.c @@ -23,8 +23,8 @@ static ssize_t get (struct blah_s *blah) return sanitize_read(ipc_recv(blah->fd, blah->s, blah->len, blah->path)) ; } -ssize_t ipc_timed_recv (int fd, char *s, size_t 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 const *deadline, tain *stamp) { struct blah_s blah = { .fd = fd, .s = s, .len = len, .path = path } ; - return timed_get(&blah, (initfunc_t_ref)&getfd, (getfunc_t_ref)&get, deadline, stamp) ; + return timed_get(&blah, (init_func_ref)&getfd, (get_func_ref)&get, deadline, stamp) ; } diff --git a/src/libunixonacid/ipc_timed_send.c b/src/libunixonacid/ipc_timed_send.c index 2f6ce88..d4a4d7b 100644 --- a/src/libunixonacid/ipc_timed_send.c +++ b/src/libunixonacid/ipc_timed_send.c @@ -10,7 +10,7 @@ #include <skalibs/unix-timed.h> #include <skalibs/posixishard.h> -int ipc_timed_send (int fd, char const *s, size_t len, tain_t const *deadline, tain_t *stamp) +int ipc_timed_send (int fd, char const *s, size_t len, tain const *deadline, tain *stamp) { iopause_fd x = { .fd = fd, .events = IOPAUSE_WRITE, .revents = 0 } ; for (;;) diff --git a/src/libunixonacid/ipc_timed_sendv.c b/src/libunixonacid/ipc_timed_sendv.c index 1bdae5b..673503d 100644 --- a/src/libunixonacid/ipc_timed_sendv.c +++ b/src/libunixonacid/ipc_timed_sendv.c @@ -11,7 +11,7 @@ #include <skalibs/unix-timed.h> #include <skalibs/posixishard.h> -int ipc_timed_sendv (int fd, struct iovec const *v, unsigned int n, tain_t const *deadline, tain_t *stamp) +int ipc_timed_sendv (int fd, struct iovec const *v, unsigned int n, tain const *deadline, tain *stamp) { struct msghdr hdr = { diff --git a/src/libunixonacid/kolbak_call.c b/src/libunixonacid/kolbak_call.c index b7b97c0..fce2add 100644 --- a/src/libunixonacid/kolbak_call.c +++ b/src/libunixonacid/kolbak_call.c @@ -1,10 +1,11 @@ /* ISC license. */ #include <errno.h> + #include <skalibs/unixmessage.h> #include <skalibs/kolbak.h> -int kolbak_call (unixmessage_t const *m, kolbak_queue_t *q) +int kolbak_call (unixmessage const *m, kolbak_queue *q) { if (q->head == q->tail) return (errno = EILSEQ, 0) ; if (!(*q->x[q->head].f)(m, q->x[q->head].data)) return 0 ; diff --git a/src/libunixonacid/kolbak_enqueue.c b/src/libunixonacid/kolbak_enqueue.c index 0838e99..7a7b619 100644 --- a/src/libunixonacid/kolbak_enqueue.c +++ b/src/libunixonacid/kolbak_enqueue.c @@ -2,10 +2,11 @@ #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) +int kolbak_enqueue (kolbak_queue *q, unixmessage_handler_func_ref f, void *data) { size_t newtail = (q->tail + 1) % q->n ; if (newtail == q->head) return (errno = ENOBUFS, 0) ; diff --git a/src/libunixonacid/kolbak_queue_init.c b/src/libunixonacid/kolbak_queue_init.c index a6c8fa5..b8c9b42 100644 --- a/src/libunixonacid/kolbak_queue_init.c +++ b/src/libunixonacid/kolbak_queue_init.c @@ -1,9 +1,10 @@ /* ISC license. */ #include <errno.h> + #include <skalibs/kolbak.h> -int kolbak_queue_init (kolbak_queue_t *q, kolbak_closure_t *s, size_t len) +int kolbak_queue_init (kolbak_queue *q, kolbak_closure *s, size_t len) { if (len < 2) return (errno = EINVAL, 0) ; q->x = s ; diff --git a/src/libunixonacid/kolbak_unenqueue.c b/src/libunixonacid/kolbak_unenqueue.c index 894beea..07ad8ea 100644 --- a/src/libunixonacid/kolbak_unenqueue.c +++ b/src/libunixonacid/kolbak_unenqueue.c @@ -1,9 +1,10 @@ /* ISC license. */ #include <errno.h> + #include <skalibs/kolbak.h> -int kolbak_unenqueue (kolbak_queue_t *q) +int kolbak_unenqueue (kolbak_queue *q) { if (q->head == q->tail) return (errno = EINVAL, 0) ; q->tail = (q->tail + q->n - 1) % q->n ; diff --git a/src/libunixonacid/netstring_timed_get.c b/src/libunixonacid/netstring_timed_get.c index c540a3f..106bbbd 100644 --- a/src/libunixonacid/netstring_timed_get.c +++ b/src/libunixonacid/netstring_timed_get.c @@ -6,7 +6,7 @@ #include <skalibs/iopause.h> #include <skalibs/unix-timed.h> -int netstring_timed_get (buffer *b, stralloc *sa, tain_t const *deadline, tain_t *stamp) +int netstring_timed_get (buffer *b, stralloc *sa, tain const *deadline, tain *stamp) { iopause_fd x = { .fd = buffer_fd(b), .events = IOPAUSE_READ } ; size_t w = 0 ; diff --git a/src/libunixonacid/skaclient-internal.h b/src/libunixonacid/skaclient-internal.h index b26152b..7828879 100644 --- a/src/libunixonacid/skaclient-internal.h +++ b/src/libunixonacid/skaclient-internal.h @@ -4,11 +4,12 @@ #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 *, 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 *) ; +extern int skaclient_init (skaclient *, int, char *, size_t, char *, size_t, char *, size_t, char *, size_t, kolbak_closure *, size_t, char const *, size_t) ; +extern int skaclient_start_cb (unixmessage const *, skaclient_cbdata *) ; #endif diff --git a/src/libunixonacid/skaclient_default_cb.c b/src/libunixonacid/skaclient_default_cb.c index 447d796..87fe62b 100644 --- a/src/libunixonacid/skaclient_default_cb.c +++ b/src/libunixonacid/skaclient_default_cb.c @@ -6,7 +6,7 @@ #include <skalibs/unixmessage.h> #include <skalibs/posixishard.h> -int skaclient_default_cb (unixmessage_t const *m, void *p) +int skaclient_default_cb (unixmessage const *m, void *p) { unsigned char *err = p ; if (m->len != 1 || m->nfds) return (errno = EPROTO, 0) ; diff --git a/src/libunixonacid/skaclient_end.c b/src/libunixonacid/skaclient_end.c index 1b24303..2fd39ab 100644 --- a/src/libunixonacid/skaclient_end.c +++ b/src/libunixonacid/skaclient_end.c @@ -5,7 +5,7 @@ #include <skalibs/skaclient.h> #include <skalibs/unixmessage.h> -void skaclient_end (skaclient_t *a) +void skaclient_end (skaclient *a) { fd_close(a->syncout.fd) ; fd_close(a->asyncout.fd) ; diff --git a/src/libunixonacid/skaclient_init.c b/src/libunixonacid/skaclient_init.c index a1cda0a..8419fc6 100644 --- a/src/libunixonacid/skaclient_init.c +++ b/src/libunixonacid/skaclient_init.c @@ -5,7 +5,7 @@ #include "skaclient-internal.h" int skaclient_init ( - skaclient_t *a, + skaclient *a, int fd, char *bufss, size_t bufsn, @@ -15,12 +15,12 @@ int skaclient_init ( size_t bufan, char *auxbufas, size_t auxbufan, - kolbak_closure_t *q, + kolbak_closure *q, size_t qlen, char const *before, size_t beforelen) { - unixmessage_t msg = { .s = (char *)before, .len = beforelen, .fds = 0, .nfds = 0 } ; + unixmessage msg = { .s = (char *)before, .len = beforelen, .fds = 0, .nfds = 0 } ; if (!unixmessage_receiver_init(&a->syncin, fd, bufss, bufsn, auxbufss, auxbufsn) || !unixmessage_receiver_init(&a->asyncin, -1, bufas, bufan, auxbufas, auxbufan) || !kolbak_queue_init(&a->kq, q, qlen)) return 0 ; diff --git a/src/libunixonacid/skaclient_put.c b/src/libunixonacid/skaclient_put.c index 214d013..35b85e9 100644 --- a/src/libunixonacid/skaclient_put.c +++ b/src/libunixonacid/skaclient_put.c @@ -3,8 +3,8 @@ #include <skalibs/skaclient.h> #include <skalibs/unixmessage.h> -int skaclient_put (skaclient_t *a, char const *s, size_t len, unixmessage_handler_func_t *cb, void *result) +int skaclient_put (skaclient *a, char const *s, size_t len, unixmessage_handler_func *cb, void *result) { - unixmessage_t m = { .s = (char *)s, .len = len, .fds = 0, .nfds = 0 } ; + unixmessage 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 d1cb68e..83878bd 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_ref cb, void *result) +int skaclient_putmsg_and_close (skaclient *a, unixmessage const *m, unsigned char const *bits, unixmessage_handler_func_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 fb0b866..6905479 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_ref cb, void *result) +int skaclient_putmsgv_and_close (skaclient *a, unixmessagev const *m, unsigned char const *bits, unixmessage_handler_func_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 8a5276e..8831373 100644 --- a/src/libunixonacid/skaclient_putv.c +++ b/src/libunixonacid/skaclient_putv.c @@ -4,8 +4,8 @@ #include <skalibs/skaclient.h> #include <skalibs/unixmessage.h> -int skaclient_putv (skaclient_t *a, struct iovec const *v, unsigned int vlen, unixmessage_handler_func_t *cb, void *result) +int skaclient_putv (skaclient *a, struct iovec const *v, unsigned int vlen, unixmessage_handler_func *cb, void *result) { - unixmessage_v_t m = { .v = (struct iovec *)v, .vlen = vlen, .fds = 0, .nfds = 0 } ; + unixmessagev 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 980d953..cb5b44d 100644 --- a/src/libunixonacid/skaclient_send.c +++ b/src/libunixonacid/skaclient_send.c @@ -3,8 +3,8 @@ #include <skalibs/unixmessage.h> #include <skalibs/skaclient.h> -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) +int skaclient_send (skaclient *a, char const *s, size_t len, unixmessage_handler_func *cb, void *result, tain const *deadline, tain *stamp) { - unixmessage_t m = { .s = (char *)s, .len = len, .fds = 0, .nfds = 0 } ; + unixmessage 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 6ace2ba..2d60a16 100644 --- a/src/libunixonacid/skaclient_sendmsg.c +++ b/src/libunixonacid/skaclient_sendmsg.c @@ -2,7 +2,7 @@ #include <skalibs/skaclient.h> -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) +int skaclient_sendmsg_and_close (skaclient *a, unixmessage const *m, unsigned char const *bits, unixmessage_handler_func_ref cb, void *result, tain const *deadline, tain *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 0b8a702..10ab27a 100644 --- a/src/libunixonacid/skaclient_sendmsgv.c +++ b/src/libunixonacid/skaclient_sendmsgv.c @@ -2,7 +2,7 @@ #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_ref cb, void *result, tain_t const *deadline, tain_t *stamp) +int skaclient_sendmsgv_and_close (skaclient *a, unixmessagev const *m, unsigned char const *bits, unixmessage_handler_func_ref cb, void *result, tain const *deadline, tain *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 fa2713d..7cbf098 100644 --- a/src/libunixonacid/skaclient_sendv.c +++ b/src/libunixonacid/skaclient_sendv.c @@ -3,8 +3,8 @@ #include <skalibs/skaclient.h> #include <skalibs/unixmessage.h> -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) +int skaclient_sendv (skaclient *a, struct iovec const *v, unsigned int vlen, unixmessage_handler_func *cb, void *result, tain const *deadline, tain *stamp) { - unixmessage_v_t m = { .v = (struct iovec *)v, .vlen = vlen, .fds = 0, .nfds = 0 } ; + unixmessagev 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 cec61d1..0f08d55 100644 --- a/src/libunixonacid/skaclient_server_ack.c +++ b/src/libunixonacid/skaclient_server_ack.c @@ -9,10 +9,10 @@ #include <skalibs/socket.h> #include <skalibs/posixishard.h> -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 skaclient_server_ack (unixmessage const *clientmsg, unixmessage_sender *out, unixmessage_sender *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 } ; + unixmessage m = { .s = (char *)after, .len = afterlen, .fds = fd, .nfds = 1 } ; static unsigned char const bits = 0xff ; if (clientmsg->nfds || clientmsg->len != beforelen diff --git a/src/libunixonacid/skaclient_server_bidi_ack.c b/src/libunixonacid/skaclient_server_bidi_ack.c index 4a65fdb..b1a60f3 100644 --- a/src/libunixonacid/skaclient_server_bidi_ack.c +++ b/src/libunixonacid/skaclient_server_bidi_ack.c @@ -3,7 +3,7 @@ #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, size_t mainlen, char *auxbuf, size_t auxlen, char const *before, size_t beforelen, char const *after, size_t afterlen) +int skaclient_server_bidi_ack (unixmessage const *clientmsg, unixmessage_sender *out, unixmessage_sender *asyncout, unixmessage_receiver *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 827a5e4..796ed43 100644 --- a/src/libunixonacid/skaclient_server_init.c +++ b/src/libunixonacid/skaclient_server_init.c @@ -4,9 +4,9 @@ #include <skalibs/skaclient.h> #include <skalibs/unixmessage.h> -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) +int skaclient_server_init (unixmessage_receiver *in, unixmessage_sender *out, unixmessage_sender *asyncout, char const *before, size_t beforelen, char const *after, size_t afterlen, tain const *deadline, tain *stamp) { - unixmessage_t m ; + unixmessage m ; return (sanitize_read(unixmessage_timed_receive(in, &m, deadline, stamp)) >= 0) && skaclient_server_ack(&m, out, asyncout, before, beforelen, after, afterlen) && unixmessage_sender_timed_flush(out, deadline, stamp) ; diff --git a/src/libunixonacid/skaclient_start.c b/src/libunixonacid/skaclient_start.c index d78a1e3..15cc3af 100644 --- a/src/libunixonacid/skaclient_start.c +++ b/src/libunixonacid/skaclient_start.c @@ -1,12 +1,13 @@ /* ISC license. */ #include <errno.h> + #include <skalibs/kolbak.h> #include <skalibs/skaclient.h> #include "skaclient-internal.h" int skaclient_start ( - skaclient_t *a, + skaclient *a, char *bufss, size_t bufsn, char *auxbufss, @@ -15,7 +16,7 @@ int skaclient_start ( size_t bufan, char *auxbufas, size_t auxbufan, - kolbak_closure_t *q, + kolbak_closure *q, size_t qlen, char const *path, uint32_t options, @@ -23,11 +24,11 @@ int skaclient_start ( size_t beforelen, char const *after, size_t afterlen, - tain_t const *deadline, - tain_t *stamp) + tain const *deadline, + tain *stamp) { - skaclient_cbdata_t blah ; - unixmessage_t m ; + skaclient_cbdata blah ; + unixmessage m ; 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)) diff --git a/src/libunixonacid/skaclient_start_async.c b/src/libunixonacid/skaclient_start_async.c index 3847ec0..48aecf7 100644 --- a/src/libunixonacid/skaclient_start_async.c +++ b/src/libunixonacid/skaclient_start_async.c @@ -11,7 +11,7 @@ #include "skaclient-internal.h" int skaclient_start_async ( - skaclient_t *a, + skaclient *a, char *bufss, size_t bufsn, char *auxbufss, @@ -20,7 +20,7 @@ int skaclient_start_async ( size_t bufan, char *auxbufas, size_t auxbufan, - kolbak_closure_t *q, + kolbak_closure *q, size_t qlen, char const *path, uint32_t options, @@ -28,7 +28,7 @@ int skaclient_start_async ( size_t beforelen, char const *after, size_t afterlen, - skaclient_cbdata_t *blah) + skaclient_cbdata *blah) { int fd = ipc_stream_nbcoe() ; if (fd < 0) return 0 ; @@ -40,7 +40,7 @@ int skaclient_start_async ( } a->pid = 0 ; a->options = options & ~SKACLIENT_OPTION_WAITPID ; - if (!kolbak_enqueue(&a->kq, (unixmessage_handler_func_t_ref)&skaclient_start_cb, blah)) + if (!kolbak_enqueue(&a->kq, (unixmessage_handler_func_ref)&skaclient_start_cb, blah)) { skaclient_end(a) ; return 0 ; diff --git a/src/libunixonacid/skaclient_start_cb.c b/src/libunixonacid/skaclient_start_cb.c index f385b6b..117faf3 100644 --- a/src/libunixonacid/skaclient_start_cb.c +++ b/src/libunixonacid/skaclient_start_cb.c @@ -8,7 +8,7 @@ #include <skalibs/posixishard.h> #include "skaclient-internal.h" -int skaclient_start_cb (unixmessage_t const *m, skaclient_cbdata_t *blah) +int skaclient_start_cb (unixmessage const *m, skaclient_cbdata *blah) { if (m->len != blah->afterlen || memcmp(m->s, blah->after, m->len) diff --git a/src/libunixonacid/skaclient_startf.c b/src/libunixonacid/skaclient_startf.c index 9d9cbff..bc58baf 100644 --- a/src/libunixonacid/skaclient_startf.c +++ b/src/libunixonacid/skaclient_startf.c @@ -1,12 +1,13 @@ /* ISC license. */ #include <errno.h> + #include <skalibs/kolbak.h> #include <skalibs/skaclient.h> #include "skaclient-internal.h" int skaclient_startf ( - skaclient_t *a, + skaclient *a, char *bufss, size_t bufsn, char *auxbufss, @@ -15,7 +16,7 @@ int skaclient_startf ( size_t bufan, char *auxbufas, size_t auxbufan, - kolbak_closure_t *q, + kolbak_closure *q, size_t qlen, char const *prog, char const *const *argv, @@ -25,11 +26,11 @@ int skaclient_startf ( size_t beforelen, char const *after, size_t afterlen, - tain_t const *deadline, - tain_t *stamp) + tain const *deadline, + tain *stamp) { - skaclient_cbdata_t blah ; - unixmessage_t m ; + skaclient_cbdata blah ; + unixmessage m ; 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)) diff --git a/src/libunixonacid/skaclient_startf_async.c b/src/libunixonacid/skaclient_startf_async.c index 9427ce3..7b2e1da 100644 --- a/src/libunixonacid/skaclient_startf_async.c +++ b/src/libunixonacid/skaclient_startf_async.c @@ -2,13 +2,14 @@ #include <errno.h> #include <signal.h> + #include <skalibs/djbunix.h> #include <skalibs/kolbak.h> #include <skalibs/skaclient.h> #include "skaclient-internal.h" int skaclient_startf_async ( - skaclient_t *a, + skaclient *a, char *bufss, size_t bufsn, char *auxbufss, @@ -17,7 +18,7 @@ int skaclient_startf_async ( size_t bufan, char *auxbufas, size_t auxbufan, - kolbak_closure_t *q, + kolbak_closure *q, size_t qlen, char const *prog, char const *const *argv, @@ -27,7 +28,7 @@ int skaclient_startf_async ( size_t beforelen, char const *after, size_t afterlen, - skaclient_cbdata_t *blah) + skaclient_cbdata *blah) { int fd ; pid_t pid = child_spawn1_socket(prog, argv, envp, &fd) ; @@ -48,7 +49,7 @@ int skaclient_startf_async ( } a->pid = pid ; a->options = options ; - if (!kolbak_enqueue(&a->kq, (unixmessage_handler_func_t_ref)&skaclient_start_cb, blah)) + if (!kolbak_enqueue(&a->kq, (unixmessage_handler_func_ref)&skaclient_start_cb, blah)) { skaclient_end(a) ; return 0 ; diff --git a/src/libunixonacid/skaclient_syncify.c b/src/libunixonacid/skaclient_syncify.c index a0fd30f..8ef01b0 100644 --- a/src/libunixonacid/skaclient_syncify.c +++ b/src/libunixonacid/skaclient_syncify.c @@ -1,9 +1,10 @@ /* ISC license. */ #include <errno.h> + #include <skalibs/skaclient.h> -int skaclient_syncify (skaclient_t *a, tain_t const *deadline, tain_t *stamp) +int skaclient_syncify (skaclient *a, tain const *deadline, tain *stamp) { int r ; if (!skaclient_timed_flush(a, deadline, stamp)) return 0 ; diff --git a/src/libunixonacid/skaclient_zero.c b/src/libunixonacid/skaclient_zero.c index 4bb85b5..e630891 100644 --- a/src/libunixonacid/skaclient_zero.c +++ b/src/libunixonacid/skaclient_zero.c @@ -2,4 +2,4 @@ #include <skalibs/skaclient.h> -skaclient_t const skaclient_zero = SKACLIENT_ZERO ; +skaclient const skaclient_zero = SKACLIENT_ZERO ; diff --git a/src/libunixonacid/textclient_command.c b/src/libunixonacid/textclient_command.c index a0015ac..1c1417e 100644 --- a/src/libunixonacid/textclient_command.c +++ b/src/libunixonacid/textclient_command.c @@ -6,7 +6,7 @@ #include <skalibs/textclient.h> #include <skalibs/posixishard.h> -int textclient_command (textclient_t *a, char const *s, size_t len, tain_t const *deadline, tain_t *stamp) +int textclient_command (textclient *a, char const *s, size_t len, tain const *deadline, tain *stamp) { struct iovec ans ; if (!textclient_exchange(a, s, len, &ans, deadline, stamp)) return 0 ; diff --git a/src/libunixonacid/textclient_commandv.c b/src/libunixonacid/textclient_commandv.c index 267e584..1983a33 100644 --- a/src/libunixonacid/textclient_commandv.c +++ b/src/libunixonacid/textclient_commandv.c @@ -6,7 +6,7 @@ #include <skalibs/textclient.h> #include <skalibs/posixishard.h> -int textclient_commandv (textclient_t *a, struct iovec const *v, unsigned int n, tain_t const *deadline, tain_t *stamp) +int textclient_commandv (textclient *a, struct iovec const *v, unsigned int n, tain const *deadline, tain *stamp) { struct iovec ans ; if (!textclient_exchangev(a, v, n, &ans, deadline, stamp)) return 0 ; diff --git a/src/libunixonacid/textclient_end.c b/src/libunixonacid/textclient_end.c index 1ddf93f..a87a58f 100644 --- a/src/libunixonacid/textclient_end.c +++ b/src/libunixonacid/textclient_end.c @@ -1,11 +1,12 @@ /* ISC license. */ #include <errno.h> + #include <skalibs/djbunix.h> #include <skalibs/textmessage.h> #include <skalibs/textclient.h> -void textclient_end (textclient_t *a) +void textclient_end (textclient *a) { fd_close(textmessage_sender_fd(&a->syncout)) ; if (textmessage_receiver_fd(&a->syncin) != textmessage_sender_fd(&a->syncout)) diff --git a/src/libunixonacid/textclient_server_init.c b/src/libunixonacid/textclient_server_init.c index 27d3a20..09f17ba 100644 --- a/src/libunixonacid/textclient_server_init.c +++ b/src/libunixonacid/textclient_server_init.c @@ -4,7 +4,7 @@ #include <skalibs/djbunix.h> #include <skalibs/textclient.h> -int textclient_server_init (textmessage_receiver_t *in, textmessage_sender_t *syncout, textmessage_sender_t *asyncout, char const *before, size_t beforelen, char const *after, size_t afterlen, tain_t const *deadline, tain_t *stamp) +int textclient_server_init (textmessage_receiver *in, textmessage_sender *syncout, textmessage_sender *asyncout, char const *before, size_t beforelen, char const *after, size_t afterlen, tain const *deadline, tain *stamp) { return getenv(SKALIBS_CHILD_SPAWN_FDS_ENVVAR) ? textclient_server_init_frompipe(in, syncout, asyncout, before, beforelen, after, afterlen, deadline, stamp) : diff --git a/src/libunixonacid/textclient_server_init_frompipe.c b/src/libunixonacid/textclient_server_init_frompipe.c index 515916a..78e07b9 100644 --- a/src/libunixonacid/textclient_server_init_frompipe.c +++ b/src/libunixonacid/textclient_server_init_frompipe.c @@ -12,7 +12,7 @@ #include <skalibs/textclient.h> #include <skalibs/posixishard.h> -int textclient_server_init_frompipe (textmessage_receiver_t *in, textmessage_sender_t *syncout, textmessage_sender_t *asyncout, char const *before, size_t beforelen, char const *after, size_t afterlen, tain_t const *deadline, tain_t *stamp) +int textclient_server_init_frompipe (textmessage_receiver *in, textmessage_sender *syncout, textmessage_sender *asyncout, char const *before, size_t beforelen, char const *after, size_t afterlen, tain const *deadline, tain *stamp) { struct iovec v ; unsigned int asyncfd ; diff --git a/src/libunixonacid/textclient_server_init_fromsocket.c b/src/libunixonacid/textclient_server_init_fromsocket.c index a662cfc..7a146e2 100644 --- a/src/libunixonacid/textclient_server_init_fromsocket.c +++ b/src/libunixonacid/textclient_server_init_fromsocket.c @@ -9,7 +9,7 @@ #include <skalibs/textclient.h> #include <skalibs/posixishard.h> -int textclient_server_init_fromsocket (textmessage_receiver_t *in, textmessage_sender_t *syncout, textmessage_sender_t *asyncout, char const *before, size_t beforelen, char const *after, size_t afterlen, tain_t const *deadline, tain_t *stamp) +int textclient_server_init_fromsocket (textmessage_receiver *in, textmessage_sender *syncout, textmessage_sender *asyncout, char const *before, size_t beforelen, char const *after, size_t afterlen, tain const *deadline, tain *stamp) { struct iovec v ; if (sanitize_read(textmessage_timed_receive(in, &v, deadline, stamp)) <= 0) return 0 ; diff --git a/src/libunixonacid/textclient_start.c b/src/libunixonacid/textclient_start.c index ee2f800..fc087bb 100644 --- a/src/libunixonacid/textclient_start.c +++ b/src/libunixonacid/textclient_start.c @@ -10,7 +10,7 @@ #include <skalibs/textclient.h> #include <skalibs/posixishard.h> -int textclient_start (textclient_t *a, char const *path, uint32_t options, char const *before, size_t beforelen, char const *after, size_t afterlen, tain_t const *deadline, tain_t *stamp) +int textclient_start (textclient *a, char const *path, uint32_t options, char const *before, size_t beforelen, char const *after, size_t afterlen, tain const *deadline, tain *stamp) { struct iovec v ; int fd = ipc_stream_nbcoe() ; diff --git a/src/libunixonacid/textclient_startf.c b/src/libunixonacid/textclient_startf.c index fc871fd..0162d6b 100644 --- a/src/libunixonacid/textclient_startf.c +++ b/src/libunixonacid/textclient_startf.c @@ -10,7 +10,7 @@ #include <skalibs/textclient.h> #include <skalibs/posixishard.h> -int textclient_startf (textclient_t *a, char const *const *argv, char const *const *envp, uint32_t options, char const *before, size_t beforelen, char const *after, size_t afterlen, tain_t const *deadline, tain_t *stamp) +int textclient_startf (textclient *a, char const *const *argv, char const *const *envp, uint32_t options, char const *before, size_t beforelen, char const *after, size_t afterlen, tain const *deadline, tain *stamp) { struct iovec v ; int fd[3] = { 0, 1 } ; diff --git a/src/libunixonacid/textclient_zero.c b/src/libunixonacid/textclient_zero.c index c2897d7..d2b27eb 100644 --- a/src/libunixonacid/textclient_zero.c +++ b/src/libunixonacid/textclient_zero.c @@ -2,4 +2,4 @@ #include <skalibs/textclient.h> -textclient_t const textclient_zero = TEXTCLIENT_ZERO ; +textclient const textclient_zero = TEXTCLIENT_ZERO ; diff --git a/src/libunixonacid/textmessage_create_send_channel.c b/src/libunixonacid/textmessage_create_send_channel.c index 40f7ff7..deeb979 100644 --- a/src/libunixonacid/textmessage_create_send_channel.c +++ b/src/libunixonacid/textmessage_create_send_channel.c @@ -27,7 +27,7 @@ static int sendit (void *p) return ancil_send_fd(fd[0], fd[1], '|') ; } -int textmessage_create_send_channel (int sock, textmessage_sender_t *asyncout, char const *after, size_t afterlen, tain_t const *deadline, tain_t *stamp) +int textmessage_create_send_channel (int sock, textmessage_sender *asyncout, char const *after, size_t afterlen, tain const *deadline, tain *stamp) { int fd[3] = { sock } ; int r ; diff --git a/src/libunixonacid/textmessage_handle.c b/src/libunixonacid/textmessage_handle.c index bec62cb..acde280 100644 --- a/src/libunixonacid/textmessage_handle.c +++ b/src/libunixonacid/textmessage_handle.c @@ -3,7 +3,7 @@ #include <sys/uio.h> #include <skalibs/textmessage.h> -int textmessage_handle (textmessage_receiver_t *tr, textmessage_handler_func_t_ref f, void *p) +int textmessage_handle (textmessage_receiver *tr, textmessage_handler_func_ref f, void *p) { unsigned int count = 0 ; while (count < TEXTMESSAGE_MAXREADS || textmessage_receiver_hasmsginbuf(tr)) diff --git a/src/libunixonacid/textmessage_put.c b/src/libunixonacid/textmessage_put.c index 5b7d944..4e7d924 100644 --- a/src/libunixonacid/textmessage_put.c +++ b/src/libunixonacid/textmessage_put.c @@ -7,7 +7,7 @@ #include <skalibs/bufalloc.h> #include <skalibs/textmessage.h> -int textmessage_put (textmessage_sender_t *ts, char const *s, size_t len) +int textmessage_put (textmessage_sender *ts, char const *s, size_t len) { char pack[4] ; struct iovec v[2] = diff --git a/src/libunixonacid/textmessage_putv.c b/src/libunixonacid/textmessage_putv.c index 759ce84..0e742aa 100644 --- a/src/libunixonacid/textmessage_putv.c +++ b/src/libunixonacid/textmessage_putv.c @@ -8,7 +8,7 @@ #include <skalibs/siovec.h> #include <skalibs/textmessage.h> -int textmessage_putv (textmessage_sender_t *ts, struct iovec const *v, unsigned int n) +int textmessage_putv (textmessage_sender *ts, struct iovec const *v, unsigned int n) { size_t len = siovec_len(v, n) ; char pack[4] ; diff --git a/src/libunixonacid/textmessage_receive.c b/src/libunixonacid/textmessage_receive.c index 1411f9a..c9b8008 100644 --- a/src/libunixonacid/textmessage_receive.c +++ b/src/libunixonacid/textmessage_receive.c @@ -9,7 +9,7 @@ #include <skalibs/stralloc.h> #include <skalibs/textmessage.h> -int textmessage_receive (textmessage_receiver_t *tr, struct iovec *v) +int textmessage_receive (textmessage_receiver *tr, struct iovec *v) { if (tr->indata.len == tr->wanted) { diff --git a/src/libunixonacid/textmessage_receiver_0.c b/src/libunixonacid/textmessage_receiver_0.c index ab883de..28e332a 100644 --- a/src/libunixonacid/textmessage_receiver_0.c +++ b/src/libunixonacid/textmessage_receiver_0.c @@ -6,4 +6,4 @@ #include <skalibs/textmessage.h> static char buf[BUFFER_INSIZE] ; -textmessage_receiver_t textmessage_receiver_0_ = TEXTMESSAGE_RECEIVER_INIT(0, buf, BUFFER_INSIZE, TEXTMESSAGE_MAXLEN) ; +textmessage_receiver textmessage_receiver_0_ = TEXTMESSAGE_RECEIVER_INIT(0, buf, BUFFER_INSIZE, TEXTMESSAGE_MAXLEN) ; diff --git a/src/libunixonacid/textmessage_receiver_free.c b/src/libunixonacid/textmessage_receiver_free.c index 037e23b..fb02989 100644 --- a/src/libunixonacid/textmessage_receiver_free.c +++ b/src/libunixonacid/textmessage_receiver_free.c @@ -3,7 +3,7 @@ #include <skalibs/stralloc.h> #include <skalibs/textmessage.h> -void textmessage_receiver_free (textmessage_receiver_t *ts) +void textmessage_receiver_free (textmessage_receiver *ts) { stralloc_free(&ts->indata) ; *ts = textmessage_receiver_zero ; diff --git a/src/libunixonacid/textmessage_receiver_hasmsginbuf.c b/src/libunixonacid/textmessage_receiver_hasmsginbuf.c index d0cdcc3..e41f520 100644 --- a/src/libunixonacid/textmessage_receiver_hasmsginbuf.c +++ b/src/libunixonacid/textmessage_receiver_hasmsginbuf.c @@ -7,7 +7,7 @@ #include <skalibs/buffer.h> #include <skalibs/textmessage.h> -int textmessage_receiver_hasmsginbuf (textmessage_receiver_t const *tr) +int textmessage_receiver_hasmsginbuf (textmessage_receiver const *tr) { size_t len = buffer_len(&tr->in) ; uint32_t n ; diff --git a/src/libunixonacid/textmessage_receiver_init.c b/src/libunixonacid/textmessage_receiver_init.c index 8a29d68..3085fe8 100644 --- a/src/libunixonacid/textmessage_receiver_init.c +++ b/src/libunixonacid/textmessage_receiver_init.c @@ -4,7 +4,7 @@ #include <skalibs/stralloc.h> #include <skalibs/textmessage.h> -int textmessage_receiver_init (textmessage_receiver_t *tr, int fd, char *buf, size_t buflen, uint32_t max) +int textmessage_receiver_init (textmessage_receiver *tr, int fd, char *buf, size_t buflen, uint32_t max) { if (!buffer_init(&tr->in, &buffer_read, fd, buf, buflen)) return 0 ; tr->indata = stralloc_zero ; diff --git a/src/libunixonacid/textmessage_receiver_zero.c b/src/libunixonacid/textmessage_receiver_zero.c index 1e852e5..aae22f1 100644 --- a/src/libunixonacid/textmessage_receiver_zero.c +++ b/src/libunixonacid/textmessage_receiver_zero.c @@ -2,4 +2,4 @@ #include <skalibs/textmessage.h> -textmessage_receiver_t const textmessage_receiver_zero = TEXTMESSAGE_RECEIVER_ZERO ; +textmessage_receiver const textmessage_receiver_zero = TEXTMESSAGE_RECEIVER_ZERO ; diff --git a/src/libunixonacid/textmessage_recv_channel.c b/src/libunixonacid/textmessage_recv_channel.c index 69adbcf..884821f 100644 --- a/src/libunixonacid/textmessage_recv_channel.c +++ b/src/libunixonacid/textmessage_recv_channel.c @@ -26,7 +26,7 @@ static ssize_t get (void *p) return 1 ; } -int textmessage_recv_channel (int sock, textmessage_receiver_t *asyncin, char *asyncbuf, size_t asyncbufsize, char const *after, size_t afterlen, tain_t const *deadline, tain_t *stamp) +int textmessage_recv_channel (int sock, textmessage_receiver *asyncin, char *asyncbuf, size_t asyncbufsize, char const *after, size_t afterlen, tain const *deadline, tain *stamp) { struct iovec v ; int fd[2] = { sock, -1 } ; diff --git a/src/libunixonacid/textmessage_sender_1.c b/src/libunixonacid/textmessage_sender_1.c index 0be2ae9..0988f2e 100644 --- a/src/libunixonacid/textmessage_sender_1.c +++ b/src/libunixonacid/textmessage_sender_1.c @@ -4,4 +4,4 @@ #include <skalibs/textmessage.h> -textmessage_sender_t textmessage_sender_1_ = TEXTMESSAGE_SENDER_INIT(1) ; +textmessage_sender textmessage_sender_1_ = TEXTMESSAGE_SENDER_INIT(1) ; diff --git a/src/libunixonacid/textmessage_sender_flush.c b/src/libunixonacid/textmessage_sender_flush.c index 53bd407..12476eb 100644 --- a/src/libunixonacid/textmessage_sender_flush.c +++ b/src/libunixonacid/textmessage_sender_flush.c @@ -3,7 +3,7 @@ #include <skalibs/bufalloc.h> #include <skalibs/textmessage.h> -int textmessage_sender_flush (textmessage_sender_t *ts) +int textmessage_sender_flush (textmessage_sender *ts) { return bufalloc_flush(&ts->out) ; } diff --git a/src/libunixonacid/textmessage_sender_getfd.c b/src/libunixonacid/textmessage_sender_getfd.c index 8a6ddf7..9dc3168 100644 --- a/src/libunixonacid/textmessage_sender_getfd.c +++ b/src/libunixonacid/textmessage_sender_getfd.c @@ -3,7 +3,7 @@ #include <skalibs/bufalloc.h> #include <skalibs/textmessage.h> -int textmessage_sender_getfd (textmessage_sender_t const *ts) +int textmessage_sender_getfd (textmessage_sender const *ts) { return bufalloc_fd(&ts->out) ; } diff --git a/src/libunixonacid/textmessage_sender_timed_flush.c b/src/libunixonacid/textmessage_sender_timed_flush.c index 18eddd2..fbe30a6 100644 --- a/src/libunixonacid/textmessage_sender_timed_flush.c +++ b/src/libunixonacid/textmessage_sender_timed_flush.c @@ -4,12 +4,12 @@ #include <skalibs/unix-timed.h> #include <skalibs/textmessage.h> -static int textmessage_sender_isnonempty (textmessage_sender_t *ts) +static int textmessage_sender_isnonempty (textmessage_sender *ts) { return !textmessage_sender_isempty(ts) ; } -int textmessage_sender_timed_flush (textmessage_sender_t *ts, tain_t const *deadline, tain_t *stamp) +int textmessage_sender_timed_flush (textmessage_sender *ts, tain const *deadline, tain *stamp) { - return timed_flush(ts, (initfunc_t_ref)&textmessage_sender_getfd, (initfunc_t_ref)&textmessage_sender_isnonempty, (initfunc_t_ref)&textmessage_sender_flush, deadline, stamp) ; + return timed_flush(ts, (init_func_ref)&textmessage_sender_getfd, (init_func_ref)&textmessage_sender_isnonempty, (init_func_ref)&textmessage_sender_flush, deadline, stamp) ; } diff --git a/src/libunixonacid/textmessage_sender_x.c b/src/libunixonacid/textmessage_sender_x.c index 2f6c557..82e2475 100644 --- a/src/libunixonacid/textmessage_sender_x.c +++ b/src/libunixonacid/textmessage_sender_x.c @@ -4,4 +4,4 @@ #include <skalibs/textmessage.h> -textmessage_sender_t textmessage_sender_x_ = TEXTMESSAGE_SENDER_ZERO ; +textmessage_sender textmessage_sender_x_ = TEXTMESSAGE_SENDER_ZERO ; diff --git a/src/libunixonacid/textmessage_sender_zero.c b/src/libunixonacid/textmessage_sender_zero.c index fbb2921..23687c4 100644 --- a/src/libunixonacid/textmessage_sender_zero.c +++ b/src/libunixonacid/textmessage_sender_zero.c @@ -2,4 +2,4 @@ #include <skalibs/textmessage.h> -textmessage_sender_t const textmessage_sender_zero = TEXTMESSAGE_SENDER_ZERO ; +textmessage_sender const textmessage_sender_zero = TEXTMESSAGE_SENDER_ZERO ; diff --git a/src/libunixonacid/textmessage_timed_handle.c b/src/libunixonacid/textmessage_timed_handle.c index f8cf2dd..161314d 100644 --- a/src/libunixonacid/textmessage_timed_handle.c +++ b/src/libunixonacid/textmessage_timed_handle.c @@ -4,26 +4,26 @@ #include <skalibs/unix-timed.h> #include <skalibs/textmessage.h> -typedef struct textmessage_handler_blah_s textmessage_handler_blah_t, *textmessage_handler_blah_t_ref ; +typedef struct textmessage_handler_blah_s textmessage_handler_blah, *textmessage_handler_blah_ref ; struct textmessage_handler_blah_s { - textmessage_receiver_t *tr ; - textmessage_handler_func_t_ref f ; + textmessage_receiver *tr ; + textmessage_handler_func_ref f ; void *p ; } ; -static int getfd (textmessage_handler_blah_t *blah) +static int getfd (textmessage_handler_blah *blah) { return textmessage_receiver_fd(blah->tr) ; } -static ssize_t get (textmessage_handler_blah_t *blah) +static ssize_t get (textmessage_handler_blah *blah) { return textmessage_handle(blah->tr, blah->f, blah->p) ; } -int textmessage_timed_handle (textmessage_receiver_t *tr, textmessage_handler_func_t_ref f, void *p, tain_t const *deadline, tain_t *stamp) +int textmessage_timed_handle (textmessage_receiver *tr, textmessage_handler_func_ref f, void *p, tain const *deadline, tain *stamp) { - textmessage_handler_blah_t blah = { .tr = tr, .f = f, .p = p } ; - return timed_get(&blah, (initfunc_t_ref)&getfd, (getfunc_t_ref)&get, deadline, stamp) ; + textmessage_handler_blah blah = { .tr = tr, .f = f, .p = p } ; + return timed_get(&blah, (init_func_ref)&getfd, (get_func_ref)&get, deadline, stamp) ; } diff --git a/src/libunixonacid/textmessage_timed_receive.c b/src/libunixonacid/textmessage_timed_receive.c index 5c7a848..fe02080 100644 --- a/src/libunixonacid/textmessage_timed_receive.c +++ b/src/libunixonacid/textmessage_timed_receive.c @@ -1,29 +1,30 @@ /* ISC license. */ #include <sys/uio.h> + #include <skalibs/functypes.h> #include <skalibs/unix-timed.h> #include <skalibs/textmessage.h> -typedef struct textmessage_get_s textmessage_get_t, *textmessage_get_t_ref ; -struct textmessage_get_s +typedef struct textmessage_getter_s textmessage_getter, *textmessage_getter_ref ; +struct textmessage_getter_s { - textmessage_receiver_t *tr ; + textmessage_receiver *tr ; struct iovec *v ; } ; -static int getfd (textmessage_get_t *g) +static int getfd (textmessage_getter *g) { return textmessage_receiver_fd(g->tr) ; } -static ssize_t get (textmessage_get_t *g) +static ssize_t get (textmessage_getter *g) { return textmessage_receive(g->tr, g->v) ; } -int textmessage_timed_receive (textmessage_receiver_t *tr, struct iovec *v, tain_t const *deadline, tain_t *stamp) +int textmessage_timed_receive (textmessage_receiver *tr, struct iovec *v, tain const *deadline, tain *stamp) { - textmessage_get_t g = { .tr = tr, .v = v } ; - return timed_get(&g, (initfunc_t_ref)&getfd, (getfunc_t_ref)&get, deadline, stamp) ; + textmessage_getter g = { .tr = tr, .v = v } ; + return timed_get(&g, (init_func_ref)&getfd, (get_func_ref)&get, deadline, stamp) ; } diff --git a/src/libunixonacid/timed_flush.c b/src/libunixonacid/timed_flush.c index 10367ad..02206f6 100644 --- a/src/libunixonacid/timed_flush.c +++ b/src/libunixonacid/timed_flush.c @@ -5,7 +5,7 @@ #include <skalibs/iopause.h> #include <skalibs/unix-timed.h> -int timed_flush (void *b, initfunc_t_ref getfd, initfunc_t_ref isnonempty, initfunc_t_ref flush, tain_t const *deadline, tain_t *stamp) +int timed_flush (void *b, init_func_ref getfd, init_func_ref isnonempty, init_func_ref flush, tain const *deadline, tain *stamp) { iopause_fd x = { .fd = (*getfd)(b), .events = IOPAUSE_WRITE, .revents = 0 } ; while ((*isnonempty)(b)) diff --git a/src/libunixonacid/timed_get.c b/src/libunixonacid/timed_get.c index ddbfa97..fb751d2 100644 --- a/src/libunixonacid/timed_get.c +++ b/src/libunixonacid/timed_get.c @@ -5,7 +5,7 @@ #include <skalibs/iopause.h> #include <skalibs/unix-timed.h> -ssize_t timed_get (void *b, initfunc_t_ref getfd, getfunc_t_ref get, tain_t const *deadline, tain_t *stamp) +ssize_t timed_get (void *b, init_func_ref getfd, get_func_ref get, tain const *deadline, tain *stamp) { iopause_fd x = { .fd = (*getfd)(b), .events = IOPAUSE_READ, .revents = 0 } ; ssize_t r = (*get)(b) ; diff --git a/src/libunixonacid/timed_getln.c b/src/libunixonacid/timed_getln.c index dda0a9f..0fa1908 100644 --- a/src/libunixonacid/timed_getln.c +++ b/src/libunixonacid/timed_getln.c @@ -25,8 +25,8 @@ static ssize_t get (struct blah_s *blah) return sanitize_read(skagetln(blah->b, blah->sa, blah->sep)) ; } -int timed_getln (buffer *b, stralloc *sa, char sep, tain_t const *deadline, tain_t *stamp) +int timed_getln (buffer *b, stralloc *sa, char sep, tain const *deadline, tain *stamp) { struct blah_s blah = { .b = b, .sa = sa, .sep = sep } ; - return timed_get(&blah, (initfunc_t_ref)&getfd, (getfunc_t_ref)&get, deadline, stamp) ; + return timed_get(&blah, (init_func_ref)&getfd, (get_func_ref)&get, deadline, stamp) ; } diff --git a/src/libunixonacid/timed_getlnmax.c b/src/libunixonacid/timed_getlnmax.c index a054b59..77ba605 100644 --- a/src/libunixonacid/timed_getlnmax.c +++ b/src/libunixonacid/timed_getlnmax.c @@ -26,10 +26,10 @@ static ssize_t get (struct blah_s *blah) return sanitize_read(getlnmax(blah->b, blah->d, blah->max, &blah->w, blah->sep)) ; } -ssize_t timed_getlnmax (buffer *b, char *d, size_t max, size_t *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 const *deadline, tain *stamp) { struct blah_s blah = { .b = b, .d = d, .max = max, .w = *w, .sep = sep } ; - ssize_t r = timed_get(&blah, (initfunc_t_ref)&getfd, (getfunc_t_ref)&get, deadline, stamp) ; + ssize_t r = timed_get(&blah, (init_func_ref)&getfd, (get_func_ref)&get, deadline, stamp) ; *w = blah.w ; return r ; } diff --git a/src/libunixonacid/unixconnection_free.c b/src/libunixonacid/unixconnection_free.c index 52f9027..a10ebe4 100644 --- a/src/libunixonacid/unixconnection_free.c +++ b/src/libunixonacid/unixconnection_free.c @@ -3,7 +3,7 @@ #include <skalibs/unixmessage.h> #include <skalibs/unixconnection.h> -void unixconnection_free (unixconnection_t *io) +void unixconnection_free (unixconnection *io) { unixmessage_sender_free(&io->out) ; unixmessage_receiver_free(&io->in) ; diff --git a/src/libunixonacid/unixconnection_init.c b/src/libunixonacid/unixconnection_init.c index 52ecd44..8ae7508 100644 --- a/src/libunixonacid/unixconnection_init.c +++ b/src/libunixonacid/unixconnection_init.c @@ -3,7 +3,7 @@ #include <skalibs/unixmessage.h> #include <skalibs/unixconnection.h> -void unixconnection_init (unixconnection_t *io, int fdin, int fdout) +void unixconnection_init (unixconnection *io, int fdin, int fdout) { unixconnection_init_withclosecb(io, fdin, fdout, &unixmessage_sender_closecb, 0) ; } diff --git a/src/libunixonacid/unixconnection_init_withclosecb.c b/src/libunixonacid/unixconnection_init_withclosecb.c index b89b3ee..fedc176 100644 --- a/src/libunixonacid/unixconnection_init_withclosecb.c +++ b/src/libunixonacid/unixconnection_init_withclosecb.c @@ -3,7 +3,7 @@ #include <skalibs/unixmessage.h> #include <skalibs/unixconnection.h> -void unixconnection_init_withclosecb (unixconnection_t *io, int fdin, int fdout, unixmessage_sender_closecb_func_t_ref f, void *p) +void unixconnection_init_withclosecb (unixconnection *io, int fdin, int fdout, unixmessage_sender_closecb_func_ref f, void *p) { unixmessage_receiver_init(&io->in, fdin, io->mainbuf, UNIXMESSAGE_BUFSIZE, io->auxbuf, UNIXMESSAGE_AUXBUFSIZE) ; unixmessage_sender_init_withclosecb(&io->out, fdout, f, p) ; diff --git a/src/libunixonacid/unixconnection_zero.c b/src/libunixonacid/unixconnection_zero.c index 9100cac..81143b5 100644 --- a/src/libunixonacid/unixconnection_zero.c +++ b/src/libunixonacid/unixconnection_zero.c @@ -2,4 +2,4 @@ #include <skalibs/unixconnection.h> -unixconnection_t const unixconnection_zero = UNIXCONNECTION_ZERO ; +unixconnection const unixconnection_zero = UNIXCONNECTION_ZERO ; diff --git a/src/libunixonacid/unixmessage_drop.c b/src/libunixonacid/unixmessage_drop.c index bf37df3..d9fc429 100644 --- a/src/libunixonacid/unixmessage_drop.c +++ b/src/libunixonacid/unixmessage_drop.c @@ -3,7 +3,7 @@ #include <skalibs/djbunix.h> #include <skalibs/unixmessage.h> -void unixmessage_drop (unixmessage_t const *m) +void unixmessage_drop (unixmessage const *m) { unsigned int i = m->nfds ; while (i--) fd_close(m->fds[i]) ; diff --git a/src/libunixonacid/unixmessage_handle.c b/src/libunixonacid/unixmessage_handle.c index 487430d..61fc522 100644 --- a/src/libunixonacid/unixmessage_handle.c +++ b/src/libunixonacid/unixmessage_handle.c @@ -2,12 +2,12 @@ #include <skalibs/unixmessage.h> -int unixmessage_handle (unixmessage_receiver_t *b, unixmessage_handler_func_t_ref f, void *p) +int unixmessage_handle (unixmessage_receiver *b, unixmessage_handler_func_ref f, void *p) { unsigned int count = 0 ; while (count < UNIXMESSAGE_MAXREADS || unixmessage_receiver_hasmsginbuf(b)) { - unixmessage_t m ; + unixmessage m ; int r = unixmessage_receive(b, &m) ; if (r < 0) return -1 ; if (!r) break ; diff --git a/src/libunixonacid/unixmessage_put.c b/src/libunixonacid/unixmessage_put.c index 9ce103d..a41c5c0 100644 --- a/src/libunixonacid/unixmessage_put.c +++ b/src/libunixonacid/unixmessage_put.c @@ -11,7 +11,7 @@ #include <skalibs/unixmessage.h> #include <skalibs/posixishard.h> -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) +static inline int copyfds (char *s, int const *fds, unsigned int n, unsigned char const *bits, unixmessage_sender_closecb_func_ref closecb, void *closecbdata) { unsigned int i = 0 ; for (; i < n ; i++) @@ -25,7 +25,7 @@ static inline int copyfds (char *s, int const *fds, unsigned int n, unsigned cha return 1 ; } -static int reserve_and_copy (unixmessage_sender_t *b, size_t len, int const *fds, unsigned int nfds, unsigned char const *bits) +static int reserve_and_copy (unixmessage_sender *b, size_t len, int const *fds, unsigned int nfds, unsigned char const *bits) { disize cur = { .left = b->data.len, .right = genalloc_len(int, &b->fds) } ; if (len > UNIXMESSAGE_MAXSIZE || nfds > UNIXMESSAGE_MAXFDS) @@ -39,7 +39,7 @@ static int reserve_and_copy (unixmessage_sender_t *b, size_t len, int const *fds return genalloc_append(disize, &b->offsets, &cur) ; } -int unixmessage_put_and_close (unixmessage_sender_t *b, unixmessage_t const *m, unsigned char const *bits) +int unixmessage_put_and_close (unixmessage_sender *b, unixmessage const *m, unsigned char const *bits) { if (!reserve_and_copy(b, m->len, m->fds, m->nfds, bits)) return 0 ; memmove(b->data.s + b->data.len, m->s, m->len) ; @@ -47,7 +47,7 @@ int unixmessage_put_and_close (unixmessage_sender_t *b, unixmessage_t const *m, return 1 ; } -int unixmessage_putv_and_close (unixmessage_sender_t *b, unixmessage_v_t const *m, unsigned char const *bits) +int unixmessage_putv_and_close (unixmessage_sender *b, unixmessagev const *m, unsigned char const *bits) { size_t len = siovec_len(m->v, m->vlen) ; if (!reserve_and_copy(b, len, m->fds, m->nfds, bits)) return 0 ; diff --git a/src/libunixonacid/unixmessage_receive.c b/src/libunixonacid/unixmessage_receive.c index b4171f0..c3e1107 100644 --- a/src/libunixonacid/unixmessage_receive.c +++ b/src/libunixonacid/unixmessage_receive.c @@ -36,7 +36,7 @@ static int const awesomeflags = #endif ; -static int unixmessage_receiver_fill (unixmessage_receiver_t *b) +static int unixmessage_receiver_fill (unixmessage_receiver *b) { union aligner_u ancilbuf[1 + CMSG_SPACE(b->auxb.a - 1) / sizeof(union aligner_u)] ; struct iovec iov[2] ; @@ -98,7 +98,7 @@ static int unixmessage_receiver_fill (unixmessage_receiver_t *b) return 1 ; } -int unixmessage_receive (unixmessage_receiver_t *b, unixmessage_t *m) +int unixmessage_receive (unixmessage_receiver *b, unixmessage *m) { if (b->maindata.len == b->mainlen && b->auxdata.len == b->auxlen) { diff --git a/src/libunixonacid/unixmessage_receiver_0.c b/src/libunixonacid/unixmessage_receiver_0.c index 76a537f..0ddddad 100644 --- a/src/libunixonacid/unixmessage_receiver_0.c +++ b/src/libunixonacid/unixmessage_receiver_0.c @@ -7,4 +7,4 @@ static char mainbuf[UNIXMESSAGE_BUFSIZE] ; static char auxbuf[UNIXMESSAGE_AUXBUFSIZE] ; -unixmessage_receiver_t unixmessage_receiver_0_ = UNIXMESSAGE_RECEIVER_INIT(0, mainbuf, UNIXMESSAGE_BUFSIZE, auxbuf, UNIXMESSAGE_AUXBUFSIZE) ; +unixmessage_receiver unixmessage_receiver_0_ = UNIXMESSAGE_RECEIVER_INIT(0, mainbuf, UNIXMESSAGE_BUFSIZE, auxbuf, UNIXMESSAGE_AUXBUFSIZE) ; diff --git a/src/libunixonacid/unixmessage_receiver_free.c b/src/libunixonacid/unixmessage_receiver_free.c index 776509c..29ae58d 100644 --- a/src/libunixonacid/unixmessage_receiver_free.c +++ b/src/libunixonacid/unixmessage_receiver_free.c @@ -6,7 +6,7 @@ #include <skalibs/djbunix.h> #include <skalibs/unixmessage.h> -void unixmessage_receiver_free (unixmessage_receiver_t *b) +void unixmessage_receiver_free (unixmessage_receiver *b) { size_t maindatalen = b->maindata.len ; int h ; diff --git a/src/libunixonacid/unixmessage_receiver_hasmsginbuf.c b/src/libunixonacid/unixmessage_receiver_hasmsginbuf.c index 0a5f7d2..c35b3af 100644 --- a/src/libunixonacid/unixmessage_receiver_hasmsginbuf.c +++ b/src/libunixonacid/unixmessage_receiver_hasmsginbuf.c @@ -7,7 +7,7 @@ #include <skalibs/cbuffer.h> #include <skalibs/unixmessage.h> -int unixmessage_receiver_hasmsginbuf (unixmessage_receiver_t const *b) +int unixmessage_receiver_hasmsginbuf (unixmessage_receiver const *b) { size_t len = cbuffer_len(&b->mainb) ; uint32_t mainlen ; diff --git a/src/libunixonacid/unixmessage_receiver_init.c b/src/libunixonacid/unixmessage_receiver_init.c index 32a514a..e1e9e92 100644 --- a/src/libunixonacid/unixmessage_receiver_init.c +++ b/src/libunixonacid/unixmessage_receiver_init.c @@ -4,7 +4,7 @@ #include <skalibs/stralloc.h> #include <skalibs/unixmessage.h> -int unixmessage_receiver_init (unixmessage_receiver_t *b, int fd, char *mainbuf, size_t mainlen, char *auxbuf, size_t auxlen) +int unixmessage_receiver_init (unixmessage_receiver *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_1.c b/src/libunixonacid/unixmessage_sender_1.c index e01081d..55d199c 100644 --- a/src/libunixonacid/unixmessage_sender_1.c +++ b/src/libunixonacid/unixmessage_sender_1.c @@ -4,4 +4,4 @@ #include <skalibs/unixmessage.h> -unixmessage_sender_t unixmessage_sender_1_ = UNIXMESSAGE_SENDER_INIT(1) ; +unixmessage_sender unixmessage_sender_1_ = UNIXMESSAGE_SENDER_INIT(1) ; diff --git a/src/libunixonacid/unixmessage_sender_flush.c b/src/libunixonacid/unixmessage_sender_flush.c index 96f9112..93bbbd7 100644 --- a/src/libunixonacid/unixmessage_sender_flush.c +++ b/src/libunixonacid/unixmessage_sender_flush.c @@ -30,7 +30,7 @@ union aligner_u XXX: We assume ancillary data is attached to the first byte. */ -int unixmessage_sender_flush (unixmessage_sender_t *b) +int unixmessage_sender_flush (unixmessage_sender *b) { disize last = { .left = b->data.len, .right = genalloc_len(int, &b->fds) } ; disize *offsets = genalloc_s(disize, &b->offsets) ; diff --git a/src/libunixonacid/unixmessage_sender_free.c b/src/libunixonacid/unixmessage_sender_free.c index 4c07952..f01a940 100644 --- a/src/libunixonacid/unixmessage_sender_free.c +++ b/src/libunixonacid/unixmessage_sender_free.c @@ -7,7 +7,7 @@ #include <skalibs/djbunix.h> #include <skalibs/unixmessage.h> -void unixmessage_sender_free (unixmessage_sender_t *b) +void unixmessage_sender_free (unixmessage_sender *b) { size_t n = genalloc_len(int, &b->fds) ; if (n) diff --git a/src/libunixonacid/unixmessage_sender_getfd.c b/src/libunixonacid/unixmessage_sender_getfd.c index 1f130eb..7e1c45e 100644 --- a/src/libunixonacid/unixmessage_sender_getfd.c +++ b/src/libunixonacid/unixmessage_sender_getfd.c @@ -2,7 +2,7 @@ #include <skalibs/unixmessage.h> -int unixmessage_sender_getfd (unixmessage_sender_t const *b) +int unixmessage_sender_getfd (unixmessage_sender const *b) { return b->fd ; } diff --git a/src/libunixonacid/unixmessage_sender_init.c b/src/libunixonacid/unixmessage_sender_init.c index 71a8b3b..0dbd963 100644 --- a/src/libunixonacid/unixmessage_sender_init.c +++ b/src/libunixonacid/unixmessage_sender_init.c @@ -2,7 +2,7 @@ #include <skalibs/unixmessage.h> -void unixmessage_sender_init (unixmessage_sender_t *b, int fd) +void unixmessage_sender_init (unixmessage_sender *b, int fd) { unixmessage_sender_init_withclosecb(b, fd, &unixmessage_sender_closecb, 0) ; } diff --git a/src/libunixonacid/unixmessage_sender_init_withclosecb.c b/src/libunixonacid/unixmessage_sender_init_withclosecb.c index 7d82a8e..25d85e8 100644 --- a/src/libunixonacid/unixmessage_sender_init_withclosecb.c +++ b/src/libunixonacid/unixmessage_sender_init_withclosecb.c @@ -4,7 +4,7 @@ #include <skalibs/genalloc.h> #include <skalibs/unixmessage.h> -void unixmessage_sender_init_withclosecb (unixmessage_sender_t *b, int fd, unixmessage_sender_closecb_func_t_ref f, void *p) +void unixmessage_sender_init_withclosecb (unixmessage_sender *b, int fd, unixmessage_sender_closecb_func_ref f, void *p) { b->fd = fd ; b->data = stralloc_zero ; diff --git a/src/libunixonacid/unixmessage_sender_timed_flush.c b/src/libunixonacid/unixmessage_sender_timed_flush.c index 65b1b7d..90accfe 100644 --- a/src/libunixonacid/unixmessage_sender_timed_flush.c +++ b/src/libunixonacid/unixmessage_sender_timed_flush.c @@ -4,12 +4,12 @@ #include <skalibs/unix-timed.h> #include <skalibs/unixmessage.h> -static int unixmessage_sender_isnonempty (unixmessage_sender_t *b) +static int unixmessage_sender_isnonempty (unixmessage_sender *b) { return !unixmessage_sender_isempty(b) ; } -int unixmessage_sender_timed_flush (unixmessage_sender_t *b, tain_t const *deadline, tain_t *stamp) +int unixmessage_sender_timed_flush (unixmessage_sender *b, tain const *deadline, tain *stamp) { - return timed_flush(b, (initfunc_t_ref)&unixmessage_sender_getfd, (initfunc_t_ref)&unixmessage_sender_isnonempty, (initfunc_t_ref)&unixmessage_sender_flush, deadline, stamp) ; + return timed_flush(b, (init_func_ref)&unixmessage_sender_getfd, (init_func_ref)&unixmessage_sender_isnonempty, (init_func_ref)&unixmessage_sender_flush, deadline, stamp) ; } diff --git a/src/libunixonacid/unixmessage_sender_x.c b/src/libunixonacid/unixmessage_sender_x.c index da8659f..9d3d518 100644 --- a/src/libunixonacid/unixmessage_sender_x.c +++ b/src/libunixonacid/unixmessage_sender_x.c @@ -4,4 +4,4 @@ #include <skalibs/unixmessage.h> -unixmessage_sender_t unixmessage_sender_x_ = UNIXMESSAGE_SENDER_ZERO ; +unixmessage_sender unixmessage_sender_x_ = UNIXMESSAGE_SENDER_ZERO ; diff --git a/src/libunixonacid/unixmessage_sender_zero.c b/src/libunixonacid/unixmessage_sender_zero.c index bda0a9b..b9883c5 100644 --- a/src/libunixonacid/unixmessage_sender_zero.c +++ b/src/libunixonacid/unixmessage_sender_zero.c @@ -2,4 +2,4 @@ #include <skalibs/unixmessage.h> -unixmessage_sender_t const unixmessage_sender_zero = UNIXMESSAGE_SENDER_ZERO ; +unixmessage_sender const unixmessage_sender_zero = UNIXMESSAGE_SENDER_ZERO ; diff --git a/src/libunixonacid/unixmessage_timed_handle.c b/src/libunixonacid/unixmessage_timed_handle.c index dd198e7..570cebf 100644 --- a/src/libunixonacid/unixmessage_timed_handle.c +++ b/src/libunixonacid/unixmessage_timed_handle.c @@ -4,26 +4,26 @@ #include <skalibs/unix-timed.h> #include <skalibs/unixmessage.h> -typedef struct unixmessage_handler_blah_s unixmessage_handler_blah_t, *unixmessage_handler_blah_t_ref ; +typedef struct unixmessage_handler_blah_s unixmessage_handler_blah, *unixmessage_handler_blah_ref ; struct unixmessage_handler_blah_s { - unixmessage_receiver_t *b ; - unixmessage_handler_func_t_ref f ; + unixmessage_receiver *b ; + unixmessage_handler_func_ref f ; void *p ; } ; -static int getfd (unixmessage_handler_blah_t *blah) +static int getfd (unixmessage_handler_blah *blah) { return unixmessage_receiver_fd(blah->b) ; } -static ssize_t get (unixmessage_handler_blah_t *blah) +static ssize_t get (unixmessage_handler_blah *blah) { return unixmessage_handle(blah->b, blah->f, blah->p) ; } -int unixmessage_timed_handle (unixmessage_receiver_t *b, unixmessage_handler_func_t_ref f, void *p, tain_t const *deadline, tain_t *stamp) +int unixmessage_timed_handle (unixmessage_receiver *b, unixmessage_handler_func_ref f, void *p, tain const *deadline, tain *stamp) { - unixmessage_handler_blah_t blah = { .b = b, .f = f, .p = p } ; - return timed_get(&blah, (initfunc_t_ref)&getfd, (getfunc_t_ref)&get, deadline, stamp) ; + unixmessage_handler_blah blah = { .b = b, .f = f, .p = p } ; + return timed_get(&blah, (init_func_ref)&getfd, (get_func_ref)&get, deadline, stamp) ; } diff --git a/src/libunixonacid/unixmessage_timed_receive.c b/src/libunixonacid/unixmessage_timed_receive.c index 08aabb2..b22cfd5 100644 --- a/src/libunixonacid/unixmessage_timed_receive.c +++ b/src/libunixonacid/unixmessage_timed_receive.c @@ -1,29 +1,30 @@ /* ISC license. */ #include <sys/types.h> + #include <skalibs/functypes.h> #include <skalibs/unix-timed.h> #include <skalibs/unixmessage.h> -typedef struct unixmessage_get_s unixmessage_get_t, *unixmessage_get_t_ref ; -struct unixmessage_get_s +typedef struct unixmessage_getter_s unixmessage_getter, *unixmessage_getter_ref ; +struct unixmessage_getter_s { - unixmessage_receiver_t *b ; - unixmessage_t *m ; + unixmessage_receiver *b ; + unixmessage *m ; } ; -static int getfd (unixmessage_get_t *g) +static int getfd (unixmessage_getter *g) { return unixmessage_receiver_fd(g->b) ; } -static ssize_t get (unixmessage_get_t *g) +static ssize_t get (unixmessage_getter *g) { return unixmessage_receive(g->b, g->m) ; } -int unixmessage_timed_receive (unixmessage_receiver_t *b, unixmessage_t *m, tain_t const *deadline, tain_t *stamp) +int unixmessage_timed_receive (unixmessage_receiver *b, unixmessage *m, tain const *deadline, tain *stamp) { - unixmessage_get_t g = { .b = b, .m = m } ; - return timed_get(&g, (initfunc_t_ref)&getfd, (getfunc_t_ref)&get, deadline, stamp) ; + unixmessage_getter g = { .b = b, .m = m } ; + return timed_get(&g, (init_func_ref)&getfd, (get_func_ref)&get, deadline, stamp) ; } diff --git a/src/libunixonacid/unixmessage_unput.c b/src/libunixonacid/unixmessage_unput.c index 3ee2abc..a59f6f3 100644 --- a/src/libunixonacid/unixmessage_unput.c +++ b/src/libunixonacid/unixmessage_unput.c @@ -5,7 +5,7 @@ #include <skalibs/djbunix.h> #include <skalibs/unixmessage.h> -int unixmessage_unput_and_maybe_drop (unixmessage_sender_t *b, int drop) +int unixmessage_unput_and_maybe_drop (unixmessage_sender *b, int drop) { disize *start ; size_t n = genalloc_len(disize, &b->offsets) ; diff --git a/src/libunixonacid/unixmessage_v_zero.c b/src/libunixonacid/unixmessage_v_zero.c deleted file mode 100644 index b4ab13a..0000000 --- a/src/libunixonacid/unixmessage_v_zero.c +++ /dev/null @@ -1,5 +0,0 @@ -/* ISC license. */ - -#include <skalibs/unixmessage.h> - -unixmessage_v_t const unixmessage_v_zero = UNIXMESSAGE_V_ZERO ; diff --git a/src/libunixonacid/unixmessage_zero.c b/src/libunixonacid/unixmessage_zero.c index 4cfb242..02d30c2 100644 --- a/src/libunixonacid/unixmessage_zero.c +++ b/src/libunixonacid/unixmessage_zero.c @@ -2,4 +2,4 @@ #include <skalibs/unixmessage.h> -unixmessage_t const unixmessage_zero = UNIXMESSAGE_ZERO ; +unixmessage const unixmessage_zero = UNIXMESSAGE_ZERO ; diff --git a/src/libunixonacid/unixmessagev_zero.c b/src/libunixonacid/unixmessagev_zero.c new file mode 100644 index 0000000..af9ee3e --- /dev/null +++ b/src/libunixonacid/unixmessagev_zero.c @@ -0,0 +1,5 @@ +/* ISC license. */ + +#include <skalibs/unixmessage.h> + +unixmessagev const unixmessagev_zero = UNIXMESSAGEV_ZERO ; |