From 49d8fa1058aaf23c29e074b2314492ae40d2f557 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Tue, 21 Feb 2017 12:05:07 +0000 Subject: Types change: big pass on libstddjb and libunixonacid libdatastruct still missing, library still not functional --- src/include/skalibs/djbunix.h | 8 ------- src/include/skalibs/env.h | 11 +++++---- src/include/skalibs/envalloc.h | 5 ++-- src/include/skalibs/iobuffer.h | 18 ++++++++------- src/include/skalibs/mininetstring.h | 7 +++--- src/include/skalibs/netstring.h | 3 ++- src/include/skalibs/randomegd.h | 10 -------- src/include/skalibs/rc4.h | 2 ++ src/include/skalibs/sha512.h | 4 ++-- src/include/skalibs/socket.h | 46 ++++++++++++++++++------------------- src/include/skalibs/stralloc.h | 1 - src/include/skalibs/tai.h | 34 +++++++++++++-------------- src/include/skalibs/webipc.h | 12 ++++++---- 13 files changed, 75 insertions(+), 86 deletions(-) delete mode 100644 src/include/skalibs/randomegd.h (limited to 'src/include') diff --git a/src/include/skalibs/djbunix.h b/src/include/skalibs/djbunix.h index 03fd092..af76ec4 100644 --- a/src/include/skalibs/djbunix.h +++ b/src/include/skalibs/djbunix.h @@ -69,12 +69,6 @@ extern int prot_readgroups (char const *, gid_t *, unsigned int) ; extern int prot_grps (char const *) ; extern int prot_setuidgid (char const *) ; -extern long seek_cur (int) ; -extern int seek_set (int, off_t) ; -extern int seek_end (int) ; -extern int seek_trunc (int, off_t) ; -#define seek_begin(fd) (seek_set((fd), 0)) - extern pid_t wait_nointr (int *) ; extern pid_t waitpid_nointr (pid_t, int *, int) ; #define wait_pid(pid, wstat) waitpid_nointr(pid, (wstat), 0) @@ -92,8 +86,6 @@ extern pid_t doublefork (void) ; extern int fd_chdir (int) ; #define absolutepath(sa, s) sarealpath(sa, s) -/* extern char *realpath (char const *, char *) ; */ -extern char *realpath_tmp (char const *, char *, stralloc *) ; extern int sarealpath (stralloc *, char const *) ; extern int sarealpath_tmp (stralloc *, char const *, stralloc *) ; extern int sabasename (stralloc *, char const *, size_t) ; diff --git a/src/include/skalibs/env.h b/src/include/skalibs/env.h index ccb3aac..f0c2dbc 100644 --- a/src/include/skalibs/env.h +++ b/src/include/skalibs/env.h @@ -3,23 +3,24 @@ #ifndef ENV_H #define ENV_H +#include #include #include -extern unsigned int env_len (char const *const *) gccattr_pure ; +extern size_t env_len (char const *const *) gccattr_pure ; extern char const *env_get (char const *) gccattr_pure ; extern char const *env_get2 (char const *const *, char const *) gccattr_pure ; extern char const *ucspi_get (char const *) gccattr_pure ; extern int env_addmodif (stralloc *, char const *, char const *) ; -extern int env_make (char const **, unsigned int, char const *, unsigned int) ; -extern unsigned int env_merge (char const **, unsigned int, char const *const *, unsigned int, char const *, unsigned int) ; -extern int env_string (stralloc *, char const *const *, unsigned int) ; +extern int env_make (char const **, size_t, char const *, size_t) ; +extern size_t env_merge (char const **, size_t, char const *const *, size_t, char const *, size_t) ; +extern int env_string (stralloc *, char const *const *, size_t) ; #define SKALIBS_ENVDIR_VERBATIM 0x01 #define SKALIBS_ENVDIR_NOCHOMP 0x02 extern int envdir_internal (char const *, stralloc *, unsigned int, char) ; #define envdir(path, sa) envdir_internal(path, (sa), 0, '\n') -#define envdir_leaveblanks(path, sa) envdir_internal(path, (sa), SKALIBS_ENVDIR_NOCHOMP, '\n') +#define envdir_chomp(path, sa) envdir_internal(path, (sa), SKALIBS_ENVDIR_NOCHOMP, '\n') #define envdir_verbatim_chomp(path, sa) envdir_internal(path, (sa), SKALIBS_ENVDIR_VERBATIM, '\n') #define envdir_verbatim(path, sa) envdir_internal(path, (sa), SKALIBS_ENVDIR_VERBATIM|SKALIBS_ENVDIR_NOCHOMP, '\n') diff --git a/src/include/skalibs/envalloc.h b/src/include/skalibs/envalloc.h index 1ebcd6b..aba6dca 100644 --- a/src/include/skalibs/envalloc.h +++ b/src/include/skalibs/envalloc.h @@ -3,13 +3,14 @@ #ifndef ENVALLOC_H #define ENVALLOC_H +#include #include #define ENVALLOC_ZERO GENALLOC_ZERO -extern int envalloc_make (genalloc *, unsigned int, char const *, unsigned int) ; +extern int envalloc_make (genalloc *, size_t, char const *, size_t) ; extern int envalloc_uniq (genalloc *, char) ; -extern int envalloc_merge (genalloc *, char const *const *, unsigned int, char const *, unsigned int) ; +extern int envalloc_merge (genalloc *, char const *const *, size_t, char const *, size_t) ; extern int envalloc_0 (genalloc *) ; #endif diff --git a/src/include/skalibs/iobuffer.h b/src/include/skalibs/iobuffer.h index b6abd2d..84a8b6d 100644 --- a/src/include/skalibs/iobuffer.h +++ b/src/include/skalibs/iobuffer.h @@ -7,6 +7,7 @@ /* iobufferu */ +#include #include #include @@ -20,7 +21,7 @@ struct iobufferu_s } ; extern int iobufferu_init (iobufferu *, int, int) ; -extern int iobufferu_fill (iobufferu *) ; +extern ssize_t iobufferu_fill (iobufferu *) ; extern int iobufferu_flush (iobufferu *) ; extern void iobufferu_finish (iobufferu *) ; @@ -50,17 +51,18 @@ struct iobufferk_s unsigned int nb : 2 ; } ; -typedef int iobufferk_io_func_t (iobufferk *) ; -typedef iobufferk_io_func_t *iobufferk_io_func_t_ref ; +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 ; -extern iobufferk_io_func_t iobufferk_nosys ; -extern iobufferk_io_func_t iobufferk_isworking ; +extern iobufferk_output_func_t iobufferk_isworking ; extern int iobufferk_init (iobufferk *, int, int) ; -extern iobufferk_io_func_t_ref const iobufferk_fill_f[4] ; -extern iobufferk_io_func_t_ref const iobufferk_flush_f[4] ; +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] ; #define iobufferk_fill(k) (*iobufferk_fill_f[(k)->type])(k) @@ -99,7 +101,7 @@ extern int iobuffer_kfromu (iobufferk *, iobufferu *) ; extern int iobuffer_salvage (iobuffer *) ; extern int iobuffer_init (iobuffer *, int, int) ; -extern int iobuffer_fill (iobuffer *) ; +extern ssize_t iobuffer_fill (iobuffer *) ; extern int iobuffer_flush (iobuffer *) ; #define iobuffer_finish(b) ((b)->isk ? iobufferk_finish(&(b)->x.k) : iobufferu_finish(&(b)->x.u)) diff --git a/src/include/skalibs/mininetstring.h b/src/include/skalibs/mininetstring.h index c275fb2..1997b18 100644 --- a/src/include/skalibs/mininetstring.h +++ b/src/include/skalibs/mininetstring.h @@ -3,11 +3,10 @@ #ifndef MININETSTRING_H #define MININETSTRING_H -#include -#include +#include #include -extern int mininetstring_read (int, stralloc *, uint32 *) ; -extern int mininetstring_write (int, char const *, uint16, uint32 *) ; +extern int mininetstring_read (int, stralloc *, uint32_t *) ; +extern int mininetstring_write (int, char const *, uint16_t, uint32_t *) ; #endif diff --git a/src/include/skalibs/netstring.h b/src/include/skalibs/netstring.h index 107e796..941011a 100644 --- a/src/include/skalibs/netstring.h +++ b/src/include/skalibs/netstring.h @@ -5,11 +5,12 @@ #include #include +#include #include #include extern int netstring_appendb (stralloc *, char const *, size_t) ; -#define netstring_appends(sa, s) netstring_appendb((sa), (s), str_len(s)) +#define netstring_appends(sa, s) netstring_appendb((sa), (s), strlen(s)) #define netstring_append(to, from) netstring_appendb((to), (from)->s, (from)->len) extern int netstring_appendv (stralloc *, struct iovec const *, unsigned int) ; diff --git a/src/include/skalibs/randomegd.h b/src/include/skalibs/randomegd.h deleted file mode 100644 index 28d4faa..0000000 --- a/src/include/skalibs/randomegd.h +++ /dev/null @@ -1,10 +0,0 @@ -/* ISC license. */ - -#ifndef RANDOMEGD_H -#define RANDOMEGD_H - -extern int randomegd_open (char const *) ; -extern unsigned int randomegd_readb (int, char *, unsigned int) ; -extern unsigned int randomegd_readnb (int, char *, unsigned int) ; - -#endif diff --git a/src/include/skalibs/rc4.h b/src/include/skalibs/rc4.h index 44ce20b..c4fde53 100644 --- a/src/include/skalibs/rc4.h +++ b/src/include/skalibs/rc4.h @@ -3,6 +3,8 @@ #ifndef RC4_H #define RC4_H +#include + #define RC4_THROWAWAY 128 typedef struct RC4Schedule RC4Schedule, *RC4Schedule_ref ; diff --git a/src/include/skalibs/sha512.h b/src/include/skalibs/sha512.h index 9d098be..12ddbcb 100644 --- a/src/include/skalibs/sha512.h +++ b/src/include/skalibs/sha512.h @@ -9,8 +9,8 @@ typedef struct SHA512Schedule_s SHA512Schedule, *SHA512Schedule_ref ; struct SHA512Schedule_s { - uint64 len ; - uint64 h[8] ; + uint64_t len ; + uint64_t h[8] ; unsigned char buf[128] ; } ; diff --git a/src/include/skalibs/socket.h b/src/include/skalibs/socket.h index 91be2f5..11ad1db 100644 --- a/src/include/skalibs/socket.h +++ b/src/include/skalibs/socket.h @@ -3,14 +3,14 @@ #ifndef SOCKET_H #define SOCKET_H +#include +#include #include -#include -#include #include #include #include -typedef int socket_io_func_t (int, char *, unsigned int, char *, uint16 *) ; +typedef ssize_t socket_io_func_t (int, char *, size_t, char *, uint16_t *) ; typedef socket_io_func_t *socket_io_func_t_ref ; @@ -58,47 +58,47 @@ extern int socket_udp6_internal (unsigned int) ; extern int socket_waitconn (int, tain_t const *, tain_t *) ; #define socket_waitconn_g(fd, deadline) socket_waitconn(fd, (deadline), &STAMP) -extern int socket_deadlineconnstamp4 (int, char const *, uint16, tain_t const *, tain_t *) ; +extern int socket_deadlineconnstamp4 (int, char const *, uint16_t, tain_t const *, tain_t *) ; #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, uint16, tain_t const *, tain_t *) ; +extern int socket_deadlineconnstamp4_u32 (int, uint32_t, uint16_t, tain_t const *, tain_t *) ; #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, unsigned int) ; -extern int socket_connect4 (int, char const *, uint16) ; -extern int socket_connect4_u32 (int, uint32, uint16) ; +extern int socket_timeoutconn (int, char const *, uint16_t, unsigned int) ; +extern int socket_connect4 (int, char const *, uint16_t) ; +extern int socket_connect4_u32 (int, uint32_t, uint16_t) ; extern int socket_connected (int) gccattr_const ; -extern int socket_bind4 (int, char const *, uint16) ; -extern int socket_bind4_reuse (int, char const *, uint16) ; +extern int socket_bind4 (int, char const *, uint16_t) ; +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) ; -extern int socket_deadlineconnstamp6 (int, char const *, uint16, tain_t const *, tain_t *) ; +extern int socket_connect6 (int, char const *, uint16_t) ; +extern int socket_deadlineconnstamp6 (int, char const *, uint16_t, tain_t const *, tain_t *) ; #define socket_deadlineconnstamp6_g(fd, ip6, port, deadline) socket_deadlineconnstamp6(fd, ip6, port, (deadline), &STAMP) -extern int socket_bind6 (int, char const *, uint16) ; -extern int socket_bind6_reuse (int, char const *, uint16) ; +extern int socket_bind6 (int, char const *, uint16_t) ; +extern int socket_bind6_reuse (int, char const *, uint16_t) ; #define socket_accept4(s, ip, port) socket_accept4_internal(s, ip, (port), 0) #define socket_accept4_nb(s, ip, port) socket_accept4_internal(s, ip, (port), DJBUNIX_FLAG_NB) #define socket_accept4_coe(s, ip, port) socket_accept4_internal(s, ip, (port), DJBUNIX_FLAG_COE) #define socket_accept4_nbcoe(s, ip, port) socket_accept4_internal(s, ip, (port), DJBUNIX_FLAG_NB|DJBUNIX_FLAG_COE) -extern int socket_accept4_internal (int, char *, uint16 *, unsigned int) ; +extern int socket_accept4_internal (int, char *, uint16_t *, unsigned int) ; extern socket_io_func_t socket_recv4 ; -extern int socket_send4 (int, char const *, unsigned int, char const *, uint16) ; +extern ssize_t socket_send4 (int, char const *, size_t, char const *, uint16_t) ; extern socket_io_func_t socket_ioloop_send4 ; -extern int socket_local4 (int, char *, uint16 *) ; -extern int socket_remote4 (int, char *, uint16 *) ; +extern int socket_local4 (int, char *, uint16_t *) ; +extern int socket_remote4 (int, char *, uint16_t *) ; #define socket_accept6(s, ip6, port) socket_accept6_internal(s, ip6, (port), 0) #define socket_accept6_nb(s, ip6, port) socket_accept6_internal(s, ip6, (port), DJBUNIX_FLAG_NB) #define socket_accept6_coe(s, ip6, port) socket_accept6_internal(s, ip6, (port), DJBUNIX_FLAG_COE) #define socket_accept6_nbcoe(s, ip6, port) socket_accept6_internal(s, ip6, (port), DJBUNIX_FLAG_NB|DJBUNIX_FLAG_COE) -extern int socket_accept6_internal (int, char *, uint16 *, unsigned int) ; +extern int socket_accept6_internal (int, char *, uint16_t *, unsigned int) ; extern socket_io_func_t socket_recv6 ; -extern int socket_send6 (int, char const *, unsigned int, char const *, uint16) ; +extern ssize_t socket_send6 (int, char const *, size_t, char const *, uint16_t) ; extern socket_io_func_t socket_ioloop_send6 ; -extern int socket_local6 (int, char *, uint16 *) ; -extern int socket_remote6 (int, char *, uint16 *) ; +extern int socket_local6 (int, char *, uint16_t *) ; +extern int socket_remote6 (int, char *, uint16_t *) ; extern int socket_ipoptionskill (int) ; extern int socket_tcpnodelay (int) ; @@ -107,7 +107,7 @@ extern void socket_tryreservein (int, unsigned int) ; /* Timed send and recv operations (for dgram sockets) */ -extern int socket_ioloop (int, char *, unsigned int, char *, uint16 *, 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_t_ref, int, tain_t const *, tain_t *) ; #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/stralloc.h b/src/include/skalibs/stralloc.h index 2ec4c23..c94547f 100644 --- a/src/include/skalibs/stralloc.h +++ b/src/include/skalibs/stralloc.h @@ -3,7 +3,6 @@ #ifndef STRALLOC_H #define STRALLOC_H -#include #include #include diff --git a/src/include/skalibs/tai.h b/src/include/skalibs/tai.h index 64e81cf..6ff8be7 100644 --- a/src/include/skalibs/tai.h +++ b/src/include/skalibs/tai.h @@ -4,41 +4,41 @@ #define TAI_H #include +#include #include #include #include -#include #include typedef struct tai_s tai_t, *tai_t_ref ; struct tai_s { - uint64 x ; + uint64_t x ; } ; #define TAI_ZERO { .x = 0 } -#define TAI_MAGIC ((uint64)4611686018427387904ULL) +#define TAI_MAGIC ((uint64_t)4611686018427387904ULL) #define TAI_EPOCH { .x = TAI_MAGIC + 10UL } -#define TAI_INFINITE_RELATIVE { .x = (uint64)1 << 60 } -#define TAI_INFINITE { .x = TAI_MAGIC + ((uint64)1 << 61) } +#define TAI_INFINITE_RELATIVE { .x = (uint64_t)1 << 60 } +#define TAI_INFINITE { .x = TAI_MAGIC + ((uint64_t)1 << 61) } #define tai_sec(t) ((t)->x) -extern int tai_u64 (tai_t *, uint64) ; +extern int tai_u64 (tai_t *, uint64_t) ; #define tai_unix(t, u) tai_u64(t, (TAI_MAGIC + (u))) -#define tai_uint(t, u) tai_u64(t, (uint64)(u)) +#define tai_uint(t, u) tai_u64(t, (uint64_t)(u)) extern int tai_now (tai_t *) ; -#define tai_relative_from_time(t, u) ((t)->x = (uint64)(u), 1) +#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)(u) + TAI_MAGIC) +#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 tai_from_sysclock (tai_t *, uint64) ; -extern int sysclock_from_tai (uint64 *, tai_t const *) ; +extern int tai_from_sysclock (tai_t *, uint64_t) ; +extern int sysclock_from_tai (uint64_t *, tai_t const *) ; #define tai_approx(t) ((double)(tai_sec(t))) @@ -56,7 +56,7 @@ typedef struct tain_s tain_t, *tain_t_ref ; struct tain_s { tai_t sec ; - uint32 nano ; /* 0..999999999U */ + uint32_t nano ; /* 0..999999999U */ } ; #define TAIN_ZERO { .sec = TAI_ZERO, .nano = 0 } @@ -125,19 +125,19 @@ extern void tain_pack_little (char *, tain_t const *) ; extern void tain_unpack_little (char const *, tain_t *) ; #define TAIN_FMT 25 -extern unsigned int tain_fmt (char *, tain_t const *) ; -extern unsigned int tain_scan (char const *, tain_t *) ; +extern size_t tain_fmt (char *, tain_t const *) ; +extern size_t tain_scan (char const *, tain_t *) ; #define TAIN_FMTFRAC 19 -extern unsigned int tain_fmtfrac (char *, tain_t const *) ; +extern size_t tain_fmtfrac (char *, tain_t 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 *) ; #define TIMESTAMP (1 + (TAIN_PACK << 1)) -extern unsigned int timestamp_fmt (char *, tain_t const *) ; -extern unsigned int timestamp_scan (char const *, tain_t *) ; +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 int timestamp (char *) ; #define timestamp_g(s) timestamp_fmt((s), &STAMP) diff --git a/src/include/skalibs/webipc.h b/src/include/skalibs/webipc.h index 6b2c1fe..0ddd084 100644 --- a/src/include/skalibs/webipc.h +++ b/src/include/skalibs/webipc.h @@ -12,6 +12,8 @@ #define IPCPATH_MAX 107 +#include +#include #include #include @@ -44,17 +46,17 @@ extern int ipc_listen (int, int) ; #define ipc_accept_nb(s, path, len, trunc) ipc_accept_internal(s, path, len, (trunc), DJBUNIX_FLAG_NB) #define ipc_accept_coe(s, path, len, trunc) ipc_accept_internal(s, path, len, (trunc), DJBUNIX_FLAG_COE) #define ipc_accept_nbcoe(s, path, len, trunc) ipc_accept_internal(s, path, len, (trunc), DJBUNIX_FLAG_NB|DJBUNIX_FLAG_COE) -extern int ipc_accept_internal (int, char *, unsigned int, int *, unsigned int) ; +extern int ipc_accept_internal (int, char *, size_t, int *, unsigned int) ; -extern int ipc_eid (int, unsigned int *, unsigned int *) ; -extern int ipc_local (int, char *, unsigned int, int *) ; +#define ipc_eid getpeereid +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 *) ; #define ipc_timed_connect_g(fd, path, deadline) ipc_timed_connect(fd, path, (deadline), &STAMP) -extern int ipc_send (int, char const *, unsigned int, char const *) ; -extern int ipc_recv (int, char *, unsigned int, char *) ; +extern ssize_t ipc_send (int, char const *, size_t, char const *) ; +extern ssize_t ipc_recv (int, char *, size_t, char *) ; #endif -- cgit v1.2.3