summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-02-15 17:40:40 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-02-15 17:40:40 +0000
commita896ca2a8c617e5e00ffd5fc9e69331ad754e5b3 (patch)
treef49a8382b9999b5aa00c0885eedd5c5c3a233e55 /src
parent00c9cb1b22cc17c4db573e0e613a5f116ff0092e (diff)
downloadskalibs-a896ca2a8c617e5e00ffd5fc9e69331ad754e5b3.tar.xz
add arc4random_addrandom sysdep; next batch of types changes.
The library isn't supposed to be functional yet: there are still a lot of type mismatches.
Diffstat (limited to 'src')
-rw-r--r--src/include/skalibs/alloc.h5
-rw-r--r--src/include/skalibs/allreadwrite.h30
-rw-r--r--src/include/skalibs/bitarray.h24
-rw-r--r--src/include/skalibs/bufalloc.h7
-rw-r--r--src/include/skalibs/bytestr.h43
-rw-r--r--src/include/skalibs/djbunix.h2
-rw-r--r--src/include/skalibs/functypes.h11
-rw-r--r--src/include/skalibs/genalloc.h3
-rw-r--r--src/include/skalibs/genwrite.h4
-rw-r--r--src/include/skalibs/stralloc.h27
-rw-r--r--src/librandom/random_init.c2
-rw-r--r--src/libstddjb/absolutepath_tmp.c5
-rw-r--r--src/libstddjb/alloc.c5
-rw-r--r--src/libstddjb/allread.c5
-rw-r--r--src/libstddjb/allreadv.c7
-rw-r--r--src/libstddjb/allreadwrite.c8
-rw-r--r--src/libstddjb/allreadwritev.c16
-rw-r--r--src/libstddjb/allwrite.c2
-rw-r--r--src/libstddjb/allwritev.c7
-rw-r--r--src/libstddjb/bitarray_and.c7
-rw-r--r--src/libstddjb/bitarray_clearsetn.c5
-rw-r--r--src/libstddjb/bitarray_count.c10
-rw-r--r--src/libstddjb/bitarray_firstclear.c7
-rw-r--r--src/libstddjb/bitarray_firstclear_skip.c7
-rw-r--r--src/libstddjb/bitarray_firstset.c7
-rw-r--r--src/libstddjb/bitarray_firstset_skip.c7
-rw-r--r--src/libstddjb/bitarray_not.c5
-rw-r--r--src/libstddjb/bitarray_or.c7
-rw-r--r--src/libstddjb/bitarray_testandpoke.c3
-rw-r--r--src/libstddjb/bitarray_xor.c7
-rw-r--r--src/libstddjb/bufalloc_clean.c4
-rw-r--r--src/libstddjb/bufalloc_flush.c1
-rw-r--r--src/libstddjb/bufalloc_getlen.c3
-rw-r--r--src/libstddjb/bufalloc_init.c3
-rw-r--r--src/libstddjb/buffer_0.c2
-rw-r--r--src/libstddjb/buffer_0small.c2
-rw-r--r--src/libstddjb/buffer_1.c2
-rw-r--r--src/libstddjb/buffer_1small.c2
-rw-r--r--src/libstddjb/buffer_2.c2
-rw-r--r--src/libstddjb/buffer_flush1read.c7
-rw-r--r--src/libstddjb/byte_chr.c23
-rw-r--r--src/libstddjb/byte_count.c5
-rw-r--r--src/libstddjb/byte_in.c3
-rw-r--r--src/libstddjb/byte_rchr.c7
-rw-r--r--src/libstddjb/case_lowerb.c5
-rw-r--r--src/libstddjb/case_startb.c6
-rw-r--r--src/libstddjb/case_str.c17
-rw-r--r--src/libstddjb/case_upperb.c4
-rw-r--r--src/libstddjb/cdb_make.c2
-rw-r--r--src/libstddjb/fd_cat.c5
-rw-r--r--src/libstddjb/fd_catn.c11
-rw-r--r--src/libstddjb/fd_chown.c4
-rw-r--r--src/libstddjb/fd_copy2.c1
-rw-r--r--src/libstddjb/fd_read.c5
-rw-r--r--src/libstddjb/fd_readsv.c13
-rw-r--r--src/libstddjb/fd_readv.c4
-rw-r--r--src/libstddjb/fd_recv.c4
-rw-r--r--src/libstddjb/fd_send.c4
-rw-r--r--src/libstddjb/fd_write.c5
-rw-r--r--src/libstddjb/fd_writesv.c13
-rw-r--r--src/libstddjb/fd_writev.c4
-rw-r--r--src/libstddjb/genalloc_deepfree.c7
-rw-r--r--src/libstddjb/genwrite_put_bufalloc.c5
-rw-r--r--src/libstddjb/genwrite_put_buffer.c3
-rw-r--r--src/libstddjb/genwrite_put_stralloc.c5
-rw-r--r--src/libstddjb/iobufferu_init.c4
-rw-r--r--src/libstddjb/sanitize_read.c3
-rw-r--r--src/libstddjb/str_chr.c32
-rw-r--r--src/libstddjb/str_rchr.c24
-rw-r--r--src/libstddjb/str_strn.c28
-rw-r--r--src/libstddjb/stralloc_catb.c7
-rw-r--r--src/libstddjb/stralloc_catv.c15
-rw-r--r--src/libstddjb/stralloc_copyb.c7
-rw-r--r--src/libstddjb/stralloc_insertb.c8
-rw-r--r--src/libstddjb/stralloc_ready_tuned.c5
-rw-r--r--src/libstddjb/stralloc_reverse.c4
-rw-r--r--src/libstddjb/stralloc_reverse_blocks.c15
-rw-r--r--src/libstddjb/unsanitize_read.c3
-rw-r--r--src/libunixonacid/opengetlnclose.c2
-rw-r--r--src/libunixonacid/opengetlnclose_at.c2
-rw-r--r--src/sysdeps/tryarc4random_addrandom.c12
81 files changed, 300 insertions, 349 deletions
diff --git a/src/include/skalibs/alloc.h b/src/include/skalibs/alloc.h
index 0df0f9d..85f02f2 100644
--- a/src/include/skalibs/alloc.h
+++ b/src/include/skalibs/alloc.h
@@ -3,14 +3,15 @@
#ifndef ALLOC_H
#define ALLOC_H
+#include <sys/types.h>
#include <skalibs/gccattributes.h>
typedef char aligned_char gccattr_aligned ;
typedef aligned_char *aligned_char_ref, **aligned_char_ref_ref ;
-extern aligned_char *alloc (unsigned int) ;
+extern aligned_char *alloc (size_t) ;
extern void alloc_free (void *) ;
#define alloc_re(p, old, new) alloc_realloc(p, new)
-extern int alloc_realloc (aligned_char **, unsigned int) ;
+extern int alloc_realloc (aligned_char **, size_t) ;
#endif
diff --git a/src/include/skalibs/allreadwrite.h b/src/include/skalibs/allreadwrite.h
index d2e6bf7..9e42c1c 100644
--- a/src/include/skalibs/allreadwrite.h
+++ b/src/include/skalibs/allreadwrite.h
@@ -8,26 +8,24 @@
#include <skalibs/functypes.h>
#include <skalibs/siovec.h>
-extern int sanitize_read (int) ;
-extern int unsanitize_read (int) ;
+extern ssize_t sanitize_read (ssize_t) ;
+extern ssize_t unsanitize_read (ssize_t) ;
-extern unsigned int allreadwrite (iofunc_t_ref, int, char *, unsigned int) ;
-extern unsigned int allreadwritev (iovfunc_t_ref, int, siovec_t const *, unsigned int) ;
+extern size_t allreadwrite (iofunc_t_ref, int, char *, size_t) ;
+extern size_t allreadwritev (iovfunc_t_ref, int, struct iovec const *, unsigned int) ;
-extern int fd_read (int, char *, unsigned int) ;
-extern int fd_write (int, char const *, unsigned int) ;
+extern ssize_t fd_read (int, char *, size_t) ;
+extern ssize_t fd_write (int, char const *, size_t) ;
-extern int fd_recv (int, char *, unsigned int, unsigned int) ;
-extern int fd_send (int, char const *, unsigned int, unsigned int) ;
+extern ssize_t fd_recv (int, char *, size_t, unsigned int) ;
+extern ssize_t fd_send (int, char const *, size_t, unsigned int) ;
-extern unsigned int allread (int, char *, unsigned int) ;
-extern unsigned int allwrite (int, char const *, unsigned int) ;
-extern unsigned int allreadv (int, siovec_t const *, unsigned int) ;
-extern unsigned int allwritev (int, siovec_t const *, unsigned int) ;
+extern size_t allread (int, char *, size_t) ;
+extern size_t allwrite (int, char const *, size_t) ;
+extern size_t allreadv (int, struct iovec const *, unsigned int) ;
+extern size_t allwritev (int, struct iovec const *, unsigned int) ;
-extern int fd_readv (int, struct iovec const *, unsigned int) ;
-extern int fd_readsv (int, siovec_t const *, unsigned int) ;
-extern int fd_writev (int, struct iovec const *, unsigned int) ;
-extern int fd_writesv (int, siovec_t const *, unsigned int) ;
+extern ssize_t fd_readv (int, struct iovec const *, unsigned int) ;
+extern ssize_t fd_writev (int, struct iovec const *, unsigned int) ;
#endif
diff --git a/src/include/skalibs/bitarray.h b/src/include/skalibs/bitarray.h
index fc9b16d..7344492 100644
--- a/src/include/skalibs/bitarray.h
+++ b/src/include/skalibs/bitarray.h
@@ -3,11 +3,13 @@
#ifndef BITARRAY_H
#define BITARRAY_H
+#include <sys/types.h>
#include <skalibs/gccattributes.h>
+#include <skalibs/uint64.h>
#define bitarray_div8(n) ((n) ? 1U + (((n) - 1) >> 3) : 0U)
-extern void bitarray_clearsetn (unsigned char *, unsigned int, unsigned int, int) ;
+extern void bitarray_clearsetn (unsigned char *, size_t, size_t, int) ;
#define bitarray_clearn(s, start, len) bitarray_clearsetn(s, start, (len), 0)
#define bitarray_setn(s, start, len) bitarray_clearsetn(s, start, (len), 1)
@@ -17,23 +19,23 @@ extern void bitarray_clearsetn (unsigned char *, unsigned int, unsigned int, int
#define bitarray_set(s, n) ((s)[(n)>>3] |= 1U << ((n) & 7))
#define bitarray_poke(s, n, h) ((h) ? bitarray_set(s, n) : bitarray_clear(s, n))
-extern int bitarray_testandpoke (unsigned char *, unsigned int, int) ;
+extern int bitarray_testandpoke (unsigned char *, size_t, int) ;
#define bitarray_testandclear(b, n) bitarray_testandpoke(b, n, 0)
#define bitarray_testandset(b, n) bitarray_testandpoke(b, n, 1)
-extern unsigned int bitarray_firstclear (unsigned char const *, unsigned int) gccattr_pure ;
-extern unsigned int bitarray_firstset (unsigned char const *, unsigned int) gccattr_pure ;
+extern size_t bitarray_firstclear (unsigned char const *, size_t) gccattr_pure ;
+extern size_t bitarray_firstset (unsigned char const *, size_t) gccattr_pure ;
#define bitarray_first(s, n, h) ((h) ? bitarray_firstset(s, n) : bitarray_firstclear(s, n))
-extern unsigned int bitarray_firstclear_skip (unsigned char const *, unsigned int, unsigned int) gccattr_pure ;
-extern unsigned int bitarray_firstset_skip (unsigned char const *, unsigned int, unsigned int) gccattr_pure ;
+extern size_t bitarray_firstclear_skip (unsigned char const *, size_t, size_t) gccattr_pure ;
+extern size_t bitarray_firstset_skip (unsigned char const *, size_t, size_t) gccattr_pure ;
#define bitarray_first_skip(s, n, k, h) ((h) ? bitarray_firstset_skip(s, n, k) : bitarray_firstclear_skip(s, n, k))
-extern unsigned int bitarray_countones (unsigned char const *, unsigned int) gccattr_pure ;
+extern uint64_t bitarray_countones (unsigned char const *, size_t) gccattr_pure ;
-extern void bitarray_not (unsigned char *, unsigned int, unsigned int) ;
-extern void bitarray_and (unsigned char *, unsigned char const *, unsigned char const *, unsigned int) ;
-extern void bitarray_or (unsigned char *, unsigned char const *, unsigned char const *, unsigned int) ;
-extern void bitarray_xor (unsigned char *, unsigned char const *, unsigned char const *, unsigned int) ;
+extern void bitarray_not (unsigned char *, size_t, size_t) ;
+extern void bitarray_and (unsigned char *, unsigned char const *, unsigned char const *, size_t) ;
+extern void bitarray_or (unsigned char *, unsigned char const *, unsigned char const *, size_t) ;
+extern void bitarray_xor (unsigned char *, unsigned char const *, unsigned char const *, size_t) ;
#endif
diff --git a/src/include/skalibs/bufalloc.h b/src/include/skalibs/bufalloc.h
index 2941311..838ab02 100644
--- a/src/include/skalibs/bufalloc.h
+++ b/src/include/skalibs/bufalloc.h
@@ -3,6 +3,7 @@
#ifndef BUFALLOC_H
#define BUFALLOC_H
+#include <sys/types.h>
#include <skalibs/gccattributes.h>
#include <skalibs/stralloc.h>
@@ -10,14 +11,14 @@ typedef struct bufalloc bufalloc, *bufalloc_ref ;
struct bufalloc
{
stralloc x ;
- unsigned int p ;
+ size_t p ;
int fd ;
int (*op) (int, char const *, unsigned int) ;
} ;
#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 *, unsigned int), int) ;
+extern void bufalloc_init (bufalloc *, int (*)(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)
@@ -28,7 +29,7 @@ extern int bufalloc_getfd (bufalloc const *) gccattr_pure ;
extern int bufalloc_flush (bufalloc *) ;
extern void bufalloc_clean (bufalloc *) ;
#define bufalloc_len(ba) ((ba)->x.len - (ba)->p)
-extern unsigned int bufalloc_getlen (bufalloc const *) gccattr_pure ;
+extern size_t bufalloc_getlen (bufalloc const *) gccattr_pure ;
#define bufalloc_isempty(ba) ((ba)->x.len == (ba)->p)
extern bufalloc bufalloc_1_ ;
diff --git a/src/include/skalibs/bytestr.h b/src/include/skalibs/bytestr.h
index 2340a2f..79768a8 100644
--- a/src/include/skalibs/bytestr.h
+++ b/src/include/skalibs/bytestr.h
@@ -9,12 +9,11 @@
/* for Alphas and other archs where char != 8bit */
#define T8(x) ((x) & 0xffU)
-#ifndef SKALIBS_FLAG_REPLACE_LIBC
-
#include <skalibs/sysdeps.h>
#include <sys/types.h>
#include <string.h>
#include <strings.h>
+#include <skalibs/uint64.h>
#define byte_copy(to, n, from) memmove(to, (from), n)
#define byte_copyr(to, n, from) memmove(to, (from), n)
@@ -34,44 +33,28 @@
#define case_diffs strcasecmp
#define case_diffn strncasecmp
-#else
-
-extern void byte_copy (char *, unsigned int, char const *) ;
-extern void byte_copyr (char *, unsigned int, char const *) ;
-extern int byte_diff (char const *, unsigned int, char const *) gccattr_pure ;
-extern void byte_zero (void *, unsigned int) ;
-extern unsigned int str_len (char const *) gccattr_pure ;
-#define str_nlen(s, max) byte_chr(s, (max), 0)
-extern int str_diff (char const *, char const *) gccattr_pure ;
-extern int str_diffn (char const *, char const *, unsigned int) gccattr_pure ;
-extern unsigned int str_copy (char *, char const *) ;
-extern int case_diffs (char const *, char const *) gccattr_pure ;
-extern int case_diffn (char const *, char const *, unsigned int) gccattr_pure ;
-
-#endif
-
-extern unsigned int byte_chr (char const *, unsigned int, int) gccattr_pure ;
-extern unsigned int byte_rchr (char const *, unsigned int, int) gccattr_pure ;
-extern unsigned int byte_in (char const *, unsigned int, char const *, unsigned int) gccattr_pure ;
+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 unsigned int byte_count (char const *, unsigned int, char) gccattr_pure ;
+extern uint64_t byte_count (char const *, size_t, char) gccattr_pure ;
#define str_diffb(a, n, b) str_diffn(a, (b), n)
-extern unsigned int str_chr (char const *, int) gccattr_pure ;
-extern unsigned int str_rchr (char const *, int) gccattr_pure ;
+extern size_t str_chr (char const *, int) gccattr_pure ;
+extern size_t str_rchr (char const *, int) gccattr_pure ;
extern int str_start (char const *, char const *) gccattr_pure ;
#define str_equal(s, t) (!str_diff(s, t))
-extern unsigned int str_strn (char const *, unsigned int, char const *, unsigned int) gccattr_pure ;
+extern size_t str_strn (char const *, size_t, char const *, size_t) gccattr_pure ;
extern void case_lowers (char *) ;
-extern void case_lowerb (char *, unsigned int) ;
+extern void case_lowerb (char *, size_t) ;
extern void case_uppers (char *) ;
-extern void case_upperb (char *, unsigned int) ;
+extern void case_upperb (char *, size_t) ;
#define case_diffb(a, n, b) case_diffn(a, (b), n)
#define case_equals(a, b) (!case_diffs(a, b))
#define case_equalb(a, n, b) (!case_diffb(a, n, b))
-#define case_starts(s, t) case_startb(s, str_len(s), t)
-extern int case_startb (char const *, unsigned int, char const *) gccattr_pure ;
-extern unsigned int case_str (char const *, char const *) gccattr_pure ;
+#define case_starts(s, t) case_startb(s, strlen(s), t)
+extern int case_startb (char const *, size_t, char const *) gccattr_pure ;
+extern size_t case_str (char const *, char const *) gccattr_pure ;
#endif
diff --git a/src/include/skalibs/djbunix.h b/src/include/skalibs/djbunix.h
index 354ca57..a0d65a0 100644
--- a/src/include/skalibs/djbunix.h
+++ b/src/include/skalibs/djbunix.h
@@ -35,7 +35,7 @@ extern int fd_chmod (int, unsigned int) ;
extern int fd_chown (int, unsigned int, unsigned int) ;
extern int fd_sync (int) ;
extern int fd_cat (int, int) ;
-extern unsigned int fd_catn (int, int, unsigned int) ;
+extern size_t fd_catn (int, int, size_t) ;
extern int fd_ensure_open (int, int) ;
#define fd_sanitize() (fd_ensure_open(0, 0) && fd_ensure_open(1, 1) && fd_ensure_open(2, 1))
extern int lock_ex (int) ;
diff --git a/src/include/skalibs/functypes.h b/src/include/skalibs/functypes.h
index d7094fc..a443c2a 100644
--- a/src/include/skalibs/functypes.h
+++ b/src/include/skalibs/functypes.h
@@ -3,7 +3,8 @@
#ifndef FUNCTYPES_H
#define FUNCTYPES_H
-#include <skalibs/siovec.h>
+#include <sys/types.h>
+#include <sys/uio.h>
typedef int uintcmpfunc_t (unsigned int, unsigned int, void *) ;
typedef uintcmpfunc_t *uintcmpfunc_t_ref ;
@@ -26,16 +27,16 @@ typedef initfunc_t *initfunc_t_ref ;
typedef unsigned int uinitfunc_t (void *) ;
typedef uinitfunc_t *uinitfunc_t_ref ;
-typedef int iofunc_t (int, char *, unsigned int) ;
+typedef ssize_t iofunc_t (int, char *, size_t) ;
typedef iofunc_t *iofunc_t_ref ;
-typedef int iovfunc_t (int, siovec_t const *, unsigned int) ;
+typedef ssize_t iovfunc_t (int, struct iovec const *, unsigned int) ;
typedef iovfunc_t *iovfunc_t_ref ;
-typedef unsigned int alliofunc_t (int, char *, unsigned int) ;
+typedef size_t alliofunc_t (int, char *, size_t) ;
typedef alliofunc_t *alliofunc_t_ref ;
-typedef unsigned int alliovfunc_t (int, siovec_t const *, unsigned int) ;
+typedef size_t alliovfunc_t (int, struct iovec const *, unsigned int) ;
typedef alliovfunc_t *alliovfunc_t_ref ;
#endif
diff --git a/src/include/skalibs/genalloc.h b/src/include/skalibs/genalloc.h
index 1aa0613..9c81acd 100644
--- a/src/include/skalibs/genalloc.h
+++ b/src/include/skalibs/genalloc.h
@@ -3,6 +3,7 @@
#ifndef GENALLOC_H
#define GENALLOC_H
+#include <sys/types.h>
#include <skalibs/stralloc.h>
#include <skalibs/functypes.h>
@@ -30,6 +31,6 @@ typedef stralloc genalloc, *genalloc_ref ;
#define genalloc_insert(type, g1, offset, g2) stralloc_insert((g1), (offset)*sizeof(type), (g2))
#define genalloc_deepfree(type, g, f) genalloc_deepfree_size(g, (freefunc_t_ref)(f), sizeof(type))
-extern void genalloc_deepfree_size (genalloc *, freefunc_t_ref, unsigned int) ;
+extern void genalloc_deepfree_size (genalloc *, freefunc_t_ref, size_t) ;
#endif
diff --git a/src/include/skalibs/genwrite.h b/src/include/skalibs/genwrite.h
index 9ae0fb9..0b3af87 100644
--- a/src/include/skalibs/genwrite.h
+++ b/src/include/skalibs/genwrite.h
@@ -3,7 +3,9 @@
#ifndef GENWRITE_H
#define GENWRITE_H
-typedef int genwrite_put_func_t (void *, char const *, unsigned int) ;
+#include <sys/types.h>
+
+typedef ssize_t genwrite_put_func_t (void *, char const *, size_t) ;
typedef genwrite_put_func_t *genwrite_put_func_t_ref ;
typedef int genwrite_flush_func_t (void *) ;
diff --git a/src/include/skalibs/stralloc.h b/src/include/skalibs/stralloc.h
index 2d762d4..2ec4c23 100644
--- a/src/include/skalibs/stralloc.h
+++ b/src/include/skalibs/stralloc.h
@@ -3,38 +3,39 @@
#ifndef STRALLOC_H
#define STRALLOC_H
-#include <skalibs/bytestr.h>
-#include <skalibs/siovec.h>
+#include <sys/types.h>
+#include <string.h>
+#include <sys/uio.h>
typedef struct stralloc_s stralloc, *stralloc_ref ;
struct stralloc_s
{
char *s ;
- unsigned int len ;
- unsigned int a ;
+ size_t len ;
+ size_t a ;
} ;
#define STRALLOC_ZERO { .s = 0, .len = 0, .a = 0 }
extern stralloc const stralloc_zero ;
-extern int stralloc_ready_tuned (stralloc *, unsigned int, unsigned int, unsigned int, unsigned int) ;
+extern int stralloc_ready_tuned (stralloc *, size_t, size_t, size_t, size_t) ;
#define stralloc_ready(sa, n) stralloc_ready_tuned(sa, (n), 8, 1, 8)
#define stralloc_readyplus(sa, n) stralloc_ready(sa, (sa)->len + (n))
extern void stralloc_free (stralloc *) ;
extern int stralloc_shrink (stralloc *) ;
-extern int stralloc_copyb (stralloc *, char const *, unsigned int) ;
-extern int stralloc_catb (stralloc *, char const *, unsigned int) ;
-extern int stralloc_catv (stralloc *, siovec_t const *, unsigned int) ;
-#define stralloc_copys(sa, s) stralloc_copyb(sa, (s), str_len(s))
-#define stralloc_cats(sa, s) stralloc_catb(sa, (s), str_len(s))
+extern int stralloc_copyb (stralloc *, char const *, size_t) ;
+extern int stralloc_catb (stralloc *, char const *, size_t) ;
+extern int stralloc_catv (stralloc *, struct iovec const *, unsigned int) ;
+#define stralloc_copys(sa, s) stralloc_copyb(sa, (s), strlen(s))
+#define stralloc_cats(sa, s) stralloc_catb(sa, (s), strlen(s))
#define stralloc_copy(sa1, sa2) stralloc_copyb(sa1, (sa2)->s, (sa2)->len)
#define stralloc_cat(sa1, sa2) stralloc_catb(sa1, (sa2)->s, (sa2)->len)
extern int stralloc_append (stralloc *, char) ;
extern void stralloc_reverse (stralloc *) ;
-extern void stralloc_reverse_blocks (stralloc *, unsigned int) ;
+extern void stralloc_reverse_blocks (stralloc *, size_t) ;
#define stralloc_0(sa) stralloc_catb(sa, "", 1)
-extern int stralloc_insertb (stralloc *, unsigned int, char const *, unsigned int) ;
-#define stralloc_inserts(sa, offset, s) stralloc_insertb(sa, offset, (s), str_len(s))
+extern int stralloc_insertb (stralloc *, size_t, char const *, size_t) ;
+#define stralloc_inserts(sa, offset, s) stralloc_insertb(sa, offset, (s), strlen(s))
#define stralloc_insert(sa1, offset, sa2) stralloc_insertb(sa1, offset, (sa2)->s, (sa2)->len)
#endif
diff --git a/src/librandom/random_init.c b/src/librandom/random_init.c
index 3ab5b08..cf7ef32 100644
--- a/src/librandom/random_init.c
+++ b/src/librandom/random_init.c
@@ -10,9 +10,11 @@
int random_init ()
{
+#ifdef SKALIBS_HASARC4RANDOM_ADDRANDOM
char seed[160] ;
random_makeseed(seed) ;
arc4random_addrandom((unsigned char *)seed, 160) ;
+#endif
return 1 ;
}
diff --git a/src/libstddjb/absolutepath_tmp.c b/src/libstddjb/absolutepath_tmp.c
index 79a613a..3d3c2b1 100644
--- a/src/libstddjb/absolutepath_tmp.c
+++ b/src/libstddjb/absolutepath_tmp.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <skalibs/bytestr.h>
@@ -8,8 +9,8 @@
int sarealpath_tmp (stralloc *sa, char const *path, stralloc *tmp)
{
- unsigned int tmpbase = tmp->len ;
- unsigned int base = sa->len ;
+ size_t tmpbase = tmp->len ;
+ size_t base = sa->len ;
unsigned int loop = 48 ;
int fdhere ;
int wasnull = !sa->s ;
diff --git a/src/libstddjb/alloc.c b/src/libstddjb/alloc.c
index 31e3e05..bf291f0 100644
--- a/src/libstddjb/alloc.c
+++ b/src/libstddjb/alloc.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <sys/types.h>
#include <errno.h>
#include <stdlib.h>
#include <skalibs/sysdeps.h>
@@ -13,7 +14,7 @@
# define PLM(...) (bprintf(buffer_2, "%s: debug_alloc: ", PROG), bprintf(buffer_2, __VA_ARGS__), buffer_putflush(buffer_2, "\n", 1))
#endif
-aligned_char *alloc (unsigned int n)
+aligned_char *alloc (size_t n)
{
register aligned_char *p = n ? (aligned_char *)malloc(n) : (aligned_char *)alloc_0 ;
#ifdef DEBUG_ALLOC
@@ -37,7 +38,7 @@ void alloc_free (void *p)
errno = e ;
}
-int alloc_realloc (aligned_char **x, unsigned int n)
+int alloc_realloc (aligned_char **x, size_t n)
{
aligned_char *y = n ? (aligned_char *)realloc(*x, n) : (free(*x), alloc_0) ;
#ifdef DEBUG_ALLOC
diff --git a/src/libstddjb/allread.c b/src/libstddjb/allread.c
index 9f3d3bc..a33b650 100644
--- a/src/libstddjb/allread.c
+++ b/src/libstddjb/allread.c
@@ -1,8 +1,9 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/allreadwrite.h>
-unsigned int allread (int fd, char *buf, unsigned int len)
+size_t allread (int fd, char *buf, size_t len)
{
- return allreadwrite(&fd_read, fd, buf, len) ;
+ return allreadwrite(&fd_readv, fd, buf, len) ;
}
diff --git a/src/libstddjb/allreadv.c b/src/libstddjb/allreadv.c
index 5eb3863..13514cc 100644
--- a/src/libstddjb/allreadv.c
+++ b/src/libstddjb/allreadv.c
@@ -1,9 +1,10 @@
/* ISC license. */
+#include <sys/types.h>
+#include <sys/uio.h>
#include <skalibs/allreadwrite.h>
-#include <skalibs/siovec.h>
-unsigned int allreadv (int fd, siovec_t const *v, unsigned int vlen)
+size_t allreadv (int fd, struct iovec const *v, unsigned int vlen)
{
- return allreadwritev(&fd_readsv, fd, v, vlen) ;
+ return allreadwritev(&fd_readv, fd, v, vlen) ;
}
diff --git a/src/libstddjb/allreadwrite.c b/src/libstddjb/allreadwrite.c
index a811f69..0e22a8d 100644
--- a/src/libstddjb/allreadwrite.c
+++ b/src/libstddjb/allreadwrite.c
@@ -1,14 +1,16 @@
/* ISC license. */
+#include <sys/types.h>
#include <errno.h>
+#include <skalibs/functypes.h>
#include <skalibs/allreadwrite.h>
-unsigned int allreadwrite (iofunc_t_ref op, int fd, register char *buf, register unsigned int len)
+size_t allreadwrite (iofunc_t_ref op, int fd, char *buf, size_t len)
{
- register unsigned int written = 0 ;
+ size_t written = 0 ;
while (len)
{
- register int w = (*op)(fd, buf, len) ;
+ register ssize_t w = (*op)(fd, buf, len) ;
if (w <= 0)
{
if (!w) errno = 0 ;
diff --git a/src/libstddjb/allreadwritev.c b/src/libstddjb/allreadwritev.c
index 28695a1..2b06ac7 100644
--- a/src/libstddjb/allreadwritev.c
+++ b/src/libstddjb/allreadwritev.c
@@ -1,18 +1,20 @@
/* ISC license. */
-#include <errno.h>
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <skalibs/functypes.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/siovec.h>
-unsigned int allreadwritev (iovfunc_t_ref op, int fd, siovec_t const *v, unsigned int vlen)
+size_t allreadwritev (iovfunc_t_ref op, int fd, struct iovec const *v, unsigned int vlen)
{
- register unsigned int written = 0 ;
- siovec_t vv[vlen] ;
- for (; written < vlen ; written++) vv[written] = v[written] ;
- written = 0 ;
+ size_t written = 0 ;
+ struct iovec vv[vlen] ;
+ unsigned int i = 0 ;
+ for (; i < vlen ; i++) vv[i] = v[i] ;
while (siovec_len(vv, vlen))
{
- register int w = (*op)(fd, vv, vlen) ;
+ register 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 61c8ad7..f465eb4 100644
--- a/src/libstddjb/allwrite.c
+++ b/src/libstddjb/allwrite.c
@@ -2,7 +2,7 @@
#include <skalibs/allreadwrite.h>
-unsigned int allwrite (int fd, char const *buf, unsigned int len)
+size_t allwrite (int fd, char const *buf, size_t len)
{
return allreadwrite((iofunc_t_ref)&fd_write, fd, (char *)buf, len) ;
}
diff --git a/src/libstddjb/allwritev.c b/src/libstddjb/allwritev.c
index d7195a8..dc343a4 100644
--- a/src/libstddjb/allwritev.c
+++ b/src/libstddjb/allwritev.c
@@ -1,9 +1,10 @@
/* ISC license. */
+#include <sys/types.h>
+#include <sys/uio.h>
#include <skalibs/allreadwrite.h>
-#include <skalibs/siovec.h>
-unsigned int allwritev (int fd, siovec_t const *v, unsigned int vlen)
+size_t allwritev (int fd, struct iovec const *v, unsigned int vlen)
{
- return allreadwritev(&fd_writesv, fd, v, vlen) ;
+ return allreadwritev(&fd_writev, fd, v, vlen) ;
}
diff --git a/src/libstddjb/bitarray_and.c b/src/libstddjb/bitarray_and.c
index d2f491e..449f300 100644
--- a/src/libstddjb/bitarray_and.c
+++ b/src/libstddjb/bitarray_and.c
@@ -1,10 +1,11 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/bitarray.h>
-void bitarray_and (unsigned char *c, unsigned char const *a, unsigned char const *b, unsigned int n)
+void bitarray_and (unsigned char *c, unsigned char const *a, unsigned char const *b, size_t n)
{
- unsigned int len = bitarray_div8(n) ;
- register unsigned int i = 0 ;
+ size_t len = bitarray_div8(n) ;
+ register size_t i = 0 ;
for (; i < len ; i++) c[i] = a[i] & b[i] ;
}
diff --git a/src/libstddjb/bitarray_clearsetn.c b/src/libstddjb/bitarray_clearsetn.c
index d14d6e4..82bff7e 100644
--- a/src/libstddjb/bitarray_clearsetn.c
+++ b/src/libstddjb/bitarray_clearsetn.c
@@ -1,8 +1,9 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/bitarray.h>
-void bitarray_clearsetn (register unsigned char *s, register unsigned int a, register unsigned int b, register int h)
+void bitarray_clearsetn (register unsigned char *s, register size_t a, register size_t b, register int h)
{
if (!b) return ;
b += a ;
@@ -14,7 +15,7 @@ void bitarray_clearsetn (register unsigned char *s, register unsigned int a, reg
else
{
register unsigned char mask = ~((1 << (a & 7)) - 1) ;
- register unsigned int i = (a>>3) + 1 ;
+ register size_t i = (a>>3) + 1 ;
if (h) s[a>>3] |= mask ; else s[a>>3] &= ~mask ;
mask = h ? 0xff : 0x00 ;
for (; i < b>>3 ; i++) s[i] = mask ;
diff --git a/src/libstddjb/bitarray_count.c b/src/libstddjb/bitarray_count.c
index 724f2b3..47dfda7 100644
--- a/src/libstddjb/bitarray_count.c
+++ b/src/libstddjb/bitarray_count.c
@@ -1,5 +1,7 @@
/* ISC license. */
+#include <sys/types.h>
+#include <skalibs/uint64.h>
#include <skalibs/bitarray.h>
#define B0(n) n, n+1, n+1, n+2
@@ -7,12 +9,12 @@
#define B2(n) B1(n), B1(n+1), B1(n+1), B1(n+2)
#define B3(n) B2(n), B2(n+1), B2(n+1), B2(n+2)
-unsigned int bitarray_countones (unsigned char const *c, unsigned int n)
+uint64_t bitarray_countones (unsigned char const *c, size_t n)
{
static unsigned char const table[256] = { B3(0) } ;
- unsigned int len = bitarray_div8(n) ;
- unsigned int total = 0 ;
- register unsigned int i = 0 ;
+ size_t len = bitarray_div8(n) ;
+ uint64_t total = 0 ;
+ register size_t i = 0 ;
if (n & 7) len-- ;
for (; i < len ; i++) total += table[c[i]] ;
if (n & 7) total += table[c[i] & ((1 << (n & 7)) - 1)] ;
diff --git a/src/libstddjb/bitarray_firstclear.c b/src/libstddjb/bitarray_firstclear.c
index 80b6fbb..869dffe 100644
--- a/src/libstddjb/bitarray_firstclear.c
+++ b/src/libstddjb/bitarray_firstclear.c
@@ -1,11 +1,12 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/bitarray.h>
-unsigned int bitarray_firstclear (register unsigned char const *s, unsigned int max)
+size_t bitarray_firstclear (register unsigned char const *s, size_t max)
{
- unsigned int n = bitarray_div8(max) ;
- register unsigned int i = 0 ;
+ size_t n = bitarray_div8(max) ;
+ register size_t i = 0 ;
for (; i < n ; i++) if (s[i] != 0xffU) break ;
if (i == n) return max ;
i <<= 3 ;
diff --git a/src/libstddjb/bitarray_firstclear_skip.c b/src/libstddjb/bitarray_firstclear_skip.c
index 8a32dba..ef49ee0 100644
--- a/src/libstddjb/bitarray_firstclear_skip.c
+++ b/src/libstddjb/bitarray_firstclear_skip.c
@@ -1,11 +1,12 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/bitarray.h>
-unsigned int bitarray_firstclear_skip (register unsigned char const *s, unsigned int max, unsigned int skip)
+size_t bitarray_firstclear_skip (register unsigned char const *s, size_t max, size_t skip)
{
- register unsigned int i = bitarray_div8(skip) ;
- register unsigned int j = i << 3 > max ? max : i << 3 ;
+ register size_t i = bitarray_div8(skip) ;
+ register size_t j = i << 3 > max ? max : i << 3 ;
if (i && s[i-1] != 0xffU)
{
while ((skip < j) && bitarray_peek(s, skip)) skip++ ;
diff --git a/src/libstddjb/bitarray_firstset.c b/src/libstddjb/bitarray_firstset.c
index de3d27e..1422111 100644
--- a/src/libstddjb/bitarray_firstset.c
+++ b/src/libstddjb/bitarray_firstset.c
@@ -1,11 +1,12 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/bitarray.h>
-unsigned int bitarray_firstset (register unsigned char const *s, unsigned int max)
+size_t bitarray_firstset (register unsigned char const *s, size_t max)
{
- unsigned int n = bitarray_div8(max) ;
- register unsigned int i = 0 ;
+ size_t n = bitarray_div8(max) ;
+ register size_t i = 0 ;
for (; i < n ; i++) if (s[i]) break ;
if (i == n) return max ;
i <<= 3 ;
diff --git a/src/libstddjb/bitarray_firstset_skip.c b/src/libstddjb/bitarray_firstset_skip.c
index 2f269cf..3689375 100644
--- a/src/libstddjb/bitarray_firstset_skip.c
+++ b/src/libstddjb/bitarray_firstset_skip.c
@@ -1,11 +1,12 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/bitarray.h>
-unsigned int bitarray_firstset_skip (register unsigned char const *s, unsigned int max, unsigned int skip)
+size_t bitarray_firstset_skip (register unsigned char const *s, size_t max, size_t skip)
{
- register unsigned int i = bitarray_div8(skip) ;
- register unsigned int j = i << 3 > max ? max : i << 3 ;
+ register size_t i = bitarray_div8(skip) ;
+ register size_t j = i << 3 > max ? max : i << 3 ;
if (i && s[i-1])
{
while ((skip < j) && !bitarray_peek(s, skip)) skip++ ;
diff --git a/src/libstddjb/bitarray_not.c b/src/libstddjb/bitarray_not.c
index de37b9f..06da25a 100644
--- a/src/libstddjb/bitarray_not.c
+++ b/src/libstddjb/bitarray_not.c
@@ -1,8 +1,9 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/bitarray.h>
-void bitarray_not (register unsigned char *s, register unsigned int a, register unsigned int b)
+void bitarray_not (register unsigned char *s, register size_t a, register size_t b)
{
if (!b) return ;
b += a ;
@@ -10,7 +11,7 @@ void bitarray_not (register unsigned char *s, register unsigned int a, register
s[a>>3] ^= ((1 << (a & 7)) - 1) ^ ((a << (b & 7)) - 1) ;
else
{
- register unsigned int i = (a>>3) + 1 ;
+ register size_t i = (a>>3) + 1 ;
s[a>>3] ^= ~((1 << (a & 7)) - 1) ;
for (; i < (b>>3) ; i++) s[i] = ~s[i] ;
s[b>>3] ^= (1 << (b & 7)) - 1 ;
diff --git a/src/libstddjb/bitarray_or.c b/src/libstddjb/bitarray_or.c
index 9e9e6b3..1220ed2 100644
--- a/src/libstddjb/bitarray_or.c
+++ b/src/libstddjb/bitarray_or.c
@@ -1,10 +1,11 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/bitarray.h>
-void bitarray_or (unsigned char *c, unsigned char const *a, unsigned char const *b, unsigned int n)
+void bitarray_or (unsigned char *c, unsigned char const *a, unsigned char const *b, size_t n)
{
- unsigned int len = bitarray_div8(n) ;
- register unsigned int i = 0 ;
+ size_t len = bitarray_div8(n) ;
+ register size_t i = 0 ;
for (; i < len ; i++) c[i] = a[i] | b[i] ;
}
diff --git a/src/libstddjb/bitarray_testandpoke.c b/src/libstddjb/bitarray_testandpoke.c
index 5075f1d..5b13b7a 100644
--- a/src/libstddjb/bitarray_testandpoke.c
+++ b/src/libstddjb/bitarray_testandpoke.c
@@ -1,8 +1,9 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/bitarray.h>
-int bitarray_testandpoke (register unsigned char *s, register unsigned int n, register int h)
+int bitarray_testandpoke (register unsigned char *s, register size_t n, register int h)
{
register unsigned char mask = 1 << (n & 7) ;
register unsigned char c = s[n>>3] ;
diff --git a/src/libstddjb/bitarray_xor.c b/src/libstddjb/bitarray_xor.c
index 8b16f25..dde5dc7 100644
--- a/src/libstddjb/bitarray_xor.c
+++ b/src/libstddjb/bitarray_xor.c
@@ -1,10 +1,11 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/bitarray.h>
-void bitarray_xor (unsigned char *c, unsigned char const *a, unsigned char const *b, unsigned int n)
+void bitarray_xor (unsigned char *c, unsigned char const *a, unsigned char const *b, size_t n)
{
- unsigned int len = bitarray_div8(n) ;
- register unsigned int i = 0 ;
+ size_t len = bitarray_div8(n) ;
+ register size_t i = 0 ;
for (; i < len ; i++) c[i] = a[i] ^ b[i] ;
}
diff --git a/src/libstddjb/bufalloc_clean.c b/src/libstddjb/bufalloc_clean.c
index 79b5880..2b78f39 100644
--- a/src/libstddjb/bufalloc_clean.c
+++ b/src/libstddjb/bufalloc_clean.c
@@ -1,13 +1,13 @@
/* ISC license. */
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/bufalloc.h>
void bufalloc_clean (register bufalloc *ba)
{
if (ba->p)
{
- byte_copy(ba->x.s, ba->x.len - ba->p, ba->x.s + ba->p) ;
+ memmove(ba->x.s, ba->x.s + ba->p, ba->x.len - ba->p) ;
ba->x.len -= ba->p ;
ba->p = 0 ;
}
diff --git a/src/libstddjb/bufalloc_flush.c b/src/libstddjb/bufalloc_flush.c
index e6ddfc2..b6de51e 100644
--- a/src/libstddjb/bufalloc_flush.c
+++ b/src/libstddjb/bufalloc_flush.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <skalibs/functypes.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/bufalloc.h>
diff --git a/src/libstddjb/bufalloc_getlen.c b/src/libstddjb/bufalloc_getlen.c
index 696e41d..600e2ab 100644
--- a/src/libstddjb/bufalloc_getlen.c
+++ b/src/libstddjb/bufalloc_getlen.c
@@ -1,8 +1,9 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/bufalloc.h>
-unsigned int bufalloc_getlen (bufalloc const *ba)
+size_t bufalloc_getlen (bufalloc const *ba)
{
return bufalloc_len(ba) ;
}
diff --git a/src/libstddjb/bufalloc_init.c b/src/libstddjb/bufalloc_init.c
index 913dabb..d6a89da 100644
--- a/src/libstddjb/bufalloc_init.c
+++ b/src/libstddjb/bufalloc_init.c
@@ -1,9 +1,10 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/stralloc.h>
#include <skalibs/bufalloc.h>
-void bufalloc_init (bufalloc *ba, int (*op)(int, char const *, unsigned int), int fd)
+void bufalloc_init (bufalloc *ba, int (*op)(int, char const *, size_t), int fd)
{
ba->x = stralloc_zero ;
ba->op = op ;
diff --git a/src/libstddjb/buffer_0.c b/src/libstddjb/buffer_0.c
index 5d40465..d1b4688 100644
--- a/src/libstddjb/buffer_0.c
+++ b/src/libstddjb/buffer_0.c
@@ -6,4 +6,4 @@
#include <skalibs/buffer.h>
static char buf[BUFFER_INSIZE] ;
-buffer buffer_0_ = BUFFER_INIT(&fd_readsv, 0, buf, BUFFER_INSIZE) ;
+buffer buffer_0_ = BUFFER_INIT(&fd_readv, 0, buf, BUFFER_INSIZE) ;
diff --git a/src/libstddjb/buffer_0small.c b/src/libstddjb/buffer_0small.c
index 7537dd6..203908c 100644
--- a/src/libstddjb/buffer_0small.c
+++ b/src/libstddjb/buffer_0small.c
@@ -6,4 +6,4 @@
#include <skalibs/buffer.h>
static char buf[BUFFER_INSIZE_SMALL] ;
-buffer buffer_0small_ = BUFFER_INIT(&fd_readsv, 0, buf, BUFFER_INSIZE_SMALL) ;
+buffer buffer_0small_ = BUFFER_INIT(&fd_readv, 0, buf, BUFFER_INSIZE_SMALL) ;
diff --git a/src/libstddjb/buffer_1.c b/src/libstddjb/buffer_1.c
index 46d9647..0def179 100644
--- a/src/libstddjb/buffer_1.c
+++ b/src/libstddjb/buffer_1.c
@@ -6,4 +6,4 @@
#include <skalibs/buffer.h>
static char buf[BUFFER_OUTSIZE] ;
-buffer buffer_1_ = BUFFER_INIT(&fd_writesv, 1, buf, BUFFER_OUTSIZE) ;
+buffer buffer_1_ = BUFFER_INIT(&fd_writev, 1, buf, BUFFER_OUTSIZE) ;
diff --git a/src/libstddjb/buffer_1small.c b/src/libstddjb/buffer_1small.c
index 2bf13e6..27ba875 100644
--- a/src/libstddjb/buffer_1small.c
+++ b/src/libstddjb/buffer_1small.c
@@ -6,4 +6,4 @@
#include <skalibs/buffer.h>
static char buf[BUFFER_OUTSIZE_SMALL] ;
-buffer buffer_1small_ = BUFFER_INIT(&fd_writesv, 1, buf, BUFFER_OUTSIZE_SMALL) ;
+buffer buffer_1small_ = BUFFER_INIT(&fd_writev, 1, buf, BUFFER_OUTSIZE_SMALL) ;
diff --git a/src/libstddjb/buffer_2.c b/src/libstddjb/buffer_2.c
index 8bf9d63..145d424 100644
--- a/src/libstddjb/buffer_2.c
+++ b/src/libstddjb/buffer_2.c
@@ -6,4 +6,4 @@
#include <skalibs/buffer.h>
static char buf[BUFFER_ERRSIZE] ;
-buffer buffer_2_ = BUFFER_INIT(&fd_writesv, 2, buf, BUFFER_ERRSIZE) ;
+buffer buffer_2_ = BUFFER_INIT(&fd_writev, 2, buf, BUFFER_ERRSIZE) ;
diff --git a/src/libstddjb/buffer_flush1read.c b/src/libstddjb/buffer_flush1read.c
index aaa2869..0384602 100644
--- a/src/libstddjb/buffer_flush1read.c
+++ b/src/libstddjb/buffer_flush1read.c
@@ -1,11 +1,12 @@
/* ISC license. */
+#include <sys/types.h>
+#include <sys/uio.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/buffer.h>
-#include <skalibs/siovec.h>
-int buffer_flush1read (int fd, siovec_t const *v, unsigned int n)
+ssize_t buffer_flush1read (int fd, struct iovec const *v, unsigned int n)
{
if (!buffer_flush(buffer_1)) return -1 ;
- return fd_readsv(fd, v, n) ;
+ return fd_readv(fd, v, n) ;
}
diff --git a/src/libstddjb/byte_chr.c b/src/libstddjb/byte_chr.c
index 45ad543..d24e92d 100644
--- a/src/libstddjb/byte_chr.c
+++ b/src/libstddjb/byte_chr.c
@@ -1,26 +1,11 @@
/* ISC license. */
-#include <skalibs/config.h>
-#include <skalibs/bytestr.h>
-
-#ifndef SKALIBS_FLAG_REPLACE_LIBC
-
+#include <sys/types.h>
#include <string.h>
+#include <skalibs/bytestr.h>
-unsigned int byte_chr (char const *s, unsigned int n, int c)
+size_t byte_chr (char const *s, size_t n, int c)
{
register void *p = memchr(s, c, n) ;
- return p ? (unsigned int)((char *)p - s) : n ;
+ return p ? (char *)p - s : n ;
}
-
-#else
-
-unsigned int byte_chr (char const *s, unsigned int n, int c)
-{
- register unsigned int i = 0 ;
- register char ch = c ;
- for (; i < n && *s++ != ch ; i++) ;
- return i ;
-}
-
-#endif
diff --git a/src/libstddjb/byte_count.c b/src/libstddjb/byte_count.c
index 5e3f8af..a09e044 100644
--- a/src/libstddjb/byte_count.c
+++ b/src/libstddjb/byte_count.c
@@ -1,10 +1,11 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/bytestr.h>
-unsigned int byte_count (register char const *s, register unsigned int len, register char b)
+size_t byte_count (char const *s, size_t len, char b)
{
- register unsigned int n = 0 ;
+ size_t n = 0 ;
while (len--) if (*s++ == b) n++ ;
return n ;
}
diff --git a/src/libstddjb/byte_in.c b/src/libstddjb/byte_in.c
index 60625c5..cb6e5bc 100644
--- a/src/libstddjb/byte_in.c
+++ b/src/libstddjb/byte_in.c
@@ -1,8 +1,9 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/bytestr.h>
-unsigned int byte_in (char const *s, register unsigned int n, register char const *sep, register unsigned int len)
+size_t byte_in (char const *s, size_t n, char const *sep, size_t len)
{
register char const *t = s ;
while (n--)
diff --git a/src/libstddjb/byte_rchr.c b/src/libstddjb/byte_rchr.c
index 3564c36..66fbf27 100644
--- a/src/libstddjb/byte_rchr.c
+++ b/src/libstddjb/byte_rchr.c
@@ -1,11 +1,12 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/bytestr.h>
-unsigned int byte_rchr (register char const *s, unsigned int n, int c)
+size_t byte_rchr (char const *s, size_t n, int c)
{
- register unsigned int i = n ;
- register char ch = c ;
+ size_t i = n ;
+ char ch = c ;
s += n ;
while (i--) if (*--s == ch) return i ;
return n ;
diff --git a/src/libstddjb/case_lowerb.c b/src/libstddjb/case_lowerb.c
index 9f51ed5..1285b52 100644
--- a/src/libstddjb/case_lowerb.c
+++ b/src/libstddjb/case_lowerb.c
@@ -1,10 +1,11 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/bytestr.h>
-void case_lowerb (register char *s, unsigned int len)
+void case_lowerb (register char *s, size_t len)
{
- register unsigned char const d = 'a' - 'A' ;
+ unsigned char const d = 'a' - 'A' ;
while (len--)
{
if (('A' <= *s) && (*s <= 'Z')) *s += d ;
diff --git a/src/libstddjb/case_startb.c b/src/libstddjb/case_startb.c
index cae0fb4..d69f461 100644
--- a/src/libstddjb/case_startb.c
+++ b/src/libstddjb/case_startb.c
@@ -1,9 +1,11 @@
/* ISC license. */
+#include <sys/types.h>
+#include <string.h>
#include <skalibs/bytestr.h>
-int case_startb (register char const *s, unsigned int slen, register char const *t)
+int case_startb (register char const *s, size_t slen, register char const *t)
{
- register unsigned int tlen = str_len(t) ;
+ size_t tlen = strlen(t) ;
return slen < tlen ? 0 : !case_diffb(s, tlen, t) ;
}
diff --git a/src/libstddjb/case_str.c b/src/libstddjb/case_str.c
index 14409c3..a6cd9b4 100644
--- a/src/libstddjb/case_str.c
+++ b/src/libstddjb/case_str.c
@@ -1,32 +1,33 @@
/* ISC license. */
-#include <skalibs/config.h>
#include <skalibs/sysdeps.h>
-#if defined(SKALIBS_HASSTRCASESTR) && !defined(SKALIBS_FLAG_REPLACE_LIBC)
+#ifdef SKALIBS_HASSTRCASESTR
#include <skalibs/nonposix.h>
#include <string.h>
#include <skalibs/bytestr.h>
-unsigned int case_str (char const *haystack, char const *needle)
+size_t case_str (char const *haystack, char const *needle)
{
register char *p = strcasestr(haystack, needle) ;
- return p ? p - haystack : str_len(haystack) ;
+ return p ? p - haystack : strlen(haystack) ;
}
#else
+#include <sys/types.h>
+#include <string.h>
#include <skalibs/bytestr.h>
-unsigned int case_str (char const *haystack, char const *needle)
+size_t case_str (char const *haystack, char const *needle)
{
- unsigned int nlen = str_len(needle) ;
- register char const *p = haystack ;
+ size_t nlen = strlen(needle) ;
+ char const *p = haystack ;
if (!nlen) return 0 ;
for (; *p ; p++)
if (!case_diffb(p, nlen, needle)) return p - haystack ;
- return str_len(haystack) ;
+ return strlen(haystack) ;
}
#endif
diff --git a/src/libstddjb/case_upperb.c b/src/libstddjb/case_upperb.c
index 54ceab4..78ece8f 100644
--- a/src/libstddjb/case_upperb.c
+++ b/src/libstddjb/case_upperb.c
@@ -2,9 +2,9 @@
#include <skalibs/bytestr.h>
-void case_upperb (register char *s, unsigned int len)
+void case_upperb (char *s, size_t len)
{
- register unsigned char const d = 'a' - 'A' ;
+ unsigned char const d = 'a' - 'A' ;
while (len--)
{
if (('a' <= *s) && (*s <= 'z')) *s -= d ;
diff --git a/src/libstddjb/cdb_make.c b/src/libstddjb/cdb_make.c
index 203d24c..c7e79d3 100644
--- a/src/libstddjb/cdb_make.c
+++ b/src/libstddjb/cdb_make.c
@@ -15,7 +15,7 @@ int cdb_make_start (struct cdb_make *c, int fd)
{
c->hplist = genalloc_zero ;
c->pos = 2048 ;
- buffer_init(&c->b, &fd_writesv, fd, c->buf, BUFFER_OUTSIZE) ;
+ buffer_init(&c->b, &fd_writev, fd, c->buf, BUFFER_OUTSIZE) ;
return (int)lseek(fd, c->pos, SEEK_SET) ;
}
diff --git a/src/libstddjb/fd_cat.c b/src/libstddjb/fd_cat.c
index 5682f02..1853427 100644
--- a/src/libstddjb/fd_cat.c
+++ b/src/libstddjb/fd_cat.c
@@ -1,16 +1,17 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/iobuffer.h>
#include <skalibs/djbunix.h>
int fd_cat (int from, int to)
{
iobuffer b ;
- unsigned int n = 0 ;
+ size_t n = 0 ;
if (!iobuffer_init(&b, from, to)) return -1 ;
for (;;)
{
- register int r = iobuffer_fill(&b) ;
+ register ssize_t r = iobuffer_fill(&b) ;
if (r < 0) goto err ;
else if (!r) break ;
if (!iobuffer_flush(&b)) goto err ;
diff --git a/src/libstddjb/fd_catn.c b/src/libstddjb/fd_catn.c
index ca78546..b757853 100644
--- a/src/libstddjb/fd_catn.c
+++ b/src/libstddjb/fd_catn.c
@@ -1,20 +1,21 @@
/* ISC license. */
+#include <sys/types.h>
#include <errno.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/iobuffer.h>
#include <skalibs/djbunix.h>
-unsigned int fd_catn (int from, int to, unsigned int n)
+size_t fd_catn (int from, int to, size_t n)
{
- unsigned int w = 0 ;
+ size_t w = 0 ;
if (n >= IOBUFFER_SIZE)
{
iobuffer b ;
if (!iobuffer_init(&b, from, to)) return 0 ;
while (n >= IOBUFFER_SIZE)
{
- register int r = iobuffer_fill(&b) ;
+ register ssize_t r = iobuffer_fill(&b) ;
if (r <= 0)
{
iobuffer_finish(&b) ;
@@ -33,8 +34,8 @@ unsigned int fd_catn (int from, int to, unsigned int n)
{
char buf[n] ;
- unsigned int r = allread(from, buf, n) ;
- unsigned int v = 0 ;
+ size_t r = allread(from, buf, n) ;
+ size_t v = 0 ;
if (r) v = allwrite(to, buf, r) ;
w += v ;
}
diff --git a/src/libstddjb/fd_chown.c b/src/libstddjb/fd_chown.c
index 8aa36c8..f4915ae 100644
--- a/src/libstddjb/fd_chown.c
+++ b/src/libstddjb/fd_chown.c
@@ -5,11 +5,11 @@
#include <errno.h>
#include <skalibs/djbunix.h>
-int fd_chown (int fd, unsigned int uid, unsigned int gid)
+int fd_chown (int fd, uid_t uid, gid_t gid)
{
register int r ;
do
- r = fchown(fd, (uid_t)uid, (gid_t)gid) ;
+ r = fchown(fd, uid, gid) ;
while ((r == -1) && (errno == EINTR)) ;
return r ;
}
diff --git a/src/libstddjb/fd_copy2.c b/src/libstddjb/fd_copy2.c
index 5537329..4f2e80d 100644
--- a/src/libstddjb/fd_copy2.c
+++ b/src/libstddjb/fd_copy2.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <unistd.h>
#include <errno.h>
#include <skalibs/djbunix.h>
diff --git a/src/libstddjb/fd_read.c b/src/libstddjb/fd_read.c
index 22a296b..9664024 100644
--- a/src/libstddjb/fd_read.c
+++ b/src/libstddjb/fd_read.c
@@ -1,12 +1,13 @@
/* ISC license. */
+#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <skalibs/allreadwrite.h>
-int fd_read (int fd, char *buf, unsigned int len)
+ssize_t fd_read (int fd, char *buf, size_t len)
{
- register int r ;
+ register ssize_t r ;
do r = read(fd, buf, len) ;
while ((r == -1) && (errno == EINTR)) ;
return r ;
diff --git a/src/libstddjb/fd_readsv.c b/src/libstddjb/fd_readsv.c
deleted file mode 100644
index e4390df..0000000
--- a/src/libstddjb/fd_readsv.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/* ISC license. */
-
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <skalibs/allreadwrite.h>
-#include <skalibs/siovec.h>
-
-int fd_readsv (int fd, siovec_t const *v, unsigned int vlen)
-{
- struct iovec vv[vlen] ;
- iovec_from_siovec(vv, v, vlen) ;
- return fd_readv(fd, vv, vlen) ;
-}
diff --git a/src/libstddjb/fd_readv.c b/src/libstddjb/fd_readv.c
index c97d7ab..11dda66 100644
--- a/src/libstddjb/fd_readv.c
+++ b/src/libstddjb/fd_readv.c
@@ -5,9 +5,9 @@
#include <errno.h>
#include <skalibs/allreadwrite.h>
-int fd_readv (int fd, struct iovec const *v, unsigned int vlen)
+ssize_t fd_readv (int fd, struct iovec const *v, unsigned int vlen)
{
- register int r ;
+ ssize_t r ;
do r = readv(fd, v, vlen) ;
while ((r == -1) && (errno == EINTR)) ;
return r ;
diff --git a/src/libstddjb/fd_recv.c b/src/libstddjb/fd_recv.c
index 592dc8e..4eb8659 100644
--- a/src/libstddjb/fd_recv.c
+++ b/src/libstddjb/fd_recv.c
@@ -5,9 +5,9 @@
#include <errno.h>
#include <skalibs/allreadwrite.h>
-int fd_recv (int fd, char *buf, unsigned int len, unsigned int flags)
+ssize_t fd_recv (int fd, char *buf, size_t len, unsigned int flags)
{
- register int r ;
+ register ssize_t r ;
do r = recv(fd, buf, len, (int)flags) ;
while ((r == -1) && (errno == EINTR)) ;
return r ;
diff --git a/src/libstddjb/fd_send.c b/src/libstddjb/fd_send.c
index cdc3dd2..1d37bd5 100644
--- a/src/libstddjb/fd_send.c
+++ b/src/libstddjb/fd_send.c
@@ -5,9 +5,9 @@
#include <errno.h>
#include <skalibs/allreadwrite.h>
-int fd_send (int fd, char const *buf, unsigned int len, unsigned int flags)
+ssize_t fd_send (int fd, char const *buf, size_t len, unsigned int flags)
{
- register int r ;
+ register ssize_t r ;
do r = send(fd, buf, len, (int)flags) ;
while ((r == -1) && (errno == EINTR)) ;
return r ;
diff --git a/src/libstddjb/fd_write.c b/src/libstddjb/fd_write.c
index 636bce9..c6758fb 100644
--- a/src/libstddjb/fd_write.c
+++ b/src/libstddjb/fd_write.c
@@ -1,12 +1,13 @@
/* ISC license. */
+#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <skalibs/allreadwrite.h>
-int fd_write (int fd, char const *buf, unsigned int len)
+ssize_t fd_write (int fd, char const *buf, size_t len)
{
- register int r ;
+ register ssize_t r ;
do r = write(fd, buf, len) ;
while ((r == -1) && (errno == EINTR)) ;
return r ;
diff --git a/src/libstddjb/fd_writesv.c b/src/libstddjb/fd_writesv.c
deleted file mode 100644
index d16991b..0000000
--- a/src/libstddjb/fd_writesv.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/* ISC license. */
-
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <skalibs/allreadwrite.h>
-#include <skalibs/siovec.h>
-
-int fd_writesv (int fd, siovec_t const *v, unsigned int vlen)
-{
- struct iovec vv[vlen] ;
- iovec_from_siovec(vv, v, vlen) ;
- return fd_writev(fd, vv, vlen) ;
-}
diff --git a/src/libstddjb/fd_writev.c b/src/libstddjb/fd_writev.c
index d48d7f1..c54a20e 100644
--- a/src/libstddjb/fd_writev.c
+++ b/src/libstddjb/fd_writev.c
@@ -5,9 +5,9 @@
#include <errno.h>
#include <skalibs/allreadwrite.h>
-int fd_writev (int fd, struct iovec const *v, unsigned int vlen)
+ssize_t fd_writev (int fd, struct iovec const *v, unsigned int vlen)
{
- register int r ;
+ register ssize_t r ;
do r = writev(fd, v, vlen) ;
while ((r == -1) && (errno == EINTR)) ;
return r ;
diff --git a/src/libstddjb/genalloc_deepfree.c b/src/libstddjb/genalloc_deepfree.c
index cda800a..29f1527 100644
--- a/src/libstddjb/genalloc_deepfree.c
+++ b/src/libstddjb/genalloc_deepfree.c
@@ -1,12 +1,13 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/stralloc.h>
#include <skalibs/genalloc.h>
-void genalloc_deepfree_size (genalloc *g, freefunc_t_ref f, unsigned int size)
+void genalloc_deepfree_size (genalloc *g, freefunc_t_ref f, size_t size)
{
- unsigned int len = g->len / size ;
- register unsigned int i = 0 ;
+ size_t len = g->len / size ;
+ register size_t i = 0 ;
for (; i < len ; i++) (*f)(g->s + i * size) ;
stralloc_free(g) ;
}
diff --git a/src/libstddjb/genwrite_put_bufalloc.c b/src/libstddjb/genwrite_put_bufalloc.c
index 6aabe1c..4b5830d 100644
--- a/src/libstddjb/genwrite_put_bufalloc.c
+++ b/src/libstddjb/genwrite_put_bufalloc.c
@@ -1,10 +1,11 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/bufalloc.h>
#include <skalibs/genwrite.h>
-int genwrite_put_bufalloc (void *target, char const *s, unsigned int len)
+ssize_t genwrite_put_bufalloc (void *target, char const *s, size_t len)
{
register bufalloc *ba = target ;
- return bufalloc_put(ba, s, len) ? (int)len : -1 ;
+ return bufalloc_put(ba, s, len) ? (ssize_t)len : -1 ;
}
diff --git a/src/libstddjb/genwrite_put_buffer.c b/src/libstddjb/genwrite_put_buffer.c
index 1c85725..e5d7843 100644
--- a/src/libstddjb/genwrite_put_buffer.c
+++ b/src/libstddjb/genwrite_put_buffer.c
@@ -1,9 +1,10 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/buffer.h>
#include <skalibs/genwrite.h>
-int genwrite_put_buffer (void *target, char const *s, unsigned int len)
+ssize_t genwrite_put_buffer (void *target, char const *s, size_t len)
{
register buffer *b = target ;
return buffer_put(b, s, len) ;
diff --git a/src/libstddjb/genwrite_put_stralloc.c b/src/libstddjb/genwrite_put_stralloc.c
index 2a8a8e8..6f1e2b7 100644
--- a/src/libstddjb/genwrite_put_stralloc.c
+++ b/src/libstddjb/genwrite_put_stralloc.c
@@ -1,10 +1,11 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/stralloc.h>
#include <skalibs/genwrite.h>
-int genwrite_put_stralloc (void *target, char const *s, unsigned int len)
+ssize_t genwrite_put_stralloc (void *target, char const *s, size_t len)
{
register stralloc *sa = target ;
- return stralloc_catb(sa, s, len) ? (int)len : -1 ;
+ return stralloc_catb(sa, s, len) ? (ssize_t)len : -1 ;
}
diff --git a/src/libstddjb/iobufferu_init.c b/src/libstddjb/iobufferu_init.c
index 490ac59..b9d643b 100644
--- a/src/libstddjb/iobufferu_init.c
+++ b/src/libstddjb/iobufferu_init.c
@@ -10,7 +10,7 @@ int iobufferu_init (iobufferu *b, int fdin, int fdout)
register char *x = alloc(IOBUFFERU_SIZE) ;
if (!x) return 0 ;
b->buf = x ;
- buffer_init(&b->b[0], &fd_readsv, fdin, x, IOBUFFERU_SIZE) ;
- buffer_init(&b->b[1], &fd_writesv, fdout, x, IOBUFFERU_SIZE) ;
+ buffer_init(&b->b[0], &fd_readv, fdin, x, IOBUFFERU_SIZE) ;
+ buffer_init(&b->b[1], &fd_writev, fdout, x, IOBUFFERU_SIZE) ;
return 1 ;
}
diff --git a/src/libstddjb/sanitize_read.c b/src/libstddjb/sanitize_read.c
index bd8eee3..136f7ee 100644
--- a/src/libstddjb/sanitize_read.c
+++ b/src/libstddjb/sanitize_read.c
@@ -1,10 +1,11 @@
/* ISC license. */
+#include <sys/types.h>
#include <errno.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/error.h>
-int sanitize_read (int r)
+ssize_t sanitize_read (ssize_t r)
{
return r == -1 ? error_isagain(errno) ? (errno = 0, 0) : -1 :
!r ? (errno = EPIPE, -1) : r ;
diff --git a/src/libstddjb/str_chr.c b/src/libstddjb/str_chr.c
index ed55e50..a415de6 100644
--- a/src/libstddjb/str_chr.c
+++ b/src/libstddjb/str_chr.c
@@ -1,33 +1,11 @@
/* ISC license. */
-#include <skalibs/config.h>
-#include <skalibs/bytestr.h>
-
-#ifndef SKALIBS_FLAG_REPLACE_LIBC
-
+#include <sys/types.h>
#include <string.h>
+#include <skalibs/bytestr.h>
-unsigned int str_chr (register char const *s, int c)
-{
- register char *p = strchr(s, c) ;
- return p ? (unsigned int)(p - s) : strlen(s) ;
-}
-
-#else
-
-unsigned int str_chr (register char const *s, int c)
+size_t str_chr (char const *s, int c)
{
- register char ch = c ;
- register char const *t = s ;
-
- for (;;)
- {
- if (!*t) break; if (*t == ch) break; ++t;
- if (!*t) break; if (*t == ch) break; ++t;
- if (!*t) break; if (*t == ch) break; ++t;
- if (!*t) break; if (*t == ch) break; ++t;
- }
- return t - s ;
+ char *p = strchr(s, c) ;
+ return p ? p - s : strlen(s) ;
}
-
-#endif
diff --git a/src/libstddjb/str_rchr.c b/src/libstddjb/str_rchr.c
index 39a4822..c82ee69 100644
--- a/src/libstddjb/str_rchr.c
+++ b/src/libstddjb/str_rchr.c
@@ -1,28 +1,12 @@
/* ISC license. */
-#include <skalibs/config.h>
-#include <skalibs/bytestr.h>
-
-#ifndef SKALIBS_FLAG_REPLACE_LIBC
-
+#include <sys/types.h>
#include <string.h>
+#include <skalibs/bytestr.h>
-unsigned int str_rchr (register char const *s, int c)
+size_t str_rchr (register char const *s, int c)
{
register char *p = strrchr(s, c) ;
- return p ? (unsigned int)(p - s) : (unsigned int)strlen(s) ;
-}
-
-#else
-
-unsigned int str_rchr (register char const *s, int c)
-{
- register char ch = c ;
- register char const *t = s ;
- register char const *u = 0 ;
- for ( ; *t ; t++) if (*t == ch) u = t ;
- if (!u) u = t ;
- return u - s ;
+ return p ? p - s : strlen(s) ;
}
-#endif
diff --git a/src/libstddjb/str_strn.c b/src/libstddjb/str_strn.c
index 7c2e425..fef219b 100644
--- a/src/libstddjb/str_strn.c
+++ b/src/libstddjb/str_strn.c
@@ -1,36 +1,16 @@
/* ISC license. */
-#include <skalibs/config.h>
-#include <skalibs/bytestr.h>
-
-#ifdef SKALIBS_FLAG_REPLACE_LIBC
-
-/* Very naive implementation, but it's small. */
-
-unsigned int str_strn (char const *haystack, unsigned int hlen, char const *needle, unsigned int nlen)
-{
- register unsigned int i = 0 ;
- if (!nlen) return 0 ;
- if (hlen < nlen) return hlen ;
- hlen -= nlen ;
- for (; i <= hlen ; i++)
- if (!byte_diff(haystack+i, nlen, needle)) return i ;
- return hlen+nlen ;
-}
-
-#else
-
+#include <sys/types.h>
#include <string.h>
+#include <skalibs/bytestr.h>
-unsigned int str_strn (char const *haystack, unsigned int hlen, char const *needle, unsigned int nlen)
+size_t str_strn (char const *haystack, size_t hlen, char const *needle, size_t nlen)
{
char haystack2[hlen+1] ;
char needle2[nlen+1] ;
- register char *p ;
+ char *p ;
byte_copy(haystack2, hlen, haystack) ; haystack2[hlen] = 0 ;
byte_copy(needle2, nlen, needle) ; needle2[nlen] = 0 ;
p = strstr(haystack2, needle2) ;
return p ? p - haystack2 : hlen ;
}
-
-#endif
diff --git a/src/libstddjb/stralloc_catb.c b/src/libstddjb/stralloc_catb.c
index bb03405..f1bdc0a 100644
--- a/src/libstddjb/stralloc_catb.c
+++ b/src/libstddjb/stralloc_catb.c
@@ -1,12 +1,13 @@
/* ISC license. */
-#include <skalibs/bytestr.h>
+#include <sys/types.h>
+#include <string.h>
#include <skalibs/stralloc.h>
-int stralloc_catb (stralloc *sa, char const *s, unsigned int n)
+int stralloc_catb (stralloc *sa, char const *s, size_t n)
{
if (!stralloc_readyplus(sa, n)) return 0 ;
- byte_copy(sa->s + sa->len, n, s) ;
+ memmove(sa->s + sa->len, s, n) ;
sa->len += n ;
return 1 ;
}
diff --git a/src/libstddjb/stralloc_catv.c b/src/libstddjb/stralloc_catv.c
index 1649f4c..684829c 100644
--- a/src/libstddjb/stralloc_catv.c
+++ b/src/libstddjb/stralloc_catv.c
@@ -1,21 +1,22 @@
/* ISC license. */
-#include <skalibs/bytestr.h>
-#include <skalibs/siovec.h>
+#include <sys/types.h>
+#include <string.h>
+#include <sys/uio.h>
#include <skalibs/stralloc.h>
-int stralloc_catv (stralloc *sa, siovec_t const *v, unsigned int n)
+int stralloc_catv (stralloc *sa, struct iovec const *v, unsigned int n)
{
register unsigned int i = 0 ;
{
- unsigned int total = 0 ;
- for (; i < n ; i++) total += v[i].len ;
+ 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++)
{
- byte_copy(sa->s + sa->len, v[i].len, v[i].s) ;
- sa->len += v[i].len ;
+ memmove(sa->s + sa->len, v[i].iov_base, v[i].iov_len) ;
+ sa->len += v[i].iov_len ;
}
return 1 ;
}
diff --git a/src/libstddjb/stralloc_copyb.c b/src/libstddjb/stralloc_copyb.c
index be2b397..31fc31e 100644
--- a/src/libstddjb/stralloc_copyb.c
+++ b/src/libstddjb/stralloc_copyb.c
@@ -1,12 +1,13 @@
/* ISC license. */
-#include <skalibs/bytestr.h>
+#include <sys/types.h>
+#include <string.h>
#include <skalibs/stralloc.h>
-int stralloc_copyb (stralloc *sa, char const *s, unsigned int n)
+int stralloc_copyb (stralloc *sa, char const *s, size_t n)
{
if (!stralloc_ready(sa, n)) return 0 ;
- byte_copy(sa->s, n, s) ;
+ memmove(sa->s, s, n) ;
sa->len = n ;
return 1 ;
}
diff --git a/src/libstddjb/stralloc_insertb.c b/src/libstddjb/stralloc_insertb.c
index 339ffff..f964ea5 100644
--- a/src/libstddjb/stralloc_insertb.c
+++ b/src/libstddjb/stralloc_insertb.c
@@ -1,15 +1,15 @@
/* ISC license. */
+#include <sys/types.h>
#include <errno.h>
-#include <skalibs/bytestr.h>
#include <skalibs/stralloc.h>
-int stralloc_insertb (stralloc *sa, unsigned int offset, char const *s, unsigned int n)
+int stralloc_insertb (stralloc *sa, size_t offset, char const *s, size_t n)
{
if (offset > sa->len) return (errno = EINVAL, 0) ;
if (!stralloc_readyplus(sa, n)) return 0 ;
- byte_copyr(sa->s + offset + n, sa->len - offset, sa->s + offset) ;
+ memmove(sa->s + offset + n, sa->s + offset, sa->len - offset) ;
sa->len += n ;
- byte_copyr(sa->s + offset, n, s) ;
+ memmove(sa->s + offset, s, n) ;
return 1 ;
}
diff --git a/src/libstddjb/stralloc_ready_tuned.c b/src/libstddjb/stralloc_ready_tuned.c
index 04e1a41..53a47cd 100644
--- a/src/libstddjb/stralloc_ready_tuned.c
+++ b/src/libstddjb/stralloc_ready_tuned.c
@@ -1,12 +1,13 @@
/* ISC license. */
+#include <sys/types.h>
#include <errno.h>
#include <skalibs/alloc.h>
#include <skalibs/stralloc.h>
-int stralloc_ready_tuned (stralloc *sa, unsigned int n, unsigned int base, unsigned int a, unsigned int b)
+int stralloc_ready_tuned (stralloc *sa, size_t n, size_t base, size_t a, size_t b)
{
- register unsigned int t ;
+ register size_t t ;
if (!b) return (errno = EINVAL, 0) ;
t = n + base + a * n / b ;
if (t < n) return (errno = ERANGE, 0) ;
diff --git a/src/libstddjb/stralloc_reverse.c b/src/libstddjb/stralloc_reverse.c
index 9ad29e7..46d22cb 100644
--- a/src/libstddjb/stralloc_reverse.c
+++ b/src/libstddjb/stralloc_reverse.c
@@ -1,11 +1,11 @@
/* ISC license. */
-#include <skalibs/bytestr.h>
+#include <sys/types.h>
#include <skalibs/stralloc.h>
void stralloc_reverse (stralloc *sa)
{
- register unsigned int i = 0 ;
+ register size_t i = 0 ;
for (; i < sa->len >> 1 ; i++)
{
char tmp = sa->s[i] ;
diff --git a/src/libstddjb/stralloc_reverse_blocks.c b/src/libstddjb/stralloc_reverse_blocks.c
index 6a2e4b8..67a18de 100644
--- a/src/libstddjb/stralloc_reverse_blocks.c
+++ b/src/libstddjb/stralloc_reverse_blocks.c
@@ -1,17 +1,18 @@
/* ISC license. */
-#include <skalibs/bytestr.h>
+#include <sys/types.h>
+#include <string.h>
#include <skalibs/stralloc.h>
-void stralloc_reverse_blocks (stralloc *sa, unsigned int size)
+void stralloc_reverse_blocks (stralloc *sa, size_t size)
{
- register unsigned int n = sa->len / (size << 1) ;
- register unsigned int i = 0 ;
+ register size_t n = sa->len / (size << 1) ;
+ register size_t i = 0 ;
char tmp[size] ;
for (; i < n ; i++)
{
- byte_copy(tmp, size, sa->s + i * size) ;
- byte_copy(sa->s + i * size, size, sa->s + (2*n - 1 - i) * size) ;
- byte_copy(sa->s + (2*n - 1 - i) * size, size, tmp) ;
+ memcpy(tmp, sa->s + i * size, size) ;
+ memcpy(sa->s + i * size, sa->s + (2*n - 1 - i) * size, size) ;
+ memcpy(sa->s + (2*n - 1 - i) * size, tmp, size) ;
}
}
diff --git a/src/libstddjb/unsanitize_read.c b/src/libstddjb/unsanitize_read.c
index efea22a..4d9e99d 100644
--- a/src/libstddjb/unsanitize_read.c
+++ b/src/libstddjb/unsanitize_read.c
@@ -1,10 +1,11 @@
/* ISC license. */
+#include <sys/types.h>
#include <errno.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/error.h>
-int unsanitize_read (int r)
+ssize_t unsanitize_read (ssize_t r)
{
return r == -1 ? errno == EPIPE ? (errno = 0, 0) : -1 :
!r ? (errno = EWOULDBLOCK, -1) : r ;
diff --git a/src/libunixonacid/opengetlnclose.c b/src/libunixonacid/opengetlnclose.c
index 9bdf882..90940af 100644
--- a/src/libunixonacid/opengetlnclose.c
+++ b/src/libunixonacid/opengetlnclose.c
@@ -16,7 +16,7 @@ int opengetlnclose (char const *fn, stralloc *sa, int sep)
register int e ;
int fd = open_readb(fn) ;
if (fd < 0) return -1 ;
- buffer_init(&b, &fd_readsv, fd, buf, BUFFER_INSIZE) ;
+ buffer_init(&b, &fd_readv, fd, buf, BUFFER_INSIZE) ;
r = skagetln(&b, sa, sep) ;
e = errno ;
fd_close(fd) ;
diff --git a/src/libunixonacid/opengetlnclose_at.c b/src/libunixonacid/opengetlnclose_at.c
index a6fd2b6..e91acbf 100644
--- a/src/libunixonacid/opengetlnclose_at.c
+++ b/src/libunixonacid/opengetlnclose_at.c
@@ -16,7 +16,7 @@ int opengetlnclose_at (int dirfd, char const *fn, stralloc *sa, int sep)
register int e ;
int fd = open_readatb(dirfd, fn) ;
if (fd < 0) return -1 ;
- buffer_init(&b, &fd_readsv, fd, buf, BUFFER_INSIZE) ;
+ buffer_init(&b, &fd_readv, fd, buf, BUFFER_INSIZE) ;
r = skagetln(&b, sa, sep) ;
e = errno ;
fd_close(fd) ;
diff --git a/src/sysdeps/tryarc4random_addrandom.c b/src/sysdeps/tryarc4random_addrandom.c
new file mode 100644
index 0000000..e89a65c
--- /dev/null
+++ b/src/sysdeps/tryarc4random_addrandom.c
@@ -0,0 +1,12 @@
+/* ISC license. */
+
+#undef _POSIX_C_SOURCE
+#undef _XOPEN_SOURCE
+
+#include <stdlib.h>
+
+int main (void)
+{
+ arc4random_addrandom("", 1) ;
+ return 0 ;
+}