diff options
Diffstat (limited to 'src')
203 files changed, 928 insertions, 1366 deletions
diff --git a/src/headers/error-header b/src/headers/error-header index b891b6b..af294e2 100644 --- a/src/headers/error-header +++ b/src/headers/error-header @@ -4,9 +4,9 @@ #define ERROR_H #include <errno.h> +#include <string.h> #include <skalibs/gccattributes.h> -extern char const *error_str (int) gccattr_const ; +#define error_str(e) ((char const *)strerror(e)) extern int error_temp (int) gccattr_const ; - #define error_isagain(e) (((e) == EAGAIN) || ((e) == EWOULDBLOCK)) diff --git a/src/include/skalibs/bufalloc.h b/src/include/skalibs/bufalloc.h index 838ab02..46b4f84 100644 --- a/src/include/skalibs/bufalloc.h +++ b/src/include/skalibs/bufalloc.h @@ -13,12 +13,12 @@ struct bufalloc stralloc x ; size_t p ; int fd ; - int (*op) (int, char const *, unsigned int) ; + ssize_t (*op) (int, char const *, size_t) ; } ; #define BUFALLOC_ZERO { .x = STRALLOC_ZERO, .p = 0, .fd = -1, .op = 0 } #define BUFALLOC_INIT(f, d) { .x = STRALLOC_ZERO, .p = 0, .fd = (d), .op = (f) } -extern void bufalloc_init (bufalloc *, int (*)(int, char const *, size_t), int) ; +extern void bufalloc_init (bufalloc *, ssize_t (*)(int, char const *, size_t), 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 0c7866a..18db87e 100644 --- a/src/include/skalibs/buffer.h +++ b/src/include/skalibs/buffer.h @@ -3,12 +3,13 @@ #ifndef BUFFER_H #define BUFFER_H +#include <sys/types.h> +#include <sys/uio.h> +#include <string.h> #include <skalibs/gccattributes.h> #include <skalibs/allreadwrite.h> -#include <skalibs/bytestr.h> #include <skalibs/cbuffer.h> #include <skalibs/functypes.h> -#include <skalibs/siovec.h> typedef struct buffer_s buffer, buffer_t, *buffer_ref, *buffer_t_ref ; struct buffer_s @@ -32,7 +33,7 @@ struct buffer_s #define BUFFER_OUTSIZE_SMALL 512 #define BUFFER_INIT(f, d, buf, len) { .op = (f), .fd = (d), .c = CBUFFER_INIT(buf, len) } -extern int buffer_init (buffer *, iovfunc_t_ref, int, char *, unsigned int) ; +extern int buffer_init (buffer *, iovfunc_t_ref, int, char *, size_t) ; /* Writing */ @@ -41,27 +42,27 @@ extern int buffer_flush (buffer *) ; #define buffer_putnoflush(b, s, len) cbuffer_put(&(b)->c, s, len) #define buffer_putvnoflush(b, v, n) cbuffer_putv(&(b)->c, v, n) -extern int buffer_putsnoflush (buffer *, char const *) ; +extern size_t buffer_putsnoflush (buffer *, char const *) ; -extern int buffer_putallnoflush (buffer *, char const *, unsigned int) ; -extern int buffer_putvallnoflush (buffer *, siovec_t const *, unsigned int) ; +extern int buffer_putallnoflush (buffer *, char const *, size_t) ; +extern int buffer_putvallnoflush (buffer *, struct iovec const *, unsigned int) ; extern int buffer_putsallnoflush (buffer *, char const *) ; -extern int buffer_putall (buffer *, char const *, unsigned int, unsigned int *) ; -extern int buffer_putvall (buffer *, siovec_t const *, unsigned int, unsigned int *) ; -extern int buffer_putsall (buffer *, char const *, unsigned int *) ; +extern int buffer_putall (buffer *, char const *, size_t, size_t *) ; +extern int buffer_putvall (buffer *, struct iovec const *, unsigned int, size_t *) ; +extern int buffer_putsall (buffer *, char const *, size_t *) ; #define buffer_putallflush(b, s, len, w) (buffer_putall(b, s, len, w) && buffer_flush(b)) #define buffer_putvallflush(b, v, n, w) (buffer_putvall(b, v, n, w) && buffer_flush(b)) -extern int buffer_putsallflush (buffer *, char const *, unsigned int *) ; +extern int buffer_putsallflush (buffer *, char const *, size_t *) ; -extern int buffer_put (buffer *, char const *, unsigned int) ; -extern int buffer_putv (buffer *, siovec_t const *, unsigned int) ; -extern int buffer_puts (buffer *, char const *) ; +extern ssize_t buffer_put (buffer *, char const *, size_t) ; +extern ssize_t buffer_putv (buffer *, struct iovec const *, unsigned int) ; +extern ssize_t buffer_puts (buffer *, char const *) ; -extern int buffer_putflush (buffer *, char const *, unsigned int) ; -extern int buffer_putvflush (buffer *, siovec_t const *, unsigned int) ; -extern int buffer_putsflush (buffer *, char const *) ; +extern ssize_t buffer_putflush (buffer *, char const *, size_t) ; +extern ssize_t buffer_putvflush (buffer *, struct iovec const *, unsigned int) ; +extern ssize_t buffer_putsflush (buffer *, char const *) ; #define buffer_unput(b, n) cbuffer_unput(&(b)->c, n) #define buffer_wpeek(b, v) cbuffer_wpeek(&(b)->c, v) @@ -70,19 +71,19 @@ extern int buffer_putsflush (buffer *, char const *) ; /* Reading */ -extern int buffer_fill (buffer *) ; +extern ssize_t buffer_fill (buffer *) ; #define buffer_getnofill(b, s, len) cbuffer_get(&(b)->c, s, len) #define buffer_getvnofill(b, v, n) cbuffer_getv(&(b)->c, v, n) -extern int buffer_getallnofill (buffer *, char *, unsigned int) ; -extern int buffer_getvallnofill (buffer *, siovec_t const *, unsigned int) ; +extern int buffer_getallnofill (buffer *, char *, size_t) ; +extern int buffer_getvallnofill (buffer *, struct iovec const *, unsigned int) ; -extern int buffer_getall (buffer *, char *, unsigned int, unsigned int *) ; -extern int buffer_getvall (buffer *, siovec_t const *, unsigned int, unsigned int *) ; +extern int buffer_getall (buffer *, char *, size_t, size_t *) ; +extern int buffer_getvall (buffer *, struct iovec const *, unsigned int, size_t *) ; -extern int buffer_get (buffer *, char *, unsigned int) ; -extern int buffer_getv (buffer *, siovec_t const *, unsigned int) ; +extern ssize_t buffer_get (buffer *, char *, size_t) ; +extern ssize_t buffer_getv (buffer *, struct iovec const *, unsigned int) ; #define buffer_unget(b, n) cbuffer_unget(&(b)->c, n) #define buffer_rpeek(b, n) cbuffer_rpeek(&(b)->c, n) @@ -92,7 +93,7 @@ extern int buffer_getv (buffer *, siovec_t const *, unsigned int) ; /* Utility */ #define buffer_len(b) cbuffer_len(&(b)->c) -extern unsigned int buffer_getlen (buffer const *) gccattr_pure ; +extern size_t buffer_getlen (buffer const *) gccattr_pure ; #define buffer_available(b) cbuffer_available(&(b)->c) #define buffer_isempty(b) cbuffer_isempty(&(b)->c) #define buffer_isfull(b) cbuffer_isfull(&(b)->c) @@ -104,8 +105,8 @@ extern int buffer_getfd (buffer const *) gccattr_pure ; /* Globals */ -#define buffer_read fd_readsv -#define buffer_write fd_writesv +#define buffer_read fd_readv +#define buffer_write fd_writev extern iovfunc_t buffer_flush1read ; extern buffer buffer_0_ ; diff --git a/src/include/skalibs/bytestr.h b/src/include/skalibs/bytestr.h index 79768a8..25f05d3 100644 --- a/src/include/skalibs/bytestr.h +++ b/src/include/skalibs/bytestr.h @@ -37,7 +37,7 @@ extern size_t byte_chr (char const *, size_t, int) gccattr_pure ; extern size_t byte_rchr (char const *, size_t, int) gccattr_pure ; extern size_t byte_in (char const *, size_t, char const *, size_t) gccattr_pure ; #define byte_equal(s, n, t) (!byte_diff((s), (n), (t))) -extern uint64_t byte_count (char const *, size_t, char) gccattr_pure ; +extern size_t byte_count (char const *, size_t, char) gccattr_pure ; #define str_diffb(a, n, b) str_diffn(a, (b), n) extern size_t str_chr (char const *, int) gccattr_pure ; diff --git a/src/include/skalibs/cbuffer.h b/src/include/skalibs/cbuffer.h index a80e3af..19b3078 100644 --- a/src/include/skalibs/cbuffer.h +++ b/src/include/skalibs/cbuffer.h @@ -3,18 +3,18 @@ #ifndef CBUFFER_H #define CBUFFER_H +#include <sys/types.h> +#include <sys/uio.h> +#include <string.h> #include <skalibs/gccattributes.h> -#include <skalibs/bytestr.h> -#include <skalibs/diuint.h> -#include <skalibs/siovec.h> typedef struct cbuffer_s cbuffer_t, *cbuffer_t_ref ; struct cbuffer_s { char *x ; - unsigned int a ; /* total length */ - unsigned int p ; /* head */ - unsigned int n ; /* tail */ + size_t a ; /* total length */ + size_t p ; /* head */ + size_t n ; /* tail */ } ; #define CBUFFER_ZERO { .x = 0, .a = 0, .p = 0, .n = 0 } @@ -24,38 +24,38 @@ struct cbuffer_s */ #define CBUFFER_INIT(buf, len) { .x = (buf), .a = (len), .p = 0, .n = 0 } -extern int cbuffer_init (cbuffer_t *, char *, unsigned int) ; +extern int cbuffer_init (cbuffer_t *, char *, size_t) ; /* Writing */ -extern unsigned int cbuffer_put (cbuffer_t *, char const *, unsigned int) ; -extern unsigned int cbuffer_putv (cbuffer_t *, siovec_t const *, unsigned int) ; -#define cbuffer_puts(b, s) cbuffer_put(b, (s), str_len(s)) +extern size_t cbuffer_put (cbuffer_t *, char const *, size_t) ; +extern size_t cbuffer_putv (cbuffer_t *, 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 unsigned int cbuffer_unput (cbuffer_t *, unsigned int) ; -extern void cbuffer_wpeek (cbuffer_t *, siovec_t *) ; +extern size_t cbuffer_unput (cbuffer_t *, size_t) ; +extern void cbuffer_wpeek (cbuffer_t *, struct iovec *) ; #define cbuffer_WSEEK(b, w) ((b)->n = ((b)->n + (w)) % (b)->a, w) -extern unsigned int cbuffer_wseek (cbuffer_t *, unsigned int) ; +extern size_t cbuffer_wseek (cbuffer_t *, size_t) ; /* Reading */ -extern unsigned int cbuffer_get (cbuffer_t *, char *, unsigned int) ; -extern unsigned int cbuffer_getv (cbuffer_t *, siovec_t const *, unsigned int) ; +extern size_t cbuffer_get (cbuffer_t *, char *, size_t) ; +extern size_t cbuffer_getv (cbuffer_t *, struct iovec const *, unsigned int) ; #define cbuffer_UNGET(b, n) ((b)->p = ((b)->a + (b)->p - n) % (b)->a, n) ; -extern unsigned int cbuffer_unget (cbuffer_t *, unsigned int) ; -extern void cbuffer_rpeek (cbuffer_t *, siovec_t *) ; +extern size_t cbuffer_unget (cbuffer_t *, size_t) ; +extern void cbuffer_rpeek (cbuffer_t *, struct iovec *) ; #define cbuffer_RSEEK(b, n) ((b)->p = ((b)->p + (n)) % (b)->a, n) -extern unsigned int cbuffer_rseek (cbuffer_t *, unsigned int) ; +extern size_t cbuffer_rseek (cbuffer_t *, size_t) ; /* Utility */ -#define cbuffer_len(b) ((unsigned int)(((b)->a - (b)->p + (b)->n) % (b)->a)) -#define cbuffer_available(b) ((unsigned int)(((b)->a - (b)->n + (b)->p - 1) % (b)->a)) +#define cbuffer_len(b) ((size_t)(((b)->a - (b)->p + (b)->n) % (b)->a)) +#define cbuffer_available(b) ((size_t)(((b)->a - (b)->n + (b)->p - 1) % (b)->a)) #define cbuffer_isempty(b) (!cbuffer_len(b)) #define cbuffer_isfull(b) (!cbuffer_available(b)) diff --git a/src/include/skalibs/cdb.h b/src/include/skalibs/cdb.h index 9e9aae0..52e72ee 100644 --- a/src/include/skalibs/cdb.h +++ b/src/include/skalibs/cdb.h @@ -3,26 +3,26 @@ #ifndef CDB_H #define CDB_H +#include <stdint.h> #include <skalibs/gccattributes.h> -#include <skalibs/uint32.h> #define CDB_HASHSTART 5381 -extern uint32 cdb_hashadd (uint32, unsigned char) gccattr_const ; -extern uint32 cdb_hash (char const *, unsigned int) gccattr_pure ; +extern uint32_t cdb_hashadd (uint32_t, unsigned char) gccattr_const ; +extern uint32_t cdb_hash (char const *, unsigned int) gccattr_pure ; typedef struct cdb cdb_t, *cdb_t_ref ; struct cdb { char *map ; /* 0 if no map */ int fd ; /* -1 if uninitted, negative if mapped, nonnegative if nomapped */ - uint32 size ; /* initialized if map is nonzero */ - uint32 loop ; /* number of hash slots searched under this key */ - uint32 khash ; /* initialized if loop is nonzero */ - uint32 kpos ; /* initialized if loop is nonzero */ - uint32 hpos ; /* initialized if loop is nonzero */ - uint32 hslots ; /* initialized if loop is nonzero */ - uint32 dpos ; /* initialized if cdb_findnext() returns 1 */ - uint32 dlen ; /* initialized if cdb_findnext() returns 1 */ + uint32_t size ; /* initialized if map is nonzero */ + uint32_t loop ; /* number of hash slots searched under this key */ + uint32_t khash ; /* initialized if loop is nonzero */ + uint32_t kpos ; /* initialized if loop is nonzero */ + uint32_t hpos ; /* initialized if loop is nonzero */ + uint32_t hslots ; /* initialized if loop is nonzero */ + uint32_t dpos ; /* initialized if cdb_findnext() returns 1 */ + uint32_t dlen ; /* initialized if cdb_findnext() returns 1 */ } ; #define CDB_ZERO { .map = 0, .fd = -1, .size = 0, .loop = 0, .khash = 0, .kpos = 0, .hpos = 0, .hslots = 0, .dpos = 0, .dlen = 0 } @@ -33,7 +33,7 @@ extern void cdb_free (struct cdb *) ; #define cdb_init(c, fd) (cdb_init_map(c, (fd), 1) ? 0 : -1) extern int cdb_init_map (struct cdb *, int fd, int) ; extern int cdb_mapfile (struct cdb *, char const *) ; -extern int cdb_read (struct cdb *, char *, unsigned int, uint32) ; +extern int cdb_read (struct cdb *, char *, unsigned int, uint32_t) ; #define cdb_findstart(c) ((c)->loop = 0) extern int cdb_findnext (struct cdb *, char const *, unsigned int) ; #define cdb_find(c, s, len) (cdb_findstart(c), cdb_findnext(c, s, len)) @@ -45,7 +45,7 @@ extern int cdb_findnext (struct cdb *, char const *, unsigned int) ; #define cdb_traverse_init(c, kpos) (*(kpos) = 2048) #define cdb_firstkey(c, kpos) (cdb_traverse_init(c, kpos), cdb_nextkey(c, kpos)) -extern int cdb_nextkey (struct cdb *, uint32 *) ; +extern int cdb_nextkey (struct cdb *, uint32_t *) ; extern int cdb_successor (struct cdb *, char const *, unsigned int) ; #endif diff --git a/src/include/skalibs/cdb_make.h b/src/include/skalibs/cdb_make.h index 2858358..69e1c68 100644 --- a/src/include/skalibs/cdb_make.h +++ b/src/include/skalibs/cdb_make.h @@ -3,7 +3,7 @@ #ifndef CDB_MAKE_H #define CDB_MAKE_H -#include <skalibs/uint32.h> +#include <stdint.h> #include <skalibs/diuint32.h> #include <skalibs/allreadwrite.h> #include <skalibs/genalloc.h> @@ -13,12 +13,12 @@ typedef struct cdb_make cdb_make, *cdb_make_ref ; struct cdb_make { genalloc hplist ; /* array of diuint32 */ - uint32 pos ; + uint32_t pos ; buffer b ; char buf[BUFFER_OUTSIZE] ; } ; -#define CDB_MAKE_ZERO { .hplist = GENALLOC_ZERO, .pos = 2048, .b = BUFFER_INIT(&fd_writesv, -1, 0, 0) } +#define CDB_MAKE_ZERO { .hplist = GENALLOC_ZERO, .pos = 2048, .b = BUFFER_INIT(&fd_writev, -1, 0, 0) } extern int cdb_make_start (struct cdb_make *, int) ; extern int cdb_make_add (struct cdb_make *, char const *, unsigned int, char const *, unsigned int) ; diff --git a/src/include/skalibs/direntry.h b/src/include/skalibs/direntry.h index 3150e51..518ce77 100644 --- a/src/include/skalibs/direntry.h +++ b/src/include/skalibs/direntry.h @@ -3,7 +3,6 @@ #ifndef DIRENTRY_H #define DIRENTRY_H -#include <sys/types.h> #include <dirent.h> typedef struct dirent direntry, direntry_t, *direntry_ref, *direntry_t_ref ; diff --git a/src/include/skalibs/disize.h b/src/include/skalibs/disize.h new file mode 100644 index 0000000..418b518 --- /dev/null +++ b/src/include/skalibs/disize.h @@ -0,0 +1,17 @@ +/* ISC license. */ + +#ifndef DISIZE_H +#define DISIZE_H + +#include <sys/types.h> + +typedef struct disize_s disize, *disize_ref ; +struct disize_s +{ + size_t left ; + size_t right ; +} ; + +#define DISIZE_ZERO { .left = 0, .right = 0 } + +#endif diff --git a/src/include/skalibs/diuint32.h b/src/include/skalibs/diuint32.h index cd8ae75..fb0a2de 100644 --- a/src/include/skalibs/diuint32.h +++ b/src/include/skalibs/diuint32.h @@ -3,13 +3,13 @@ #ifndef DIUINT32_H #define DIUINT32_H -#include <skalibs/uint32.h> +#include <stdint.h> -typedef struct diuint32 diuint32, *diuint32_ref ; -struct diuint32 +typedef struct diuint32_s diuint32, *diuint32_ref ; +struct diuint32_s { - uint32 left ; - uint32 right ; + uint32_t left ; + uint32_t right ; } ; #define DIUINT32_ZERO { .left = 0, .right = 0 } diff --git a/src/include/skalibs/djbtime.h b/src/include/skalibs/djbtime.h index 07ad662..2f924c7 100644 --- a/src/include/skalibs/djbtime.h +++ b/src/include/skalibs/djbtime.h @@ -3,9 +3,8 @@ #ifndef DJBTIME_H #define DJBTIME_H -#include <sys/types.h> +#include <stdint.h> #include <time.h> -#include <skalibs/uint32.h> #include <skalibs/uint64.h> #include <skalibs/tai.h> diff --git a/src/include/skalibs/djbunix.h b/src/include/skalibs/djbunix.h index a0d65a0..03fd092 100644 --- a/src/include/skalibs/djbunix.h +++ b/src/include/skalibs/djbunix.h @@ -9,8 +9,6 @@ #include <sys/stat.h> #include <unistd.h> #include <skalibs/gccattributes.h> -#include <skalibs/uint64.h> -#include <skalibs/siovec.h> #include <skalibs/stralloc.h> #include <skalibs/envalloc.h> #include <skalibs/env.h> /* compatibility */ @@ -32,7 +30,7 @@ extern int fd_move (int, int) ; extern int fd_move2 (int, int, int, int) ; extern int fd_close (int) ; extern int fd_chmod (int, unsigned int) ; -extern int fd_chown (int, unsigned int, unsigned int) ; +extern int fd_chown (int, uid_t, gid_t) ; extern int fd_sync (int) ; extern int fd_cat (int, int) ; extern size_t fd_catn (int, int, size_t) ; @@ -56,9 +54,9 @@ extern int socket_internal (int, int, int, unsigned int) ; extern int socketpair_internal (int, int, int, unsigned int, int *) ; extern int pathexec_env (char const *, char const *) ; -extern void pathexec_r (char const *const *, char const *const *, unsigned int, char const *, unsigned int) ; -extern void pathexec_r_name (char const *, char const *const *, char const *const *, unsigned int, char const *, unsigned int) ; -extern void pathexec_fromenv (char const *const *, char const *const *, unsigned int) ; +extern void pathexec_r (char const *const *, char const *const *, size_t, char const *, size_t) ; +extern void pathexec_r_name (char const *, char const *const *, char const *const *, size_t, char const *, size_t) ; +extern void pathexec_fromenv (char const *const *, char const *const *, size_t) ; extern void execvep (char const *, char const *const *, char const *const *, char const *) ; extern void pathexec_run (char const *, char const *const *, char const *const *) ; extern void pathexec0_run (char const *const *, char const *const *) ; @@ -72,9 +70,9 @@ extern int prot_grps (char const *) ; extern int prot_setuidgid (char const *) ; extern long seek_cur (int) ; -extern int seek_set (int, long) ; +extern int seek_set (int, off_t) ; extern int seek_end (int) ; -extern int seek_trunc (int, long) ; +extern int seek_trunc (int, off_t) ; #define seek_begin(fd) (seek_set((fd), 0)) extern pid_t wait_nointr (int *) ; @@ -98,48 +96,45 @@ extern int fd_chdir (int) ; extern char *realpath_tmp (char const *, char *, stralloc *) ; extern int sarealpath (stralloc *, char const *) ; extern int sarealpath_tmp (stralloc *, char const *, stralloc *) ; -/* extern char *basename (char *) ; */ -extern int sabasename (stralloc *, char const *, unsigned int) ; -/* extern char *dirname (char *) ; */ -extern int sadirname (stralloc *, char const *, unsigned int) ; +extern int sabasename (stralloc *, char const *, size_t) ; +extern int sadirname (stralloc *, char const *, size_t) ; extern int sagetcwd (stralloc *) ; extern int sareadlink (stralloc *, char const *) ; extern int sagethostname (stralloc *) ; extern int slurp (stralloc *, int) ; extern int openslurpclose (stralloc *, char const *) ; -extern int openreadclose (char const *, stralloc *, unsigned int) ; -extern int openreadnclose (char const *, char *, unsigned int) ; -extern int openreadnclose_nb (char const *, char *, unsigned int) ; -extern int openreadfileclose (char const *, stralloc *, unsigned int) ; +extern ssize_t openreadnclose (char const *, char *, size_t) ; +extern ssize_t openreadnclose_nb (char const *, char *, size_t) ; +extern int openreadfileclose (char const *, stralloc *, size_t) ; #define openwritenclose_unsafe(f, s, n) openwritenclose_unsafe_internal(f, s, (n), 0, 0, 0) #define openwritenclose_unsafe_sync(f, s, n) openwritenclose_unsafe_internal(f, s, (n), 0, 0, 1) #define openwritenclose_unsafe_devino(f, s, n, dev, ino) openwritenclose_unsafe_internal(f, s, n, dev, (ino), 0) #define openwritenclose_unsafe_devino_sync(f, s, n, dev, ino) openwritenclose_unsafe_internal(f, s, n, dev, (ino), 1) -extern int openwritenclose_unsafe_internal (char const *, char const *, unsigned int, uint64 *, uint64 *, int) ; +extern int openwritenclose_unsafe_internal (char const *, char const *, size_t, dev_t *, ino_t *, int) ; #define openwritenclose_suffix(f, s, n, t) openwritenclose_suffix_internal(f, s, n, 0, 0, 0, t) #define openwritenclose_suffix_sync(f, s, n, t) openwritenclose_suffix_internal(f, s, n, 0, 0, 1, t) #define openwritenclose_suffix_devino(f, s, n, t, dev, ino) openwritenclose_suffix_internal(f, s, n, dev, (ino), 0, t) #define openwritenclose_suffix_devino_sync(f, s, n, t, dev, ino) openwritenclose_suffix_internal(f, s, n, dev, (ino), 1, t) -extern int openwritenclose_suffix_internal (char const *, char const *, unsigned int, uint64 *, uint64 *, int, char const *) ; +extern int openwritenclose_suffix_internal (char const *, char const *, size_t, dev_t *, ino_t *, int, char const *) ; #define openwritevnclose_unsafe(f, v, n) openwritevnclose_unsafe_internal(f, v, (n), 0, 0, 0) #define openwritevnclose_unsafe_sync(f, v, n) openwritevnclose_unsafe_internal(f, v, (n), 0, 0, 1) #define openwritevnclose_unsafe_devino(f, v, n, dev, ino) openwritevnclose_unsafe_internal(f, v, n, dev, (ino), 0) #define openwritevnclose_unsafe_devino_sync(f, v, n, dev, ino) openwritevnclose_unsafe_internal(f, v, n, dev, (ino), 1) -extern int openwritevnclose_unsafe_internal (char const *, siovec_t const *, unsigned int, uint64 *, uint64 *, int) ; +extern int openwritevnclose_unsafe_internal (char const *, struct iovec const *, unsigned int, dev_t *, ino_t *, int) ; #define openwritevnclose_suffix(f, v, n, t) openwritevnclose_suffix_internal(f, v, n, 0, 0, 0, t) #define openwritevnclose_suffix_sync(f, v, n, t) openwritevnclose_suffix_internal(f, v, n, 0, 0, 1, t) #define openwritevnclose_suffix_devino(f, v, n, t, dev, ino) openwritevnclose_suffix_internal(f, v, n, dev, (ino), 0, t) #define openwritevnclose_suffix_devino_sync(f, v, n, t, dev, ino) openwritevnclose_suffix_internal(f, v, n, dev, (ino), 1, t) -extern int openwritevnclose_suffix_internal (char const *, siovec_t const *, unsigned int, uint64 *, uint64 *, int, char const *) ; +extern int openwritevnclose_suffix_internal (char const *, struct iovec const *, unsigned int, dev_t *, ino_t *, int, char const *) ; extern int rm_rf (char const *) ; extern int rm_rf_tmp (char const *, stralloc *) ; -extern int rm_rf_in_tmp (stralloc *, unsigned int) ; /* caution ! */ +extern int rm_rf_in_tmp (stralloc *, size_t) ; /* caution ! */ extern int rmstar (char const *) ; extern int rmstar_tmp (char const *, stralloc *) ; diff --git a/src/include/skalibs/functypes.h b/src/include/skalibs/functypes.h index a443c2a..f67a0bc 100644 --- a/src/include/skalibs/functypes.h +++ b/src/include/skalibs/functypes.h @@ -24,8 +24,11 @@ typedef freefunc_t *freefunc_t_ref ; typedef int initfunc_t (void *) ; typedef initfunc_t *initfunc_t_ref ; -typedef unsigned int uinitfunc_t (void *) ; -typedef uinitfunc_t *uinitfunc_t_ref ; +typedef ssize_t getfunc_t (void *) ; +typedef getfunc_t *getfunc_t_ref ; + +typedef size_t ugetfunc_t (void *) ; +typedef ugetfunc_t *ugetfunc_t_ref ; typedef ssize_t iofunc_t (int, char *, size_t) ; typedef iofunc_t *iofunc_t_ref ; diff --git a/src/include/skalibs/kolbak.h b/src/include/skalibs/kolbak.h index 86a2170..566f065 100644 --- a/src/include/skalibs/kolbak.h +++ b/src/include/skalibs/kolbak.h @@ -3,6 +3,7 @@ #ifndef KOLBAK_H #define KOLBAK_H +#include <sys/types.h> #include <skalibs/unixmessage.h> typedef struct kolbak_closure_s kolbak_closure_t, *kolbak_closure_t_ref ; @@ -17,14 +18,14 @@ typedef struct kolbak_queue_s kolbak_queue_t, *kolbak_queue_t_ref ; struct kolbak_queue_s { kolbak_closure_t *x ; - unsigned int n ; - unsigned int head ; - unsigned int tail ; + size_t n ; + size_t head ; + size_t tail ; } ; #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 *, unsigned int) ; +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 *) ; diff --git a/src/include/skalibs/netstring.h b/src/include/skalibs/netstring.h index f6663c3..107e796 100644 --- a/src/include/skalibs/netstring.h +++ b/src/include/skalibs/netstring.h @@ -17,7 +17,7 @@ extern int netstring_encode (stralloc *, char const *, size_t) ; extern ssize_t netstring_decode (stralloc *, char const *, size_t) ; extern int netstring_okeof (buffer *, size_t) ; -extern ssize_t netstring_get (buffer *, stralloc *, size_t *) ; +extern int netstring_get (buffer *, stralloc *, size_t *) ; extern int netstring_put (buffer *, char const *, size_t, size_t *) ; #define netstring_putba(ba, s, n) netstring_appendb(&(ba)->x, s, n) #define netstring_putbav(ba, v, n) netstring_appendv(&(ba)->x, v, n) diff --git a/src/include/skalibs/siovec.h b/src/include/skalibs/siovec.h index 55ef993..a543d93 100644 --- a/src/include/skalibs/siovec.h +++ b/src/include/skalibs/siovec.h @@ -7,24 +7,14 @@ #include <sys/uio.h> #include <skalibs/gccattributes.h> -typedef struct siovec_s siovec_t, *siovec_t_ref ; -struct siovec_s -{ - char *s ; - unsigned int len ; -} ; +extern size_t siovec_len (struct iovec const *, unsigned int) gccattr_pure ; +extern size_t siovec_gather (struct iovec const *, unsigned int, char *, size_t) ; +extern size_t siovec_scatter (struct iovec const *, unsigned int, char const *, size_t) ; +extern size_t siovec_deal (struct iovec const *, unsigned int, struct iovec const *, unsigned int) ; +extern size_t siovec_seek (struct iovec *, unsigned int, size_t) ; +extern unsigned int siovec_trunc (struct iovec *, unsigned int, size_t) ; -extern unsigned int siovec_len (siovec_t const *, unsigned int) gccattr_pure ; -extern unsigned int siovec_gather (siovec_t const *, unsigned int, char *, unsigned int) ; -extern unsigned int siovec_scatter (siovec_t const *, unsigned int, char const *, unsigned int) ; -extern unsigned int siovec_deal (siovec_t const *, unsigned int, siovec_t const *, unsigned int) ; -extern unsigned int siovec_seek (siovec_t *, unsigned int, unsigned int) ; -extern unsigned int siovec_trunc (siovec_t *, unsigned int, unsigned int) ; - -extern void siovec_from_iovec (siovec_t *, struct iovec const *, unsigned int) ; -extern void iovec_from_siovec (struct iovec *, siovec_t const *, unsigned int) ; - -extern unsigned int siovec_bytechr (siovec_t const *, unsigned int, char) ; -extern unsigned int siovec_bytein (siovec_t const *, unsigned int, char const *, unsigned int) ; +extern size_t siovec_bytechr (struct iovec const *, unsigned int, char) ; +extern size_t siovec_bytein (struct iovec const *, unsigned int, char const *, size_t) ; #endif diff --git a/src/include/skalibs/skaclient.h b/src/include/skalibs/skaclient.h index 5b73852..2e6e251 100644 --- a/src/include/skalibs/skaclient.h +++ b/src/include/skalibs/skaclient.h @@ -4,18 +4,18 @@ #define SKACLIENT_H #include <sys/types.h> +#include <sys/uio.h> +#include <stdint.h> #include <skalibs/kolbak.h> -#include <skalibs/siovec.h> #include <skalibs/tai.h> -#include <skalibs/uint32.h> #include <skalibs/unixmessage.h> /* Server part */ -extern int skaclient_server_ack (unixmessage_t const *, unixmessage_sender_t *, unixmessage_sender_t *, char const *, unsigned int, char const *, unsigned int) ; -extern int skaclient_server_bidi_ack (unixmessage_t const *, unixmessage_sender_t *, unixmessage_sender_t *, unixmessage_receiver_t *, char *, unsigned int, char *, unsigned int, char const *, unsigned int, char const *, unsigned int) ; -extern int skaclient_server_init (unixmessage_receiver_t *, unixmessage_sender_t *, unixmessage_sender_t *, char const *, unsigned int, char const *, unsigned int, tain_t const *, tain_t *) ; +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 *) ; #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) @@ -43,7 +43,7 @@ struct skaclient_s unixmessage_receiver_t asyncin ; unixmessage_sender_t asyncout ; pid_t pid ; - uint32 options ; + 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 ; @@ -56,7 +56,7 @@ struct skaclient_cbdata_s { skaclient_t *a ; char const *after ; - unsigned int afterlen ; + size_t afterlen ; } ; @@ -64,17 +64,17 @@ struct skaclient_cbdata_s extern void skaclient_end (skaclient_t *) ; -extern int skaclient_start_async (skaclient_t *, char *, unsigned int, char *, unsigned int, char *, unsigned int, char *, unsigned int, kolbak_closure_t *, unsigned int, char const *, uint32, char const *, unsigned int, char const *, unsigned int, skaclient_cbdata_t *) ; +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 *) ; #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 *, unsigned int, char *, unsigned int, char *, unsigned int, char *, unsigned int, kolbak_closure_t *, unsigned int, char const *, char const *const *, char const *const *, uint32, char const *, unsigned int, char const *, unsigned int, skaclient_cbdata_t *) ; +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_start (skaclient_t *, char *, unsigned int, char *, unsigned int, char *, unsigned int, char *, unsigned int, kolbak_closure_t *, unsigned int, char const *, uint32, char const *, unsigned int, char const *, unsigned int, tain_t const *, tain_t *) ; +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) #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 *, unsigned int, char *, unsigned int, char *, unsigned int, char *, unsigned int, kolbak_closure_t *, unsigned int, char const *, char const *const *, char const *const *, uint32, char const *, unsigned int, char const *, unsigned int, tain_t const *, tain_t *) ; +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) #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) @@ -87,8 +87,8 @@ extern int skaclient_putmsg_and_close (skaclient_t *, unixmessage_t const *, uns extern int skaclient_putmsgv_and_close (skaclient_t *, unixmessage_v_t const *, unsigned char const *, unixmessage_handler_func_t *, 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 *, unsigned int, unixmessage_handler_func_t *, void *) ; -extern int skaclient_putv (skaclient_t *, siovec_t const *, unsigned int, unixmessage_handler_func_t *, void *) ; +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 *) ; /* Writing and flushing */ @@ -103,9 +103,9 @@ extern int skaclient_sendmsgv_and_close (skaclient_t *, unixmessage_v_t const *, #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 *, unsigned int, unixmessage_handler_func_t *, void *, tain_t const *, tain_t *) ; +extern int skaclient_send (skaclient_t *, char const *, size_t, unixmessage_handler_func_t *, void *, tain_t const *, tain_t *) ; #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 *, siovec_t const *, unsigned int, unixmessage_handler_func_t *, void *, tain_t const *, tain_t *) ; +extern int skaclient_sendv (skaclient_t *, struct iovec const *, unsigned int, unixmessage_handler_func_t *, void *, tain_t const *, tain_t *) ; #define skaclient_sendv_g(a, v, vlen, cb, result, deadline) skaclient_sendv(a, v, vlen, cb, result, (deadline), &STAMP) diff --git a/src/include/skalibs/skamisc.h b/src/include/skalibs/skamisc.h index 4b76fb7..cf33ec2 100644 --- a/src/include/skalibs/skamisc.h +++ b/src/include/skalibs/skamisc.h @@ -3,6 +3,7 @@ #ifndef SKAMISC_H #define SKAMISC_H +#include <sys/types.h> #include <skalibs/buffer.h> #include <skalibs/stralloc.h> @@ -10,18 +11,18 @@ extern stralloc satmp ; extern int skagetln (buffer *, stralloc *, char) ; extern int skagetln_nofill (buffer *, stralloc *, char) ; -extern int skagetlnsep (buffer *, stralloc *, char const *, unsigned int) ; -extern int getlnmax (buffer *, char *, unsigned int, unsigned int *, char) ; -extern int getlnmaxsep (buffer *, char *, unsigned int, unsigned int *, char const *, unsigned int) ; +extern int skagetlnsep (buffer *, stralloc *, char const *, size_t) ; +extern int getlnmax (buffer *, char *, size_t, size_t *, char) ; +extern int getlnmaxsep (buffer *, char *, size_t, size_t *, char const *, size_t) ; extern int sauniquename (stralloc *) ; -extern int string_quote (stralloc *, char const *, unsigned int) ; -extern int string_quote_nodelim (stralloc *, char const *, unsigned int) ; -extern int string_quote_nodelim_mustquote (stralloc *, char const *, unsigned int, char const *, unsigned int) ; -extern int string_unquote (char *, unsigned int *, char const *, unsigned int, unsigned int *) ; -extern int string_unquote_nodelim (char *, char const *, unsigned int) ; -extern int string_unquote_withdelim (char *, unsigned int *, char const *, unsigned int, unsigned int *, char const *, unsigned int) ; +extern int string_quote (stralloc *, char const *, size_t) ; +extern int string_quote_nodelim (stralloc *, char const *, size_t) ; +extern int string_quote_nodelim_mustquote (stralloc *, char const *, size_t, char const *, size_t) ; +extern int string_unquote (char *, size_t *, char const *, size_t, size_t *) ; +extern ssize_t string_unquote_nodelim (char *, char const *, size_t) ; +extern int string_unquote_withdelim (char *, size_t *, char const *, size_t, size_t *, char const *, size_t) ; extern int string_format (stralloc *, char const *, char const *, char const *const *) ; diff --git a/src/include/skalibs/stddjb.h b/src/include/skalibs/stddjb.h index b1f54cb..1a2ccca 100644 --- a/src/include/skalibs/stddjb.h +++ b/src/include/skalibs/stddjb.h @@ -25,6 +25,7 @@ #include <skalibs/direntry.h> #include <skalibs/diuint32.h> #include <skalibs/diuint.h> +#include <skalibs/disize.h> #include <skalibs/djbtime.h> #include <skalibs/djbunix.h> #include <skalibs/envalloc.h> diff --git a/src/include/skalibs/unix-timed.h b/src/include/skalibs/unix-timed.h index 17bda9d..84b5465 100644 --- a/src/include/skalibs/unix-timed.h +++ b/src/include/skalibs/unix-timed.h @@ -3,39 +3,40 @@ #ifndef UNIX_TIMED_H #define UNIX_TIMED_H +#include <sys/types.h> #include <skalibs/bufalloc.h> #include <skalibs/buffer.h> #include <skalibs/functypes.h> #include <skalibs/stralloc.h> #include <skalibs/tai.h> - /* Timed "blocking" operations (the fd must still be non-blocking) */ + /* 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 *) ; #define timed_flush_g(b, getfd, isnonempty, flush, deadline) timed_flush(b, getfd, isnonempty, flush, (deadline_), &STAMP) -extern int timed_get (void *, initfunc_t_ref, initfunc_t_ref, tain_t const *, tain_t *) ; +extern ssize_t timed_get (void *, initfunc_t_ref, getfunc_t_ref, tain_t const *, tain_t *) ; #define timed_get_g (b, getfd, get, deadline) timed_get(b, getfd, get, (deadline), &STAMP) -extern int buffer_timed_fill (buffer *, tain_t const *, tain_t *) ; +extern ssize_t buffer_timed_fill (buffer *, tain_t const *, tain_t *) ; #define buffer_timed_fill_g(b, deadline) buffer_timed_fill(b, (deadline), &STAMP) extern int bufalloc_timed_flush (bufalloc *, tain_t const *, tain_t *) ; #define bufalloc_timed_flush_g(ba, deadline) bufalloc_timed_flush(ba, (deadline), &STAMP) extern int buffer_timed_flush (buffer *, tain_t const *, tain_t *) ; #define buffer_timed_flush_g(b, deadline) buffer_timed_flush(b, (deadline), &STAMP) -extern unsigned int buffer_timed_get (buffer *, char *, unsigned int, tain_t const *, tain_t *) ; +extern size_t buffer_timed_get (buffer *, char *, size_t, tain_t const *, tain_t *) ; #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 *) ; #define timed_getln_g(b, sa, sep, deadline) timed_getln(b, sa, sep, (deadline), &STAMP) -extern int timed_getlnmax (buffer *, char *, unsigned int, unsigned int *, char, tain_t const *, tain_t *) ; +extern ssize_t timed_getlnmax (buffer *, char *, size_t, size_t *, char, tain_t const *, tain_t *) ; #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 *) ; #define netstring_timed_get_g(b, sa, deadline) netstring_timed_get(b, sa, (deadline), &STAMP) -extern int ipc_timed_send (int, char const *, unsigned int, tain_t const *, tain_t *) ; +extern int ipc_timed_send (int, char const *, size_t, tain_t const *, tain_t *) ; #define ipc_timed_send_g(fd, s, len, deadline) ipc_timed_send(fd, s, len, (deadline), &STAMP) -extern int ipc_timed_recv (int, char *, unsigned int, char *, tain_t const *, tain_t *) ; +extern ssize_t ipc_timed_recv (int, char *, size_t, char *, tain_t const *, tain_t *) ; #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 beb27b4..b1decb5 100644 --- a/src/include/skalibs/unix-transactional.h +++ b/src/include/skalibs/unix-transactional.h @@ -4,9 +4,9 @@ #define UNIX_TRANSACTIONAL_H #include <sys/types.h> +#include <sys/uio.h> #include <sys/stat.h> #include <skalibs/uint64.h> -#include <skalibs/siovec.h> #include <skalibs/stralloc.h> /* Transactional/reliable filesystem operations */ @@ -28,16 +28,16 @@ extern int open_appendatb (int, char const *) ; extern int stat_at (int, char const *, struct stat *) ; extern int lstat_at (int, char const *, struct stat *) ; -extern unsigned int openreadnclose_at (int, char const *, char *, unsigned int) ; +extern size_t openreadnclose_at (int, char const *, char *, size_t) ; extern int openslurpclose_at (int, char const *, stralloc *) ; extern int opengetlnclose_at (int, char const *, stralloc *, int) ; -extern int openwritenclose (char const *, char const *, unsigned int) ; -extern int openwritenclose_devino (char const *, char const *, unsigned int, uint64 *, uint64 *) ; -extern int openwritenclose_tmp (char const *, char const *, unsigned int, stralloc *) ; -extern int openwritenclose_devino_tmp (char const *, char const *, unsigned int, uint64 *, uint64 *, stralloc *) ; -extern unsigned int openwritenclose_at (int, char const *, char const *, unsigned int) ; -extern unsigned int openwritevnclose_at (int, char const *, siovec_t const *, unsigned int) ; +extern int openwritenclose (char const *, char const *, size_t) ; +extern int openwritenclose_devino (char const *, char const *, size_t, dev_t *, ino_t *) ; +extern int openwritenclose_tmp (char const *, char const *, size_t, stralloc *) ; +extern int openwritenclose_devino_tmp (char const *, char const *, size_t, dev_t *, ino_t *, stralloc *) ; +extern size_t openwritenclose_at (int, char const *, char const *, size_t) ; +extern size_t openwritevnclose_at (int, char const *, struct iovec const *, unsigned int) ; extern int mkdir_unique (stralloc *, char const *, unsigned int) ; extern int atomic_rm_rf (char const *) ; diff --git a/src/include/skalibs/unixmessage.h b/src/include/skalibs/unixmessage.h index f971a65..4c98ed6 100644 --- a/src/include/skalibs/unixmessage.h +++ b/src/include/skalibs/unixmessage.h @@ -3,14 +3,14 @@ #ifndef UNIXMESSAGE_H #define UNIXMESSAGE_H -#include <skalibs/uint16.h> -#include <skalibs/uint32.h> +#include <sys/types.h> +#include <sys/uio.h> +#include <stdint.h> +#include <skalibs/gccattributes.h> #include <skalibs/buffer.h> #include <skalibs/cbuffer.h> -#include <skalibs/gccattributes.h> #include <skalibs/stralloc.h> #include <skalibs/genalloc.h> -#include <skalibs/siovec.h> #include <skalibs/tai.h> @@ -20,7 +20,7 @@ typedef struct unixmessage_s unixmessage_t, *unixmessage_t_ref ; struct unixmessage_s { char *s ; - unsigned int len ; + size_t len ; int *fds ; unsigned int nfds ; } ; @@ -32,7 +32,7 @@ extern void unixmessage_drop (unixmessage_t const *) ; typedef struct unixmessage_v_s unixmessage_v_t, *unixmessage_v_t_ref ; struct unixmessage_v_s { - siovec_t *v ; + struct iovec *v ; unsigned int vlen ; int *fds ; unsigned int nfds ; @@ -40,7 +40,7 @@ struct unixmessage_v_s #define UNIXMESSAGE_V_ZERO { .v = 0, .vlen = 0, .fds = 0, .nfds = 0 } extern unixmessage_v_t const unixmessage_v_zero ; -#define UNIXMESSAGE_MAXSIZE (2U << 27) +#define UNIXMESSAGE_MAXSIZE (1U << 28) #define UNIXMESSAGE_MAXFDS 255 #define UNIXMESSAGE_BUFSIZE 2048 #define UNIXMESSAGE_AUXBUFSIZE (sizeof(int) * UNIXMESSAGE_MAXFDS + 1) @@ -58,9 +58,9 @@ struct unixmessage_sender_s int fd ; stralloc data ; genalloc fds ; /* int */ - genalloc offsets ; /* diuint */ - unsigned int head ; - unsigned int shorty ; + genalloc offsets ; /* disize */ + size_t head ; + size_t shorty ; unixmessage_sender_closecb_func_t_ref closecb ; void *closecbdata ; } ; @@ -104,8 +104,8 @@ struct unixmessage_receiver_s cbuffer_t auxb ; stralloc maindata ; stralloc auxdata ; - uint32 mainlen ; - uint16 auxlen ; + uint32_t mainlen ; + uint16_t auxlen ; unsigned int fds_ok : 2 ; } ; #define UNIXMESSAGE_RECEIVER_ZERO { .fd = -1, .mainb = CBUFFER_ZERO, .auxb = CBUFFER_ZERO, .maindata = STRALLOC_ZERO, .auxdata = STRALLOC_ZERO, .mainlen = 0, .auxlen = 0, .fds_ok = 3 } @@ -120,7 +120,7 @@ struct unixmessage_receiver_s .auxlen = 0, \ .fds_ok = 3 \ } -extern int unixmessage_receiver_init (unixmessage_receiver_t *, int, char *, unsigned int, char *, unsigned int) ; +extern int unixmessage_receiver_init (unixmessage_receiver_t *, int, char *, size_t, char *, size_t) ; extern void unixmessage_receiver_free (unixmessage_receiver_t *) ; #define unixmessage_receiver_fd(b) ((b)->fd) #define unixmessage_receiver_isempty(b) (cbuffer_isempty(&(b)->mainb) && cbuffer_isempty(&(b)->auxb)) @@ -137,8 +137,8 @@ extern int unixmessage_timed_receive (unixmessage_receiver_t *, unixmessage_t *, typedef int unixmessage_handler_func_t (unixmessage_t const *, void *) ; typedef unixmessage_handler_func_t *unixmessage_handler_func_t_ref ; -extern int unixmessage_handle (unixmessage_receiver_t *, unixmessage_handler_func_t *, void *) ; -extern int unixmessage_timed_handle (unixmessage_receiver_t *, unixmessage_handler_func_t *, void *, tain_t const *, tain_t *) ; +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 *) ; #define unixmessage_timed_handle_g(b, f, p, deadline) unixmessage_timed_handle(b, f, p, (deadline), &STAMP) diff --git a/src/libstddjb/absolutepath_tmp.c b/src/libstddjb/absolutepath_tmp.c index 3d3c2b1..b0e1e07 100644 --- a/src/libstddjb/absolutepath_tmp.c +++ b/src/libstddjb/absolutepath_tmp.c @@ -1,5 +1,7 @@ /* ISC license. */ +/* MT-unsafe (because of chdir) */ + #include <sys/types.h> #include <unistd.h> #include <errno.h> @@ -52,7 +54,7 @@ int sarealpath_tmp (stralloc *sa, char const *path, stralloc *tmp) err: { - register int e = errno ; + int e = errno ; tmp->len = tmpbase ; fd_chdir(fdhere) ; fd_close(fdhere) ; diff --git a/src/libstddjb/allread.c b/src/libstddjb/allread.c index a33b650..3fdd4ea 100644 --- a/src/libstddjb/allread.c +++ b/src/libstddjb/allread.c @@ -5,5 +5,5 @@ size_t allread (int fd, char *buf, size_t len) { - return allreadwrite(&fd_readv, fd, buf, len) ; + return allreadwrite(&fd_read, fd, buf, len) ; } diff --git a/src/libstddjb/allreadwritev.c b/src/libstddjb/allreadwritev.c index 2b06ac7..5ba3837 100644 --- a/src/libstddjb/allreadwritev.c +++ b/src/libstddjb/allreadwritev.c @@ -9,12 +9,12 @@ size_t allreadwritev (iovfunc_t_ref op, int fd, struct iovec const *v, unsigned int vlen) { size_t written = 0 ; - struct iovec vv[vlen] ; - unsigned int i = 0 ; - for (; i < vlen ; i++) vv[i] = v[i] ; + struct iovec vv[vlen ? vlen : 1] ; + unsigned int i = vlen ; + while (i--) vv[i] = v[i] ; while (siovec_len(vv, vlen)) { - register ssize_t w = (*op)(fd, vv, vlen) ; + ssize_t w = (*op)(fd, vv, vlen) ; if (w <= 0) break ; w = siovec_seek(vv, vlen, w) ; written += w ; diff --git a/src/libstddjb/allwrite.c b/src/libstddjb/allwrite.c index f465eb4..200227d 100644 --- a/src/libstddjb/allwrite.c +++ b/src/libstddjb/allwrite.c @@ -1,5 +1,7 @@ /* ISC license. */ +#include <sys/types.h> +#include <skalibs/functypes.h> #include <skalibs/allreadwrite.h> size_t allwrite (int fd, char const *buf, size_t len) diff --git a/src/libstddjb/basename.c b/src/libstddjb/basename.c deleted file mode 100644 index 4eb4080..0000000 --- a/src/libstddjb/basename.c +++ /dev/null @@ -1,19 +0,0 @@ -/* ISC license. */ - -/* MT-unsafe */ - -#include <skalibs/bytestr.h> -#include <skalibs/stralloc.h> -#include <skalibs/djbunix.h> - -char *basename (char *s) -{ - static stralloc basename_sa = STRALLOC_ZERO ; - static char dot0[2] = "." ; - char *dot = dot0 ; - if (!s) return dot ; - basename_sa.len = 0 ; - if (!sabasename(&basename_sa, s, str_len(s))) return 0 ; - if (!stralloc_0(&basename_sa)) return 0 ; - return basename_sa.s ; -} diff --git a/src/libstddjb/bufalloc_init.c b/src/libstddjb/bufalloc_init.c index d6a89da..c538bc1 100644 --- a/src/libstddjb/bufalloc_init.c +++ b/src/libstddjb/bufalloc_init.c @@ -4,7 +4,7 @@ #include <skalibs/stralloc.h> #include <skalibs/bufalloc.h> -void bufalloc_init (bufalloc *ba, int (*op)(int, char const *, size_t), int fd) +void bufalloc_init (bufalloc *ba, ssize_t (*op)(int, char const *, size_t), int fd) { ba->x = stralloc_zero ; ba->op = op ; diff --git a/src/libstddjb/buffer_fill.c b/src/libstddjb/buffer_fill.c index 9899be1..b3a1bf2 100644 --- a/src/libstddjb/buffer_fill.c +++ b/src/libstddjb/buffer_fill.c @@ -1,12 +1,14 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> #include <errno.h> #include <skalibs/buffer.h> -int buffer_fill (buffer *b) +ssize_t buffer_fill (buffer *b) { - siovec_t v[2] ; - register int r ; + struct iovec v[2] ; + ssize_t r ; if (buffer_isfull(b)) return (errno = ENOBUFS, -1) ; buffer_wpeek(b, v) ; r = (*b->op)(b->fd, v, 2) ; diff --git a/src/libstddjb/buffer_flush.c b/src/libstddjb/buffer_flush.c index 46512fc..3249a11 100644 --- a/src/libstddjb/buffer_flush.c +++ b/src/libstddjb/buffer_flush.c @@ -1,17 +1,18 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> #include <skalibs/cbuffer.h> -#include <skalibs/siovec.h> #include <skalibs/buffer.h> int buffer_flush (buffer *b) { for (;;) { - siovec_t v[2] ; - register int r ; + struct iovec v[2] ; + ssize_t r ; buffer_rpeek(b, v) ; - if (!v[0].len && !v[1].len) break ; + if (!v[0].iov_len && !v[1].iov_len) break ; r = (*b->op)(b->fd, v, 2) ; if (r <= 0) return 0 ; cbuffer_RSEEK(&b->c, r) ; diff --git a/src/libstddjb/buffer_get.c b/src/libstddjb/buffer_get.c index ff67a06..0263f87 100644 --- a/src/libstddjb/buffer_get.c +++ b/src/libstddjb/buffer_get.c @@ -1,12 +1,13 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/buffer.h> -int buffer_get (buffer *b, char *s, unsigned int len) +ssize_t buffer_get (buffer *b, char *s, size_t len) { - unsigned int w = 0 ; + size_t w = 0 ; register int r = buffer_getall(b, s, len, &w) ; - return r == -1 ? errno == EPIPE ? (errno = 0, (int)w) : -1 : - !r ? (errno = EWOULDBLOCK, -1) : (int)w ; + return r == -1 ? errno == EPIPE ? (errno = 0, (ssize_t)w) : -1 : + !r ? (errno = EWOULDBLOCK, -1) : (ssize_t)w ; } diff --git a/src/libstddjb/buffer_getall.c b/src/libstddjb/buffer_getall.c index dc0e115..dca9e3b 100644 --- a/src/libstddjb/buffer_getall.c +++ b/src/libstddjb/buffer_getall.c @@ -1,15 +1,16 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/allreadwrite.h> #include <skalibs/buffer.h> -int buffer_getall (buffer *b, char *buf, unsigned int len, unsigned int *w) +int buffer_getall (buffer *b, char *buf, size_t len, size_t *w) { if (*w > len) return (errno = EINVAL, -1) ; for (;;) { - register int r ; + ssize_t r ; *w += buffer_getnofill(b, buf + *w, len - *w) ; if (*w >= len) break ; r = sanitize_read(buffer_fill(b)) ; diff --git a/src/libstddjb/buffer_getallnf.c b/src/libstddjb/buffer_getallnf.c index be46196..9ad0036 100644 --- a/src/libstddjb/buffer_getallnf.c +++ b/src/libstddjb/buffer_getallnf.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/buffer.h> -int buffer_getallnofill (buffer *b, char *s, unsigned int len) +int buffer_getallnofill (buffer *b, char *s, size_t len) { - register unsigned int r = buffer_getnofill(b, s, len) ; + size_t r = buffer_getnofill(b, s, len) ; if (r < len) { buffer_unget(b, r) ; diff --git a/src/libstddjb/buffer_getlen.c b/src/libstddjb/buffer_getlen.c index 73289a7..47ff472 100644 --- a/src/libstddjb/buffer_getlen.c +++ b/src/libstddjb/buffer_getlen.c @@ -1,8 +1,9 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/buffer.h> -unsigned int buffer_getlen (buffer const *b) +size_t buffer_getlen (buffer const *b) { return buffer_len(b) ; } diff --git a/src/libstddjb/buffer_getv.c b/src/libstddjb/buffer_getv.c index b3d237e..358de01 100644 --- a/src/libstddjb/buffer_getv.c +++ b/src/libstddjb/buffer_getv.c @@ -1,12 +1,13 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> #include <skalibs/allreadwrite.h> #include <skalibs/buffer.h> -#include <skalibs/siovec.h> -int buffer_getv (buffer *b, siovec_t const *v, unsigned int n) +ssize_t buffer_getv (buffer *b, struct iovec const *v, unsigned int n) { - unsigned int w = 0 ; - register int r = unsanitize_read(buffer_getvall(b, v, n, &w)) ; + size_t w = 0 ; + ssize_t r = unsanitize_read(buffer_getvall(b, v, n, &w)) ; return r <= 0 ? r : w ; } diff --git a/src/libstddjb/buffer_getvall.c b/src/libstddjb/buffer_getvall.c index e34c547..ba2dfae 100644 --- a/src/libstddjb/buffer_getvall.c +++ b/src/libstddjb/buffer_getvall.c @@ -1,14 +1,16 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> #include <errno.h> #include <skalibs/allreadwrite.h> #include <skalibs/buffer.h> #include <skalibs/siovec.h> -int buffer_getvall (buffer *b, siovec_t const *v, unsigned int n, unsigned int *written) +int buffer_getvall (buffer *b, struct iovec const *v, unsigned int n, size_t *written) { - unsigned int len = siovec_len(v, n) ; - siovec_t vv[n] ; + size_t len = siovec_len(v, n) ; + struct iovec vv[n ? n : 1] ; if (*written > len) return (errno = EINVAL, -1) ; { register unsigned int i = n ; @@ -17,8 +19,8 @@ int buffer_getvall (buffer *b, siovec_t const *v, unsigned int n, unsigned int * siovec_seek(vv, n, *written) ; for (;;) { - register int r ; - unsigned int w = buffer_getvnofill(b, vv, n) ; + ssize_t r ; + size_t w = buffer_getvnofill(b, vv, n) ; *written += w ; if (*written >= len) break ; siovec_seek(vv, n, w) ; @@ -27,4 +29,3 @@ int buffer_getvall (buffer *b, siovec_t const *v, unsigned int n, unsigned int * } return 1 ; } - diff --git a/src/libstddjb/buffer_getvallnf.c b/src/libstddjb/buffer_getvallnf.c index 15f6c3d..e0e2e5d 100644 --- a/src/libstddjb/buffer_getvallnf.c +++ b/src/libstddjb/buffer_getvallnf.c @@ -1,12 +1,14 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> #include <errno.h> -#include <skalibs/buffer.h> #include <skalibs/siovec.h> +#include <skalibs/buffer.h> -int buffer_getvallnofill (buffer *b, siovec_t const *v, unsigned int n) +int buffer_getvallnofill (buffer *b, struct iovec const *v, unsigned int n) { - register unsigned int r = buffer_getvnofill(b, v, n) ; + size_t r = buffer_getvnofill(b, v, n) ; if (r < siovec_len(v, n)) { buffer_unget(b, r) ; diff --git a/src/libstddjb/buffer_init.c b/src/libstddjb/buffer_init.c index fac648a..27fd4e5 100644 --- a/src/libstddjb/buffer_init.c +++ b/src/libstddjb/buffer_init.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/cbuffer.h> #include <skalibs/functypes.h> #include <skalibs/buffer.h> -int buffer_init (buffer *b, iovfunc_t_ref op, int fd, char *s, unsigned int len) +int buffer_init (buffer *b, iovfunc_t_ref op, int fd, char *s, size_t len) { if (!cbuffer_init(&b->c, s, len)) return 0 ; b->fd = fd ; diff --git a/src/libstddjb/buffer_put.c b/src/libstddjb/buffer_put.c index 56baaa7..5e1fb89 100644 --- a/src/libstddjb/buffer_put.c +++ b/src/libstddjb/buffer_put.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/buffer.h> -int buffer_put (buffer *b, char const *s, unsigned int len) +ssize_t buffer_put (buffer *b, char const *s, size_t len) { - unsigned int w = 0 ; + size_t w = 0 ; if (!buffer_putall(b, s, len, &w)) return -1 ; - return (int)w ; + return (ssize_t)w ; } diff --git a/src/libstddjb/buffer_putall.c b/src/libstddjb/buffer_putall.c index 16facc2..f65b73e 100644 --- a/src/libstddjb/buffer_putall.c +++ b/src/libstddjb/buffer_putall.c @@ -1,9 +1,10 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/buffer.h> -int buffer_putall (buffer *b, char const *s, unsigned int len, unsigned int *written) +int buffer_putall (buffer *b, char const *s, size_t len, size_t *written) { if (*written > len) return (errno = EINVAL, 0) ; for (;;) diff --git a/src/libstddjb/buffer_putallnf.c b/src/libstddjb/buffer_putallnf.c index 1cf3c5e..8ee5c54 100644 --- a/src/libstddjb/buffer_putallnf.c +++ b/src/libstddjb/buffer_putallnf.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/buffer.h> -int buffer_putallnoflush (buffer *b, char const *s, unsigned int len) +int buffer_putallnoflush (buffer *b, char const *s, size_t len) { - register unsigned int r = buffer_putnoflush(b, s, len) ; + ssize_t r = buffer_putnoflush(b, s, len) ; if (r < len) { buffer_unput(b, r) ; diff --git a/src/libstddjb/buffer_putflush.c b/src/libstddjb/buffer_putflush.c index 609d88b..0443180 100644 --- a/src/libstddjb/buffer_putflush.c +++ b/src/libstddjb/buffer_putflush.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/buffer.h> -int buffer_putflush (buffer *b, char const *s, unsigned int len) +ssize_t buffer_putflush (buffer *b, char const *s, size_t len) { - int r = buffer_put(b, s, len) ; + ssize_t r = buffer_put(b, s, len) ; if (r < 0) return -1 ; if (!buffer_flush(b)) return -1 ; return r ; diff --git a/src/libstddjb/buffer_puts.c b/src/libstddjb/buffer_puts.c index aaaac2e..84acca8 100644 --- a/src/libstddjb/buffer_puts.c +++ b/src/libstddjb/buffer_puts.c @@ -1,9 +1,10 @@ /* ISC license. */ -#include <skalibs/bytestr.h> +#include <sys/types.h> +#include <string.h> #include <skalibs/buffer.h> -int buffer_puts (buffer *b, char const *s) +ssize_t buffer_puts (buffer *b, char const *s) { - return buffer_put(b, s, str_len(s)) ; + return buffer_put(b, s, strlen(s)) ; } diff --git a/src/libstddjb/buffer_putsall.c b/src/libstddjb/buffer_putsall.c index dbd306c..382f74b 100644 --- a/src/libstddjb/buffer_putsall.c +++ b/src/libstddjb/buffer_putsall.c @@ -1,9 +1,10 @@ /* ISC license. */ -#include <skalibs/bytestr.h> +#include <sys/types.h> +#include <string.h> #include <skalibs/buffer.h> -int buffer_putsall (buffer *b, char const *s, unsigned int *w) +int buffer_putsall (buffer *b, char const *s, size_t *w) { - return buffer_putall(b, s, str_len(s), w) ; + return buffer_putall(b, s, strlen(s), w) ; } diff --git a/src/libstddjb/buffer_putsallflush.c b/src/libstddjb/buffer_putsallflush.c index fa4c98c..a63cca7 100644 --- a/src/libstddjb/buffer_putsallflush.c +++ b/src/libstddjb/buffer_putsallflush.c @@ -1,9 +1,10 @@ /* ISC license. */ -#include <skalibs/bytestr.h> +#include <sys/types.h> +#include <string.h> #include <skalibs/buffer.h> -int buffer_putsallflush (buffer *b, char const *s, unsigned int *w) +int buffer_putsallflush (buffer *b, char const *s, size_t *w) { - return buffer_putallflush(b, s, str_len(s), w) ; + return buffer_putallflush(b, s, strlen(s), w) ; } diff --git a/src/libstddjb/buffer_putsallnoflush.c b/src/libstddjb/buffer_putsallnoflush.c index 0056cb4..e0d7e36 100644 --- a/src/libstddjb/buffer_putsallnoflush.c +++ b/src/libstddjb/buffer_putsallnoflush.c @@ -1,9 +1,9 @@ /* ISC license. */ -#include <skalibs/bytestr.h> +#include <string.h> #include <skalibs/buffer.h> int buffer_putsallnoflush (buffer *b, char const *s) { - return buffer_putallnoflush(b, s, str_len(s)) ; + return buffer_putallnoflush(b, s, strlen(s)) ; } diff --git a/src/libstddjb/buffer_putsflush.c b/src/libstddjb/buffer_putsflush.c index 4be4c34..fc54a3e 100644 --- a/src/libstddjb/buffer_putsflush.c +++ b/src/libstddjb/buffer_putsflush.c @@ -1,9 +1,10 @@ /* ISC license. */ -#include <skalibs/bytestr.h> +#include <sys/types.h> +#include <string.h> #include <skalibs/buffer.h> -int buffer_putsflush (buffer *b, char const *s) +ssize_t buffer_putsflush (buffer *b, char const *s) { - return buffer_putflush(b, s, str_len(s)) ; + return buffer_putflush(b, s, strlen(s)) ; } diff --git a/src/libstddjb/buffer_putsnoflush.c b/src/libstddjb/buffer_putsnoflush.c index ad6b372..06d12d1 100644 --- a/src/libstddjb/buffer_putsnoflush.c +++ b/src/libstddjb/buffer_putsnoflush.c @@ -1,9 +1,9 @@ /* ISC license. */ -#include <skalibs/bytestr.h> +#include <string.h> #include <skalibs/buffer.h> -int buffer_putsnoflush (buffer *b, char const *s) +size_t buffer_putsnoflush (buffer *b, char const *s) { - return buffer_putnoflush(b, s, str_len(s)) ; + return buffer_putnoflush(b, s, strlen(s)) ; } diff --git a/src/libstddjb/buffer_putv.c b/src/libstddjb/buffer_putv.c index fc46811..bd902ae 100644 --- a/src/libstddjb/buffer_putv.c +++ b/src/libstddjb/buffer_putv.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> #include <skalibs/buffer.h> -#include <skalibs/siovec.h> -int buffer_putv (buffer *b, siovec_t const *v, unsigned int n) +ssize_t buffer_putv (buffer *b, struct iovec const *v, unsigned int n) { - unsigned int w = 0 ; - return buffer_putvall(b, v, n, &w) ? w : -1 ; + size_t w = 0 ; + return buffer_putvall(b, v, n, &w) ? (ssize_t)w : -1 ; } diff --git a/src/libstddjb/buffer_putvall.c b/src/libstddjb/buffer_putvall.c index 22b7ae4..b04ac36 100644 --- a/src/libstddjb/buffer_putvall.c +++ b/src/libstddjb/buffer_putvall.c @@ -1,14 +1,16 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> #include <errno.h> -#include <skalibs/buffer.h> #include <skalibs/siovec.h> +#include <skalibs/buffer.h> -int buffer_putvall (buffer *b, siovec_t const *v, unsigned int n, unsigned int *written) +int buffer_putvall (buffer *b, struct iovec const *v, unsigned int n, size_t *written) { - unsigned int len = siovec_len(v, n) ; - unsigned int w = n ; - siovec_t vv[n] ; + size_t len = siovec_len(v, n) ; + size_t w = n ; + struct iovec vv[n ? n : 1] ; if (*written > len) return (errno = EINVAL, 0) ; while (w--) vv[w] = v[w] ; w = *written ; diff --git a/src/libstddjb/buffer_putvallnf.c b/src/libstddjb/buffer_putvallnf.c index cada660..6f87d13 100644 --- a/src/libstddjb/buffer_putvallnf.c +++ b/src/libstddjb/buffer_putvallnf.c @@ -1,11 +1,14 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> #include <errno.h> +#include <skalibs/siovec.h> #include <skalibs/buffer.h> -int buffer_putvallnoflush (buffer *b, siovec_t const *v, unsigned int n) +int buffer_putvallnoflush (buffer *b, struct iovec const *v, unsigned int n) { - register unsigned int r = buffer_putvnoflush(b, v, n) ; + size_t r = buffer_putvnoflush(b, v, n) ; if (r < siovec_len(v, n)) { buffer_unput(b, r) ; diff --git a/src/libstddjb/buffer_putvflush.c b/src/libstddjb/buffer_putvflush.c index 46f9e03..4bbb329 100644 --- a/src/libstddjb/buffer_putvflush.c +++ b/src/libstddjb/buffer_putvflush.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> #include <skalibs/buffer.h> -#include <skalibs/siovec.h> -int buffer_putvflush (buffer *b, siovec_t const *v, unsigned int n) +ssize_t buffer_putvflush (buffer *b, struct iovec const *v, unsigned int n) { - int r = buffer_putv(b, v, n) ; + ssize_t r = buffer_putv(b, v, n) ; if (r < 0) return -1 ; if (!buffer_flush(b)) return -1 ; return r ; diff --git a/src/libstddjb/byte_copy.c b/src/libstddjb/byte_copy.c deleted file mode 100644 index 410fb95..0000000 --- a/src/libstddjb/byte_copy.c +++ /dev/null @@ -1,14 +0,0 @@ -/* ISC license. */ - -#include <skalibs/config.h> - -#ifdef SKALIBS_FLAG_REPLACE_LIBC - -#include <skalibs/bytestr.h> - -void byte_copy (register char *to, register unsigned int n, register char const *from) -{ - while (n--) *to++ = *from++ ; -} - -#endif diff --git a/src/libstddjb/byte_cr.c b/src/libstddjb/byte_cr.c deleted file mode 100644 index d81e7cf..0000000 --- a/src/libstddjb/byte_cr.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ISC license. */ - -#include <skalibs/config.h> - -#ifdef SKALIBS_FLAG_REPLACE_LIBC - -#include <skalibs/bytestr.h> - -void byte_copyr (register char *to, register unsigned int n, register char const *from) -{ - to += n ; - from += n ; - for (;;) - { - if (!n) return; *--to = *--from; --n; - if (!n) return; *--to = *--from; --n; - if (!n) return; *--to = *--from; --n; - if (!n) return; *--to = *--from; --n; - } -} - -#endif diff --git a/src/libstddjb/byte_diff.c b/src/libstddjb/byte_diff.c deleted file mode 100644 index 9e7f107..0000000 --- a/src/libstddjb/byte_diff.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ISC license. */ - -#include <skalibs/config.h> - -#ifdef SKALIBS_FLAG_REPLACE_LIBC - -#include <skalibs/bytestr.h> - -int byte_diff (register char const *s, register unsigned int n, register char const *t) -{ - for (;;) - { - if (!n) return 0; if (*s != *t) break; ++s; ++t; --n; - if (!n) return 0; if (*s != *t) break; ++s; ++t; --n; - if (!n) return 0; if (*s != *t) break; ++s; ++t; --n; - if (!n) return 0; if (*s != *t) break; ++s; ++t; --n; - } - return ((int)(unsigned int)(unsigned char) *s) - - ((int)(unsigned int)(unsigned char) *t) ; -} - -#endif diff --git a/src/libstddjb/byte_in.c b/src/libstddjb/byte_in.c index cb6e5bc..f777991 100644 --- a/src/libstddjb/byte_in.c +++ b/src/libstddjb/byte_in.c @@ -1,14 +1,15 @@ /* ISC license. */ #include <sys/types.h> +#include <string.h> #include <skalibs/bytestr.h> size_t byte_in (char const *s, size_t n, char const *sep, size_t len) { - register char const *t = s ; + char const *t = s ; while (n--) { - if (byte_chr(sep, len, *t) < len) break ; + if (memchr(sep, *t, len)) break ; ++t ; } return t - s ; diff --git a/src/libstddjb/byte_zero.c b/src/libstddjb/byte_zero.c deleted file mode 100644 index 6751210..0000000 --- a/src/libstddjb/byte_zero.c +++ /dev/null @@ -1,15 +0,0 @@ -/* ISC license. */ - -#include <skalibs/config.h> - -#ifdef SKALIBS_FLAG_REPLACE_LIBC - -#include <skalibs/bytestr.h> - -void byte_zero (void *p, register unsigned int n) -{ - register char *s = (char *)p ; - while (n--) *s++ = 0 ; -} - -#endif diff --git a/src/libstddjb/case_diffn.c b/src/libstddjb/case_diffn.c deleted file mode 100644 index 0e75aa5..0000000 --- a/src/libstddjb/case_diffn.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ISC license. */ - -#include <skalibs/config.h> -#include <skalibs/bytestr.h> - -#ifdef SKALIBS_FLAG_REPLACE_LIBC - -int case_diffn (char const *s, char const *t, unsigned int len) -{ - register unsigned char x = 0, y = 0 ; - unsigned char const d = 'a' - 'A' ; - - while (len-- && (x == y)) - { - x = *s++ ; - if (('a' <= x) && (x <= 'z')) x -= d ; - y = *t++ ; - if (('a' <= y) && (y <= 'z')) y -= d ; - } - return (int)(x - y) ; -} - -#endif diff --git a/src/libstddjb/case_diffs.c b/src/libstddjb/case_diffs.c deleted file mode 100644 index 621a8fa..0000000 --- a/src/libstddjb/case_diffs.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ISC license. */ - -#include <skalibs/config.h> -#include <skalibs/bytestr.h> - -#ifdef SKALIBS_FLAG_REPLACE_LIBC - -int case_diffs (char const *s, char const *t) -{ - register unsigned char x = 1, y = 1 ; - unsigned char const d = 'a' - 'A' ; - - while (x && (x == y)) - { - x = *s++ ; - if (('a' <= x) && (x <= 'z')) x -= d ; - y = *t++ ; - if (('a' <= y) && (y <= 'z')) y -= d ; - } - return (int)(x - y) ; -} - -#endif diff --git a/src/libstddjb/cbuffer_get.c b/src/libstddjb/cbuffer_get.c index d322a03..c490c26 100644 --- a/src/libstddjb/cbuffer_get.c +++ b/src/libstddjb/cbuffer_get.c @@ -1,12 +1,14 @@ /* ISC license. */ -#include <skalibs/cbuffer.h> +#include <sys/types.h> +#include <sys/uio.h> #include <skalibs/siovec.h> +#include <skalibs/cbuffer.h> -unsigned int cbuffer_get (cbuffer_t *b, char *s, unsigned int len) +size_t cbuffer_get (cbuffer_t *b, char *s, size_t len) { - siovec_t v[2] ; - register unsigned int w ; + struct iovec v[2] ; + size_t w ; cbuffer_rpeek(b, v) ; w = siovec_gather(v, 2, s, len) ; return cbuffer_RSEEK(b, w) ; diff --git a/src/libstddjb/cbuffer_getv.c b/src/libstddjb/cbuffer_getv.c index 22bd6f7..f27d054 100644 --- a/src/libstddjb/cbuffer_getv.c +++ b/src/libstddjb/cbuffer_getv.c @@ -1,12 +1,14 @@ /* ISC license. */ -#include <skalibs/cbuffer.h> +#include <sys/types.h> +#include <sys/uio.h> #include <skalibs/siovec.h> +#include <skalibs/cbuffer.h> -unsigned int cbuffer_getv (cbuffer_t *b, siovec_t const *v, unsigned int n) +size_t cbuffer_getv (cbuffer_t *b, struct iovec const *v, unsigned int n) { - siovec_t vsrc[2] ; - register unsigned int w ; + struct iovec vsrc[2] ; + size_t w ; cbuffer_rpeek(b, vsrc) ; w = siovec_deal(v, n, vsrc, 2) ; return cbuffer_RSEEK(b, w) ; diff --git a/src/libstddjb/cbuffer_init.c b/src/libstddjb/cbuffer_init.c index eba4765..24ee8b3 100644 --- a/src/libstddjb/cbuffer_init.c +++ b/src/libstddjb/cbuffer_init.c @@ -1,9 +1,10 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/cbuffer.h> -int cbuffer_init (cbuffer_t *b, char *s, unsigned int len) +int cbuffer_init (cbuffer_t *b, char *s, size_t len) { if (len < 2) return (errno = EINVAL, 0) ; b->x = s ; diff --git a/src/libstddjb/cbuffer_put.c b/src/libstddjb/cbuffer_put.c index 5733d21..2a5fcf8 100644 --- a/src/libstddjb/cbuffer_put.c +++ b/src/libstddjb/cbuffer_put.c @@ -1,12 +1,14 @@ /* ISC license. */ -#include <skalibs/cbuffer.h> +#include <sys/types.h> +#include <sys/uio.h> #include <skalibs/siovec.h> +#include <skalibs/cbuffer.h> -unsigned int cbuffer_put (cbuffer_t *b, char const *s, unsigned int len) +size_t cbuffer_put (cbuffer_t *b, char const *s, size_t len) { - siovec_t v[2] ; - register unsigned int w ; + struct iovec v[2] ; + size_t w ; cbuffer_wpeek(b, v) ; w = siovec_scatter(v, 2, s, len) ; return cbuffer_WSEEK(b, w) ; diff --git a/src/libstddjb/cbuffer_putv.c b/src/libstddjb/cbuffer_putv.c index 6a914de..2fcdee6 100644 --- a/src/libstddjb/cbuffer_putv.c +++ b/src/libstddjb/cbuffer_putv.c @@ -1,12 +1,14 @@ /* ISC license. */ -#include <skalibs/cbuffer.h> +#include <sys/types.h> +#include <sys/uio.h> #include <skalibs/siovec.h> +#include <skalibs/cbuffer.h> -unsigned int cbuffer_putv (cbuffer_t *b, siovec_t const *v, unsigned int n) +size_t cbuffer_putv (cbuffer_t *b, struct iovec const *v, unsigned int n) { - siovec_t vdest[2] ; - register unsigned int w ; + struct iovec vdest[2] ; + size_t w ; cbuffer_wpeek(b, vdest) ; w = siovec_deal(vdest, 2, v, n) ; return cbuffer_WSEEK(b, w) ; diff --git a/src/libstddjb/cbuffer_rpeek.c b/src/libstddjb/cbuffer_rpeek.c index 22a1ef5..58cb207 100644 --- a/src/libstddjb/cbuffer_rpeek.c +++ b/src/libstddjb/cbuffer_rpeek.c @@ -1,21 +1,21 @@ /* ISC license. */ +#include <sys/uio.h> #include <skalibs/cbuffer.h> -#include <skalibs/siovec.h> -void cbuffer_rpeek (cbuffer_t *b, siovec_t *v) +void cbuffer_rpeek (cbuffer_t *b, struct iovec *v) { - v[0].s = b->x + b->p ; + v[0].iov_base = b->x + b->p ; if (b->n >= b->p) { - v[0].len = b->n - b->p ; - v[1].s = 0 ; - v[1].len = 0 ; + v[0].iov_len = b->n - b->p ; + v[1].iov_base = 0 ; + v[1].iov_len = 0 ; } else { - v[0].len = b->a - b->p ; - v[1].s = b->x ; - v[1].len = b->n ; + v[0].iov_len = b->a - b->p ; + v[1].iov_base = b->x ; + v[1].iov_len = b->n ; } } diff --git a/src/libstddjb/cbuffer_rseek.c b/src/libstddjb/cbuffer_rseek.c index 4a98511..98532af 100644 --- a/src/libstddjb/cbuffer_rseek.c +++ b/src/libstddjb/cbuffer_rseek.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/cbuffer.h> -unsigned int cbuffer_rseek (cbuffer_t *b, unsigned int len) +size_t cbuffer_rseek (cbuffer_t *b, size_t len) { - register unsigned int max = cbuffer_len(b) ; + size_t max = cbuffer_len(b) ; if (len > max) len = max ; return cbuffer_RSEEK(b, len) ; } diff --git a/src/libstddjb/cbuffer_unget.c b/src/libstddjb/cbuffer_unget.c index d1591e6..8ada7fe 100644 --- a/src/libstddjb/cbuffer_unget.c +++ b/src/libstddjb/cbuffer_unget.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/cbuffer.h> -unsigned int cbuffer_unget (cbuffer_t *b, unsigned int len) +size_t cbuffer_unget (cbuffer_t *b, size_t len) { - register unsigned int max = cbuffer_available(b) ; + size_t max = cbuffer_available(b) ; if (len > max) len = max ; return cbuffer_UNGET(b, len) ; } diff --git a/src/libstddjb/cbuffer_unput.c b/src/libstddjb/cbuffer_unput.c index 8221ca0..40f8f92 100644 --- a/src/libstddjb/cbuffer_unput.c +++ b/src/libstddjb/cbuffer_unput.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/cbuffer.h> -unsigned int cbuffer_unput (cbuffer_t *b, unsigned int len) +size_t cbuffer_unput (cbuffer_t *b, size_t len) { - register unsigned int max = cbuffer_len(b) ; + size_t max = cbuffer_len(b) ; if (len > max) len = max ; return cbuffer_UNPUT(b, len) ; } diff --git a/src/libstddjb/cbuffer_wpeek.c b/src/libstddjb/cbuffer_wpeek.c index a2c6a63..a1e502e 100644 --- a/src/libstddjb/cbuffer_wpeek.c +++ b/src/libstddjb/cbuffer_wpeek.c @@ -1,22 +1,23 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> #include <skalibs/cbuffer.h> -#include <skalibs/siovec.h> -void cbuffer_wpeek (cbuffer_t *b, siovec_t *v) +void cbuffer_wpeek (cbuffer_t *b, struct iovec *v) { - unsigned int last = (b->a - 1 + b->p) % b->a ; - v[0].s = b->x + b->n ; + size_t last = (b->a - 1 + b->p) % b->a ; + v[0].iov_base = b->x + b->n ; if (last >= b->n) { - v[0].len = last - b->n ; - v[1].s = 0 ; - v[1].len = 0 ; + v[0].iov_len = last - b->n ; + v[1].iov_base = 0 ; + v[1].iov_len = 0 ; } else { - v[0].len = b->a - b->n ; - v[1].s = b->x ; - v[1].len = last ; + v[0].iov_len = b->a - b->n ; + v[1].iov_base = b->x ; + v[1].iov_len = last ; } } diff --git a/src/libstddjb/cbuffer_wseek.c b/src/libstddjb/cbuffer_wseek.c index 6b90ab6..3d44d44 100644 --- a/src/libstddjb/cbuffer_wseek.c +++ b/src/libstddjb/cbuffer_wseek.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/cbuffer.h> -unsigned int cbuffer_wseek (cbuffer_t *b, unsigned int len) +size_t cbuffer_wseek (cbuffer_t *b, size_t len) { - register unsigned int max = cbuffer_available(b) ; + size_t max = cbuffer_available(b) ; if (len > max) len = max ; return cbuffer_WSEEK(b, len) ; } diff --git a/src/libstddjb/child_spawn.c b/src/libstddjb/child_spawn.c index 78b45ac..db00bd3 100644 --- a/src/libstddjb/child_spawn.c +++ b/src/libstddjb/child_spawn.c @@ -49,10 +49,10 @@ pid_t child_spawn (char const *prog, char const *const *argv, char const *const int p[n ? n : 1][2] ; pid_t pid ; int e ; - unsigned int m = sizeof(NOFDVAR) ; + size_t m = sizeof(NOFDVAR) ; unsigned int i = 0 ; char modifs[m + 1 + n * UINT_FMT] ; - byte_copy(modifs, sizeof(NOFDVAR), NOFDVAR "=") ; + memcpy(modifs, NOFDVAR "=", sizeof(NOFDVAR)) ; for (; i < n ; i++) if (pipe(p[i]) < 0) { e = errno ; goto errpi ; } for (i = 0 ; i < n ; i++) if ((ndelay_on(p[i][i & 1]) < 0) || (coe(p[i][i & 1]) < 0)) @@ -96,7 +96,7 @@ pid_t child_spawn (char const *prog, char const *const *argv, char const *const } { int haspath = !!env_get("PATH") ; - unsigned int envlen = env_len(envp) ; + size_t envlen = env_len(envp) ; char const *newenv[envlen + 2] ; if (!env_merge(newenv, envlen+2, envp, envlen, modifs, m)) goto errsp ; if (!haspath && (setenv("PATH", SKALIBS_DEFAULTPATH, 0) < 0)) @@ -119,10 +119,10 @@ pid_t child_spawn (char const *prog, char const *const *argv, char const *const if (pid < 0) { e = errno ; goto errsp ; } else if (!pid) { - unsigned int len = str_len(PROG) ; + size_t len = strlen(PROG) ; char name[len + 9] ; - byte_copy(name, len, PROG) ; - byte_copy(name + len, 9, " (child)") ; + memcpy(name, PROG, len) ; + memcpy(name + len, " (child)", 9) ; PROG = name ; fd_close(syncpipe[0]) ; if (n >= 2) diff --git a/src/libstddjb/child_spawn0.c b/src/libstddjb/child_spawn0.c index d1eddba..8c114b8 100644 --- a/src/libstddjb/child_spawn0.c +++ b/src/libstddjb/child_spawn0.c @@ -45,7 +45,9 @@ pid_t child_spawn0 (char const *prog, char const *const *argv, char const *const #else #include <unistd.h> +#include <string.h> #include <skalibs/allreadwrite.h> +#include <skalibs/strerr2.h> #include <skalibs/sig.h> #include <skalibs/djbunix.h> @@ -66,6 +68,11 @@ pid_t child_spawn0 (char const *prog, char const *const *argv, char const *const } if (!pid) { + size_t len = strlen(PROG) ; + char name[len + 9] ; + memcpy(name, PROG, len) ; + memcpy(name + len, " (child)", 9) ; + PROG = name ; fd_close(p[0]) ; sig_blocknone() ; pathexec_run(prog, argv, envp) ; diff --git a/src/libstddjb/child_spawn1_internal.c b/src/libstddjb/child_spawn1_internal.c index f833a15..8bd1678 100644 --- a/src/libstddjb/child_spawn1_internal.c +++ b/src/libstddjb/child_spawn1_internal.c @@ -66,7 +66,9 @@ pid_t child_spawn1_internal (char const *prog, char const *const *argv, char con #else +#include <string.h> #include <skalibs/allreadwrite.h> +#include <skalibs/strerr2.h> #include <skalibs/sig.h> pid_t child_spawn1_internal (char const *prog, char const *const *argv, char const *const *envp, int *p, int to) @@ -95,6 +97,11 @@ pid_t child_spawn1_internal (char const *prog, char const *const *argv, char con } if (!pid) { + size_t len = strlen(PROG) ; + char name[len + 9] ; + memcpy(name, PROG, len) ; + memcpy(name + len, " (child)", 9) ; + PROG = name ; fd_close(syncp[0]) ; fd_close(p[!(to & 1)]) ; if (fd_move(to & 1, p[to & 1]) < 0) goto err ; diff --git a/src/libstddjb/child_spawn2.c b/src/libstddjb/child_spawn2.c index 701be26..d17ff7b 100644 --- a/src/libstddjb/child_spawn2.c +++ b/src/libstddjb/child_spawn2.c @@ -21,7 +21,7 @@ #else -#include <skalibs/bytestr.h> +#include <string.h> #include <skalibs/allreadwrite.h> #include <skalibs/sig.h> #include <skalibs/strerr2.h> @@ -87,10 +87,10 @@ pid_t child_spawn2 (char const *prog, char const *const *argv, char const *const if (pid < 0) { e = errno ; goto errsp ; } else if (!pid) { - unsigned int len = str_len(PROG) ; + size_t len = strlen(PROG) ; char name[len + 9] ; - byte_copy(name, len, PROG) ; - byte_copy(name + len, 9, " (child)") ; + memcpy(name, PROG, len) ; + memcpy(name + len, " (child)", 9) ; PROG = name ; fd_close(syncpipe[0]) ; if (fd_move2(fds[0], p[1][0], fds[1], p[0][1]) < 0) goto syncdie ; diff --git a/src/libstddjb/coe.c b/src/libstddjb/coe.c index a12f9cb..9f9f184 100644 --- a/src/libstddjb/coe.c +++ b/src/libstddjb/coe.c @@ -5,7 +5,7 @@ int coe (int fd) { - register int flags = fcntl(fd, F_GETFD, 0) ; - if (flags < 0) return -1 ; - return fcntl(fd, F_SETFD, flags | FD_CLOEXEC) ; + int flags = fcntl(fd, F_GETFD, 0) ; + if (flags < 0) return -1 ; + return fcntl(fd, F_SETFD, flags | FD_CLOEXEC) ; } diff --git a/src/libstddjb/dirname.c b/src/libstddjb/dirname.c deleted file mode 100644 index 1def443..0000000 --- a/src/libstddjb/dirname.c +++ /dev/null @@ -1,19 +0,0 @@ -/* ISC license. */ - -/* MT-unsafe */ - -#include <skalibs/bytestr.h> -#include <skalibs/stralloc.h> -#include <skalibs/djbunix.h> - -char *dirname (char *s) -{ - static stralloc dirname_sa = STRALLOC_ZERO ; - static char dot0[2] = "." ; - char *dot = dot0 ; - if (!s) return dot ; - dirname_sa.len = 0 ; - if (!sadirname(&dirname_sa, s, str_len(s))) return 0 ; - if (!stralloc_0(&dirname_sa)) return 0 ; - return dirname_sa.s ; -} diff --git a/src/libstddjb/doublefork.c b/src/libstddjb/doublefork.c index 5a1f7b1..5d4e0e9 100644 --- a/src/libstddjb/doublefork.c +++ b/src/libstddjb/doublefork.c @@ -19,7 +19,7 @@ pid_t doublefork () { case -1: { - register int e = errno ; + int e = errno ; fd_close(fd[1]) ; fd_close(fd[0]) ; errno = e ; @@ -35,13 +35,13 @@ pid_t doublefork () case -1: _exit(errno) ; case 0: fd_close(fd[1]) ; return 0 ; } - uint64_pack_big(pack, (uint64)pid) ; + uint64_pack_big(pack, pid) ; _exit((allwrite(fd[1], pack, 8) < 8) ? errno : 0) ; } } fd_close(fd[1]) ; { - uint64 grandchild = 0 ; + uint64_t grandchild = 0 ; int wstat ; if (allread(fd[0], pack, 8) < 8) grandchild = 1 ; fd_close(fd[0]) ; diff --git a/src/libstddjb/envdir.c b/src/libstddjb/envdir.c index 7866c7a..6992654 100644 --- a/src/libstddjb/envdir.c +++ b/src/libstddjb/envdir.c @@ -1,6 +1,7 @@ /* ISC license. */ #include <unistd.h> +#include <string.h> #include <errno.h> #include <skalibs/bytestr.h> #include <skalibs/env.h> @@ -14,8 +15,8 @@ int envdir_internal (char const *path, stralloc *modifs, unsigned int options, c { char buf[MAXVARSIZE + 1] ; unsigned int n = 0 ; - unsigned int pathlen = str_len(path) ; - unsigned int modifbase = modifs->len ; + size_t pathlen = strlen(path) ; + size_t modifbase = modifs->len ; int wasnull = !modifs->s ; DIR *dir ; if (!nullis) return (errno = EINVAL, -1) ; @@ -24,19 +25,19 @@ int envdir_internal (char const *path, stralloc *modifs, unsigned int options, c for (;;) { direntry *d ; - unsigned int len ; - register int r ; + size_t len ; + ssize_t r ; errno = 0 ; d = readdir(dir) ; if (!d) break ; if (d->d_name[0] == '.') continue ; - len = str_len(d->d_name) ; + len = strlen(d->d_name) ; if (str_chr(d->d_name, '=') < len) continue ; { char tmp[pathlen + len + 2] ; - byte_copy(tmp, pathlen, path) ; + memcpy(tmp, path, pathlen) ; tmp[pathlen] = '/' ; - byte_copy(tmp + pathlen + 1, len + 1, d->d_name) ; + memcpy(tmp + pathlen + 1, d->d_name, len + 1) ; r = openreadnclose(tmp, buf, MAXVARSIZE) ; } if (r < 0) @@ -60,8 +61,8 @@ int envdir_internal (char const *path, stralloc *modifs, unsigned int options, c } } { - register unsigned int i = 0 ; - for (; i < (unsigned int)r ; i++) if (!buf[i]) buf[i] = nullis ; + size_t i = 0 ; + for (; i < (size_t)r ; i++) if (!buf[i]) buf[i] = nullis ; } buf[r++] = 0 ; if (!env_addmodif(modifs, d->d_name, buf)) goto err ; @@ -75,7 +76,7 @@ int envdir_internal (char const *path, stralloc *modifs, unsigned int options, c err: { - register int e = errno ; + int e = errno ; dir_close(dir) ; if (wasnull) stralloc_free(modifs) ; else modifs->len = modifbase ; errno = e ; diff --git a/src/libstddjb/error_str.c b/src/libstddjb/error_str.c deleted file mode 100644 index 6aca43f..0000000 --- a/src/libstddjb/error_str.c +++ /dev/null @@ -1,277 +0,0 @@ -/* ISC license. */ - -#include <skalibs/config.h> -#include <skalibs/error.h> - -#ifndef SKALIBS_FLAG_REPLACE_LIBC - -#include <string.h> - -char const *error_str (register int i) -{ - return (char const *)strerror(i) ; -} - -#else - -#include <errno.h> - -#define X(e, s) case e : return s ; -#define Y(e, s) if (i == e) return s ; - -char const *error_str (register int i) -{ - Y(EWOULDBLOCK, "input/output would block") - Y(EAGAIN, "temporary failure") - Y(EINVAL, "invalid argument") - - switch (i) - { - X(0, "no error") - X(EINTR, "interrupted system call") - X(ENOMEM, "out of memory") - X(ENOENT, "file does not exist") - X(ETXTBSY, "text busy") - X(EIO, "input/output error") - X(EEXIST, "file already exists") - X(ETIMEDOUT, "timed out") - X(EINPROGRESS, "operation in progress") - X(EPIPE, "broken pipe") - X(EPERM, "permission denied") - X(EACCES, "access denied") - X(ENODEV, "device not configured") - X(EPROTO, "protocol error") - X(EISDIR, "is a directory") - X(ECONNREFUSED, "connection refused") - X(ENOTDIR, "not a directory") - X(ENOTSOCK, "not a socket") - X(EDOM, "input out of range") - X(ENOBUFS, "out of buffer space") - -#ifdef ESRCH - X(ESRCH, "no such process") -#endif -#ifdef E2BIG - X(E2BIG, "argument list too long") -#endif -#ifdef ENOEXEC - X(ENOEXEC, "exec format error") -#endif -#ifdef EBADF - X(EBADF, "file descriptor not open") -#endif -#ifdef ECHILD - X(ECHILD, "no child processes") -#endif -#ifdef EDEADLK - X(EDEADLK, "operation would cause deadlock") -#endif -#ifdef EFAULT - X(EFAULT, "bad address") -#endif -#ifdef ENOTBLK - X(ENOTBLK, "not a block device") -#endif -#ifdef EBUSY - X(EBUSY, "device busy") -#endif -#ifdef EXDEV - X(EXDEV, "cross-device link") -#endif -#ifdef ENFILE - X(ENFILE, "system cannot open more files") -#endif -#ifdef EMFILE - X(EMFILE, "process cannot open more files") -#endif -#ifdef ENOTTY - X(ENOTTY, "not a tty") -#endif -#ifdef EFBIG - X(EFBIG, "file too big") -#endif -#ifdef ENOSPC - X(ENOSPC, "out of disk space") -#endif -#ifdef ESPIPE - X(ESPIPE, "unseekable descriptor") -#endif -#ifdef EROFS - X(EROFS, "read-only file system") -#endif -#ifdef EMLINK - X(EMLINK, "too many links") -#endif -#ifdef ERANGE - X(ERANGE, "output out of range") -#endif -#ifdef EALREADY - X(EALREADY, "operation already in progress") -#endif -#ifdef EDESTADDRREQ - X(EDESTADDRREQ, "destination address required") -#endif -#ifdef EMSGSIZE - X(EMSGSIZE, "message too long") -#endif -#ifdef EPROTOTYPE - X(EPROTOTYPE, "incorrect protocol type") -#endif -#ifdef ENOPROTOOPT - X(ENOPROTOOPT, "protocol not available") -#endif -#ifdef EPROTONOSUPPORT - X(EPROTONOSUPPORT, "protocol not supported") -#endif -#ifdef ESOCKTNOSUPPORT - X(ESOCKTNOSUPPORT, "socket type not supported") -#endif -#ifdef EOPNOTSUPP - X(EOPNOTSUPP, "operation not supported") -#endif -#ifdef EPFNOSUPPORT - X(EPFNOSUPPORT, "protocol family not supported") -#endif -#ifdef EAFNOSUPPORT - X(EAFNOSUPPORT, "address family not supported") -#endif -#ifdef EADDRINUSE - X(EADDRINUSE, "address already used") -#endif -#ifdef EADDRNOTAVAIL - X(EADDRNOTAVAIL, "address not available") -#endif -#ifdef ENETDOWN - X(ENETDOWN, "network down") -#endif -#ifdef ENETUNREACH - X(ENETUNREACH, "network unreachable") -#endif -#ifdef ENETRESET - X(ENETRESET, "network reset") -#endif -#ifdef ECONNABORTED - X(ECONNABORTED, "connection aborted") -#endif -#ifdef ECONNRESET - X(ECONNRESET, "connection reset") -#endif -#ifdef EISCONN - X(EISCONN, "already connected") -#endif -#ifdef ENOTCONN - X(ENOTCONN, "not connected") -#endif -#ifdef ESHUTDOWN - X(ESHUTDOWN, "socket shut down") -#endif -#ifdef ETOOMANYREFS - X(ETOOMANYREFS, "too many references") -#endif -#ifdef ELOOP - X(ELOOP, "symbolic link loop") -#endif -#ifdef ENAMETOOLONG - X(ENAMETOOLONG, "file name too long") -#endif -#ifdef EHOSTDOWN - X(EHOSTDOWN, "host down") -#endif -#ifdef EHOSTUNREACH - X(EHOSTUNREACH, "host unreachable") -#endif -#ifdef ENOTEMPTY - X(ENOTEMPTY, "directory not empty") -#endif -#ifdef EPROCLIM - X(EPROCLIM, "too many processes") -#endif -#ifdef EUSERS - X(EUSERS, "too many users") -#endif -#ifdef EDQUOT - X(EDQUOT, "disk quota exceeded") -#endif -#ifdef ESTALE - X(ESTALE, "stale NFS file handle") -#endif -#ifdef EREMOTE - X(EREMOTE, "too many levels of remote in path") -#endif -#ifdef EBADRPC - X(EBADRPC, "RPC structure is bad") -#endif -#ifdef ERPCMISMATCH - X(ERPCMISMATCH, "RPC version mismatch") -#endif -#ifdef EPROGUNAVAIL - X(EPROGUNAVAIL, "RPC program unavailable") -#endif -#ifdef EPROGMISMATCH - X(EPROGMISMATCH, "program version mismatch") -#endif -#ifdef EPROCUNAVAIL - X(EPROCUNAVAIL, "bad procedure for program") -#endif -#ifdef ENOLCK - X(ENOLCK, "no locks available") -#endif -#ifdef ENOSYS - X(ENOSYS, "system call not available") -#endif -#ifdef EFTYPE - X(EFTYPE, "bad file type") -#endif -#ifdef EAUTH - X(EAUTH, "authentication error") -#endif -#ifdef ENEEDAUTH - X(ENEEDAUTH, "not authenticated") -#endif -#ifdef ENOSTR - X(ENOSTR, "not a stream device") -#endif -#ifdef ETIME - X(ETIME, "timer expired") -#endif -#ifdef ENOSR - X(ENOSR, "out of stream resources") -#endif -#ifdef ENOMSG - X(ENOMSG, "no message of desired type") -#endif -#ifdef EBADMSG - X(EBADMSG, "bad message type") -#endif -#ifdef EIDRM - X(EIDRM, "identifier removed") -#endif -#ifdef ENONET - X(ENONET, "machine not on network") -#endif -#ifdef ERREMOTE - X(ERREMOTE, "object not local") -#endif -#ifdef ENOLINK - X(ENOLINK, "link severed") -#endif -#ifdef EADV - X(EADV, "advertise error") -#endif -#ifdef ESRMNT - X(ESRMNT, "srmount error") -#endif -#ifdef ECOMM - X(ECOMM, "communication error") -#endif -#ifdef EMULTIHOP - X(EMULTIHOP, "multihop attempted") -#endif -#ifdef EREMCHG - X(EREMCHG, "remote address changed") -#endif - default : return "unknown error" ; - } -} - -#endif diff --git a/src/libstddjb/execvep.c b/src/libstddjb/execvep.c index 1639236..3dae8bc 100644 --- a/src/libstddjb/execvep.c +++ b/src/libstddjb/execvep.c @@ -1,6 +1,7 @@ /* ISC license. */ #include <unistd.h> +#include <string.h> #include <errno.h> #include <skalibs/bytestr.h> #include <skalibs/djbunix.h> @@ -12,18 +13,18 @@ void execvep (char const *file, char const *const *argv, char const *const *envp execve(file, (char *const *)argv, (char *const *)envp) ; /* execve prototype sucks */ else { - unsigned int pathlen = str_len(path) + 1 ; - unsigned int filelen = str_len(file) ; + size_t pathlen = strlen(path) + 1 ; + size_t filelen = strlen(file) ; int savederrno = 0 ; while (pathlen) { - unsigned int split = byte_chr(path, pathlen - 1, ':') ; + size_t split = byte_chr(path, pathlen - 1, ':') ; if (split) { char tmp[split + 2 + filelen] ; - byte_copy(tmp, split, path) ; + memcpy(tmp, path, split) ; tmp[split] = '/' ; - byte_copy(tmp + split + 1, filelen + 1, file) ; + memcpy(tmp + split + 1, file, filelen + 1) ; execve(tmp, (char *const *)argv, (char *const *)envp) ; if (errno != ENOENT) { diff --git a/src/libstddjb/fd_read.c b/src/libstddjb/fd_read.c index 9664024..43453b8 100644 --- a/src/libstddjb/fd_read.c +++ b/src/libstddjb/fd_read.c @@ -1,13 +1,12 @@ /* ISC license. */ -#include <sys/types.h> #include <unistd.h> #include <errno.h> #include <skalibs/allreadwrite.h> ssize_t fd_read (int fd, char *buf, size_t len) { - register ssize_t r ; + ssize_t r ; do r = read(fd, buf, len) ; while ((r == -1) && (errno == EINTR)) ; return r ; diff --git a/src/libstddjb/fd_write.c b/src/libstddjb/fd_write.c index c6758fb..a93c2d9 100644 --- a/src/libstddjb/fd_write.c +++ b/src/libstddjb/fd_write.c @@ -1,13 +1,12 @@ /* ISC license. */ -#include <sys/types.h> #include <unistd.h> #include <errno.h> #include <skalibs/allreadwrite.h> ssize_t fd_write (int fd, char const *buf, size_t len) { - register ssize_t r ; + ssize_t r ; do r = write(fd, buf, len) ; while ((r == -1) && (errno == EINTR)) ; return r ; diff --git a/src/libstddjb/filecopy_suffix.c b/src/libstddjb/filecopy_suffix.c index 70673ea..3cc5218 100644 --- a/src/libstddjb/filecopy_suffix.c +++ b/src/libstddjb/filecopy_suffix.c @@ -1,22 +1,22 @@ /* ISC license. */ +#include <string.h> #include <errno.h> #include <unistd.h> #include <stdio.h> -#include <skalibs/bytestr.h> #include <skalibs/djbunix.h> int filecopy_suffix (char const *src, char const *dst, unsigned int mode, char const *suffix) { - unsigned int dstlen = str_len(dst) ; - unsigned int suffixlen = str_len(suffix) ; + size_t dstlen = strlen(dst) ; + size_t suffixlen = strlen(suffix) ; char tmp[dstlen + suffixlen + 1] ; - byte_copy(tmp, dstlen, dst) ; - byte_copy(tmp + dstlen, suffixlen + 1, suffix) ; + memcpy(tmp, dst, dstlen) ; + memcpy(tmp + dstlen, suffix, suffixlen + 1) ; if (!filecopy_unsafe(src, tmp, mode)) return 0 ; if (rename(tmp, dst) < 0) { - register int e = errno ; + int e = errno ; unlink(tmp) ; errno = e ; return 0 ; diff --git a/src/libstddjb/filecopy_unsafe.c b/src/libstddjb/filecopy_unsafe.c index b60c783..68bcc5b 100644 --- a/src/libstddjb/filecopy_unsafe.c +++ b/src/libstddjb/filecopy_unsafe.c @@ -12,14 +12,14 @@ int filecopy_unsafe (char const *src, char const *dst, unsigned int mode) d = open3(dst, O_WRONLY | O_CREAT | O_TRUNC, mode) ; if (d < 0) { - register int e = errno ; + int e = errno ; fd_close(s) ; errno = e ; return 0 ; } if (fd_cat(s, d) < 0) { - register int e = errno ; + int e = errno ; fd_close(d) ; fd_close(s) ; errno = e ; diff --git a/src/libstddjb/getlnmax.c b/src/libstddjb/getlnmax.c index e3fde8f..6f6783a 100644 --- a/src/libstddjb/getlnmax.c +++ b/src/libstddjb/getlnmax.c @@ -1,19 +1,21 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> #include <errno.h> #include <skalibs/bytestr.h> #include <skalibs/buffer.h> #include <skalibs/skamisc.h> -int getlnmax (buffer *b, char *d, unsigned int max, unsigned int *w, char sep) +int getlnmax (buffer *b, char *d, size_t max, size_t *w, char sep) { if (max < *w) return (errno = EINVAL, -1) ; for (;;) { - siovec_t v[2] ; - unsigned int len = buffer_len(b) ; - unsigned int pos ; - int r ; + struct iovec v[2] ; + size_t len = buffer_len(b) ; + size_t pos ; + ssize_t r ; buffer_rpeek(b, v) ; if (len > max - *w) len = max - *w ; pos = siovec_bytechr(v, 2, sep) ; diff --git a/src/libstddjb/getlnmaxsep.c b/src/libstddjb/getlnmaxsep.c index 2bde443..8505417 100644 --- a/src/libstddjb/getlnmaxsep.c +++ b/src/libstddjb/getlnmaxsep.c @@ -1,19 +1,21 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> #include <errno.h> -#include <skalibs/bytestr.h> #include <skalibs/buffer.h> +#include <skalibs/siovec.h> #include <skalibs/skamisc.h> -int getlnmaxsep (buffer *b, char *d, unsigned int max, unsigned int *w, char const *sep, unsigned int seplen) +int getlnmaxsep (buffer *b, char *d, size_t max, size_t *w, char const *sep, size_t seplen) { if (max < *w) return (errno = EINVAL, -1) ; for (;;) { - siovec_t v[2] ; - unsigned int len = buffer_len(b) ; - unsigned int pos ; - int r ; + struct iovec v[2] ; + size_t len = buffer_len(b) ; + size_t pos ; + ssize_t r ; buffer_rpeek(b, v) ; if (len > max - *w) len = max - *w ; pos = siovec_bytein(v, 2, sep, seplen) ; diff --git a/src/libstddjb/hiercopy_tmp.c b/src/libstddjb/hiercopy_tmp.c index bcff2b2..ef76b57 100644 --- a/src/libstddjb/hiercopy_tmp.c +++ b/src/libstddjb/hiercopy_tmp.c @@ -2,10 +2,10 @@ #include <sys/types.h> #include <sys/stat.h> +#include <string.h> #include <unistd.h> #include <errno.h> #include <fcntl.h> -#include <skalibs/bytestr.h> #include <skalibs/strerr2.h> #include <skalibs/stralloc.h> #include <skalibs/direntry.h> @@ -13,22 +13,22 @@ static int dircopy (char const *src, char const *dst, mode_t mode, stralloc *tmp) { - unsigned int tmpbase = tmp->len ; - unsigned int maxlen = 0 ; + size_t tmpbase = tmp->len ; + size_t maxlen = 0 ; { DIR *dir = opendir(src) ; if (!dir) return 0 ; for (;;) { direntry *d ; - register unsigned int n ; + size_t n ; errno = 0 ; d = readdir(dir) ; if (!d) break ; if (d->d_name[0] == '.') if (((d->d_name[1] == '.') && !d->d_name[2]) || !d->d_name[1]) continue ; - n = str_len(d->d_name) ; + n = strlen(d->d_name) ; if (n > maxlen) maxlen = n ; if (!stralloc_catb(tmp, d->d_name, n+1)) break ; } @@ -50,20 +50,20 @@ static int dircopy (char const *src, char const *dst, mode_t mode, stralloc *tmp if (!S_ISDIR(st.st_mode)) { errno = ENOTDIR ; goto err ; } } { - unsigned int srclen = str_len(src) ; - unsigned int dstlen = str_len(dst) ; - unsigned int i = tmpbase ; + size_t srclen = strlen(src) ; + size_t dstlen = strlen(dst) ; + size_t i = tmpbase ; char srcbuf[srclen + maxlen + 2] ; char dstbuf[dstlen + maxlen + 2] ; - byte_copy(srcbuf, srclen, src) ; - byte_copy(dstbuf, dstlen, dst) ; + memcpy(srcbuf, src, srclen) ; + memcpy(dstbuf, dst, dstlen) ; srcbuf[srclen] = '/' ; dstbuf[dstlen] = '/' ; while (i < tmp->len) { - register unsigned int n = str_len(tmp->s + i) + 1 ; - byte_copy(srcbuf + srclen + 1, n, tmp->s + i) ; - byte_copy(dstbuf + dstlen + 1, n, tmp->s + i) ; + size_t n = strlen(tmp->s + i) + 1 ; + memcpy(srcbuf + srclen + 1, tmp->s + i, n) ; + memcpy(dstbuf + dstlen + 1, tmp->s + i, n) ; i += n ; hiercopy_tmp(srcbuf, dstbuf, tmp) ; } @@ -94,14 +94,9 @@ int hiercopy_tmp (char const *src, char const *dst, stralloc *tmp) } else if (S_ISLNK(st.st_mode)) { - unsigned int tmpbase = tmp->len ; + size_t tmpbase = tmp->len ; if (sareadlink(tmp, src) < 0) return 0 ; - if (!stralloc_0(tmp)) - { - tmp->len = tmpbase ; - return 0 ; - } - if (symlink(tmp->s + tmpbase, dst) < 0) + if (!stralloc_0(tmp) || symlink(tmp->s + tmpbase, dst) < 0) { tmp->len = tmpbase ; return 0 ; diff --git a/src/libstddjb/iobuffer_kfromu.c b/src/libstddjb/iobuffer_kfromu.c index 7f2feda..7942541 100644 --- a/src/libstddjb/iobuffer_kfromu.c +++ b/src/libstddjb/iobuffer_kfromu.c @@ -13,15 +13,13 @@ int iobuffer_kfromu (iobufferk *k, iobufferu *u) { - struct iovec iov[2] ; - siovec_t v[2] ; - int r ; + struct iovec v[2] ; + ssize_t r ; buffer_rpeek(&u->b[0], v) ; - iovec_from_siovec(iov, v, 2) ; - r = vmsplice(k->p[1], iov, 2, 0) ; + r = vmsplice(k->p[1], v, 2, 0) ; if (r < 0) return 0 ; k->n += r ; - buffer_rseek(&u->b[0], (unsigned int)r) ; + buffer_rseek(&u->b[0], r) ; u->b[1].c.p = u->b[0].c.p ; return iobufferu_isempty(u) ; } diff --git a/src/libstddjb/iovec_from_siovec.c b/src/libstddjb/iovec_from_siovec.c deleted file mode 100644 index 154cca5..0000000 --- a/src/libstddjb/iovec_from_siovec.c +++ /dev/null @@ -1,14 +0,0 @@ -/* ISC license. */ - -#include <sys/types.h> -#include <sys/uio.h> -#include <skalibs/siovec.h> - -void iovec_from_siovec (struct iovec *iov, siovec_t const *v, unsigned int n) -{ - while (n--) - { - iov[n].iov_base = v[n].s ; - iov[n].iov_len = v[n].len ; - } -} diff --git a/src/libstddjb/ip6_fmt.c b/src/libstddjb/ip6_fmt.c index eb6acc0..8d56a90 100644 --- a/src/libstddjb/ip6_fmt.c +++ b/src/libstddjb/ip6_fmt.c @@ -8,7 +8,7 @@ static inline size_t xfmt16 (char *s, char const *key) { - register size_t j = 0 ; + size_t j = 0 ; j += px((unsigned char)key[0] >> 4) ; j += px((unsigned char)key[0] & 15) ; j += px((unsigned char)key[1] >> 4) ; @@ -21,8 +21,8 @@ static inline unsigned int find_colcol (char const *key, unsigned int *pos) diuint z[4] = { DIUINT_ZERO, DIUINT_ZERO, DIUINT_ZERO, DIUINT_ZERO } ; unsigned int j = 0 ; unsigned int max = 0 ; - register int iszero = 0 ; - register unsigned int i = 0 ; + int iszero = 0 ; + unsigned int i = 0 ; for ( ; i < 8 ; i++) { if (key[i<<1] || key[(i<<1)+1]) @@ -59,9 +59,9 @@ static inline unsigned int find_colcol (char const *key, unsigned int *pos) size_t ip6_fmt (char *s, char const *ip6) { size_t w = 0 ; - register unsigned int i = 0 ; unsigned int pos = 8 ; unsigned int len = find_colcol(ip6, &pos) ; + unsigned int i = 0 ; for (; i < 8 ; i++) { if (i == pos) diff --git a/src/libstddjb/lock_ex.c b/src/libstddjb/lock_ex.c index fde901b..19b9a9c 100644 --- a/src/libstddjb/lock_ex.c +++ b/src/libstddjb/lock_ex.c @@ -11,7 +11,7 @@ int lock_ex (int fd) { - register int r ; + int r ; do r = flock(fd, LOCK_EX) ; while ((r == -1) && (errno == EINTR)) ; @@ -27,7 +27,7 @@ int lock_ex (int fd) int lock_ex (int fd) { - register int r ; + int r ; do r = lockf(fd, F_LOCK, 0) ; while ((r == -1) && (errno == EINTR)) ; diff --git a/src/libstddjb/lock_exnb.c b/src/libstddjb/lock_exnb.c index 7fed9f0..a1785a9 100644 --- a/src/libstddjb/lock_exnb.c +++ b/src/libstddjb/lock_exnb.c @@ -11,7 +11,7 @@ int lock_exnb (int fd) { - register int r ; + int r ; do r = flock(fd, LOCK_EX | LOCK_NB) ; while ((r == -1) && (errno == EINTR)) ; @@ -27,7 +27,7 @@ int lock_exnb (int fd) int lock_exnb (int fd) { - register int r ; + int r ; do r = lockf(fd, F_TLOCK, 0) ; while ((r == -1) && (errno == EINTR)) ; diff --git a/src/libstddjb/ndelay_off.c b/src/libstddjb/ndelay_off.c index 828acfa..209fd2b 100644 --- a/src/libstddjb/ndelay_off.c +++ b/src/libstddjb/ndelay_off.c @@ -1,11 +1,10 @@ /* ISC license. */ -#include <sys/types.h> #include <fcntl.h> #include <skalibs/djbunix.h> int ndelay_off (int fd) { - register int got = fcntl(fd, F_GETFL) ; + int got = fcntl(fd, F_GETFL) ; return (got == -1) ? -1 : fcntl(fd, F_SETFL, got & ~O_NONBLOCK) ; } diff --git a/src/libstddjb/ndelay_on.c b/src/libstddjb/ndelay_on.c index 186590b..63ffa58 100644 --- a/src/libstddjb/ndelay_on.c +++ b/src/libstddjb/ndelay_on.c @@ -1,11 +1,10 @@ /* ISC license. */ -#include <sys/types.h> #include <fcntl.h> #include <skalibs/djbunix.h> int ndelay_on (int fd) { - register int got = fcntl(fd, F_GETFL) ; + int got = fcntl(fd, F_GETFL) ; return (got == -1) ? -1 : fcntl(fd, F_SETFL, got | O_NONBLOCK) ; } diff --git a/src/libstddjb/netstring_get.c b/src/libstddjb/netstring_get.c index c2f8b05..dee6821 100644 --- a/src/libstddjb/netstring_get.c +++ b/src/libstddjb/netstring_get.c @@ -2,7 +2,7 @@ #include <sys/types.h> #include <errno.h> -#include <skalibs/uint64.h> +#include <skalibs/types.h> #include <skalibs/allreadwrite.h> #include <skalibs/bytestr.h> #include <skalibs/buffer.h> @@ -16,20 +16,20 @@ int netstring_okeof (buffer *b, size_t w) return (errno == EPIPE) && !w && buffer_isempty(b) ? (errno = 0, 1) : 0 ; } -ssize_t netstring_get (buffer *b, stralloc *sa, size_t *state) +int netstring_get (buffer *b, stralloc *sa, size_t *state) { if (!*state) { size_t n ; size_t len ; - char buf[UINT64_FMT] ; - if (b->c.a < UINT64_FMT+1) return (errno = EINVAL, -1) ; + char buf[SIZE_FMT] ; + if (b->c.a < SIZE_FMT+1) return (errno = EINVAL, -1) ; for (;;) { - register int r ; - len = buffer_getnofill(b, buf, UINT64_FMT) ; + ssize_t r ; + len = buffer_getnofill(b, buf, SIZE_FMT) ; n = byte_chr(buf, len, ':') ; /* XXX: accepts :, as a valid netstring */ - if (n >= UINT64_FMT) + if (n >= SIZE_FMT) { buffer_unget(b, len) ; return (errno = EPROTO, -1) ; @@ -40,13 +40,13 @@ ssize_t netstring_get (buffer *b, stralloc *sa, size_t *state) if (r <= 0) return r ; } buffer_unget(b, len - n - 1) ; - if (!n || n != uint64_scan(buf, &len)) return (errno = EPROTO, -1) ; + if (!n || n != size_scan(buf, &len)) return (errno = EPROTO, -1) ; if (!stralloc_readyplus(sa, len + 1)) return -1 ; *state = len + 1 ; } { size_t w = 0 ; - register ssize_t r = buffer_getall(b, sa->s + sa->len, *state, &w) ; + int r = buffer_getall(b, sa->s + sa->len, *state, &w) ; sa->len += w ; *state -= w ; if (r <= 0) return r ; diff --git a/src/libstddjb/openreadclose.c b/src/libstddjb/openreadclose.c deleted file mode 100644 index cf9a736..0000000 --- a/src/libstddjb/openreadclose.c +++ /dev/null @@ -1,21 +0,0 @@ -/* ISC license. */ - -#include <errno.h> -#include <skalibs/stralloc.h> -#include <skalibs/djbunix.h> - -int openreadclose (char const *fn, stralloc *sa, unsigned int bufsize) -{ - int fd = open_readb(fn) ; - if (fd == -1) return (errno == ENOENT) ? 0 : -1 ; - if (!slurp(sa, fd)) - { - register int e = errno ; - fd_close(fd) ; - errno = e ; - return -1 ; - } - fd_close(fd) ; - (void)bufsize ; - return 0 ; -} diff --git a/src/libstddjb/openreadfileclose.c b/src/libstddjb/openreadfileclose.c index 90e6b47..b78232c 100644 --- a/src/libstddjb/openreadfileclose.c +++ b/src/libstddjb/openreadfileclose.c @@ -7,9 +7,9 @@ #include <skalibs/stralloc.h> #include <skalibs/djbunix.h> -int openreadfileclose (char const *file, stralloc *sa, unsigned int limit) +int openreadfileclose (char const *file, stralloc *sa, size_t limit) { - unsigned int n ; + size_t n ; int fd = open_readb(file) ; if (fd < 0) return 0 ; { @@ -20,7 +20,7 @@ int openreadfileclose (char const *file, stralloc *sa, unsigned int limit) if (limit && (limit < n)) n = limit ; if (!stralloc_ready_tuned(sa, sa->len + n, 0, 0, 1)) goto err ; { - register unsigned int r = allread(fd, sa->s + sa->len, n) ; + size_t r = allread(fd, sa->s + sa->len, n) ; sa->len += r ; if (r < n) goto err ; } @@ -29,7 +29,7 @@ int openreadfileclose (char const *file, stralloc *sa, unsigned int limit) err: { - register int e = errno ; + int e = errno ; fd_close(fd) ; errno = e ; } diff --git a/src/libstddjb/openreadnclose.c b/src/libstddjb/openreadnclose.c index 40edea9..fcecedc 100644 --- a/src/libstddjb/openreadnclose.c +++ b/src/libstddjb/openreadnclose.c @@ -1,27 +1,28 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/allreadwrite.h> #include <skalibs/djbunix.h> -static int readnclose (int fd, char *s, unsigned int n) +static ssize_t readnclose (int fd, char *s, size_t n) { - register int r = allread(fd, s, n) ; - register int e = errno ; + ssize_t r = allread(fd, s, n) ; + int e = errno ; fd_close(fd) ; - if ((r > 0) && (r < (int)n)) e = EPIPE ; + if ((r > 0) && (r < (ssize_t)n)) e = EPIPE ; errno = e ; return r ; } -int openreadnclose (char const *file, char *s, unsigned int n) +ssize_t openreadnclose (char const *file, char *s, size_t n) { - register int fd = open_readb(file) ; + int fd = open_readb(file) ; return fd < 0 ? fd : readnclose(fd, s, n) ; } -int openreadnclose_nb (char const *file, char *s, unsigned int n) +ssize_t openreadnclose_nb (char const *file, char *s, size_t n) { - register int fd = open_read(file) ; + int fd = open_read(file) ; return fd < 0 ? fd : readnclose(fd, s, n) ; } diff --git a/src/libstddjb/openwritenclose_suffix.c b/src/libstddjb/openwritenclose_suffix.c index 1c538ed..8608810 100644 --- a/src/libstddjb/openwritenclose_suffix.c +++ b/src/libstddjb/openwritenclose_suffix.c @@ -1,24 +1,25 @@ /* ISC license. */ +#include <sys/types.h> +#include <string.h> #include <errno.h> #include <unistd.h> -#include <stdio.h> /* for rename() */ -#include <skalibs/uint64.h> -#include <skalibs/bytestr.h> +#include <stdio.h> #include <skalibs/djbunix.h> -int openwritenclose_suffix_internal (char const *fn, char const *s, unsigned int n, uint64 *dev, uint64 *ino, int dosync, char const *suffix) +int openwritenclose_suffix_internal (char const *fn, char const *s, size_t n, dev_t *dev, ino_t *ino, int dosync, char const *suffix) { - uint64 tmpdev, tmpino ; - unsigned int len = str_len(fn) ; - unsigned int suffixlen = str_len(suffix) ; + dev_t tmpdev ; + ino_t tmpino ; + size_t len = strlen(fn) ; + size_t suffixlen = strlen(suffix) ; char tmp[len + suffixlen + 1] ; - byte_copy(tmp, len, fn) ; - byte_copy(tmp + len, suffixlen + 1, suffix) ; + memcpy(tmp, fn, len) ; + memcpy(tmp + len, suffix, suffixlen + 1) ; if (!openwritenclose_unsafe_internal(tmp, s, n, dev ? &tmpdev : 0, ino ? &tmpino : 0, dosync)) return 0 ; if (rename(tmp, fn) < 0) { - register int e = errno ; + int e = errno ; unlink(tmp) ; errno = e ; return 0 ; diff --git a/src/libstddjb/openwritenclose_unsafe.c b/src/libstddjb/openwritenclose_unsafe.c index 427f6a6..3276c3f 100644 --- a/src/libstddjb/openwritenclose_unsafe.c +++ b/src/libstddjb/openwritenclose_unsafe.c @@ -4,11 +4,10 @@ #include <sys/stat.h> #include <errno.h> #include <unistd.h> -#include <skalibs/uint64.h> #include <skalibs/allreadwrite.h> #include <skalibs/djbunix.h> -int openwritenclose_unsafe_internal (char const *fn, char const *s, unsigned int len, uint64 *dev, uint64 *ino, int dosync) +int openwritenclose_unsafe_internal (char const *fn, char const *s, size_t len, dev_t *dev, ino_t *ino, int dosync) { struct stat st ; int fd = open_trunc(fn) ; @@ -17,13 +16,13 @@ int openwritenclose_unsafe_internal (char const *fn, char const *s, unsigned int if ((dev || ino) && (fstat(fd, &st) < 0)) goto fail ; if (dosync && (fd_sync(fd) < 0) && (errno != EINVAL)) goto fail ; fd_close(fd) ; - if (dev) *dev = (uint64)st.st_dev ; - if (ino) *ino = (uint64)st.st_ino ; + if (dev) *dev = st.st_dev ; + if (ino) *ino = st.st_ino ; return 1 ; fail: { - register int e = errno ; + int e = errno ; fd_close(fd) ; unlink(fn) ; errno = e ; diff --git a/src/libstddjb/openwritevnclose_suffix.c b/src/libstddjb/openwritevnclose_suffix.c index 0440960..d0185e6 100644 --- a/src/libstddjb/openwritevnclose_suffix.c +++ b/src/libstddjb/openwritevnclose_suffix.c @@ -1,25 +1,26 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> +#include <string.h> #include <errno.h> #include <unistd.h> #include <stdio.h> -#include <skalibs/uint64.h> -#include <skalibs/bytestr.h> -#include <skalibs/siovec.h> #include <skalibs/djbunix.h> -int openwritevnclose_suffix_internal (char const *fn, siovec_t const *v, unsigned int n, uint64 *dev, uint64 *ino, int dosync, char const *suffix) +int openwritevnclose_suffix_internal (char const *fn, struct iovec const *v, unsigned int n, dev_t *dev, ino_t *ino, int dosync, char const *suffix) { - uint64 tmpdev, tmpino ; - unsigned int len = str_len(fn) ; - unsigned int suffixlen = str_len(suffix) ; + dev_t tmpdev ; + ino_t tmpino ; + size_t len = strlen(fn) ; + size_t suffixlen = strlen(suffix) ; char tmp[len + suffixlen + 1] ; - byte_copy(tmp, len, fn) ; - byte_copy(tmp + len, suffixlen + 1, suffix) ; + memcpy(tmp, fn, len) ; + memcpy(tmp + len, suffix, suffixlen + 1) ; if (!openwritevnclose_unsafe_internal(tmp, v, n, dev ? &tmpdev : 0, ino ? &tmpino : 0, dosync)) return 0 ; if (rename(tmp, fn) < 0) { - register int e = errno ; + int e = errno ; unlink(tmp) ; errno = e ; return 0 ; diff --git a/src/libstddjb/openwritevnclose_unsafe.c b/src/libstddjb/openwritevnclose_unsafe.c index feb2ae5..19c5f88 100644 --- a/src/libstddjb/openwritevnclose_unsafe.c +++ b/src/libstddjb/openwritevnclose_unsafe.c @@ -1,15 +1,15 @@ /* ISC license. */ #include <sys/types.h> +#include <sys/uio.h> #include <sys/stat.h> #include <errno.h> #include <unistd.h> -#include <skalibs/uint64.h> #include <skalibs/allreadwrite.h> #include <skalibs/siovec.h> #include <skalibs/djbunix.h> -int openwritevnclose_unsafe_internal (char const *fn, siovec_t const *v, unsigned int vlen, uint64 *dev, uint64 *ino, int dosync) +int openwritevnclose_unsafe_internal (char const *fn, struct iovec const *v, unsigned int vlen, dev_t *dev, ino_t *ino, int dosync) { struct stat st ; int fd = open_trunc(fn) ; @@ -18,13 +18,13 @@ int openwritevnclose_unsafe_internal (char const *fn, siovec_t const *v, unsigne if ((dev || ino) && (fstat(fd, &st) < 0)) goto fail ; if (dosync && (fd_sync(fd) < 0) && (errno != EINVAL)) goto fail ; fd_close(fd) ; - if (dev) *dev = (uint64)st.st_dev ; - if (ino) *ino = (uint64)st.st_ino ; + if (dev) *dev = st.st_dev ; + if (ino) *ino = st.st_ino ; return 1 ; fail: { - register int e = errno ; + int e = errno ; fd_close(fd) ; unlink(fn) ; errno = e ; diff --git a/src/libstddjb/pathexec_fromenv.c b/src/libstddjb/pathexec_fromenv.c index df8b0e6..f9c973b 100644 --- a/src/libstddjb/pathexec_fromenv.c +++ b/src/libstddjb/pathexec_fromenv.c @@ -11,7 +11,7 @@ int pathexec_env (char const *s, char const *t) /* historic, bad name */ return env_addmodif(&plus, s, t) ; } -void pathexec_fromenv (char const *const *argv, char const *const *envp, unsigned int envlen) +void pathexec_fromenv (char const *const *argv, char const *const *envp, size_t envlen) { pathexec_r(argv, envp, envlen, plus.s, plus.len) ; } diff --git a/src/libstddjb/pathexec_r.c b/src/libstddjb/pathexec_r.c index eb4a894..38420cb 100644 --- a/src/libstddjb/pathexec_r.c +++ b/src/libstddjb/pathexec_r.c @@ -1,8 +1,9 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/djbunix.h> -void pathexec_r (char const *const *argv, char const *const *envp, unsigned int envlen, char const *modifs, unsigned int modiflen) +void pathexec_r (char const *const *argv, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen) { pathexec_r_name(argv[0], argv, envp, envlen, modifs, modiflen) ; } diff --git a/src/libstddjb/pathexec_r_name.c b/src/libstddjb/pathexec_r_name.c index c5caf4e..68016e5 100644 --- a/src/libstddjb/pathexec_r_name.c +++ b/src/libstddjb/pathexec_r_name.c @@ -1,12 +1,13 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/bytestr.h> #include <skalibs/env.h> #include <skalibs/djbunix.h> -void pathexec_r_name (char const *file, char const *const *argv, char const *const *envp, unsigned int envlen, char const *modifs, unsigned int modiflen) +void pathexec_r_name (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen) { - unsigned int n = envlen + 1 + byte_count(modifs, modiflen, '\0') ; + size_t n = envlen + 1 + byte_count(modifs, modiflen, '\0') ; char const *v[n] ; if (env_merge(v, n, envp, envlen, modifs, modiflen)) pathexec_run(file, argv, v) ; diff --git a/src/libstddjb/pathexec_run.c b/src/libstddjb/pathexec_run.c index ced2ae6..4d9b291 100644 --- a/src/libstddjb/pathexec_run.c +++ b/src/libstddjb/pathexec_run.c @@ -6,7 +6,7 @@ void pathexec_run (char const *file, char const *const *argv, char const *const *envp) { - register char const *path = env_get("PATH") ; + char const *path = env_get("PATH") ; if (!path) path = SKALIBS_DEFAULTPATH ; execvep(file, argv, envp, path) ; } diff --git a/src/libstddjb/rm_rf_in_tmp.c b/src/libstddjb/rm_rf_in_tmp.c index 8a0a9ec..cc13e95 100644 --- a/src/libstddjb/rm_rf_in_tmp.c +++ b/src/libstddjb/rm_rf_in_tmp.c @@ -1,19 +1,18 @@ /* ISC license. */ -#include <sys/types.h> #include <unistd.h> #include <errno.h> -#include <skalibs/bytestr.h> +#include <string.h> #include <skalibs/stralloc.h> #include <skalibs/direntry.h> #include <skalibs/djbunix.h> -static int rmstarindir (DIR *dir, stralloc *tmp, unsigned int ipos) /* WARNING: closes dir */ +static int rmstarindir (DIR *dir, stralloc *tmp, size_t ipos) /* WARNING: closes dir */ { - unsigned int tmpbase = tmp->len ; + size_t tmpbase = tmp->len ; for (;;) { - register direntry *d ; + direntry *d ; errno = 0 ; d = readdir(dir) ; if (!d) break ; @@ -26,16 +25,16 @@ static int rmstarindir (DIR *dir, stralloc *tmp, unsigned int ipos) /* WARNING: dir_close(dir) ; { - unsigned int tmpstop = tmp->len ; - unsigned int fnbase = str_len(tmp->s + ipos) ; - unsigned int i = tmpbase ; + size_t tmpstop = tmp->len ; + size_t fnbase = strlen(tmp->s + ipos) ; + size_t i = tmpbase ; if (!stralloc_readyplus(tmp, fnbase+1)) goto err ; stralloc_catb(tmp, tmp->s + ipos, fnbase) ; stralloc_catb(tmp, "/", 1) ; fnbase = tmp->len ; for (; i < tmpstop ; i += tmp->len - fnbase) { - register unsigned int n = str_len(tmp->s + i) ; + size_t n = strlen(tmp->s + i) ; tmp->len = fnbase ; if (!stralloc_readyplus(tmp, n+1)) goto err ; stralloc_catb(tmp, tmp->s + i, n+1) ; @@ -47,7 +46,7 @@ static int rmstarindir (DIR *dir, stralloc *tmp, unsigned int ipos) /* WARNING: closeanderr: { - register int e = errno ; + int e = errno ; dir_close(dir) ; errno = e ; } @@ -56,14 +55,14 @@ err: return -1 ; } -int rm_rf_in_tmp (stralloc *tmp, unsigned int ipos) +int rm_rf_in_tmp (stralloc *tmp, size_t ipos) { if (unlink(tmp->s + ipos) == 0) return 0 ; if (errno == ENOENT) return 0 ; if ((errno != EISDIR) && (errno != EPERM)) return -1 ; { - register int h = (errno == EPERM) ; - register DIR *dir = opendir(tmp->s + ipos) ; + int h = (errno == EPERM) ; + DIR *dir = opendir(tmp->s + ipos) ; if (!dir) { if (h && (errno == ENOTDIR)) errno = EPERM ; @@ -76,11 +75,11 @@ int rm_rf_in_tmp (stralloc *tmp, unsigned int ipos) int rmstar_tmp (char const *dirname, stralloc *tmp) { - unsigned int tmpbase = tmp->len ; + size_t tmpbase = tmp->len ; if (!stralloc_cats(tmp, dirname)) return -1 ; if (!stralloc_0(tmp)) goto err ; { - register DIR *dir = opendir(dirname) ; + DIR *dir = opendir(dirname) ; if (!dir) goto err ; if (rmstarindir(dir, tmp, tmpbase) == -1) goto err ; } diff --git a/src/libstddjb/rm_rf_tmp.c b/src/libstddjb/rm_rf_tmp.c index 6e434d7..d1a8b1a 100644 --- a/src/libstddjb/rm_rf_tmp.c +++ b/src/libstddjb/rm_rf_tmp.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/stralloc.h> #include <skalibs/djbunix.h> int rm_rf_tmp (char const *filename, stralloc *tmp) { - unsigned int tmpbase = tmp->len ; + size_t tmpbase = tmp->len ; if (!stralloc_cats(tmp, filename)) return -1 ; if (!stralloc_0(tmp)) goto err ; if (rm_rf_in_tmp(tmp, tmpbase) == -1) goto err ; diff --git a/src/libstddjb/sabasename.c b/src/libstddjb/sabasename.c index 829b2a7..8d9b6fc 100644 --- a/src/libstddjb/sabasename.c +++ b/src/libstddjb/sabasename.c @@ -1,16 +1,17 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/bytestr.h> #include <skalibs/stralloc.h> #include <skalibs/djbunix.h> -int sabasename (stralloc *sa, char const *s, unsigned int len) +int sabasename (stralloc *sa, char const *s, size_t len) { if (!len) return stralloc_catb(sa, ".", 1) ; while (len && (s[len-1] == '/')) len-- ; if (!len) return stralloc_catb(sa, "/", 1) ; { - register unsigned int i = byte_rchr(s, len, '/') ; + size_t i = byte_rchr(s, len, '/') ; i = (i == len) ? 0 : i+1 ; return stralloc_catb(sa, s + i, len - i) ; } diff --git a/src/libstddjb/sadirname.c b/src/libstddjb/sadirname.c index 9fc4802..ac818e8 100644 --- a/src/libstddjb/sadirname.c +++ b/src/libstddjb/sadirname.c @@ -1,16 +1,17 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/bytestr.h> #include <skalibs/stralloc.h> #include <skalibs/djbunix.h> -int sadirname (stralloc *sa, char const *s, unsigned int len) +int sadirname (stralloc *sa, char const *s, size_t len) { if (!len) return stralloc_catb(sa, ".", 1) ; while (len && (s[len-1] == '/')) len-- ; if (!len) return stralloc_catb(sa, "/", 1) ; { - register unsigned int i = byte_rchr(s, len, '/') ; + size_t i = byte_rchr(s, len, '/') ; return (i == len) ? stralloc_catb(sa, ".", 1) : (i == 0) ? stralloc_catb(sa, "/", 1) : stralloc_catb(sa, s, i) ; diff --git a/src/libstddjb/sig_name.c b/src/libstddjb/sig_name.c index dd5a456..0679055 100644 --- a/src/libstddjb/sig_name.c +++ b/src/libstddjb/sig_name.c @@ -5,7 +5,7 @@ char const *sig_name (int sig) { - register sigtable_t const *p = skalibs_sigtable ; + sigtable_t const *p = skalibs_sigtable ; for (; p->number ; p++) if (sig == p->number) break ; return p->number ? p->name : "???" ; } diff --git a/src/libstddjb/siovec_bytechr.c b/src/libstddjb/siovec_bytechr.c index a825488..8c7e78c 100644 --- a/src/libstddjb/siovec_bytechr.c +++ b/src/libstddjb/siovec_bytechr.c @@ -1,17 +1,19 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> #include <skalibs/bytestr.h> #include <skalibs/siovec.h> -unsigned int siovec_bytechr (siovec_t const *v, unsigned int n, char c) +size_t siovec_bytechr (struct iovec const *v, unsigned int n, char c) { - unsigned int w = 0 ; + size_t w = 0 ; unsigned int i = 0 ; for (; i < n ; i++) { - register unsigned int pos = byte_chr(v[i].s, v[i].len, c) ; + size_t pos = byte_chr((char const *)v[i].iov_base, v[i].iov_len, c) ; w += pos ; - if (pos < v[i].len) break ; + if (pos < v[i].iov_len) break ; } return w ; } diff --git a/src/libstddjb/siovec_bytein.c b/src/libstddjb/siovec_bytein.c index e9db87d..bcf6e59 100644 --- a/src/libstddjb/siovec_bytein.c +++ b/src/libstddjb/siovec_bytein.c @@ -1,17 +1,19 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> #include <skalibs/bytestr.h> #include <skalibs/siovec.h> -unsigned int siovec_bytein (siovec_t const *v, unsigned int n, char const *sep, unsigned int seplen) +size_t siovec_bytein (struct iovec const *v, unsigned int n, char const *sep, size_t seplen) { - unsigned int w = 0 ; + size_t w = 0 ; unsigned int i = 0 ; for (; i < n ; i++) { - register unsigned int pos = byte_in(v[i].s, v[i].len, sep, seplen) ; + size_t pos = byte_in((char const *)v[i].iov_base, v[i].iov_len, sep, seplen) ; w += pos ; - if (pos < v[i].len) break ; + if (pos < v[i].iov_len) break ; } return w ; } diff --git a/src/libstddjb/siovec_deal.c b/src/libstddjb/siovec_deal.c index fffea92..3f802b9 100644 --- a/src/libstddjb/siovec_deal.c +++ b/src/libstddjb/siovec_deal.c @@ -1,24 +1,26 @@ /* ISC license. */ -#include <skalibs/bytestr.h> +#include <sys/types.h> +#include <sys/uio.h> +#include <string.h> #include <skalibs/siovec.h> -unsigned int siovec_deal (siovec_t const *vj, unsigned int nj, siovec_t const *vi, unsigned int ni) +size_t siovec_deal (struct iovec const *vj, unsigned int nj, struct iovec const *vi, unsigned int ni) { - unsigned int w = 0 ; + size_t w = 0 ; + size_t wi = 0 ; + size_t wj = 0 ; unsigned int i = 0 ; unsigned int j = 0 ; - unsigned int wi = 0 ; - unsigned int wj = 0 ; while (i < ni && j < nj) { - register unsigned int tor = vi[i].len - wi ; - register unsigned int tow = vj[j].len - wj ; - register unsigned int len = tor < tow ? tor : tow ; - byte_copy(vj[j].s + wj, len, vi[i].s + wi) ; + size_t tor = vi[i].iov_len - wi ; + size_t tow = vj[j].iov_len - wj ; + size_t len = tor < tow ? tor : tow ; + memmove((char *)vj[j].iov_base + wj, (char const *)vi[i].iov_base + wi, len) ; wi += len ; wj += len ; w += len ; - if (wi >= vi[i].len) { wi = 0 ; i++ ; } - if (wj >= vj[j].len) { wj = 0 ; j++ ; } + if (wi >= vi[i].iov_len) { wi = 0 ; i++ ; } + if (wj >= vj[j].iov_len) { wj = 0 ; j++ ; } } return w ; } diff --git a/src/libstddjb/siovec_from_iovec.c b/src/libstddjb/siovec_from_iovec.c deleted file mode 100644 index ffc0508..0000000 --- a/src/libstddjb/siovec_from_iovec.c +++ /dev/null @@ -1,14 +0,0 @@ -/* ISC license. */ - -#include <sys/types.h> -#include <sys/uio.h> -#include <skalibs/siovec.h> - -void siovec_from_iovec (siovec_t *v, struct iovec const *iov, unsigned int n) -{ - while (n--) - { - v[n].s = iov[n].iov_base ; - v[n].len = iov[n].iov_len ; - } -} diff --git a/src/libstddjb/siovec_gather.c b/src/libstddjb/siovec_gather.c index 23ae28a..b5fcbb7 100644 --- a/src/libstddjb/siovec_gather.c +++ b/src/libstddjb/siovec_gather.c @@ -1,17 +1,19 @@ /* ISC license. */ -#include <skalibs/bytestr.h> +#include <sys/types.h> +#include <sys/uio.h> +#include <string.h> #include <skalibs/siovec.h> -unsigned int siovec_gather (siovec_t const *v, unsigned int n, char *s, unsigned int max) +size_t siovec_gather (struct iovec const *v, unsigned int n, char *s, size_t max) { - unsigned int w = 0 ; - register unsigned int i = 0 ; + size_t w = 0 ; + unsigned int i = 0 ; for (; i < n && w < max ; i++) { - register unsigned int len = v[i].len ; + size_t len = v[i].iov_len ; if ((w + len) > max) len = max - w ; - byte_copy(s + w, len, v[i].s) ; + memmove(s + w, v[i].iov_base, len) ; w += len ; } return w ; diff --git a/src/libstddjb/siovec_len.c b/src/libstddjb/siovec_len.c index 5d53e53..5465fd7 100644 --- a/src/libstddjb/siovec_len.c +++ b/src/libstddjb/siovec_len.c @@ -1,10 +1,12 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> #include <skalibs/siovec.h> -unsigned int siovec_len (siovec_t const *v, register unsigned int n) +size_t siovec_len (struct iovec const *v, unsigned int n) { - register unsigned int w = 0 ; - while (n--) w += v[n].len ; + size_t w = 0 ; + while (n--) w += v[n].iov_len ; return w ; } diff --git a/src/libstddjb/siovec_scatter.c b/src/libstddjb/siovec_scatter.c index 256bef5..3a583f3 100644 --- a/src/libstddjb/siovec_scatter.c +++ b/src/libstddjb/siovec_scatter.c @@ -1,17 +1,19 @@ /* ISC license. */ -#include <skalibs/bytestr.h> +#include <sys/types.h> +#include <sys/uio.h> +#include <string.h> #include <skalibs/siovec.h> -unsigned int siovec_scatter (siovec_t const *v, unsigned int n, char const *s, unsigned int len) +size_t siovec_scatter (struct iovec const *v, unsigned int n, char const *s, size_t len) { - unsigned int w = 0 ; - register unsigned int i = 0 ; + size_t w = 0 ; + unsigned int i = 0 ; for (; i < n && w < len ; i++) { - register unsigned int chunklen = v[i].len ; + size_t chunklen = v[i].iov_len ; if (w + chunklen > len) chunklen = len - w ; - byte_copy(v[i].s, chunklen, s + w) ; + memmove(v[i].iov_base, s + w, chunklen) ; w += chunklen ; } return w ; diff --git a/src/libstddjb/siovec_seek.c b/src/libstddjb/siovec_seek.c index 34a8918..f03b20a 100644 --- a/src/libstddjb/siovec_seek.c +++ b/src/libstddjb/siovec_seek.c @@ -1,24 +1,26 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> #include <skalibs/bytestr.h> #include <skalibs/siovec.h> -unsigned int siovec_seek (siovec_t *v, unsigned int n, unsigned int len) +size_t siovec_seek (struct iovec *v, unsigned int n, size_t len) { - unsigned int w = 0 ; + size_t w = 0 ; register unsigned int i = 0 ; for (; i < n ; i++) { - if (len < v[i].len) break ; - w += v[i].len ; - len -= v[i].len ; - v[i].s = 0 ; - v[i].len = 0 ; + if (len < v[i].iov_len) break ; + w += v[i].iov_len ; + len -= v[i].iov_len ; + v[i].iov_base = 0 ; + v[i].iov_len = 0 ; } if (i < n) { - v[i].s += len ; - v[i].len -= len ; + v[i].iov_base = (char *)v[i].iov_base + len ; + v[i].iov_len -= len ; w += len ; } return w ; diff --git a/src/libstddjb/siovec_trunc.c b/src/libstddjb/siovec_trunc.c index c09225a..ca40922 100644 --- a/src/libstddjb/siovec_trunc.c +++ b/src/libstddjb/siovec_trunc.c @@ -1,18 +1,19 @@ /* ISC license. */ -#include <skalibs/bytestr.h> +#include <sys/types.h> +#include <sys/uio.h> #include <skalibs/siovec.h> -unsigned int siovec_trunc (siovec_t *v, unsigned int n, unsigned int len) +unsigned int siovec_trunc (struct iovec *v, unsigned int n, size_t len) { - register unsigned int i = siovec_len(v, n) ; - if (i < len) return n ; - len = i - len ; - i = n ; + size_t w = siovec_len(v, n) ; + unsigned int i = n ; + if (w < len) return n ; + len = w - len ; while (len && i--) { - register unsigned int w = len > v[i].len ? v[i].len : len ; - v[i].len -= w ; len -= w ; + w = len > v[i].iov_len ? v[i].iov_len : len ; + v[i].iov_len -= w ; len -= w ; } return i ; } diff --git a/src/libstddjb/skagetln.c b/src/libstddjb/skagetln.c index 05775f6..45d81d8 100644 --- a/src/libstddjb/skagetln.c +++ b/src/libstddjb/skagetln.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/buffer.h> #include <skalibs/stralloc.h> @@ -7,10 +8,10 @@ int skagetln (buffer *b, stralloc *sa, char sep) { - unsigned int start = sa->len ; + size_t start = sa->len ; for (;;) { - register int r = skagetln_nofill(b, sa, sep) ; + ssize_t r = skagetln_nofill(b, sa, sep) ; if (r) return r ; r = buffer_fill(b) ; if (r < 0) return r ; diff --git a/src/libstddjb/skagetln_nofill.c b/src/libstddjb/skagetln_nofill.c index 7e25760..ce28921 100644 --- a/src/libstddjb/skagetln_nofill.c +++ b/src/libstddjb/skagetln_nofill.c @@ -1,5 +1,7 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> #include <skalibs/buffer.h> #include <skalibs/siovec.h> #include <skalibs/stralloc.h> @@ -7,8 +9,8 @@ int skagetln_nofill (buffer *b, stralloc *sa, char sep) { - siovec_t v[2] ; - unsigned int pos ; + struct iovec v[2] ; + size_t pos ; int r ; buffer_rpeek(b, v) ; pos = siovec_bytechr(v, 2, sep) ; diff --git a/src/libstddjb/skagetlnsep.c b/src/libstddjb/skagetlnsep.c index 1d3b4ef..f9813f3 100644 --- a/src/libstddjb/skagetlnsep.c +++ b/src/libstddjb/skagetlnsep.c @@ -1,18 +1,20 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> #include <errno.h> #include <skalibs/buffer.h> #include <skalibs/siovec.h> #include <skalibs/stralloc.h> #include <skalibs/skamisc.h> -int skagetlnsep (buffer *b, stralloc *sa, char const *sep, unsigned int seplen) +int skagetlnsep (buffer *b, stralloc *sa, char const *sep, size_t seplen) { - unsigned int start = sa->len ; + size_t start = sa->len ; for (;;) { - siovec_t v[2] ; - unsigned int pos ; + struct iovec v[2] ; + size_t pos ; int r ; buffer_rpeek(b, v) ; pos = siovec_bytein(v, 2, sep, seplen) ; diff --git a/src/libstddjb/str_cpy.c b/src/libstddjb/str_cpy.c deleted file mode 100644 index 179688c..0000000 --- a/src/libstddjb/str_cpy.c +++ /dev/null @@ -1,16 +0,0 @@ -/* ISC license. */ - -#include <skalibs/config.h> - -#ifdef SKALIBS_FLAG_REPLACE_LIBC - -#include <skalibs/bytestr.h> - -unsigned int str_copy (char *s, char const *t) -{ - register unsigned int len = 0 ; - while ((*s = *t)) (s++, t++, len++) ; - return len ; -} - -#endif diff --git a/src/libstddjb/str_diff.c b/src/libstddjb/str_diff.c deleted file mode 100644 index b85288a..0000000 --- a/src/libstddjb/str_diff.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ISC license. */ - -#include <skalibs/config.h> - -#ifdef SKALIBS_FLAG_REPLACE_LIBC - -#include <skalibs/bytestr.h> - -int str_diff (register char const *s, register char const *t) -{ - register char x ; - - for (;;) - { - x = *s; if (x != *t) break; if (!x) break; ++s; ++t; - x = *s; if (x != *t) break; if (!x) break; ++s; ++t; - x = *s; if (x != *t) break; if (!x) break; ++s; ++t; - x = *s; if (x != *t) break; if (!x) break; ++s; ++t; - } - return ((int)(unsigned int)(unsigned char) x) - - ((int)(unsigned int)(unsigned char) *t) ; -} - -#endif diff --git a/src/libstddjb/str_diffn.c b/src/libstddjb/str_diffn.c deleted file mode 100644 index 28f37f6..0000000 --- a/src/libstddjb/str_diffn.c +++ /dev/null @@ -1,19 +0,0 @@ -/* ISC license. */ - -#include <skalibs/config.h> -#include <skalibs/bytestr.h> - -#ifdef SKALIBS_FLAG_REPLACE_LIBC - -int str_diffn (register char const *s, register char const *t, register unsigned int len) -{ - while (len--) - { - if (*s != *t) return *s - *t ; - if (!*s) break ; - s++ ; t++ ; - } - return 0 ; -} - -#endif diff --git a/src/libstddjb/str_len.c b/src/libstddjb/str_len.c deleted file mode 100644 index 75bd1f2..0000000 --- a/src/libstddjb/str_len.c +++ /dev/null @@ -1,16 +0,0 @@ -/* ISC license. */ - -#include <skalibs/config.h> - -#ifdef SKALIBS_FLAG_REPLACE_LIBC - -#include <skalibs/bytestr.h> - -unsigned int str_len (char const *s) -{ - register unsigned int len = 0 ; - while (*s++) len++ ; - return len ; -} - -#endif diff --git a/src/libstddjb/stralloc_catv.c b/src/libstddjb/stralloc_catv.c index 684829c..a0c50aa 100644 --- a/src/libstddjb/stralloc_catv.c +++ b/src/libstddjb/stralloc_catv.c @@ -3,17 +3,14 @@ #include <sys/types.h> #include <string.h> #include <sys/uio.h> +#include <skalibs/siovec.h> #include <skalibs/stralloc.h> int stralloc_catv (stralloc *sa, struct iovec const *v, unsigned int n) { - register unsigned int i = 0 ; - { - size_t total = 0 ; - for (; i < n ; i++) total += v[i].iov_len ; - if (!stralloc_readyplus(sa, total)) return 0 ; - } - for (i = 0 ; i < n ; i++) + unsigned int i = 0 ; + if (!stralloc_readyplus(sa, siovec_len(v, n))) return 0 ; + for ( ; i < n ; i++) { memmove(sa->s + sa->len, v[i].iov_base, v[i].iov_len) ; sa->len += v[i].iov_len ; diff --git a/src/libstddjb/string_format.c b/src/libstddjb/string_format.c index f81b03d..73c2572 100644 --- a/src/libstddjb/string_format.c +++ b/src/libstddjb/string_format.c @@ -1,5 +1,7 @@ /* ISC license. */ +#include <sys/types.h> +#include <string.h> #include <errno.h> #include <skalibs/bytestr.h> #include <skalibs/stralloc.h> @@ -8,10 +10,10 @@ int string_format (stralloc *sa, char const *vars, char const *format, char cons { static unsigned char const tab[2][4] = { "1442", "4833" } ; char class[256] = "3222222222222222222222222222222222222022222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222" ; - unsigned int varlen = str_len(vars) ; - unsigned int base = sa->len ; + size_t varlen = strlen(vars) ; + size_t base = sa->len ; + size_t state = 0 ; int wasnull = !sa->s ; - unsigned int state = 0 ; for (; state < varlen ; state++) if (class[(unsigned char)vars[state]] == '2') diff --git a/src/libstddjb/string_quote.c b/src/libstddjb/string_quote.c index ed00402..37258c5 100644 --- a/src/libstddjb/string_quote.c +++ b/src/libstddjb/string_quote.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/stralloc.h> #include <skalibs/skamisc.h> -int string_quote (stralloc *sa, char const *s, unsigned int len) +int string_quote (stralloc *sa, char const *s, size_t len) { - unsigned int base = sa->len ; + size_t base = sa->len ; int wasnull = !sa->s ; if (!stralloc_catb(sa, "\"", 1)) return 0 ; if (!string_quote_nodelim(sa, s, len) || !stralloc_catb(sa, "\"", 1)) diff --git a/src/libstddjb/string_quote_nodelim.c b/src/libstddjb/string_quote_nodelim.c index dfe41ce..26b612f 100644 --- a/src/libstddjb/string_quote_nodelim.c +++ b/src/libstddjb/string_quote_nodelim.c @@ -1,9 +1,10 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/stralloc.h> #include <skalibs/skamisc.h> -int string_quote_nodelim (stralloc *sa, char const *s, unsigned int len) +int string_quote_nodelim (stralloc *sa, char const *s, size_t len) { return string_quote_nodelim_mustquote(sa, s, len, "\"", 1) ; } diff --git a/src/libstddjb/string_quote_nodelim_mustquote.c b/src/libstddjb/string_quote_nodelim_mustquote.c index e52bce3..a978921 100644 --- a/src/libstddjb/string_quote_nodelim_mustquote.c +++ b/src/libstddjb/string_quote_nodelim_mustquote.c @@ -1,17 +1,17 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/bytestr.h> #include <skalibs/fmtscan.h> #include <skalibs/stralloc.h> #include <skalibs/skamisc.h> -int string_quote_nodelim_mustquote (stralloc *sa, char const *s, unsigned int len, char const *delim, unsigned int delimlen) +int string_quote_nodelim_mustquote (stralloc *sa, char const *s, size_t len, char const *delim, size_t delimlen) { char class[256] = "dddddddaaaaaaaddddddddddddddddddcccccccccccccccceeeeeeeeeeccccccccccccccccccccccccccccccccccbcccceeeeeecccccccecccececececcccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" ; - - unsigned int base = sa->len ; - unsigned int i = 0 ; + size_t base = sa->len ; + size_t i = 0 ; int wasnull = !sa->s ; for (; i < delimlen ; i++) diff --git a/src/libstddjb/string_unquote.c b/src/libstddjb/string_unquote.c index f4482ff..4245014 100644 --- a/src/libstddjb/string_unquote.c +++ b/src/libstddjb/string_unquote.c @@ -1,18 +1,19 @@ /* ISC license. */ +#include <sys/types.h> +#include <string.h> #include <errno.h> -#include <skalibs/bytestr.h> #include <skalibs/skamisc.h> -int string_unquote (char *d, unsigned int *w, char const *s, unsigned int len, unsigned int *r) +int string_unquote (char *d, size_t *w, char const *s, size_t len, size_t *r) { if (!len-- || (*s++ != '"')) return (errno = EINVAL, 0) ; { - unsigned int rr, ww ; - char tmp[len] ; + size_t rr, ww ; + char tmp[len ? len : 1] ; if (!string_unquote_withdelim(tmp, &ww, s, len, &rr, "\"", 1)) return 0 ; if (rr == len) return (errno = EPIPE, 0) ; - byte_copy(d, ww, tmp) ; + memcpy(d, tmp, ww) ; *w = ww ; *r = rr + 2 ; } diff --git a/src/libstddjb/string_unquote_nodelim.c b/src/libstddjb/string_unquote_nodelim.c index 1dc90f1..cabe504 100644 --- a/src/libstddjb/string_unquote_nodelim.c +++ b/src/libstddjb/string_unquote_nodelim.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/skamisc.h> -int string_unquote_nodelim (char *d, char const *s, unsigned int len) +ssize_t string_unquote_nodelim (char *d, char const *s, size_t len) { - unsigned int rr, ww ; + size_t rr, ww ; if (!string_unquote_withdelim(d, &ww, s, len, &rr, 0, 0)) return -1 ; - return (int)ww ; + return (ssize_t)ww ; } diff --git a/src/libstddjb/string_unquote_withdelim.c b/src/libstddjb/string_unquote_withdelim.c index dd52dbd..a3e0a68 100644 --- a/src/libstddjb/string_unquote_withdelim.c +++ b/src/libstddjb/string_unquote_withdelim.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/error.h> #include <skalibs/bytestr.h> @@ -14,9 +15,8 @@ #define SYNTAXERROR 0x02 #define BROKENPIPE 0x01 -int string_unquote_withdelim (char *d, unsigned int *w, char const *s, unsigned int len, unsigned int *r, char const *delim, unsigned int delimlen) +int string_unquote_withdelim (char *d, size_t *w, char const *s, size_t len, size_t *r, char const *delim, size_t delimlen) { - register unsigned int i = 0 ; static unsigned char const actions[5][9] = { { 0, 0, PUSH, PUSH, PUSH, PUSH, PUSH, PUSH, 0 }, @@ -34,6 +34,7 @@ int string_unquote_withdelim (char *d, unsigned int *w, char const *s, unsigned { 6, 6, 0, 6, 0, 0, 6, 6, 6 } } ; unsigned char class[256] = "7777777777777777777777777777777777777777777777772555555555777777777777777777777777777777777707777445554777777767776767673777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777" ; + size_t i = 0 ; unsigned char store = 0 ; unsigned char state = 0 ; for (; i < delimlen ; i++) diff --git a/src/libstddjb/touch.c b/src/libstddjb/touch.c index d85c483..d270251 100644 --- a/src/libstddjb/touch.c +++ b/src/libstddjb/touch.c @@ -11,7 +11,7 @@ int touch (char const *file) { - register int fd = open_create(file) ; + int fd = open_create(file) ; if (fd < 0) return 0 ; if (futimens(fd, 0) < 0) return 0 ; fd_close(fd) ; @@ -27,7 +27,7 @@ int touch (char const *file) int touch (char const *file) { - register int fd = open_create(file) ; + int fd = open_create(file) ; if (fd < 0) return 0 ; if (futimes(fd, 0) < 0) return 0 ; fd_close(fd) ; @@ -41,7 +41,7 @@ int touch (char const *file) int touch (char const *file) { - register int fd = open_create(file) ; + int fd = open_create(file) ; if (fd < 0) return 0 ; fd_close(fd) ; if (utimes(file, 0) < 0) return 0 ; diff --git a/src/libstddjb/uncoe.c b/src/libstddjb/uncoe.c index 61593b9..b6bf430 100644 --- a/src/libstddjb/uncoe.c +++ b/src/libstddjb/uncoe.c @@ -5,7 +5,7 @@ int uncoe (int fd) { - register int flags = fcntl(fd, F_GETFD, 0) ; - if (flags < 0) return -1 ; - return fcntl(fd, F_SETFD, flags & ~FD_CLOEXEC) ; + int flags = fcntl(fd, F_GETFD, 0) ; + if (flags < 0) return -1 ; + return fcntl(fd, F_SETFD, flags & ~FD_CLOEXEC) ; } diff --git a/src/libstddjb/vbaprintf.c b/src/libstddjb/vbaprintf.c index efc2bd1..1c23e8c 100644 --- a/src/libstddjb/vbaprintf.c +++ b/src/libstddjb/vbaprintf.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <stdarg.h> #include <stdio.h> #include <skalibs/stralloc.h> @@ -16,8 +17,8 @@ int vbaprintf (bufalloc *ba, char const *format, va_list args) va_end(ugly) ; } if (r < 0) return r ; - if (!stralloc_readyplus(&ba->x, (unsigned int)r + 1)) return -1 ; - r = vsnprintf(ba->x.s + ba->x.len, (unsigned int)r + 1, format, args) ; + if (!stralloc_readyplus(&ba->x, (size_t)r + 1)) return -1 ; + r = vsnprintf(ba->x.s + ba->x.len, (size_t)r + 1, format, args) ; if (r > 0) ba->x.len += r ; return r ; } diff --git a/src/libstddjb/vbprintf.c b/src/libstddjb/vbprintf.c index a6a75f3..2f8c13b 100644 --- a/src/libstddjb/vbprintf.c +++ b/src/libstddjb/vbprintf.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <stdarg.h> #include <stdio.h> #include <skalibs/buffer.h> @@ -16,8 +17,8 @@ int vbprintf (buffer *b, char const *format, va_list args) } if (r < 0) return r ; { - char buf[(unsigned int)r + 1] ; - r = vsnprintf(buf, (unsigned int)r + 1, format, args) ; + char buf[(size_t)r + 1] ; + r = vsnprintf(buf, (size_t)r + 1, format, args) ; if (r < 0) return r ; if (buffer_put(b, buf, r) < r) return -1 ; } diff --git a/src/libstddjb/wait_nointr.c b/src/libstddjb/wait_nointr.c index 02dcd42..90d6412 100644 --- a/src/libstddjb/wait_nointr.c +++ b/src/libstddjb/wait_nointr.c @@ -7,7 +7,7 @@ pid_t wait_nointr (int *wstat) { - register pid_t r ; + pid_t r ; do r = wait(wstat) ; while ((r == (pid_t)-1) && (errno == EINTR)) ; diff --git a/src/libunixonacid/atomic_rm_rf_tmp.c b/src/libunixonacid/atomic_rm_rf_tmp.c index 5bba785..b6a8422 100644 --- a/src/libunixonacid/atomic_rm_rf_tmp.c +++ b/src/libunixonacid/atomic_rm_rf_tmp.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <stdio.h> #include <skalibs/stralloc.h> @@ -9,8 +10,8 @@ int atomic_rm_rf_tmp (char const *filename, stralloc *tmp) { - unsigned int tmpbase = tmp->len ; - unsigned int start ; + size_t tmpbase = tmp->len ; + size_t start ; if (!stralloc_cats(tmp, ".skalibs-rmrf-") || !stralloc_cats(tmp, filename)) return -1 ; start = tmp->len ; diff --git a/src/libunixonacid/buffer_timed_fill.c b/src/libunixonacid/buffer_timed_fill.c index c6f580f..fc24bc9 100644 --- a/src/libunixonacid/buffer_timed_fill.c +++ b/src/libunixonacid/buffer_timed_fill.c @@ -1,17 +1,18 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/allreadwrite.h> #include <skalibs/buffer.h> #include <skalibs/functypes.h> #include <skalibs/tai.h> #include <skalibs/unix-timed.h> -static int get (buffer *b) +static ssize_t get (buffer *b) { return sanitize_read(buffer_fill(b)) ; } -int buffer_timed_fill (buffer *b, tain_t const *deadline, tain_t *stamp) +ssize_t buffer_timed_fill (buffer *b, tain_t const *deadline, tain_t *stamp) { - return timed_get(b, (initfunc_t_ref)&buffer_getfd, (initfunc_t_ref)&get, deadline, stamp) ; + return timed_get(b, (initfunc_t_ref)&buffer_getfd, (getfunc_t_ref)&get, deadline, stamp) ; } diff --git a/src/libunixonacid/buffer_timed_get.c b/src/libunixonacid/buffer_timed_get.c index af846ff..4eb1033 100644 --- a/src/libunixonacid/buffer_timed_get.c +++ b/src/libunixonacid/buffer_timed_get.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/buffer.h> #include <skalibs/buffer.h> #include <skalibs/tai.h> @@ -9,8 +10,8 @@ struct blah_s { buffer *b ; char *s ; - unsigned int len ; - unsigned int w ; + size_t len ; + size_t w ; } ; static int getfd (struct blah_s *blah) @@ -18,14 +19,14 @@ static int getfd (struct blah_s *blah) return buffer_fd(blah->b) ; } -static int get (struct blah_s *blah) +static ssize_t get (struct blah_s *blah) { return buffer_getall(blah->b, blah->s, blah->len, &blah->w) ; } -unsigned int buffer_timed_get (buffer *b, char *s, unsigned int len, tain_t const *deadline, tain_t *stamp) +size_t buffer_timed_get (buffer *b, char *s, size_t len, tain_t const *deadline, tain_t *stamp) { struct blah_s blah = { .b = b, .s = s, .len = len, .w = 0 } ; - timed_get(&blah, (initfunc_t_ref)&getfd, (initfunc_t_ref)&get, deadline, stamp) ; + timed_get(&blah, (initfunc_t_ref)&getfd, (getfunc_t_ref)&get, deadline, stamp) ; return blah.w ; } diff --git a/src/libunixonacid/dd_cancel.c b/src/libunixonacid/dd_cancel.c index cbd044e..f17525c 100644 --- a/src/libunixonacid/dd_cancel.c +++ b/src/libunixonacid/dd_cancel.c @@ -8,7 +8,7 @@ void dd_cancel (dirdescriptor_t *dd) { dirdescriptor_t zero = DIRDESCRIPTOR_ZERO ; - register int e = errno ; + int e = errno ; fd_close(dd->fd) ; rm_rf_in_tmp(&dd->new, 0) ; stralloc_free(&dd->new) ; diff --git a/src/libunixonacid/dd_commit.c b/src/libunixonacid/dd_commit.c index f4a7b06..b4d1511 100644 --- a/src/libunixonacid/dd_commit.c +++ b/src/libunixonacid/dd_commit.c @@ -1,17 +1,18 @@ /* ISC license. */ +#include <sys/types.h> #include <unistd.h> #include <errno.h> -#include <stdio.h> /* for rename() */ -#include <skalibs/bytestr.h> +#include <stdio.h> +#include <string.h> #include <skalibs/stralloc.h> #include <skalibs/djbunix.h> #include <skalibs/random.h> #include <skalibs/unix-transactional.h> -static char const *mybasename (char const *s, unsigned int len) +static char const *mybasename (char const *s, size_t len) { - register unsigned int i = len ; + size_t i = len ; while (i--) if (s[i] == '/') return s + i + 1 ; return s ; } @@ -19,15 +20,15 @@ static char const *mybasename (char const *s, unsigned int len) int dd_commit (dirdescriptor_t *dd) { dirdescriptor_t zero = DIRDESCRIPTOR_ZERO ; - unsigned int len = str_len(dd->lnkfn) ; - unsigned int oldbase = dd->new.len ; - unsigned int newlnkbase ; + size_t len = strlen(dd->lnkfn) ; + size_t oldbase = dd->new.len ; + size_t newlnkbase ; char const *lnkbn = mybasename(dd->lnkfn, len) ; if (!sadirname(&dd->new, dd->lnkfn, len)) return 0 ; if (!stralloc_catb(&dd->new, "/", 1)) goto fail ; if (sareadlink(&dd->new, dd->lnkfn) < 0) { - unsigned int lnkbnbase = dd->new.len ; + size_t lnkbnbase = dd->new.len ; if (errno != EINVAL) goto fail ; if (!stralloc_cats(&dd->new, lnkbn)) goto fail ; if (!random_sauniquename(&dd->new, 8)) goto fail ; @@ -36,7 +37,7 @@ int dd_commit (dirdescriptor_t *dd) /* /!\ race condition right here: there's no lnkfn in the fs */ if (symlink(dd->new.s + lnkbnbase, dd->lnkfn) < 0) /* now that's VERY BAD if it fails */ { - register int e = errno ; + int e = errno ; rename(dd->new.s + oldbase, dd->lnkfn) ; /* attempt to revert to initial situation */ errno = e ; goto fail ; /* and hope for the best */ @@ -50,7 +51,7 @@ int dd_commit (dirdescriptor_t *dd) if (symlink(dd->new.s, dd->new.s + newlnkbase) < 0) goto fail ; if (rename(dd->new.s + newlnkbase, dd->lnkfn) < 0) { - register int e = errno ; + int e = errno ; unlink(dd->new.s + newlnkbase) ; errno = e ; goto fail ; diff --git a/src/libunixonacid/dd_commit_devino.c b/src/libunixonacid/dd_commit_devino.c index 7155c7b..364e466 100644 --- a/src/libunixonacid/dd_commit_devino.c +++ b/src/libunixonacid/dd_commit_devino.c @@ -2,15 +2,15 @@ #include <sys/types.h> #include <sys/stat.h> -#include <skalibs/uint64.h> +#include <skalibs/types.h> #include <skalibs/unix-transactional.h> -int dd_commit_devino (dirdescriptor_t *dd, uint64 *dev, uint64 *ino) +int dd_commit_devino (dirdescriptor_t *dd, dev_t *dev, ino_t *ino) { struct stat st ; if (fstat(dd->fd, &st) < 0) return 0 ; if (!dd_commit(dd)) return 0 ; - *dev = (uint64)st.st_dev ; - *ino = (uint64)st.st_ino ; + *dev = st.st_dev ; + *ino = st.st_ino ; return 1 ; } diff --git a/src/libunixonacid/dd_open_write.c b/src/libunixonacid/dd_open_write.c index 90518cb..40d3443 100644 --- a/src/libunixonacid/dd_open_write.c +++ b/src/libunixonacid/dd_open_write.c @@ -20,7 +20,7 @@ int dd_open_write (dirdescriptor_t *dd, char const *lnkfn, unsigned int mode) d.fd = open_read(d.new.s) ; if (d.fd < 0) { - register int e = errno ; + int e = errno ; rmdir(d.new.s) ; errno = e ; goto fail ; diff --git a/src/libunixonacid/ipc_timed_recv.c b/src/libunixonacid/ipc_timed_recv.c index 7093c4d..acf3d48 100644 --- a/src/libunixonacid/ipc_timed_recv.c +++ b/src/libunixonacid/ipc_timed_recv.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/functypes.h> #include <skalibs/tai.h> #include <skalibs/webipc.h> @@ -9,7 +10,7 @@ struct blah_s { int fd ; char *s ; - unsigned int len ; + size_t len ; char *path ; } ; @@ -18,13 +19,13 @@ static int getfd (struct blah_s *blah) return blah->fd ; } -static int get (struct blah_s *blah) +static ssize_t get (struct blah_s *blah) { return sanitize_read(ipc_recv(blah->fd, blah->s, blah->len, blah->path)) ; } -int ipc_timed_recv (int fd, char *s, unsigned int len, char *path, tain_t const *deadline, tain_t *stamp) +ssize_t ipc_timed_recv (int fd, char *s, size_t len, char *path, tain_t const *deadline, tain_t *stamp) { struct blah_s blah = { .fd = fd, .s = s, .len = len, .path = path } ; - return timed_get(&blah, (initfunc_t_ref)&getfd, (initfunc_t_ref)&get, deadline, stamp) ; + return timed_get(&blah, (initfunc_t_ref)&getfd, (getfunc_t_ref)&get, deadline, stamp) ; } diff --git a/src/libunixonacid/ipc_timed_send.c b/src/libunixonacid/ipc_timed_send.c index 2129ec7..959c4bc 100644 --- a/src/libunixonacid/ipc_timed_send.c +++ b/src/libunixonacid/ipc_timed_send.c @@ -1,8 +1,6 @@ /* ISC license. */ - /* For OpenBSD, that still doesn't know what self-contained headers are */ #include <sys/types.h> - #include <sys/socket.h> #include <errno.h> #include <skalibs/error.h> @@ -15,20 +13,20 @@ #define MSG_NOSIGNAL 0 #endif -int ipc_timed_send (int fd, char const *s, unsigned int len, tain_t const *deadline, tain_t *stamp) +int ipc_timed_send (int fd, char const *s, size_t len, tain_t const *deadline, tain_t *stamp) { iopause_fd x = { .fd = fd, .events = IOPAUSE_WRITE, .revents = 0 } ; for (;;) { - register int r = iopause_stamp(&x, 1, deadline, stamp) ; + int r = iopause_stamp(&x, 1, deadline, stamp) ; if (r < 0) return 0 ; else if (!r) return (errno = ETIMEDOUT, 0) ; else if (x.revents & IOPAUSE_WRITE) { - if (send(fd, s, len, MSG_NOSIGNAL) == (int)len) break ; + if (send(fd, s, len, MSG_NOSIGNAL) == (ssize_t)len) break ; if (!error_isagain(errno)) return 0 ; } - else if (x.revents & IOPAUSE_EXCEPT) return (send(fd, s, len, MSG_NOSIGNAL) == (int)len) ; + else if (x.revents & IOPAUSE_EXCEPT) return (send(fd, s, len, MSG_NOSIGNAL) == (ssize_t)len) ; } return 1 ; } diff --git a/src/libunixonacid/kolbak_enqueue.c b/src/libunixonacid/kolbak_enqueue.c index 80fce01..0838e99 100644 --- a/src/libunixonacid/kolbak_enqueue.c +++ b/src/libunixonacid/kolbak_enqueue.c @@ -1,12 +1,13 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/kolbak.h> #include <skalibs/unixmessage.h> int kolbak_enqueue (kolbak_queue_t *q, unixmessage_handler_func_t *f, void *data) { - register unsigned int newtail = (q->tail + 1) % q->n ; + size_t newtail = (q->tail + 1) % q->n ; if (newtail == q->head) return (errno = ENOBUFS, 0) ; q->x[q->tail].f = f ; q->x[q->tail].data = data ; diff --git a/src/libunixonacid/kolbak_queue_init.c b/src/libunixonacid/kolbak_queue_init.c index 6d91232..d2f11da 100644 --- a/src/libunixonacid/kolbak_queue_init.c +++ b/src/libunixonacid/kolbak_queue_init.c @@ -1,9 +1,10 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/kolbak.h> -int kolbak_queue_init (kolbak_queue_t *q, kolbak_closure_t *s, unsigned int len) +int kolbak_queue_init (kolbak_queue_t *q, kolbak_closure_t *s, size_t len) { if (len < 2) return (errno = EINVAL, 0) ; q->x = s ; diff --git a/src/libunixonacid/mkdir_unique.c b/src/libunixonacid/mkdir_unique.c index 1eee4c6..83e240e 100644 --- a/src/libunixonacid/mkdir_unique.c +++ b/src/libunixonacid/mkdir_unique.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <sys/stat.h> #include <skalibs/stralloc.h> #include <skalibs/random.h> @@ -7,7 +8,7 @@ int mkdir_unique (stralloc *sa, char const *fn, unsigned int mode) { - unsigned int base = sa->len ; + size_t base = sa->len ; int wasnull = !sa->s ; if (!stralloc_cats(sa, fn)) return 0 ; if (!stralloc_cats(sa, "/mkdir_unique:")) goto fail ; diff --git a/src/libunixonacid/netstring_timed_get.c b/src/libunixonacid/netstring_timed_get.c index 04ace6c..c8c954d 100644 --- a/src/libunixonacid/netstring_timed_get.c +++ b/src/libunixonacid/netstring_timed_get.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/buffer.h> #include <skalibs/stralloc.h> @@ -11,10 +12,10 @@ int netstring_timed_get (buffer *b, stralloc *sa, tain_t const *deadline, tain_t *stamp) { iopause_fd x = { .fd = buffer_fd(b), .events = IOPAUSE_READ } ; - unsigned int w = 0 ; + size_t w = 0 ; for (;;) { - register int r = netstring_get(b, sa, &w) ; + int r = netstring_get(b, sa, &w) ; if (r > 0) return r ; if (r < 0) return 0 ; r = iopause_stamp(&x, 1, deadline, stamp) ; diff --git a/src/libunixonacid/open2_at.c b/src/libunixonacid/open2_at.c index 4deb837..625ec20 100644 --- a/src/libunixonacid/open2_at.c +++ b/src/libunixonacid/open2_at.c @@ -33,7 +33,7 @@ int open2_at (int dirfd, char const *file, int flags) if (fdhere < 0) return -1 ; if (fd_chdir(dirfd) < 0) { - register int e = errno ; + int e = errno ; fd_close(fdhere) ; errno = e ; return -1 ; @@ -41,7 +41,7 @@ int open2_at (int dirfd, char const *file, int flags) fd = open2(file, flags) ; if (fd < 0) { - register int e = errno ; + int e = errno ; fd_chdir(fdhere) ; fd_close(fdhere) ; errno = e ; @@ -49,7 +49,7 @@ int open2_at (int dirfd, char const *file, int flags) } if (fd_chdir(fdhere) < 0) { - register int e = errno ; + int e = errno ; fd_close(fdhere) ; errno = e ; return -1 ; diff --git a/src/libunixonacid/open3_at.c b/src/libunixonacid/open3_at.c index d9c7222..f92fa59 100644 --- a/src/libunixonacid/open3_at.c +++ b/src/libunixonacid/open3_at.c @@ -33,7 +33,7 @@ int open3_at (int dirfd, char const *file, int flags, unsigned int mode) if (fdhere < 0) return -1 ; if (fd_chdir(dirfd) < 0) { - register int e = errno ; + int e = errno ; fd_close(fdhere) ; errno = e ; return -1 ; @@ -41,7 +41,7 @@ int open3_at (int dirfd, char const *file, int flags, unsigned int mode) fd = open3(file, flags, mode) ; if (fd < 0) { - register int e = errno ; + int e = errno ; fd_chdir(fdhere) ; fd_close(fdhere) ; errno = e ; @@ -49,7 +49,7 @@ int open3_at (int dirfd, char const *file, int flags, unsigned int mode) } if (fd_chdir(fdhere) < 0) { - register int e = errno ; + int e = errno ; fd_close(fdhere) ; errno = e ; return -1 ; diff --git a/src/libunixonacid/opengetlnclose.c b/src/libunixonacid/opengetlnclose.c index 90940af..2615c6b 100644 --- a/src/libunixonacid/opengetlnclose.c +++ b/src/libunixonacid/opengetlnclose.c @@ -12,8 +12,8 @@ int opengetlnclose (char const *fn, stralloc *sa, int sep) { char buf[BUFFER_INSIZE] ; buffer b ; - register int r ; - register int e ; + int r ; + int e ; int fd = open_readb(fn) ; if (fd < 0) return -1 ; buffer_init(&b, &fd_readv, fd, buf, BUFFER_INSIZE) ; diff --git a/src/libunixonacid/opengetlnclose_at.c b/src/libunixonacid/opengetlnclose_at.c index e91acbf..7d2bee3 100644 --- a/src/libunixonacid/opengetlnclose_at.c +++ b/src/libunixonacid/opengetlnclose_at.c @@ -12,8 +12,8 @@ int opengetlnclose_at (int dirfd, char const *fn, stralloc *sa, int sep) { char buf[BUFFER_INSIZE] ; buffer b ; - register int r ; - register int e ; + int r ; + int e ; int fd = open_readatb(dirfd, fn) ; if (fd < 0) return -1 ; buffer_init(&b, &fd_readv, fd, buf, BUFFER_INSIZE) ; diff --git a/src/libunixonacid/openreadnclose_at.c b/src/libunixonacid/openreadnclose_at.c index 4e8209d..fb58935 100644 --- a/src/libunixonacid/openreadnclose_at.c +++ b/src/libunixonacid/openreadnclose_at.c @@ -1,14 +1,15 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/allreadwrite.h> #include <skalibs/djbunix.h> #include <skalibs/unix-transactional.h> -unsigned int openreadnclose_at (int dirfd, char const *file, char *s, unsigned int n) +size_t openreadnclose_at (int dirfd, char const *file, char *s, size_t n) { - register unsigned int r ; - register int e ; + size_t r ; + int e ; int fd = open_readatb(dirfd, file) ; if (fd < 0) return 0 ; r = allread(fd, s, n) ; diff --git a/src/libunixonacid/openslurpclose_at.c b/src/libunixonacid/openslurpclose_at.c index cf2f8ee..24a2d1c 100644 --- a/src/libunixonacid/openslurpclose_at.c +++ b/src/libunixonacid/openslurpclose_at.c @@ -11,7 +11,7 @@ int openslurpclose_at (int dirfd, char const *fn, stralloc *sa) if (fd < 0) return 0 ; if (!slurp(sa, fd)) { - register int e = errno ; + int e = errno ; fd_close(fd) ; errno = e ; return 0 ; diff --git a/src/libunixonacid/openwritenclose.c b/src/libunixonacid/openwritenclose.c index 09149e2..2c5ffb7 100644 --- a/src/libunixonacid/openwritenclose.c +++ b/src/libunixonacid/openwritenclose.c @@ -2,10 +2,11 @@ /* MT-unsafe */ +#include <sys/types.h> #include <skalibs/skamisc.h> #include <skalibs/unix-transactional.h> -int openwritenclose (char const *fn, char const *s, unsigned int len) +int openwritenclose (char const *fn, char const *s, size_t len) { return openwritenclose_tmp(fn, s, len, &satmp) ; } diff --git a/src/libunixonacid/openwritenclose_at.c b/src/libunixonacid/openwritenclose_at.c index fe92a5e..3fea94c 100644 --- a/src/libunixonacid/openwritenclose_at.c +++ b/src/libunixonacid/openwritenclose_at.c @@ -6,15 +6,15 @@ #include <skalibs/djbunix.h> #include <skalibs/unix-transactional.h> -unsigned int openwritenclose_at (int dirfd, char const *file, char const *s, unsigned int n) +size_t openwritenclose_at (int dirfd, char const *file, char const *s, size_t n) { - register unsigned int r ; + size_t r ; int fd = open_truncatb(dirfd, file) ; if (fd < 0) return 0 ; r = allwrite(fd, s, n) ; if ((r < n) || (fsync(fd) < 0)) { - register int e = errno ; + int e = errno ; fd_close(fd) ; errno = e ; return r ; diff --git a/src/libunixonacid/openwritenclose_devino.c b/src/libunixonacid/openwritenclose_devino.c index 5edc646..28e686e 100644 --- a/src/libunixonacid/openwritenclose_devino.c +++ b/src/libunixonacid/openwritenclose_devino.c @@ -2,11 +2,12 @@ /* MT-unsafe */ -#include <skalibs/uint64.h> +#include <sys/types.h> +#include <skalibs/types.h> #include <skalibs/skamisc.h> #include <skalibs/unix-transactional.h> -int openwritenclose_devino (char const *fn, char const *s, unsigned int len, uint64 *dev, uint64 *ino) +int openwritenclose_devino (char const *fn, char const *s, size_t len, dev_t *dev, ino_t *ino) { return openwritenclose_devino_tmp(fn, s, len, dev, ino, &satmp) ; } diff --git a/src/libunixonacid/openwritenclose_devino_tmp.c b/src/libunixonacid/openwritenclose_devino_tmp.c index 0fe032c..49eec93 100644 --- a/src/libunixonacid/openwritenclose_devino_tmp.c +++ b/src/libunixonacid/openwritenclose_devino_tmp.c @@ -1,25 +1,27 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <unistd.h> -#include <stdio.h> /* for rename() */ -#include <skalibs/uint64.h> +#include <stdio.h> +#include <skalibs/types.h> #include <skalibs/stralloc.h> #include <skalibs/djbunix.h> #include <skalibs/random.h> #include <skalibs/unix-transactional.h> -int openwritenclose_devino_tmp (char const *fn, char const *s, unsigned int len, uint64 *dev, uint64 *ino, stralloc *tmp) +int openwritenclose_devino_tmp (char const *fn, char const *s, size_t len, dev_t *dev, ino_t *ino, stralloc *tmp) { - uint64 tmpdev, tmpino ; - unsigned int base = tmp->len ; + dev_t tmpdev ; + ino_t tmpino ; + size_t base = tmp->len ; if (!stralloc_cats(tmp, fn)) return 0 ; if (!random_sauniquename(tmp, 8)) goto fail ; if (!stralloc_0(tmp)) goto fail ; if (!openwritenclose_unsafe_devino_sync(tmp->s + base, s, len, &tmpdev, &tmpino)) goto fail ; if (rename(tmp->s + base, fn) < 0) { - register int e = errno ; + int e = errno ; unlink(tmp->s + base) ; errno = e ; goto fail ; diff --git a/src/libunixonacid/openwritenclose_tmp.c b/src/libunixonacid/openwritenclose_tmp.c index 1ada80b..5b3fe15 100644 --- a/src/libunixonacid/openwritenclose_tmp.c +++ b/src/libunixonacid/openwritenclose_tmp.c @@ -1,11 +1,13 @@ /* ISC license. */ -#include <skalibs/uint64.h> +#include <sys/types.h> +#include <skalibs/types.h> #include <skalibs/stralloc.h> #include <skalibs/unix-transactional.h> -int openwritenclose_tmp (char const *fn, char const *s, unsigned int len, stralloc *tmp) +int openwritenclose_tmp (char const *fn, char const *s, size_t len, stralloc *tmp) { - uint64 dev, ino ; + dev_t dev ; + ino_t ino ; return openwritenclose_devino_tmp(fn, s, len, &dev, &ino, tmp) ; } diff --git a/src/libunixonacid/openwritevnclose_at.c b/src/libunixonacid/openwritevnclose_at.c index 7cff485..518187a 100644 --- a/src/libunixonacid/openwritevnclose_at.c +++ b/src/libunixonacid/openwritevnclose_at.c @@ -1,5 +1,7 @@ /* ISC license. */ +#include <sys/types.h> +#include <sys/uio.h> #include <unistd.h> #include <errno.h> #include <skalibs/allreadwrite.h> @@ -7,15 +9,15 @@ #include <skalibs/djbunix.h> #include <skalibs/unix-transactional.h> -unsigned int openwritevnclose_at (int dirfd, char const *file, siovec_t const *v, unsigned int n) +size_t openwritevnclose_at (int dirfd, char const *file, struct iovec const *v, unsigned int n) { - register unsigned int r ; + size_t r ; int fd = open_truncatb(dirfd, file) ; if (fd < 0) return 0 ; r = allwritev(fd, v, n) ; if (r < siovec_len(v, n) || fsync(fd) < 0) { - register int e = errno ; + int e = errno ; fd_close(fd) ; errno = e ; return r ; diff --git a/src/libunixonacid/skaclient-internal.h b/src/libunixonacid/skaclient-internal.h index 3c73d1f..b26152b 100644 --- a/src/libunixonacid/skaclient-internal.h +++ b/src/libunixonacid/skaclient-internal.h @@ -3,11 +3,12 @@ #ifndef SKACLIENT_INTERNAL_H #define SKACLIENT_INTERNAL_H +#include <sys/types.h> #include <skalibs/kolbak.h> #include <skalibs/unixmessage.h> #include <skalibs/skaclient.h> -extern int skaclient_init (skaclient_t *, int, char *, unsigned int, char *, unsigned int, char *, unsigned int, char *, unsigned int, kolbak_closure_t *, unsigned int, char const *, unsigned int) ; +extern int skaclient_init (skaclient_t *, int, char *, size_t, char *, size_t, char *, size_t, char *, size_t, kolbak_closure_t *, size_t, char const *, size_t) ; extern int skaclient_start_cb (unixmessage_t const *, skaclient_cbdata_t *) ; #endif diff --git a/src/libunixonacid/skaclient_init.c b/src/libunixonacid/skaclient_init.c index 89ed59c..0ab4137 100644 --- a/src/libunixonacid/skaclient_init.c +++ b/src/libunixonacid/skaclient_init.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/kolbak.h> #include <skalibs/skaclient.h> #include <skalibs/unixmessage.h> @@ -9,17 +10,17 @@ int skaclient_init ( skaclient_t *a, int fd, char *bufss, - unsigned int bufsn, + size_t bufsn, char *auxbufss, - unsigned int auxbufsn, + size_t auxbufsn, char *bufas, - unsigned int bufan, + size_t bufan, char *auxbufas, - unsigned int auxbufan, + size_t auxbufan, kolbak_closure_t *q, - unsigned int qlen, + size_t qlen, char const *before, - unsigned int beforelen) + size_t beforelen) { unixmessage_t msg = { .s = (char *)before, .len = beforelen, .fds = 0, .nfds = 0 } ; if (!unixmessage_receiver_init(&a->syncin, fd, bufss, bufsn, auxbufss, auxbufsn) diff --git a/src/libunixonacid/skaclient_put.c b/src/libunixonacid/skaclient_put.c index 5e3dc92..d15c0ec 100644 --- a/src/libunixonacid/skaclient_put.c +++ b/src/libunixonacid/skaclient_put.c @@ -1,9 +1,10 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/skaclient.h> #include <skalibs/unixmessage.h> -int skaclient_put (skaclient_t *a, char const *s, unsigned int len, unixmessage_handler_func_t *cb, void *result) +int skaclient_put (skaclient_t *a, char const *s, size_t len, unixmessage_handler_func_t *cb, void *result) { unixmessage_t m = { .s = (char *)s, .len = len, .fds = 0, .nfds = 0 } ; return skaclient_putmsg(a, &m, cb, result) ; diff --git a/src/libunixonacid/skaclient_putmsg.c b/src/libunixonacid/skaclient_putmsg.c index 9dcb37d..d1cb68e 100644 --- a/src/libunixonacid/skaclient_putmsg.c +++ b/src/libunixonacid/skaclient_putmsg.c @@ -4,7 +4,7 @@ #include <skalibs/skaclient.h> #include <skalibs/unixmessage.h> -int skaclient_putmsg_and_close (skaclient_t *a, unixmessage_t const *m, unsigned char const *bits, unixmessage_handler_func_t *cb, void *result) +int skaclient_putmsg_and_close (skaclient_t *a, unixmessage_t const *m, unsigned char const *bits, unixmessage_handler_func_t_ref cb, void *result) { if (!kolbak_enqueue(&a->kq, cb, result)) return 0 ; if (!unixmessage_put_and_close(&a->syncout, m, bits)) diff --git a/src/libunixonacid/skaclient_putmsgv.c b/src/libunixonacid/skaclient_putmsgv.c index e53935a..fb0b866 100644 --- a/src/libunixonacid/skaclient_putmsgv.c +++ b/src/libunixonacid/skaclient_putmsgv.c @@ -4,7 +4,7 @@ #include <skalibs/skaclient.h> #include <skalibs/unixmessage.h> -int skaclient_putmsgv_and_close (skaclient_t *a, unixmessage_v_t const *m, unsigned char const *bits, unixmessage_handler_func_t *cb, void *result) +int skaclient_putmsgv_and_close (skaclient_t *a, unixmessage_v_t const *m, unsigned char const *bits, unixmessage_handler_func_t_ref cb, void *result) { if (!kolbak_enqueue(&a->kq, cb, result)) return 0 ; if (!unixmessage_putv_and_close(&a->syncout, m, bits)) diff --git a/src/libunixonacid/skaclient_putv.c b/src/libunixonacid/skaclient_putv.c index c41b092..8a5276e 100644 --- a/src/libunixonacid/skaclient_putv.c +++ b/src/libunixonacid/skaclient_putv.c @@ -1,11 +1,11 @@ /* ISC license. */ -#include <skalibs/siovec.h> +#include <sys/uio.h> #include <skalibs/skaclient.h> #include <skalibs/unixmessage.h> -int skaclient_putv (skaclient_t *a, siovec_t const *v, unsigned int vlen, unixmessage_handler_func_t *cb, void *result) +int skaclient_putv (skaclient_t *a, struct iovec const *v, unsigned int vlen, unixmessage_handler_func_t *cb, void *result) { - unixmessage_v_t m = { .v = (siovec_t *)v, .vlen = vlen, .fds = 0, .nfds = 0 } ; + unixmessage_v_t m = { .v = (struct iovec *)v, .vlen = vlen, .fds = 0, .nfds = 0 } ; return skaclient_putmsgv(a, &m, cb, result) ; } diff --git a/src/libunixonacid/skaclient_send.c b/src/libunixonacid/skaclient_send.c index 38dcddb..2e63c34 100644 --- a/src/libunixonacid/skaclient_send.c +++ b/src/libunixonacid/skaclient_send.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/tai.h> #include <skalibs/unixmessage.h> #include <skalibs/skaclient.h> -int skaclient_send (skaclient_t *a, char const *s, unsigned int len, unixmessage_handler_func_t *cb, void *result, tain_t const *deadline, tain_t *stamp) +int skaclient_send (skaclient_t *a, char const *s, size_t len, unixmessage_handler_func_t *cb, void *result, tain_t const *deadline, tain_t *stamp) { unixmessage_t m = { .s = (char *)s, .len = len, .fds = 0, .nfds = 0 } ; return skaclient_sendmsg(a, &m, cb, result, deadline, stamp) ; diff --git a/src/libunixonacid/skaclient_sendmsg.c b/src/libunixonacid/skaclient_sendmsg.c index 49cfbea..371e84a 100644 --- a/src/libunixonacid/skaclient_sendmsg.c +++ b/src/libunixonacid/skaclient_sendmsg.c @@ -4,7 +4,7 @@ #include <skalibs/unixmessage.h> #include <skalibs/skaclient.h> -int skaclient_sendmsg_and_close (skaclient_t *a, unixmessage_t const *m, unsigned char const *bits, unixmessage_handler_func_t *cb, void *result, tain_t const *deadline, tain_t *stamp) +int skaclient_sendmsg_and_close (skaclient_t *a, unixmessage_t const *m, unsigned char const *bits, unixmessage_handler_func_t_ref cb, void *result, tain_t const *deadline, tain_t *stamp) { return skaclient_putmsg_and_close(a, m, bits, cb, result) && skaclient_syncify(a, deadline, stamp) ; diff --git a/src/libunixonacid/skaclient_sendmsgv.c b/src/libunixonacid/skaclient_sendmsgv.c index 6584173..91467a2 100644 --- a/src/libunixonacid/skaclient_sendmsgv.c +++ b/src/libunixonacid/skaclient_sendmsgv.c @@ -4,7 +4,7 @@ #include <skalibs/unixmessage.h> #include <skalibs/skaclient.h> -int skaclient_sendmsgv_and_close (skaclient_t *a, unixmessage_v_t const *m, unsigned char const *bits, unixmessage_handler_func_t *cb, void *result, tain_t const *deadline, tain_t *stamp) +int skaclient_sendmsgv_and_close (skaclient_t *a, unixmessage_v_t const *m, unsigned char const *bits, unixmessage_handler_func_t_ref cb, void *result, tain_t const *deadline, tain_t *stamp) { return skaclient_putmsgv_and_close(a, m, bits, cb, result) && skaclient_syncify(a, deadline, stamp) ; diff --git a/src/libunixonacid/skaclient_sendv.c b/src/libunixonacid/skaclient_sendv.c index a140768..224a38a 100644 --- a/src/libunixonacid/skaclient_sendv.c +++ b/src/libunixonacid/skaclient_sendv.c @@ -1,12 +1,12 @@ /* ISC license. */ -#include <skalibs/siovec.h> +#include <sys/uio.h> #include <skalibs/skaclient.h> #include <skalibs/tai.h> #include <skalibs/unixmessage.h> -int skaclient_sendv (skaclient_t *a, siovec_t const *v, unsigned int vlen, unixmessage_handler_func_t *cb, void *result, tain_t const *deadline, tain_t *stamp) +int skaclient_sendv (skaclient_t *a, struct iovec const *v, unsigned int vlen, unixmessage_handler_func_t *cb, void *result, tain_t const *deadline, tain_t *stamp) { - unixmessage_v_t m = { .v = (siovec_t *)v, .vlen = vlen, .fds = 0, .nfds = 0 } ; + unixmessage_v_t m = { .v = (struct iovec *)v, .vlen = vlen, .fds = 0, .nfds = 0 } ; return skaclient_sendmsgv(a, &m, cb, result, deadline, stamp) ; } diff --git a/src/libunixonacid/skaclient_server_ack.c b/src/libunixonacid/skaclient_server_ack.c index 31ee9fe..6b59563 100644 --- a/src/libunixonacid/skaclient_server_ack.c +++ b/src/libunixonacid/skaclient_server_ack.c @@ -1,21 +1,22 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> -#include <skalibs/bytestr.h> +#include <string.h> #include <skalibs/djbunix.h> #include <skalibs/error.h> #include <skalibs/skaclient.h> #include <skalibs/unixmessage.h> #include <skalibs/webipc.h> -int skaclient_server_ack (unixmessage_t const *clientmsg, unixmessage_sender_t *out, unixmessage_sender_t *asyncout, char const *before, unsigned int beforelen, char const *after, unsigned int afterlen) +int skaclient_server_ack (unixmessage_t const *clientmsg, unixmessage_sender_t *out, unixmessage_sender_t *asyncout, char const *before, size_t beforelen, char const *after, size_t afterlen) { int fd[2] ; unixmessage_t m = { .s = (char *)after, .len = afterlen, .fds = fd, .nfds = 1 } ; static unsigned char const bits = 0xff ; if (clientmsg->nfds || clientmsg->len != beforelen - || byte_diff(clientmsg->s, beforelen, before)) return (errno = EPROTO, 0) ; + || memcmp(clientmsg->s, before, beforelen)) return (errno = EPROTO, 0) ; if (ipc_pair_nbcoe(fd) < 0) return 0 ; unixmessage_sender_init(asyncout, fd[1]) ; if (!unixmessage_put_and_close(out, &m, &bits)) diff --git a/src/libunixonacid/skaclient_server_bidi_ack.c b/src/libunixonacid/skaclient_server_bidi_ack.c index 1d3cdbf..0a3e5da 100644 --- a/src/libunixonacid/skaclient_server_bidi_ack.c +++ b/src/libunixonacid/skaclient_server_bidi_ack.c @@ -1,9 +1,10 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/skaclient.h> #include <skalibs/unixmessage.h> -int skaclient_server_bidi_ack (unixmessage_t const *clientmsg, unixmessage_sender_t *out, unixmessage_sender_t *asyncout, unixmessage_receiver_t *asyncin, char *mainbuf, unsigned int mainlen, char *auxbuf, unsigned int auxlen, char const *before, unsigned int beforelen, char const *after, unsigned int afterlen) +int skaclient_server_bidi_ack (unixmessage_t const *clientmsg, unixmessage_sender_t *out, unixmessage_sender_t *asyncout, unixmessage_receiver_t *asyncin, char *mainbuf, size_t mainlen, char *auxbuf, size_t auxlen, char const *before, size_t beforelen, char const *after, size_t afterlen) { if (!unixmessage_receiver_init(asyncin, -1, mainbuf, mainlen, auxbuf, auxlen)) return 0 ; if (!skaclient_server_ack(clientmsg, out, asyncout, before, beforelen, after, afterlen)) return 0 ; diff --git a/src/libunixonacid/skaclient_server_init.c b/src/libunixonacid/skaclient_server_init.c index 86eb003..ec5623a 100644 --- a/src/libunixonacid/skaclient_server_init.c +++ b/src/libunixonacid/skaclient_server_init.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/allreadwrite.h> #include <skalibs/skaclient.h> #include <skalibs/tai.h> #include <skalibs/unixmessage.h> -int skaclient_server_init (unixmessage_receiver_t *in, unixmessage_sender_t *out, unixmessage_sender_t *asyncout, char const *before, unsigned int beforelen, char const *after, unsigned int afterlen, tain_t const *deadline, tain_t *stamp) +int skaclient_server_init (unixmessage_receiver_t *in, unixmessage_sender_t *out, unixmessage_sender_t *asyncout, char const *before, size_t beforelen, char const *after, size_t afterlen, tain_t const *deadline, tain_t *stamp) { unixmessage_t m ; return (sanitize_read(unixmessage_timed_receive(in, &m, deadline, stamp)) >= 0) diff --git a/src/libunixonacid/skaclient_start.c b/src/libunixonacid/skaclient_start.c index 85021cb..7a166ae 100644 --- a/src/libunixonacid/skaclient_start.c +++ b/src/libunixonacid/skaclient_start.c @@ -1,7 +1,8 @@ /* ISC license. */ +#include <sys/types.h> +#include <stdint.h> #include <errno.h> -#include <skalibs/uint32.h> #include <skalibs/kolbak.h> #include <skalibs/skaclient.h> #include <skalibs/tai.h> @@ -10,31 +11,31 @@ int skaclient_start ( skaclient_t *a, char *bufss, - unsigned int bufsn, + size_t bufsn, char *auxbufss, - unsigned int auxbufsn, + size_t auxbufsn, char *bufas, - unsigned int bufan, + size_t bufan, char *auxbufas, - unsigned int auxbufan, + size_t auxbufan, kolbak_closure_t *q, - unsigned int qlen, + size_t qlen, char const *path, - uint32 options, + uint32_t options, char const *before, - unsigned int beforelen, + size_t beforelen, char const *after, - unsigned int afterlen, + size_t afterlen, tain_t const *deadline, tain_t *stamp) { skaclient_cbdata_t blah ; unixmessage_t m ; - register int r ; + int r ; if (!skaclient_start_async(a, bufss, bufsn, auxbufss, auxbufsn, bufas, bufan, auxbufas, auxbufan, q, qlen, path, options, before, beforelen, after, afterlen, &blah)) return 0 ; if (!skaclient_timed_flush(a, deadline, stamp)) { - register int e = errno ; + int e = errno ; skaclient_end(a) ; errno = e ; return 0 ; diff --git a/src/libunixonacid/skaclient_start_async.c b/src/libunixonacid/skaclient_start_async.c index 79ea5df..467acd9 100644 --- a/src/libunixonacid/skaclient_start_async.c +++ b/src/libunixonacid/skaclient_start_async.c @@ -1,7 +1,8 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> -#include <skalibs/uint32.h> +#include <stdint.h> #include <skalibs/error.h> #include <skalibs/kolbak.h> #include <skalibs/skaclient.h> @@ -12,21 +13,21 @@ int skaclient_start_async ( skaclient_t *a, char *bufss, - unsigned int bufsn, + size_t bufsn, char *auxbufss, - unsigned int auxbufsn, + size_t auxbufsn, char *bufas, - unsigned int bufan, + size_t bufan, char *auxbufas, - unsigned int auxbufan, + size_t auxbufan, kolbak_closure_t *q, - unsigned int qlen, + size_t qlen, char const *path, - uint32 options, + uint32_t options, char const *before, - unsigned int beforelen, + size_t beforelen, char const *after, - unsigned int afterlen, + size_t afterlen, skaclient_cbdata_t *blah) { int fd = ipc_stream_nbcoe() ; @@ -34,7 +35,7 @@ int skaclient_start_async ( if ((!ipc_connect(fd, path) && !error_isalready(errno)) || !skaclient_init(a, fd, bufss, bufsn, auxbufss, auxbufsn, bufas, bufan, auxbufas, auxbufan, q, qlen, before, beforelen)) { - register int e = errno ; + int e = errno ; fd_close(fd) ; errno = e ; return 0 ; diff --git a/src/libunixonacid/skaclient_start_cb.c b/src/libunixonacid/skaclient_start_cb.c index ff11a21..80cb6c3 100644 --- a/src/libunixonacid/skaclient_start_cb.c +++ b/src/libunixonacid/skaclient_start_cb.c @@ -1,7 +1,7 @@ /* ISC license. */ #include <errno.h> -#include <skalibs/bytestr.h> +#include <string.h> #include <skalibs/error.h> #include <skalibs/unixmessage.h> #include <skalibs/skaclient.h> @@ -10,7 +10,7 @@ int skaclient_start_cb (unixmessage_t const *m, skaclient_cbdata_t *blah) { if (m->len != blah->afterlen - || byte_diff(m->s, m->len, blah->after) + || memcmp(m->s, blah->after, m->len) || m->nfds != 1) { unixmessage_drop(m) ; diff --git a/src/libunixonacid/skaclient_startf.c b/src/libunixonacid/skaclient_startf.c index 57d6f46..755bc78 100644 --- a/src/libunixonacid/skaclient_startf.c +++ b/src/libunixonacid/skaclient_startf.c @@ -1,5 +1,7 @@ /* ISC license. */ +#include <sys/types.h> +#include <stdint.h> #include <errno.h> #include <skalibs/kolbak.h> #include <skalibs/skaclient.h> @@ -9,33 +11,33 @@ int skaclient_startf ( skaclient_t *a, char *bufss, - unsigned int bufsn, + size_t bufsn, char *auxbufss, - unsigned int auxbufsn, + size_t auxbufsn, char *bufas, - unsigned int bufan, + size_t bufan, char *auxbufas, - unsigned int auxbufan, + size_t auxbufan, kolbak_closure_t *q, - unsigned int qlen, + size_t qlen, char const *prog, char const *const *argv, char const *const *envp, - uint32 options, + uint32_t options, char const *before, - unsigned int beforelen, + size_t beforelen, char const *after, - unsigned int afterlen, + size_t afterlen, tain_t const *deadline, tain_t *stamp) { skaclient_cbdata_t blah ; unixmessage_t m ; - register int r ; + int r ; if (!skaclient_startf_async(a, bufss, bufsn, auxbufss, auxbufsn, bufas, bufan, auxbufas, auxbufan, q, qlen, prog, argv, envp, options, before, beforelen, after, afterlen, &blah)) return 0 ; if (!skaclient_timed_flush(a, deadline, stamp)) { - register int e = errno ; + int e = errno ; skaclient_end(a) ; errno = e ; return 0 ; diff --git a/src/libunixonacid/skaclient_startf_async.c b/src/libunixonacid/skaclient_startf_async.c index dd1688e..dce692e 100644 --- a/src/libunixonacid/skaclient_startf_async.c +++ b/src/libunixonacid/skaclient_startf_async.c @@ -1,34 +1,34 @@ /* ISC license. */ #include <sys/types.h> +#include <stdint.h> #include <errno.h> #include <signal.h> #include <skalibs/djbunix.h> #include <skalibs/kolbak.h> #include <skalibs/skaclient.h> -#include <skalibs/uint32.h> #include "skaclient-internal.h" int skaclient_startf_async ( skaclient_t *a, char *bufss, - unsigned int bufsn, + size_t bufsn, char *auxbufss, - unsigned int auxbufsn, + size_t auxbufsn, char *bufas, - unsigned int bufan, + size_t bufan, char *auxbufas, - unsigned int auxbufan, + size_t auxbufan, kolbak_closure_t *q, - unsigned int qlen, + size_t qlen, char const *prog, char const *const *argv, char const *const *envp, - uint32 options, + uint32_t options, char const *before, - unsigned int beforelen, + size_t beforelen, char const *after, - unsigned int afterlen, + size_t afterlen, skaclient_cbdata_t *blah) { int fd ; @@ -36,7 +36,7 @@ int skaclient_startf_async ( if (!pid) return 0 ; if (ndelay_on(fd) < 0 || !skaclient_init(a, fd, bufss, bufsn, auxbufss, auxbufsn, bufas, bufan, auxbufas, auxbufan, q, qlen, before, beforelen)) { - register int e = errno ; + int e = errno ; fd_close(fd) ; if (options & SKACLIENT_OPTION_WAITPID) { diff --git a/src/libunixonacid/skaclient_syncify.c b/src/libunixonacid/skaclient_syncify.c index 08b7b9a..ea5afb4 100644 --- a/src/libunixonacid/skaclient_syncify.c +++ b/src/libunixonacid/skaclient_syncify.c @@ -6,7 +6,7 @@ int skaclient_syncify (skaclient_t *a, tain_t const *deadline, tain_t *stamp) { - register int r ; + int r ; if (!skaclient_timed_flush(a, deadline, stamp)) return 0 ; r = skaclient_timed_supdate(a, deadline, stamp) ; return r < 0 ? 0 : !r ? (errno = EPIPE, 0) : 1 ; diff --git a/src/libunixonacid/stat_at.c b/src/libunixonacid/stat_at.c index 11f7924..3f0f1a5 100644 --- a/src/libunixonacid/stat_at.c +++ b/src/libunixonacid/stat_at.c @@ -9,7 +9,6 @@ #endif #include <skalibs/nonposix.h> -#include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <skalibs/unix-transactional.h> @@ -43,7 +42,7 @@ static int fstat_at (int dirfd, char const *file, struct stat *st, int (*dostat) if (fdhere < 0) return -1 ; if (fd_chdir(dirfd) < 0) { - register int e = errno ; + int e = errno ; fd_close(fdhere) ; errno = e ; return -1 ; @@ -51,7 +50,7 @@ static int fstat_at (int dirfd, char const *file, struct stat *st, int (*dostat) r = (*dostat)(file, st) ; if (r < 0) { - register int e = errno ; + int e = errno ; fd_chdir(fdhere) ; fd_close(fdhere) ; errno = e ; @@ -59,7 +58,7 @@ static int fstat_at (int dirfd, char const *file, struct stat *st, int (*dostat) } if (fd_chdir(fdhere) < 0) { - register int e = errno ; + int e = errno ; fd_close(fdhere) ; errno = e ; return -1 ; diff --git a/src/libunixonacid/timed_flush.c b/src/libunixonacid/timed_flush.c index 2d60256..ced60b6 100644 --- a/src/libunixonacid/timed_flush.c +++ b/src/libunixonacid/timed_flush.c @@ -13,7 +13,7 @@ int timed_flush (void *b, initfunc_t_ref getfd, initfunc_t_ref isnonempty, initf iopause_fd x = { .fd = (*getfd)(b), .events = IOPAUSE_WRITE, .revents = 0 } ; while ((*isnonempty)(b)) { - register int r = iopause_stamp(&x, 1, deadline, stamp) ; + int r = iopause_stamp(&x, 1, deadline, stamp) ; if (r < 0) return 0 ; else if (!r) return (errno = ETIMEDOUT, 0) ; else if (x.revents & IOPAUSE_WRITE) diff --git a/src/libunixonacid/timed_get.c b/src/libunixonacid/timed_get.c index 1b4e420..e93478e 100644 --- a/src/libunixonacid/timed_get.c +++ b/src/libunixonacid/timed_get.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/allreadwrite.h> #include <skalibs/functypes.h> @@ -7,10 +8,10 @@ #include <skalibs/iopause.h> #include <skalibs/unix-timed.h> -int timed_get (void *b, initfunc_t *getfd, initfunc_t *get, tain_t const *deadline, tain_t *stamp) +ssize_t timed_get (void *b, initfunc_t_ref getfd, getfunc_t_ref get, tain_t const *deadline, tain_t *stamp) { iopause_fd x = { .fd = (*getfd)(b), .events = IOPAUSE_READ, .revents = 0 } ; - register int r = (*get)(b) ; + ssize_t r = (*get)(b) ; while (!r) { r = iopause_stamp(&x, 1, deadline, stamp) ; diff --git a/src/libunixonacid/timed_getln.c b/src/libunixonacid/timed_getln.c index 0c442de..f699d97 100644 --- a/src/libunixonacid/timed_getln.c +++ b/src/libunixonacid/timed_getln.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/allreadwrite.h> #include <skalibs/buffer.h> #include <skalibs/functypes.h> @@ -20,7 +21,7 @@ static int getfd (struct blah_s *blah) return buffer_fd(blah->b) ; } -static int get (struct blah_s *blah) +static ssize_t get (struct blah_s *blah) { return sanitize_read(skagetln(blah->b, blah->sa, blah->sep)) ; } @@ -28,5 +29,5 @@ static int get (struct blah_s *blah) int timed_getln (buffer *b, stralloc *sa, char sep, tain_t const *deadline, tain_t *stamp) { struct blah_s blah = { .b = b, .sa = sa, .sep = sep } ; - return timed_get(&blah, (initfunc_t_ref)&getfd, (initfunc_t_ref)&get, deadline, stamp) ; + return timed_get(&blah, (initfunc_t_ref)&getfd, (getfunc_t_ref)&get, deadline, stamp) ; } diff --git a/src/libunixonacid/timed_getlnmax.c b/src/libunixonacid/timed_getlnmax.c index 2a8fab3..1d89d85 100644 --- a/src/libunixonacid/timed_getlnmax.c +++ b/src/libunixonacid/timed_getlnmax.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/allreadwrite.h> #include <skalibs/buffer.h> #include <skalibs/functypes.h> @@ -11,8 +12,8 @@ struct blah_s { buffer *b ; char *d ; - unsigned int max ; - unsigned int w ; + size_t max ; + size_t w ; char sep ; } ; @@ -21,15 +22,15 @@ static int getfd (struct blah_s *blah) return buffer_fd(blah->b) ; } -static int get (struct blah_s *blah) +static ssize_t get (struct blah_s *blah) { return sanitize_read(getlnmax(blah->b, blah->d, blah->max, &blah->w, blah->sep)) ; } -int timed_getlnmax (buffer *b, char *d, unsigned int max, unsigned int *w, char sep, tain_t const *deadline, tain_t *stamp) +ssize_t timed_getlnmax (buffer *b, char *d, size_t max, size_t *w, char sep, tain_t const *deadline, tain_t *stamp) { struct blah_s blah = { .b = b, .d = d, .max = max, .w = *w, .sep = sep } ; - register int r = timed_get(&blah, (initfunc_t_ref)&getfd, (initfunc_t_ref)&get, deadline, stamp) ; + ssize_t r = timed_get(&blah, (initfunc_t_ref)&getfd, (getfunc_t_ref)&get, deadline, stamp) ; *w = blah.w ; return r ; } diff --git a/src/libunixonacid/unixmessage_bits_closeall.c b/src/libunixonacid/unixmessage_bits_closeall.c index a963809..f640f48 100644 --- a/src/libunixonacid/unixmessage_bits_closeall.c +++ b/src/libunixonacid/unixmessage_bits_closeall.c @@ -3,5 +3,5 @@ #include <skalibs/bitarray.h> #include <skalibs/unixmessage.h> -static unsigned char _unixmessage_bits_closeall[bitarray_div8(UNIXMESSAGE_MAXFDS)] = "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" ; -unsigned char const *const unixmessage_bits_closeall = _unixmessage_bits_closeall ; +static unsigned char unixmessage_bits_closeall_[bitarray_div8(UNIXMESSAGE_MAXFDS)] = "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" ; +unsigned char const *const unixmessage_bits_closeall = unixmessage_bits_closeall_ ; diff --git a/src/libunixonacid/unixmessage_bits_closenone.c b/src/libunixonacid/unixmessage_bits_closenone.c index 79412a5..4d84737 100644 --- a/src/libunixonacid/unixmessage_bits_closenone.c +++ b/src/libunixonacid/unixmessage_bits_closenone.c @@ -3,5 +3,5 @@ #include <skalibs/bitarray.h> #include <skalibs/unixmessage.h> -static unsigned char _unixmessage_bits_closenone[bitarray_div8(UNIXMESSAGE_MAXFDS)] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" ; -unsigned char const *const unixmessage_bits_closenone = _unixmessage_bits_closenone ; +static unsigned char unixmessage_bits_closenone_[bitarray_div8(UNIXMESSAGE_MAXFDS)] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" ; +unsigned char const *const unixmessage_bits_closenone = unixmessage_bits_closenone_ ; diff --git a/src/libunixonacid/unixmessage_drop.c b/src/libunixonacid/unixmessage_drop.c index 7fa34fb..e51a8d0 100644 --- a/src/libunixonacid/unixmessage_drop.c +++ b/src/libunixonacid/unixmessage_drop.c @@ -7,7 +7,7 @@ void unixmessage_drop (unixmessage_t const *m) { int e = errno ; - register unsigned int i = 0 ; - for (; i < m->nfds ; i++) fd_close(m->fds[i]) ; + unsigned int i = m->nfds ; + while (i--) fd_close(m->fds[i]) ; errno = e ; } diff --git a/src/libunixonacid/unixmessage_handle.c b/src/libunixonacid/unixmessage_handle.c index 52e85cb..9d9de5c 100644 --- a/src/libunixonacid/unixmessage_handle.c +++ b/src/libunixonacid/unixmessage_handle.c @@ -2,19 +2,19 @@ #include <skalibs/unixmessage.h> -int unixmessage_handle (unixmessage_receiver_t *b, unixmessage_handler_func_t *f, void *p) +int unixmessage_handle (unixmessage_receiver_t *b, unixmessage_handler_func_t_ref f, void *p) { unsigned int n = UNIXMESSAGE_MAXREADS ; - int count = 0 ; + unsigned int count = 0 ; while (n--) { unixmessage_t m ; - register int r = unixmessage_receive(b, &m) ; + int r = unixmessage_receive(b, &m) ; if (r < 0) return -1 ; if (!r) break ; r = (*f)(&m, p) ; if (r <= 0) return r-2 ; count++ ; } - return count ; + return (int)count ; } diff --git a/src/libunixonacid/unixmessage_put.c b/src/libunixonacid/unixmessage_put.c index 43091c9..d9fe306 100644 --- a/src/libunixonacid/unixmessage_put.c +++ b/src/libunixonacid/unixmessage_put.c @@ -4,10 +4,10 @@ #ifdef SKALIBS_HASANCILAUTOCLOSE #include <unistd.h> #endif +#include <string.h> #include <errno.h> #include <skalibs/bitarray.h> -#include <skalibs/bytestr.h> -#include <skalibs/diuint.h> +#include <skalibs/disize.h> #include <skalibs/error.h> #include <skalibs/stralloc.h> #include <skalibs/genalloc.h> @@ -16,7 +16,7 @@ static inline int copyfds (char *s, int const *fds, unsigned int n, unsigned char const *bits, unixmessage_sender_closecb_func_t_ref closecb, void *closecbdata) { - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < n ; i++) { int fd = fds[i] ; @@ -32,7 +32,7 @@ static inline int copyfds (char *s, int const *fds, unsigned int n, unsigned cha while (i--) { s -= sizeof(int) ; - byte_copy((char *)fd, sizeof(int), s) ; + memcpy((char *)fd, s, sizeof(int)) ; if (fd >= 0) (*closecb)(fd, closecbdata) ; } errno = e ; @@ -40,46 +40,38 @@ static inline int copyfds (char *s, int const *fds, unsigned int n, unsigned cha } } #endif - byte_copy(s, sizeof(int), (char const *)&fd) ; + memcpy(s, (char const *)&fd, sizeof(int)) ; s += sizeof(int) ; } return 1 ; } -static int reserve_and_copy (unixmessage_sender_t *b, unsigned int len, int const *fds, unsigned int nfds, unsigned char const *bits) +static int reserve_and_copy (unixmessage_sender_t *b, size_t len, int const *fds, unsigned int nfds, unsigned char const *bits) { - diuint cur = { .left = b->data.len, .right = genalloc_len(int, &b->fds) } ; + disize cur = { .left = b->data.len, .right = genalloc_len(int, &b->fds) } ; if (len > UNIXMESSAGE_MAXSIZE || nfds > UNIXMESSAGE_MAXFDS) return (errno = EPROTO, 0) ; - if (!genalloc_readyplus(diuint, &b->offsets, 1) + if (!genalloc_readyplus(disize, &b->offsets, 1) || !genalloc_readyplus(int, &b->fds, nfds) || !stralloc_readyplus(&b->data, len)) return 0 ; if (!copyfds(b->fds.s + b->fds.len, fds, nfds, bits, b->closecb, b->closecbdata)) return 0 ; genalloc_setlen(int, &b->fds, cur.right + nfds) ; - byte_copy(b->offsets.s + b->offsets.len, sizeof(diuint), (char const *)&cur) ; - b->offsets.len += sizeof(diuint) ; - return 1 ; + return genalloc_append(disize, &b->offsets, &cur) ; } int unixmessage_put_and_close (unixmessage_sender_t *b, unixmessage_t const *m, unsigned char const *bits) { if (!reserve_and_copy(b, m->len, m->fds, m->nfds, bits)) return 0 ; - byte_copy(b->data.s + b->data.len, m->len, m->s) ; + memmove(b->data.s + b->data.len, m->s, m->len) ; b->data.len += m->len ; return 1 ; } int unixmessage_putv_and_close (unixmessage_sender_t *b, unixmessage_v_t const *m, unsigned char const *bits) { - unsigned int len = 0 ; - register unsigned int i = 0 ; - for (; i < m->vlen ; i++) len += m->v[i].len ; + size_t len = siovec_len(m->v, m->vlen) ; if (!reserve_and_copy(b, len, m->fds, m->nfds, bits)) return 0 ; - for (i = 0 ; i < m->vlen ; i++) - { - byte_copy(b->data.s + b->data.len, m->v[i].len, m->v[i].s) ; - b->data.len += m->v[i].len ; - } + siovec_gather(m->v, m->vlen, b->data.s + b->data.len, len) ; return 1 ; } diff --git a/src/libunixonacid/unixmessage_receive.c b/src/libunixonacid/unixmessage_receive.c index 885a7bc..9672b63 100644 --- a/src/libunixonacid/unixmessage_receive.c +++ b/src/libunixonacid/unixmessage_receive.c @@ -12,7 +12,6 @@ #include <skalibs/error.h> #include <skalibs/allreadwrite.h> #include <skalibs/stralloc.h> -#include <skalibs/siovec.h> #include <skalibs/unixmessage.h> static int const awesomeflags = @@ -49,14 +48,10 @@ static int unixmessage_receiver_fill (unixmessage_receiver_t *b) .msg_control = b->fds_ok & 1 ? ancilbuf : 0, .msg_controllen = b->fds_ok & 1 ? sizeof(ancilbuf) : 0 } ; - int r = -1 ; + ssize_t r = -1 ; if (cbuffer_isfull(&b->mainb) || ((b->fds_ok & 1) && cbuffer_isfull(&b->auxb))) return (errno = ENOBUFS, -1) ; - { - siovec_t v[2] ; - cbuffer_wpeek(&b->mainb, v) ; - iovec_from_siovec(iov, v, 2) ; - } + cbuffer_wpeek(&b->mainb, iov) ; while (r < 0) { r = recvmsg(b->fd, &msghdr, awesomeflags) ; @@ -67,20 +62,20 @@ static int unixmessage_receiver_fill (unixmessage_receiver_t *b) struct cmsghdr *c = CMSG_FIRSTHDR(&msghdr) ; if (c) { - unsigned int auxlen ; + size_t auxlen ; if (c->cmsg_level != SOL_SOCKET || c->cmsg_type != SCM_RIGHTS) return (errno = EPROTO, -1) ; - auxlen = (unsigned int)(c->cmsg_len - (CMSG_DATA(c) - (unsigned char *)c)) ; + auxlen = (size_t)(c->cmsg_len - (CMSG_DATA(c) - (unsigned char *)c)) ; if (auxlen && !(b->fds_ok & 2)) { - register unsigned int i = auxlen/sizeof(int) ; + size_t i = auxlen / sizeof(int) ; while (i--) fd_close(((int *)CMSG_DATA(c))[i]) ; return (errno = EPROTO, -1) ; } #ifndef SKALIBS_HASCMSGCLOEXEC { - register unsigned int i = 0 ; - for (; i < auxlen/sizeof(int) ; i++) + size_t i = 0 ; + for (; i < auxlen / sizeof(int) ; i++) if (coe(((int *)CMSG_DATA(c))[i]) < 0) { int e = errno ; @@ -93,7 +88,7 @@ static int unixmessage_receiver_fill (unixmessage_receiver_t *b) #endif if ((msghdr.msg_flags & MSG_CTRUNC) || cbuffer_put(&b->auxb, (char *)CMSG_DATA(c), auxlen) < auxlen) { - register unsigned int i = auxlen/sizeof(int) ; + size_t i = auxlen/sizeof(int) ; while (i--) fd_close(((int *)CMSG_DATA(c))[i]) ; return (errno = ENOBUFS, -1) ; } @@ -110,7 +105,7 @@ int unixmessage_receive (unixmessage_receiver_t *b, unixmessage_t *m) char pack[6] ; if (cbuffer_len(&b->mainb) < 6) { - register int r = sanitize_read(unixmessage_receiver_fill(b)) ; + ssize_t r = sanitize_read(unixmessage_receiver_fill(b)) ; if (r <= 0) return r ; if (cbuffer_len(&b->mainb) < 6) return (errno = EWOULDBLOCK, 0) ; } @@ -131,8 +126,8 @@ int unixmessage_receive (unixmessage_receiver_t *b, unixmessage_t *m) for (;;) { - register int r ; - register unsigned int n = cbuffer_len(&b->mainb) ; + ssize_t r ; + size_t n = cbuffer_len(&b->mainb) ; if (n > b->mainlen - b->maindata.len) n = b->mainlen - b->maindata.len ; b->maindata.len += cbuffer_get(&b->mainb, b->maindata.s + b->maindata.len, n) ; n = cbuffer_len(&b->auxb) ; diff --git a/src/libunixonacid/unixmessage_receiver_free.c b/src/libunixonacid/unixmessage_receiver_free.c index d9d575e..776509c 100644 --- a/src/libunixonacid/unixmessage_receiver_free.c +++ b/src/libunixonacid/unixmessage_receiver_free.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/cbuffer.h> #include <skalibs/stralloc.h> #include <skalibs/djbunix.h> @@ -7,19 +8,20 @@ void unixmessage_receiver_free (unixmessage_receiver_t *b) { - register unsigned int h = b->maindata.len ; + size_t maindatalen = b->maindata.len ; + int h ; b->fd = -1 ; stralloc_free(&b->maindata) ; - h = h != b->mainlen || b->auxdata.len != b->auxlen || cbuffer_len(&b->auxb) ; + h = maindatalen != b->mainlen || b->auxdata.len != b->auxlen || cbuffer_len(&b->auxb) ; if (h) { - register unsigned int n = b->auxdata.len / sizeof(int) ; + size_t n = b->auxdata.len / sizeof(int) ; while (n--) fd_close(((int *)b->auxdata.s)[n]) ; } stralloc_free(&b->auxdata) ; if (h) { - register unsigned int n = cbuffer_len(&b->auxb) / sizeof(int) ; + size_t n = cbuffer_len(&b->auxb) / sizeof(int) ; if (n) { int fds[n] ; diff --git a/src/libunixonacid/unixmessage_receiver_init.c b/src/libunixonacid/unixmessage_receiver_init.c index 430ccac..117512e 100644 --- a/src/libunixonacid/unixmessage_receiver_init.c +++ b/src/libunixonacid/unixmessage_receiver_init.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/cbuffer.h> #include <skalibs/stralloc.h> #include <skalibs/unixmessage.h> -int unixmessage_receiver_init (unixmessage_receiver_t *b, int fd, char *mainbuf, unsigned int mainlen, char *auxbuf, unsigned int auxlen) +int unixmessage_receiver_init (unixmessage_receiver_t *b, int fd, char *mainbuf, size_t mainlen, char *auxbuf, size_t auxlen) { if (!cbuffer_init(&b->mainb, mainbuf, mainlen) || !cbuffer_init(&b->auxb, auxbuf, auxlen)) return 0 ; diff --git a/src/libunixonacid/unixmessage_sender_flush.c b/src/libunixonacid/unixmessage_sender_flush.c index 57c5d6e..8cfb709 100644 --- a/src/libunixonacid/unixmessage_sender_flush.c +++ b/src/libunixonacid/unixmessage_sender_flush.c @@ -4,12 +4,13 @@ #include <skalibs/nonposix.h> #include <sys/socket.h> #include <sys/uio.h> +#include <stdint.h> #include <unistd.h> #include <errno.h> #include <skalibs/uint16.h> #include <skalibs/uint32.h> #include <skalibs/bytestr.h> -#include <skalibs/diuint.h> +#include <skalibs/disize.h> #include <skalibs/allreadwrite.h> #include <skalibs/genalloc.h> #include <skalibs/djbunix.h> @@ -27,28 +28,28 @@ int unixmessage_sender_flush (unixmessage_sender_t *b) { - diuint last = { .left = b->data.len, .right = genalloc_len(int, &b->fds) } ; - diuint *offsets = genalloc_s(diuint, &b->offsets) ; - unsigned int n = genalloc_len(diuint, &b->offsets) ; - register int r ; + disize last = { .left = b->data.len, .right = genalloc_len(int, &b->fds) } ; + disize *offsets = genalloc_s(disize, &b->offsets) ; + size_t n = genalloc_len(disize, &b->offsets) ; + ssize_t r ; if (b->shorty) /* we had a short write, gotta send the remainder first */ { - diuint *next = b->head+1 < n ? offsets + b->head+1 : &last ; - unsigned int len = next->left - offsets[b->head].left ; + disize *next = b->head+1 < n ? offsets + b->head+1 : &last ; + size_t len = next->left - offsets[b->head].left ; if (b->shorty <= len) r = fd_write(b->fd, b->data.s + offsets[b->head].left + (len - b->shorty), b->shorty) ; else { - unsigned int nfds = next->right - offsets[b->head].right ; + size_t nfds = next->right - offsets[b->head].right ; char pack[6] ; struct iovec v[2] = { { .iov_base = pack + 6 - (b->shorty - len), .iov_len = b->shorty - len }, { .iov_base = b->data.s + offsets[b->head].left, .iov_len = len } } ; - uint32_pack_big(pack, (uint32)len) ; - uint16_pack_big(pack + 4, (uint16)nfds) ; + uint32_pack_big(pack, (uint32_t)len) ; + uint16_pack_big(pack + 4, (uint16_t)nfds) ; r = fd_writev(b->fd, v, 2) ; } if (r <= 0) return 0 ; @@ -58,9 +59,9 @@ int unixmessage_sender_flush (unixmessage_sender_t *b) for (; b->head < n ; b->head++) { - diuint *next = b->head+1 < n ? offsets + b->head+1 : &last ; - unsigned int len = next->left - offsets[b->head].left ; - unsigned int nfds = next->right - offsets[b->head].right ; + disize *next = b->head+1 < n ? offsets + b->head+1 : &last ; + size_t len = next->left - offsets[b->head].left ; + size_t nfds = next->right - offsets[b->head].right ; char pack[6] ; struct iovec v[2] = { @@ -77,19 +78,19 @@ int unixmessage_sender_flush (unixmessage_sender_t *b) .msg_control = nfds ? ancilbuf : 0, .msg_controllen = nfds ? sizeof(ancilbuf) : 0 } ; - uint32_pack_big(pack, (uint32)len) ; - uint16_pack_big(pack + 4, (uint16)nfds) ; + uint32_pack_big(pack, (uint32_t)len) ; + uint16_pack_big(pack + 4, (uint16_t)nfds) ; if (nfds) { struct cmsghdr *cp = CMSG_FIRSTHDR(&hdr) ; - register unsigned int i = 0 ; + size_t i = 0 ; byte_zero(ancilbuf, sizeof(ancilbuf)) ; cp->cmsg_level = SOL_SOCKET ; cp->cmsg_type = SCM_RIGHTS ; cp->cmsg_len = CMSG_LEN(nfds * sizeof(int)) ; for (; i < nfds ; i++) { - register int fd = genalloc_s(int, &b->fds)[offsets[b->head].right + i] ; + int fd = genalloc_s(int, &b->fds)[offsets[b->head].right + i] ; ((int *)CMSG_DATA(cp))[i] = fd < 0 ? -(fd+1) : fd ; } } @@ -99,15 +100,15 @@ int unixmessage_sender_flush (unixmessage_sender_t *b) #ifndef SKALIBS_HASANCILAUTOCLOSE if (nfds) { - register unsigned int i = 0 ; + size_t i = 0 ; for (; i < nfds ; i++) { - register int fd = genalloc_s(int, &b->fds)[offsets[b->head].right + i] ; + int fd = genalloc_s(int, &b->fds)[offsets[b->head].right + i] ; if (fd < 0) (*b->closecb)(-(fd+1), b->closecbdata) ; } } #endif - if ((unsigned int)r < 6 + len) + if ((size_t)r < 6 + len) { b->shorty = 6 + len - r ; return (errno = EWOULDBLOCK, 0) ; @@ -115,7 +116,7 @@ int unixmessage_sender_flush (unixmessage_sender_t *b) } b->data.len = 0 ; genalloc_setlen(int, &b->fds, 0) ; - genalloc_setlen(diuint, &b->offsets, 0) ; + genalloc_setlen(disize, &b->offsets, 0) ; b->head = 0 ; return 1 ; } diff --git a/src/libunixonacid/unixmessage_sender_free.c b/src/libunixonacid/unixmessage_sender_free.c index a976827..da127c2 100644 --- a/src/libunixonacid/unixmessage_sender_free.c +++ b/src/libunixonacid/unixmessage_sender_free.c @@ -1,7 +1,8 @@ /* ISC license. */ #include <skalibs/sysdeps.h> -#include <skalibs/diuint.h> +#include <sys/types.h> +#include <skalibs/disize.h> #include <skalibs/stralloc.h> #include <skalibs/genalloc.h> #include <skalibs/djbunix.h> @@ -9,20 +10,20 @@ void unixmessage_sender_free (unixmessage_sender_t *b) { - unsigned int n = genalloc_len(int, &b->fds) ; + size_t n = genalloc_len(int, &b->fds) ; if (n) { - unsigned int i = genalloc_s(diuint, &b->offsets)[b->head].right ; + size_t i = genalloc_s(disize, &b->offsets)[b->head].right ; for (; i < n ; i++) { - register int fd = genalloc_s(int, &b->fds)[i] ; + int fd = genalloc_s(int, &b->fds)[i] ; if (fd < 0) (*b->closecb)(-(fd+1), b->closecbdata) ; #ifdef SKALIBS_HASANCILAUTOCLOSE else (*b->closecb)(fd, b->closecbdata) ; #endif } } - genalloc_free(diuint, &b->offsets) ; + genalloc_free(disize, &b->offsets) ; genalloc_free(int, &b->fds) ; stralloc_free(&b->data) ; *b = unixmessage_sender_zero ; diff --git a/src/libunixonacid/unixmessage_timed_handle.c b/src/libunixonacid/unixmessage_timed_handle.c index 5ac7ccd..ae10621 100644 --- a/src/libunixonacid/unixmessage_timed_handle.c +++ b/src/libunixonacid/unixmessage_timed_handle.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/functypes.h> #include <skalibs/tai.h> #include <skalibs/unix-timed.h> @@ -9,7 +10,7 @@ typedef struct unixmessage_handler_blah_s unixmessage_handler_blah_t, *unixmessa struct unixmessage_handler_blah_s { unixmessage_receiver_t *b ; - unixmessage_handler_func_t *f ; + unixmessage_handler_func_t_ref f ; void *p ; } ; @@ -18,13 +19,13 @@ static int getfd (unixmessage_handler_blah_t *blah) return unixmessage_receiver_fd(blah->b) ; } -static int get (unixmessage_handler_blah_t *blah) +static ssize_t get (unixmessage_handler_blah_t *blah) { return unixmessage_handle(blah->b, blah->f, blah->p) ; } -int unixmessage_timed_handle (unixmessage_receiver_t *b, unixmessage_handler_func_t *f, void *p, tain_t const *deadline, tain_t *stamp) +int unixmessage_timed_handle (unixmessage_receiver_t *b, unixmessage_handler_func_t_ref f, void *p, tain_t const *deadline, tain_t *stamp) { unixmessage_handler_blah_t blah = { .b = b, .f = f, .p = p } ; - return timed_get(&blah, (initfunc_t_ref)&getfd, (initfunc_t_ref)&get, deadline, stamp) ; + return timed_get(&blah, (initfunc_t_ref)&getfd, (getfunc_t_ref)&get, deadline, stamp) ; } diff --git a/src/libunixonacid/unixmessage_timed_receive.c b/src/libunixonacid/unixmessage_timed_receive.c index 3761d26..dc83ff7 100644 --- a/src/libunixonacid/unixmessage_timed_receive.c +++ b/src/libunixonacid/unixmessage_timed_receive.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/functypes.h> #include <skalibs/tai.h> #include <skalibs/unix-timed.h> @@ -17,7 +18,7 @@ static int getfd (unixmessage_get_t *g) return unixmessage_receiver_fd(g->b) ; } -static int get (unixmessage_get_t *g) +static ssize_t get (unixmessage_get_t *g) { return unixmessage_receive(g->b, g->m) ; } @@ -25,5 +26,5 @@ static int get (unixmessage_get_t *g) int unixmessage_timed_receive (unixmessage_receiver_t *b, unixmessage_t *m, tain_t const *deadline, tain_t *stamp) { unixmessage_get_t g = { .b = b, .m = m } ; - return timed_get(&g, (initfunc_t *)&getfd, (initfunc_t *)&get, deadline, stamp) ; + return timed_get(&g, (initfunc_t_ref)&getfd, (getfunc_t_ref)&get, deadline, stamp) ; } diff --git a/src/libunixonacid/unixmessage_unput.c b/src/libunixonacid/unixmessage_unput.c index e869110..180c5a7 100644 --- a/src/libunixonacid/unixmessage_unput.c +++ b/src/libunixonacid/unixmessage_unput.c @@ -1,18 +1,19 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/genalloc.h> -#include <skalibs/diuint.h> +#include <skalibs/disize.h> #include <skalibs/djbunix.h> #include <skalibs/unixmessage.h> int unixmessage_unput_and_maybe_drop (unixmessage_sender_t *b, int drop) { - diuint *start ; - unsigned int n = genalloc_len(diuint, &b->offsets) ; - register int *fds ; - register unsigned int i ; + disize *start ; + size_t n = genalloc_len(disize, &b->offsets) ; + size_t i ; + int *fds ; if (!n) return 0 ; - start = genalloc_s(diuint, &b->offsets) + n - 1 ; + start = genalloc_s(disize, &b->offsets) + n - 1 ; fds = genalloc_s(int, &b->fds) + start->right ; i = genalloc_len(int, &b->fds) - start->right ; while (i--) @@ -20,6 +21,6 @@ int unixmessage_unput_and_maybe_drop (unixmessage_sender_t *b, int drop) else if (drop) fd_close(fds[i]) ; b->data.len = start->left ; genalloc_setlen(int, &b->fds, start->right) ; - genalloc_setlen(diuint, &b->offsets, n-1) ; + genalloc_setlen(disize, &b->offsets, n-1) ; return 1 ; } diff --git a/src/sysdeps/output-types.c b/src/sysdeps/output-types.c index bc3447a..09995d2 100644 --- a/src/sysdeps/output-types.c +++ b/src/sysdeps/output-types.c @@ -12,6 +12,7 @@ int main (void) q(ushort, unsigned short) ; q(uint, unsigned int) ; q(ulong, unsigned long) ; + p(size) ; p(uid) ; p(gid) ; p(pid) ; |