summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-01-25 15:52:18 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-01-25 15:52:18 +0000
commit00c9cb1b22cc17c4db573e0e613a5f116ff0092e (patch)
tree53178b2c52c6e97c6193f73378f3c5e5a781a914 /src
parent2746b131aa482ac17c94bc6b82e58dbcc1b752cf (diff)
downloadskalibs-00c9cb1b22cc17c4db573e0e613a5f116ff0092e.tar.xz
More work on the types. This commit builds but has errors.
Rework src/headers entirely: build skalibs/types.h Convert skalibs/fmtscan.h types. Propagate changes until it builds. There are a lot of incompatible pointer issues remaining, those will be fixed with the buffer overhaul.
Diffstat (limited to 'src')
-rw-r--r--src/headers/bits-bendian3
-rw-r--r--src/headers/bits-footer4
-rw-r--r--src/headers/bits-header6
-rw-r--r--src/headers/bits-lendian3
-rw-r--r--src/headers/bits-stdint2
-rw-r--r--src/headers/bits-template44
-rw-r--r--src/headers/gidstuff-168
-rw-r--r--src/headers/gidstuff-328
-rw-r--r--src/headers/gidstuff-648
-rw-r--r--src/headers/gidstuff-header5
-rw-r--r--src/headers/ip46-footer2
-rw-r--r--src/headers/ip46-header7
-rw-r--r--src/headers/ip46-with4
-rw-r--r--src/headers/signed-template9
-rw-r--r--src/headers/types-footer (renamed from src/headers/gidstuff-footer)0
-rw-r--r--src/headers/types-header12
-rw-r--r--src/headers/uint-1634
-rw-r--r--src/headers/uint-3234
-rw-r--r--src/headers/uint-6434
-rw-r--r--src/headers/uint-footer10
-rw-r--r--src/headers/uint-header5
-rw-r--r--src/headers/uint16-bendian3
-rw-r--r--src/headers/uint16-footer40
-rw-r--r--src/headers/uint16-header9
-rw-r--r--src/headers/uint16-lendian3
-rw-r--r--src/headers/uint32-bendian3
-rw-r--r--src/headers/uint32-footer39
-rw-r--r--src/headers/uint32-header9
-rw-r--r--src/headers/uint32-inttypesh3
-rw-r--r--src/headers/uint32-lendian3
-rw-r--r--src/headers/uint32-noulong322
-rw-r--r--src/headers/uint32-stdinth3
-rw-r--r--src/headers/uint32-ulong322
-rw-r--r--src/headers/uint64-bendian3
-rw-r--r--src/headers/uint64-footer39
-rw-r--r--src/headers/uint64-header5
-rw-r--r--src/headers/uint64-lendian3
-rw-r--r--src/headers/uint64-noulong643
-rw-r--r--src/headers/uint64-stdinth3
-rw-r--r--src/headers/uint64-ulong644
-rw-r--r--src/headers/ulong-3232
-rw-r--r--src/headers/ulong-6432
-rw-r--r--src/headers/ulong-footer10
-rw-r--r--src/headers/ulong-header5
-rw-r--r--src/headers/unsigned-template42
-rw-r--r--src/headers/ushort-1634
-rw-r--r--src/headers/ushort-3234
-rw-r--r--src/headers/ushort-footer10
-rw-r--r--src/headers/ushort-header5
-rw-r--r--src/include/skalibs/djbtime.h50
-rw-r--r--src/include/skalibs/fmtscan.h44
-rw-r--r--src/include/skalibs/netstring.h17
-rw-r--r--src/include/skalibs/stddjb.h5
-rw-r--r--src/libstddjb/child_spawn.c2
-rw-r--r--src/libstddjb/fmtscan-internal.h117
-rw-r--r--src/libstddjb/int160_scan.c (renamed from src/libstddjb/int_scan.c)4
-rw-r--r--src/libstddjb/int16_fmt.c (renamed from src/libstddjb/long_scan.c)4
-rw-r--r--src/libstddjb/int16_fmtlist.c (renamed from src/libstddjb/short_scan.c)4
-rw-r--r--src/libstddjb/int16_scan.c6
-rw-r--r--src/libstddjb/int16_scanlist.c6
-rw-r--r--src/libstddjb/int320_scan.c6
-rw-r--r--src/libstddjb/int32_fmt.c6
-rw-r--r--src/libstddjb/int32_fmtlist.c6
-rw-r--r--src/libstddjb/int32_scan.c6
-rw-r--r--src/libstddjb/int32_scanlist.c6
-rw-r--r--src/libstddjb/int640_scan.c6
-rw-r--r--src/libstddjb/int64_fmt.c6
-rw-r--r--src/libstddjb/int64_fmtlist.c6
-rw-r--r--src/libstddjb/int64_scan.c6
-rw-r--r--src/libstddjb/int64_scanlist.c6
-rw-r--r--src/libstddjb/ip46_scan.c7
-rw-r--r--src/libstddjb/ip46_scanlist.c8
-rw-r--r--src/libstddjb/ip4_fmt.c11
-rw-r--r--src/libstddjb/ip4_fmtu32.c4
-rw-r--r--src/libstddjb/ip4_scan.c9
-rw-r--r--src/libstddjb/ip4_scanlist.c7
-rw-r--r--src/libstddjb/ip4_scanlist_u32.c8
-rw-r--r--src/libstddjb/ip4_scanu32.c6
-rw-r--r--src/libstddjb/ip6_fmt.c9
-rw-r--r--src/libstddjb/ip6_scan.c9
-rw-r--r--src/libstddjb/ip6_scanlist.c7
-rw-r--r--src/libstddjb/localtm_fmt.c5
-rw-r--r--src/libstddjb/localtm_scan.c49
-rw-r--r--src/libstddjb/localtmn_fmt.c3
-rw-r--r--src/libstddjb/localtmn_scan.c7
-rw-r--r--src/libstddjb/long_fmt.c10
-rw-r--r--src/libstddjb/netstring_append.c9
-rw-r--r--src/libstddjb/netstring_appendv.c17
-rw-r--r--src/libstddjb/netstring_decode.c12
-rw-r--r--src/libstddjb/netstring_encode.c9
-rw-r--r--src/libstddjb/netstring_get.c25
-rw-r--r--src/libstddjb/netstring_put.c21
-rw-r--r--src/libstddjb/sauniquename.c4
-rw-r--r--src/libstddjb/str_fmt.c6
-rw-r--r--src/libstddjb/strn_fmt.c7
-rw-r--r--src/libstddjb/ucharn_findlen.c5
-rw-r--r--src/libstddjb/ucharn_fmt.c5
-rw-r--r--src/libstddjb/ucharn_fmt_little.c5
-rw-r--r--src/libstddjb/ucharn_scan.c3
-rw-r--r--src/libstddjb/ucharn_scan_little.c5
-rw-r--r--src/libstddjb/uint160_fmt.c6
-rw-r--r--src/libstddjb/uint160_scan.c2
-rw-r--r--src/libstddjb/uint16_fmt.c6
-rw-r--r--src/libstddjb/uint16_fmtlist.c2
-rw-r--r--src/libstddjb/uint16_pack.c3
-rw-r--r--src/libstddjb/uint16_pack_big.c3
-rw-r--r--src/libstddjb/uint16_reverse.c3
-rw-r--r--src/libstddjb/uint16_scan.c2
-rw-r--r--src/libstddjb/uint16_scanlist.c2
-rw-r--r--src/libstddjb/uint16_unpack.c5
-rw-r--r--src/libstddjb/uint16_unpack_big.c5
-rw-r--r--src/libstddjb/uint320_fmt.c6
-rw-r--r--src/libstddjb/uint320_scan.c2
-rw-r--r--src/libstddjb/uint32_fmt.c6
-rw-r--r--src/libstddjb/uint32_fmtlist.c2
-rw-r--r--src/libstddjb/uint32_pack.c3
-rw-r--r--src/libstddjb/uint32_pack_big.c3
-rw-r--r--src/libstddjb/uint32_reverse.c3
-rw-r--r--src/libstddjb/uint32_scan.c2
-rw-r--r--src/libstddjb/uint32_scanlist.c2
-rw-r--r--src/libstddjb/uint32_unpack.c5
-rw-r--r--src/libstddjb/uint32_unpack_big.c5
-rw-r--r--src/libstddjb/uint640_fmt.c8
-rw-r--r--src/libstddjb/uint640_scan.c2
-rw-r--r--src/libstddjb/uint64_fmt.c17
-rw-r--r--src/libstddjb/uint64_fmtlist.c2
-rw-r--r--src/libstddjb/uint64_pack.c2
-rw-r--r--src/libstddjb/uint64_pack_big.c2
-rw-r--r--src/libstddjb/uint64_reverse.c3
-rw-r--r--src/libstddjb/uint64_scan.c2
-rw-r--r--src/libstddjb/uint64_scanlist.c2
-rw-r--r--src/libstddjb/uint64_unpack.c4
-rw-r--r--src/libstddjb/uint64_unpack_big.c4
-rw-r--r--src/sysdeps/output-types.c22
134 files changed, 621 insertions, 763 deletions
diff --git a/src/headers/bits-bendian b/src/headers/bits-bendian
new file mode 100644
index 0000000..ef57f58
--- /dev/null
+++ b/src/headers/bits-bendian
@@ -0,0 +1,3 @@
+#define uint@BITS@_little_endian(s, n) uint@BITS@_reverse((s), (n))
+#define uint@BITS@_big_endian(s, n)
+
diff --git a/src/headers/bits-footer b/src/headers/bits-footer
new file mode 100644
index 0000000..b6f75a9
--- /dev/null
+++ b/src/headers/bits-footer
@@ -0,0 +1,4 @@
+
+typedef uint@BITS@_t uint@BITS@ ;
+
+#endif
diff --git a/src/headers/bits-header b/src/headers/bits-header
new file mode 100644
index 0000000..58eee22
--- /dev/null
+++ b/src/headers/bits-header
@@ -0,0 +1,6 @@
+/* ISC license. */
+
+#ifndef UINT@BITS@_H
+#define UINT@BITS@_H
+
+#include <sys/types.h>
diff --git a/src/headers/bits-lendian b/src/headers/bits-lendian
new file mode 100644
index 0000000..278af3e
--- /dev/null
+++ b/src/headers/bits-lendian
@@ -0,0 +1,3 @@
+#define uint@BITS@_little_endian(s, n)
+#define uint@BITS@_big_endian(s, n) uint16_reverse((s), (n))
+
diff --git a/src/headers/bits-stdint b/src/headers/bits-stdint
new file mode 100644
index 0000000..31da039
--- /dev/null
+++ b/src/headers/bits-stdint
@@ -0,0 +1,2 @@
+#include <stdint.h>
+
diff --git a/src/headers/bits-template b/src/headers/bits-template
new file mode 100644
index 0000000..4b43de2
--- /dev/null
+++ b/src/headers/bits-template
@@ -0,0 +1,44 @@
+extern void uint@BITS@_pack (char *, uint@BITS@_t) ;
+extern void uint@BITS@_pack_big (char *, uint@BITS@_t) ;
+extern void uint@BITS@_unpack (char const *, uint@BITS@_t *) ;
+extern void uint@BITS@_unpack_big (char const *, uint@BITS@_t *) ;
+extern void uint@BITS@_reverse (char *, size_t) ;
+
+#define UINT@BITS@_FMT @DFMT@
+#define UINT@BITS@_OFMT @OFMT@
+#define UINT@BITS@_XFMT @XFMT@
+#define UINT@BITS@_BFMT @BFMT@
+
+extern size_t uint@BITS@_fmt_base (char *, uint@BITS@_t, unsigned int) ;
+extern size_t uint@BITS@0_fmt_base (char *, uint@BITS@_t, size_t, unsigned int) ;
+
+#define uint@BITS@_fmt(s, u) uint@BITS@_fmt_base(s, (u), 10)
+#define uint@BITS@0_fmt(s, u, n) uint@BITS@0_fmt_base(s, u, (n), 10)
+#define uint@BITS@_ofmt(s, o) uint@BITS@_fmt_base(s, (o), 8)
+#define uint@BITS@0_ofmt(s, o, n) uint@BITS@0_fmt_base(s, o, (n), 8)
+#define uint@BITS@_xfmt(s, x) uint@BITS@_fmt_base(s, (x), 16)
+#define uint@BITS@0_xfmt(s, x, n) uint@BITS@0_fmt_base(s, x, (n), 16)
+#define uint@BITS@_bfmt(s, b) uint@BITS@0_fmt_base(s, (b), 2)
+#define uint@BITS@0_bfmt(s, b, n) uint@BITS@0_fmt_base(s, b, (n), 2)
+
+extern size_t uint@BITS@_fmtlist (char *, uint@BITS@_t const *, size_t) ;
+
+extern size_t uint@BITS@_scan_base (char const *, uint@BITS@_t *, unsigned int) ;
+extern size_t uint@BITS@0_scan_base (char const *, uint@BITS@_t *, unsigned int) ;
+
+#define uint@BITS@_scan(s, u) uint@BITS@_scan_base(s, (u), 10)
+#define uint@BITS@0_scan(s, u) uint@BITS@0_scan_base(s, (u), 10)
+#define uint@BITS@_oscan(s, u) uint@BITS@_scan_base(s, (u), 8)
+#define uint@BITS@0_oscan(s, u) uint@BITS@0_scan_base(s, (u), 8)
+#define uint@BITS@_xscan(s, u) uint@BITS@_scan_base(s, (u), 16)
+#define uint@BITS@0_xscan(s, u) uint@BITS@0_scan_base(s, (u), 16)
+#define uint@BITS@_bscan(s, u) uint@BITS@_scan_base(s, (u), 2)
+#define uint@BITS@0_bscan(s, u) uint@BITS@0_scan_base(s, (u), 2)
+
+extern size_t uint@BITS@_scanlist (uint@BITS@_t *, size_t, char const *, size_t *) ;
+
+extern size_t int@BITS@_fmt (char *, int@BITS@_t) ;
+extern size_t int@BITS@_fmtlist (char *, int@BITS@_t const *, size_t) ;
+extern size_t int@BITS@_scan (char const *, int@BITS@_t *) ;
+extern size_t int@BITS@0_scan (char const *, int@BITS@_t *) ;
+extern size_t int@BITS@_scanlist (int@BITS@_t *, size_t, char const *, size_t *) ;
diff --git a/src/headers/gidstuff-16 b/src/headers/gidstuff-16
deleted file mode 100644
index 438b843..0000000
--- a/src/headers/gidstuff-16
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <skalibs/uint16.h>
-
-#define GID_FMT UINT16_FMT
-#define gid_fmt(s, u) uint16_fmt(s, u)
-#define gid_scan(s, u) uint16_scan(s, u)
-#define gid0_scan(s, u) uint160_scan(s, u)
-#define gid_fmtlist(s, tab, n) uint16_fmtlist(s, tab, n)
-#define gid_scanlist(tab, max, s, num) uint16_scanlist(tab, max, s, num)
diff --git a/src/headers/gidstuff-32 b/src/headers/gidstuff-32
deleted file mode 100644
index 95a8f12..0000000
--- a/src/headers/gidstuff-32
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <skalibs/uint32.h>
-
-#define GID_FMT UINT32_FMT
-#define gid_fmt(s, u) uint32_fmt(s, u)
-#define gid_scan(s, u) uint32_scan(s, u)
-#define gid0_scan(s, u) uint320_scan(s, u)
-#define gid_fmtlist(s, tab, n) uint32_fmtlist(s, tab, n)
-#define gid_scanlist(tab, max, s, num) uint32_scanlist(tab, max, s, num)
diff --git a/src/headers/gidstuff-64 b/src/headers/gidstuff-64
deleted file mode 100644
index 92b869e..0000000
--- a/src/headers/gidstuff-64
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <skalibs/uint64.h>
-
-#define GID_FMT UINT64_FMT
-#define gid_fmt(s, u) uint64_fmt(s, u)
-#define gid_scan(s, u) uint64_scan(s, u)
-#define gid0_scan(s, u) uint640_scan(s, u)
-#define gid_fmtlist(s, tab, n) uint64_fmtlist(s, tab, n)
-#define gid_scanlist(tab, max, s, num) uint64_scanlist(tab, max, s, num)
diff --git a/src/headers/gidstuff-header b/src/headers/gidstuff-header
deleted file mode 100644
index 73bf86b..0000000
--- a/src/headers/gidstuff-header
+++ /dev/null
@@ -1,5 +0,0 @@
-/* ISC license. */
-
-#ifndef GIDSTUFF_H
-#define GIDSTUFF_H
-
diff --git a/src/headers/ip46-footer b/src/headers/ip46-footer
index 4340daf..4be22b5 100644
--- a/src/headers/ip46-footer
+++ b/src/headers/ip46-footer
@@ -4,7 +4,7 @@
#define socket_recvnb46_g(fd, buf, len, i, port, deadline) socket_recvnb46(fd, buf, len, i, port, (deadline), &STAMP)
#define socket_sendnb46_g(fd, buf, len, i, port, deadline) socket_sendnb46(fd, buf, len, i, port, (deadline), &STAMP)
-extern int socket_deadlineconnstamp46 (int, ip46_t const *, uint16, tain_t const *, tain_t *) ;
+extern int socket_deadlineconnstamp46 (int, ip46_t const *, uint16_t, tain_t const *, tain_t *) ;
#define socket_deadlineconnstamp46_g(fd, ip, port, deadline) socket_deadlineconnstamp46(fd, ip, port, (deadline), &STAMP)
#endif
diff --git a/src/headers/ip46-header b/src/headers/ip46-header
index ba310d3..91d0c86 100644
--- a/src/headers/ip46-header
+++ b/src/headers/ip46-header
@@ -3,8 +3,9 @@
#ifndef IP46_H
#define IP46_H
+#include <sys/types.h>
+#include <stdint.h>
#include <errno.h>
-#include <skalibs/uint16.h>
#include <skalibs/bytestr.h>
#include <skalibs/fmtscan.h>
#include <skalibs/tai.h>
@@ -27,8 +28,8 @@ struct ip46full_s
#define ip46full_is6(i) ((i)->is6)
#define ip46full_fmt(s, i) ((i)->is6 ? ip6_fmt(s, (i)->ip) : ip4_fmt(s, (i)->ip))
-extern unsigned int ip46full_scan (char const *, ip46full_t *) ;
-extern unsigned int ip46full_scanlist (ip46full_t *, unsigned int, char const *, unsigned int *) ;
+extern size_t ip46full_scan (char const *, ip46full_t *) ;
+extern size_t ip46full_scanlist (ip46full_t *, size_t, char const *, size_t *) ;
#define ip46full_from_ip4(i, ip4) (byte_copy((i)->ip, 4, ip4), byte_zero((i)->ip + 4, 12), (i)->is6 = 0)
#define ip46full_from_ip6(i, ip6) (byte_copy((i)->ip, 16, ip6), (i)->is6 = 1)
diff --git a/src/headers/ip46-with b/src/headers/ip46-with
index 8ff6752..9570ffa 100644
--- a/src/headers/ip46-with
+++ b/src/headers/ip46-with
@@ -17,8 +17,8 @@ typedef ip46full_t ip46_t, *ip46_t_ref ;
#define socket_udp46(h) ((h) ? socket_udp6() : socket_udp4())
#define socket_recv46(fd, s, len, i, port) ((i)->is6 ? socket_recv6(fd, s, len, (i)->ip, port) : socket_recv4(fd, s, len, (i)->ip, port))
#define socket_send46(fd, s, len, i, port) ((i)->is6 ? socket_send6(fd, s, len, (i)->ip, port) : socket_send4(fd, s, len, (i)->ip, port))
-extern int socket_local46 (int, ip46_t *, uint16 *) ;
-extern int socket_remote46 (int, ip46_t *, uint16 *) ;
+extern int socket_local46 (int, ip46_t *, uint16_t *) ;
+extern int socket_remote46 (int, ip46_t *, uint16_t *) ;
#define socket_recvnb46(fd, buf, len, i, port, deadline, stamp) ((i)->is6 ? socket_recvnb6(fd, buf, len, (i)->ip, port, deadline, stamp) : socket_recvnb4(fd, buf, len, (i)->ip, port, deadline, stamp))
#define socket_sendnb46(fd, buf, len, i, port, deadline, stamp) ((i)->is6 ? socket_sendnb6(fd, buf, len, (i)->ip, port, deadline, stamp) : socket_sendnb4(fd, buf, len, (i)->ip, port, deadline, stamp))
diff --git a/src/headers/signed-template b/src/headers/signed-template
new file mode 100644
index 0000000..2ef6fdd
--- /dev/null
+++ b/src/headers/signed-template
@@ -0,0 +1,9 @@
+#define @TYPE@_FMT (1+UINT@BITS@_FMT)
+
+#define @type@_fmt int@BITS@_fmt
+#define @type@_fmtlist int@BITS@_fmtlist
+#define @type@_scan int@BITS@_scan
+#define @type@0_scan int@BITS@0_scan
+#define @type@_scanlist int@BITS@_scanlist
+
+
diff --git a/src/headers/gidstuff-footer b/src/headers/types-footer
index ddd5dae..ddd5dae 100644
--- a/src/headers/gidstuff-footer
+++ b/src/headers/types-footer
diff --git a/src/headers/types-header b/src/headers/types-header
new file mode 100644
index 0000000..015bb08
--- /dev/null
+++ b/src/headers/types-header
@@ -0,0 +1,12 @@
+/* ISC license. */
+
+#ifndef SKALIBS_TYPES_H
+#define SKALIBS_TYPES_H
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <skalibs/uint16.h>
+#include <skalibs/uint32.h>
+#include <skalibs/uint64.h>
+
+
diff --git a/src/headers/uint-16 b/src/headers/uint-16
deleted file mode 100644
index 85434db..0000000
--- a/src/headers/uint-16
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <skalibs/uint16.h>
-
-#define UINT_PACK 2
-#define uint_pack uint16_pack
-#define uint_pack_big uint16_pack_big
-#define uint_unpack(s, u) uint16_unpack(s, (uint16 *)(char *)(u))
-#define uint_unpack_big(s, u) uint16_unpack_big(s, (uint16 *)(char *)(u))
-
-#define uint_reverse uint16_reverse
-#define uint_big_endian uint16_big_endian
-#define uint_little_endian uint16_little_endian
-
-#define UINT_FMT UINT16_FMT
-#define UINT_OFMT UINT16_OFMT
-#define UINT_XFMT UINT16_XFMT
-#define UINT_BFMT UINT16_BFMT
-
-#define uint_fmt_base uint16_fmt_base
-#define uint0_fmt_base uint160_fmt_base
-#define uint_fmt uint16_fmt
-#define uint0_fmt uint160_fmt
-#define uint_ofmt uint16_ofmt
-#define uint0_ofmt uint160_ofmt
-#define uint_xfmt uint16_xfmt
-#define uint0_xfmt uint160_xfmt
-#define uint_bfmt uint16_bfmt
-#define uint0_bfmt uint160_bfmt
-
-#define uint_fmtlist(s, tab, n) uint16_fmtlist(s, tab, n)
-
-#define uint_scan_base(s, u, b) uint16_scan_base(s, (uint16 *)(char *)(u), b)
-#define uint0_scan_base(s, u, b) uint160_scan_base(s, (uint16 *)(char *)(u), b)
-
-#define uint_scanlist(tab, max, s, num) uint16_scanlist(tab, max, s, num)
diff --git a/src/headers/uint-32 b/src/headers/uint-32
deleted file mode 100644
index 32c6600..0000000
--- a/src/headers/uint-32
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <skalibs/uint32.h>
-
-#define UINT_PACK 4
-#define uint_pack uint32_pack
-#define uint_pack_big uint32_pack_big
-#define uint_unpack(s, u) uint32_unpack(s, (uint32 *)(char *)(u))
-#define uint_unpack_big(s, u) uint32_unpack_big(s, (uint32 *)(char *)(u))
-
-#define uint_reverse uint32_reverse
-#define uint_big_endian uint32_big_endian
-#define uint_little_endian uint32_little_endian
-
-#define UINT_FMT UINT32_FMT
-#define UINT_OFMT UINT32_OFMT
-#define UINT_XFMT UINT32_XFMT
-#define UINT_BFMT UINT32_BFMT
-
-#define uint_fmt_base uint32_fmt_base
-#define uint0_fmt_base uint320_fmt_base
-#define uint_fmt uint32_fmt
-#define uint0_fmt uint320_fmt
-#define uint_ofmt uint32_ofmt
-#define uint0_ofmt uint320_ofmt
-#define uint_xfmt uint32_xfmt
-#define uint0_xfmt uint320_xfmt
-#define uint_bfmt uint32_bfmt
-#define uint0_bfmt uint320_bfmt
-
-#define uint_fmtlist(s, tab, n) uint32_fmtlist(s, tab, n)
-
-#define uint_scan_base(s, u, b) uint32_scan_base(s, (uint32 *)(char *)(u), b)
-#define uint0_scan_base(s, u, b) uint320_scan_base(s, (uint32 *)(char *)(u), b)
-
-#define uint_scanlist(tab, max, s, num) uint32_scanlist(tab, max, s, num)
diff --git a/src/headers/uint-64 b/src/headers/uint-64
deleted file mode 100644
index 31926d9..0000000
--- a/src/headers/uint-64
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <skalibs/uint64.h>
-
-#define UINT_PACK 8
-#define uint_pack uint64_pack
-#define uint_pack_big uint64_pack_big
-#define uint_unpack(s, u) uint64_unpack(s, (uint64 *)(char *)(u))
-#define uint_unpack_big(s, u) uint64_unpack_big(s, (uint64 *)(char *)(u))
-
-#define uint_reverse uint64_reverse
-#define uint_big_endian uint64_big_endian
-#define uint_little_endian uint64_little_endian
-
-#define UINT_FMT UINT64_FMT
-#define UINT_OFMT UINT64_OFMT
-#define UINT_XFMT UINT64_XFMT
-#define UINT_BFMT UINT64_BFMT
-
-#define uint_fmt_base uint64_fmt_base
-#define uint0_fmt_base uint640_fmt_base
-#define uint_fmt uint64_fmt
-#define uint0_fmt uint640_fmt
-#define uint_ofmt uint64_ofmt
-#define uint0_ofmt uint640_ofmt
-#define uint_xfmt uint64_xfmt
-#define uint0_xfmt uint640_xfmt
-#define uint_bfmt uint64_bfmt
-#define uint0_bfmt uint640_bfmt
-
-#define uint_fmtlist(s, tab, n) uint64_fmtlist(s, tab, n)
-
-#define uint_scan_base(s, u, b) uint64_scan_base(s, (uint64 *)(char *)(u), b)
-#define uint0_scan_base(s, u, b) uint640_scan_base(s, (uint64 *)(char *)(u), b)
-
-#define uint_scanlist(tab, max, s, num) uint64_scanlist(tab, max, s, num)
diff --git a/src/headers/uint-footer b/src/headers/uint-footer
deleted file mode 100644
index 68bbaf7..0000000
--- a/src/headers/uint-footer
+++ /dev/null
@@ -1,10 +0,0 @@
-#define uint_scan(s, u) uint_scan_base(s, (u), 10)
-#define uint0_scan(s, u) uint0_scan_base(s, (u), 10)
-#define uint_oscan(s, u) uint_scan_base(s, (u), 8)
-#define uint0_oscan(s, u) uint0_scan_base(s, (u), 8)
-#define uint_xscan(s, u) uint_scan_base(s, (u), 16)
-#define uint0_xscan(s, u) uint0_scan_base(s, (u), 16)
-#define uint_bscan(s, u) uint_scan_base(s, (u), 2)
-#define uint0_bscan(s, u) uint0_scan_base(s, (u), 2)
-
-#endif
diff --git a/src/headers/uint-header b/src/headers/uint-header
deleted file mode 100644
index 8136b0c..0000000
--- a/src/headers/uint-header
+++ /dev/null
@@ -1,5 +0,0 @@
-/* ISC license. */
-
-#ifndef UINT_H
-#define UINT_H
-
diff --git a/src/headers/uint16-bendian b/src/headers/uint16-bendian
deleted file mode 100644
index e1d0427..0000000
--- a/src/headers/uint16-bendian
+++ /dev/null
@@ -1,3 +0,0 @@
-#define uint16_little_endian(s, n) uint16_reverse((s), (n))
-#define uint16_big_endian(s, n)
-
diff --git a/src/headers/uint16-footer b/src/headers/uint16-footer
deleted file mode 100644
index 5602571..0000000
--- a/src/headers/uint16-footer
+++ /dev/null
@@ -1,40 +0,0 @@
-
-extern void uint16_pack (char *, uint16) ;
-extern void uint16_pack_big (char *, uint16) ;
-extern void uint16_unpack (char const *, uint16 *) ;
-extern void uint16_unpack_big (char const *, uint16 *) ;
-extern void uint16_reverse (char *, unsigned int) ;
-
-#define UINT16_FMT 6
-#define UINT16_OFMT 7
-#define UINT16_XFMT 5
-#define UINT16_BFMT 17
-
-#define uint16_fmt_base(s, u, b) uint64_fmt_base(s, (uint64)(uint16)(u), b)
-#define uint160_fmt_base(s, u, n, b) uint640_fmt_base(s, (uint64)(uint16)(u), n, b)
-
-#define uint16_fmt(s, u) uint64_fmt(s, (uint64)(uint16)(u))
-#define uint160_fmt(s, u, n) uint64_fmt(s, (uint64)(uint16)(u), n)
-#define uint16_ofmt(s, o) uint64_ofmt(s, (uint64)(uint16)(o))
-#define uint160_ofmt(s, o, n) uint64_ofmt(s, (uint64)(uint16)(o), n)
-#define uint16_xfmt(s, x) uint64_xfmt(s, (uint64)(uint16)(x))
-#define uint160_xfmt(s, x, n) uint64_xfmt(s, (uint64)(uint16)(x), n)
-#define uint16_bfmt(s, b) uint64_bfmt(s, (uint64)(uint16)(b))
-#define uint160_bfmt(s, b, n) uint64_bfmt(s, (uint64)(uint16)(b), n)
-
-extern unsigned int uint16_fmtlist (char *, uint16 const *, unsigned int) ;
-
-extern unsigned int uint16_scan_base (char const *, uint16 *, unsigned char) ;
-extern unsigned int uint160_scan_base (char const *, uint16 *, unsigned char) ;
-#define uint16_scan(s, u) uint16_scan_base(s, (u), 10)
-#define uint160_scan(s, u) uint160_scan_base(s, (u), 10)
-#define uint16_oscan(s, u) uint16_scan_base(s, (u), 8)
-#define uint160_oscan(s, u) uint160_scan_base(s, (u), 8)
-#define uint16_xscan(s, u) uint16_scan_base(s, (u), 16)
-#define uint160_xscan(s, u) uint160_scan_base(s, (u), 16)
-#define uint16_bscan(s, u) uint16_scan_base(s, (u), 2)
-#define uint160_bscan(s, u) uint160_scan_base(s, (u), 2)
-
-extern unsigned int uint16_scanlist (uint16 *, unsigned int, char const *, unsigned int *) ;
-
-#endif
diff --git a/src/headers/uint16-header b/src/headers/uint16-header
deleted file mode 100644
index a8058c6..0000000
--- a/src/headers/uint16-header
+++ /dev/null
@@ -1,9 +0,0 @@
-/* ISC license. */
-
-#ifndef UINT16_H
-#define UINT16_H
-
-#include <stdint.h>
-#include <skalibs/uint64.h>
-
-typedef uint16_t uint16 ;
diff --git a/src/headers/uint16-lendian b/src/headers/uint16-lendian
deleted file mode 100644
index a9f9945..0000000
--- a/src/headers/uint16-lendian
+++ /dev/null
@@ -1,3 +0,0 @@
-#define uint16_little_endian(s, n)
-#define uint16_big_endian(s, n) uint16_reverse((s), (n))
-
diff --git a/src/headers/uint32-bendian b/src/headers/uint32-bendian
deleted file mode 100644
index 27903c7..0000000
--- a/src/headers/uint32-bendian
+++ /dev/null
@@ -1,3 +0,0 @@
-#define uint32_little_endian(s, n) uint32_reverse((s), (n))
-#define uint32_big_endian(s, n)
-
diff --git a/src/headers/uint32-footer b/src/headers/uint32-footer
deleted file mode 100644
index 7cfe7ba..0000000
--- a/src/headers/uint32-footer
+++ /dev/null
@@ -1,39 +0,0 @@
-extern void uint32_pack (char *, uint32) ;
-extern void uint32_pack_big (char *, uint32) ;
-extern void uint32_unpack (char const *, uint32 *) ;
-extern void uint32_unpack_big (char const *, uint32 *) ;
-extern void uint32_reverse (char *, unsigned int) ;
-
-#define UINT32_FMT 11
-#define UINT32_OFMT 13
-#define UINT32_XFMT 9
-#define UINT32_BFMT 33
-
-#define uint32_fmt_base(s, u, b) uint64_fmt_base(s, (uint64)(uint32)(u), b)
-#define uint320_fmt_base(s, u, n, b) uint640_fmt_base(s, (uint64)(uint32)(u), n, b)
-
-#define uint32_fmt(s, u) uint64_fmt(s, (uint64)(uint32)(u))
-#define uint320_fmt(s, u, n) uint640_fmt(s, (uint64)(uint32)(u), n)
-#define uint32_ofmt(s, o) uint64_ofmt(s, (uint64)(uint32)(o))
-#define uint320_ofmt(s, o, n) uint640_ofmt(s, (uint64)(uint32)(o), n)
-#define uint32_xfmt(s, x) uint64_xfmt(s, (uint64)(uint32)(x))
-#define uint320_xfmt(s, x, n) uint640_xfmt(s, (uint64)(uint32)(x), n)
-#define uint32_bfmt(s, b) uint64_bfmt(s, (uint64)(uint32)(b))
-#define uint320_bfmt(s, b, n) uint640_bfmt(s, (uint64)(uint32)(b), n)
-
-extern unsigned int uint32_fmtlist (char *, uint32 const *, unsigned int) ;
-
-extern unsigned int uint32_scan_base (char const *, uint32 *, unsigned char) ;
-extern unsigned int uint320_scan_base (char const *, uint32 *, unsigned char) ;
-#define uint32_scan(s, u) uint32_scan_base(s, (u), 10)
-#define uint320_scan(s, u) uint320_scan_base(s, (u), 10)
-#define uint32_oscan(s, u) uint32_scan_base(s, (u), 8)
-#define uint320_oscan(s, u) uint320_scan_base(s, (u), 8)
-#define uint32_xscan(s, u) uint32_scan_base(s, (u), 16)
-#define uint320_xscan(s, u) uint320_scan_base(s, (u), 16)
-#define uint32_bscan(s, u) uint32_scan_base(s, (u), 2)
-#define uint320_bscan(s, u) uint320_scan_base(s, (u), 2)
-
-extern unsigned int uint32_scanlist (uint32 *, unsigned int, char const *, unsigned int *) ;
-
-#endif
diff --git a/src/headers/uint32-header b/src/headers/uint32-header
deleted file mode 100644
index f71267f..0000000
--- a/src/headers/uint32-header
+++ /dev/null
@@ -1,9 +0,0 @@
-/* ISC license. */
-
-#ifndef UINT32_H
-#define UINT32_H
-
-#include <stdint.h>
-#include <skalibs/uint64.h>
-
-typedef uint32_t uint32 ;
diff --git a/src/headers/uint32-inttypesh b/src/headers/uint32-inttypesh
deleted file mode 100644
index 47a8910..0000000
--- a/src/headers/uint32-inttypesh
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <inttypes.h>
-typedef uint32_t uint32 ;
-
diff --git a/src/headers/uint32-lendian b/src/headers/uint32-lendian
deleted file mode 100644
index f88c111..0000000
--- a/src/headers/uint32-lendian
+++ /dev/null
@@ -1,3 +0,0 @@
-#define uint32_little_endian(s, n)
-#define uint32_big_endian(s, n) uint32_reverse((s), (n))
-
diff --git a/src/headers/uint32-noulong32 b/src/headers/uint32-noulong32
deleted file mode 100644
index 4705047..0000000
--- a/src/headers/uint32-noulong32
+++ /dev/null
@@ -1,2 +0,0 @@
-typedef unsigned int uint32 ;
-
diff --git a/src/headers/uint32-stdinth b/src/headers/uint32-stdinth
deleted file mode 100644
index dc9eb42..0000000
--- a/src/headers/uint32-stdinth
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <stdint.h>
-typedef uint32_t uint32 ;
-
diff --git a/src/headers/uint32-ulong32 b/src/headers/uint32-ulong32
deleted file mode 100644
index 87119a5..0000000
--- a/src/headers/uint32-ulong32
+++ /dev/null
@@ -1,2 +0,0 @@
-typedef unsigned long uint32 ;
-
diff --git a/src/headers/uint64-bendian b/src/headers/uint64-bendian
deleted file mode 100644
index 2485bec..0000000
--- a/src/headers/uint64-bendian
+++ /dev/null
@@ -1,3 +0,0 @@
-#define uint64_little_endian(s, n) uint64_reverse((s), (n))
-#define uint64_big_endian(s, n)
-
diff --git a/src/headers/uint64-footer b/src/headers/uint64-footer
deleted file mode 100644
index df620a5..0000000
--- a/src/headers/uint64-footer
+++ /dev/null
@@ -1,39 +0,0 @@
-extern void uint64_pack (char *, uint64) ;
-extern void uint64_pack_big (char *, uint64) ;
-extern void uint64_unpack (char const *, uint64 *) ;
-extern void uint64_unpack_big (char const *, uint64 *) ;
-extern void uint64_reverse (char *, unsigned int) ;
-
-#define UINT64_FMT 21
-#define UINT64_OFMT 25
-#define UINT64_XFMT 17
-#define UINT64_BFMT 65
-
-extern unsigned int uint64_fmt_base (char *, uint64, unsigned char) ;
-extern unsigned int uint640_fmt_base (char *, uint64, unsigned int, unsigned char) ;
-
-#define uint64_fmt(s, u) uint64_fmt_base(s, (u), 10)
-#define uint640_fmt(s, u, n) uint640_fmt_base(s, u, (n), 10)
-#define uint64_ofmt(s, u) uint64_fmt_base(s, (u), 8)
-#define uint640_ofmt(s, u, n) uint640_fmt_base(s, u, (n), 8)
-#define uint64_xfmt(s, u) uint64_fmt_base(s, (u), 16)
-#define uint640_xfmt(s, u, n) uint640_fmt_base(s, u, (n), 16)
-#define uint64_bfmt(s, u) uint64_fmt_base(s, (u), 2)
-#define uint640_bfmt(s, u, n) uint640_fmt_base(s, u, (n), 2)
-
-extern unsigned int uint64_fmtlist (char *, uint64 const *, unsigned int) ;
-
-extern unsigned int uint64_scan_base (char const *, uint64 *, unsigned char) ;
-extern unsigned int uint640_scan_base (char const *, uint64 *, unsigned char) ;
-#define uint64_scan(s, u) uint64_scan_base(s, (u), 10)
-#define uint640_scan(s, u) uint640_scan_base(s, (u), 10)
-#define uint64_oscan(s, u) uint64_scan_base(s, (u), 8)
-#define uint640_oscan(s, u) uint640_scan_base(s, (u), 8)
-#define uint64_xscan(s, u) uint64_scan_base(s, (u), 16)
-#define uint640_xscan(s, u) uint640_scan_base(s, (u), 16)
-#define uint64_bscan(s, u) uint64_scan_base(s, (u), 2)
-#define uint640_bscan(s, u) uint640_scan_base(s, (u), 2)
-
-extern unsigned int uint64_scanlist (uint64 *, unsigned int, char const *, unsigned int *) ;
-
-#endif
diff --git a/src/headers/uint64-header b/src/headers/uint64-header
deleted file mode 100644
index f0f10e6..0000000
--- a/src/headers/uint64-header
+++ /dev/null
@@ -1,5 +0,0 @@
-/* ISC license. */
-
-#ifndef UINT64_H
-#define UINT64_H
-
diff --git a/src/headers/uint64-lendian b/src/headers/uint64-lendian
deleted file mode 100644
index ffdb4de..0000000
--- a/src/headers/uint64-lendian
+++ /dev/null
@@ -1,3 +0,0 @@
-#define uint64_little_endian(s, n)
-#define uint64_big_endian(s, n) uint64_reverse((s), (n))
-
diff --git a/src/headers/uint64-noulong64 b/src/headers/uint64-noulong64
index c72ebef..1a67c1d 100644
--- a/src/headers/uint64-noulong64
+++ b/src/headers/uint64-noulong64
@@ -1,2 +1,3 @@
-typedef unsigned long long uint64 ;
+
+typedef unsigned long long uint64_t ;
diff --git a/src/headers/uint64-stdinth b/src/headers/uint64-stdinth
deleted file mode 100644
index 9c43f44..0000000
--- a/src/headers/uint64-stdinth
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <stdint.h>
-
-typedef uint64_t uint64 ;
diff --git a/src/headers/uint64-ulong64 b/src/headers/uint64-ulong64
index d9313d4..84ae235 100644
--- a/src/headers/uint64-ulong64
+++ b/src/headers/uint64-ulong64
@@ -1 +1,3 @@
-typedef unsigned long uint64 ;
+
+typedef unsigned long uint64_t ;
+
diff --git a/src/headers/ulong-32 b/src/headers/ulong-32
deleted file mode 100644
index b1b3326..0000000
--- a/src/headers/ulong-32
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <skalibs/uint32.h>
-
-#define ULONG_PACK 4
-#define ulong_pack uint32_pack
-#define ulong_pack_big uint32_pack_big
-#define ulong_unpack(s, u) uint32_unpack(s, (uint32 *)(char *)(u))
-#define ulong_unpack_big(s, u) uint32_unpack_big(s, (uint32 *)(char *)(u))
-
-#define ulong_reverse uint32_reverse
-#define ulong_big_endian uint32_big_endian
-#define ulong_little_endian uint32_little_endian
-
-#define ULONG_FMT UINT32_FMT
-#define ULONG_OFMT UINT32_OFMT
-#define ULONG_XFMT UINT32_XFMT
-#define ULONG_BFMT UINT32_BFMT
-
-#define ulong_fmt uint32_fmt
-#define ulong0_fmt uint320_fmt
-#define ulong_ofmt uint32_ofmt
-#define ulong0_ofmt uint320_ofmt
-#define ulong_xfmt uint32_xfmt
-#define ulong0_xfmt uint320_xfmt
-#define ulong_bfmt uint32_bfmt
-#define ulong0_bfmt uint320_bfmt
-
-#define ulong_fmtlist(s, tab, n) uint32_fmtlist(s, tab, n)
-
-#define ulong_scan_base(s, u, b) uint32_scan_base(s, (uint32 *)(char *)(u), b)
-#define ulong0_scan_base(s, u, b) uint320_scan_base(s, (uint32 *)(char *)(u), b)
-
-#define ulong_scanlist(tab, max, s, num) uint32_scanlist(tab, max, s, num)
diff --git a/src/headers/ulong-64 b/src/headers/ulong-64
deleted file mode 100644
index 016fd1f..0000000
--- a/src/headers/ulong-64
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <skalibs/uint64.h>
-
-#define ULONG_PACK 8
-#define ulong_pack uint64_pack
-#define ulong_pack_big uint64_pack_big
-#define ulong_unpack(s, u) uint64_unpack(s, (uint64 *)(char *)(u))
-#define ulong_unpack_big(s, u) uint64_unpack_big(s, (uint64 *)(char *)(u))
-
-#define ulong_reverse uint64_reverse
-#define ulong_big_endian uint64_big_endian
-#define ulong_little_endian uint64_little_endian
-
-#define ULONG_FMT UINT64_FMT
-#define ULONG_OFMT UINT64_OFMT
-#define ULONG_XFMT UINT64_XFMT
-#define ULONG_BFMT UINT64_BFMT
-
-#define ulong_fmt uint64_fmt
-#define ulong0_fmt uint640_fmt
-#define ulong_ofmt uint64_ofmt
-#define ulong0_ofmt uint640_ofmt
-#define ulong_xfmt uint64_xfmt
-#define ulong0_xfmt uint640_xfmt
-#define ulong_bfmt uint64_bfmt
-#define ulong0_bfmt uint640_bfmt
-
-#define ulong_fmtlist(s, tab, n) uint64_fmtlist(s, tab, n)
-
-#define ulong_scan_base(s, u, b) uint64_scan_base(s, (uint64 *)(char *)(u), b)
-#define ulong0_scan_base(s, u, b) uint640_scan_base(s, (uint64 *)(char *)(u), b)
-
-#define ulong_scanlist(tab, max, s, num) uint64_scanlist(tab, max, s, num)
diff --git a/src/headers/ulong-footer b/src/headers/ulong-footer
deleted file mode 100644
index 0607872..0000000
--- a/src/headers/ulong-footer
+++ /dev/null
@@ -1,10 +0,0 @@
-#define ulong_scan(s, u) ulong_scan_base(s, (u), 10)
-#define ulong0_scan(s, u) ulong0_scan_base(s, (u), 10)
-#define ulong_oscan(s, u) ulong_scan_base(s, (u), 8)
-#define ulong0_oscan(s, u) ulong0_scan_base(s, (u), 8)
-#define ulong_xscan(s, u) ulong_scan_base(s, (u), 16)
-#define ulong0_xscan(s, u) ulong0_scan_base(s, (u), 16)
-#define ulong_bscan(s, u) ulong_scan_base(s, (u), 2)
-#define ulong0_bscan(s, u) ulong0_scan_base(s, (u), 2)
-
-#endif
diff --git a/src/headers/ulong-header b/src/headers/ulong-header
deleted file mode 100644
index 98e6f37..0000000
--- a/src/headers/ulong-header
+++ /dev/null
@@ -1,5 +0,0 @@
-/* ISC license. */
-
-#ifndef ULONG_H
-#define ULONG_H
-
diff --git a/src/headers/unsigned-template b/src/headers/unsigned-template
new file mode 100644
index 0000000..8ef6db4
--- /dev/null
+++ b/src/headers/unsigned-template
@@ -0,0 +1,42 @@
+#define @TYPE@_PACK @BYTES@
+#define @type@_pack uint@BITS@_pack
+#define @type@_pack_big uint@BITS@_pack_big
+#define @type@_unpack uint@BITS@_unpack
+#define @type@_unpack_big uint@BITS@_unpack_big
+
+#define @type@_reverse uint@BITS@_reverse
+#define @type@_big_endian uint@BITS@_big_endian
+#define @type@_little_endian uint@BITS@_little_endian
+
+#define @TYPE@_FMT UINT@BITS@_FMT
+#define @TYPE@_OFMT UINT@BITS@_OFMT
+#define @TYPE@_XFMT UINT@BITS@_XFMT
+#define @TYPE@_BFMT UINT@BITS@_BFMT
+
+#define @type@_fmt_base uint@BITS@_fmt_base
+#define @type@0_fmt_base uint@BITS@0_fmt_base
+#define @type@_fmt uint@BITS@_fmt
+#define @type@0_fmt uint@BITS@0_fmt
+#define @type@_ofmt uint@BITS@_ofmt
+#define @type@0_ofmt uint@BITS@0_ofmt
+#define @type@_xfmt uint@BITS@_xfmt
+#define @type@0_xfmt uint@BITS@0_xfmt
+#define @type@_bfmt uint@BITS@_bfmt
+#define @type@0_bfmt uint@BITS@0_bfmt
+
+#define @type@_fmtlist uint@BITS@_fmtlist
+
+#define @type@_scan_base uint@BITS@_scan_base
+#define @type@0_scan_base uint@BITS@0_scan_base
+#define @type@_scanlist uint@BITS@_scanlist
+
+#define @type@_scan(s, u) @type@_scan_base(s, (u), 10)
+#define @type@0_scan(s, u) @type@0_scan_base(s, (u), 10)
+#define @type@_oscan(s, u) @type@_scan_base(s, (u), 8)
+#define @type@0_oscan(s, u) @type@0_scan_base(s, (u), 8)
+#define @type@_xscan(s, u) @type@_scan_base(s, (u), 16)
+#define @type@0_xscan(s, u) @type@0_scan_base(s, (u), 16)
+#define @type@_bscan(s, u) @type@_scan_base(s, (u), 2)
+#define @type@0_bscan(s, u) @type@0_scan_base(s, (u), 2)
+
+
diff --git a/src/headers/ushort-16 b/src/headers/ushort-16
deleted file mode 100644
index 0e210c6..0000000
--- a/src/headers/ushort-16
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <skalibs/uint16.h>
-
-#define USHORT_PACK 2
-#define ushort_pack uint16_pack
-#define ushort_pack_big uint16_pack_big
-#define ushort_unpack(s, u) uint16_unpack(s, (uint16 *)(char *)(u))
-#define ushort_unpack_big(s, u) uint16_unpack_big(s, (uint16 *)(char *)(u))
-
-#define ushort_reverse uint16_reverse
-#define ushort_big_endian uint16_big_endian
-#define ushort_little_endian uint16_little_endian
-
-#define USHORT_FMT UINT16_FMT
-#define USHORT_OFMT UINT16_OFMT
-#define USHORT_XFMT UINT16_XFMT
-#define USHORT_BFMT UINT16_BFMT
-
-#define ushort_fmt_base uint16_fmt_base
-#define ushort0_fmt_base uint160_fmt_base
-#define ushort_fmt uint16_fmt
-#define ushort0_fmt uint160_fmt
-#define ushort_ofmt uint16_ofmt
-#define ushort0_ofmt uint160_ofmt
-#define ushort_xfmt uint16_xfmt
-#define ushort0_xfmt uint160_xfmt
-#define ushort_bfmt uint16_bfmt
-#define ushort0_bfmt uint160_bfmt
-
-#define ushort_fmtlist(s, tab, n) uint16_fmtlist(s, tab, n)
-
-#define ushort_scan_base(s, u, b) uint16_scan_base(s, (uint16 *)(char *)(u), b)
-#define ushort0_scan_base(s, u, b) uint160_scan_base(s, (uint16 *)(char *)(u), b)
-
-#define ushort_scanlist(tab, max, s, num) uint16_scanlist(tab, max, s, num)
diff --git a/src/headers/ushort-32 b/src/headers/ushort-32
deleted file mode 100644
index b41aef4..0000000
--- a/src/headers/ushort-32
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <skalibs/uint32.h>
-
-#define USHORT_PACK 4
-#define ushort_pack uint32_pack
-#define ushort_pack_big uint32_pack_big
-#define ushort_unpack(s, u) uint32_unpack(s, (uint32 *)(char *)(u))
-#define ushort_unpack_big(s, u) uint32_unpack_big(s, (uint32 *)(char *)(u))
-
-#define ushort_reverse uint32_reverse
-#define ushort_big_endian uint32_big_endian
-#define ushort_little_endian uint32_little_endian
-
-#define USHORT_FMT UINT32_FMT
-#define USHORT_OFMT UINT32_OFMT
-#define USHORT_XFMT UINT32_XFMT
-#define USHORT_BFMT UINT32_BFMT
-
-#define ushort_fmt_base uint32_fmt_base
-#define ushort0_fmt_base uint320_fmt_base
-#define ushort_fmt uint32_fmt
-#define ushort0_fmt uint320_fmt
-#define ushort_ofmt uint32_ofmt
-#define ushort0_ofmt uint320_ofmt
-#define ushort_xfmt uint32_xfmt
-#define ushort0_xfmt uint320_xfmt
-#define ushort_bfmt uint32_bfmt
-#define ushort0_bfmt uint320_bfmt
-
-#define ushort_fmtlist(s, tab, n) uint32_fmtlist(s, tab, n)
-
-#define ushort_scan_base(s, u, b) uint32_scan_base(s, (uint32 *)(char *)(u), b)
-#define ushort0_scan_base(s, u, b) uint320_scan_base(s, (uint32 *)(char *)(u), b)
-
-#define ushort_scanlist(tab, max, s, num) uint32_scanlist(tab, max, s, num)
diff --git a/src/headers/ushort-footer b/src/headers/ushort-footer
deleted file mode 100644
index db56f73..0000000
--- a/src/headers/ushort-footer
+++ /dev/null
@@ -1,10 +0,0 @@
-#define ushort_scan(s, u) ushort_scan_base(s, (u), 10)
-#define ushort0_scan(s, u) ushort0_scan_base(s, (u), 10)
-#define ushort_oscan(s, u) ushort_scan_base(s, (u), 8)
-#define ushort0_oscan(s, u) ushort0_scan_base(s, (u), 8)
-#define ushort_xscan(s, u) ushort_scan_base(s, (u), 16)
-#define ushort0_xscan(s, u) ushort0_scan_base(s, (u), 16)
-#define ushort_bscan(s, u) ushort_scan_base(s, (u), 2)
-#define ushort0_bscan(s, u) ushort0_scan_base(s, (u), 2)
-
-#endif
diff --git a/src/headers/ushort-header b/src/headers/ushort-header
deleted file mode 100644
index 66b7f9a..0000000
--- a/src/headers/ushort-header
+++ /dev/null
@@ -1,5 +0,0 @@
-/* ISC license. */
-
-#ifndef USHORT_H
-#define USHORT_H
-
diff --git a/src/include/skalibs/djbtime.h b/src/include/skalibs/djbtime.h
index 229966f..07ad662 100644
--- a/src/include/skalibs/djbtime.h
+++ b/src/include/skalibs/djbtime.h
@@ -3,8 +3,8 @@
#ifndef DJBTIME_H
#define DJBTIME_H
+#include <sys/types.h>
#include <time.h>
-#include <skalibs/config.h>
#include <skalibs/uint32.h>
#include <skalibs/uint64.h>
#include <skalibs/tai.h>
@@ -13,18 +13,18 @@
/* UTC <--> TAI conversions */
/* sysclock can be either TAI-10 or UTC */
-extern int utc_from_tai (uint64 *, tai_t const *) ;
-extern int tai_from_utc (tai_t *, uint64) ;
-extern int utc_from_sysclock (uint64 *) ;
-extern int sysclock_from_utc (uint64 *) ;
+extern int utc_from_tai (uint64_t *, tai_t const *) ;
+extern int tai_from_utc (tai_t *, uint64_t) ;
+extern int utc_from_sysclock (uint64_t *) ;
+extern int sysclock_from_utc (uint64_t *) ;
/* NTP internal format */
#define NTP_OFFSET 2208988800UL
-extern int ntp_from_tain (uint64 *, tain_t const *) ;
+extern int ntp_from_tain (uint64_t *, tain_t const *) ;
#define ntp_from_tain_g(u) ntp_from_tain((u), &STAMP)
-extern int tain_from_ntp (tain_t *, uint64) ;
+extern int tain_from_ntp (tain_t *, uint64_t) ;
/* localtime handling - replaces caltimedate functions */
@@ -36,22 +36,22 @@ typedef struct localtmn_s localtmn_t, *localtmn_t_ref ;
struct localtmn_s
{
struct tm tm ;
- uint32 nano ;
+ uint32_t nano ;
} ;
-extern int ltm64_from_tai (uint64 *, tai_t const *) ;
-extern int tai_from_ltm64 (tai_t *, uint64) ;
-extern int ltm64_from_utc (uint64 *) ;
-extern int utc_from_ltm64 (uint64 *) ;
-extern int ltm64_from_sysclock (uint64 *) ;
-extern int sysclock_from_ltm64 (uint64 *) ;
-
-extern int localtm_from_ltm64 (struct tm *, uint64, int) ;
-extern int ltm64_from_localtm (uint64 *, struct tm const *) ;
-extern int localtm_from_sysclock (struct tm *, uint64, int) ;
-extern int sysclock_from_localtm (uint64 *, struct tm const *) ;
-extern int localtm_from_utc (struct tm *, uint64, int) ;
-extern int utc_from_localtm (uint64 *, struct tm const *) ;
+extern int ltm64_from_tai (uint64_t *, tai_t const *) ;
+extern int tai_from_ltm64 (tai_t *, uint64_t) ;
+extern int ltm64_from_utc (uint64_t *) ;
+extern int utc_from_ltm64 (uint64_t *) ;
+extern int ltm64_from_sysclock (uint64_t *) ;
+extern int sysclock_from_ltm64 (uint64_t *) ;
+
+extern int localtm_from_ltm64 (struct tm *, uint64_t, int) ;
+extern int ltm64_from_localtm (uint64_t *, struct tm const *) ;
+extern int localtm_from_sysclock (struct tm *, uint64_t, int) ;
+extern int sysclock_from_localtm (uint64_t *, struct tm const *) ;
+extern int localtm_from_utc (struct tm *, uint64_t, int) ;
+extern int utc_from_localtm (uint64_t *, struct tm const *) ;
extern int localtm_from_tai (struct tm *, tai_t const *, int) ;
extern int tai_from_localtm (tai_t *, struct tm const *) ;
@@ -62,11 +62,11 @@ extern int localtmn_from_sysclock (localtmn_t *, tain_t const *, int) ;
extern int sysclock_from_localtmn (tain_t *, localtmn_t const *) ;
#define LOCALTM_FMT 21
-extern unsigned int localtm_fmt (char *, struct tm const *) ;
-extern unsigned int localtm_scan (char const *, struct tm *) ;
+extern size_t localtm_fmt (char *, struct tm const *) ;
+extern size_t localtm_scan (char const *, struct tm *) ;
#define LOCALTMN_FMT 31
-extern unsigned int localtmn_fmt (char *, localtmn_t const *) ;
-extern unsigned int localtmn_scan (char const *, localtmn_t *) ;
+extern size_t localtmn_fmt (char *, localtmn_t const *) ;
+extern size_t localtmn_scan (char const *, localtmn_t *) ;
#endif
diff --git a/src/include/skalibs/fmtscan.h b/src/include/skalibs/fmtscan.h
index ccfd160..f820b42 100644
--- a/src/include/skalibs/fmtscan.h
+++ b/src/include/skalibs/fmtscan.h
@@ -3,31 +3,27 @@
#ifndef FMTSCAN_H
#define FMTSCAN_H
+#include <sys/types.h>
+#include <stdint.h>
#include <skalibs/gccattributes.h>
-#include <skalibs/uint32.h>
/* fmt */
+extern size_t str_fmt (char *, char const *) ;
+extern size_t strn_fmt (char *, char const *, size_t) ;
extern unsigned char fmtscan_asc (unsigned char) gccattr_const ;
-extern unsigned int str_fmt (char *, char const *) ;
-extern unsigned int strn_fmt (char *, char const *, unsigned int) ;
-
#define IP4_FMT 20
-extern unsigned int ip4_fmt (char *, char const *) ;
-extern unsigned int ip4_fmtu32 (char *, uint32) ;
+extern size_t ip4_fmt (char *, char const *) ;
+extern size_t ip4_fmtu32 (char *, uint32_t) ;
-extern unsigned int ucharn_fmt (char *, char const *, unsigned int) ;
-extern unsigned int ucharn_fmt_little (char *, char const *, unsigned int) ;
+extern size_t ucharn_fmt (char *, char const *, size_t) ;
+extern size_t ucharn_fmt_little (char *, char const *, size_t) ;
#define IP6_FMT 40
-extern unsigned int ip6_fmt (char *, char const *) ;
-
-#define short_fmt(s, u) long_fmt((s), (long)(u))
-#define int_fmt(s, u) long_fmt((s), (long)(u))
-extern unsigned int long_fmt (char *, long) ;
+extern size_t ip6_fmt (char *, char const *) ;
/* scan */
@@ -35,19 +31,15 @@ extern unsigned int long_fmt (char *, long) ;
extern unsigned char fmtscan_num (unsigned char, unsigned char) gccattr_const ;
-extern unsigned int ip4_scan (char const *, char *) ;
-extern unsigned int ip4_scanu32 (char const *, uint32 *) ;
-extern unsigned int ip4_scanlist_u32 (uint32 *, unsigned int, char const *, unsigned int *) ;
-extern unsigned int ip4_scanlist (char *, unsigned int, char const *, unsigned int *) ;
-extern unsigned int ip6_scan (char const *, char *) ;
-extern unsigned int ip6_scanlist (char *, unsigned int, char const *, unsigned int *) ;
-
-extern unsigned int ucharn_scan (char const *, char *, unsigned int) ;
-extern unsigned int ucharn_scan_little (char const *, char *, unsigned int) ;
-extern unsigned int ucharn_findlen (char const *) gccattr_pure ;
+extern size_t ip4_scan (char const *, char *) ;
+extern size_t ip4_scanu32 (char const *, uint32_t *) ;
+extern size_t ip4_scanlist_u32 (uint32_t *, size_t, char const *, size_t *) ;
+extern size_t ip4_scanlist (char *, size_t, char const *, size_t *) ;
+extern size_t ip6_scan (char const *, char *) ;
+extern size_t ip6_scanlist (char *, size_t, char const *, size_t *) ;
-extern unsigned int short_scan (char const *, short *) ;
-extern unsigned int int_scan (char const *, int *) ;
-extern unsigned int long_scan (char const *, long *) ;
+extern size_t ucharn_scan (char const *, char *, size_t) ;
+extern size_t ucharn_scan_little (char const *, char *, size_t) ;
+extern size_t ucharn_findlen (char const *) gccattr_pure ;
#endif
diff --git a/src/include/skalibs/netstring.h b/src/include/skalibs/netstring.h
index ee5cd85..f6663c3 100644
--- a/src/include/skalibs/netstring.h
+++ b/src/include/skalibs/netstring.h
@@ -3,21 +3,22 @@
#ifndef NETSTRING_H
#define NETSTRING_H
+#include <sys/types.h>
+#include <sys/uio.h>
#include <skalibs/buffer.h>
-#include <skalibs/siovec.h>
#include <skalibs/stralloc.h>
-extern int netstring_appendb (stralloc *, char const *, unsigned int) ;
+extern int netstring_appendb (stralloc *, char const *, size_t) ;
#define netstring_appends(sa, s) netstring_appendb((sa), (s), str_len(s))
#define netstring_append(to, from) netstring_appendb((to), (from)->s, (from)->len)
-extern int netstring_appendv (stralloc *, siovec_t const *, unsigned int) ;
+extern int netstring_appendv (stralloc *, struct iovec const *, unsigned int) ;
-extern int netstring_encode (stralloc *, char const *, unsigned int) ;
-extern int netstring_decode (stralloc *, char const *, unsigned int) ;
+extern int netstring_encode (stralloc *, char const *, size_t) ;
+extern ssize_t netstring_decode (stralloc *, char const *, size_t) ;
-extern int netstring_okeof (buffer *, unsigned int) ;
-extern int netstring_get (buffer *, stralloc *, unsigned int *) ;
-extern int netstring_put (buffer *, char const *, unsigned int, unsigned int *) ;
+extern int netstring_okeof (buffer *, size_t) ;
+extern ssize_t 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/stddjb.h b/src/include/skalibs/stddjb.h
index 3ebd219..b1f54cb 100644
--- a/src/include/skalibs/stddjb.h
+++ b/src/include/skalibs/stddjb.h
@@ -7,11 +7,8 @@
#include <skalibs/uint16.h>
#include <skalibs/uint32.h>
#include <skalibs/uint64.h>
-#include <skalibs/ushort.h>
-#include <skalibs/uint.h>
-#include <skalibs/ulong.h>
+#include <skalibs/types.h>
#include <skalibs/error.h>
-#include <skalibs/gidstuff.h>
#include <skalibs/ip46.h>
#include <skalibs/setgroups.h>
diff --git a/src/libstddjb/child_spawn.c b/src/libstddjb/child_spawn.c
index 2170a6e..78b45ac 100644
--- a/src/libstddjb/child_spawn.c
+++ b/src/libstddjb/child_spawn.c
@@ -10,11 +10,11 @@
#include <unistd.h>
#include <errno.h>
#include <signal.h>
+#include <skalibs/types.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/bytestr.h>
#include <skalibs/env.h>
#include <skalibs/djbunix.h>
-#include <skalibs/uint.h>
#ifdef SKALIBS_HASPOSIXSPAWN
diff --git a/src/libstddjb/fmtscan-internal.h b/src/libstddjb/fmtscan-internal.h
index b1cac3e..3c9f214 100644
--- a/src/libstddjb/fmtscan-internal.h
+++ b/src/libstddjb/fmtscan-internal.h
@@ -3,17 +3,19 @@
#ifndef FMTSCAN_INTERNAL_H
#define FMTSCAN_INTERNAL_H
+#include <sys/types.h>
+#include <stdint.h>
#include <errno.h>
#include <limits.h>
#include <skalibs/bytestr.h>
#include <skalibs/fmtscan.h>
#define SCANB(bits) \
-unsigned int uint##bits##_scan_base (char const *s, uint##bits *u, unsigned char base) \
+size_t uint##bits##_scan_base (char const *s, uint##bits##_t *u, unsigned int base) \
{ \
- static uint##bits const max = (uint##bits)(-1) ; \
- uint##bits result = 0 ; \
- unsigned int pos = 0 ; \
+ static uint##bits##_t const max = UINT##bits##_MAX ; \
+ uint##bits##_t result = 0 ; \
+ size_t pos = 0 ; \
for (;; pos++) \
{ \
register unsigned char c = fmtscan_num(s[pos], base) ; \
@@ -25,42 +27,42 @@ unsigned int uint##bits##_scan_base (char const *s, uint##bits *u, unsigned char
} \
#define SCANB0(bits) \
-unsigned int uint##bits##0_scan_base (char const *s, uint##bits *u, unsigned char base) \
+size_t uint##bits##0_scan_base (char const *s, uint##bits##_t *u, unsigned int base) \
{ \
- register unsigned int pos = uint##bits##_scan_base(s, u, base) ; \
+ register size_t pos = uint##bits##_scan_base(s, u, base) ; \
if (!pos) return (errno = EINVAL, 0) ; \
if (!s[pos]) return pos ; \
errno = (fmtscan_num(s[pos], base) < base) ? EDOM : EINVAL ; \
return 0 ; \
} \
-#define SCANS(type, cstname) \
-unsigned int type##_scan (char const *s, type *n) \
+#define SCANS(bits) \
+size_t int##bits##_scan (char const *s, int##bits##_t *n) \
{ \
- unsigned type tmp ; \
- register unsigned int r = 0 ; \
+ uint##bits##_t tmp ; \
+ register size_t r = 0 ; \
register unsigned int sign = 0 ; \
if (*s == '-') \
{ \
- r = 1 + u##type##_scan(s+1, &tmp) ; \
+ r = 1 + uint##bits##_scan(s+1, &tmp) ; \
if (r == 1) return 0 ; \
if (tmp == 0) *n = 0 ; \
else \
{ \
- if (tmp-1 > -(cstname##_MIN+1)) \
+ if (tmp-1 > -(INT##bits##_MIN+1)) \
{ \
tmp /= 10 ; \
r-- ; \
} \
- *n = cstname##_MIN + (-(cstname##_MIN+1) - (tmp-1)) ; \
+ *n = INT##bits##_MIN + (-(INT##bits##_MIN+1) - (tmp-1)) ; \
} \
return r ; \
} \
if (*s == '+') (s++, sign++) ; \
- r = u##type##_scan(s, &tmp) ; \
+ r = uint##bits##_scan(s, &tmp) ; \
if (!r) return 0 ; \
r += sign ; \
- if (tmp > cstname##_MAX) \
+ if (tmp > INT##bits##_MAX) \
{ \
tmp /= 10 ; \
r-- ; \
@@ -69,13 +71,38 @@ unsigned int type##_scan (char const *s, type *n) \
return r ; \
} \
+#define SCANS0(bits) \
+size_t int##bits##0_scan (char const *s, int##bits##_t *u) \
+{ \
+ register size_t pos = int##bits##_scan(s, u) ; \
+ if (!pos) return (errno = EINVAL, 0) ; \
+ if (!s[pos]) return pos ; \
+ errno = (fmtscan_num(s[pos], 10) < 10) ? EDOM : EINVAL ; \
+ return 0 ; \
+} \
+
#define SCANL(bits) \
-unsigned int uint##bits##_scanlist (uint##bits *tab, unsigned int max, char const *s, unsigned int *num) \
+size_t uint##bits##_scanlist (uint##bits##_t *tab, size_t max, char const *s, size_t *num) \
+{ \
+ size_t i = 0, len = 0 ; \
+ for (; s[len] && (i < max) ; i++) \
+ { \
+ register size_t w = uint##bits##_scan(s + len, tab + i) ; \
+ if (!w) break ; \
+ len += w ; \
+ while (byte_chr(",:; \t\r\n", 7, s[len]) < 7) len++ ; \
+ } \
+ *num = i ; \
+ return len ; \
+} \
+
+#define SCANSL(bits) \
+size_t int##bits##_scanlist (int##bits##_t *tab, size_t max, char const *s, size_t *num) \
{ \
- unsigned int i = 0, len = 0 ; \
+ size_t i = 0, len = 0 ; \
for (; s[len] && (i < max) ; i++) \
{ \
- register unsigned int w = uint##bits##_scan(s + len, tab + i) ; \
+ register size_t w = int##bits##_scan(s + len, tab + i) ; \
if (!w) break ; \
len += w ; \
while (byte_chr(",:; \t\r\n", 7, s[len]) < 7) len++ ; \
@@ -85,12 +112,12 @@ unsigned int uint##bits##_scanlist (uint##bits *tab, unsigned int max, char cons
} \
#define FMTL(bits) \
-unsigned int uint##bits##_fmtlist (char *s, uint##bits const *tab, unsigned int n) \
+size_t uint##bits##_fmtlist (char *s, uint##bits##_t const *tab, size_t n) \
{ \
- unsigned int i = 0, len = 0 ; \
+ size_t i = 0, len = 0 ; \
for (; i < n ; i++) \
{ \
- register unsigned int w = uint##bits##_fmt(s, tab[i]) ; \
+ register size_t w = uint##bits##_fmt(s, tab[i]) ; \
len += w ; \
if (s) \
{ \
@@ -101,5 +128,53 @@ unsigned int uint##bits##_fmtlist (char *s, uint##bits const *tab, unsigned int
return len ; \
} \
+#define FMTB(bits) \
+size_t uint##bits##_fmt_base (char *s, uint##bits##_t x, unsigned int base) \
+{ \
+ register size_t len = 1 ; \
+ { \
+ register uint##bits##_t q = x ; \
+ while (q >= base) { len++ ; q /= base ; } \
+ } \
+ if (s) \
+ { \
+ s += len ; \
+ do { *--s = fmtscan_asc(x % base) ; x /= base ; } while (x) ; \
+ } \
+ return len ; \
+} \
+
+#define FMTB0(bits) \
+size_t uint##bits##0_fmt_base (char *s, uint##bits##_t x, register size_t n, unsigned int base) \
+{ \
+ register size_t len = uint##bits##_fmt_base(0, x, base) ; \
+ while (n-- > len) *s++ = '0' ; \
+ return uint##bits##_fmt_base(s, x, base) ; \
+} \
+
+#define FMTS(bits) \
+size_t int##bits##_fmt (char *fmt, int##bits##_t n) \
+{ \
+ if (n >= 0) return uint##bits##_fmt(fmt, n) ; \
+ if (fmt) *fmt++ = '-' ; \
+ return 1 + uint##bits##_fmt(fmt, -n) ; \
+} \
+
+#define FMTSL(bits) \
+size_t int##bits##_fmtlist (char *s, int##bits##_t const *tab, size_t n) \
+{ \
+ size_t i = 0, len = 0 ; \
+ for (; i < n ; i++) \
+ { \
+ register size_t w = int##bits##_fmt(s, tab[i]) ; \
+ len += w ; \
+ if (s) \
+ { \
+ s += w ; \
+ if (i < n-1) { *s++ = ',' ; len++ ; } \
+ } \
+ } \
+ return len ; \
+} \
#endif
diff --git a/src/libstddjb/int_scan.c b/src/libstddjb/int160_scan.c
index 2547a04..f2ce735 100644
--- a/src/libstddjb/int_scan.c
+++ b/src/libstddjb/int160_scan.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/uint.h>
#include "fmtscan-internal.h"
+#include <skalibs/uint16.h>
-SCANS(int, INT)
+SCANS0(16)
diff --git a/src/libstddjb/long_scan.c b/src/libstddjb/int16_fmt.c
index 34a5e1a..6dff58b 100644
--- a/src/libstddjb/long_scan.c
+++ b/src/libstddjb/int16_fmt.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/ulong.h>
#include "fmtscan-internal.h"
+#include <skalibs/uint16.h>
-SCANS(long, LONG)
+FMTS(16)
diff --git a/src/libstddjb/short_scan.c b/src/libstddjb/int16_fmtlist.c
index 898ba9f..4ec6899 100644
--- a/src/libstddjb/short_scan.c
+++ b/src/libstddjb/int16_fmtlist.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/ushort.h>
#include "fmtscan-internal.h"
+#include <skalibs/uint16.h>
-SCANS(short, SHRT)
+FMTSL(16)
diff --git a/src/libstddjb/int16_scan.c b/src/libstddjb/int16_scan.c
new file mode 100644
index 0000000..b20523d
--- /dev/null
+++ b/src/libstddjb/int16_scan.c
@@ -0,0 +1,6 @@
+/* ISC license. */
+
+#include "fmtscan-internal.h"
+#include <skalibs/uint16.h>
+
+SCANS(16)
diff --git a/src/libstddjb/int16_scanlist.c b/src/libstddjb/int16_scanlist.c
new file mode 100644
index 0000000..9b4bf87
--- /dev/null
+++ b/src/libstddjb/int16_scanlist.c
@@ -0,0 +1,6 @@
+/* ISC license. */
+
+#include "fmtscan-internal.h"
+#include <skalibs/uint16.h>
+
+SCANSL(16)
diff --git a/src/libstddjb/int320_scan.c b/src/libstddjb/int320_scan.c
new file mode 100644
index 0000000..dea7c91
--- /dev/null
+++ b/src/libstddjb/int320_scan.c
@@ -0,0 +1,6 @@
+/* ISC license. */
+
+#include "fmtscan-internal.h"
+#include <skalibs/uint32.h>
+
+SCANS0(32)
diff --git a/src/libstddjb/int32_fmt.c b/src/libstddjb/int32_fmt.c
new file mode 100644
index 0000000..dc0ff1b
--- /dev/null
+++ b/src/libstddjb/int32_fmt.c
@@ -0,0 +1,6 @@
+/* ISC license. */
+
+#include "fmtscan-internal.h"
+#include <skalibs/uint32.h>
+
+FMTS(32)
diff --git a/src/libstddjb/int32_fmtlist.c b/src/libstddjb/int32_fmtlist.c
new file mode 100644
index 0000000..aac8d33
--- /dev/null
+++ b/src/libstddjb/int32_fmtlist.c
@@ -0,0 +1,6 @@
+/* ISC license. */
+
+#include "fmtscan-internal.h"
+#include <skalibs/uint32.h>
+
+FMTSL(32)
diff --git a/src/libstddjb/int32_scan.c b/src/libstddjb/int32_scan.c
new file mode 100644
index 0000000..ba4510a
--- /dev/null
+++ b/src/libstddjb/int32_scan.c
@@ -0,0 +1,6 @@
+/* ISC license. */
+
+#include "fmtscan-internal.h"
+#include <skalibs/uint32.h>
+
+SCANS(32)
diff --git a/src/libstddjb/int32_scanlist.c b/src/libstddjb/int32_scanlist.c
new file mode 100644
index 0000000..b9e92d0
--- /dev/null
+++ b/src/libstddjb/int32_scanlist.c
@@ -0,0 +1,6 @@
+/* ISC license. */
+
+#include "fmtscan-internal.h"
+#include <skalibs/uint32.h>
+
+SCANSL(32)
diff --git a/src/libstddjb/int640_scan.c b/src/libstddjb/int640_scan.c
new file mode 100644
index 0000000..69e9f6d
--- /dev/null
+++ b/src/libstddjb/int640_scan.c
@@ -0,0 +1,6 @@
+/* ISC license. */
+
+#include "fmtscan-internal.h"
+#include <skalibs/uint64.h>
+
+SCANS0(64)
diff --git a/src/libstddjb/int64_fmt.c b/src/libstddjb/int64_fmt.c
new file mode 100644
index 0000000..d2b7145
--- /dev/null
+++ b/src/libstddjb/int64_fmt.c
@@ -0,0 +1,6 @@
+/* ISC license. */
+
+#include "fmtscan-internal.h"
+#include <skalibs/uint64.h>
+
+FMTS(64)
diff --git a/src/libstddjb/int64_fmtlist.c b/src/libstddjb/int64_fmtlist.c
new file mode 100644
index 0000000..8027708
--- /dev/null
+++ b/src/libstddjb/int64_fmtlist.c
@@ -0,0 +1,6 @@
+/* ISC license. */
+
+#include "fmtscan-internal.h"
+#include <skalibs/uint64.h>
+
+FMTSL(64)
diff --git a/src/libstddjb/int64_scan.c b/src/libstddjb/int64_scan.c
new file mode 100644
index 0000000..934e84c
--- /dev/null
+++ b/src/libstddjb/int64_scan.c
@@ -0,0 +1,6 @@
+/* ISC license. */
+
+#include "fmtscan-internal.h"
+#include <skalibs/uint64.h>
+
+SCANS(64)
diff --git a/src/libstddjb/int64_scanlist.c b/src/libstddjb/int64_scanlist.c
new file mode 100644
index 0000000..6a121a8
--- /dev/null
+++ b/src/libstddjb/int64_scanlist.c
@@ -0,0 +1,6 @@
+/* ISC license. */
+
+#include "fmtscan-internal.h"
+#include <skalibs/uint64.h>
+
+SCANSL(64)
diff --git a/src/libstddjb/ip46_scan.c b/src/libstddjb/ip46_scan.c
index 97ebe4d..73045e6 100644
--- a/src/libstddjb/ip46_scan.c
+++ b/src/libstddjb/ip46_scan.c
@@ -1,13 +1,12 @@
/* ISC license. */
-#include <skalibs/ip46.h>
-
+#include <sys/types.h>
#include <skalibs/fmtscan.h>
#include <skalibs/ip46.h>
-unsigned int ip46full_scan (char const *s, ip46full_t_ref ip)
+size_t ip46full_scan (char const *s, ip46full_t *ip)
{
- unsigned int len = ip6_scan(s, ip->ip) ;
+ size_t len = ip6_scan(s, ip->ip) ;
if (len) ip->is6 = 1 ;
else
{
diff --git a/src/libstddjb/ip46_scanlist.c b/src/libstddjb/ip46_scanlist.c
index 6462da7..7ee2b68 100644
--- a/src/libstddjb/ip46_scanlist.c
+++ b/src/libstddjb/ip46_scanlist.c
@@ -1,17 +1,17 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/ip46.h>
-
#include <skalibs/bytestr.h>
#include <skalibs/fmtscan.h>
-unsigned int ip46full_scanlist (ip46full_t *out, unsigned int max, char const *s, unsigned int *num)
+size_t ip46full_scanlist (ip46full_t *out, size_t max, char const *s, size_t *num)
{
- unsigned int n = 0, w = 0 ;
+ size_t n = 0, w = 0 ;
for (; s[w] && (n < max) ; n++)
{
ip46full_t z ;
- register unsigned int i = ip6_scan(s + w, z.ip) ;
+ register size_t i = ip6_scan(s + w, z.ip) ;
if (i) z.is6 = 1 ;
else
{
diff --git a/src/libstddjb/ip4_fmt.c b/src/libstddjb/ip4_fmt.c
index 4c2f6a3..9804b38 100644
--- a/src/libstddjb/ip4_fmt.c
+++ b/src/libstddjb/ip4_fmt.c
@@ -1,15 +1,16 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/uint32.h>
#include <skalibs/fmtscan.h>
-unsigned int ip4_fmt (char *s, char const *ip)
+size_t ip4_fmt (char *s, char const *ip)
{
- unsigned int len = 0 ;
- unsigned int i, j ;
- for (j = 0 ; j < 4 ; j++)
+ size_t len = 0 ;
+ unsigned int j = 0 ;
+ for (; j < 4 ; j++)
{
- i = uint32_fmt(s, (uint32)(unsigned char) ip[j]) ;
+ size_t i = uint32_fmt(s, (unsigned char)ip[j]) ;
len += i ;
if (s) s += i ;
if (j == 3) break ;
diff --git a/src/libstddjb/ip4_fmtu32.c b/src/libstddjb/ip4_fmtu32.c
index d4833e8..9347cef 100644
--- a/src/libstddjb/ip4_fmtu32.c
+++ b/src/libstddjb/ip4_fmtu32.c
@@ -1,9 +1,11 @@
/* ISC license. */
+#include <sys/types.h>
+#include <stdint.h>
#include <skalibs/uint32.h>
#include <skalibs/fmtscan.h>
-unsigned int ip4_fmtu32 (char *s, uint32 ip)
+size_t ip4_fmtu32 (char *s, uint32_t ip)
{
char pack[4] ;
uint32_pack_big(pack, ip) ;
diff --git a/src/libstddjb/ip4_scan.c b/src/libstddjb/ip4_scan.c
index 2873cd4..749a176 100644
--- a/src/libstddjb/ip4_scan.c
+++ b/src/libstddjb/ip4_scan.c
@@ -1,15 +1,16 @@
/* ISC license. */
-#include <skalibs/uint.h>
+#include <skalibs/types.h>
+#include <skalibs/fmtscan.h>
-unsigned int ip4_scan (char const *s, char *ip)
+size_t ip4_scan (char const *s, char *ip)
{
+ size_t len = 0 ;
register unsigned int j = 0 ;
- unsigned int len = 0 ;
for (; j < 4 ; j++)
{
unsigned int u ;
- register unsigned int i = uint_scan(s, &u) ;
+ register size_t i = uint_scan(s, &u) ;
if (!i) return 0 ;
ip[j] = (char)u ;
s += i ;
diff --git a/src/libstddjb/ip4_scanlist.c b/src/libstddjb/ip4_scanlist.c
index f1e3ccc..edc2949 100644
--- a/src/libstddjb/ip4_scanlist.c
+++ b/src/libstddjb/ip4_scanlist.c
@@ -1,14 +1,15 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/bytestr.h>
#include <skalibs/fmtscan.h>
-unsigned int ip4_scanlist (char *out, unsigned int max, char const *s, unsigned int *num)
+size_t ip4_scanlist (char *out, size_t max, char const *s, size_t *num)
{
- unsigned int n = 0, w = 0 ;
+ size_t n = 0, w = 0 ;
for (; s[w] && (n < max) ; n++)
{
- register unsigned int i = ip4_scan(s + w, out + (n << 2)) ;
+ register size_t i = ip4_scan(s + w, out + (n << 2)) ;
if (!i) break ;
w += i ;
while (byte_chr(",:; \t\r\n", 7, s[w]) < 7) w++ ;
diff --git a/src/libstddjb/ip4_scanlist_u32.c b/src/libstddjb/ip4_scanlist_u32.c
index 26a4e38..10c24cf 100644
--- a/src/libstddjb/ip4_scanlist_u32.c
+++ b/src/libstddjb/ip4_scanlist_u32.c
@@ -1,15 +1,17 @@
/* ISC license. */
+#include <sys/types.h>
+#include <stdint.h>
#include <skalibs/uint32.h>
#include <skalibs/bytestr.h>
#include <skalibs/fmtscan.h>
-unsigned int ip4_scanlist_u32 (uint32 *out, unsigned int max, char const *s, unsigned int *num)
+size_t ip4_scanlist_u32 (uint32_t *out, size_t max, char const *s, size_t *num)
{
- unsigned int n = 0, w = 0 ;
+ size_t n = 0, w = 0 ;
for (; s[w] && (n < max) ; n++)
{
- register unsigned int i = ip4_scanu32(s + w, out + n) ;
+ register size_t i = ip4_scanu32(s + w, out + n) ;
if (!i) break ;
w += i ;
while (byte_chr(",:; \t\r\n", 7, s[w]) < 7) w++ ;
diff --git a/src/libstddjb/ip4_scanu32.c b/src/libstddjb/ip4_scanu32.c
index a305926..205c52d 100644
--- a/src/libstddjb/ip4_scanu32.c
+++ b/src/libstddjb/ip4_scanu32.c
@@ -1,12 +1,14 @@
/* ISC license. */
+#include <sys/types.h>
+#include <stdint.h>
#include <skalibs/uint32.h>
#include <skalibs/fmtscan.h>
-unsigned int ip4_scanu32 (char const *s, uint32 *ip)
+size_t ip4_scanu32 (char const *s, uint32_t *ip)
{
char pack[4] ;
- register unsigned int r = ip4_scan(s, pack) ;
+ register size_t r = ip4_scan(s, pack) ;
if (r) uint32_unpack_big(pack, ip) ;
return r ;
}
diff --git a/src/libstddjb/ip6_fmt.c b/src/libstddjb/ip6_fmt.c
index afd8a21..eb6acc0 100644
--- a/src/libstddjb/ip6_fmt.c
+++ b/src/libstddjb/ip6_fmt.c
@@ -1,13 +1,14 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/diuint.h>
#include <skalibs/fmtscan.h>
#define px(c) ((j || (c)) ? (*s++ = fmtscan_asc(c), 1) : 0)
-static inline unsigned int xfmt16 (char *s, char const *key)
+static inline size_t xfmt16 (char *s, char const *key)
{
- register unsigned int j = 0 ;
+ register 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) ;
@@ -55,9 +56,9 @@ static inline unsigned int find_colcol (char const *key, unsigned int *pos)
return 0 ;
}
-unsigned int ip6_fmt (char *s, char const *ip6)
+size_t ip6_fmt (char *s, char const *ip6)
{
- unsigned int w = 0 ;
+ size_t w = 0 ;
register unsigned int i = 0 ;
unsigned int pos = 8 ;
unsigned int len = find_colcol(ip6, &pos) ;
diff --git a/src/libstddjb/ip6_scan.c b/src/libstddjb/ip6_scan.c
index cb2dc49..1e34051 100644
--- a/src/libstddjb/ip6_scan.c
+++ b/src/libstddjb/ip6_scan.c
@@ -1,15 +1,18 @@
/* ISC license. */
+#include <sys/types.h>
+#include <stdint.h>
#include <errno.h>
#include <skalibs/uint16.h>
#include <skalibs/fmtscan.h>
-unsigned int ip6_scan (char const *s, char *ip6)
+size_t ip6_scan (char const *s, char *ip6)
{
static const unsigned char class[256] = "2222222222222222222222222222222222222222222222220000000000122222200000022222222222222222222222222000000222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222" ;
static const unsigned char table[5][3] = { "\024#\005", "\024\"\005", "\024\005\006", "\005\002\005", "\024\t\016" } ;
- uint16 tmp[8] = { 0, 0, 0, 0, 0, 0, 0, 0 } ;
- unsigned int pos = 8, j = 0, state = 0, i = 0 ;
+ uint16_t tmp[8] = { 0, 0, 0, 0, 0, 0, 0, 0 } ;
+ size_t i = 0 ;
+ unsigned int pos = 8, j = 0, state = 0 ;
while (state < 5)
{
diff --git a/src/libstddjb/ip6_scanlist.c b/src/libstddjb/ip6_scanlist.c
index 8d751a6..cf1c7fd 100644
--- a/src/libstddjb/ip6_scanlist.c
+++ b/src/libstddjb/ip6_scanlist.c
@@ -1,15 +1,16 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/bytestr.h>
#include <skalibs/fmtscan.h>
-unsigned int ip6_scanlist (char *out, unsigned int max, char const *s, unsigned int *num)
+size_t ip6_scanlist (char *out, size_t max, char const *s, size_t *num)
{
- unsigned int n = 0, w = 0 ;
+ size_t n = 0, w = 0 ;
for (; s[w] && (n < max) ; n++)
{
char ip[16] ;
- register unsigned int i = ip6_scan(s + w, ip) ;
+ register size_t i = ip6_scan(s + w, ip) ;
if (!i) break ;
byte_copy(out + (n << 4), 16, ip) ;
w += i ;
diff --git a/src/libstddjb/localtm_fmt.c b/src/libstddjb/localtm_fmt.c
index ee083ef..dc8095a 100644
--- a/src/libstddjb/localtm_fmt.c
+++ b/src/libstddjb/localtm_fmt.c
@@ -1,10 +1,11 @@
/* ISC license. */
+#include <sys/types.h>
#include <time.h>
-#include <skalibs/uint.h>
+#include <skalibs/types.h>
#include <skalibs/djbtime.h>
-unsigned int localtm_fmt (char *s, struct tm const *l)
+size_t localtm_fmt (char *s, struct tm const *l)
{
char *p = s ;
p += uint_fmt(p, 1900 + l->tm_year) ; *p++ = '-' ;
diff --git a/src/libstddjb/localtm_scan.c b/src/libstddjb/localtm_scan.c
index b028883..62bf4c3 100644
--- a/src/libstddjb/localtm_scan.c
+++ b/src/libstddjb/localtm_scan.c
@@ -1,37 +1,52 @@
/* ISC license. */
+#include <sys/types.h>
#include <errno.h>
#include <time.h>
+#include <skalibs/types.h>
#include <skalibs/djbtime.h>
-#include <skalibs/uint.h>
-unsigned int localtm_scan (char const *s, struct tm *l)
+size_t localtm_scan (char const *s, struct tm *l)
{
struct tm ll = { .tm_isdst = -1 } ;
- unsigned int n = 0 ; unsigned int u ;
- register unsigned int i = uint_scan(s+n, &u) ;
- if (!i) goto fail ; n += i ;
- if (u < 1900) goto fail ; u -= 1900 ; ll.tm_year = u ;
+ size_t n = 0 ;
+ unsigned int u ;
+ register size_t i = uint_scan(s+n, &u) ;
+ if (!i) goto fail ;
+ n += i ;
+ if (u < 1900) goto fail ;
+ u -= 1900 ; ll.tm_year = u ;
if (s[n++] != '-') goto fail ;
i = uint_scan(s+n, &u) ;
- if (!i) goto fail ; n += i ;
- if (!u || (u > 12)) goto fail ; u-- ; ll.tm_mon = u ;
+ if (!i) goto fail ;
+ n += i ;
+ if (!u || (u > 12)) goto fail ;
+ u-- ; ll.tm_mon = u ;
if (s[n++] != '-') goto fail ;
i = uint_scan(s+n, &u) ;
- if (!i) goto fail ; n += i ;
- if (!u || (u > 31)) goto fail ; ll.tm_mday = u ;
- if ((s[n] != ' ') && (s[n] != 'T')) goto fail ; n++ ;
+ if (!i) goto fail ;
+ n += i ;
+ if (!u || (u > 31)) goto fail ;
+ ll.tm_mday = u ;
+ if ((s[n] != ' ') && (s[n] != 'T')) goto fail ;
+ n++ ;
i = uint_scan(s+n, &u) ;
- if (!i) goto fail ; n += i ;
- if (u > 23) goto fail ; ll.tm_hour = u ;
+ if (!i) goto fail ;
+ n += i ;
+ if (u > 23) goto fail ;
+ ll.tm_hour = u ;
if (s[n++] != ':') goto fail ;
i = uint_scan(s+n, &u) ;
- if (!i) goto fail ; n += i ;
- if (u > 59) goto fail ; ll.tm_min = u ;
+ if (!i) goto fail ;
+ n += i ;
+ if (u > 59) goto fail ;
+ ll.tm_min = u ;
if (s[n++] != ':') goto fail ;
i = uint_scan(s+n, &u) ;
- if (!i) goto fail ; n += i ;
- if (u > 60) goto fail ; ll.tm_sec = u ;
+ if (!i) goto fail ;
+ n += i ;
+ if (u > 60) goto fail ;
+ ll.tm_sec = u ;
if (mktime(&ll) == (time_t)-1) goto fail ;
*l = ll ;
return n ;
diff --git a/src/libstddjb/localtmn_fmt.c b/src/libstddjb/localtmn_fmt.c
index 79a869d..b47911d 100644
--- a/src/libstddjb/localtmn_fmt.c
+++ b/src/libstddjb/localtmn_fmt.c
@@ -1,9 +1,10 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/uint32.h>
#include <skalibs/djbtime.h>
-unsigned int localtmn_fmt (char *s, localtmn_t const *l)
+size_t localtmn_fmt (char *s, localtmn_t const *l)
{
char *p = s ;
p += localtm_fmt(p, &l->tm) ; *p++ = '.' ;
diff --git a/src/libstddjb/localtmn_scan.c b/src/libstddjb/localtmn_scan.c
index fa5cbcd..c9d4d19 100644
--- a/src/libstddjb/localtmn_scan.c
+++ b/src/libstddjb/localtmn_scan.c
@@ -1,18 +1,19 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/uint32.h>
#include <skalibs/djbtime.h>
-unsigned int localtmn_scan (char const *s, localtmn_t *l)
+size_t localtmn_scan (char const *s, localtmn_t *l)
{
localtmn_t m ;
- unsigned int n = localtm_scan(s, &m.tm) ;
+ size_t n = localtm_scan(s, &m.tm) ;
if (!n) return 0 ;
s += n ;
if (*s++ != '.') m.nano = 0 ;
else
{
- register unsigned int b = uint32_scan(s, &m.nano) ;
+ register size_t b = uint32_scan(s, &m.nano) ;
if (!b) return 0 ;
n += b ;
}
diff --git a/src/libstddjb/long_fmt.c b/src/libstddjb/long_fmt.c
deleted file mode 100644
index 552fe47..0000000
--- a/src/libstddjb/long_fmt.c
+++ /dev/null
@@ -1,10 +0,0 @@
-/* ISC license. */
-
-#include <skalibs/ulong.h>
-
-unsigned int long_fmt (char *fmt, long n)
-{
- if (n >= 0) return ulong_fmt(fmt, n) ;
- if (fmt) *fmt++ = '-' ;
- return 1 + ulong_fmt(fmt, -n) ;
-}
diff --git a/src/libstddjb/netstring_append.c b/src/libstddjb/netstring_append.c
index 9c14f49..88098a4 100644
--- a/src/libstddjb/netstring_append.c
+++ b/src/libstddjb/netstring_append.c
@@ -1,14 +1,15 @@
/* ISC license. */
-#include <skalibs/uint.h>
+#include <sys/types.h>
+#include <skalibs/uint64.h>
#include <skalibs/bytestr.h>
#include <skalibs/stralloc.h>
#include <skalibs/netstring.h>
-int netstring_appendb (stralloc *sa, char const *s, unsigned int len)
+int netstring_appendb (stralloc *sa, char const *s, size_t len)
{
- char fmt[UINT_FMT] ;
- unsigned int n = uint_fmt(fmt, len) ;
+ char fmt[UINT64_FMT] ;
+ size_t n = uint64_fmt(fmt, len) ;
if (!stralloc_readyplus(sa, len + n + 2)) return 0 ;
fmt[n] = ':' ;
byte_copy(sa->s + sa->len, n+1, fmt) ;
diff --git a/src/libstddjb/netstring_appendv.c b/src/libstddjb/netstring_appendv.c
index 1fc1406..1d9c290 100644
--- a/src/libstddjb/netstring_appendv.c
+++ b/src/libstddjb/netstring_appendv.c
@@ -1,26 +1,27 @@
/* ISC license. */
-#include <skalibs/uint.h>
+#include <sys/types.h>
+#include <skalibs/uint64.h>
#include <skalibs/bytestr.h>
#include <skalibs/siovec.h>
#include <skalibs/stralloc.h>
#include <skalibs/netstring.h>
-int netstring_appendv (stralloc *sa, siovec_t const *v, unsigned int n)
+int netstring_appendv (stralloc *sa, struct iovec const *v, unsigned int n)
{
- char fmt[UINT_FMT] ;
- unsigned int len = 0, pos ;
+ char fmt[UINT64_FMT] ;
+ size_t len = 0, pos ;
register unsigned int i = 0 ;
- for (; i < n ; i++) len += v[i].len ;
- pos = uint_fmt(fmt, len) ;
+ for (; i < n ; i++) len += v[i].iov_len ;
+ pos = uint64_fmt(fmt, len) ;
if (!stralloc_readyplus(sa, len + pos + 2)) return 0 ;
fmt[pos] = ':' ;
byte_copy(sa->s + sa->len, pos+1, fmt) ;
sa->len += pos+1 ;
for (i = 0 ; i < n ; i++)
{
- byte_copy(sa->s + sa->len, v[i].len, v[i].s) ;
- sa->len += v[i].len ;
+ byte_copy(sa->s + sa->len, v[i].iov_len, (char const *)v[i].iov_base) ;
+ sa->len += v[i].iov_len ;
}
sa->s[sa->len++] = ',' ;
return 1 ;
diff --git a/src/libstddjb/netstring_decode.c b/src/libstddjb/netstring_decode.c
index a81756b..d129ea8 100644
--- a/src/libstddjb/netstring_decode.c
+++ b/src/libstddjb/netstring_decode.c
@@ -1,17 +1,17 @@
/* ISC license. */
+#include <sys/types.h>
#include <errno.h>
-#include <skalibs/fmtscan.h>
+#include <skalibs/uint64.h>
#include <skalibs/netstring.h>
#include <skalibs/stralloc.h>
-#include <skalibs/uint.h>
-int netstring_decode (stralloc *sa, char const *s, unsigned int len)
+ssize_t netstring_decode (stralloc *sa, char const *s, size_t len)
{
- unsigned int nlen ;
- register unsigned int pos ;
+ uint64_t nlen ;
+ register size_t pos ;
if (!len) return 0 ;
- pos = uint_scan(s, &nlen) ;
+ pos = uint64_scan(s, &nlen) ;
if (pos >= len) return (errno = EINVAL, -1) ;
if (s[pos] != ':') return (errno = EINVAL, -1) ;
s += pos+1 ; len -= pos+1 ;
diff --git a/src/libstddjb/netstring_encode.c b/src/libstddjb/netstring_encode.c
index c13abd6..6b2d0ea 100644
--- a/src/libstddjb/netstring_encode.c
+++ b/src/libstddjb/netstring_encode.c
@@ -1,13 +1,14 @@
/* ISC license. */
+#include <sys/types.h>
+#include <skalibs/uint64.h>
#include <skalibs/netstring.h>
#include <skalibs/stralloc.h>
-#include <skalibs/uint.h>
-int netstring_encode (stralloc *sa, char const *s, unsigned int len)
+int netstring_encode (stralloc *sa, char const *s, size_t len)
{
- char fmt[UINT_FMT] ;
- unsigned int pos = uint_fmt(fmt, len) ;
+ char fmt[UINT64_FMT] ;
+ size_t pos = uint64_fmt(fmt, len) ;
if (!stralloc_readyplus(sa, pos + len + 2)) return 0 ;
stralloc_catb(sa, fmt, pos) ;
stralloc_catb(sa, ":", 1) ;
diff --git a/src/libstddjb/netstring_get.c b/src/libstddjb/netstring_get.c
index 6f6c602..c2f8b05 100644
--- a/src/libstddjb/netstring_get.c
+++ b/src/libstddjb/netstring_get.c
@@ -1,8 +1,9 @@
/* ISC license. */
+#include <sys/types.h>
#include <errno.h>
+#include <skalibs/uint64.h>
#include <skalibs/allreadwrite.h>
-#include <skalibs/uint.h>
#include <skalibs/bytestr.h>
#include <skalibs/buffer.h>
#include <skalibs/cbuffer.h>
@@ -10,25 +11,25 @@
#include <skalibs/stralloc.h>
#include <skalibs/netstring.h>
-int netstring_okeof (buffer *b, unsigned int w)
+int netstring_okeof (buffer *b, size_t w)
{
return (errno == EPIPE) && !w && buffer_isempty(b) ? (errno = 0, 1) : 0 ;
}
-int netstring_get (buffer *b, stralloc *sa, unsigned int *state)
+ssize_t netstring_get (buffer *b, stralloc *sa, size_t *state)
{
if (!*state)
{
- unsigned int n ;
- unsigned int len ;
- char buf[UINT_FMT] ;
- if (b->c.a < UINT_FMT+1) return (errno = EINVAL, -1) ;
+ size_t n ;
+ size_t len ;
+ char buf[UINT64_FMT] ;
+ if (b->c.a < UINT64_FMT+1) return (errno = EINVAL, -1) ;
for (;;)
{
register int r ;
- len = buffer_getnofill(b, buf, UINT_FMT) ;
+ len = buffer_getnofill(b, buf, UINT64_FMT) ;
n = byte_chr(buf, len, ':') ; /* XXX: accepts :, as a valid netstring */
- if (n >= UINT_FMT)
+ if (n >= UINT64_FMT)
{
buffer_unget(b, len) ;
return (errno = EPROTO, -1) ;
@@ -39,13 +40,13 @@ int netstring_get (buffer *b, stralloc *sa, unsigned int *state)
if (r <= 0) return r ;
}
buffer_unget(b, len - n - 1) ;
- if (!n || n != uint_scan(buf, &len)) return (errno = EPROTO, -1) ;
+ if (!n || n != uint64_scan(buf, &len)) return (errno = EPROTO, -1) ;
if (!stralloc_readyplus(sa, len + 1)) return -1 ;
*state = len + 1 ;
}
{
- unsigned int w = 0 ;
- register int r = buffer_getall(b, sa->s + sa->len, *state, &w) ;
+ size_t w = 0 ;
+ register ssize_t 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/netstring_put.c b/src/libstddjb/netstring_put.c
index 5a27b25..692d2fc 100644
--- a/src/libstddjb/netstring_put.c
+++ b/src/libstddjb/netstring_put.c
@@ -1,34 +1,35 @@
/* ISC license. */
+#include <sys/types.h>
#include <errno.h>
+#include <skalibs/uint64.h>
#include <skalibs/buffer.h>
#include <skalibs/netstring.h>
-#include <skalibs/uint.h>
-int netstring_put (buffer *b, char const *s, unsigned int len, unsigned int *written)
+int netstring_put (buffer *b, char const *s, size_t len, size_t *written)
{
- char fmt[UINT_FMT] ;
- unsigned int n = uint_fmt(fmt, len) ;
+ char fmt[UINT64_FMT] ;
+ size_t n = uint64_fmt(fmt, len) ;
if (*written > len + n + 2) return (errno = EINVAL, 0) ;
fmt[n] = ':' ;
if (*written < n + 1)
{
- unsigned int w = *written ;
- int r = buffer_putall(b, fmt, n+1, &w) ;
+ size_t w = *written ;
+ ssize_t r = buffer_putall(b, fmt, n+1, &w) ;
if (r < 0) return (*written = w, 0) ;
*written = n+1 ;
}
if (*written < n+1 + len)
{
- unsigned int w = *written - (n+1) ;
- int r = buffer_putall(b, s, len, &w) ;
+ size_t w = *written - (n+1) ;
+ ssize_t r = buffer_putall(b, s, len, &w) ;
*written = w + (n+1) ;
if (r < 0) return (*written = n+1 + w, 0) ;
*written = n+1 + len ;
}
{
- unsigned int w = 0 ;
- int r = buffer_putall(b, ",", 1, &w) ;
+ size_t w = 0 ;
+ ssize_t r = buffer_putall(b, ",", 1, &w) ;
if (r < 0) return 0 ;
}
*written = 0 ;
diff --git a/src/libstddjb/sauniquename.c b/src/libstddjb/sauniquename.c
index ddf47ec..ff102fa 100644
--- a/src/libstddjb/sauniquename.c
+++ b/src/libstddjb/sauniquename.c
@@ -1,11 +1,11 @@
/* ISC license. */
#include <unistd.h>
+#include <skalibs/types.h>
#include <skalibs/djbunix.h>
#include <skalibs/skamisc.h>
#include <skalibs/stralloc.h>
#include <skalibs/tai.h>
-#include <skalibs/uint.h>
int sauniquename (stralloc *sa)
{
@@ -17,7 +17,7 @@ int sauniquename (stralloc *sa)
timestamp(sa->s + base + 1) ;
sa->s[base + 1 + TIMESTAMP] = ':' ;
sa->len = base + 2 + TIMESTAMP ;
- sa->len += uint_fmt(sa->s + sa->len, getpid()) ;
+ sa->len += pid_fmt(sa->s + sa->len, getpid()) ;
sa->s[sa->len++] = ':' ;
if (sagethostname(sa) == -1) goto err ;
return 1 ;
diff --git a/src/libstddjb/str_fmt.c b/src/libstddjb/str_fmt.c
index 1c14c70..220119a 100644
--- a/src/libstddjb/str_fmt.c
+++ b/src/libstddjb/str_fmt.c
@@ -1,9 +1,9 @@
/* ISC license. */
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/fmtscan.h>
-unsigned int str_fmt (register char *d, char const *s)
+size_t str_fmt (char *d, char const *s)
{
- return strn_fmt(d, s, str_len(s)) ;
+ return strn_fmt(d, s, strlen(s)) ;
}
diff --git a/src/libstddjb/strn_fmt.c b/src/libstddjb/strn_fmt.c
index bbb9651..0c6ffb7 100644
--- a/src/libstddjb/strn_fmt.c
+++ b/src/libstddjb/strn_fmt.c
@@ -1,12 +1,13 @@
/* ISC license. */
+#include <sys/types.h>
+#include <skalibs/types.h>
#include <skalibs/fmtscan.h>
-#include <skalibs/uint.h>
-unsigned int strn_fmt (char *blah, register char const *s, unsigned int len)
+size_t strn_fmt (char *blah, register char const *s, size_t len)
{
register char *d = blah ;
- unsigned int i ;
+ size_t i ;
for (i = 0 ; i < len ; i++)
if ((s[i] >= 32) && ((unsigned char)s[i] < 127)) *d++ = s[i] ;
else
diff --git a/src/libstddjb/ucharn_findlen.c b/src/libstddjb/ucharn_findlen.c
index 1016647..59b5577 100644
--- a/src/libstddjb/ucharn_findlen.c
+++ b/src/libstddjb/ucharn_findlen.c
@@ -1,10 +1,11 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/fmtscan.h>
-unsigned int ucharn_findlen (char const *s)
+size_t ucharn_findlen (char const *s)
{
- register unsigned int i = 0 ;
+ register size_t i = 0 ;
while (fmtscan_num(s[i], 16) <= 0xF) i++ ;
return i ;
}
diff --git a/src/libstddjb/ucharn_fmt.c b/src/libstddjb/ucharn_fmt.c
index 2943fdf..5eec54f 100644
--- a/src/libstddjb/ucharn_fmt.c
+++ b/src/libstddjb/ucharn_fmt.c
@@ -1,10 +1,11 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/fmtscan.h>
-unsigned int ucharn_fmt (char *s, char const *key, unsigned int n)
+size_t ucharn_fmt (char *s, char const *key, size_t n)
{
- register unsigned int i = 0 ;
+ register size_t i = 0 ;
for (; i < n ; i++)
{
s[i<<1] = fmtscan_asc((unsigned char)key[i] >> 4) ;
diff --git a/src/libstddjb/ucharn_fmt_little.c b/src/libstddjb/ucharn_fmt_little.c
index 8450c46..d033096 100644
--- a/src/libstddjb/ucharn_fmt_little.c
+++ b/src/libstddjb/ucharn_fmt_little.c
@@ -1,10 +1,11 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/fmtscan.h>
-unsigned int ucharn_fmt_little (char *s, char const *key, unsigned int n)
+size_t ucharn_fmt_little (char *s, char const *key, size_t n)
{
- register unsigned int i = 0 ;
+ register size_t i = 0 ;
for (; i < n ; i++)
{
s[i<<1] = fmtscan_asc((unsigned char)key[i] & 0xF) ;
diff --git a/src/libstddjb/ucharn_scan.c b/src/libstddjb/ucharn_scan.c
index cdcc403..b544d0d 100644
--- a/src/libstddjb/ucharn_scan.c
+++ b/src/libstddjb/ucharn_scan.c
@@ -1,8 +1,9 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/fmtscan.h>
-unsigned int ucharn_scan (char const *s, char *key, unsigned int n)
+size_t ucharn_scan (char const *s, char *key, size_t n)
{
register unsigned int i = 0 ;
for (; i < n ; i++)
diff --git a/src/libstddjb/ucharn_scan_little.c b/src/libstddjb/ucharn_scan_little.c
index 5b66af5..b278dff 100644
--- a/src/libstddjb/ucharn_scan_little.c
+++ b/src/libstddjb/ucharn_scan_little.c
@@ -1,10 +1,11 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/fmtscan.h>
-unsigned int ucharn_scan_little (char const *s, char *key, unsigned int n)
+size_t ucharn_scan_little (char const *s, char *key, size_t n)
{
- register unsigned int i = 0 ;
+ register size_t i = 0 ;
for (; i < n ; i++)
{
unsigned char c = fmtscan_num(s[(i<<1)+1], 16) ;
diff --git a/src/libstddjb/uint160_fmt.c b/src/libstddjb/uint160_fmt.c
new file mode 100644
index 0000000..ccd2485
--- /dev/null
+++ b/src/libstddjb/uint160_fmt.c
@@ -0,0 +1,6 @@
+/* ISC license. */
+
+#include "fmtscan-internal.h"
+#include <skalibs/uint16.h>
+
+FMTB0(16)
diff --git a/src/libstddjb/uint160_scan.c b/src/libstddjb/uint160_scan.c
index 9a48514..36d04f3 100644
--- a/src/libstddjb/uint160_scan.c
+++ b/src/libstddjb/uint160_scan.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/uint16.h>
#include "fmtscan-internal.h"
+#include <skalibs/uint16.h>
SCANB0(16)
diff --git a/src/libstddjb/uint16_fmt.c b/src/libstddjb/uint16_fmt.c
new file mode 100644
index 0000000..668c2bf
--- /dev/null
+++ b/src/libstddjb/uint16_fmt.c
@@ -0,0 +1,6 @@
+/* ISC license. */
+
+#include "fmtscan-internal.h"
+#include <skalibs/uint16.h>
+
+FMTB(16)
diff --git a/src/libstddjb/uint16_fmtlist.c b/src/libstddjb/uint16_fmtlist.c
index 721b443..4898d5c 100644
--- a/src/libstddjb/uint16_fmtlist.c
+++ b/src/libstddjb/uint16_fmtlist.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/uint16.h>
#include "fmtscan-internal.h"
+#include <skalibs/uint16.h>
FMTL(16)
diff --git a/src/libstddjb/uint16_pack.c b/src/libstddjb/uint16_pack.c
index c84f504..56b5dcb 100644
--- a/src/libstddjb/uint16_pack.c
+++ b/src/libstddjb/uint16_pack.c
@@ -1,9 +1,10 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/uint16.h>
#include <skalibs/bytestr.h>
-void uint16_pack (char *s, uint16 u)
+void uint16_pack (char *s, uint16_t u)
{
((unsigned char *)s)[0] = T8(u) ; u >>= 8 ;
((unsigned char *)s)[1] = T8(u) ;
diff --git a/src/libstddjb/uint16_pack_big.c b/src/libstddjb/uint16_pack_big.c
index 9fac1fa..b5b0f01 100644
--- a/src/libstddjb/uint16_pack_big.c
+++ b/src/libstddjb/uint16_pack_big.c
@@ -1,9 +1,10 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/uint16.h>
#include <skalibs/bytestr.h>
-void uint16_pack_big (char *s, uint16 u)
+void uint16_pack_big (char *s, uint16_t u)
{
((unsigned char *)s)[1] = T8(u) ; u >>= 8 ;
((unsigned char *)s)[0] = T8(u) ;
diff --git a/src/libstddjb/uint16_reverse.c b/src/libstddjb/uint16_reverse.c
index fedade1..9a6e8d9 100644
--- a/src/libstddjb/uint16_reverse.c
+++ b/src/libstddjb/uint16_reverse.c
@@ -1,8 +1,9 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/uint16.h>
-void uint16_reverse (char *s, unsigned int n)
+void uint16_reverse (char *s, size_t n)
{
while (n--)
{
diff --git a/src/libstddjb/uint16_scan.c b/src/libstddjb/uint16_scan.c
index 5665807..4c0564e 100644
--- a/src/libstddjb/uint16_scan.c
+++ b/src/libstddjb/uint16_scan.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/uint16.h>
#include "fmtscan-internal.h"
+#include <skalibs/uint16.h>
SCANB(16)
diff --git a/src/libstddjb/uint16_scanlist.c b/src/libstddjb/uint16_scanlist.c
index e98777f..afb9af4 100644
--- a/src/libstddjb/uint16_scanlist.c
+++ b/src/libstddjb/uint16_scanlist.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/uint16.h>
#include "fmtscan-internal.h"
+#include <skalibs/uint16.h>
SCANL(16)
diff --git a/src/libstddjb/uint16_unpack.c b/src/libstddjb/uint16_unpack.c
index c3ade45..1497671 100644
--- a/src/libstddjb/uint16_unpack.c
+++ b/src/libstddjb/uint16_unpack.c
@@ -1,11 +1,12 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/uint16.h>
#include <skalibs/bytestr.h>
-void uint16_unpack (char const *s, uint16 *u)
+void uint16_unpack (char const *s, uint16_t *u)
{
- uint16 r = T8((unsigned char)s[1]) ; r <<= 8 ;
+ uint16_t r = T8((unsigned char)s[1]) ; r <<= 8 ;
r += T8((unsigned char)s[0]) ;
*u = r ;
}
diff --git a/src/libstddjb/uint16_unpack_big.c b/src/libstddjb/uint16_unpack_big.c
index 2f22555..73b94da 100644
--- a/src/libstddjb/uint16_unpack_big.c
+++ b/src/libstddjb/uint16_unpack_big.c
@@ -1,11 +1,12 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/uint16.h>
#include <skalibs/bytestr.h>
-void uint16_unpack_big (char const *s, uint16 *u)
+void uint16_unpack_big (char const *s, uint16_t *u)
{
- uint16 r = T8((unsigned char)s[0]) ; r <<= 8 ;
+ uint16_t r = T8((unsigned char)s[0]) ; r <<= 8 ;
r += T8((unsigned char)s[1]) ;
*u = r ;
}
diff --git a/src/libstddjb/uint320_fmt.c b/src/libstddjb/uint320_fmt.c
new file mode 100644
index 0000000..7de9833
--- /dev/null
+++ b/src/libstddjb/uint320_fmt.c
@@ -0,0 +1,6 @@
+/* ISC license. */
+
+#include "fmtscan-internal.h"
+#include <skalibs/uint32.h>
+
+FMTB0(32)
diff --git a/src/libstddjb/uint320_scan.c b/src/libstddjb/uint320_scan.c
index 103354c..2c63e65 100644
--- a/src/libstddjb/uint320_scan.c
+++ b/src/libstddjb/uint320_scan.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/uint32.h>
#include "fmtscan-internal.h"
+#include <skalibs/uint32.h>
SCANB0(32)
diff --git a/src/libstddjb/uint32_fmt.c b/src/libstddjb/uint32_fmt.c
new file mode 100644
index 0000000..4364285
--- /dev/null
+++ b/src/libstddjb/uint32_fmt.c
@@ -0,0 +1,6 @@
+/* ISC license. */
+
+#include "fmtscan-internal.h"
+#include <skalibs/uint32.h>
+
+FMTB(32)
diff --git a/src/libstddjb/uint32_fmtlist.c b/src/libstddjb/uint32_fmtlist.c
index 831dcfc..d7e96be 100644
--- a/src/libstddjb/uint32_fmtlist.c
+++ b/src/libstddjb/uint32_fmtlist.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/uint32.h>
#include "fmtscan-internal.h"
+#include <skalibs/uint32.h>
FMTL(32)
diff --git a/src/libstddjb/uint32_pack.c b/src/libstddjb/uint32_pack.c
index d467c3d..75febe0 100644
--- a/src/libstddjb/uint32_pack.c
+++ b/src/libstddjb/uint32_pack.c
@@ -1,9 +1,10 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/uint32.h>
#include <skalibs/bytestr.h>
-void uint32_pack (char *s, uint32 u)
+void uint32_pack (char *s, uint32_t u)
{
((unsigned char *)s)[0] = T8(u) ; u >>= 8 ;
((unsigned char *)s)[1] = T8(u) ; u >>= 8 ;
diff --git a/src/libstddjb/uint32_pack_big.c b/src/libstddjb/uint32_pack_big.c
index 487cf21..02f0eb6 100644
--- a/src/libstddjb/uint32_pack_big.c
+++ b/src/libstddjb/uint32_pack_big.c
@@ -1,9 +1,10 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/uint32.h>
#include <skalibs/bytestr.h>
-void uint32_pack_big (char *s, uint32 u)
+void uint32_pack_big (char *s, uint32_t u)
{
((unsigned char *)s)[3] = T8(u) ; u >>= 8 ;
((unsigned char *)s)[2] = T8(u) ; u >>= 8 ;
diff --git a/src/libstddjb/uint32_reverse.c b/src/libstddjb/uint32_reverse.c
index 18b3b43..6a33f23 100644
--- a/src/libstddjb/uint32_reverse.c
+++ b/src/libstddjb/uint32_reverse.c
@@ -1,8 +1,9 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/uint32.h>
-void uint32_reverse (char *s, unsigned int n)
+void uint32_reverse (char *s, size_t n)
{
while (n--)
{
diff --git a/src/libstddjb/uint32_scan.c b/src/libstddjb/uint32_scan.c
index 06e2d77..58d43e6 100644
--- a/src/libstddjb/uint32_scan.c
+++ b/src/libstddjb/uint32_scan.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/uint32.h>
#include "fmtscan-internal.h"
+#include <skalibs/uint32.h>
SCANB(32)
diff --git a/src/libstddjb/uint32_scanlist.c b/src/libstddjb/uint32_scanlist.c
index 8af3ae9..34d8067 100644
--- a/src/libstddjb/uint32_scanlist.c
+++ b/src/libstddjb/uint32_scanlist.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/uint32.h>
#include "fmtscan-internal.h"
+#include <skalibs/uint32.h>
SCANL(32)
diff --git a/src/libstddjb/uint32_unpack.c b/src/libstddjb/uint32_unpack.c
index d5dabcc..a9cabbb 100644
--- a/src/libstddjb/uint32_unpack.c
+++ b/src/libstddjb/uint32_unpack.c
@@ -1,11 +1,12 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/uint32.h>
#include <skalibs/bytestr.h>
-void uint32_unpack (char const *s, uint32 *u)
+void uint32_unpack (char const *s, uint32_t *u)
{
- uint32 r = T8((unsigned char)s[3]) ; r <<= 8 ;
+ uint32_t r = T8((unsigned char)s[3]) ; r <<= 8 ;
r += T8((unsigned char)s[2]) ; r <<= 8 ;
r += T8((unsigned char)s[1]) ; r <<= 8 ;
r += T8((unsigned char)s[0]) ;
diff --git a/src/libstddjb/uint32_unpack_big.c b/src/libstddjb/uint32_unpack_big.c
index 1a53292..defde56 100644
--- a/src/libstddjb/uint32_unpack_big.c
+++ b/src/libstddjb/uint32_unpack_big.c
@@ -1,11 +1,12 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/uint32.h>
#include <skalibs/bytestr.h>
-void uint32_unpack_big (char const *s, uint32 *u)
+void uint32_unpack_big (char const *s, uint32_t *u)
{
- uint32 r = T8((unsigned char)s[0]) ; r <<= 8 ;
+ uint32_t r = T8((unsigned char)s[0]) ; r <<= 8 ;
r += T8((unsigned char)s[1]) ; r <<= 8 ;
r += T8((unsigned char)s[2]) ; r <<= 8 ;
r += T8((unsigned char)s[3]) ;
diff --git a/src/libstddjb/uint640_fmt.c b/src/libstddjb/uint640_fmt.c
index 7153055..dc9cfa5 100644
--- a/src/libstddjb/uint640_fmt.c
+++ b/src/libstddjb/uint640_fmt.c
@@ -1,10 +1,6 @@
/* ISC license. */
+#include "fmtscan-internal.h"
#include <skalibs/uint64.h>
-unsigned int uint640_fmt_base (char *s, uint64 x, register unsigned int n, unsigned char base)
-{
- register unsigned int len = uint64_fmt_base(0, x, base) ;
- while (n-- > len) *s++ = '0' ;
- return uint64_fmt_base(s, x, base) ;
-}
+FMTB0(64)
diff --git a/src/libstddjb/uint640_scan.c b/src/libstddjb/uint640_scan.c
index 45c8e20..28ae049 100644
--- a/src/libstddjb/uint640_scan.c
+++ b/src/libstddjb/uint640_scan.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/uint64.h>
#include "fmtscan-internal.h"
+#include <skalibs/uint64.h>
SCANB0(64)
diff --git a/src/libstddjb/uint64_fmt.c b/src/libstddjb/uint64_fmt.c
index cbe3382..91c8178 100644
--- a/src/libstddjb/uint64_fmt.c
+++ b/src/libstddjb/uint64_fmt.c
@@ -1,19 +1,6 @@
/* ISC license. */
+#include "fmtscan-internal.h"
#include <skalibs/uint64.h>
-#include <skalibs/fmtscan.h>
-unsigned int uint64_fmt_base (char *s, uint64 x, unsigned char base)
-{
- register unsigned int len = 1 ;
- {
- register uint64 q = x ;
- while (q >= base) { len++ ; q /= base ; }
- }
- if (s)
- {
- s += len ;
- do { *--s = fmtscan_asc(x % base) ; x /= base ; } while (x) ;
- }
- return len ;
-}
+FMTB(64)
diff --git a/src/libstddjb/uint64_fmtlist.c b/src/libstddjb/uint64_fmtlist.c
index 7d9b321..5aa5e49 100644
--- a/src/libstddjb/uint64_fmtlist.c
+++ b/src/libstddjb/uint64_fmtlist.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/uint64.h>
#include "fmtscan-internal.h"
+#include <skalibs/uint64.h>
FMTL(64)
diff --git a/src/libstddjb/uint64_pack.c b/src/libstddjb/uint64_pack.c
index 23c8e19..5559a90 100644
--- a/src/libstddjb/uint64_pack.c
+++ b/src/libstddjb/uint64_pack.c
@@ -3,7 +3,7 @@
#include <skalibs/uint64.h>
#include <skalibs/bytestr.h>
-void uint64_pack (char *s, uint64 u)
+void uint64_pack (char *s, uint64_t u)
{
((unsigned char *)s)[0] = T8(u) ; u >>= 8 ;
((unsigned char *)s)[1] = T8(u) ; u >>= 8 ;
diff --git a/src/libstddjb/uint64_pack_big.c b/src/libstddjb/uint64_pack_big.c
index 17d0206..381f105 100644
--- a/src/libstddjb/uint64_pack_big.c
+++ b/src/libstddjb/uint64_pack_big.c
@@ -3,7 +3,7 @@
#include <skalibs/uint64.h>
#include <skalibs/bytestr.h>
-void uint64_pack_big (char *s, uint64 u)
+void uint64_pack_big (char *s, uint64_t u)
{
((unsigned char *)s)[7] = T8(u) ; u >>= 8 ;
((unsigned char *)s)[6] = T8(u) ; u >>= 8 ;
diff --git a/src/libstddjb/uint64_reverse.c b/src/libstddjb/uint64_reverse.c
index f8730fe..29e81d1 100644
--- a/src/libstddjb/uint64_reverse.c
+++ b/src/libstddjb/uint64_reverse.c
@@ -1,8 +1,9 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/uint64.h>
-void uint64_reverse (char *s, unsigned int n)
+void uint64_reverse (char *s, size_t n)
{
while (n--)
{
diff --git a/src/libstddjb/uint64_scan.c b/src/libstddjb/uint64_scan.c
index 530e84c..33744b1 100644
--- a/src/libstddjb/uint64_scan.c
+++ b/src/libstddjb/uint64_scan.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/uint64.h>
#include "fmtscan-internal.h"
+#include <skalibs/uint64.h>
SCANB(64)
diff --git a/src/libstddjb/uint64_scanlist.c b/src/libstddjb/uint64_scanlist.c
index 5ffeaa7..f288bcc 100644
--- a/src/libstddjb/uint64_scanlist.c
+++ b/src/libstddjb/uint64_scanlist.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/uint64.h>
#include "fmtscan-internal.h"
+#include <skalibs/uint64.h>
SCANL(64)
diff --git a/src/libstddjb/uint64_unpack.c b/src/libstddjb/uint64_unpack.c
index e0561d9..452d3ea 100644
--- a/src/libstddjb/uint64_unpack.c
+++ b/src/libstddjb/uint64_unpack.c
@@ -3,9 +3,9 @@
#include <skalibs/uint64.h>
#include <skalibs/bytestr.h>
-void uint64_unpack (char const *s, uint64 *u)
+void uint64_unpack (char const *s, uint64_t *u)
{
- uint64 r = T8((unsigned char)s[7]) ; r <<= 8 ;
+ uint64_t r = T8((unsigned char)s[7]) ; r <<= 8 ;
r += T8((unsigned char)s[6]) ; r <<= 8 ;
r += T8((unsigned char)s[5]) ; r <<= 8 ;
r += T8((unsigned char)s[4]) ; r <<= 8 ;
diff --git a/src/libstddjb/uint64_unpack_big.c b/src/libstddjb/uint64_unpack_big.c
index ebb419b..3554dcc 100644
--- a/src/libstddjb/uint64_unpack_big.c
+++ b/src/libstddjb/uint64_unpack_big.c
@@ -3,9 +3,9 @@
#include <skalibs/uint64.h>
#include <skalibs/bytestr.h>
-void uint64_unpack_big (char const *s, uint64 *u)
+void uint64_unpack_big (char const *s, uint64_t *u)
{
- uint64 r = T8((unsigned char)s[0]) ; r <<= 8 ;
+ uint64_t r = T8((unsigned char)s[0]) ; r <<= 8 ;
r += T8((unsigned char)s[1]) ; r <<= 8 ;
r += T8((unsigned char)s[2]) ; r <<= 8 ;
r += T8((unsigned char)s[3]) ; r <<= 8 ;
diff --git a/src/sysdeps/output-types.c b/src/sysdeps/output-types.c
new file mode 100644
index 0000000..bc3447a
--- /dev/null
+++ b/src/sysdeps/output-types.c
@@ -0,0 +1,22 @@
+#include <sys/types.h>
+#include <stdio.h>
+
+#define p(type) printf("sizeof" #type ": %u\nsigned" #type ": %s\n", \
+ (unsigned int)sizeof(type##_t), \
+ (type##_t)-1 < 0 ? "yes" : "no") ;
+
+#define q(abbr, type) printf("sizeof" #abbr ": %u\n", (unsigned int)sizeof(type)) ;
+
+int main (void)
+{
+ q(ushort, unsigned short) ;
+ q(uint, unsigned int) ;
+ q(ulong, unsigned long) ;
+ p(uid) ;
+ p(gid) ;
+ p(pid) ;
+ p(time) ;
+ p(dev) ;
+ p(ino) ;
+ return 0 ;
+}