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/include | |
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/include')
68 files changed, 539 insertions, 664 deletions
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> |