summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-02-21 12:05:07 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-02-21 12:05:07 +0000
commit49d8fa1058aaf23c29e074b2314492ae40d2f557 (patch)
tree393f884d5a99f984e992a0f35f1b02ac43536217 /src
parentfdffefb8032922ce7ffe4c00816072a8ff2148fc (diff)
downloadskalibs-49d8fa1058aaf23c29e074b2314492ae40d2f557.tar.xz
Types change: big pass on libstddjb and libunixonacid
libdatastruct still missing, library still not functional
Diffstat (limited to 'src')
-rw-r--r--src/headers/error-header2
-rw-r--r--src/include/skalibs/djbunix.h8
-rw-r--r--src/include/skalibs/env.h11
-rw-r--r--src/include/skalibs/envalloc.h5
-rw-r--r--src/include/skalibs/iobuffer.h18
-rw-r--r--src/include/skalibs/mininetstring.h7
-rw-r--r--src/include/skalibs/netstring.h3
-rw-r--r--src/include/skalibs/randomegd.h10
-rw-r--r--src/include/skalibs/rc4.h2
-rw-r--r--src/include/skalibs/sha512.h4
-rw-r--r--src/include/skalibs/socket.h46
-rw-r--r--src/include/skalibs/stralloc.h1
-rw-r--r--src/include/skalibs/tai.h34
-rw-r--r--src/include/skalibs/webipc.h12
-rw-r--r--src/libbiguint/bu_addc.c10
-rw-r--r--src/libbiguint/bu_cmp.c2
-rw-r--r--src/libbiguint/bu_copy.c2
-rw-r--r--src/libbiguint/bu_copy_internal.c2
-rw-r--r--src/libbiguint/bu_div.c2
-rw-r--r--src/libbiguint/bu_divmod_internal.c8
-rw-r--r--src/libbiguint/bu_fmt.c7
-rw-r--r--src/libbiguint/bu_gcd.c6
-rw-r--r--src/libbiguint/bu_len.c2
-rw-r--r--src/libbiguint/bu_mul.c8
-rw-r--r--src/libbiguint/bu_pack.c2
-rw-r--r--src/libbiguint/bu_pack_big.c2
-rw-r--r--src/libbiguint/bu_scan.c2
-rw-r--r--src/libbiguint/bu_scan_internal.c7
-rw-r--r--src/libbiguint/bu_slbc.c6
-rw-r--r--src/libbiguint/bu_srbc.c4
-rw-r--r--src/libbiguint/bu_subc.c10
-rw-r--r--src/libbiguint/bu_unpack.c2
-rw-r--r--src/libbiguint/bu_unpack_big.c2
-rw-r--r--src/libbiguint/bu_zero.c2
-rw-r--r--src/librandom/random_name.c1
-rw-r--r--src/librandom/random_string.c2
-rw-r--r--src/librandom/random_uint32.c2
-rw-r--r--src/librandom/random_unsort.c10
-rw-r--r--src/librandom/surf.c11
-rw-r--r--src/librandom/surf_init.c2
-rw-r--r--src/libstdcrypto/md5_final.c4
-rw-r--r--src/libstdcrypto/md5_transform.c2
-rw-r--r--src/libstdcrypto/md5_update.c2
-rw-r--r--src/libstdcrypto/rc4.c4
-rw-r--r--src/libstdcrypto/rc4_init.c4
-rw-r--r--src/libstdcrypto/sha1_feed.c5
-rw-r--r--src/libstdcrypto/sha1_final.c2
-rw-r--r--src/libstdcrypto/sha1_init.c4
-rw-r--r--src/libstdcrypto/sha1_transform.c6
-rw-r--r--src/libstdcrypto/sha1_update.c2
-rw-r--r--src/libstdcrypto/sha256_feed.c4
-rw-r--r--src/libstdcrypto/sha256_final.c4
-rw-r--r--src/libstdcrypto/sha256_transform.c2
-rw-r--r--src/libstdcrypto/sha256_update.c2
-rw-r--r--src/libstdcrypto/sha512_final.c4
-rw-r--r--src/libstdcrypto/sha512_transform.c12
-rw-r--r--src/libstdcrypto/sha512_update.c9
-rw-r--r--src/libstddjb/allreadv.c1
-rw-r--r--src/libstddjb/allreadwritev.c1
-rw-r--r--src/libstddjb/allwritev.c1
-rw-r--r--src/libstddjb/bitarray_firstclear_skip.c6
-rw-r--r--src/libstddjb/bitarray_firstset_skip.c6
-rw-r--r--src/libstddjb/buffer_fill.c1
-rw-r--r--src/libstddjb/buffer_flush.c1
-rw-r--r--src/libstddjb/buffer_flush1read.c1
-rw-r--r--src/libstddjb/buffer_getv.c1
-rw-r--r--src/libstddjb/buffer_getvall.c1
-rw-r--r--src/libstddjb/buffer_getvallnf.c1
-rw-r--r--src/libstddjb/buffer_putv.c1
-rw-r--r--src/libstddjb/buffer_putvall.c1
-rw-r--r--src/libstddjb/buffer_putvallnf.c1
-rw-r--r--src/libstddjb/buffer_putvflush.c1
-rw-r--r--src/libstddjb/case_lowerb.c2
-rw-r--r--src/libstddjb/case_lowers.c4
-rw-r--r--src/libstddjb/case_startb.c6
-rw-r--r--src/libstddjb/case_str.c4
-rw-r--r--src/libstddjb/case_upperb.c1
-rw-r--r--src/libstddjb/case_uppers.c4
-rw-r--r--src/libstddjb/cbuffer_get.c1
-rw-r--r--src/libstddjb/cbuffer_getv.c1
-rw-r--r--src/libstddjb/cbuffer_put.c1
-rw-r--r--src/libstddjb/cbuffer_putv.c1
-rw-r--r--src/libstddjb/cbuffer_wpeek.c1
-rw-r--r--src/libstddjb/cdb_findnext.c13
-rw-r--r--src/libstddjb/cdb_hash.c8
-rw-r--r--src/libstddjb/cdb_init_map.c7
-rw-r--r--src/libstddjb/cdb_make.c34
-rw-r--r--src/libstddjb/cdb_mapfile.c2
-rw-r--r--src/libstddjb/cdb_nextkey.c5
-rw-r--r--src/libstddjb/cdb_read.c11
-rw-r--r--src/libstddjb/cdb_successor.c5
-rw-r--r--src/libstddjb/dir_close.c2
-rw-r--r--src/libstddjb/djbtime-internal.h6
-rw-r--r--src/libstddjb/env_addmodif.c3
-rw-r--r--src/libstddjb/env_get2.c7
-rw-r--r--src/libstddjb/env_len.c5
-rw-r--r--src/libstddjb/env_make.c6
-rw-r--r--src/libstddjb/env_merge.c17
-rw-r--r--src/libstddjb/env_string.c7
-rw-r--r--src/libstddjb/envalloc_make.c3
-rw-r--r--src/libstddjb/envalloc_merge.c5
-rw-r--r--src/libstddjb/envalloc_uniq.c15
-rw-r--r--src/libstddjb/error_temp.c2
-rw-r--r--src/libstddjb/fd_cat.c2
-rw-r--r--src/libstddjb/fd_catn.c2
-rw-r--r--src/libstddjb/fd_chdir.c2
-rw-r--r--src/libstddjb/fd_chmod.c2
-rw-r--r--src/libstddjb/fd_chown.c2
-rw-r--r--src/libstddjb/fd_copy.c2
-rw-r--r--src/libstddjb/fd_ensure_open.c2
-rw-r--r--src/libstddjb/fd_move.c2
-rw-r--r--src/libstddjb/fd_move2.c6
-rw-r--r--src/libstddjb/fd_readv.c1
-rw-r--r--src/libstddjb/fd_recv.c4
-rw-r--r--src/libstddjb/fd_send.c4
-rw-r--r--src/libstddjb/fd_sync.c2
-rw-r--r--src/libstddjb/fd_writev.c3
-rw-r--r--src/libstddjb/fmtscan-internal.h32
-rw-r--r--src/libstddjb/fmtscan_num.c2
-rw-r--r--src/libstddjb/genalloc_deepfree.c2
-rw-r--r--src/libstddjb/genwrite_flush_bufalloc.c3
-rw-r--r--src/libstddjb/genwrite_flush_buffer.c3
-rw-r--r--src/libstddjb/genwrite_put_bufalloc.c3
-rw-r--r--src/libstddjb/genwrite_put_buffer.c3
-rw-r--r--src/libstddjb/genwrite_put_stralloc.c3
-rw-r--r--src/libstddjb/getlnmax.c3
-rw-r--r--src/libstddjb/getlnmaxsep.c1
-rw-r--r--src/libstddjb/getpeereid.c2
-rw-r--r--src/libstddjb/hiercopy.c2
-rw-r--r--src/libstddjb/hiercopy_tmp.c3
-rw-r--r--src/libstddjb/iobuffer_fill.c5
-rw-r--r--src/libstddjb/iobuffer_kfromu.c1
-rw-r--r--src/libstddjb/iobuffer_ufromk.c3
-rw-r--r--src/libstddjb/iobufferk_fill.c24
-rw-r--r--src/libstddjb/iobufferk_flush.c16
-rw-r--r--src/libstddjb/iobufferk_init.c6
-rw-r--r--src/libstddjb/iobufferk_isworking.c3
-rw-r--r--src/libstddjb/iobufferk_nosys.c10
-rw-r--r--src/libstddjb/iobufferu_fill.c4
-rw-r--r--src/libstddjb/iobufferu_flush.c2
-rw-r--r--src/libstddjb/iopause_poll.c2
-rw-r--r--src/libstddjb/iopause_select.c4
-rw-r--r--src/libstddjb/iopause_stamp.c4
-rw-r--r--src/libstddjb/ip46_scanlist.c9
-rw-r--r--src/libstddjb/ip4_scan.c4
-rw-r--r--src/libstddjb/ip4_scanlist.c7
-rw-r--r--src/libstddjb/ip4_scanlist_u32.c8
-rw-r--r--src/libstddjb/ip6_scan.c2
-rw-r--r--src/libstddjb/ip6_scanlist.c9
-rw-r--r--src/libstddjb/ipc_accept.c11
-rw-r--r--src/libstddjb/ipc_bind.c8
-rw-r--r--src/libstddjb/ipc_connect.c8
-rw-r--r--src/libstddjb/ipc_connected.c2
-rw-r--r--src/libstddjb/ipc_eid.c15
-rw-r--r--src/libstddjb/ipc_local.c7
-rw-r--r--src/libstddjb/ipc_recv.c12
-rw-r--r--src/libstddjb/ipc_send.c10
-rw-r--r--src/libstddjb/ipc_timed_connect.c2
-rw-r--r--src/libstddjb/leapsecs_add.c6
-rw-r--r--src/libstddjb/leapsecs_sub.c10
-rw-r--r--src/libstddjb/leapsecs_table.c4
-rw-r--r--src/libstddjb/localtm_from_ltm64.c3
-rw-r--r--src/libstddjb/localtm_from_sysclock.c3
-rw-r--r--src/libstddjb/localtm_from_tai.c3
-rw-r--r--src/libstddjb/localtm_from_utc.c3
-rw-r--r--src/libstddjb/localtm_scan.c2
-rw-r--r--src/libstddjb/localtmn_from_sysclock.c1
-rw-r--r--src/libstddjb/localtmn_from_tain.c1
-rw-r--r--src/libstddjb/localtmn_scan.c2
-rw-r--r--src/libstddjb/lock_ex.c7
-rw-r--r--src/libstddjb/lock_exnb.c7
-rw-r--r--src/libstddjb/lock_sh.c11
-rw-r--r--src/libstddjb/lock_shnb.c11
-rw-r--r--src/libstddjb/lock_un.c11
-rw-r--r--src/libstddjb/ltm64_from_localtm.c5
-rw-r--r--src/libstddjb/ltm64_from_sysclock.c6
-rw-r--r--src/libstddjb/ltm64_from_tai.c2
-rw-r--r--src/libstddjb/ltm64_from_utc.c2
-rw-r--r--src/libstddjb/mininetstring_read.c13
-rw-r--r--src/libstddjb/mininetstring_write.c4
-rw-r--r--src/libstddjb/netstring_append.c7
-rw-r--r--src/libstddjb/netstring_appendv.c8
-rw-r--r--src/libstddjb/netstring_decode.c4
-rw-r--r--src/libstddjb/netstring_encode.c2
-rw-r--r--src/libstddjb/netstring_put.c6
-rw-r--r--src/libstddjb/ntp_from_tain.c4
-rw-r--r--src/libstddjb/open2.c5
-rw-r--r--src/libstddjb/open3.c3
-rw-r--r--src/libstddjb/open_readb.c6
-rw-r--r--src/libstddjb/pathexec0.c2
-rw-r--r--src/libstddjb/pipe_internal.c7
-rw-r--r--src/libstddjb/prot_readgroups.c8
-rw-r--r--src/libstddjb/realpath.c11
-rw-r--r--src/libstddjb/realpath_tmp.c26
-rw-r--r--src/libstddjb/sabasename.c2
-rw-r--r--src/libstddjb/sadirname.c2
-rw-r--r--src/libstddjb/sagetcwd.c6
-rw-r--r--src/libstddjb/sagethostname.c6
-rw-r--r--src/libstddjb/sareadlink.c6
-rw-r--r--src/libstddjb/sauniquename.c6
-rw-r--r--src/libstddjb/seek_cur.c10
-rw-r--r--src/libstddjb/seek_set.c10
-rw-r--r--src/libstddjb/selfpipe_finish.c2
-rw-r--r--src/libstddjb/selfpipe_read.c5
-rw-r--r--src/libstddjb/selfpipe_trapset.c2
-rw-r--r--src/libstddjb/selfpipe_untrap.c4
-rw-r--r--src/libstddjb/sig_number.c6
-rw-r--r--src/libstddjb/sig_restoreto.c4
-rw-r--r--src/libstddjb/siovec_bytechr.c1
-rw-r--r--src/libstddjb/siovec_bytein.c1
-rw-r--r--src/libstddjb/siovec_deal.c1
-rw-r--r--src/libstddjb/siovec_gather.c1
-rw-r--r--src/libstddjb/siovec_len.c1
-rw-r--r--src/libstddjb/siovec_scatter.c1
-rw-r--r--src/libstddjb/siovec_seek.c3
-rw-r--r--src/libstddjb/siovec_trunc.c1
-rw-r--r--src/libstddjb/skagetln_nofill.c1
-rw-r--r--src/libstddjb/skagetlnsep.c1
-rw-r--r--src/libstddjb/skalibs_tzisright.c1
-rw-r--r--src/libstddjb/skasigaction.c2
-rw-r--r--src/libstddjb/slurp.c14
-rw-r--r--src/libstddjb/socket_accept4.c11
-rw-r--r--src/libstddjb/socket_accept4_u32.c10
-rw-r--r--src/libstddjb/socket_accept6.c13
-rw-r--r--src/libstddjb/socket_bind4.c9
-rw-r--r--src/libstddjb/socket_bind4r.c6
-rw-r--r--src/libstddjb/socket_bind6.c11
-rw-r--r--src/libstddjb/socket_bind6r.c6
-rw-r--r--src/libstddjb/socket_conn4.c11
-rw-r--r--src/libstddjb/socket_conn4_u32.c4
-rw-r--r--src/libstddjb/socket_conn6.c13
-rw-r--r--src/libstddjb/socket_connected.c2
-rw-r--r--src/libstddjb/socket_deadlineconnstamp4.c4
-rw-r--r--src/libstddjb/socket_deadlineconnstamp46.c4
-rw-r--r--src/libstddjb/socket_deadlineconnstamp4_u32.c4
-rw-r--r--src/libstddjb/socket_deadlineconnstamp6.c4
-rw-r--r--src/libstddjb/socket_internal.c2
-rw-r--r--src/libstddjb/socket_ioloop.c7
-rw-r--r--src/libstddjb/socket_ioloop_send4.c4
-rw-r--r--src/libstddjb/socket_ioloop_send6.c4
-rw-r--r--src/libstddjb/socket_local4.c8
-rw-r--r--src/libstddjb/socket_local46.c13
-rw-r--r--src/libstddjb/socket_local6.c10
-rw-r--r--src/libstddjb/socket_recv4.c9
-rw-r--r--src/libstddjb/socket_recv6.c11
-rw-r--r--src/libstddjb/socket_remote4.c8
-rw-r--r--src/libstddjb/socket_remote46.c13
-rw-r--r--src/libstddjb/socket_remote6.c10
-rw-r--r--src/libstddjb/socket_send4.c11
-rw-r--r--src/libstddjb/socket_send6.c13
-rw-r--r--src/libstddjb/socket_tcp6.c2
-rw-r--r--src/libstddjb/socket_timeoutconn.c4
-rw-r--r--src/libstddjb/socket_tryr.c2
-rw-r--r--src/libstddjb/socket_udp6.c2
-rw-r--r--src/libstddjb/socket_waitconn.c2
-rw-r--r--src/libstddjb/socketpair_internal.c2
-rw-r--r--src/libstddjb/str_chr.c1
-rw-r--r--src/libstddjb/str_rchr.c5
-rw-r--r--src/libstddjb/str_start.c13
-rw-r--r--src/libstddjb/str_strn.c5
-rw-r--r--src/libstddjb/stralloc_catb.c1
-rw-r--r--src/libstddjb/stralloc_catv.c1
-rw-r--r--src/libstddjb/stralloc_copyb.c1
-rw-r--r--src/libstddjb/stralloc_insertb.c2
-rw-r--r--src/libstddjb/stralloc_ready_tuned.c4
-rw-r--r--src/libstddjb/stralloc_reverse.c4
-rw-r--r--src/libstddjb/stralloc_reverse_blocks.c5
-rw-r--r--src/libstddjb/strerr_sys.c4
-rw-r--r--src/libstddjb/string_format.c1
-rw-r--r--src/libstddjb/string_quote.c2
-rw-r--r--src/libstddjb/string_quote_nodelim.c2
-rw-r--r--src/libstddjb/string_quote_nodelim_mustquote.c3
-rw-r--r--src/libstddjb/string_unquote.c1
-rw-r--r--src/libstddjb/strn_fmt.c4
-rw-r--r--src/libstddjb/sysclock_from_localtm.c5
-rw-r--r--src/libstddjb/sysclock_from_ltm64.c4
-rw-r--r--src/libstddjb/sysclock_from_tai.c5
-rw-r--r--src/libstddjb/sysclock_from_utc.c4
-rw-r--r--src/libstddjb/tai_from_localtm.c3
-rw-r--r--src/libstddjb/tai_from_ltm64.c2
-rw-r--r--src/libstddjb/tai_from_sysclock.c5
-rw-r--r--src/libstddjb/tai_from_utc.c2
-rw-r--r--src/libstddjb/tai_now.c2
-rw-r--r--src/libstddjb/tai_u64.c4
-rw-r--r--src/libstddjb/tain_addsec.c4
-rw-r--r--src/libstddjb/tain_fmt.c3
-rw-r--r--src/libstddjb/tain_from_ntp.c4
-rw-r--r--src/libstddjb/tain_scan.c5
-rw-r--r--src/libstddjb/tain_to_millisecs.c4
-rw-r--r--src/libstddjb/time_from_tai.c7
-rw-r--r--src/libstddjb/time_from_tai_relative.c4
-rw-r--r--src/libstddjb/time_sysclock_from_tai.c6
-rw-r--r--src/libstddjb/timestamp_fmt.c3
-rw-r--r--src/libstddjb/timestamp_scan.c5
-rw-r--r--src/libstddjb/ucharn_findlen.c2
-rw-r--r--src/libstddjb/ucharn_fmt.c2
-rw-r--r--src/libstddjb/ucharn_fmt_little.c2
-rw-r--r--src/libstddjb/ucharn_scan.c2
-rw-r--r--src/libstddjb/ucharn_scan_little.c2
-rw-r--r--src/libstddjb/ucspi_get.c10
-rw-r--r--src/libstddjb/unsanitize_read.c2
-rw-r--r--src/libstddjb/utc_from_localtm.c3
-rw-r--r--src/libstddjb/utc_from_ltm64.c3
-rw-r--r--src/libstddjb/utc_from_sysclock.c4
-rw-r--r--src/libstddjb/vbaprintf.c7
-rw-r--r--src/libstddjb/vbprintf.c7
-rw-r--r--src/libstddjb/wait_nointr.c1
-rw-r--r--src/libstddjb/wait_pid_nohang.c6
-rw-r--r--src/libstddjb/wait_pids_nohang.c6
-rw-r--r--src/libstddjb/wait_reap.c2
-rw-r--r--src/libstddjb/waitn.c6
-rw-r--r--src/libstddjb/waitn_reap.c6
-rw-r--r--src/libstddjb/waitpid_nointr.c6
-rw-r--r--src/libunixonacid/openwritevnclose_at.c1
-rw-r--r--src/sysdeps/tryipv6.c3
-rw-r--r--src/sysdeps/trynbwaitall.c2
-rw-r--r--src/sysdeps/tryppoll.c3
-rw-r--r--src/sysdeps/trysplice.c2
318 files changed, 768 insertions, 888 deletions
diff --git a/src/headers/error-header b/src/headers/error-header
index af294e2..435a64b 100644
--- a/src/headers/error-header
+++ b/src/headers/error-header
@@ -4,9 +4,7 @@
#define ERROR_H
#include <errno.h>
-#include <string.h>
#include <skalibs/gccattributes.h>
-#define error_str(e) ((char const *)strerror(e))
extern int error_temp (int) gccattr_const ;
#define error_isagain(e) (((e) == EAGAIN) || ((e) == EWOULDBLOCK))
diff --git a/src/include/skalibs/djbunix.h b/src/include/skalibs/djbunix.h
index 03fd092..af76ec4 100644
--- a/src/include/skalibs/djbunix.h
+++ b/src/include/skalibs/djbunix.h
@@ -69,12 +69,6 @@ extern int prot_readgroups (char const *, gid_t *, unsigned int) ;
extern int prot_grps (char const *) ;
extern int prot_setuidgid (char const *) ;
-extern long seek_cur (int) ;
-extern int seek_set (int, off_t) ;
-extern int seek_end (int) ;
-extern int seek_trunc (int, off_t) ;
-#define seek_begin(fd) (seek_set((fd), 0))
-
extern pid_t wait_nointr (int *) ;
extern pid_t waitpid_nointr (pid_t, int *, int) ;
#define wait_pid(pid, wstat) waitpid_nointr(pid, (wstat), 0)
@@ -92,8 +86,6 @@ extern pid_t doublefork (void) ;
extern int fd_chdir (int) ;
#define absolutepath(sa, s) sarealpath(sa, s)
-/* extern char *realpath (char const *, char *) ; */
-extern char *realpath_tmp (char const *, char *, stralloc *) ;
extern int sarealpath (stralloc *, char const *) ;
extern int sarealpath_tmp (stralloc *, char const *, stralloc *) ;
extern int sabasename (stralloc *, char const *, size_t) ;
diff --git a/src/include/skalibs/env.h b/src/include/skalibs/env.h
index ccb3aac..f0c2dbc 100644
--- a/src/include/skalibs/env.h
+++ b/src/include/skalibs/env.h
@@ -3,23 +3,24 @@
#ifndef ENV_H
#define ENV_H
+#include <sys/types.h>
#include <skalibs/gccattributes.h>
#include <skalibs/stralloc.h>
-extern unsigned int env_len (char const *const *) gccattr_pure ;
+extern size_t env_len (char const *const *) gccattr_pure ;
extern char const *env_get (char const *) gccattr_pure ;
extern char const *env_get2 (char const *const *, char const *) gccattr_pure ;
extern char const *ucspi_get (char const *) gccattr_pure ;
extern int env_addmodif (stralloc *, char const *, char const *) ;
-extern int env_make (char const **, unsigned int, char const *, unsigned int) ;
-extern unsigned int env_merge (char const **, unsigned int, char const *const *, unsigned int, char const *, unsigned int) ;
-extern int env_string (stralloc *, char const *const *, unsigned int) ;
+extern int env_make (char const **, size_t, char const *, size_t) ;
+extern size_t env_merge (char const **, size_t, char const *const *, size_t, char const *, size_t) ;
+extern int env_string (stralloc *, char const *const *, size_t) ;
#define SKALIBS_ENVDIR_VERBATIM 0x01
#define SKALIBS_ENVDIR_NOCHOMP 0x02
extern int envdir_internal (char const *, stralloc *, unsigned int, char) ;
#define envdir(path, sa) envdir_internal(path, (sa), 0, '\n')
-#define envdir_leaveblanks(path, sa) envdir_internal(path, (sa), SKALIBS_ENVDIR_NOCHOMP, '\n')
+#define envdir_chomp(path, sa) envdir_internal(path, (sa), SKALIBS_ENVDIR_NOCHOMP, '\n')
#define envdir_verbatim_chomp(path, sa) envdir_internal(path, (sa), SKALIBS_ENVDIR_VERBATIM, '\n')
#define envdir_verbatim(path, sa) envdir_internal(path, (sa), SKALIBS_ENVDIR_VERBATIM|SKALIBS_ENVDIR_NOCHOMP, '\n')
diff --git a/src/include/skalibs/envalloc.h b/src/include/skalibs/envalloc.h
index 1ebcd6b..aba6dca 100644
--- a/src/include/skalibs/envalloc.h
+++ b/src/include/skalibs/envalloc.h
@@ -3,13 +3,14 @@
#ifndef ENVALLOC_H
#define ENVALLOC_H
+#include <sys/types.h>
#include <skalibs/genalloc.h>
#define ENVALLOC_ZERO GENALLOC_ZERO
-extern int envalloc_make (genalloc *, unsigned int, char const *, unsigned int) ;
+extern int envalloc_make (genalloc *, size_t, char const *, size_t) ;
extern int envalloc_uniq (genalloc *, char) ;
-extern int envalloc_merge (genalloc *, char const *const *, unsigned int, char const *, unsigned int) ;
+extern int envalloc_merge (genalloc *, char const *const *, size_t, char const *, size_t) ;
extern int envalloc_0 (genalloc *) ;
#endif
diff --git a/src/include/skalibs/iobuffer.h b/src/include/skalibs/iobuffer.h
index b6abd2d..84a8b6d 100644
--- a/src/include/skalibs/iobuffer.h
+++ b/src/include/skalibs/iobuffer.h
@@ -7,6 +7,7 @@
/* iobufferu */
+#include <sys/types.h>
#include <skalibs/buffer.h>
#include <skalibs/djbunix.h>
@@ -20,7 +21,7 @@ struct iobufferu_s
} ;
extern int iobufferu_init (iobufferu *, int, int) ;
-extern int iobufferu_fill (iobufferu *) ;
+extern ssize_t iobufferu_fill (iobufferu *) ;
extern int iobufferu_flush (iobufferu *) ;
extern void iobufferu_finish (iobufferu *) ;
@@ -50,17 +51,18 @@ struct iobufferk_s
unsigned int nb : 2 ;
} ;
-typedef int iobufferk_io_func_t (iobufferk *) ;
-typedef iobufferk_io_func_t *iobufferk_io_func_t_ref ;
+typedef int iobufferk_output_func_t (iobufferk *) ;
+typedef iobufferk_output_func_t *iobufferk_output_func_t_ref ;
+typedef ssize_t iobufferk_input_func_t (iobufferk *) ;
+typedef iobufferk_input_func_t *iobufferk_input_func_t_ref ;
typedef void iobufferk_finish_func_t (iobufferk *) ;
typedef iobufferk_finish_func_t *iobufferk_finish_func_t_ref ;
-extern iobufferk_io_func_t iobufferk_nosys ;
-extern iobufferk_io_func_t iobufferk_isworking ;
+extern iobufferk_output_func_t iobufferk_isworking ;
extern int iobufferk_init (iobufferk *, int, int) ;
-extern iobufferk_io_func_t_ref const iobufferk_fill_f[4] ;
-extern iobufferk_io_func_t_ref const iobufferk_flush_f[4] ;
+extern iobufferk_input_func_t_ref const iobufferk_fill_f[4] ;
+extern iobufferk_output_func_t_ref const iobufferk_flush_f[4] ;
extern iobufferk_finish_func_t_ref const iobufferk_finish_f[4] ;
#define iobufferk_fill(k) (*iobufferk_fill_f[(k)->type])(k)
@@ -99,7 +101,7 @@ extern int iobuffer_kfromu (iobufferk *, iobufferu *) ;
extern int iobuffer_salvage (iobuffer *) ;
extern int iobuffer_init (iobuffer *, int, int) ;
-extern int iobuffer_fill (iobuffer *) ;
+extern ssize_t iobuffer_fill (iobuffer *) ;
extern int iobuffer_flush (iobuffer *) ;
#define iobuffer_finish(b) ((b)->isk ? iobufferk_finish(&(b)->x.k) : iobufferu_finish(&(b)->x.u))
diff --git a/src/include/skalibs/mininetstring.h b/src/include/skalibs/mininetstring.h
index c275fb2..1997b18 100644
--- a/src/include/skalibs/mininetstring.h
+++ b/src/include/skalibs/mininetstring.h
@@ -3,11 +3,10 @@
#ifndef MININETSTRING_H
#define MININETSTRING_H
-#include <skalibs/uint16.h>
-#include <skalibs/uint32.h>
+#include <stdint.h>
#include <skalibs/stralloc.h>
-extern int mininetstring_read (int, stralloc *, uint32 *) ;
-extern int mininetstring_write (int, char const *, uint16, uint32 *) ;
+extern int mininetstring_read (int, stralloc *, uint32_t *) ;
+extern int mininetstring_write (int, char const *, uint16_t, uint32_t *) ;
#endif
diff --git a/src/include/skalibs/netstring.h b/src/include/skalibs/netstring.h
index 107e796..941011a 100644
--- a/src/include/skalibs/netstring.h
+++ b/src/include/skalibs/netstring.h
@@ -5,11 +5,12 @@
#include <sys/types.h>
#include <sys/uio.h>
+#include <string.h>
#include <skalibs/buffer.h>
#include <skalibs/stralloc.h>
extern int netstring_appendb (stralloc *, char const *, size_t) ;
-#define netstring_appends(sa, s) netstring_appendb((sa), (s), str_len(s))
+#define netstring_appends(sa, s) netstring_appendb((sa), (s), strlen(s))
#define netstring_append(to, from) netstring_appendb((to), (from)->s, (from)->len)
extern int netstring_appendv (stralloc *, struct iovec const *, unsigned int) ;
diff --git a/src/include/skalibs/randomegd.h b/src/include/skalibs/randomegd.h
deleted file mode 100644
index 28d4faa..0000000
--- a/src/include/skalibs/randomegd.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/* ISC license. */
-
-#ifndef RANDOMEGD_H
-#define RANDOMEGD_H
-
-extern int randomegd_open (char const *) ;
-extern unsigned int randomegd_readb (int, char *, unsigned int) ;
-extern unsigned int randomegd_readnb (int, char *, unsigned int) ;
-
-#endif
diff --git a/src/include/skalibs/rc4.h b/src/include/skalibs/rc4.h
index 44ce20b..c4fde53 100644
--- a/src/include/skalibs/rc4.h
+++ b/src/include/skalibs/rc4.h
@@ -3,6 +3,8 @@
#ifndef RC4_H
#define RC4_H
+#include <sys/types.h>
+
#define RC4_THROWAWAY 128
typedef struct RC4Schedule RC4Schedule, *RC4Schedule_ref ;
diff --git a/src/include/skalibs/sha512.h b/src/include/skalibs/sha512.h
index 9d098be..12ddbcb 100644
--- a/src/include/skalibs/sha512.h
+++ b/src/include/skalibs/sha512.h
@@ -9,8 +9,8 @@
typedef struct SHA512Schedule_s SHA512Schedule, *SHA512Schedule_ref ;
struct SHA512Schedule_s
{
- uint64 len ;
- uint64 h[8] ;
+ uint64_t len ;
+ uint64_t h[8] ;
unsigned char buf[128] ;
} ;
diff --git a/src/include/skalibs/socket.h b/src/include/skalibs/socket.h
index 91be2f5..11ad1db 100644
--- a/src/include/skalibs/socket.h
+++ b/src/include/skalibs/socket.h
@@ -3,14 +3,14 @@
#ifndef SOCKET_H
#define SOCKET_H
+#include <sys/types.h>
+#include <stdint.h>
#include <skalibs/gccattributes.h>
-#include <skalibs/uint16.h>
-#include <skalibs/uint32.h>
#include <skalibs/tai.h>
#include <skalibs/djbunix.h>
#include <skalibs/webipc.h>
-typedef int socket_io_func_t (int, char *, unsigned int, char *, uint16 *) ;
+typedef ssize_t socket_io_func_t (int, char *, size_t, char *, uint16_t *) ;
typedef socket_io_func_t *socket_io_func_t_ref ;
@@ -58,47 +58,47 @@ extern int socket_udp6_internal (unsigned int) ;
extern int socket_waitconn (int, tain_t const *, tain_t *) ;
#define socket_waitconn_g(fd, deadline) socket_waitconn(fd, (deadline), &STAMP)
-extern int socket_deadlineconnstamp4 (int, char const *, uint16, tain_t const *, tain_t *) ;
+extern int socket_deadlineconnstamp4 (int, char const *, uint16_t, tain_t const *, tain_t *) ;
#define socket_deadlineconnstamp(s, ip, port, deadline, stamp) socket_deadlineconnstamp4(s, ip, port, deadline, stamp)
#define socket_deadlineconnstamp4_g(fd, ip, port, deadline) socket_deadlineconnstamp4(fd, ip, port, (deadline), &STAMP)
-extern int socket_deadlineconnstamp4_u32 (int, uint32, uint16, tain_t const *, tain_t *) ;
+extern int socket_deadlineconnstamp4_u32 (int, uint32_t, uint16_t, tain_t const *, tain_t *) ;
#define socket_deadlineconnstamp4_u32_g(fd, ip, port, deadline) socket_deadlineconnstamp4_u32(fd, ip, port, (deadline), &STAMP)
-extern int socket_timeoutconn (int, char const *, uint16, unsigned int) ;
-extern int socket_connect4 (int, char const *, uint16) ;
-extern int socket_connect4_u32 (int, uint32, uint16) ;
+extern int socket_timeoutconn (int, char const *, uint16_t, unsigned int) ;
+extern int socket_connect4 (int, char const *, uint16_t) ;
+extern int socket_connect4_u32 (int, uint32_t, uint16_t) ;
extern int socket_connected (int) gccattr_const ;
-extern int socket_bind4 (int, char const *, uint16) ;
-extern int socket_bind4_reuse (int, char const *, uint16) ;
+extern int socket_bind4 (int, char const *, uint16_t) ;
+extern int socket_bind4_reuse (int, char const *, uint16_t) ;
#define socket_listen(fd, b) ipc_listen(fd, b)
-extern int socket_connect6 (int, char const *, uint16) ;
-extern int socket_deadlineconnstamp6 (int, char const *, uint16, tain_t const *, tain_t *) ;
+extern int socket_connect6 (int, char const *, uint16_t) ;
+extern int socket_deadlineconnstamp6 (int, char const *, uint16_t, tain_t const *, tain_t *) ;
#define socket_deadlineconnstamp6_g(fd, ip6, port, deadline) socket_deadlineconnstamp6(fd, ip6, port, (deadline), &STAMP)
-extern int socket_bind6 (int, char const *, uint16) ;
-extern int socket_bind6_reuse (int, char const *, uint16) ;
+extern int socket_bind6 (int, char const *, uint16_t) ;
+extern int socket_bind6_reuse (int, char const *, uint16_t) ;
#define socket_accept4(s, ip, port) socket_accept4_internal(s, ip, (port), 0)
#define socket_accept4_nb(s, ip, port) socket_accept4_internal(s, ip, (port), DJBUNIX_FLAG_NB)
#define socket_accept4_coe(s, ip, port) socket_accept4_internal(s, ip, (port), DJBUNIX_FLAG_COE)
#define socket_accept4_nbcoe(s, ip, port) socket_accept4_internal(s, ip, (port), DJBUNIX_FLAG_NB|DJBUNIX_FLAG_COE)
-extern int socket_accept4_internal (int, char *, uint16 *, unsigned int) ;
+extern int socket_accept4_internal (int, char *, uint16_t *, unsigned int) ;
extern socket_io_func_t socket_recv4 ;
-extern int socket_send4 (int, char const *, unsigned int, char const *, uint16) ;
+extern ssize_t socket_send4 (int, char const *, size_t, char const *, uint16_t) ;
extern socket_io_func_t socket_ioloop_send4 ;
-extern int socket_local4 (int, char *, uint16 *) ;
-extern int socket_remote4 (int, char *, uint16 *) ;
+extern int socket_local4 (int, char *, uint16_t *) ;
+extern int socket_remote4 (int, char *, uint16_t *) ;
#define socket_accept6(s, ip6, port) socket_accept6_internal(s, ip6, (port), 0)
#define socket_accept6_nb(s, ip6, port) socket_accept6_internal(s, ip6, (port), DJBUNIX_FLAG_NB)
#define socket_accept6_coe(s, ip6, port) socket_accept6_internal(s, ip6, (port), DJBUNIX_FLAG_COE)
#define socket_accept6_nbcoe(s, ip6, port) socket_accept6_internal(s, ip6, (port), DJBUNIX_FLAG_NB|DJBUNIX_FLAG_COE)
-extern int socket_accept6_internal (int, char *, uint16 *, unsigned int) ;
+extern int socket_accept6_internal (int, char *, uint16_t *, unsigned int) ;
extern socket_io_func_t socket_recv6 ;
-extern int socket_send6 (int, char const *, unsigned int, char const *, uint16) ;
+extern ssize_t socket_send6 (int, char const *, size_t, char const *, uint16_t) ;
extern socket_io_func_t socket_ioloop_send6 ;
-extern int socket_local6 (int, char *, uint16 *) ;
-extern int socket_remote6 (int, char *, uint16 *) ;
+extern int socket_local6 (int, char *, uint16_t *) ;
+extern int socket_remote6 (int, char *, uint16_t *) ;
extern int socket_ipoptionskill (int) ;
extern int socket_tcpnodelay (int) ;
@@ -107,7 +107,7 @@ extern void socket_tryreservein (int, unsigned int) ;
/* Timed send and recv operations (for dgram sockets) */
-extern int socket_ioloop (int, char *, unsigned int, char *, uint16 *, socket_io_func_t_ref, int, tain_t const *, tain_t *) ;
+extern ssize_t socket_ioloop (int, char *, size_t, char *, uint16_t *, socket_io_func_t_ref, int, tain_t const *, tain_t *) ;
#define socket_sendnb4(fd, buf, len, ip4, port, deadline, stamp) socket_ioloop(fd, buf, len, (char *)ip4, &(port), &socket_ioloop_send4, 1, deadline, stamp)
#define socket_sendnb4_g(fd, buf, len, ip4, port, deadline) socket_sendnb4(fd, buf, len, ip4, port, (deadline), &STAMP)
diff --git a/src/include/skalibs/stralloc.h b/src/include/skalibs/stralloc.h
index 2ec4c23..c94547f 100644
--- a/src/include/skalibs/stralloc.h
+++ b/src/include/skalibs/stralloc.h
@@ -3,7 +3,6 @@
#ifndef STRALLOC_H
#define STRALLOC_H
-#include <sys/types.h>
#include <string.h>
#include <sys/uio.h>
diff --git a/src/include/skalibs/tai.h b/src/include/skalibs/tai.h
index 64e81cf..6ff8be7 100644
--- a/src/include/skalibs/tai.h
+++ b/src/include/skalibs/tai.h
@@ -4,41 +4,41 @@
#define TAI_H
#include <sys/types.h>
+#include <stdint.h>
#include <time.h>
#include <sys/time.h>
#include <skalibs/gccattributes.h>
-#include <skalibs/uint32.h>
#include <skalibs/uint64.h>
typedef struct tai_s tai_t, *tai_t_ref ;
struct tai_s
{
- uint64 x ;
+ uint64_t x ;
} ;
#define TAI_ZERO { .x = 0 }
-#define TAI_MAGIC ((uint64)4611686018427387904ULL)
+#define TAI_MAGIC ((uint64_t)4611686018427387904ULL)
#define TAI_EPOCH { .x = TAI_MAGIC + 10UL }
-#define TAI_INFINITE_RELATIVE { .x = (uint64)1 << 60 }
-#define TAI_INFINITE { .x = TAI_MAGIC + ((uint64)1 << 61) }
+#define TAI_INFINITE_RELATIVE { .x = (uint64_t)1 << 60 }
+#define TAI_INFINITE { .x = TAI_MAGIC + ((uint64_t)1 << 61) }
#define tai_sec(t) ((t)->x)
-extern int tai_u64 (tai_t *, uint64) ;
+extern int tai_u64 (tai_t *, uint64_t) ;
#define tai_unix(t, u) tai_u64(t, (TAI_MAGIC + (u)))
-#define tai_uint(t, u) tai_u64(t, (uint64)(u))
+#define tai_uint(t, u) tai_u64(t, (uint64_t)(u))
extern int tai_now (tai_t *) ;
-#define tai_relative_from_time(t, u) ((t)->x = (uint64)(u), 1)
+#define tai_relative_from_time(t, u) ((t)->x = (uint64_t)(u), 1)
#define tai_from_time(t, u) tai_unix(t, u)
-#define tai_from_time_sysclock(t, u) tai_from_sysclock(t, (uint64)(u) + TAI_MAGIC)
+#define tai_from_time_sysclock(t, u) tai_from_sysclock(t, (uint64_t)(u) + TAI_MAGIC)
extern int time_from_tai_relative (time_t *, tai_t const *) ;
extern int time_from_tai (time_t *, tai_t const *) ;
extern int time_sysclock_from_tai(time_t *, tai_t const *) ;
-extern int tai_from_sysclock (tai_t *, uint64) ;
-extern int sysclock_from_tai (uint64 *, tai_t const *) ;
+extern int tai_from_sysclock (tai_t *, uint64_t) ;
+extern int sysclock_from_tai (uint64_t *, tai_t const *) ;
#define tai_approx(t) ((double)(tai_sec(t)))
@@ -56,7 +56,7 @@ typedef struct tain_s tain_t, *tain_t_ref ;
struct tain_s
{
tai_t sec ;
- uint32 nano ; /* 0..999999999U */
+ uint32_t nano ; /* 0..999999999U */
} ;
#define TAIN_ZERO { .sec = TAI_ZERO, .nano = 0 }
@@ -125,19 +125,19 @@ extern void tain_pack_little (char *, tain_t const *) ;
extern void tain_unpack_little (char const *, tain_t *) ;
#define TAIN_FMT 25
-extern unsigned int tain_fmt (char *, tain_t const *) ;
-extern unsigned int tain_scan (char const *, tain_t *) ;
+extern size_t tain_fmt (char *, tain_t const *) ;
+extern size_t tain_scan (char const *, tain_t *) ;
#define TAIN_FMTFRAC 19
-extern unsigned int tain_fmtfrac (char *, tain_t const *) ;
+extern size_t tain_fmtfrac (char *, tain_t const *) ;
#define tain_uint(a, u) tain_ulong(a, u)
extern int tain_ulong (tain_t *, unsigned long) ;
extern void tain_half (tain_t *, tain_t const *) ;
#define TIMESTAMP (1 + (TAIN_PACK << 1))
-extern unsigned int timestamp_fmt (char *, tain_t const *) ;
-extern unsigned int timestamp_scan (char const *, tain_t *) ;
+extern size_t timestamp_fmt (char *, tain_t const *) ;
+extern size_t timestamp_scan (char const *, tain_t *) ;
extern int timestamp_r (char *, tain_t *) ;
extern int timestamp (char *) ;
#define timestamp_g(s) timestamp_fmt((s), &STAMP)
diff --git a/src/include/skalibs/webipc.h b/src/include/skalibs/webipc.h
index 6b2c1fe..0ddd084 100644
--- a/src/include/skalibs/webipc.h
+++ b/src/include/skalibs/webipc.h
@@ -12,6 +12,8 @@
#define IPCPATH_MAX 107
+#include <sys/types.h>
+#include <skalibs/getpeereid.h>
#include <skalibs/tai.h>
#include <skalibs/djbunix.h>
@@ -44,17 +46,17 @@ extern int ipc_listen (int, int) ;
#define ipc_accept_nb(s, path, len, trunc) ipc_accept_internal(s, path, len, (trunc), DJBUNIX_FLAG_NB)
#define ipc_accept_coe(s, path, len, trunc) ipc_accept_internal(s, path, len, (trunc), DJBUNIX_FLAG_COE)
#define ipc_accept_nbcoe(s, path, len, trunc) ipc_accept_internal(s, path, len, (trunc), DJBUNIX_FLAG_NB|DJBUNIX_FLAG_COE)
-extern int ipc_accept_internal (int, char *, unsigned int, int *, unsigned int) ;
+extern int ipc_accept_internal (int, char *, size_t, int *, unsigned int) ;
-extern int ipc_eid (int, unsigned int *, unsigned int *) ;
-extern int ipc_local (int, char *, unsigned int, int *) ;
+#define ipc_eid getpeereid
+extern int ipc_local (int, char *, size_t, int *) ;
extern int ipc_connect (int, char const *) ;
extern int ipc_connected (int) ;
extern int ipc_timed_connect (int, char const *, tain_t const *, tain_t *) ;
#define ipc_timed_connect_g(fd, path, deadline) ipc_timed_connect(fd, path, (deadline), &STAMP)
-extern int ipc_send (int, char const *, unsigned int, char const *) ;
-extern int ipc_recv (int, char *, unsigned int, char *) ;
+extern ssize_t ipc_send (int, char const *, size_t, char const *) ;
+extern ssize_t ipc_recv (int, char *, size_t, char *) ;
#endif
diff --git a/src/libbiguint/bu_addc.c b/src/libbiguint/bu_addc.c
index 20a2740..1a7f164 100644
--- a/src/libbiguint/bu_addc.c
+++ b/src/libbiguint/bu_addc.c
@@ -9,14 +9,14 @@
#include <errno.h>
#include <skalibs/biguint.h>
-int bu_addc (uint32_t *c, unsigned int cn, uint32_t const *a, unsigned int an, uint32_t const *b, unsigned int bn, register int carry)
+int bu_addc (uint32_t *c, unsigned int cn, uint32_t const *a, unsigned int an, uint32_t const *b, unsigned int bn, int carry)
{
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
for (; i < cn ; i++)
{
- register uint32_t ai = (i < an) ? a[i] : 0 ;
- register uint32_t bi = (i < bn) ? b[i] : 0 ;
- register uint32_t ci = ai + bi + carry ;
+ uint32_t ai = (i < an) ? a[i] : 0 ;
+ uint32_t bi = (i < bn) ? b[i] : 0 ;
+ uint32_t ci = ai + bi + carry ;
carry = (carry || bi) && (ci < ai) ;
c[i] = ci ;
}
diff --git a/src/libbiguint/bu_cmp.c b/src/libbiguint/bu_cmp.c
index 033c61c..f0363b7 100644
--- a/src/libbiguint/bu_cmp.c
+++ b/src/libbiguint/bu_cmp.c
@@ -3,7 +3,7 @@
#include <stdint.h>
#include <skalibs/biguint.h>
-int bu_cmp (register uint32_t const *a, register unsigned int an, register uint32_t const *b, register unsigned int bn)
+int bu_cmp (uint32_t const *a, unsigned int an, uint32_t const *b, unsigned int bn)
{
an = bu_len(a, an) ;
bn = bu_len(b, bn) ;
diff --git a/src/libbiguint/bu_copy.c b/src/libbiguint/bu_copy.c
index b975577..2822569 100644
--- a/src/libbiguint/bu_copy.c
+++ b/src/libbiguint/bu_copy.c
@@ -11,7 +11,7 @@
int bu_copy (uint32_t *b, unsigned int bn, uint32_t const *a, unsigned int an)
{
- register unsigned int alen = bu_len(a, an) ;
+ unsigned int alen = bu_len(a, an) ;
if (bn < alen)
{
bu_copy_internal(b, a, bn) ;
diff --git a/src/libbiguint/bu_copy_internal.c b/src/libbiguint/bu_copy_internal.c
index a869ea2..41fe205 100644
--- a/src/libbiguint/bu_copy_internal.c
+++ b/src/libbiguint/bu_copy_internal.c
@@ -3,7 +3,7 @@
#include <stdint.h>
#include <skalibs/biguint.h>
-void bu_copy_internal (register uint32_t *b, register uint32_t const *a, register unsigned int n)
+void bu_copy_internal (uint32_t *b, uint32_t const *a, unsigned int n)
{
while (n--) b[n] = a[n] ;
}
diff --git a/src/libbiguint/bu_div.c b/src/libbiguint/bu_div.c
index 47c48f8..7f2a6c0 100644
--- a/src/libbiguint/bu_div.c
+++ b/src/libbiguint/bu_div.c
@@ -13,7 +13,7 @@ int bu_div (uint32_t const *a, unsigned int an, uint32_t const *b, unsigned int
{
uint32_t qq[alen] ;
uint32_t rr[alen] ;
- register int qh, rh ;
+ int qh, rh ;
bu_copy_internal(rr, a, alen) ;
bu_div_internal(rr, alen, b, blen, qq, alen) ;
qh = bu_copy(q, qn, qq, alen) ;
diff --git a/src/libbiguint/bu_divmod_internal.c b/src/libbiguint/bu_divmod_internal.c
index ad0f277..13e60b0 100644
--- a/src/libbiguint/bu_divmod_internal.c
+++ b/src/libbiguint/bu_divmod_internal.c
@@ -9,10 +9,10 @@
Original idea: see http://research.sun.com/techrep/2001/abstract-95.html
*/
-void bu_divmod_internal (register uint32_t *u, register uint32_t *a, register uint32_t const *m, unsigned int n)
+void bu_divmod_internal (uint32_t *u, uint32_t *a, uint32_t const *m, unsigned int n)
{
- uint32_t bb[n] ; register uint32_t *b = bb ;
- uint32_t vv[n] ; register uint32_t *v = vv ;
+ uint32_t bb[n] ; uint32_t *b = bb ;
+ uint32_t vv[n] ; uint32_t *v = vv ;
bu_copy_internal(b, m, n) ;
bu_zero(v, n) ;
@@ -28,7 +28,7 @@ void bu_divmod_internal (register uint32_t *u, register uint32_t *a, register ui
if ((a[0] == 1) && (bu_len(a, n) == 1)) break ;
if (bu_cmp(a, n, b, n) < 0)
{
- register uint32_t *t = a ; a = b ; b = t ;
+ uint32_t *t = a ; a = b ; b = t ;
t = u ; u = v ; v = t ;
}
bu_add(a, n, a, n, b, n) ;
diff --git a/src/libbiguint/bu_fmt.c b/src/libbiguint/bu_fmt.c
index 8e5dda1..4c3e7e7 100644
--- a/src/libbiguint/bu_fmt.c
+++ b/src/libbiguint/bu_fmt.c
@@ -1,9 +1,8 @@
/* ISC license. */
-#include <sys/types.h>
#include <stdint.h>
+#include <string.h>
#include <skalibs/uint32.h>
-#include <skalibs/bytestr.h>
#include <skalibs/biguint.h>
size_t bu_fmt (char *s, uint32_t const *x, unsigned int n)
@@ -13,8 +12,8 @@ size_t bu_fmt (char *s, uint32_t const *x, unsigned int n)
{
char fmt[8] ;
size_t i = uint32_xfmt(fmt, x[n]) ;
- byte_copy(s+len, 8-i, "00000000") ;
- byte_copy(s+len+8-i, i, fmt) ;
+ memcpy(s+len, "00000000", 8-i) ;
+ memcpy(s+len+8-i, fmt, i) ;
len += 8 ;
}
return len ;
diff --git a/src/libbiguint/bu_gcd.c b/src/libbiguint/bu_gcd.c
index 919c868..11c14e0 100644
--- a/src/libbiguint/bu_gcd.c
+++ b/src/libbiguint/bu_gcd.c
@@ -7,8 +7,8 @@ int bu_gcd (uint32_t *r, unsigned int rn, uint32_t const *a, unsigned int an, ui
{
if (bu_cmp(a, an, b, bn) < 0)
{
- register uint32_t const *t = a ;
- register unsigned int tn = an ;
+ uint32_t const *t = a ;
+ unsigned int tn = an ;
a = b ; an = bn ;
b = t ; bn = tn ;
}
@@ -23,7 +23,7 @@ int bu_gcd (uint32_t *r, unsigned int rn, uint32_t const *a, unsigned int an, ui
while (bu_len(bbb, an))
{
- register uint32_t *ttt = aaa ;
+ uint32_t *ttt = aaa ;
bu_div_internal(aaa, an, bbb, an, trash, an) ;
aaa = bbb ;
bbb = ttt ;
diff --git a/src/libbiguint/bu_len.c b/src/libbiguint/bu_len.c
index b6be726..fb63cef 100644
--- a/src/libbiguint/bu_len.c
+++ b/src/libbiguint/bu_len.c
@@ -3,7 +3,7 @@
#include <stdint.h>
#include <skalibs/biguint.h>
-unsigned int bu_len (register uint32_t const *a, register unsigned int n)
+unsigned int bu_len (uint32_t const *a, unsigned int n)
{
while (n--) if (a[n]) return n+1 ;
return 0 ;
diff --git a/src/libbiguint/bu_mul.c b/src/libbiguint/bu_mul.c
index 45d0efe..16043fd 100644
--- a/src/libbiguint/bu_mul.c
+++ b/src/libbiguint/bu_mul.c
@@ -11,15 +11,15 @@ int bu_mul (uint32_t *x, unsigned int xn, uint32_t const *a, unsigned int an, ui
unsigned int alen = bu_len(a, an) ;
unsigned int blen = bu_len(b, bn) ;
uint32_t c[alen + blen] ;
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
bu_zero(c, alen + blen) ;
for (; i < alen ; i++)
{
- register uint32_t carry = 0 ;
- register unsigned int j = 0 ;
+ uint32_t carry = 0 ;
+ unsigned int j = 0 ;
for (; j < blen ; j++)
{
- register uint64 t = a[i] ;
+ uint64_t t = a[i] ;
t *= b[j] ;
t += c[i+j] ;
t += carry ;
diff --git a/src/libbiguint/bu_pack.c b/src/libbiguint/bu_pack.c
index a71cec9..a2d37dc 100644
--- a/src/libbiguint/bu_pack.c
+++ b/src/libbiguint/bu_pack.c
@@ -4,7 +4,7 @@
#include <skalibs/uint32.h>
#include <skalibs/biguint.h>
-void bu_pack (char *s, uint32_t const *a, register unsigned int n)
+void bu_pack (char *s, uint32_t const *a, unsigned int n)
{
while (n--) uint32_pack(s + (n<<2), a[n]) ;
}
diff --git a/src/libbiguint/bu_pack_big.c b/src/libbiguint/bu_pack_big.c
index 41a6694..d5c5d48 100644
--- a/src/libbiguint/bu_pack_big.c
+++ b/src/libbiguint/bu_pack_big.c
@@ -6,6 +6,6 @@
void bu_pack_big (char *s, uint32_t const *a, unsigned int n)
{
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
for (; i < n ; i++) uint32_pack_big(s + (i<<2), a[n-1-i]) ;
}
diff --git a/src/libbiguint/bu_scan.c b/src/libbiguint/bu_scan.c
index 76c4b4e..c5deb82 100644
--- a/src/libbiguint/bu_scan.c
+++ b/src/libbiguint/bu_scan.c
@@ -13,7 +13,7 @@
int bu_scan (char const *s, size_t len, uint32_t *x, unsigned int xn, size_t zeron)
{
- register size_t n = bitarray_div8(zeron) ;
+ size_t n = bitarray_div8(zeron) ;
if (xn < n) return (errno = EOVERFLOW, 0) ;
bu_scan_internal(s, len, x) ;
bu_zero(x + n, xn - n) ;
diff --git a/src/libbiguint/bu_scan_internal.c b/src/libbiguint/bu_scan_internal.c
index 49388cf..15c2f0f 100644
--- a/src/libbiguint/bu_scan_internal.c
+++ b/src/libbiguint/bu_scan_internal.c
@@ -1,9 +1,8 @@
/* ISC license. */
-#include <sys/types.h>
#include <stdint.h>
+#include <string.h>
#include <skalibs/uint32.h>
-#include <skalibs/bytestr.h>
#include <skalibs/biguint.h>
void bu_scan_internal (char const *s, size_t len, uint32_t *x)
@@ -12,12 +11,12 @@ void bu_scan_internal (char const *s, size_t len, uint32_t *x)
size_t i = 0 ;
if (len & 7)
{
- byte_copy(fmt, len & 7, s) ;
+ memcpy(fmt, s, len & 7) ;
uint32_xscan(fmt, x + (len >> 3)) ;
}
for (; i < (len >> 3) ; i++)
{
- byte_copy(fmt, 8, s + len - 8 - (i << 3)) ;
+ memcpy(fmt, s + len - 8 - (i << 3), 8) ;
uint32_xscan(fmt, x + i) ;
}
}
diff --git a/src/libbiguint/bu_slbc.c b/src/libbiguint/bu_slbc.c
index d87af36..a39ef15 100644
--- a/src/libbiguint/bu_slbc.c
+++ b/src/libbiguint/bu_slbc.c
@@ -3,13 +3,13 @@
#include <stdint.h>
#include <skalibs/biguint.h>
-int bu_slbc (register uint32_t *a, register unsigned int n, register int carry)
+int bu_slbc (uint32_t *a, unsigned int n, int carry)
{
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
carry = !!carry ;
for (; i < n ; i++)
{
- register int c = a[i] >> 31 ;
+ int c = a[i] >> 31 ;
a[i] = (a[i] << 1) | carry ;
carry = c ;
}
diff --git a/src/libbiguint/bu_srbc.c b/src/libbiguint/bu_srbc.c
index a2dbab5..5e1fbc4 100644
--- a/src/libbiguint/bu_srbc.c
+++ b/src/libbiguint/bu_srbc.c
@@ -3,11 +3,11 @@
#include <stdint.h>
#include <skalibs/biguint.h>
-int bu_srbc (register uint32_t *a, register unsigned int n, register int carry)
+int bu_srbc (uint32_t *a, unsigned int n, int carry)
{
while (n--)
{
- register int c = a[n] & 1 ;
+ int c = a[n] & 1 ;
a[n] = (a[n] >> 1) | (carry ? 0x80000000U : 0) ;
carry = c ;
}
diff --git a/src/libbiguint/bu_subc.c b/src/libbiguint/bu_subc.c
index cff2a05..b5b6da5 100644
--- a/src/libbiguint/bu_subc.c
+++ b/src/libbiguint/bu_subc.c
@@ -9,14 +9,14 @@
#include <stdint.h>
#include <skalibs/biguint.h>
-int bu_subc (uint32_t *c, unsigned int cn, uint32_t const *a, unsigned int an, uint32_t const *b, unsigned int bn, register int carry)
+int bu_subc (uint32_t *c, unsigned int cn, uint32_t const *a, unsigned int an, uint32_t const *b, unsigned int bn, int carry)
{
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
for (; i < cn ; i++)
{
- register uint32_t ai = (i < an) ? a[i] : 0 ;
- register uint32_t bi = (i < bn) ? b[i] : 0 ;
- register uint32_t ci = ai - bi - carry ;
+ uint32_t ai = (i < an) ? a[i] : 0 ;
+ uint32_t bi = (i < bn) ? b[i] : 0 ;
+ uint32_t ci = ai - bi - carry ;
carry = (carry || bi) && (ci > ai) ;
c[i] = ci ;
}
diff --git a/src/libbiguint/bu_unpack.c b/src/libbiguint/bu_unpack.c
index 8100037..6542d30 100644
--- a/src/libbiguint/bu_unpack.c
+++ b/src/libbiguint/bu_unpack.c
@@ -4,7 +4,7 @@
#include <skalibs/uint32.h>
#include <skalibs/biguint.h>
-void bu_unpack (char const *s, uint32_t *a, register unsigned int n)
+void bu_unpack (char const *s, uint32_t *a, unsigned int n)
{
while (n--) uint32_unpack(s + (n<<2), a + n) ;
}
diff --git a/src/libbiguint/bu_unpack_big.c b/src/libbiguint/bu_unpack_big.c
index 83cf805..52037ea 100644
--- a/src/libbiguint/bu_unpack_big.c
+++ b/src/libbiguint/bu_unpack_big.c
@@ -6,6 +6,6 @@
void bu_unpack_big (char const *s, uint32_t *a, unsigned int n)
{
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
for (; i < n ; i++) uint32_unpack_big(s + (i<<2), a + n - 1 - i) ;
}
diff --git a/src/libbiguint/bu_zero.c b/src/libbiguint/bu_zero.c
index 0d512bf..8033740 100644
--- a/src/libbiguint/bu_zero.c
+++ b/src/libbiguint/bu_zero.c
@@ -3,7 +3,7 @@
#include <stdint.h>
#include <skalibs/biguint.h>
-void bu_zero (register uint32_t *z, register unsigned int n)
+void bu_zero (uint32_t *z, unsigned int n)
{
while (n--) z[n] = 0 ;
}
diff --git a/src/librandom/random_name.c b/src/librandom/random_name.c
index f972e93..1c8eb04 100644
--- a/src/librandom/random_name.c
+++ b/src/librandom/random_name.c
@@ -2,6 +2,7 @@
/* MT-unsafe */
+#include <sys/types.h>
#include <skalibs/random.h>
void random_name (char *s, size_t n)
diff --git a/src/librandom/random_string.c b/src/librandom/random_string.c
index 5053824..cd2a0aa 100644
--- a/src/librandom/random_string.c
+++ b/src/librandom/random_string.c
@@ -31,7 +31,7 @@ void random_string (char *s, size_t n)
{
while (n)
{
- register int r = getrandom(s, n, 0) ;
+ int r = getrandom(s, n, 0) ;
if (r >= 0)
{
s += r ;
diff --git a/src/librandom/random_uint32.c b/src/librandom/random_uint32.c
index a2144f1..26c0968 100644
--- a/src/librandom/random_uint32.c
+++ b/src/librandom/random_uint32.c
@@ -29,7 +29,7 @@ uint32_t random_uint32 (uint32_t n)
{
char tmp[4] ;
random_string(tmp, 4) ;
- uint32_unpack(tmp, &x) ;
+ uint32_unpack_big(tmp, &x) ;
if (x >= min) break ;
}
return x % n ;
diff --git a/src/librandom/random_unsort.c b/src/librandom/random_unsort.c
index 98a4b09..4596136 100644
--- a/src/librandom/random_unsort.c
+++ b/src/librandom/random_unsort.c
@@ -1,7 +1,7 @@
/* ISC license. */
#include <stdint.h>
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/random.h>
void random_unsort (char *s, size_t n, size_t chunksize)
@@ -9,9 +9,9 @@ void random_unsort (char *s, size_t n, size_t chunksize)
char tmp[chunksize] ;
while (n--)
{
- register uint32_t i = random_uint32(n+1) ;
- byte_copy(tmp, chunksize, s + i * chunksize) ;
- byte_copy(s + i * chunksize, chunksize, s + n * chunksize) ;
- byte_copy(s + n * chunksize, chunksize, tmp) ;
+ uint32_t i = random_uint32(n+1) ;
+ memcpy(tmp, s + i * chunksize, chunksize) ;
+ memcpy(s + i * chunksize, s + n * chunksize, chunksize) ;
+ memcpy(s + n * chunksize, tmp, chunksize) ;
}
}
diff --git a/src/librandom/surf.c b/src/librandom/surf.c
index fe5346e..1b68fc2 100644
--- a/src/librandom/surf.c
+++ b/src/librandom/surf.c
@@ -1,9 +1,8 @@
/* ISC license. */
-#include <sys/types.h>
#include <stdint.h>
+#include <string.h>
#include <skalibs/uint32.h>
-#include <skalibs/bytestr.h>
#include <skalibs/surf.h>
#define ROTATE(x, b) (((x) << (b)) | ((x) >> (32 - (b))))
@@ -38,19 +37,19 @@ static void surfit (SURFSchedule *ctx)
void surf (SURFSchedule *ctx, char *s, size_t n)
{
{
- register size_t i = 32 - ctx->pos ;
+ size_t i = 32 - ctx->pos ;
if (n < i) i = n ;
- byte_copy(s, i, ctx->out + ctx->pos) ;
+ memcpy(s, ctx->out + ctx->pos, i) ;
s += i ; n -= i ; ctx->pos += i ;
}
while (n > 32)
{
surfit(ctx) ;
- byte_copy(s, 32, ctx->out) ;
+ memcpy(s, ctx->out, 32) ;
s += 32 ; n -= 32 ;
}
if (!n) return ;
surfit(ctx) ;
- byte_copy(s, n, ctx->out) ;
+ memcpy(s, ctx->out, n) ;
ctx->pos = n ;
}
diff --git a/src/librandom/surf_init.c b/src/librandom/surf_init.c
index d1d9b3c..53abdcc 100644
--- a/src/librandom/surf_init.c
+++ b/src/librandom/surf_init.c
@@ -6,7 +6,7 @@
void surf_init (SURFSchedule *ctx, char const *s)
{
SURFSchedule zero = SURFSCHEDULE_ZERO ;
- register unsigned int i = 4 ;
+ unsigned int i = 4 ;
*ctx = zero ;
for (; i < 12 ; i++) uint32_unpack(s + (i<<2) - 16, ctx->in + i) ;
for (i = 0 ; i < 32 ; i++) uint32_unpack(s + 32 + (i<<2), ctx->seed + i) ;
diff --git a/src/libstdcrypto/md5_final.c b/src/libstdcrypto/md5_final.c
index 1ecdedf..706162b 100644
--- a/src/libstdcrypto/md5_final.c
+++ b/src/libstdcrypto/md5_final.c
@@ -8,8 +8,8 @@
void md5_final (MD5Schedule *ctx, char *digest /* 16 chars */)
{
- register unsigned int count = (ctx->bits[0] >> 3) & 0x3F ;
- register unsigned char *p = ctx->in + count ;
+ unsigned int count = (ctx->bits[0] >> 3) & 0x3F ;
+ unsigned char *p = ctx->in + count ;
*p++ = 0x80;
count = 63 - count ;
if (count < 8)
diff --git a/src/libstdcrypto/md5_transform.c b/src/libstdcrypto/md5_transform.c
index 0e65671..e210e73 100644
--- a/src/libstdcrypto/md5_transform.c
+++ b/src/libstdcrypto/md5_transform.c
@@ -14,7 +14,7 @@
void md5_transform (uint32_t *buf /* 4 uint32s */, uint32_t const *in /* 16 uint32s */)
{
- register uint32_t a = buf[0], b = buf[1], c = buf[2], d = buf[3] ;
+ uint32_t a = buf[0], b = buf[1], c = buf[2], d = buf[3] ;
MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478U, 7) ;
MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756U, 12) ;
diff --git a/src/libstdcrypto/md5_update.c b/src/libstdcrypto/md5_update.c
index 3b53abb..1a88540 100644
--- a/src/libstdcrypto/md5_update.c
+++ b/src/libstdcrypto/md5_update.c
@@ -9,7 +9,7 @@
void md5_update (MD5Schedule *ctx, char const *s, size_t len)
{
- register uint32 t = ctx->bits[0] ;
+ uint32 t = ctx->bits[0] ;
if ((ctx->bits[0] = t + (len << 3)) < t)
ctx->bits[1]++ ;
ctx->bits[1] += len >> 29 ;
diff --git a/src/libstdcrypto/rc4.c b/src/libstdcrypto/rc4.c
index ea16a82..2f39b95 100644
--- a/src/libstdcrypto/rc4.c
+++ b/src/libstdcrypto/rc4.c
@@ -7,10 +7,10 @@
void rc4 (RC4Schedule *r, char const *in, char *out, size_t n)
{
- register size_t i = 0 ;
+ size_t i = 0 ;
for (; i < n ; i++)
{
- register unsigned char t ;
+ unsigned char t ;
r->x = T8(r->x + 1) ;
t = r->tab[r->x] ;
r->y = T8(r->y + t) ;
diff --git a/src/libstdcrypto/rc4_init.c b/src/libstdcrypto/rc4_init.c
index e5c512d..bbcefda 100644
--- a/src/libstdcrypto/rc4_init.c
+++ b/src/libstdcrypto/rc4_init.c
@@ -7,8 +7,8 @@
void rc4_init (RC4Schedule *r, char const *key, size_t ksize)
{
size_t j = 0 ;
- register unsigned int i = 0 ;
- register unsigned char c = 0;
+ unsigned int i = 0 ;
+ unsigned char c = 0;
r->x = r->y = 0 ;
for (; i < 256 ; i++) r->tab[i] = i ;
diff --git a/src/libstdcrypto/sha1_feed.c b/src/libstdcrypto/sha1_feed.c
index 578348b..cb00852 100644
--- a/src/libstdcrypto/sha1_feed.c
+++ b/src/libstdcrypto/sha1_feed.c
@@ -7,13 +7,12 @@
void sha1_feed (SHA1Schedule *ctx, unsigned char inb)
{
- register uint32_t tmp ;
-
+ uint32_t tmp ;
ctx->in[ctx->b>>2] <<= 8 ;
ctx->in[ctx->b>>2] |= T8(inb) ;
if (++ctx->b >= 64)
{
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
sha1_transform(ctx->buf, ctx->in) ;
ctx->b = 0 ;
for (i = 0 ; i < 16 ; i++) ctx->in[i] = 0 ;
diff --git a/src/libstdcrypto/sha1_final.c b/src/libstdcrypto/sha1_final.c
index 603c89c..d29a621 100644
--- a/src/libstdcrypto/sha1_final.c
+++ b/src/libstdcrypto/sha1_final.c
@@ -7,7 +7,7 @@
void sha1_final (SHA1Schedule *ctx, char *digest)
{
char pack[8] ;
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
uint32_pack_big(pack, ctx->bits[1]) ;
uint32_pack_big(pack+4, ctx->bits[0]) ;
sha1_feed(ctx, 0x80) ;
diff --git a/src/libstdcrypto/sha1_init.c b/src/libstdcrypto/sha1_init.c
index 6aad123..589230d 100644
--- a/src/libstdcrypto/sha1_init.c
+++ b/src/libstdcrypto/sha1_init.c
@@ -4,13 +4,13 @@
void sha1_init (SHA1Schedule *ctx)
{
- register unsigned int i = 0 ;
+ unsigned int i = 16 ;
ctx->buf[0] = 0x67452301U ;
ctx->buf[1] = 0xefcdab89U ;
ctx->buf[2] = 0x98badcfeU ;
ctx->buf[3] = 0x10325476U ;
ctx->buf[4] = 0xc3d2e1f0U ;
ctx->bits[0] = ctx->bits[1] = 0 ;
- for (; i < 16 ; i++) ctx->in[i] = 0 ;
+ while (i--) ctx->in[i] = 0 ;
ctx->b = 0 ;
}
diff --git a/src/libstdcrypto/sha1_transform.c b/src/libstdcrypto/sha1_transform.c
index 106c356..66a1c52 100644
--- a/src/libstdcrypto/sha1_transform.c
+++ b/src/libstdcrypto/sha1_transform.c
@@ -10,7 +10,7 @@
#define SHA1STEP(f, data) \
{ \
- register uint32_t tmp = e + f(b, c, d) + data + ((a<<5) | (a>>27)); \
+ uint32_t tmp = e + f(b, c, d) + data + ((a<<5) | (a>>27)); \
e = d ; \
d = c ; \
c = (b<<30) | (b>>2) ; \
@@ -20,9 +20,9 @@
void sha1_transform (uint32_t *buf, uint32_t const *in)
{
- register uint32_t a = buf[0], b = buf[1], c = buf[2], d = buf[3], e = buf[4] ;
+ uint32_t a = buf[0], b = buf[1], c = buf[2], d = buf[3], e = buf[4] ;
uint32_t w[80] ;
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
for (; i < 16 ; i++) w[i] = in[i] ;
for (; i < 80 ; i++)
diff --git a/src/libstdcrypto/sha1_update.c b/src/libstdcrypto/sha1_update.c
index 8c0dc54..4fa393c 100644
--- a/src/libstdcrypto/sha1_update.c
+++ b/src/libstdcrypto/sha1_update.c
@@ -6,6 +6,6 @@
void sha1_update (SHA1Schedule *ctx, char const *buf, size_t len)
{
- register size_t i = 0 ;
+ size_t i = 0 ;
for (; i < len ; i++) sha1_feed(ctx, (unsigned char)buf[i]) ;
}
diff --git a/src/libstdcrypto/sha256_feed.c b/src/libstdcrypto/sha256_feed.c
index 8f1ecbe..197b8f0 100644
--- a/src/libstdcrypto/sha256_feed.c
+++ b/src/libstdcrypto/sha256_feed.c
@@ -7,12 +7,12 @@
void sha256_feed (SHA256Schedule *ctx, unsigned char inb)
{
- register uint32_t tmp ;
+ uint32_t tmp ;
ctx->in[ctx->b>>2] <<= 8 ;
ctx->in[ctx->b>>2] |= T8(inb) ;
if (++ctx->b >= 64)
{
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
sha256_transform(ctx->buf, ctx->in) ;
ctx->b = 0 ;
for (; i < 16 ; i++) ctx->in[i] = 0 ;
diff --git a/src/libstdcrypto/sha256_final.c b/src/libstdcrypto/sha256_final.c
index b981459..ba4b5ea 100644
--- a/src/libstdcrypto/sha256_final.c
+++ b/src/libstdcrypto/sha256_final.c
@@ -7,8 +7,8 @@
void sha256_final (SHA256Schedule *ctx, char *digest)
{
- register unsigned int i = 0 ;
- register unsigned char *p = (unsigned char *)digest ;
+ unsigned int i = 0 ;
+ unsigned char *p = (unsigned char *)digest ;
uint32_t bits[2] = { ctx->bits[0], ctx->bits[1] } ;
sha256_feed(ctx, 0x80) ;
diff --git a/src/libstdcrypto/sha256_transform.c b/src/libstdcrypto/sha256_transform.c
index bc39e33..65a51c4 100644
--- a/src/libstdcrypto/sha256_transform.c
+++ b/src/libstdcrypto/sha256_transform.c
@@ -36,7 +36,7 @@ void sha256_transform (uint32_t *buf, uint32_t const *in)
{
uint32_t w[64] ;
unsigned int i = 0 ;
- register uint32_t a = buf[0], b = buf[1], c = buf[2], d = buf[3], e = buf[4], f = buf[5], g = buf[6], h = buf[7] ;
+ uint32_t a = buf[0], b = buf[1], c = buf[2], d = buf[3], e = buf[4], f = buf[5], g = buf[6], h = buf[7] ;
for (; i < 16 ; i++) w[i] = in[i] ;
for (; i < 64 ; i++)
diff --git a/src/libstdcrypto/sha256_update.c b/src/libstdcrypto/sha256_update.c
index 6d69469..d8bb3b1 100644
--- a/src/libstdcrypto/sha256_update.c
+++ b/src/libstdcrypto/sha256_update.c
@@ -6,6 +6,6 @@
void sha256_update (SHA256Schedule *ctx, char const *buf, size_t len)
{
- register size_t i = 0 ;
+ size_t i = 0 ;
for (; i < len ; i++) sha256_feed(ctx, (unsigned char)buf[i]) ;
}
diff --git a/src/libstdcrypto/sha512_final.c b/src/libstdcrypto/sha512_final.c
index 62a6187..ebda597 100644
--- a/src/libstdcrypto/sha512_final.c
+++ b/src/libstdcrypto/sha512_final.c
@@ -7,8 +7,8 @@
void sha512_final (SHA512Schedule *ctx, char *digest)
{
- register unsigned int i = 0 ;
- register unsigned int pad = ctx->len % 128;
+ unsigned int i = 0 ;
+ unsigned int pad = ctx->len % 128;
ctx->buf[pad++] = 0x80 ;
if (pad > 112)
diff --git a/src/libstdcrypto/sha512_transform.c b/src/libstdcrypto/sha512_transform.c
index 7b94adf..3413828 100644
--- a/src/libstdcrypto/sha512_transform.c
+++ b/src/libstdcrypto/sha512_transform.c
@@ -4,7 +4,7 @@
#include <skalibs/sha512.h>
#include "sha512-internal.h"
-static uint64 ror (uint64 n, unsigned int k)
+static uint64_t ror (uint64_t n, unsigned int k)
{
return (n >> k) | (n << (64 - k)) ;
}
@@ -25,7 +25,7 @@ static uint64 ror (uint64 n, unsigned int k)
void sha512_transform (SHA512Schedule *ctx, unsigned char const *block)
{
- static uint64 const K[80] =
+ static uint64_t const K[80] =
{
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL,
0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL,
@@ -68,10 +68,10 @@ void sha512_transform (SHA512Schedule *ctx, unsigned char const *block)
0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL,
0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL
} ;
- uint64 w[80] ;
- uint64 h[8] ;
- uint64 t[2] ;
- register unsigned int i = 0 ;
+ uint64_t w[80] ;
+ uint64_t h[8] ;
+ uint64_t t[2] ;
+ unsigned int i = 0 ;
for (; i < 16 ; i++) uint64_unpack_big((char const *)block + (i << 3), w + i) ;
for (; i < 80 ; i++) w[i] = R1(w[i-2]) + w[i-7] + R0(w[i-15]) + w[i-16] ;
diff --git a/src/libstdcrypto/sha512_update.c b/src/libstdcrypto/sha512_update.c
index 63bc6fb..a6c004f 100644
--- a/src/libstdcrypto/sha512_update.c
+++ b/src/libstdcrypto/sha512_update.c
@@ -1,17 +1,16 @@
/* ISC license. */
-#include <sys/types.h>
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/sha512.h>
#include "sha512-internal.h"
void sha512_update (SHA512Schedule *ctx, char const *buf, size_t len)
{
- register unsigned int pad = ctx->len & 0x7fU ;
+ unsigned int pad = ctx->len & 0x7fU ;
ctx->len += len ;
if (pad && len >= 128 - pad)
{
- byte_copy((char *)ctx->buf + pad, 128 - pad, buf) ;
+ memcpy((char *)ctx->buf + pad, buf, 128 - pad) ;
buf += 128 - pad ; len -= 128 - pad ; pad = 0 ;
sha512_transform(ctx, ctx->buf) ;
}
@@ -21,5 +20,5 @@ void sha512_update (SHA512Schedule *ctx, char const *buf, size_t len)
sha512_transform(ctx, (unsigned char const *)buf) ;
buf += 128 ; len -= 128 ;
}
- byte_copy((char *)ctx->buf + pad, len, buf) ;
+ memcpy((char *)ctx->buf + pad, buf, len) ;
}
diff --git a/src/libstddjb/allreadv.c b/src/libstddjb/allreadv.c
index 13514cc..da300fd 100644
--- a/src/libstddjb/allreadv.c
+++ b/src/libstddjb/allreadv.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <skalibs/allreadwrite.h>
diff --git a/src/libstddjb/allreadwritev.c b/src/libstddjb/allreadwritev.c
index 5ba3837..689bbf6 100644
--- a/src/libstddjb/allreadwritev.c
+++ b/src/libstddjb/allreadwritev.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <skalibs/functypes.h>
#include <skalibs/allreadwrite.h>
diff --git a/src/libstddjb/allwritev.c b/src/libstddjb/allwritev.c
index dc343a4..35b5d65 100644
--- a/src/libstddjb/allwritev.c
+++ b/src/libstddjb/allwritev.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <skalibs/allreadwrite.h>
diff --git a/src/libstddjb/bitarray_firstclear_skip.c b/src/libstddjb/bitarray_firstclear_skip.c
index ef49ee0..0fa2944 100644
--- a/src/libstddjb/bitarray_firstclear_skip.c
+++ b/src/libstddjb/bitarray_firstclear_skip.c
@@ -3,10 +3,10 @@
#include <sys/types.h>
#include <skalibs/bitarray.h>
-size_t bitarray_firstclear_skip (register unsigned char const *s, size_t max, size_t skip)
+size_t bitarray_firstclear_skip (unsigned char const *s, size_t max, size_t skip)
{
- register size_t i = bitarray_div8(skip) ;
- register size_t j = i << 3 > max ? max : i << 3 ;
+ size_t i = bitarray_div8(skip) ;
+ size_t j = i << 3 > max ? max : i << 3 ;
if (i && s[i-1] != 0xffU)
{
while ((skip < j) && bitarray_peek(s, skip)) skip++ ;
diff --git a/src/libstddjb/bitarray_firstset_skip.c b/src/libstddjb/bitarray_firstset_skip.c
index 3689375..0b11c3e 100644
--- a/src/libstddjb/bitarray_firstset_skip.c
+++ b/src/libstddjb/bitarray_firstset_skip.c
@@ -3,10 +3,10 @@
#include <sys/types.h>
#include <skalibs/bitarray.h>
-size_t bitarray_firstset_skip (register unsigned char const *s, size_t max, size_t skip)
+size_t bitarray_firstset_skip (unsigned char const *s, size_t max, size_t skip)
{
- register size_t i = bitarray_div8(skip) ;
- register size_t j = i << 3 > max ? max : i << 3 ;
+ size_t i = bitarray_div8(skip) ;
+ size_t j = i << 3 > max ? max : i << 3 ;
if (i && s[i-1])
{
while ((skip < j) && !bitarray_peek(s, skip)) skip++ ;
diff --git a/src/libstddjb/buffer_fill.c b/src/libstddjb/buffer_fill.c
index b3a1bf2..cbdef3e 100644
--- a/src/libstddjb/buffer_fill.c
+++ b/src/libstddjb/buffer_fill.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <errno.h>
#include <skalibs/buffer.h>
diff --git a/src/libstddjb/buffer_flush.c b/src/libstddjb/buffer_flush.c
index 3249a11..c40c31e 100644
--- a/src/libstddjb/buffer_flush.c
+++ b/src/libstddjb/buffer_flush.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <skalibs/cbuffer.h>
#include <skalibs/buffer.h>
diff --git a/src/libstddjb/buffer_flush1read.c b/src/libstddjb/buffer_flush1read.c
index 0384602..49c919f 100644
--- a/src/libstddjb/buffer_flush1read.c
+++ b/src/libstddjb/buffer_flush1read.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/buffer.h>
diff --git a/src/libstddjb/buffer_getv.c b/src/libstddjb/buffer_getv.c
index 358de01..280a3b4 100644
--- a/src/libstddjb/buffer_getv.c
+++ b/src/libstddjb/buffer_getv.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/buffer.h>
diff --git a/src/libstddjb/buffer_getvall.c b/src/libstddjb/buffer_getvall.c
index ba2dfae..3a90871 100644
--- a/src/libstddjb/buffer_getvall.c
+++ b/src/libstddjb/buffer_getvall.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <errno.h>
#include <skalibs/allreadwrite.h>
diff --git a/src/libstddjb/buffer_getvallnf.c b/src/libstddjb/buffer_getvallnf.c
index e0e2e5d..e0a2d0a 100644
--- a/src/libstddjb/buffer_getvallnf.c
+++ b/src/libstddjb/buffer_getvallnf.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <errno.h>
#include <skalibs/siovec.h>
diff --git a/src/libstddjb/buffer_putv.c b/src/libstddjb/buffer_putv.c
index bd902ae..f8fac59 100644
--- a/src/libstddjb/buffer_putv.c
+++ b/src/libstddjb/buffer_putv.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <skalibs/buffer.h>
diff --git a/src/libstddjb/buffer_putvall.c b/src/libstddjb/buffer_putvall.c
index b04ac36..5635aed 100644
--- a/src/libstddjb/buffer_putvall.c
+++ b/src/libstddjb/buffer_putvall.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <errno.h>
#include <skalibs/siovec.h>
diff --git a/src/libstddjb/buffer_putvallnf.c b/src/libstddjb/buffer_putvallnf.c
index 6f87d13..3898a36 100644
--- a/src/libstddjb/buffer_putvallnf.c
+++ b/src/libstddjb/buffer_putvallnf.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <errno.h>
#include <skalibs/siovec.h>
diff --git a/src/libstddjb/buffer_putvflush.c b/src/libstddjb/buffer_putvflush.c
index 4bbb329..86c5b5c 100644
--- a/src/libstddjb/buffer_putvflush.c
+++ b/src/libstddjb/buffer_putvflush.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <skalibs/buffer.h>
diff --git a/src/libstddjb/case_lowerb.c b/src/libstddjb/case_lowerb.c
index 1285b52..d2099fc 100644
--- a/src/libstddjb/case_lowerb.c
+++ b/src/libstddjb/case_lowerb.c
@@ -3,7 +3,7 @@
#include <sys/types.h>
#include <skalibs/bytestr.h>
-void case_lowerb (register char *s, size_t len)
+void case_lowerb (char *s, size_t len)
{
unsigned char const d = 'a' - 'A' ;
while (len--)
diff --git a/src/libstddjb/case_lowers.c b/src/libstddjb/case_lowers.c
index 5999786..349eade 100644
--- a/src/libstddjb/case_lowers.c
+++ b/src/libstddjb/case_lowers.c
@@ -2,9 +2,9 @@
#include <skalibs/bytestr.h>
-void case_lowers (register char *s)
+void case_lowers (char *s)
{
- register unsigned char const d = 'a' - 'A' ;
+ unsigned char const d = 'a' - 'A' ;
while (*s)
{
if (('A' <= *s) && (*s <= 'Z')) *s += d ;
diff --git a/src/libstddjb/case_startb.c b/src/libstddjb/case_startb.c
index d69f461..42e12f2 100644
--- a/src/libstddjb/case_startb.c
+++ b/src/libstddjb/case_startb.c
@@ -1,11 +1,11 @@
/* ISC license. */
-#include <sys/types.h>
#include <string.h>
+#include <strings.h>
#include <skalibs/bytestr.h>
-int case_startb (register char const *s, size_t slen, register char const *t)
+int case_startb (char const *s, size_t slen, char const *t)
{
size_t tlen = strlen(t) ;
- return slen < tlen ? 0 : !case_diffb(s, tlen, t) ;
+ return slen < tlen ? 0 : !strncasecmp(s, t, tlen) ;
}
diff --git a/src/libstddjb/case_str.c b/src/libstddjb/case_str.c
index a6cd9b4..9c79019 100644
--- a/src/libstddjb/case_str.c
+++ b/src/libstddjb/case_str.c
@@ -16,8 +16,8 @@ size_t case_str (char const *haystack, char const *needle)
#else
-#include <sys/types.h>
#include <string.h>
+#include <strings.h>
#include <skalibs/bytestr.h>
size_t case_str (char const *haystack, char const *needle)
@@ -26,7 +26,7 @@ size_t case_str (char const *haystack, char const *needle)
char const *p = haystack ;
if (!nlen) return 0 ;
for (; *p ; p++)
- if (!case_diffb(p, nlen, needle)) return p - haystack ;
+ if (!strncasecmp(p, needle, nlen)) return p - haystack ;
return strlen(haystack) ;
}
diff --git a/src/libstddjb/case_upperb.c b/src/libstddjb/case_upperb.c
index 78ece8f..e3fa47b 100644
--- a/src/libstddjb/case_upperb.c
+++ b/src/libstddjb/case_upperb.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/bytestr.h>
void case_upperb (char *s, size_t len)
diff --git a/src/libstddjb/case_uppers.c b/src/libstddjb/case_uppers.c
index cf2875a..da0837c 100644
--- a/src/libstddjb/case_uppers.c
+++ b/src/libstddjb/case_uppers.c
@@ -2,9 +2,9 @@
#include <skalibs/bytestr.h>
-void case_uppers (register char *s)
+void case_uppers (char *s)
{
- register unsigned char const d = 'a' - 'A' ;
+ unsigned char const d = 'a' - 'A' ;
while (*s)
{
if (('a' <= *s) && (*s <= 'z')) *s -= d ;
diff --git a/src/libstddjb/cbuffer_get.c b/src/libstddjb/cbuffer_get.c
index c490c26..315751a 100644
--- a/src/libstddjb/cbuffer_get.c
+++ b/src/libstddjb/cbuffer_get.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <skalibs/siovec.h>
#include <skalibs/cbuffer.h>
diff --git a/src/libstddjb/cbuffer_getv.c b/src/libstddjb/cbuffer_getv.c
index f27d054..afdf8f9 100644
--- a/src/libstddjb/cbuffer_getv.c
+++ b/src/libstddjb/cbuffer_getv.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <skalibs/siovec.h>
#include <skalibs/cbuffer.h>
diff --git a/src/libstddjb/cbuffer_put.c b/src/libstddjb/cbuffer_put.c
index 2a5fcf8..428a430 100644
--- a/src/libstddjb/cbuffer_put.c
+++ b/src/libstddjb/cbuffer_put.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <skalibs/siovec.h>
#include <skalibs/cbuffer.h>
diff --git a/src/libstddjb/cbuffer_putv.c b/src/libstddjb/cbuffer_putv.c
index 2fcdee6..62af494 100644
--- a/src/libstddjb/cbuffer_putv.c
+++ b/src/libstddjb/cbuffer_putv.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <skalibs/siovec.h>
#include <skalibs/cbuffer.h>
diff --git a/src/libstddjb/cbuffer_wpeek.c b/src/libstddjb/cbuffer_wpeek.c
index a1e502e..8b6b586 100644
--- a/src/libstddjb/cbuffer_wpeek.c
+++ b/src/libstddjb/cbuffer_wpeek.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <skalibs/cbuffer.h>
diff --git a/src/libstddjb/cdb_findnext.c b/src/libstddjb/cdb_findnext.c
index 2559bc2..536013b 100644
--- a/src/libstddjb/cdb_findnext.c
+++ b/src/libstddjb/cdb_findnext.c
@@ -1,18 +1,19 @@
/* ISC license. */
-#include <skalibs/bytestr.h>
+#include <stdint.h>
+#include <string.h>
#include <skalibs/uint32.h>
#include <skalibs/cdb.h>
-static int match (struct cdb *c, char const *key, unsigned int len, uint32 pos)
+static int match (struct cdb *c, char const *key, unsigned int len, uint32_t pos)
{
char buf[1024] ;
while (len > 0)
{
- register unsigned int n = 1024 ;
+ unsigned int n = 1024 ;
if (n > len) n = len ;
if (cdb_read(c, buf, n, pos) < 0) return -1 ;
- if (byte_diff(buf, n, key)) return 0 ;
+ if (memcmp(buf, key, n)) return 0 ;
pos += n ; key += n ; len -= n ;
}
return 1 ;
@@ -21,8 +22,8 @@ static int match (struct cdb *c, char const *key, unsigned int len, uint32 pos)
int cdb_findnext (struct cdb *c, char const *key, unsigned int len)
{
char buf[8] ;
- uint32 pos ;
- uint32 u ;
+ uint32_t pos ;
+ uint32_t u ;
if (!c->loop)
{
diff --git a/src/libstddjb/cdb_hash.c b/src/libstddjb/cdb_hash.c
index 9eedf54..85a11c1 100644
--- a/src/libstddjb/cdb_hash.c
+++ b/src/libstddjb/cdb_hash.c
@@ -1,17 +1,17 @@
/* ISC license. */
-#include <skalibs/uint32.h>
+#include <stdint.h>
#include <skalibs/cdb.h>
-uint32 cdb_hashadd (uint32 h, unsigned char c)
+uint32_t cdb_hashadd (uint32_t h, unsigned char c)
{
h += (h << 5) ;
return h ^ c ;
}
-uint32 cdb_hash (char const *buf, unsigned int len)
+uint32_t cdb_hash (char const *buf, unsigned int len)
{
- uint32 h = CDB_HASHSTART ;
+ uint32_t h = CDB_HASHSTART ;
while (len--) h = cdb_hashadd(h, *buf++) ;
return h ;
}
diff --git a/src/libstddjb/cdb_init_map.c b/src/libstddjb/cdb_init_map.c
index bf8eb9d..de9aad0 100644
--- a/src/libstddjb/cdb_init_map.c
+++ b/src/libstddjb/cdb_init_map.c
@@ -1,8 +1,14 @@
/* ISC license. */
+#ifndef _BSD_SOURCE
+#define _BSD_SOURCE
+#endif
+
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
+#include <stdint.h>
+#include <errno.h>
#include <skalibs/cdb.h>
int cdb_init_map (struct cdb *c, int fd, int domap)
@@ -12,6 +18,7 @@ int cdb_init_map (struct cdb *c, int fd, int domap)
struct stat st ;
char *map ;
if (fstat(fd, &st) < 0) return 0 ;
+ if (st.st_size > UINT32_MAX) return (errno = EOVERFLOW, 0) ;
map = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0) ;
if (map == MAP_FAILED) return 0 ;
c->fd = -fd-2 ;
diff --git a/src/libstddjb/cdb_make.c b/src/libstddjb/cdb_make.c
index c7e79d3..ce5e81e 100644
--- a/src/libstddjb/cdb_make.c
+++ b/src/libstddjb/cdb_make.c
@@ -1,6 +1,7 @@
/* ISC license. */
#include <unistd.h>
+#include <stdint.h>
#include <errno.h>
#include <skalibs/uint32.h>
#include <skalibs/diuint32.h>
@@ -16,28 +17,29 @@ int cdb_make_start (struct cdb_make *c, int fd)
c->hplist = genalloc_zero ;
c->pos = 2048 ;
buffer_init(&c->b, &fd_writev, fd, c->buf, BUFFER_OUTSIZE) ;
- return (int)lseek(fd, c->pos, SEEK_SET) ;
+ if (lseek(fd, c->pos, SEEK_SET) < 0) return -1 ;
+ return 0 ;
}
static int posplus (struct cdb_make *c, uint32 len)
{
- register uint32 newpos = c->pos + len ;
+ uint32_t newpos = c->pos + len ;
if (newpos < len) return (errno = ENOMEM, 0) ;
c->pos = newpos ;
return 1 ;
}
-static inline int cdb_make_addend (struct cdb_make *c, unsigned int keylen, unsigned int datalen, uint32 h)
+static inline int cdb_make_addend (struct cdb_make *c, unsigned int keylen, unsigned int datalen, uint32_t h)
{
diuint32 blah = { .left = h, .right = c->pos } ;
return genalloc_append(diuint32, &c->hplist, &blah) && posplus(c, 8) && posplus(c, keylen) && posplus(c, datalen) ;
}
-static inline int cdb_make_addbegin (struct cdb_make *c, unsigned int keylen, unsigned int datalen)
+static inline ssize_t cdb_make_addbegin (struct cdb_make *c, unsigned int keylen, unsigned int datalen)
{
char buf[8] ;
- uint32_pack(buf, (uint32)keylen) ;
- uint32_pack(buf + 4, (uint32)datalen) ;
+ uint32_pack(buf, (uint32_t)keylen) ;
+ uint32_pack(buf + 4, (uint32_t)datalen) ;
return buffer_put(&c->b, buf, 8) ;
}
@@ -56,19 +58,19 @@ int cdb_make_add (struct cdb_make *c, char const *key, unsigned int keylen, char
int cdb_make_finish (struct cdb_make *c)
{
- uint32 count[256] ;
- uint32 start[256] ;
+ uint32_t count[256] ;
+ uint32_t start[256] ;
char final[2048] ;
unsigned int size = 1 ;
unsigned int n = genalloc_len(diuint32, &c->hplist) ;
- register unsigned int i = 0 ;
- register diuint32 *hp = genalloc_s(diuint32, &c->hplist) ;
+ unsigned int i = 0 ;
+ diuint32 *hp = genalloc_s(diuint32, &c->hplist) ;
for (; i < 256 ; i++) count[i] = 0 ;
for (i = 0 ; i < n ; i++) ++count[hp[i].left & 255] ;
{
- register uint32 u = 0 ;
+ uint32_t u = 0 ;
for (i = 0 ; i < 256 ; i++) start[i] = u += count[i] ; /* bounded by n */
for (i = 0 ; i < 256 ; i++)
{
@@ -89,10 +91,10 @@ int cdb_make_finish (struct cdb_make *c)
for (i = 0 ; i < 256 ; ++i)
{
char buf[8] ;
- register uint32 k = count[i] ;
- register uint32 len = k << 1 ; /* no overflow possible */
- register diuint32 *p = split + start[i] ;
- register unsigned int j = 0 ;
+ uint32_t k = count[i] ;
+ uint32_t len = k << 1 ; /* no overflow possible */
+ diuint32 *p = split + start[i] ;
+ unsigned int j = 0 ;
uint32_pack(final + (i << 3), c->pos) ;
uint32_pack(final + (i << 3) + 4, len) ;
@@ -100,7 +102,7 @@ int cdb_make_finish (struct cdb_make *c)
for (; j < len ; j++) hp[j].left = hp[j].right = 0 ;
for (j = 0 ; j < k ; j++)
{
- register uint32 where = (p->left >> 8) % len ;
+ uint32_t where = (p->left >> 8) % len ;
while (hp[where].right) if (++where == len) where = 0 ;
hp[where] = *p++ ;
}
diff --git a/src/libstddjb/cdb_mapfile.c b/src/libstddjb/cdb_mapfile.c
index f26ad3c..1ffae19 100644
--- a/src/libstddjb/cdb_mapfile.c
+++ b/src/libstddjb/cdb_mapfile.c
@@ -10,7 +10,7 @@ int cdb_mapfile (struct cdb *c, char const *file)
if (fd < 0) return 0 ;
if (!cdb_init_map(c, fd, 1))
{
- register int e = errno ;
+ int e = errno ;
fd_close(fd) ;
errno = e ;
return 0 ;
diff --git a/src/libstddjb/cdb_nextkey.c b/src/libstddjb/cdb_nextkey.c
index 28925fe..51e927f 100644
--- a/src/libstddjb/cdb_nextkey.c
+++ b/src/libstddjb/cdb_nextkey.c
@@ -1,12 +1,13 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/uint32.h>
#include <skalibs/cdb.h>
-int cdb_nextkey (struct cdb *c, uint32 *kpos)
+int cdb_nextkey (struct cdb *c, uint32_t *kpos)
{
char buf[8] ;
- uint32 eod, klen ;
+ uint32_t eod, klen ;
if (cdb_read(c, buf, 4, 0) < 0) return -1 ;
uint32_unpack(buf, &eod) ;
if (eod < 8 || eod - 8 < *kpos) return 0 ;
diff --git a/src/libstddjb/cdb_read.c b/src/libstddjb/cdb_read.c
index 76fbd63..e857511 100644
--- a/src/libstddjb/cdb_read.c
+++ b/src/libstddjb/cdb_read.c
@@ -1,23 +1,24 @@
/* ISC license. */
+#include <unistd.h>
+#include <stdint.h>
+#include <string.h>
#include <errno.h>
#include <skalibs/error.h>
-#include <skalibs/bytestr.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/uint32.h>
-#include <skalibs/djbunix.h>
#include <skalibs/cdb.h>
-int cdb_read (struct cdb *c, char *buf, unsigned int len, uint32 pos)
+int cdb_read (struct cdb *c, char *buf, unsigned int len, uint32_t pos)
{
if (c->map)
{
if ((pos > c->size) || (c->size - pos < len)) return (errno = EPROTO, -1) ;
- byte_copy(buf, len, c->map + pos) ;
+ memcpy(buf, c->map + pos, len) ;
}
else
{
- if (seek_set(c->fd, pos) < 0) return -1 ;
+ if (lseek(c->fd, pos, SEEK_SET) < 0) return -1 ;
if (allread(c->fd, buf, len) < len) return -1 ;
}
return 0 ;
diff --git a/src/libstddjb/cdb_successor.c b/src/libstddjb/cdb_successor.c
index 5660692..0d7e17f 100644
--- a/src/libstddjb/cdb_successor.c
+++ b/src/libstddjb/cdb_successor.c
@@ -1,14 +1,15 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/uint32.h>
#include <skalibs/cdb.h>
int cdb_successor (struct cdb *c, char const *key, unsigned int klen)
{
- uint32 kpos ;
+ uint32_t kpos ;
if (key)
{
- register int r = cdb_find(c, key, klen) ;
+ int r = cdb_find(c, key, klen) ;
if (r < 1) return r ;
kpos = c->dpos + c->dlen ;
}
diff --git a/src/libstddjb/dir_close.c b/src/libstddjb/dir_close.c
index 0af6f0e..1b7b16a 100644
--- a/src/libstddjb/dir_close.c
+++ b/src/libstddjb/dir_close.c
@@ -5,7 +5,7 @@
int dir_close (DIR *dir)
{
- register unsigned int done = 0 ;
+ unsigned int done = 0 ;
doit:
done++ ;
if (!closedir(dir)) return 0 ;
diff --git a/src/libstddjb/djbtime-internal.h b/src/libstddjb/djbtime-internal.h
index eb4e676..a80b540 100644
--- a/src/libstddjb/djbtime-internal.h
+++ b/src/libstddjb/djbtime-internal.h
@@ -6,10 +6,10 @@
#include <skalibs/uint64.h>
extern unsigned int const leapsecs_table_len ;
-extern uint64 const *const leapsecs_table ;
+extern uint64_t const *const leapsecs_table ;
-extern void leapsecs_add (uint64 *, int) ;
-extern int leapsecs_sub (uint64 *) ;
+extern void leapsecs_add (uint64_t *, int) ;
+extern int leapsecs_sub (uint64_t *) ;
extern int skalibs_tzisright (void) ;
#endif
diff --git a/src/libstddjb/env_addmodif.c b/src/libstddjb/env_addmodif.c
index 4c34479..ddd1be3 100644
--- a/src/libstddjb/env_addmodif.c
+++ b/src/libstddjb/env_addmodif.c
@@ -1,11 +1,12 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/stralloc.h>
#include <skalibs/env.h>
int env_addmodif (stralloc *sa, char const *s, char const *t)
{
- unsigned int oldlen = sa->len ;
+ size_t oldlen = sa->len ;
if (!s) return 1 ;
if (!stralloc_cats(sa, s)) return 0 ;
if ((t && (!stralloc_catb(sa, "=", 1) || !stralloc_cats(sa, t)))
diff --git a/src/libstddjb/env_get2.c b/src/libstddjb/env_get2.c
index 612cf6a..5909ea6 100644
--- a/src/libstddjb/env_get2.c
+++ b/src/libstddjb/env_get2.c
@@ -1,15 +1,14 @@
/* ISC license. */
+#include <string.h>
#include <skalibs/bytestr.h>
#include <skalibs/env.h>
char const *env_get2 (char const *const *envp, char const *s)
{
- unsigned int i ;
- unsigned int len ;
-
+ size_t len, i ;
if (!s) return 0 ;
- len = str_len(s) ;
+ len = strlen(s) ;
for (i = 0 ; envp[i] ; ++i)
if (str_start(envp[i], s)
&& (envp[i][len] == '='))
diff --git a/src/libstddjb/env_len.c b/src/libstddjb/env_len.c
index 7e0bea8..f551ce1 100644
--- a/src/libstddjb/env_len.c
+++ b/src/libstddjb/env_len.c
@@ -1,10 +1,11 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/env.h>
-unsigned int env_len (register char const *const *e)
+size_t env_len (char const *const *e)
{
- register unsigned int i = 0 ;
+ size_t i = 0 ;
while (*e++) i++ ;
return i ;
}
diff --git a/src/libstddjb/env_make.c b/src/libstddjb/env_make.c
index dd5139f..60148f8 100644
--- a/src/libstddjb/env_make.c
+++ b/src/libstddjb/env_make.c
@@ -1,14 +1,14 @@
/* ISC license. */
+#include <string.h>
#include <errno.h>
-#include <skalibs/bytestr.h>
#include <skalibs/env.h>
-int env_make (char const **v, unsigned int argc, char const *s, unsigned int len)
+int env_make (char const **v, size_t argc, char const *s, size_t len)
{
while (argc--)
{
- register unsigned int n = str_len(s) + 1 ;
+ size_t n = strlen(s) + 1 ;
if (n > len) return (errno = EINVAL, 0) ;
*v++ = s ; s += n ; len -= n ;
}
diff --git a/src/libstddjb/env_merge.c b/src/libstddjb/env_merge.c
index 2a0e5bd..f7ba335 100644
--- a/src/libstddjb/env_merge.c
+++ b/src/libstddjb/env_merge.c
@@ -1,22 +1,23 @@
/* ISC license. */
+#include <string.h>
#include <errno.h>
#include <skalibs/bytestr.h>
#include <skalibs/env.h>
-unsigned int env_merge (char const **v, unsigned int vmax, char const *const *envp, unsigned int envlen, char const *modifs, unsigned int modiflen)
+size_t env_merge (char const **v, size_t vmax, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen)
{
- unsigned int n = byte_count(modifs, modiflen, '\0') ;
- unsigned int vlen = envlen ;
- register unsigned int i = 0 ;
+ size_t n = byte_count(modifs, modiflen, '\0') ;
+ size_t vlen = envlen ;
+ size_t i = 0 ;
if (envlen + n + 1 > vmax) return (errno = ENAMETOOLONG, 0) ;
for (; i < envlen ; i++) v[i] = envp[i] ;
- for (i = 0 ; i < modiflen ; i += str_len(modifs + i) + 1)
+ for (i = 0 ; i < modiflen ; i += strlen(modifs + i) + 1)
{
- unsigned int split = str_chr(modifs + i, '=') ;
- register unsigned int j = 0 ;
+ size_t split = str_chr(modifs + i, '=') ;
+ size_t j = 0 ;
for (; j < vlen ; j++)
- if (!byte_diff(modifs + i, split, v[j]) && (v[j][split] == '=')) break ;
+ if (!memcmp(modifs + i, v[j], split) && (v[j][split] == '=')) break ;
if (j < vlen) v[j] = v[--vlen] ;
if (modifs[i + split]) v[vlen++] = modifs + i ;
}
diff --git a/src/libstddjb/env_string.c b/src/libstddjb/env_string.c
index 7f97859..d76e783 100644
--- a/src/libstddjb/env_string.c
+++ b/src/libstddjb/env_string.c
@@ -1,12 +1,13 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/stralloc.h>
#include <skalibs/env.h>
-int env_string (stralloc *sa, char const *const *envp, unsigned int envlen)
+int env_string (stralloc *sa, char const *const *envp, size_t envlen)
{
- unsigned int salen = sa->len ;
- register unsigned int i = 0 ;
+ size_t salen = sa->len ;
+ size_t i = 0 ;
for (; i < envlen ; i++)
{
if (!stralloc_cats(sa, envp[i]) || !stralloc_0(sa))
diff --git a/src/libstddjb/envalloc_make.c b/src/libstddjb/envalloc_make.c
index 1cc44b9..2c2e553 100644
--- a/src/libstddjb/envalloc_make.c
+++ b/src/libstddjb/envalloc_make.c
@@ -1,10 +1,11 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/env.h>
#include <skalibs/genalloc.h>
#include <skalibs/envalloc.h>
-int envalloc_make (genalloc *v, unsigned int argc, char const *s, unsigned int len)
+int envalloc_make (genalloc *v, size_t argc, char const *s, size_t len)
{
int wasnull = !v->s ;
if (!genalloc_readyplus(char const *, v, argc+1)) return 0 ;
diff --git a/src/libstddjb/envalloc_merge.c b/src/libstddjb/envalloc_merge.c
index 9134b84..84179f0 100644
--- a/src/libstddjb/envalloc_merge.c
+++ b/src/libstddjb/envalloc_merge.c
@@ -1,13 +1,14 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/bytestr.h>
#include <skalibs/env.h>
#include <skalibs/genalloc.h>
#include <skalibs/envalloc.h>
-int envalloc_merge (genalloc *v, char const *const *envp, unsigned int envlen, char const *modifs, unsigned int modiflen)
+int envalloc_merge (genalloc *v, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen)
{
- unsigned int n = envlen + 1 + byte_count(modifs, modiflen, '\0') ;
+ size_t n = envlen + 1 + byte_count(modifs, modiflen, '\0') ;
if (!genalloc_readyplus(char const *, v, n)) return 0 ;
n = env_merge(genalloc_s(char const *, v) + genalloc_len(char const *, v), n, envp, envlen, modifs, modiflen) ;
genalloc_setlen(char const *, v, genalloc_len(char const *, v) + n) ;
diff --git a/src/libstddjb/envalloc_uniq.c b/src/libstddjb/envalloc_uniq.c
index 181128a..cf60b44 100644
--- a/src/libstddjb/envalloc_uniq.c
+++ b/src/libstddjb/envalloc_uniq.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <string.h>
#include <errno.h>
#include <skalibs/bytestr.h>
#include <skalibs/genalloc.h>
@@ -8,24 +9,24 @@
int envalloc_uniq (genalloc *v, char delim)
{
unsigned int m = 0 ;
- register unsigned int i = 0 ;
+ size_t i = 0 ;
for (; i < genalloc_len(char const *, v) ; i++)
{
- register unsigned int j = i+1 ;
+ size_t j = i+1 ;
char const *s = genalloc_s(char const *, v)[i] ;
- unsigned int n = str_chr(s, delim) ;
+ size_t n = str_chr(s, delim) ;
if (delim && !s[n]) return (errno = EINVAL, -1) ;
for (; j < genalloc_len(char const *, v) ; j++)
{
- register char const **p = genalloc_s(char const *, v) ;
- if (!str_diffn(s, p[j], n))
+ char const **p = genalloc_s(char const *, v) ;
+ if (!strncmp(s, p[j], n))
{
- register unsigned int len = genalloc_len(char const *, v) - 1 ;
+ size_t len = genalloc_len(char const *, v) - 1 ;
genalloc_setlen(char const *, v, len) ;
p[j] = p[len] ;
m++ ;
}
}
}
- return (int)m ;
+ return m ;
}
diff --git a/src/libstddjb/error_temp.c b/src/libstddjb/error_temp.c
index 48a54f5..ce7576a 100644
--- a/src/libstddjb/error_temp.c
+++ b/src/libstddjb/error_temp.c
@@ -3,7 +3,7 @@
#include <errno.h>
#include <skalibs/error.h>
-int error_temp (register int e)
+int error_temp (int e)
{
if (error_isagain(e)) return 1 ;
switch (e)
diff --git a/src/libstddjb/fd_cat.c b/src/libstddjb/fd_cat.c
index 1853427..fdaf093 100644
--- a/src/libstddjb/fd_cat.c
+++ b/src/libstddjb/fd_cat.c
@@ -11,7 +11,7 @@ int fd_cat (int from, int to)
if (!iobuffer_init(&b, from, to)) return -1 ;
for (;;)
{
- register ssize_t r = iobuffer_fill(&b) ;
+ ssize_t r = iobuffer_fill(&b) ;
if (r < 0) goto err ;
else if (!r) break ;
if (!iobuffer_flush(&b)) goto err ;
diff --git a/src/libstddjb/fd_catn.c b/src/libstddjb/fd_catn.c
index b757853..c2ddd7a 100644
--- a/src/libstddjb/fd_catn.c
+++ b/src/libstddjb/fd_catn.c
@@ -15,7 +15,7 @@ size_t fd_catn (int from, int to, size_t n)
if (!iobuffer_init(&b, from, to)) return 0 ;
while (n >= IOBUFFER_SIZE)
{
- register ssize_t r = iobuffer_fill(&b) ;
+ ssize_t r = iobuffer_fill(&b) ;
if (r <= 0)
{
iobuffer_finish(&b) ;
diff --git a/src/libstddjb/fd_chdir.c b/src/libstddjb/fd_chdir.c
index e09656e..f506ccc 100644
--- a/src/libstddjb/fd_chdir.c
+++ b/src/libstddjb/fd_chdir.c
@@ -6,7 +6,7 @@
int fd_chdir (int d)
{
- register int r ;
+ int r ;
do
r = fchdir(d) ;
while ((r == -1) && (errno == EINTR)) ;
diff --git a/src/libstddjb/fd_chmod.c b/src/libstddjb/fd_chmod.c
index a70c537..109826e 100644
--- a/src/libstddjb/fd_chmod.c
+++ b/src/libstddjb/fd_chmod.c
@@ -9,7 +9,7 @@
int fd_chmod (int fd, unsigned int mode)
{
- register int r ;
+ int r ;
do
r = fchmod(fd, (mode_t)mode) ;
while ((r == -1) && (errno == EINTR)) ;
diff --git a/src/libstddjb/fd_chown.c b/src/libstddjb/fd_chown.c
index f4915ae..8b0028f 100644
--- a/src/libstddjb/fd_chown.c
+++ b/src/libstddjb/fd_chown.c
@@ -7,7 +7,7 @@
int fd_chown (int fd, uid_t uid, gid_t gid)
{
- register int r ;
+ int r ;
do
r = fchown(fd, uid, gid) ;
while ((r == -1) && (errno == EINTR)) ;
diff --git a/src/libstddjb/fd_copy.c b/src/libstddjb/fd_copy.c
index b051eaf..80b887e 100644
--- a/src/libstddjb/fd_copy.c
+++ b/src/libstddjb/fd_copy.c
@@ -6,7 +6,7 @@
int fd_copy (int to, int from)
{
- register int r ;
+ int r ;
if (to == from) return (errno = EINVAL, -1) ;
do
r = dup2(from, to) ;
diff --git a/src/libstddjb/fd_ensure_open.c b/src/libstddjb/fd_ensure_open.c
index b399af2..40548c1 100644
--- a/src/libstddjb/fd_ensure_open.c
+++ b/src/libstddjb/fd_ensure_open.c
@@ -15,7 +15,7 @@ int fd_ensure_open (int fd, int w)
if (newfd < 0) return 0 ;
if (fd_move(fd, newfd) < 0)
{
- register int e = errno ;
+ int e = errno ;
fd_close(newfd) ;
errno = e ;
return 0 ;
diff --git a/src/libstddjb/fd_move.c b/src/libstddjb/fd_move.c
index d79f8ac..d84db80 100644
--- a/src/libstddjb/fd_move.c
+++ b/src/libstddjb/fd_move.c
@@ -6,7 +6,7 @@
int fd_move (int to, int from)
{
- register int r ;
+ int r ;
if (to == from) return 0 ;
do
r = dup2(from, to) ;
diff --git a/src/libstddjb/fd_move2.c b/src/libstddjb/fd_move2.c
index 7894e2f..e28c2cc 100644
--- a/src/libstddjb/fd_move2.c
+++ b/src/libstddjb/fd_move2.c
@@ -6,7 +6,7 @@
int fd_move2 (int to1, int from1, int to2, int from2)
{
- register int tmp = from2 ;
+ int tmp = from2 ;
if (to1 == from1) return fd_move(to2, from2) ;
if (to2 == from2) return fd_move(to1, from1) ;
if (from1 == from2) return (to1 == to2) ? fd_move(to1, from1) : (errno = EINVAL, -1) ;
@@ -18,14 +18,14 @@ int fd_move2 (int to1, int from1, int to2, int from2)
}
if (fd_copy(to1, from1) == -1)
{
- register int e = errno ;
+ int e = errno ;
if (from2 != tmp) fd_close(tmp) ;
errno = e ;
return -1 ;
}
if (fd_copy(to2, tmp) == -1)
{
- register int e = errno ;
+ int e = errno ;
fd_close(to1) ;
if (from2 != tmp) fd_move(from2, tmp) ;
errno = e ;
diff --git a/src/libstddjb/fd_readv.c b/src/libstddjb/fd_readv.c
index 11dda66..0d384a4 100644
--- a/src/libstddjb/fd_readv.c
+++ b/src/libstddjb/fd_readv.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <errno.h>
#include <skalibs/allreadwrite.h>
diff --git a/src/libstddjb/fd_recv.c b/src/libstddjb/fd_recv.c
index 4eb8659..781daa5 100644
--- a/src/libstddjb/fd_recv.c
+++ b/src/libstddjb/fd_recv.c
@@ -7,8 +7,8 @@
ssize_t fd_recv (int fd, char *buf, size_t len, unsigned int flags)
{
- register ssize_t r ;
- do r = recv(fd, buf, len, (int)flags) ;
+ ssize_t r ;
+ do r = recv(fd, buf, len, flags) ;
while ((r == -1) && (errno == EINTR)) ;
return r ;
}
diff --git a/src/libstddjb/fd_send.c b/src/libstddjb/fd_send.c
index 1d37bd5..b7ed939 100644
--- a/src/libstddjb/fd_send.c
+++ b/src/libstddjb/fd_send.c
@@ -7,8 +7,8 @@
ssize_t fd_send (int fd, char const *buf, size_t len, unsigned int flags)
{
- register ssize_t r ;
- do r = send(fd, buf, len, (int)flags) ;
+ ssize_t r ;
+ do r = send(fd, buf, len, flags) ;
while ((r == -1) && (errno == EINTR)) ;
return r ;
}
diff --git a/src/libstddjb/fd_sync.c b/src/libstddjb/fd_sync.c
index db54136..e978151 100644
--- a/src/libstddjb/fd_sync.c
+++ b/src/libstddjb/fd_sync.c
@@ -6,7 +6,7 @@
int fd_sync (int fd)
{
- register int r ;
+ int r ;
do
r = fsync(fd) ;
while ((r == -1) && (errno == EINTR)) ;
diff --git a/src/libstddjb/fd_writev.c b/src/libstddjb/fd_writev.c
index c54a20e..61f7132 100644
--- a/src/libstddjb/fd_writev.c
+++ b/src/libstddjb/fd_writev.c
@@ -1,13 +1,12 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <errno.h>
#include <skalibs/allreadwrite.h>
ssize_t fd_writev (int fd, struct iovec const *v, unsigned int vlen)
{
- register ssize_t r ;
+ ssize_t r ;
do r = writev(fd, v, vlen) ;
while ((r == -1) && (errno == EINTR)) ;
return r ;
diff --git a/src/libstddjb/fmtscan-internal.h b/src/libstddjb/fmtscan-internal.h
index 3c9f214..24e5774 100644
--- a/src/libstddjb/fmtscan-internal.h
+++ b/src/libstddjb/fmtscan-internal.h
@@ -5,9 +5,9 @@
#include <sys/types.h>
#include <stdint.h>
+#include <string.h>
#include <errno.h>
#include <limits.h>
-#include <skalibs/bytestr.h>
#include <skalibs/fmtscan.h>
#define SCANB(bits) \
@@ -18,7 +18,7 @@ size_t uint##bits##_scan_base (char const *s, uint##bits##_t *u, unsigned int ba
size_t pos = 0 ; \
for (;; pos++) \
{ \
- register unsigned char c = fmtscan_num(s[pos], base) ; \
+ unsigned char c = fmtscan_num(s[pos], base) ; \
if ((c >= base) || (result > ((max - c) / base))) break ; \
result = result * base + c ; \
} \
@@ -29,7 +29,7 @@ size_t uint##bits##_scan_base (char const *s, uint##bits##_t *u, unsigned int ba
#define SCANB0(bits) \
size_t uint##bits##0_scan_base (char const *s, uint##bits##_t *u, unsigned int base) \
{ \
- register size_t pos = uint##bits##_scan_base(s, u, base) ; \
+ 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 ; \
@@ -40,8 +40,8 @@ size_t uint##bits##0_scan_base (char const *s, uint##bits##_t *u, unsigned int b
size_t int##bits##_scan (char const *s, int##bits##_t *n) \
{ \
uint##bits##_t tmp ; \
- register size_t r = 0 ; \
- register unsigned int sign = 0 ; \
+ size_t r = 0 ; \
+ unsigned int sign = 0 ; \
if (*s == '-') \
{ \
r = 1 + uint##bits##_scan(s+1, &tmp) ; \
@@ -74,7 +74,7 @@ size_t int##bits##_scan (char const *s, int##bits##_t *n) \
#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) ; \
+ 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 ; \
@@ -87,10 +87,10 @@ size_t uint##bits##_scanlist (uint##bits##_t *tab, size_t max, char const *s, si
size_t i = 0, len = 0 ; \
for (; s[len] && (i < max) ; i++) \
{ \
- register size_t w = uint##bits##_scan(s + len, tab + i) ; \
+ 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++ ; \
+ while (memchr(",:; \t\r\n", s[len], 7)) len++ ; \
} \
*num = i ; \
return len ; \
@@ -102,10 +102,10 @@ size_t int##bits##_scanlist (int##bits##_t *tab, size_t max, char const *s, size
size_t i = 0, len = 0 ; \
for (; s[len] && (i < max) ; i++) \
{ \
- register size_t w = int##bits##_scan(s + len, tab + i) ; \
+ 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++ ; \
+ while (memchr(",:; \t\r\n", s[len], 7)) len++ ; \
} \
*num = i ; \
return len ; \
@@ -117,7 +117,7 @@ size_t uint##bits##_fmtlist (char *s, uint##bits##_t const *tab, size_t n) \
size_t i = 0, len = 0 ; \
for (; i < n ; i++) \
{ \
- register size_t w = uint##bits##_fmt(s, tab[i]) ; \
+ size_t w = uint##bits##_fmt(s, tab[i]) ; \
len += w ; \
if (s) \
{ \
@@ -131,9 +131,9 @@ size_t uint##bits##_fmtlist (char *s, uint##bits##_t const *tab, size_t n) \
#define FMTB(bits) \
size_t uint##bits##_fmt_base (char *s, uint##bits##_t x, unsigned int base) \
{ \
- register size_t len = 1 ; \
+ size_t len = 1 ; \
{ \
- register uint##bits##_t q = x ; \
+ uint##bits##_t q = x ; \
while (q >= base) { len++ ; q /= base ; } \
} \
if (s) \
@@ -145,9 +145,9 @@ size_t uint##bits##_fmt_base (char *s, uint##bits##_t x, unsigned int base) \
} \
#define FMTB0(bits) \
-size_t uint##bits##0_fmt_base (char *s, uint##bits##_t x, register size_t n, unsigned int base) \
+size_t uint##bits##0_fmt_base (char *s, uint##bits##_t x, size_t n, unsigned int base) \
{ \
- register size_t len = uint##bits##_fmt_base(0, x, base) ; \
+ size_t len = uint##bits##_fmt_base(0, x, base) ; \
while (n-- > len) *s++ = '0' ; \
return uint##bits##_fmt_base(s, x, base) ; \
} \
@@ -166,7 +166,7 @@ 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]) ; \
+ size_t w = int##bits##_fmt(s, tab[i]) ; \
len += w ; \
if (s) \
{ \
diff --git a/src/libstddjb/fmtscan_num.c b/src/libstddjb/fmtscan_num.c
index 094eb2a..d9fea33 100644
--- a/src/libstddjb/fmtscan_num.c
+++ b/src/libstddjb/fmtscan_num.c
@@ -2,7 +2,7 @@
#include <skalibs/fmtscan.h>
-unsigned char fmtscan_num (register unsigned char c, unsigned char n)
+unsigned char fmtscan_num (unsigned char c, unsigned char n)
{
return
((c < '0') || (n > 36)) ? n :
diff --git a/src/libstddjb/genalloc_deepfree.c b/src/libstddjb/genalloc_deepfree.c
index 29f1527..1684374 100644
--- a/src/libstddjb/genalloc_deepfree.c
+++ b/src/libstddjb/genalloc_deepfree.c
@@ -7,7 +7,7 @@
void genalloc_deepfree_size (genalloc *g, freefunc_t_ref f, size_t size)
{
size_t len = g->len / size ;
- register size_t i = 0 ;
+ size_t i = 0 ;
for (; i < len ; i++) (*f)(g->s + i * size) ;
stralloc_free(g) ;
}
diff --git a/src/libstddjb/genwrite_flush_bufalloc.c b/src/libstddjb/genwrite_flush_bufalloc.c
index 6383246..44832c7 100644
--- a/src/libstddjb/genwrite_flush_bufalloc.c
+++ b/src/libstddjb/genwrite_flush_bufalloc.c
@@ -5,6 +5,5 @@
int genwrite_flush_bufalloc (void *target)
{
- register bufalloc *ba = target ;
- return bufalloc_flush(ba) ;
+ return bufalloc_flush((bufalloc *)target) ;
}
diff --git a/src/libstddjb/genwrite_flush_buffer.c b/src/libstddjb/genwrite_flush_buffer.c
index d30f3e6..092ffb4 100644
--- a/src/libstddjb/genwrite_flush_buffer.c
+++ b/src/libstddjb/genwrite_flush_buffer.c
@@ -5,6 +5,5 @@
int genwrite_flush_buffer (void *target)
{
- register buffer *b = target ;
- return buffer_flush(b) ;
+ return buffer_flush((buffer *)target) ;
}
diff --git a/src/libstddjb/genwrite_put_bufalloc.c b/src/libstddjb/genwrite_put_bufalloc.c
index 4b5830d..98a5919 100644
--- a/src/libstddjb/genwrite_put_bufalloc.c
+++ b/src/libstddjb/genwrite_put_bufalloc.c
@@ -6,6 +6,5 @@
ssize_t genwrite_put_bufalloc (void *target, char const *s, size_t len)
{
- register bufalloc *ba = target ;
- return bufalloc_put(ba, s, len) ? (ssize_t)len : -1 ;
+ return bufalloc_put((bufalloc *)target, s, len) ? (ssize_t)len : -1 ;
}
diff --git a/src/libstddjb/genwrite_put_buffer.c b/src/libstddjb/genwrite_put_buffer.c
index e5d7843..8a710b9 100644
--- a/src/libstddjb/genwrite_put_buffer.c
+++ b/src/libstddjb/genwrite_put_buffer.c
@@ -6,6 +6,5 @@
ssize_t genwrite_put_buffer (void *target, char const *s, size_t len)
{
- register buffer *b = target ;
- return buffer_put(b, s, len) ;
+ return buffer_put((buffer *)target, s, len) ;
}
diff --git a/src/libstddjb/genwrite_put_stralloc.c b/src/libstddjb/genwrite_put_stralloc.c
index 6f1e2b7..14583fb 100644
--- a/src/libstddjb/genwrite_put_stralloc.c
+++ b/src/libstddjb/genwrite_put_stralloc.c
@@ -6,6 +6,5 @@
ssize_t genwrite_put_stralloc (void *target, char const *s, size_t len)
{
- register stralloc *sa = target ;
- return stralloc_catb(sa, s, len) ? (ssize_t)len : -1 ;
+ return stralloc_catb((stralloc *)target, s, len) ? (ssize_t)len : -1 ;
}
diff --git a/src/libstddjb/getlnmax.c b/src/libstddjb/getlnmax.c
index 6f6783a..7f7d679 100644
--- a/src/libstddjb/getlnmax.c
+++ b/src/libstddjb/getlnmax.c
@@ -1,10 +1,9 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <errno.h>
-#include <skalibs/bytestr.h>
#include <skalibs/buffer.h>
+#include <skalibs/siovec.h>
#include <skalibs/skamisc.h>
int getlnmax (buffer *b, char *d, size_t max, size_t *w, char sep)
diff --git a/src/libstddjb/getlnmaxsep.c b/src/libstddjb/getlnmaxsep.c
index 8505417..7b7dc0e 100644
--- a/src/libstddjb/getlnmaxsep.c
+++ b/src/libstddjb/getlnmaxsep.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <errno.h>
#include <skalibs/buffer.h>
diff --git a/src/libstddjb/getpeereid.c b/src/libstddjb/getpeereid.c
index bf70aca..581aac1 100644
--- a/src/libstddjb/getpeereid.c
+++ b/src/libstddjb/getpeereid.c
@@ -19,7 +19,7 @@
int getpeereid (int s, uid_t *u, gid_t *g)
{
struct ucred blah ;
- unsigned int len = sizeof(blah) ;
+ socklen_t len = sizeof(blah) ;
if (getsockopt(s, SOL_SOCKET, SO_PEERCRED, &blah, &len) == -1)
return -1 ;
diff --git a/src/libstddjb/hiercopy.c b/src/libstddjb/hiercopy.c
index 34f027e..3fc4d2f 100644
--- a/src/libstddjb/hiercopy.c
+++ b/src/libstddjb/hiercopy.c
@@ -1,7 +1,7 @@
/* ISC license. */
-#include <skalibs/djbunix.h>
#include <skalibs/skamisc.h>
+#include <skalibs/djbunix.h>
int hiercopy (char const *src, char const *dst)
{
diff --git a/src/libstddjb/hiercopy_tmp.c b/src/libstddjb/hiercopy_tmp.c
index ef76b57..79b7b46 100644
--- a/src/libstddjb/hiercopy_tmp.c
+++ b/src/libstddjb/hiercopy_tmp.c
@@ -1,9 +1,8 @@
/* ISC license. */
-#include <sys/types.h>
-#include <sys/stat.h>
#include <string.h>
#include <unistd.h>
+#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <skalibs/strerr2.h>
diff --git a/src/libstddjb/iobuffer_fill.c b/src/libstddjb/iobuffer_fill.c
index 991dffc..a122090 100644
--- a/src/libstddjb/iobuffer_fill.c
+++ b/src/libstddjb/iobuffer_fill.c
@@ -1,13 +1,14 @@
/* ISC license. */
+#include <sys/types.h>
#include <errno.h>
#include <skalibs/iobuffer.h>
-int iobuffer_fill (iobuffer_ref b)
+ssize_t iobuffer_fill (iobuffer_ref b)
{
if (b->isk)
{
- register int r = iobufferk_fill(&b->x.k) ;
+ ssize_t r = iobufferk_fill(&b->x.k) ;
if (r >= 0 || errno != ENOSYS || !iobuffer_salvage(b)) return r ;
}
return iobufferu_fill(&b->x.u) ;
diff --git a/src/libstddjb/iobuffer_kfromu.c b/src/libstddjb/iobuffer_kfromu.c
index 7942541..91525a5 100644
--- a/src/libstddjb/iobuffer_kfromu.c
+++ b/src/libstddjb/iobuffer_kfromu.c
@@ -9,7 +9,6 @@
#include <sys/uio.h>
#include <skalibs/buffer.h>
#include <skalibs/iobuffer.h>
-#include <skalibs/siovec.h>
int iobuffer_kfromu (iobufferk *k, iobufferu *u)
{
diff --git a/src/libstddjb/iobuffer_ufromk.c b/src/libstddjb/iobuffer_ufromk.c
index 778ddf2..940818d 100644
--- a/src/libstddjb/iobuffer_ufromk.c
+++ b/src/libstddjb/iobuffer_ufromk.c
@@ -4,6 +4,7 @@
#ifdef SKALIBS_HASSPLICE
+#include <sys/types.h>
#include <skalibs/iobuffer.h>
int iobuffer_ufromk (iobufferu *u, iobufferk *k)
@@ -12,7 +13,7 @@ int iobuffer_ufromk (iobufferu *u, iobufferk *k)
u->b[0].fd = k->p[0] ;
while (k->n)
{
- register int r = iobufferu_fill(u) ;
+ ssize_t r = iobufferu_fill(u) ;
if (r <= 0) goto err ;
k->n -= r ;
}
diff --git a/src/libstddjb/iobufferk_fill.c b/src/libstddjb/iobufferk_fill.c
index c811c24..0ae8763 100644
--- a/src/libstddjb/iobufferk_fill.c
+++ b/src/libstddjb/iobufferk_fill.c
@@ -9,30 +9,30 @@
#include <errno.h>
#include <skalibs/iobuffer.h>
-static int iobufferk_tee (iobufferk *k)
+static ssize_t iobufferk_tee (iobufferk *k)
{
- register int r = tee(k->fd[0], k->fd[1], IOBUFFERK_SIZE - k->n, k->nb & 1 ? SPLICE_F_NONBLOCK : 0) ;
+ ssize_t r = tee(k->fd[0], k->fd[1], IOBUFFERK_SIZE - k->n, k->nb & 1 ? SPLICE_F_NONBLOCK : 0) ;
if (r > 0) k->n += r ;
return r ;
}
-static int iobufferk_splice (iobufferk *k)
+static ssize_t iobufferk_splice (iobufferk *k)
{
- register int r = splice(k->fd[0], 0, k->fd[1], 0, IOBUFFERK_SIZE, k->nb ? SPLICE_F_NONBLOCK : 0) ;
+ ssize_t r = splice(k->fd[0], 0, k->fd[1], 0, IOBUFFERK_SIZE, k->nb ? SPLICE_F_NONBLOCK : 0) ;
if (r > 0) k->n += r ;
if ((r < 0) && (errno == EINVAL)) errno = ENOSYS ;
return r ;
}
-static int iobufferk_fill_3 (iobufferk *k)
+static ssize_t iobufferk_fill_3 (iobufferk *k)
{
- register int r = splice(k->fd[0], 0, k->p[1], 0, IOBUFFERK_SIZE - k->n, k->nb & 1 ? SPLICE_F_NONBLOCK : 0) ;
+ ssize_t r = splice(k->fd[0], 0, k->p[1], 0, IOBUFFERK_SIZE - k->n, k->nb & 1 ? SPLICE_F_NONBLOCK : 0) ;
if (r > 0) k->n += r ;
if ((r < 0) && (errno == EINVAL)) errno = ENOSYS ;
return r ;
}
-iobufferk_io_func_t_ref const iobufferk_fill_f[4] =
+iobufferk_input_func_t_ref const iobufferk_fill_f[4] =
{
&iobufferk_tee, &iobufferk_splice, &iobufferk_splice, &iobufferk_fill_3
} ;
@@ -41,9 +41,15 @@ iobufferk_io_func_t_ref const iobufferk_fill_f[4] =
#include <skalibs/iobuffer.h>
-iobufferk_io_func_t_ref const iobufferk_fill_f[4] =
+static ssize_t iobufferk_inosys (iobufferk *k)
{
- &iobufferk_nosys, &iobufferk_nosys, &iobufferk_nosys, &iobufferk_nosys
+ (void)k ;
+ return (errno = ENOSYS, -1) ;
+}
+
+iobufferk_input_func_t_ref const iobufferk_fill_f[4] =
+{
+ &iobufferk_inosys, &iobufferk_inosys, &iobufferk_inosys, &iobufferk_inosys
} ;
#endif
diff --git a/src/libstddjb/iobufferk_flush.c b/src/libstddjb/iobufferk_flush.c
index 674ffec..9bbff7d 100644
--- a/src/libstddjb/iobufferk_flush.c
+++ b/src/libstddjb/iobufferk_flush.c
@@ -13,7 +13,7 @@ static int iobufferk_flush_0 (iobufferk *k)
{
while (k->n)
{
- register int r = splice(k->fd[0], 0, k->p[1], 0, k->n, 0) ;
+ ssize_t r = splice(k->fd[0], 0, k->p[1], 0, k->n, 0) ;
if (r < 0) return 0 ;
else if (!r) break ;
k->n -= r ;
@@ -31,7 +31,7 @@ static int iobufferk_flush_3 (iobufferk *k)
{
while (k->n)
{
- register int r = splice(k->p[0], 0, k->fd[1], 0, k->n, SPLICE_F_MORE | (k->nb & 2 ? SPLICE_F_NONBLOCK : 0)) ;
+ ssize_t r = splice(k->p[0], 0, k->fd[1], 0, k->n, SPLICE_F_MORE | (k->nb & 2 ? SPLICE_F_NONBLOCK : 0)) ;
if (r < 0)
{
if (errno == EINVAL) errno = ENOSYS ;
@@ -43,7 +43,7 @@ static int iobufferk_flush_3 (iobufferk *k)
return 1 ;
}
-iobufferk_io_func_t_ref const iobufferk_flush_f[4] =
+iobufferk_output_func_t_ref const iobufferk_flush_f[4] =
{
&iobufferk_flush_0, &fakeflush, &fakeflush, &iobufferk_flush_3
} ;
@@ -53,9 +53,15 @@ iobufferk_io_func_t_ref const iobufferk_flush_f[4] =
#include <errno.h>
#include <skalibs/iobuffer.h>
-iobufferk_io_func_t_ref const iobufferk_flush_f[4] =
+static int iobufferk_onosys (iobuffer_k *k)
{
- &iobufferk_nosys, &iobufferk_nosys, &iobufferk_nosys, &iobufferk_nosys
+ (void)k ;
+ return (errno = ENOSYS, -1) ;
+}
+
+iobufferk_output_func_t_ref const iobufferk_flush_f[4] =
+{
+ &iobufferk_onosys, &iobufferk_onosys, &iobufferk_onosys, &iobufferk_onosys
} ;
#endif
diff --git a/src/libstddjb/iobufferk_init.c b/src/libstddjb/iobufferk_init.c
index 7affabd..93cd615 100644
--- a/src/libstddjb/iobufferk_init.c
+++ b/src/libstddjb/iobufferk_init.c
@@ -11,7 +11,7 @@
static int iobufferk_init_0 (iobufferk *k)
{
- register int fd = open_write("/dev/null") ;
+ int fd = open_write("/dev/null") ;
if (fd < 0) return 0 ;
if (coe(fd) < 0)
{
@@ -34,7 +34,7 @@ static int iobufferk_init_3 (iobufferk *k)
return (pipenbcoe(k->p) >= 0) ;
}
-static iobufferk_io_func_t_ref iobufferk_init_f[4] =
+static iobufferk_output_func_t_ref iobufferk_init_f[4] =
{
&iobufferk_init_0, &iobufferk_nofd, &iobufferk_nofd, &iobufferk_init_3
} ;
@@ -43,7 +43,7 @@ int iobufferk_init (iobufferk *k, int fdin, int fdout)
{
iobufferk tmp ;
struct stat st ;
- register int r ;
+ int r ;
if (fstat(fdin, &st) < 0) return 0 ;
r = fcntl(fdin, F_GETFL) ;
if (r < 0) return 0 ;
diff --git a/src/libstddjb/iobufferk_isworking.c b/src/libstddjb/iobufferk_isworking.c
index f671f81..119d130 100644
--- a/src/libstddjb/iobufferk_isworking.c
+++ b/src/libstddjb/iobufferk_isworking.c
@@ -17,7 +17,7 @@ int iobufferk_isworking (iobufferk *k)
# if 0
- register int e = errno ;
+ int e = errno ;
if (splice(k->fd[0], 0, k->p[1], 0, 0, 0) < 0) goto no ;
if (splice(k->p[0], 0, k->fd[1], 0, 0, 0) < 0) goto no ;
errno = e ;
@@ -45,4 +45,3 @@ int iobufferk_isworking (iobufferk *k)
}
#endif
-
diff --git a/src/libstddjb/iobufferk_nosys.c b/src/libstddjb/iobufferk_nosys.c
deleted file mode 100644
index 363e400..0000000
--- a/src/libstddjb/iobufferk_nosys.c
+++ /dev/null
@@ -1,10 +0,0 @@
-/* ISC license. */
-
-#include <errno.h>
-#include <skalibs/iobuffer.h>
-
-int iobufferk_nosys (iobufferk *k)
-{
- (void)k ;
- return (errno = ENOSYS, -1) ;
-}
diff --git a/src/libstddjb/iobufferu_fill.c b/src/libstddjb/iobufferu_fill.c
index de1a56c..7867444 100644
--- a/src/libstddjb/iobufferu_fill.c
+++ b/src/libstddjb/iobufferu_fill.c
@@ -3,9 +3,9 @@
#include <skalibs/buffer.h>
#include <skalibs/iobuffer.h>
-int iobufferu_fill (iobufferu *b)
+ssize_t iobufferu_fill (iobufferu *b)
{
- register int r = buffer_fill(&b->b[0]) ;
+ ssize_t r = buffer_fill(&b->b[0]) ;
b->b[1].c.n = b->b[0].c.n ;
return r ;
}
diff --git a/src/libstddjb/iobufferu_flush.c b/src/libstddjb/iobufferu_flush.c
index 8830599..ad0fd9e 100644
--- a/src/libstddjb/iobufferu_flush.c
+++ b/src/libstddjb/iobufferu_flush.c
@@ -5,7 +5,7 @@
int iobufferu_flush (iobufferu *b)
{
- register int r = buffer_flush(&b->b[1]) ;
+ int r = buffer_flush(&b->b[1]) ;
b->b[0].c.p = b->b[1].c.p ;
return r ;
}
diff --git a/src/libstddjb/iopause_poll.c b/src/libstddjb/iopause_poll.c
index e4e4da1..396122b 100644
--- a/src/libstddjb/iopause_poll.c
+++ b/src/libstddjb/iopause_poll.c
@@ -7,7 +7,7 @@
int iopause_poll (iopause_fd *x, unsigned int len, tain_t const *deadline, tain_t const *stamp)
{
- register int millisecs = 0 ;
+ int millisecs = 0 ;
if (!deadline) millisecs = -1 ;
else if (tain_less(stamp, deadline))
{
diff --git a/src/libstddjb/iopause_select.c b/src/libstddjb/iopause_select.c
index dd433b7..3e56705 100644
--- a/src/libstddjb/iopause_select.c
+++ b/src/libstddjb/iopause_select.c
@@ -34,7 +34,7 @@ int iopause_select (iopause_fd *x, unsigned int len, tain_t const *deadline, tai
}
{
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
for (; i < len ; i++)
{
x[i].revents = 0 ;
@@ -52,7 +52,7 @@ int iopause_select (iopause_fd *x, unsigned int len, tain_t const *deadline, tai
if (r > 0)
{
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
for (; i < len ; i++) if (x[i].fd >= 0)
{
if ((x[i].events & IOPAUSE_READ) && FD_ISSET(x[i].fd, &rfds))
diff --git a/src/libstddjb/iopause_stamp.c b/src/libstddjb/iopause_stamp.c
index d9a7e31..81056f4 100644
--- a/src/libstddjb/iopause_stamp.c
+++ b/src/libstddjb/iopause_stamp.c
@@ -4,9 +4,9 @@
#include <skalibs/tai.h>
#include <skalibs/iopause.h>
-extern int iopause_stamp (iopause_fd *x, unsigned int n, tain_t const *deadline, tain_t *stamp)
+int iopause_stamp (iopause_fd *x, unsigned int n, tain_t const *deadline, tain_t *stamp)
{
- register int r ;
+ int r ;
do
{
r = iopause(x, n, deadline, stamp) ;
diff --git a/src/libstddjb/ip46_scanlist.c b/src/libstddjb/ip46_scanlist.c
index 7ee2b68..d6d5cbc 100644
--- a/src/libstddjb/ip46_scanlist.c
+++ b/src/libstddjb/ip46_scanlist.c
@@ -1,9 +1,8 @@
/* ISC license. */
-#include <sys/types.h>
-#include <skalibs/ip46.h>
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/fmtscan.h>
+#include <skalibs/ip46.h>
size_t ip46full_scanlist (ip46full_t *out, size_t max, char const *s, size_t *num)
{
@@ -11,7 +10,7 @@ size_t ip46full_scanlist (ip46full_t *out, size_t max, char const *s, size_t *nu
for (; s[w] && (n < max) ; n++)
{
ip46full_t z ;
- register size_t i = ip6_scan(s + w, z.ip) ;
+ size_t i = ip6_scan(s + w, z.ip) ;
if (i) z.is6 = 1 ;
else
{
@@ -21,7 +20,7 @@ size_t ip46full_scanlist (ip46full_t *out, size_t max, char const *s, size_t *nu
}
out[n] = z ;
w += i ;
- while (byte_chr(",; \t\r\n", 6, s[w]) < 6) w++ ;
+ while (memchr(",; \t\r\n", s[w], 6)) w++ ;
}
*num = n ;
return w ;
diff --git a/src/libstddjb/ip4_scan.c b/src/libstddjb/ip4_scan.c
index 749a176..19c2cec 100644
--- a/src/libstddjb/ip4_scan.c
+++ b/src/libstddjb/ip4_scan.c
@@ -6,11 +6,11 @@
size_t ip4_scan (char const *s, char *ip)
{
size_t len = 0 ;
- register unsigned int j = 0 ;
+ unsigned int j = 0 ;
for (; j < 4 ; j++)
{
unsigned int u ;
- register size_t i = uint_scan(s, &u) ;
+ 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 edc2949..21985bd 100644
--- a/src/libstddjb/ip4_scanlist.c
+++ b/src/libstddjb/ip4_scanlist.c
@@ -1,7 +1,6 @@
/* ISC license. */
-#include <sys/types.h>
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/fmtscan.h>
size_t ip4_scanlist (char *out, size_t max, char const *s, size_t *num)
@@ -9,10 +8,10 @@ size_t ip4_scanlist (char *out, size_t max, char const *s, size_t *num)
size_t n = 0, w = 0 ;
for (; s[w] && (n < max) ; n++)
{
- register size_t i = ip4_scan(s + w, out + (n << 2)) ;
+ 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++ ;
+ while (memchr(",:; \t\r\n", s[w], 7)) w++ ;
}
*num = n ;
return w ;
diff --git a/src/libstddjb/ip4_scanlist_u32.c b/src/libstddjb/ip4_scanlist_u32.c
index 10c24cf..5515bca 100644
--- a/src/libstddjb/ip4_scanlist_u32.c
+++ b/src/libstddjb/ip4_scanlist_u32.c
@@ -1,9 +1,7 @@
/* ISC license. */
-#include <sys/types.h>
#include <stdint.h>
-#include <skalibs/uint32.h>
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/fmtscan.h>
size_t ip4_scanlist_u32 (uint32_t *out, size_t max, char const *s, size_t *num)
@@ -11,10 +9,10 @@ size_t ip4_scanlist_u32 (uint32_t *out, size_t max, char const *s, size_t *num)
size_t n = 0, w = 0 ;
for (; s[w] && (n < max) ; n++)
{
- register size_t i = ip4_scanu32(s + w, out + n) ;
+ 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++ ;
+ while (memchr(",:; \t\r\n", s[w], 7)) w++ ;
}
*num = n ;
return w ;
diff --git a/src/libstddjb/ip6_scan.c b/src/libstddjb/ip6_scan.c
index 1e34051..1837d3d 100644
--- a/src/libstddjb/ip6_scan.c
+++ b/src/libstddjb/ip6_scan.c
@@ -16,7 +16,7 @@ size_t ip6_scan (char const *s, char *ip6)
while (state < 5)
{
- register unsigned char c = table[state][class[(unsigned char)s[i]] - '0'] ;
+ unsigned char c = table[state][class[(unsigned char)s[i]] - '0'] ;
state = c & 7 ;
if (c & 0x20) { if (pos < 8) state = 5 ; else pos = j ; }
if (c & 0x10)
diff --git a/src/libstddjb/ip6_scanlist.c b/src/libstddjb/ip6_scanlist.c
index cf1c7fd..33eb055 100644
--- a/src/libstddjb/ip6_scanlist.c
+++ b/src/libstddjb/ip6_scanlist.c
@@ -1,7 +1,6 @@
/* ISC license. */
-#include <sys/types.h>
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/fmtscan.h>
size_t ip6_scanlist (char *out, size_t max, char const *s, size_t *num)
@@ -10,11 +9,11 @@ size_t ip6_scanlist (char *out, size_t max, char const *s, size_t *num)
for (; s[w] && (n < max) ; n++)
{
char ip[16] ;
- register size_t i = ip6_scan(s + w, ip) ;
+ size_t i = ip6_scan(s + w, ip) ;
if (!i) break ;
- byte_copy(out + (n << 4), 16, ip) ;
+ memcpy(out + (n << 4), ip, 16) ;
w += i ;
- while (byte_chr(",; \t\r\n", 6, s[w]) < 6) w++ ;
+ while (memchr(",; \t\r\n", s[w], 6)) w++ ;
}
*num = n ;
return w ;
diff --git a/src/libstddjb/ipc_accept.c b/src/libstddjb/ipc_accept.c
index dc3eae7..5ff82d8 100644
--- a/src/libstddjb/ipc_accept.c
+++ b/src/libstddjb/ipc_accept.c
@@ -5,16 +5,17 @@
#include <errno.h>
#include <sys/socket.h>
#include <sys/un.h>
+#include <string.h>
#include <skalibs/bytestr.h>
#include <skalibs/djbunix.h>
#include <skalibs/webipc.h>
-int ipc_accept_internal (int s, char *p, unsigned int l, int *trunc, unsigned int options)
+int ipc_accept_internal (int s, char *p, size_t l, int *trunc, unsigned int options)
{
struct sockaddr_un sa ;
socklen_t dummy = sizeof sa ;
- register int fd ;
- byte_zero((char*)&sa, (unsigned int)dummy) ;
+ int fd ;
+ memset(&sa, 0, dummy) ;
do
#ifdef SKALIBS_HASACCEPT4
fd = accept4(s, (struct sockaddr *)&sa, &dummy, ((options & DJBUNIX_FLAG_NB) ? SOCK_NONBLOCK : 0) | ((options & DJBUNIX_FLAG_COE) ? SOCK_CLOEXEC : 0)) ;
@@ -27,7 +28,7 @@ int ipc_accept_internal (int s, char *p, unsigned int l, int *trunc, unsigned in
if ((((options & DJBUNIX_FLAG_NB) ? ndelay_on(fd) : ndelay_off(fd)) < 0)
|| (((options & DJBUNIX_FLAG_COE) ? coe(fd) : uncoe(fd)) < 0))
{
- register int e = errno ;
+ int e = errno ;
fd_close(fd) ;
errno = e ;
return -1 ;
@@ -41,7 +42,7 @@ int ipc_accept_internal (int s, char *p, unsigned int l, int *trunc, unsigned in
if (!l) return fd ;
if (l < (dummy + 1)) dummy = l - 1 ;
else *trunc = 0 ;
- byte_copy(p, dummy, sa.sun_path) ;
+ memcpy(p, sa.sun_path, dummy) ;
p[dummy] = 0 ;
}
return fd ;
diff --git a/src/libstddjb/ipc_bind.c b/src/libstddjb/ipc_bind.c
index 2bb8678..8686591 100644
--- a/src/libstddjb/ipc_bind.c
+++ b/src/libstddjb/ipc_bind.c
@@ -3,18 +3,18 @@
#include <skalibs/nonposix.h>
#include <sys/socket.h>
#include <sys/un.h>
+#include <string.h>
#include <errno.h>
-#include <skalibs/bytestr.h>
#include <skalibs/error.h>
#include <skalibs/webipc.h>
int ipc_bind (int s, char const *p)
{
struct sockaddr_un sa ;
- register unsigned int l = str_len(p) ;
+ size_t l = strlen(p) ;
if (l > IPCPATH_MAX) return (errno = EPROTO, -1) ;
- byte_zero((char *)&sa, sizeof sa) ;
+ memset(&sa, 0, sizeof sa) ;
sa.sun_family = AF_UNIX ;
- byte_copy(sa.sun_path, l+1, p) ;
+ memcpy(sa.sun_path, p, l+1) ;
return bind(s, (struct sockaddr *)&sa, sizeof sa) ;
}
diff --git a/src/libstddjb/ipc_connect.c b/src/libstddjb/ipc_connect.c
index 6c5eac2..9aa4dd9 100644
--- a/src/libstddjb/ipc_connect.c
+++ b/src/libstddjb/ipc_connect.c
@@ -4,18 +4,18 @@
#include <errno.h>
#include <sys/socket.h>
#include <sys/un.h>
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/error.h>
#include <skalibs/webipc.h>
int ipc_connect (int s, char const *p)
{
struct sockaddr_un sa ;
- unsigned int l = str_len(p) ;
+ size_t l = strlen(p) ;
if (l > IPCPATH_MAX) return (errno = EPROTO, 0) ;
- byte_zero((char *) &sa, sizeof sa) ;
+ memset(&sa, 0, sizeof sa) ;
sa.sun_family = AF_UNIX ;
- byte_copy(sa.sun_path, l+1, p) ;
+ memcpy(sa.sun_path, p, l+1) ;
if (connect(s, (struct sockaddr *)&sa, sizeof sa) == -1)
{
if (errno == EINTR) errno = EINPROGRESS ;
diff --git a/src/libstddjb/ipc_connected.c b/src/libstddjb/ipc_connected.c
index 4965c9f..a079fd5 100644
--- a/src/libstddjb/ipc_connected.c
+++ b/src/libstddjb/ipc_connected.c
@@ -13,7 +13,7 @@ int ipc_connected (int s)
if (getpeername(s, (struct sockaddr *)&sa, &dummy) == -1)
{
char ch ;
- fd_read(s, &ch, 1) ; /* sets errno */
+ fd_read(s, &ch, 1) ;
return 0 ;
}
return 1 ;
diff --git a/src/libstddjb/ipc_eid.c b/src/libstddjb/ipc_eid.c
deleted file mode 100644
index 81f608a..0000000
--- a/src/libstddjb/ipc_eid.c
+++ /dev/null
@@ -1,15 +0,0 @@
-/* ISC license. */
-
-#include <sys/types.h>
-#include <skalibs/getpeereid.h>
-#include <skalibs/webipc.h>
-
-int ipc_eid (int s, unsigned int *u, unsigned int *g)
-{
- uid_t dummyu ;
- gid_t dummyg ;
- if (getpeereid(s, &dummyu, &dummyg) < 0) return -1 ;
- *u = (unsigned int)dummyu ;
- *g = (unsigned int)dummyg ;
- return 0 ;
-}
diff --git a/src/libstddjb/ipc_local.c b/src/libstddjb/ipc_local.c
index 57ffb37..e617264 100644
--- a/src/libstddjb/ipc_local.c
+++ b/src/libstddjb/ipc_local.c
@@ -3,21 +3,22 @@
#include <skalibs/nonposix.h>
#include <sys/socket.h>
#include <sys/un.h>
+#include <string.h>
#include <skalibs/bytestr.h>
#include <skalibs/webipc.h>
-int ipc_local (int s, char *p, unsigned int l, int *trunc)
+int ipc_local (int s, char *p, size_t l, int *trunc)
{
struct sockaddr_un sa ;
socklen_t dummy = sizeof sa ;
- byte_zero((char *)&sa, sizeof sa) ;
+ memset(&sa, 0, sizeof sa) ;
if (getsockname(s, (struct sockaddr *)&sa, &dummy) == -1) return -1 ;
dummy = byte_chr(sa.sun_path, dummy, 0) ;
*trunc = 1 ;
if (!l) return 0 ;
if (l < (dummy + 1)) dummy = l - 1 ;
else *trunc = 0 ;
- byte_copy(p, dummy, sa.sun_path) ;
+ memcpy(p, sa.sun_path, dummy) ;
p[dummy] = 0 ;
return 0 ;
}
diff --git a/src/libstddjb/ipc_recv.c b/src/libstddjb/ipc_recv.c
index 599bad8..5aa1c2b 100644
--- a/src/libstddjb/ipc_recv.c
+++ b/src/libstddjb/ipc_recv.c
@@ -4,16 +4,16 @@
#include <errno.h>
#include <sys/socket.h>
#include <sys/un.h>
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/error.h>
#include <skalibs/webipc.h>
-int ipc_recv (int fd, char *s, unsigned int len, char *path)
+ssize_t ipc_recv (int fd, char *s, size_t len, char *path)
{
struct sockaddr_un sa = { .sun_family = AF_UNIX } ;
socklen_t total = sizeof sa ;
char tmp[len] ;
- register int r ;
+ ssize_t r ;
do r = recvfrom(fd, tmp, len, 0, (struct sockaddr *)&sa, &total) ;
while ((r == -1) && (errno == EINTR)) ;
if (r < 0) return r ;
@@ -23,11 +23,11 @@ int ipc_recv (int fd, char *s, unsigned int len, char *path)
if (total == sizeof(sa_family_t)) path[0] = 0 ;
else
{
- unsigned int l = str_len(sa.sun_path) ;
+ size_t l = strlen(sa.sun_path) ;
if (l > IPCPATH_MAX) return (errno = EPROTO, -1) ;
- byte_copy(path, l+1, sa.sun_path) ;
+ memcpy(path, sa.sun_path, l+1) ;
}
}
- byte_copy(s, r, tmp) ;
+ memcpy(s, tmp, r) ;
return r ;
}
diff --git a/src/libstddjb/ipc_send.c b/src/libstddjb/ipc_send.c
index 0e71d98..967a64f 100644
--- a/src/libstddjb/ipc_send.c
+++ b/src/libstddjb/ipc_send.c
@@ -4,17 +4,17 @@
#include <errno.h>
#include <sys/socket.h>
#include <sys/un.h>
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/error.h>
#include <skalibs/webipc.h>
-int ipc_send (int fd, char const *s, unsigned int len, char const *path)
+ssize_t ipc_send (int fd, char const *s, size_t len, char const *path)
{
struct sockaddr_un sa ;
- register unsigned int l = str_len(path) ;
+ size_t l = strlen(path) ;
if (l > IPCPATH_MAX) return (errno = EPROTO, -1) ;
- byte_zero(&sa, sizeof sa) ;
+ memset(&sa, 0, sizeof sa) ;
sa.sun_family = AF_UNIX ;
- byte_copy(sa.sun_path, l+1, path) ;
+ memcpy(sa.sun_path, path, l+1) ;
return sendto(fd, s, len, 0, (struct sockaddr *)&sa, sizeof sa) ;
}
diff --git a/src/libstddjb/ipc_timed_connect.c b/src/libstddjb/ipc_timed_connect.c
index 4f8e73d..32e496e 100644
--- a/src/libstddjb/ipc_timed_connect.c
+++ b/src/libstddjb/ipc_timed_connect.c
@@ -14,7 +14,7 @@ int ipc_timed_connect (int s, char const *path, tain_t const *deadline, tain_t *
if (!error_isagain(errno) && !error_isalready(errno)) return 0 ;
for (;;)
{
- register int r = iopause_stamp(&x, 1, deadline, stamp) ;
+ int r = iopause_stamp(&x, 1, deadline, stamp) ;
if (r < 0) return 0 ;
else if (!r) return (errno = ETIMEDOUT, 0) ;
else if (x.revents & IOPAUSE_EXCEPT) return 0 ;
diff --git a/src/libstddjb/leapsecs_add.c b/src/libstddjb/leapsecs_add.c
index 4b75f7d..7473693 100644
--- a/src/libstddjb/leapsecs_add.c
+++ b/src/libstddjb/leapsecs_add.c
@@ -3,10 +3,10 @@
#include <skalibs/uint64.h>
#include "djbtime-internal.h"
-void leapsecs_add (uint64 *t, int hit)
+void leapsecs_add (uint64_t *t, int hit)
{
- uint64 u = *t ;
- register unsigned int i = 0 ;
+ uint64_t u = *t ;
+ unsigned int i = 0 ;
for (; i < leapsecs_table_len ; i++)
{
if (u < leapsecs_table[i]) break ;
diff --git a/src/libstddjb/leapsecs_sub.c b/src/libstddjb/leapsecs_sub.c
index f466fac..f5c1c9b 100644
--- a/src/libstddjb/leapsecs_sub.c
+++ b/src/libstddjb/leapsecs_sub.c
@@ -3,12 +3,12 @@
#include <skalibs/uint64.h>
#include "djbtime-internal.h"
-int leapsecs_sub (uint64 *t)
+int leapsecs_sub (uint64_t *t)
{
- uint64 u = *t ;
- uint64 d = 0 ;
- register unsigned int i = 0 ;
- register int hit = 0 ;
+ uint64_t u = *t ;
+ uint64_t d = 0 ;
+ unsigned int i = 0 ;
+ int hit = 0 ;
for (; i < leapsecs_table_len ; i++)
{
if (u < leapsecs_table[i]) break ;
diff --git a/src/libstddjb/leapsecs_table.c b/src/libstddjb/leapsecs_table.c
index fcf17fa..5fd538b 100644
--- a/src/libstddjb/leapsecs_table.c
+++ b/src/libstddjb/leapsecs_table.c
@@ -7,7 +7,7 @@
#include "djbtime-internal.h"
unsigned int const leapsecs_table_len = 27 ;
-static uint64 const leapsecs_table_[27] =
+static uint64_t const leapsecs_table_[27] =
{
TAI_MAGIC + 78796809,
TAI_MAGIC + 94694410,
@@ -37,4 +37,4 @@ static uint64 const leapsecs_table_[27] =
TAI_MAGIC + 1435708834,
TAI_MAGIC + 1483228835
} ;
-uint64 const *const leapsecs_table = leapsecs_table_ ;
+uint64_t const *const leapsecs_table = leapsecs_table_ ;
diff --git a/src/libstddjb/localtm_from_ltm64.c b/src/libstddjb/localtm_from_ltm64.c
index d549df9..e2cc382 100644
--- a/src/libstddjb/localtm_from_ltm64.c
+++ b/src/libstddjb/localtm_from_ltm64.c
@@ -5,14 +5,13 @@
#define _BSD_SOURCE
#endif
-#include <sys/types.h>
#include <errno.h>
#include <time.h>
#include <skalibs/uint64.h>
#include <skalibs/tai.h>
#include <skalibs/djbtime.h>
-int localtm_from_ltm64 (struct tm *l, uint64 uu, int tz)
+int localtm_from_ltm64 (struct tm *l, uint64_t uu, int tz)
{
if (uu < TAI_MAGIC) return (errno = EINVAL, 0) ;
uu -= TAI_MAGIC ;
diff --git a/src/libstddjb/localtm_from_sysclock.c b/src/libstddjb/localtm_from_sysclock.c
index 939bb21..d63a6d8 100644
--- a/src/libstddjb/localtm_from_sysclock.c
+++ b/src/libstddjb/localtm_from_sysclock.c
@@ -1,11 +1,10 @@
/* ISC license. */
-#include <sys/types.h>
#include <time.h>
#include <skalibs/uint64.h>
#include <skalibs/djbtime.h>
-int localtm_from_sysclock (struct tm *l, uint64 u, int tz)
+int localtm_from_sysclock (struct tm *l, uint64_t u, int tz)
{
if (!ltm64_from_sysclock(&u)) return 0 ;
return localtm_from_ltm64(l, u, tz) ;
diff --git a/src/libstddjb/localtm_from_tai.c b/src/libstddjb/localtm_from_tai.c
index ad12cf2..b6ddf47 100644
--- a/src/libstddjb/localtm_from_tai.c
+++ b/src/libstddjb/localtm_from_tai.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <time.h>
#include <skalibs/uint64.h>
#include <skalibs/tai.h>
@@ -8,7 +7,7 @@
int localtm_from_tai (struct tm *l, tai_t const *t, int tz)
{
- uint64 u ;
+ uint64_t u ;
if (!ltm64_from_tai(&u, t)) return 0 ;
return localtm_from_ltm64(l, u, tz) ;
}
diff --git a/src/libstddjb/localtm_from_utc.c b/src/libstddjb/localtm_from_utc.c
index 697621c..cbf6f31 100644
--- a/src/libstddjb/localtm_from_utc.c
+++ b/src/libstddjb/localtm_from_utc.c
@@ -1,11 +1,10 @@
/* ISC license. */
-#include <sys/types.h>
#include <time.h>
#include <skalibs/uint64.h>
#include <skalibs/djbtime.h>
-int localtm_from_utc (struct tm *l, uint64 u, int tz)
+int localtm_from_utc (struct tm *l, uint64_t u, int tz)
{
if (!ltm64_from_utc(&u)) return 0 ;
return localtm_from_ltm64(l, u, tz) ;
diff --git a/src/libstddjb/localtm_scan.c b/src/libstddjb/localtm_scan.c
index 62bf4c3..60bf61b 100644
--- a/src/libstddjb/localtm_scan.c
+++ b/src/libstddjb/localtm_scan.c
@@ -11,7 +11,7 @@ size_t localtm_scan (char const *s, struct tm *l)
struct tm ll = { .tm_isdst = -1 } ;
size_t n = 0 ;
unsigned int u ;
- register size_t i = uint_scan(s+n, &u) ;
+ size_t i = uint_scan(s+n, &u) ;
if (!i) goto fail ;
n += i ;
if (u < 1900) goto fail ;
diff --git a/src/libstddjb/localtmn_from_sysclock.c b/src/libstddjb/localtmn_from_sysclock.c
index 08e64b7..c52bca0 100644
--- a/src/libstddjb/localtmn_from_sysclock.c
+++ b/src/libstddjb/localtmn_from_sysclock.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <time.h>
#include <skalibs/tai.h>
#include <skalibs/djbtime.h>
diff --git a/src/libstddjb/localtmn_from_tain.c b/src/libstddjb/localtmn_from_tain.c
index 78cc051..f4858b7 100644
--- a/src/libstddjb/localtmn_from_tain.c
+++ b/src/libstddjb/localtmn_from_tain.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <time.h>
#include <skalibs/tai.h>
#include <skalibs/djbtime.h>
diff --git a/src/libstddjb/localtmn_scan.c b/src/libstddjb/localtmn_scan.c
index c9d4d19..d7fffe2 100644
--- a/src/libstddjb/localtmn_scan.c
+++ b/src/libstddjb/localtmn_scan.c
@@ -13,7 +13,7 @@ size_t localtmn_scan (char const *s, localtmn_t *l)
if (*s++ != '.') m.nano = 0 ;
else
{
- register size_t b = uint32_scan(s, &m.nano) ;
+ size_t b = uint32_scan(s, &m.nano) ;
if (!b) return 0 ;
n += b ;
}
diff --git a/src/libstddjb/lock_ex.c b/src/libstddjb/lock_ex.c
index 19b9a9c..2645fab 100644
--- a/src/libstddjb/lock_ex.c
+++ b/src/libstddjb/lock_ex.c
@@ -12,15 +12,13 @@
int lock_ex (int fd)
{
int r ;
- do
- r = flock(fd, LOCK_EX) ;
+ do r = flock(fd, LOCK_EX) ;
while ((r == -1) && (errno == EINTR)) ;
return r ;
}
#else
-#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <skalibs/djbunix.h>
@@ -28,8 +26,7 @@ int lock_ex (int fd)
int lock_ex (int fd)
{
int r ;
- do
- r = lockf(fd, F_LOCK, 0) ;
+ do r = lockf(fd, F_LOCK, 0) ;
while ((r == -1) && (errno == EINTR)) ;
return r ;
}
diff --git a/src/libstddjb/lock_exnb.c b/src/libstddjb/lock_exnb.c
index a1785a9..7d5302f 100644
--- a/src/libstddjb/lock_exnb.c
+++ b/src/libstddjb/lock_exnb.c
@@ -12,15 +12,13 @@
int lock_exnb (int fd)
{
int r ;
- do
- r = flock(fd, LOCK_EX | LOCK_NB) ;
+ do r = flock(fd, LOCK_EX | LOCK_NB) ;
while ((r == -1) && (errno == EINTR)) ;
return r ;
}
#else
-#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <skalibs/djbunix.h>
@@ -28,8 +26,7 @@ int lock_exnb (int fd)
int lock_exnb (int fd)
{
int r ;
- do
- r = lockf(fd, F_TLOCK, 0) ;
+ do r = lockf(fd, F_TLOCK, 0) ;
while ((r == -1) && (errno == EINTR)) ;
if ((r == -1) && (errno == EACCES)) errno = EAGAIN ;
return r ;
diff --git a/src/libstddjb/lock_sh.c b/src/libstddjb/lock_sh.c
index 4a42dc1..c942d0d 100644
--- a/src/libstddjb/lock_sh.c
+++ b/src/libstddjb/lock_sh.c
@@ -11,25 +11,22 @@
int lock_sh (int fd)
{
- register int r ;
- do
- r = flock(fd, LOCK_SH) ;
+ int r ;
+ do r = flock(fd, LOCK_SH) ;
while ((r == -1) && (errno == EINTR)) ;
return r ;
}
#else
-#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <skalibs/djbunix.h>
int lock_sh (int fd)
{
- register int r ;
- do
- r = lockf(fd, F_LOCK, 0) ;
+ int r ;
+ do r = lockf(fd, F_LOCK, 0) ;
while ((r == -1) && (errno == EINTR)) ;
return r ;
}
diff --git a/src/libstddjb/lock_shnb.c b/src/libstddjb/lock_shnb.c
index 6a8fd42..40c988d 100644
--- a/src/libstddjb/lock_shnb.c
+++ b/src/libstddjb/lock_shnb.c
@@ -11,25 +11,22 @@
int lock_shnb (int fd)
{
- register int r ;
- do
- r = flock(fd, LOCK_SH | LOCK_NB) ;
+ int r ;
+ do r = flock(fd, LOCK_SH | LOCK_NB) ;
while ((r == -1) && (errno == EINTR)) ;
return r ;
}
#else
-#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <skalibs/djbunix.h>
int lock_shnb (int fd)
{
- register int r ;
- do
- r = lockf(fd, F_TLOCK, 0) ;
+ int r ;
+ do r = lockf(fd, F_TLOCK, 0) ;
while ((r == -1) && (errno == EINTR)) ;
if ((r == -1) && (errno == EACCES)) errno = EAGAIN ;
return r ;
diff --git a/src/libstddjb/lock_un.c b/src/libstddjb/lock_un.c
index 099716a..a029a7c 100644
--- a/src/libstddjb/lock_un.c
+++ b/src/libstddjb/lock_un.c
@@ -11,25 +11,22 @@
int lock_un (int fd)
{
- register int r ;
- do
- r = flock(fd, LOCK_UN) ;
+ int r ;
+ do r = flock(fd, LOCK_UN) ;
while ((r == -1) && (errno == EINTR)) ;
return r ;
}
#else
-#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <skalibs/djbunix.h>
int lock_un (int fd)
{
- register int r ;
- do
- r = lockf(fd, F_ULOCK, 0) ;
+ int r ;
+ do r = lockf(fd, F_ULOCK, 0) ;
while ((r == -1) && (errno == EINTR)) ;
return r ;
}
diff --git a/src/libstddjb/ltm64_from_localtm.c b/src/libstddjb/ltm64_from_localtm.c
index 6169f04..78e59a4 100644
--- a/src/libstddjb/ltm64_from_localtm.c
+++ b/src/libstddjb/ltm64_from_localtm.c
@@ -1,13 +1,12 @@
/* ISC license. */
-#include <sys/types.h>
#include <errno.h>
#include <time.h>
-#include <skalibs/tai.h>
#include <skalibs/uint64.h>
+#include <skalibs/tai.h>
#include <skalibs/djbtime.h>
-int ltm64_from_localtm (uint64 *uu, struct tm const *l)
+int ltm64_from_localtm (uint64_t *uu, struct tm const *l)
{
struct tm ll = *l ;
time_t u = mktime(&ll) ;
diff --git a/src/libstddjb/ltm64_from_sysclock.c b/src/libstddjb/ltm64_from_sysclock.c
index 54aca39..f169c59 100644
--- a/src/libstddjb/ltm64_from_sysclock.c
+++ b/src/libstddjb/ltm64_from_sysclock.c
@@ -8,15 +8,15 @@
#include <skalibs/tai.h>
-int ltm64_from_sysclock (uint64 *u)
+int ltm64_from_sysclock (uint64_t *u)
{
- tai_t t = { *u + 10U } ;
+ tai_t t = { .x = *u + 10U } ;
return ltm64_from_tai(u, &t) ;
}
#else
-int ltm64_from_sysclock (uint64 *u)
+int ltm64_from_sysclock (uint64_t *u)
{
return ltm64_from_utc(u) ;
}
diff --git a/src/libstddjb/ltm64_from_tai.c b/src/libstddjb/ltm64_from_tai.c
index 9161a79..115c2cf 100644
--- a/src/libstddjb/ltm64_from_tai.c
+++ b/src/libstddjb/ltm64_from_tai.c
@@ -5,7 +5,7 @@
#include <skalibs/djbtime.h>
#include "djbtime-internal.h"
-int ltm64_from_tai (uint64 *u, tai_t const *t)
+int ltm64_from_tai (uint64_t *u, tai_t const *t)
{
switch (skalibs_tzisright())
{
diff --git a/src/libstddjb/ltm64_from_utc.c b/src/libstddjb/ltm64_from_utc.c
index 7e08eb1..cc96841 100644
--- a/src/libstddjb/ltm64_from_utc.c
+++ b/src/libstddjb/ltm64_from_utc.c
@@ -4,7 +4,7 @@
#include <skalibs/djbtime.h>
#include "djbtime-internal.h"
-int ltm64_from_utc (uint64 *u)
+int ltm64_from_utc (uint64_t *u)
{
switch (skalibs_tzisright())
{
diff --git a/src/libstddjb/mininetstring_read.c b/src/libstddjb/mininetstring_read.c
index f7c7a55..eaaaf99 100644
--- a/src/libstddjb/mininetstring_read.c
+++ b/src/libstddjb/mininetstring_read.c
@@ -1,12 +1,13 @@
/* ISC license. */
+#include <sys/types.h>
+#include <stdint.h>
#include <errno.h>
#include <skalibs/allreadwrite.h>
-#include <skalibs/uint32.h>
#include <skalibs/stralloc.h>
#include <skalibs/mininetstring.h>
-int mininetstring_read (int fd, stralloc *sa, uint32 *w)
+int mininetstring_read (int fd, stralloc *sa, uint32_t *w)
{
if (!*w)
{
@@ -15,8 +16,8 @@ int mininetstring_read (int fd, stralloc *sa, uint32 *w)
{
case -1 : return -1 ;
case 0 : return 0 ;
- case 1 : *w = ((uint32)pack[0] << 8) | (1U << 31) ; break ;
- case 2 : *w = ((uint32)pack[0] << 8) | (uint32)pack[1] | (1U << 30) ; break ;
+ case 1 : *w = ((uint32_t)pack[0] << 8) | (1U << 31) ; break ;
+ case 2 : *w = ((uint32_t)pack[0] << 8) | (uint32_t)pack[1] | (1U << 30) ; break ;
default : return (errno = EDOM, -1) ;
}
}
@@ -27,7 +28,7 @@ int mininetstring_read (int fd, stralloc *sa, uint32 *w)
{
case -1 : return -1 ;
case 0 : return (errno = EPIPE, -1) ;
- case 1 : *w |= (uint32)c | (1U << 30) ; *w &= ~(1U << 31) ; break ;
+ case 1 : *w |= (uint32_t)c | (1U << 30) ; *w &= ~(1U << 31) ; break ;
default : return (errno = EDOM, -1) ;
}
}
@@ -37,7 +38,7 @@ int mininetstring_read (int fd, stralloc *sa, uint32 *w)
*w &= ~(1U << 30) ;
}
{
- register unsigned int r = allread(fd, sa->s + sa->len, *w) ;
+ size_t r = allread(fd, sa->s + sa->len, *w) ;
sa->len += r ; *w -= r ;
}
return *w ? -1 : 1 ;
diff --git a/src/libstddjb/mininetstring_write.c b/src/libstddjb/mininetstring_write.c
index 5eddc7b..09833e2 100644
--- a/src/libstddjb/mininetstring_write.c
+++ b/src/libstddjb/mininetstring_write.c
@@ -1,12 +1,12 @@
/* ISC license. */
+#include <stdint.h>
#include <errno.h>
#include <skalibs/uint16.h>
-#include <skalibs/uint32.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/mininetstring.h>
-int mininetstring_write (int fd, char const *s, uint16 len, uint32 *w)
+int mininetstring_write (int fd, char const *s, uint16_t len, uint32_t *w)
{
if (!*w)
{
diff --git a/src/libstddjb/netstring_append.c b/src/libstddjb/netstring_append.c
index 88098a4..8a10d64 100644
--- a/src/libstddjb/netstring_append.c
+++ b/src/libstddjb/netstring_append.c
@@ -1,8 +1,7 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <skalibs/uint64.h>
-#include <skalibs/bytestr.h>
#include <skalibs/stralloc.h>
#include <skalibs/netstring.h>
@@ -12,8 +11,8 @@ int netstring_appendb (stralloc *sa, char const *s, size_t len)
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) ;
- byte_copy(sa->s + sa->len + n+1, len, s) ;
+ memcpy(sa->s + sa->len, fmt, n+1) ;
+ memcpy(sa->s + sa->len + n+1, s, len) ;
sa->s[sa->len + n+1 + len] = ',' ;
sa->len += n + 2 + len ;
return 1 ;
diff --git a/src/libstddjb/netstring_appendv.c b/src/libstddjb/netstring_appendv.c
index 1d9c290..652bd05 100644
--- a/src/libstddjb/netstring_appendv.c
+++ b/src/libstddjb/netstring_appendv.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <skalibs/uint64.h>
#include <skalibs/bytestr.h>
#include <skalibs/siovec.h>
@@ -11,16 +11,16 @@ int netstring_appendv (stralloc *sa, struct iovec const *v, unsigned int n)
{
char fmt[UINT64_FMT] ;
size_t len = 0, pos ;
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
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) ;
+ memcpy(sa->s + sa->len, fmt, pos+1) ;
sa->len += pos+1 ;
for (i = 0 ; i < n ; i++)
{
- byte_copy(sa->s + sa->len, v[i].iov_len, (char const *)v[i].iov_base) ;
+ memmove(sa->s + sa->len, v[i].iov_base, v[i].iov_len) ;
sa->len += v[i].iov_len ;
}
sa->s[sa->len++] = ',' ;
diff --git a/src/libstddjb/netstring_decode.c b/src/libstddjb/netstring_decode.c
index d129ea8..68c68e1 100644
--- a/src/libstddjb/netstring_decode.c
+++ b/src/libstddjb/netstring_decode.c
@@ -3,13 +3,13 @@
#include <sys/types.h>
#include <errno.h>
#include <skalibs/uint64.h>
-#include <skalibs/netstring.h>
#include <skalibs/stralloc.h>
+#include <skalibs/netstring.h>
ssize_t netstring_decode (stralloc *sa, char const *s, size_t len)
{
uint64_t nlen ;
- register size_t pos ;
+ size_t pos ;
if (!len) return 0 ;
pos = uint64_scan(s, &nlen) ;
if (pos >= len) return (errno = EINVAL, -1) ;
diff --git a/src/libstddjb/netstring_encode.c b/src/libstddjb/netstring_encode.c
index 6b2d0ea..786a4b1 100644
--- a/src/libstddjb/netstring_encode.c
+++ b/src/libstddjb/netstring_encode.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <skalibs/uint64.h>
#include <skalibs/netstring.h>
#include <skalibs/stralloc.h>
diff --git a/src/libstddjb/netstring_put.c b/src/libstddjb/netstring_put.c
index 692d2fc..13aa7e0 100644
--- a/src/libstddjb/netstring_put.c
+++ b/src/libstddjb/netstring_put.c
@@ -15,21 +15,21 @@ int netstring_put (buffer *b, char const *s, size_t len, size_t *written)
if (*written < n + 1)
{
size_t w = *written ;
- ssize_t r = buffer_putall(b, fmt, n+1, &w) ;
+ int r = buffer_putall(b, fmt, n+1, &w) ;
if (r < 0) return (*written = w, 0) ;
*written = n+1 ;
}
if (*written < n+1 + len)
{
size_t w = *written - (n+1) ;
- ssize_t r = buffer_putall(b, s, len, &w) ;
+ int r = buffer_putall(b, s, len, &w) ;
*written = w + (n+1) ;
if (r < 0) return (*written = n+1 + w, 0) ;
*written = n+1 + len ;
}
{
size_t w = 0 ;
- ssize_t r = buffer_putall(b, ",", 1, &w) ;
+ int r = buffer_putall(b, ",", 1, &w) ;
if (r < 0) return 0 ;
}
*written = 0 ;
diff --git a/src/libstddjb/ntp_from_tain.c b/src/libstddjb/ntp_from_tain.c
index 43d5a42..276a775 100644
--- a/src/libstddjb/ntp_from_tain.c
+++ b/src/libstddjb/ntp_from_tain.c
@@ -5,9 +5,9 @@
#include <skalibs/tai.h>
#include <skalibs/djbtime.h>
-int ntp_from_tain (uint64 *u, tain_t const *a)
+int ntp_from_tain (uint64_t *u, tain_t const *a)
{
- uint64 secs, frac ;
+ uint64_t secs, frac ;
if (!utc_from_tai(&secs, tain_secp(a))) return 0 ;
secs += NTP_OFFSET ;
if (secs < TAI_MAGIC + 2147483648UL) goto ifail ;
diff --git a/src/libstddjb/open2.c b/src/libstddjb/open2.c
index 780f345..1d2682e 100644
--- a/src/libstddjb/open2.c
+++ b/src/libstddjb/open2.c
@@ -7,9 +7,8 @@
int open2 (char const *s, unsigned int flags)
{
- register int r ;
- do
- r = open(s, (int)flags) ;
+ int r ;
+ do r = open(s, flags) ;
while ((r == -1) && (errno == EINTR)) ;
return r ;
}
diff --git a/src/libstddjb/open3.c b/src/libstddjb/open3.c
index f990d63..f52b8cd 100644
--- a/src/libstddjb/open3.c
+++ b/src/libstddjb/open3.c
@@ -8,8 +8,7 @@
int open3 (char const *s, unsigned int flags, unsigned int mode)
{
register int r ;
- do
- r = open(s, (int)flags, (mode_t)mode) ;
+ do r = open(s, flags, mode) ;
while ((r == -1) && (errno == EINTR)) ;
return r ;
}
diff --git a/src/libstddjb/open_readb.c b/src/libstddjb/open_readb.c
index a8b0518..6fcede1 100644
--- a/src/libstddjb/open_readb.c
+++ b/src/libstddjb/open_readb.c
@@ -4,9 +4,9 @@
int open_readb (char const *fn)
{
- register int fd = open_read(fn) ;
- if (fd == -1) return -1 ;
- if (ndelay_off(fd) == -1)
+ int fd = open_read(fn) ;
+ if (fd < 0) return -1 ;
+ if (ndelay_off(fd) < 0)
{
fd_close(fd) ;
return -1 ;
diff --git a/src/libstddjb/pathexec0.c b/src/libstddjb/pathexec0.c
index 5241452..bfddfdf 100644
--- a/src/libstddjb/pathexec0.c
+++ b/src/libstddjb/pathexec0.c
@@ -1,7 +1,5 @@
/* ISC license. */
-/* MT-unsafe */
-
#include <unistd.h>
#include <skalibs/djbunix.h>
diff --git a/src/libstddjb/pipe_internal.c b/src/libstddjb/pipe_internal.c
index d5354de..a1e8a8f 100644
--- a/src/libstddjb/pipe_internal.c
+++ b/src/libstddjb/pipe_internal.c
@@ -4,8 +4,13 @@
#ifdef SKALIBS_HASPIPE2
+#ifndef _NETBSD_SOURCE
#define _NETBSD_SOURCE
+#endif
+
+#ifndef _GNU_SOURCE
#define _GNU_SOURCE
+#endif
#include <unistd.h>
#include <fcntl.h>
@@ -34,7 +39,7 @@ int pipe_internal (int *p, unsigned int flags)
return 0 ;
err:
{
- register int e = errno ;
+ int e = errno ;
fd_close(pi[1]) ;
fd_close(pi[0]) ;
errno = e ;
diff --git a/src/libstddjb/prot_readgroups.c b/src/libstddjb/prot_readgroups.c
index 5559882..47cbfc7 100644
--- a/src/libstddjb/prot_readgroups.c
+++ b/src/libstddjb/prot_readgroups.c
@@ -5,7 +5,7 @@
#include <sys/types.h>
#include <grp.h>
#include <errno.h>
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/djbunix.h>
int prot_readgroups (char const *name, gid_t *tab, unsigned int max)
@@ -14,15 +14,15 @@ int prot_readgroups (char const *name, gid_t *tab, unsigned int max)
for (;;)
{
struct group *gr ;
- register char **member ;
+ char **member ;
errno = 0 ;
if (n >= max) break ;
gr = getgrent() ;
if (!gr) break ;
for (member = gr->gr_mem ; *member ; member++)
- if (!str_diff(name, *member)) break ;
+ if (!strcmp(name, *member)) break ;
if (*member) tab[n++] = gr->gr_gid ;
}
endgrent() ;
- return errno ? -1 : (int)n ;
+ return errno ? -1 : n ;
}
diff --git a/src/libstddjb/realpath.c b/src/libstddjb/realpath.c
deleted file mode 100644
index f286137..0000000
--- a/src/libstddjb/realpath.c
+++ /dev/null
@@ -1,11 +0,0 @@
-/* ISC license. */
-
-/* MT-unsafe */
-
-#include <skalibs/skamisc.h>
-#include <skalibs/djbunix.h>
-
-char *realpath (char const *name, char *buf)
-{
- return realpath_tmp(name, buf, &satmp) ;
-}
diff --git a/src/libstddjb/realpath_tmp.c b/src/libstddjb/realpath_tmp.c
deleted file mode 100644
index 8f877dd..0000000
--- a/src/libstddjb/realpath_tmp.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/* ISC license. */
-
-#include <limits.h>
-#include <errno.h>
-#include <skalibs/bytestr.h>
-#include <skalibs/stralloc.h>
-#include <skalibs/djbunix.h>
-
-#ifndef PATH_MAX
-# define PATH_MAX 4095
-#endif
-
-char *realpath_tmp (char const *name, char *buf, stralloc *tmp)
-{
- unsigned int tmpbase = tmp->len ;
- if (sarealpath(tmp, name) == -1) return (char *)0 ;
- if (tmp->len - tmpbase > PATH_MAX)
- {
- tmp->len = tmpbase ;
- return (errno = ENAMETOOLONG, (char *)0) ;
- }
- byte_copy(buf, tmp->len - tmpbase, tmp->s + tmpbase) ;
- buf[tmp->len - tmpbase] = 0 ;
- tmp->len = tmpbase ;
- return buf ;
-}
diff --git a/src/libstddjb/sabasename.c b/src/libstddjb/sabasename.c
index 8d9b6fc..dff30a5 100644
--- a/src/libstddjb/sabasename.c
+++ b/src/libstddjb/sabasename.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <skalibs/bytestr.h>
#include <skalibs/stralloc.h>
#include <skalibs/djbunix.h>
diff --git a/src/libstddjb/sadirname.c b/src/libstddjb/sadirname.c
index ac818e8..176f26a 100644
--- a/src/libstddjb/sadirname.c
+++ b/src/libstddjb/sadirname.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <skalibs/bytestr.h>
#include <skalibs/stralloc.h>
#include <skalibs/djbunix.h>
diff --git a/src/libstddjb/sagetcwd.c b/src/libstddjb/sagetcwd.c
index d8c5dea..90f9aae 100644
--- a/src/libstddjb/sagetcwd.c
+++ b/src/libstddjb/sagetcwd.c
@@ -2,13 +2,13 @@
#include <unistd.h>
#include <errno.h>
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/stralloc.h>
#include <skalibs/djbunix.h>
int sagetcwd (stralloc *sa)
{
- unsigned int n = 128 ;
+ size_t n = 128 ;
int wasnull = !sa->s ;
for (;;)
@@ -18,7 +18,7 @@ int sagetcwd (stralloc *sa)
if (errno != ERANGE) goto err ;
n += 128 ;
}
- sa->len += str_len(sa->s + sa->len) ;
+ sa->len += strlen(sa->s + sa->len) ;
return 0 ;
err:
diff --git a/src/libstddjb/sagethostname.c b/src/libstddjb/sagethostname.c
index 500a95c..b20db39 100644
--- a/src/libstddjb/sagethostname.c
+++ b/src/libstddjb/sagethostname.c
@@ -1,13 +1,13 @@
/* ISC license. */
#include <unistd.h>
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/stralloc.h>
#include <skalibs/djbunix.h>
int sagethostname (stralloc *sa)
{
- unsigned int n = 128 ;
+ size_t n = 128 ;
int wasnull = !sa->s ;
for (;;)
@@ -18,7 +18,7 @@ int sagethostname (stralloc *sa)
if (!sa->s[sa->len + n - 2]) break ;
n += 128 ;
}
- sa->len += str_len(sa->s + sa->len) ;
+ sa->len += strlen(sa->s + sa->len) ;
return 0 ;
err:
diff --git a/src/libstddjb/sareadlink.c b/src/libstddjb/sareadlink.c
index d6c2a4e..90810e9 100644
--- a/src/libstddjb/sareadlink.c
+++ b/src/libstddjb/sareadlink.c
@@ -6,16 +6,16 @@
int sareadlink (stralloc *sa, char const *path)
{
- unsigned int n = 128 ;
+ size_t n = 128 ;
int wasnull = !sa->s ;
- register int r ;
+ ssize_t r ;
for (;;)
{
if (!stralloc_readyplus(sa, n)) goto err ;
r = readlink(path, sa->s + sa->len, n) ;
if (r < 0) goto err ;
- if ((unsigned int)r < n) break ;
+ if ((size_t)r < n) break ;
n += 128 ;
}
sa->len += r ;
diff --git a/src/libstddjb/sauniquename.c b/src/libstddjb/sauniquename.c
index ff102fa..c015dc3 100644
--- a/src/libstddjb/sauniquename.c
+++ b/src/libstddjb/sauniquename.c
@@ -9,17 +9,17 @@
int sauniquename (stralloc *sa)
{
- unsigned int base = sa->len ;
+ size_t base = sa->len ;
int wasnull = !sa->s ;
- if (!stralloc_readyplus(sa, TIMESTAMP + UINT_FMT + 131)) return 0 ;
+ if (!stralloc_readyplus(sa, TIMESTAMP + PID_FMT + 131)) return 0 ;
sa->s[base] = ':' ;
timestamp(sa->s + base + 1) ;
sa->s[base + 1 + TIMESTAMP] = ':' ;
sa->len = base + 2 + TIMESTAMP ;
sa->len += pid_fmt(sa->s + sa->len, getpid()) ;
sa->s[sa->len++] = ':' ;
- if (sagethostname(sa) == -1) goto err ;
+ if (sagethostname(sa) < 0) goto err ;
return 1 ;
err:
diff --git a/src/libstddjb/seek_cur.c b/src/libstddjb/seek_cur.c
deleted file mode 100644
index cdfdac7..0000000
--- a/src/libstddjb/seek_cur.c
+++ /dev/null
@@ -1,10 +0,0 @@
-/* ISC license. */
-
-#include <sys/types.h>
-#include <unistd.h>
-#include <skalibs/djbunix.h>
-
-long seek_cur (int fd)
-{
- return (long)lseek(fd, 0, SEEK_CUR) ;
-}
diff --git a/src/libstddjb/seek_set.c b/src/libstddjb/seek_set.c
deleted file mode 100644
index 70f6b0d..0000000
--- a/src/libstddjb/seek_set.c
+++ /dev/null
@@ -1,10 +0,0 @@
-/* ISC license. */
-
-#include <sys/types.h>
-#include <unistd.h>
-#include <skalibs/djbunix.h>
-
-int seek_set (int fd, long pos)
-{
- return lseek(fd, (off_t) pos, SEEK_SET) ;
-}
diff --git a/src/libstddjb/selfpipe_finish.c b/src/libstddjb/selfpipe_finish.c
index 47a889f..5d9b3fd 100644
--- a/src/libstddjb/selfpipe_finish.c
+++ b/src/libstddjb/selfpipe_finish.c
@@ -2,8 +2,8 @@
/* MT-unsafe */
-#include <signal.h>
#include <skalibs/sysdeps.h>
+#include <signal.h>
#include <skalibs/djbunix.h>
#include "selfpipe-internal.h"
#include <skalibs/selfpipe.h>
diff --git a/src/libstddjb/selfpipe_read.c b/src/libstddjb/selfpipe_read.c
index b68e67d..b31c6bd 100644
--- a/src/libstddjb/selfpipe_read.c
+++ b/src/libstddjb/selfpipe_read.c
@@ -3,6 +3,7 @@
/* MT-unsafe */
#include <skalibs/sysdeps.h>
+#include <sys/types.h>
#include <skalibs/allreadwrite.h>
#include "selfpipe-internal.h"
#include <skalibs/selfpipe.h>
@@ -14,7 +15,7 @@
int selfpipe_read (void)
{
struct signalfd_siginfo buf ;
- register int r = sanitize_read(fd_read(selfpipe_fd, (char *)&buf, sizeof(struct signalfd_siginfo))) ;
+ ssize_t r = sanitize_read(fd_read(selfpipe_fd, (char *)&buf, sizeof(struct signalfd_siginfo))) ;
return (r <= 0) ? r : (int)buf.ssi_signo ;
}
@@ -23,7 +24,7 @@ int selfpipe_read (void)
int selfpipe_read (void)
{
char c ;
- register int r = sanitize_read((fd_read(selfpipe_fd, &c, 1))) ;
+ ssize_t r = sanitize_read((fd_read(selfpipe_fd, &c, 1))) ;
return (r <= 0) ? r : (int)c ;
}
diff --git a/src/libstddjb/selfpipe_trapset.c b/src/libstddjb/selfpipe_trapset.c
index f8c35ee..ed09b50 100644
--- a/src/libstddjb/selfpipe_trapset.c
+++ b/src/libstddjb/selfpipe_trapset.c
@@ -39,7 +39,7 @@ int selfpipe_trapset (sigset_t const *set)
if (selfpipe_fd < 0) return (errno = EBADF, -1) ;
for (; i <= NSIG ; i++)
{
- register int h = sigismember(set, i) ;
+ int h = sigismember(set, i) ;
if (h < 0) continue ;
if (h)
{
diff --git a/src/libstddjb/selfpipe_untrap.c b/src/libstddjb/selfpipe_untrap.c
index 776f2d7..7d82cf4 100644
--- a/src/libstddjb/selfpipe_untrap.c
+++ b/src/libstddjb/selfpipe_untrap.c
@@ -16,7 +16,7 @@ int selfpipe_untrap (int sig)
{
sigset_t ss = selfpipe_caught ;
sigset_t blah ;
- register int r = sigismember(&selfpipe_caught, sig) ;
+ int r = sigismember(&selfpipe_caught, sig) ;
if (selfpipe_fd < 0) return (errno = EBADF, -1) ;
if (r < 0) return -1 ;
if (!r) return (errno = EINVAL, -1) ;
@@ -42,7 +42,7 @@ int selfpipe_untrap (int sig)
int selfpipe_untrap (int sig)
{
- register int r = sigismember(&selfpipe_caught, sig) ;
+ int r = sigismember(&selfpipe_caught, sig) ;
if (selfpipe_fd < 0) return (errno = EBADF, -1) ;
if (r < 0) return -1 ;
if (!r) return (errno = EINVAL, -1) ;
diff --git a/src/libstddjb/sig_number.c b/src/libstddjb/sig_number.c
index cbd897d..a588abd 100644
--- a/src/libstddjb/sig_number.c
+++ b/src/libstddjb/sig_number.c
@@ -1,12 +1,12 @@
/* ISC license. */
-#include <skalibs/bytestr.h>
+#include <strings.h>
#include <skalibs/sig.h>
#include "sig-internal.h"
int sig_number (char const *name)
{
- register sigtable_t const *p = skalibs_sigtable ;
- for (; p->name ; p++) if (!case_diffs(name, p->name)) break ;
+ sigtable_t const *p = skalibs_sigtable ;
+ for (; p->name ; p++) if (!strcasecmp(name, p->name)) break ;
return p->number ;
}
diff --git a/src/libstddjb/sig_restoreto.c b/src/libstddjb/sig_restoreto.c
index 523b14a..580ba32 100644
--- a/src/libstddjb/sig_restoreto.c
+++ b/src/libstddjb/sig_restoreto.c
@@ -7,10 +7,10 @@
void sig_restoreto (sigset_t const *set, unsigned int n)
{
- register unsigned int i = 1 ;
+ unsigned int i = 1 ;
for (; i <= n ; i++)
{
- register int h = sigismember(set, i) ;
+ int h = sigismember(set, i) ;
if (h < 0) continue ;
if (h) sig_restore(i) ;
}
diff --git a/src/libstddjb/siovec_bytechr.c b/src/libstddjb/siovec_bytechr.c
index 8c7e78c..295b949 100644
--- a/src/libstddjb/siovec_bytechr.c
+++ b/src/libstddjb/siovec_bytechr.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <skalibs/bytestr.h>
#include <skalibs/siovec.h>
diff --git a/src/libstddjb/siovec_bytein.c b/src/libstddjb/siovec_bytein.c
index bcf6e59..1d4200b 100644
--- a/src/libstddjb/siovec_bytein.c
+++ b/src/libstddjb/siovec_bytein.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <skalibs/bytestr.h>
#include <skalibs/siovec.h>
diff --git a/src/libstddjb/siovec_deal.c b/src/libstddjb/siovec_deal.c
index 3f802b9..9333358 100644
--- a/src/libstddjb/siovec_deal.c
+++ b/src/libstddjb/siovec_deal.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <string.h>
#include <skalibs/siovec.h>
diff --git a/src/libstddjb/siovec_gather.c b/src/libstddjb/siovec_gather.c
index b5fcbb7..c4138b6 100644
--- a/src/libstddjb/siovec_gather.c
+++ b/src/libstddjb/siovec_gather.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <string.h>
#include <skalibs/siovec.h>
diff --git a/src/libstddjb/siovec_len.c b/src/libstddjb/siovec_len.c
index 5465fd7..2f4f556 100644
--- a/src/libstddjb/siovec_len.c
+++ b/src/libstddjb/siovec_len.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <skalibs/siovec.h>
diff --git a/src/libstddjb/siovec_scatter.c b/src/libstddjb/siovec_scatter.c
index 3a583f3..d5ff1b2 100644
--- a/src/libstddjb/siovec_scatter.c
+++ b/src/libstddjb/siovec_scatter.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <string.h>
#include <skalibs/siovec.h>
diff --git a/src/libstddjb/siovec_seek.c b/src/libstddjb/siovec_seek.c
index f03b20a..44f8279 100644
--- a/src/libstddjb/siovec_seek.c
+++ b/src/libstddjb/siovec_seek.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <skalibs/bytestr.h>
#include <skalibs/siovec.h>
@@ -8,7 +7,7 @@
size_t siovec_seek (struct iovec *v, unsigned int n, size_t len)
{
size_t w = 0 ;
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
for (; i < n ; i++)
{
if (len < v[i].iov_len) break ;
diff --git a/src/libstddjb/siovec_trunc.c b/src/libstddjb/siovec_trunc.c
index ca40922..d71f9d9 100644
--- a/src/libstddjb/siovec_trunc.c
+++ b/src/libstddjb/siovec_trunc.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <skalibs/siovec.h>
diff --git a/src/libstddjb/skagetln_nofill.c b/src/libstddjb/skagetln_nofill.c
index ce28921..cbb4a31 100644
--- a/src/libstddjb/skagetln_nofill.c
+++ b/src/libstddjb/skagetln_nofill.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <skalibs/buffer.h>
#include <skalibs/siovec.h>
diff --git a/src/libstddjb/skagetlnsep.c b/src/libstddjb/skagetlnsep.c
index f9813f3..dc6d520 100644
--- a/src/libstddjb/skagetlnsep.c
+++ b/src/libstddjb/skagetlnsep.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <errno.h>
#include <skalibs/buffer.h>
diff --git a/src/libstddjb/skalibs_tzisright.c b/src/libstddjb/skalibs_tzisright.c
index f8414a6..ed24cc1 100644
--- a/src/libstddjb/skalibs_tzisright.c
+++ b/src/libstddjb/skalibs_tzisright.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <time.h>
#include "djbtime-internal.h"
diff --git a/src/libstddjb/skasigaction.c b/src/libstddjb/skasigaction.c
index bb55642..4b1ea8b 100644
--- a/src/libstddjb/skasigaction.c
+++ b/src/libstddjb/skasigaction.c
@@ -12,7 +12,7 @@ int skasigaction (int sig, struct skasigaction const *new, struct skasigaction *
if (sigaction(sig, &sanew, &saold) < 0) return -1 ;
if (old)
{
- register int r = sigismember(&saold.sa_mask, (sig == SIGTERM) ? SIGPIPE : SIGTERM) ;
+ int r = sigismember(&saold.sa_mask, (sig == SIGTERM) ? SIGPIPE : SIGTERM) ;
if (r < 0) return -1 ;
old->flags = 0 ;
if (r) old->flags |= SKASA_MASKALL ;
diff --git a/src/libstddjb/slurp.c b/src/libstddjb/slurp.c
index 553b29e..d5b3b43 100644
--- a/src/libstddjb/slurp.c
+++ b/src/libstddjb/slurp.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/stralloc.h>
#include <skalibs/djbunix.h>
@@ -8,10 +9,11 @@
int slurp (stralloc *sa, int fd)
{
- register unsigned int salen = sa->len ;
+ size_t salen = sa->len ;
+ int wasnull = !sa->s ;
for (;;)
{
- int r ;
+ ssize_t r ;
if (!stralloc_readyplus(sa, N)) break ;
r = fd_read(fd, sa->s + sa->len, N) ;
switch (r)
@@ -25,7 +27,11 @@ int slurp (stralloc *sa, int fd)
}
}
err:
- sa->len = salen ;
- stralloc_shrink(sa) ;
+ if (wasnull) stralloc_free(sa) ;
+ else
+ {
+ sa->len = salen ;
+ stralloc_shrink(sa) ;
+ }
return 0 ;
}
diff --git a/src/libstddjb/socket_accept4.c b/src/libstddjb/socket_accept4.c
index e504375..a50ade0 100644
--- a/src/libstddjb/socket_accept4.c
+++ b/src/libstddjb/socket_accept4.c
@@ -4,17 +4,18 @@
#include <skalibs/nonposix.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <stdint.h>
+#include <string.h>
#include <errno.h>
#include <skalibs/uint16.h>
-#include <skalibs/bytestr.h>
#include <skalibs/djbunix.h>
#include <skalibs/socket.h>
-int socket_accept4_internal (int s, char *ip, uint16 *port, unsigned int options)
+int socket_accept4_internal (int s, char *ip, uint16_t *port, unsigned int options)
{
struct sockaddr_in sa ;
socklen_t dummy = sizeof sa ;
- register int fd ;
+ int fd ;
do
#ifdef SKALIBS_HASACCEPT4
fd = accept4(s, (struct sockaddr *)&sa, &dummy, ((options & DJBUNIX_FLAG_NB) ? SOCK_NONBLOCK : 0) | ((options & DJBUNIX_FLAG_COE) ? SOCK_CLOEXEC : 0)) ;
@@ -27,13 +28,13 @@ int socket_accept4_internal (int s, char *ip, uint16 *port, unsigned int options
if ((((options & DJBUNIX_FLAG_NB) ? ndelay_on(fd) : ndelay_off(fd)) < 0)
|| (((options & DJBUNIX_FLAG_COE) ? coe(fd) : uncoe(fd)) < 0))
{
- register int e = errno ;
+ int e = errno ;
fd_close(fd) ;
errno = e ;
return -1 ;
}
#endif
- byte_copy(ip, 4, (char *)&sa.sin_addr.s_addr) ;
+ memcpy(ip, &sa.sin_addr.s_addr, 4) ;
uint16_unpack_big((char *)&sa.sin_port, port) ;
return fd ;
}
diff --git a/src/libstddjb/socket_accept4_u32.c b/src/libstddjb/socket_accept4_u32.c
index 18455fc..1817ec3 100644
--- a/src/libstddjb/socket_accept4_u32.c
+++ b/src/libstddjb/socket_accept4_u32.c
@@ -1,13 +1,13 @@
/* ISC license. */
-#include <skalibs/uint16.h>
+#include <stdint.h>
#include <skalibs/uint32.h>
#include <skalibs/socket.h>
-int socket_accept4_internal_u32 (int s, uint32 *ip, uint16 *port, unsigned int options)
+int socket_accept4_internal_u32 (int s, uint32_t *ip, uint16_t *port, unsigned int options)
{
char pack[4] ;
- register int r = socket_accept4_internal(s, pack, port, options) ;
- if (r >= 0) uint32_unpack_big(pack, ip) ;
- return r ;
+ int fd = socket_accept4_internal(s, pack, port, options) ;
+ if (fd >= 0) uint32_unpack_big(pack, ip) ;
+ return fd ;
}
diff --git a/src/libstddjb/socket_accept6.c b/src/libstddjb/socket_accept6.c
index f52efbb..ff11bce 100644
--- a/src/libstddjb/socket_accept6.c
+++ b/src/libstddjb/socket_accept6.c
@@ -4,20 +4,21 @@
#include <skalibs/nonposix.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <string.h>
+#include <stdint.h>
#include <errno.h>
#include <skalibs/uint16.h>
-#include <skalibs/bytestr.h>
#include <skalibs/djbunix.h>
#include <skalibs/ip46.h>
#include <skalibs/socket.h>
#ifdef SKALIBS_IPV6_ENABLED
-int socket_accept6_internal (int s, char *ip6, uint16 *port, unsigned int options)
+int socket_accept6_internal (int s, char *ip6, uint16_t *port, unsigned int options)
{
struct sockaddr_in6 sa ;
socklen_t dummy = sizeof sa ;
- register int fd ;
+ int fd ;
do
#ifdef SKALIBS_HASACCEPT4
fd = accept4(s, (struct sockaddr *)&sa, &dummy, ((options & DJBUNIX_FLAG_NB) ? SOCK_NONBLOCK : 0) | ((options & DJBUNIX_FLAG_COE) ? SOCK_CLOEXEC : 0)) ;
@@ -30,20 +31,20 @@ int socket_accept6_internal (int s, char *ip6, uint16 *port, unsigned int option
if ((((options & DJBUNIX_FLAG_NB) ? ndelay_on(fd) : ndelay_off(fd)) < 0)
|| (((options & DJBUNIX_FLAG_COE) ? coe(fd) : uncoe(fd)) < 0))
{
- register int e = errno ;
+ int e = errno ;
fd_close(fd) ;
errno = e ;
return -1 ;
}
#endif
- byte_copy(ip6, 16, (char const *)sa.sin6_addr.s6_addr) ;
+ memcpy(ip6, sa.sin6_addr.s6_addr, 16) ;
uint16_unpack_big((char *)&sa.sin6_port, port) ;
return fd ;
}
#else
-int socket_accept6_internal (int s, char *ip6, uint16 *port, unsigned int options)
+int socket_accept6_internal (int s, char *ip6, uint16_t *port, unsigned int options)
{
(void)s ;
(void)ip6 ;
diff --git a/src/libstddjb/socket_bind4.c b/src/libstddjb/socket_bind4.c
index 1078fbc..6700b1e 100644
--- a/src/libstddjb/socket_bind4.c
+++ b/src/libstddjb/socket_bind4.c
@@ -2,18 +2,19 @@
#include <skalibs/nonposix.h>
#include <sys/socket.h>
+#include <stdint.h>
+#include <string.h>
#include <netinet/in.h>
#include <skalibs/uint16.h>
-#include <skalibs/bytestr.h>
#include <skalibs/socket.h>
-int socket_bind4 (int s, char const *ip, uint16 port)
+int socket_bind4 (int s, char const *ip, uint16_t port)
{
struct sockaddr_in sa ;
- byte_zero(&sa, sizeof sa) ;
+ memset(&sa, 0, sizeof sa) ;
sa.sin_family = AF_INET ;
uint16_big_endian((char *)&port, 1) ;
sa.sin_port = port ;
- byte_copy((char *)&sa.sin_addr.s_addr, 4, ip) ;
+ memcpy(&sa.sin_addr.s_addr, ip, 4) ;
return bind(s, (struct sockaddr *)&sa, sizeof sa) ;
}
diff --git a/src/libstddjb/socket_bind4r.c b/src/libstddjb/socket_bind4r.c
index 55f0903..2c43d9a 100644
--- a/src/libstddjb/socket_bind4r.c
+++ b/src/libstddjb/socket_bind4r.c
@@ -2,12 +2,12 @@
#include <skalibs/nonposix.h>
#include <sys/socket.h>
-#include <skalibs/uint16.h>
+#include <stdint.h>
#include <skalibs/socket.h>
-int socket_bind4_reuse (int s, char const *ip, uint16 port)
+int socket_bind4_reuse (int s, char const *ip, uint16_t port)
{
- unsigned int opt = 1 ;
+ static unsigned int const opt = 1 ;
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof opt) ;
return socket_bind4(s, ip, port) ;
}
diff --git a/src/libstddjb/socket_bind6.c b/src/libstddjb/socket_bind6.c
index 63fa412..e6c08fe 100644
--- a/src/libstddjb/socket_bind6.c
+++ b/src/libstddjb/socket_bind6.c
@@ -4,26 +4,27 @@
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <stdint.h>
+#include <string.h>
#include <skalibs/uint16.h>
-#include <skalibs/bytestr.h>
#include <skalibs/socket.h>
#include <skalibs/ip46.h>
#ifdef SKALIBS_IPV6_ENABLED
-int socket_bind6 (int s, char const *ip6, uint16 port)
+int socket_bind6 (int s, char const *ip6, uint16_t port)
{
struct sockaddr_in6 sa ;
- byte_zero(&sa, sizeof sa) ;
+ memset(&sa, 0, sizeof sa) ;
sa.sin6_family = AF_INET6 ;
uint16_pack_big((char *)&sa.sin6_port, port) ;
- byte_copy((char *)sa.sin6_addr.s6_addr, 16, ip6) ;
+ memcpy(sa.sin6_addr.s6_addr, ip6, 16) ;
return bind(s, (struct sockaddr *)&sa, sizeof sa) ;
}
#else
-int socket_bind6 (int s, char const *ip6, uint16 port)
+int socket_bind6 (int s, char const *ip6, uint16_t port)
{
(void)s ;
(void)ip6 ;
diff --git a/src/libstddjb/socket_bind6r.c b/src/libstddjb/socket_bind6r.c
index 6bf5e0d..de24c61 100644
--- a/src/libstddjb/socket_bind6r.c
+++ b/src/libstddjb/socket_bind6r.c
@@ -2,12 +2,12 @@
#include <skalibs/nonposix.h>
#include <sys/socket.h>
-#include <skalibs/uint16.h>
+#include <stdint.h>
#include <skalibs/socket.h>
-int socket_bind6_reuse (int s, char const *ip6, uint16 port)
+int socket_bind6_reuse (int s, char const *ip6, uint16_t port)
{
- unsigned int opt = 1 ;
+ static unsigned int const opt = 1 ;
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof opt) ;
return socket_bind6(s, ip6, port) ;
}
diff --git a/src/libstddjb/socket_conn4.c b/src/libstddjb/socket_conn4.c
index 12459a8..78a10b9 100644
--- a/src/libstddjb/socket_conn4.c
+++ b/src/libstddjb/socket_conn4.c
@@ -3,20 +3,21 @@
#include <skalibs/nonposix.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <stdint.h>
+#include <string.h>
#include <errno.h>
#include <skalibs/uint16.h>
-#include <skalibs/bytestr.h>
#include <skalibs/socket.h>
-int socket_connect4 (int s, char const *ip, uint16 port)
+int socket_connect4 (int s, char const *ip, uint16_t port)
{
struct sockaddr_in sa ;
- register int r ;
- byte_zero(&sa, sizeof sa) ;
+ int r ;
+ memset(&sa, 0, sizeof sa) ;
sa.sin_family = AF_INET ;
uint16_big_endian((char *)&port, 1) ;
sa.sin_port = port ;
- byte_copy((char *)&sa.sin_addr.s_addr, 4, ip) ;
+ memcpy(&sa.sin_addr.s_addr, ip, 4) ;
do r = connect(s, (struct sockaddr *)&sa, sizeof sa) ;
while ((r == -1) && (errno == EINTR)) ;
if ((r == -1) && (errno == EALREADY)) errno = EINPROGRESS ;
diff --git a/src/libstddjb/socket_conn4_u32.c b/src/libstddjb/socket_conn4_u32.c
index 20887ce..162bf72 100644
--- a/src/libstddjb/socket_conn4_u32.c
+++ b/src/libstddjb/socket_conn4_u32.c
@@ -1,10 +1,10 @@
/* ISC license. */
-#include <skalibs/uint16.h>
+#include <stdint.h>
#include <skalibs/uint32.h>
#include <skalibs/socket.h>
-int socket_connect4_u32 (int s, uint32 ip, uint16 port)
+int socket_connect4_u32 (int s, uint32_t ip, uint16_t port)
{
char pack[4] ;
uint32_pack_big(pack, ip) ;
diff --git a/src/libstddjb/socket_conn6.c b/src/libstddjb/socket_conn6.c
index 57bb3f8..9b0316b 100644
--- a/src/libstddjb/socket_conn6.c
+++ b/src/libstddjb/socket_conn6.c
@@ -3,22 +3,23 @@
#include <skalibs/nonposix.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <stdint.h>
+#include <string.h>
#include <errno.h>
#include <skalibs/uint16.h>
-#include <skalibs/bytestr.h>
#include <skalibs/socket.h>
#include <skalibs/ip46.h>
#ifdef SKALIBS_IPV6_ENABLED
-int socket_connect6 (int s, char const *ip6, uint16 port)
+int socket_connect6 (int s, char const *ip6, uint16_t port)
{
struct sockaddr_in6 sa ;
- register int r ;
- byte_zero(&sa, sizeof sa) ;
+ int r ;
+ memset(&sa, 0, sizeof sa) ;
sa.sin6_family = AF_INET6 ;
uint16_pack_big((char *)&sa.sin6_port,port) ;
- byte_copy((char *)sa.sin6_addr.s6_addr, 16, ip6) ;
+ memcpy(sa.sin6_addr.s6_addr, ip6, 16) ;
do r = connect(s, (struct sockaddr *)&sa, sizeof sa) ;
while ((r == -1) && (errno == EINTR)) ;
if ((r == -1) && (errno == EALREADY)) errno = EINPROGRESS ;
@@ -27,7 +28,7 @@ int socket_connect6 (int s, char const *ip6, uint16 port)
#else
-int socket_connect6 (int s, char const *ip6, uint16 port)
+int socket_connect6 (int s, char const *ip6, uint16_t port)
{
(void)s ;
(void)ip6 ;
diff --git a/src/libstddjb/socket_connected.c b/src/libstddjb/socket_connected.c
index 895eaf3..58ca463 100644
--- a/src/libstddjb/socket_connected.c
+++ b/src/libstddjb/socket_connected.c
@@ -13,7 +13,7 @@ int socket_connected (int s)
if (getpeername(s, (struct sockaddr *)&sa, &dummy) == -1)
{
char ch ;
- fd_read(s, &ch, 1) ; /* sets errno */
+ fd_read(s, &ch, 1) ;
return 0 ;
}
return 1 ;
diff --git a/src/libstddjb/socket_deadlineconnstamp4.c b/src/libstddjb/socket_deadlineconnstamp4.c
index 618852f..a57718d 100644
--- a/src/libstddjb/socket_deadlineconnstamp4.c
+++ b/src/libstddjb/socket_deadlineconnstamp4.c
@@ -1,12 +1,12 @@
/* ISC license. */
#include <errno.h>
-#include <skalibs/uint16.h>
+#include <stdint.h>
#include <skalibs/error.h>
#include <skalibs/tai.h>
#include <skalibs/socket.h>
-int socket_deadlineconnstamp (int s, char const *ip, uint16 port, tain_t const *deadline, tain_t *stamp)
+int socket_deadlineconnstamp (int s, char const *ip, uint16_t port, tain_t const *deadline, tain_t *stamp)
{
if (socket_connect4(s, ip, port) >= 0) return 1 ;
if (!error_isagain(errno) && !error_isalready(errno)) return 0 ;
diff --git a/src/libstddjb/socket_deadlineconnstamp46.c b/src/libstddjb/socket_deadlineconnstamp46.c
index 4ab2c9a..774e840 100644
--- a/src/libstddjb/socket_deadlineconnstamp46.c
+++ b/src/libstddjb/socket_deadlineconnstamp46.c
@@ -1,13 +1,13 @@
/* ISC license. */
#include <errno.h>
-#include <skalibs/uint16.h>
+#include <stdint.h>
#include <skalibs/error.h>
#include <skalibs/tai.h>
#include <skalibs/socket.h>
#include <skalibs/ip46.h>
-int socket_deadlineconnstamp46 (int s, ip46_t const *i, uint16 port, tain_t const *deadline, tain_t *stamp)
+int socket_deadlineconnstamp46 (int s, ip46_t const *i, uint16_t port, tain_t const *deadline, tain_t *stamp)
{
if (socket_connect46(s, i, port) >= 0) return 1 ;
if (!error_isagain(errno) && !error_isalready(errno)) return 0 ;
diff --git a/src/libstddjb/socket_deadlineconnstamp4_u32.c b/src/libstddjb/socket_deadlineconnstamp4_u32.c
index 4a82e50..296f26d 100644
--- a/src/libstddjb/socket_deadlineconnstamp4_u32.c
+++ b/src/libstddjb/socket_deadlineconnstamp4_u32.c
@@ -1,11 +1,11 @@
/* ISC license. */
-#include <skalibs/uint16.h>
+#include <stdint.h>
#include <skalibs/uint32.h>
#include <skalibs/tai.h>
#include <skalibs/socket.h>
-int socket_deadlineconnstamp4_u32 (int s, uint32 ip, uint16 port, tain_t const *deadline, tain_t *stamp)
+int socket_deadlineconnstamp4_u32 (int s, uint32_t ip, uint16_t port, tain_t const *deadline, tain_t *stamp)
{
char pack[4] ;
uint32_pack_big(pack, ip) ;
diff --git a/src/libstddjb/socket_deadlineconnstamp6.c b/src/libstddjb/socket_deadlineconnstamp6.c
index a797d1e..7d7bcab 100644
--- a/src/libstddjb/socket_deadlineconnstamp6.c
+++ b/src/libstddjb/socket_deadlineconnstamp6.c
@@ -1,12 +1,12 @@
/* ISC license. */
#include <errno.h>
-#include <skalibs/uint16.h>
+#include <stdint.h>
#include <skalibs/error.h>
#include <skalibs/tai.h>
#include <skalibs/socket.h>
-int socket_deadlineconnstamp6 (int s, char const *ip, uint16 port, tain_t const *deadline, tain_t *stamp)
+int socket_deadlineconnstamp6 (int s, char const *ip, uint16_t port, tain_t const *deadline, tain_t *stamp)
{
if (socket_connect6(s, ip, port) >= 0) return 1 ;
if (!error_isagain(errno) && !error_isalready(errno)) return 0 ;
diff --git a/src/libstddjb/socket_internal.c b/src/libstddjb/socket_internal.c
index ae57e06..f8b0a1f 100644
--- a/src/libstddjb/socket_internal.c
+++ b/src/libstddjb/socket_internal.c
@@ -22,7 +22,7 @@ int socket_internal (int domain, int type, int protocol, unsigned int flags)
if ((((flags & DJBUNIX_FLAG_NB) ? ndelay_on(s) : ndelay_off(s)) < 0)
|| (((flags & DJBUNIX_FLAG_COE) ? coe(s) : uncoe(s)) < 0))
{
- register int e = errno ;
+ int e = errno ;
fd_close(s) ;
errno = e ;
return -1 ;
diff --git a/src/libstddjb/socket_ioloop.c b/src/libstddjb/socket_ioloop.c
index a158f01..0a3a5ae 100644
--- a/src/libstddjb/socket_ioloop.c
+++ b/src/libstddjb/socket_ioloop.c
@@ -1,18 +1,19 @@
/* ISC license. */
+#include <sys/types.h>
+#include <stdint.h>
#include <errno.h>
#include <skalibs/error.h>
-#include <skalibs/uint16.h>
#include <skalibs/tai.h>
#include <skalibs/iopause.h>
#include <skalibs/socket.h>
-int socket_ioloop (int s, char *buf, unsigned int len, char *ip, uint16 *port, socket_io_func_t_ref f, int w, tain_t const *deadline, tain_t *stamp)
+ssize_t socket_ioloop (int s, char *buf, size_t len, char *ip, uint16_t *port, socket_io_func_t_ref f, int w, tain_t const *deadline, tain_t *stamp)
{
iopause_fd x = { .fd = s, .events = w ? IOPAUSE_WRITE : IOPAUSE_READ, .revents = 0 } ;
for (;;)
{
- register int r = iopause_stamp(&x, 1, deadline, stamp) ;
+ ssize_t r = iopause_stamp(&x, 1, deadline, stamp) ;
if (r < 0) return -1 ;
if (!r) return (errno = ETIMEDOUT, -1) ;
if (x.revents & IOPAUSE_EXCEPT) return (errno = EIO, -1) ;
diff --git a/src/libstddjb/socket_ioloop_send4.c b/src/libstddjb/socket_ioloop_send4.c
index aff251d..94eb311 100644
--- a/src/libstddjb/socket_ioloop_send4.c
+++ b/src/libstddjb/socket_ioloop_send4.c
@@ -1,8 +1,10 @@
/* ISC license. */
+#include <sys/types.h>
+#include <stdint.h>
#include <skalibs/socket.h>
-int socket_ioloop_send4 (int fd, char *s, unsigned int len, char *ip, uint16 *port)
+ssize_t socket_ioloop_send4 (int fd, char *s, size_t len, char *ip, uint16_t *port)
{
return socket_send4(fd, s, len, ip, *port) ;
}
diff --git a/src/libstddjb/socket_ioloop_send6.c b/src/libstddjb/socket_ioloop_send6.c
index 151a58c..f201437 100644
--- a/src/libstddjb/socket_ioloop_send6.c
+++ b/src/libstddjb/socket_ioloop_send6.c
@@ -1,8 +1,10 @@
/* ISC license. */
+#include <sys/types.h>
+#include <stdint.h>
#include <skalibs/socket.h>
-int socket_ioloop_send6 (int fd, char *s, unsigned int len, char *ip, uint16 *port)
+ssize_t socket_ioloop_send6 (int fd, char *s, size_t len, char *ip, uint16_t *port)
{
return socket_send6(fd, s, len, ip, *port) ;
}
diff --git a/src/libstddjb/socket_local4.c b/src/libstddjb/socket_local4.c
index 90ae93a..60dcd9d 100644
--- a/src/libstddjb/socket_local4.c
+++ b/src/libstddjb/socket_local4.c
@@ -3,18 +3,18 @@
#include <skalibs/nonposix.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <stdint.h>
+#include <string.h>
#include <skalibs/uint16.h>
-#include <skalibs/bytestr.h>
#include <skalibs/socket.h>
-int socket_local4 (int s, char *ip, uint16 *port)
+int socket_local4 (int s, char *ip, uint16_t *port)
{
struct sockaddr_in sa ;
socklen_t dummy = sizeof sa ;
-
if (getsockname(s, (struct sockaddr *)&sa, &dummy) == -1)
return -1 ;
- byte_copy(ip, 4, (char *)&sa.sin_addr.s_addr) ;
+ memcpy(ip, &sa.sin_addr.s_addr, 4) ;
uint16_unpack_big((char *)&sa.sin_port, port) ;
return 0 ;
}
diff --git a/src/libstddjb/socket_local46.c b/src/libstddjb/socket_local46.c
index 0eeed8c..2483996 100644
--- a/src/libstddjb/socket_local46.c
+++ b/src/libstddjb/socket_local46.c
@@ -4,28 +4,29 @@
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <stdint.h>
+#include <string.h>
#include <skalibs/uint16.h>
-#include <skalibs/bytestr.h>
#include <skalibs/ip46.h>
#ifdef SKALIBS_IPV6_ENABLED
-int socket_local46 (int s, ip46_t *ip, uint16 *port)
+int socket_local46 (int s, ip46_t *ip, uint16_t *port)
{
struct sockaddr_storage sa ;
socklen_t dummy = sizeof sa ;
if (getsockname(s, (struct sockaddr *)&sa, &dummy) < 0) return -1 ;
if (sa.ss_family == AF_INET6)
{
- register struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)&sa ;
- byte_copy(ip->ip, 16, (char const *)sa6->sin6_addr.s6_addr) ;
+ struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)&sa ;
+ memcpy(ip->ip, sa6->sin6_addr.s6_addr, 16) ;
uint16_unpack_big((char *)&sa6->sin6_port, port) ;
ip->is6 = 1 ;
}
else if (sa.ss_family == AF_INET)
{
- register struct sockaddr_in *sa4 = (struct sockaddr_in *)&sa ;
- byte_copy(ip->ip, 4, (char const *)&sa4->sin_addr.s_addr) ;
+ struct sockaddr_in *sa4 = (struct sockaddr_in *)&sa ;
+ memcpy(ip->ip, &sa4->sin_addr.s_addr, 4) ;
uint16_unpack_big((char *)&sa4->sin_port, port) ;
ip->is6 = 0 ;
}
diff --git a/src/libstddjb/socket_local6.c b/src/libstddjb/socket_local6.c
index b7025fc..6c2a0e5 100644
--- a/src/libstddjb/socket_local6.c
+++ b/src/libstddjb/socket_local6.c
@@ -3,21 +3,21 @@
#include <skalibs/nonposix.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <stdint.h>
+#include <string.h>
#include <skalibs/uint16.h>
-#include <skalibs/bytestr.h>
#include <skalibs/socket.h>
#include <skalibs/ip46.h>
#ifdef SKALIBS_IPV6_ENABLED
-int socket_local6 (int s, char *ip, uint16 *port)
+int socket_local6 (int s, char *ip, uint16_t *port)
{
struct sockaddr_in6 sa ;
socklen_t dummy = sizeof sa ;
-
if (getsockname(s, (struct sockaddr *)&sa, &dummy) == -1)
return -1 ;
- byte_copy(ip, 16, (char const *)sa.sin6_addr.s6_addr) ;
+ memcpy(ip, sa.sin6_addr.s6_addr, 16) ;
uint16_unpack_big((char *)&sa.sin6_port, port) ;
return 0 ;
}
@@ -26,7 +26,7 @@ int socket_local6 (int s, char *ip, uint16 *port)
#include <errno.h>
-int socket_local6 (int s, char *ip, uint16 *port)
+int socket_local6 (int s, char *ip, uint16_t *port)
{
(void)s ;
(void)ip ;
diff --git a/src/libstddjb/socket_recv4.c b/src/libstddjb/socket_recv4.c
index 02354e9..09572d9 100644
--- a/src/libstddjb/socket_recv4.c
+++ b/src/libstddjb/socket_recv4.c
@@ -3,20 +3,21 @@
#include <skalibs/nonposix.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <stdint.h>
+#include <string.h>
#include <errno.h>
#include <skalibs/uint16.h>
-#include <skalibs/bytestr.h>
#include <skalibs/socket.h>
-int socket_recv4 (int s, char *buf, unsigned int len, char *ip, uint16 *port)
+ssize_t socket_recv4 (int s, char *buf, size_t len, char *ip, uint16_t *port)
{
struct sockaddr_in sa ;
socklen_t dummy = sizeof sa ;
- register int r ;
+ ssize_t r ;
do r = recvfrom(s, buf, len, 0, (struct sockaddr *)&sa, &dummy) ;
while ((r == -1) && (errno == EINTR)) ;
if (r == -1) return -1 ;
- byte_copy(ip, 4, (char *)&sa.sin_addr) ;
+ memcpy(ip, &sa.sin_addr, 4) ;
uint16_unpack_big((char *)&sa.sin_port, port) ;
return r ;
}
diff --git a/src/libstddjb/socket_recv6.c b/src/libstddjb/socket_recv6.c
index 6b2b4fc..be6ce3f 100644
--- a/src/libstddjb/socket_recv6.c
+++ b/src/libstddjb/socket_recv6.c
@@ -4,29 +4,30 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <errno.h>
+#include <stdint.h>
+#include <string.h>
#include <skalibs/uint16.h>
-#include <skalibs/bytestr.h>
#include <skalibs/ip46.h>
#include <skalibs/socket.h>
#ifdef SKALIBS_IPV6_ENABLED
-int socket_recv6 (int s, char *buf, unsigned int len, char *ip6, uint16 *port)
+ssize_t socket_recv6 (int s, char *buf, size_t len, char *ip6, uint16_t *port)
{
struct sockaddr_in6 sa ;
socklen_t dummy = sizeof sa ;
- register int r ;
+ ssize_t r ;
do r = recvfrom(s, buf, len, 0, (struct sockaddr *)&sa, &dummy) ;
while ((r == -1) && (errno == EINTR)) ;
if (r == -1) return -1 ;
- byte_copy(ip6, 16, (char const *)sa.sin6_addr.s6_addr) ;
+ memcpy(ip6, sa.sin6_addr.s6_addr, 16) ;
uint16_unpack_big((char *)&sa.sin6_port, port) ;
return r ;
}
#else
-int socket_recv6 (int s, char *buf, unsigned int len, char *ip6, uint16 *port)
+ssize_t socket_recv6 (int s, char *buf, size_t len, char *ip6, uint16_t *port)
{
(void)s ;
(void)buf ;
diff --git a/src/libstddjb/socket_remote4.c b/src/libstddjb/socket_remote4.c
index 767a694..57058d5 100644
--- a/src/libstddjb/socket_remote4.c
+++ b/src/libstddjb/socket_remote4.c
@@ -3,18 +3,18 @@
#include <skalibs/nonposix.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <stdint.h>
+#include <string.h>
#include <skalibs/uint16.h>
-#include <skalibs/bytestr.h>
#include <skalibs/socket.h>
-int socket_remote4 (int s, char *ip, uint16 *port)
+int socket_remote4 (int s, char *ip, uint16_t *port)
{
struct sockaddr_in sa ;
socklen_t dummy = sizeof sa ;
-
if (getpeername(s, (struct sockaddr *)&sa, &dummy) == -1)
return -1 ;
- byte_copy(ip, 4, (char *)&sa.sin_addr.s_addr) ;
+ memcpy(ip, &sa.sin_addr.s_addr, 4) ;
uint16_unpack_big((char *)&sa.sin_port, port) ;
return 0 ;
}
diff --git a/src/libstddjb/socket_remote46.c b/src/libstddjb/socket_remote46.c
index da91417..6bd24a9 100644
--- a/src/libstddjb/socket_remote46.c
+++ b/src/libstddjb/socket_remote46.c
@@ -4,28 +4,29 @@
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <stdint.h>
+#include <string.h>
#include <skalibs/uint16.h>
-#include <skalibs/bytestr.h>
#include <skalibs/ip46.h>
#ifdef SKALIBS_IPV6_ENABLED
-int socket_remote46 (int s, ip46_t *ip, uint16 *port)
+int socket_remote46 (int s, ip46_t *ip, uint16_t *port)
{
struct sockaddr sa ;
socklen_t dummy = sizeof sa ;
if (getpeername(s, &sa, &dummy) < 0) return -1 ;
if (sa.sa_family == AF_INET6)
{
- register struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)&sa ;
- byte_copy(ip->ip, 16, (char const *)sa6->sin6_addr.s6_addr) ;
+ struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)&sa ;
+ memcpy(ip->ip, sa6->sin6_addr.s6_addr, 16) ;
uint16_unpack_big((char *)&sa6->sin6_port, port) ;
ip->is6 = 1 ;
}
else if (sa.sa_family == AF_INET)
{
- register struct sockaddr_in *sa4 = (struct sockaddr_in *)&sa ;
- byte_copy(ip->ip, 4, (char const *)&sa4->sin_addr.s_addr) ;
+ struct sockaddr_in *sa4 = (struct sockaddr_in *)&sa ;
+ memcpy(ip->ip, &sa4->sin_addr.s_addr, 4) ;
uint16_unpack_big((char *)&sa4->sin_port, port) ;
ip->is6 = 0 ;
}
diff --git a/src/libstddjb/socket_remote6.c b/src/libstddjb/socket_remote6.c
index 4c642e1..6b282ef 100644
--- a/src/libstddjb/socket_remote6.c
+++ b/src/libstddjb/socket_remote6.c
@@ -4,28 +4,28 @@
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <stdint.h>
+#include <string.h>
#include <skalibs/uint16.h>
-#include <skalibs/bytestr.h>
#include <skalibs/ip46.h>
#include <skalibs/socket.h>
#ifdef SKALIBS_IPV6_ENABLED
-int socket_remote6 (int s, char *ip, uint16 *port)
+int socket_remote6 (int s, char *ip, uint16_t *port)
{
struct sockaddr_in6 sa ;
socklen_t dummy = sizeof sa ;
-
if (getpeername(s, (struct sockaddr *)&sa, &dummy) == -1)
return -1 ;
- byte_copy(ip, 16, (char const *)sa.sin6_addr.s6_addr) ;
+ memcpy(ip, sa.sin6_addr.s6_addr, 16) ;
uint16_unpack_big((char *)&sa.sin6_port, port) ;
return 0 ;
}
#else
-int socket_remote6 (int s, char *ip, uint16 *port)
+int socket_remote6 (int s, char *ip, uint16_t *port)
{
(void)s ;
(void)ip ;
diff --git a/src/libstddjb/socket_send4.c b/src/libstddjb/socket_send4.c
index 6078dff..0431aa5 100644
--- a/src/libstddjb/socket_send4.c
+++ b/src/libstddjb/socket_send4.c
@@ -3,19 +3,20 @@
#include <skalibs/nonposix.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <stdint.h>
+#include <string.h>
#include <errno.h>
#include <skalibs/uint16.h>
-#include <skalibs/bytestr.h>
#include <skalibs/socket.h>
-int socket_send4 (int s, char const *buf, unsigned int len, char const *ip, uint16 port)
+ssize_t socket_send4 (int s, char const *buf, size_t len, char const *ip, uint16_t port)
{
struct sockaddr_in sa ;
- register int r ;
- byte_zero((char *)&sa, sizeof sa) ;
+ ssize_t r ;
+ memset(&sa, 0, sizeof sa) ;
sa.sin_family = AF_INET ;
uint16_pack_big((char *)&sa.sin_port, port) ;
- byte_copy((char *)&sa.sin_addr, 4, ip) ;
+ memcpy(&sa.sin_addr, ip, 4) ;
do r = sendto(s, buf, len, 0, (struct sockaddr *)&sa, sizeof sa) ;
while ((r == -1) && (errno == EINTR)) ;
return r ;
diff --git a/src/libstddjb/socket_send6.c b/src/libstddjb/socket_send6.c
index 6349cdb..82a0357 100644
--- a/src/libstddjb/socket_send6.c
+++ b/src/libstddjb/socket_send6.c
@@ -1,24 +1,25 @@
/* ISC license. */
#include <skalibs/nonposix.h>
+#include <stdint.h>
+#include <string.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <skalibs/uint16.h>
-#include <skalibs/bytestr.h>
#include <skalibs/ip46.h>
#include <skalibs/socket.h>
#ifdef SKALIBS_IPV6_ENABLED
-int socket_send6 (int s, char const *buf, unsigned int len, char const *ip6, uint16 port)
+ssize_t socket_send6 (int s, char const *buf, size_t len, char const *ip6, uint16_t port)
{
struct sockaddr_in6 sa ;
- register int r ;
- byte_zero((char *)&sa, sizeof sa) ;
+ ssize_t r ;
+ memset(&sa, 0, sizeof sa) ;
sa.sin6_family = AF_INET6 ;
uint16_pack_big((char *)&sa.sin6_port, port) ;
- byte_copy((char *)sa.sin6_addr.s6_addr, 16, ip6) ;
+ memcpy(sa.sin6_addr.s6_addr, ip6, 16) ;
do r = sendto(s, buf, len, 0, (struct sockaddr *)&sa, sizeof sa) ;
while ((r == -1) && (errno == EINTR)) ;
return r ;
@@ -26,7 +27,7 @@ int socket_send6 (int s, char const *buf, unsigned int len, char const *ip6, uin
#else
-int socket_send6 (int s, char const *buf, unsigned int len, char const *ip6, uint16 port)
+ssize_t socket_send6 (int s, char const *buf, size_t len, char const *ip6, uint16_t port)
{
(void)s ;
(void)buf ;
diff --git a/src/libstddjb/socket_tcp6.c b/src/libstddjb/socket_tcp6.c
index fd282fc..df6dd86 100644
--- a/src/libstddjb/socket_tcp6.c
+++ b/src/libstddjb/socket_tcp6.c
@@ -18,7 +18,7 @@ int socket_tcp6_internal (unsigned int flags)
int option = 1 ;
if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &option, sizeof(option)) < 0)
{
- register int e = errno ;
+ int e = errno ;
fd_close(fd) ;
errno = e ;
return -1 ;
diff --git a/src/libstddjb/socket_timeoutconn.c b/src/libstddjb/socket_timeoutconn.c
index ec7e251..3288426 100644
--- a/src/libstddjb/socket_timeoutconn.c
+++ b/src/libstddjb/socket_timeoutconn.c
@@ -1,10 +1,10 @@
/* ISC license. */
-#include <skalibs/uint16.h>
+#include <stdint.h>
#include <skalibs/tai.h>
#include <skalibs/socket.h>
-int socket_timeoutconn (int s, char const *ip, uint16 port, unsigned int timeout)
+int socket_timeoutconn (int s, char const *ip, uint16_t port, unsigned int timeout)
{
tain_t stamp, deadline ;
tain_now(&stamp) ;
diff --git a/src/libstddjb/socket_tryr.c b/src/libstddjb/socket_tryr.c
index 6544c9d..26c04b2 100644
--- a/src/libstddjb/socket_tryr.c
+++ b/src/libstddjb/socket_tryr.c
@@ -8,7 +8,7 @@ void socket_tryreservein (int s, unsigned int size)
{
while (size >= 1024)
{
- if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, &size, sizeof size) == 0) return ;
+ if (!setsockopt(s, SOL_SOCKET, SO_RCVBUF, &size, sizeof size)) return ;
size -= (size >> 5) ;
}
}
diff --git a/src/libstddjb/socket_udp6.c b/src/libstddjb/socket_udp6.c
index 41d395a..c8f5928 100644
--- a/src/libstddjb/socket_udp6.c
+++ b/src/libstddjb/socket_udp6.c
@@ -18,7 +18,7 @@ int socket_udp6_internal (unsigned int flags)
int option = 1 ;
if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &option, sizeof(option)) < 0)
{
- register int e = errno ;
+ int e = errno ;
fd_close(fd) ;
errno = e ;
return -1 ;
diff --git a/src/libstddjb/socket_waitconn.c b/src/libstddjb/socket_waitconn.c
index 6e5c352..aca0bbf 100644
--- a/src/libstddjb/socket_waitconn.c
+++ b/src/libstddjb/socket_waitconn.c
@@ -11,7 +11,7 @@ int socket_waitconn (int s, tain_t const *deadline, tain_t *stamp)
iopause_fd x = { s, IOPAUSE_WRITE, 0 } ;
for (;;)
{
- register int r = iopause_stamp(&x, 1, deadline, stamp) ;
+ int r = iopause_stamp(&x, 1, deadline, stamp) ;
if (r < 0) return 0 ;
if (!r) return (errno = ETIMEDOUT, 0) ;
if (x.revents & IOPAUSE_WRITE) break ;
diff --git a/src/libstddjb/socketpair_internal.c b/src/libstddjb/socketpair_internal.c
index 8e62bdf..a1e64c5 100644
--- a/src/libstddjb/socketpair_internal.c
+++ b/src/libstddjb/socketpair_internal.c
@@ -45,7 +45,7 @@ int socketpair_internal (int domain, int type, int protocol, unsigned int flags,
err:
{
- register int e = errno ;
+ int e = errno ;
fd_close(fd[1]) ;
fd_close(fd[0]) ;
errno = e ;
diff --git a/src/libstddjb/str_chr.c b/src/libstddjb/str_chr.c
index a415de6..bbb67f9 100644
--- a/src/libstddjb/str_chr.c
+++ b/src/libstddjb/str_chr.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <string.h>
#include <skalibs/bytestr.h>
diff --git a/src/libstddjb/str_rchr.c b/src/libstddjb/str_rchr.c
index c82ee69..76e8e4e 100644
--- a/src/libstddjb/str_rchr.c
+++ b/src/libstddjb/str_rchr.c
@@ -1,12 +1,11 @@
/* ISC license. */
-#include <sys/types.h>
#include <string.h>
#include <skalibs/bytestr.h>
-size_t str_rchr (register char const *s, int c)
+size_t str_rchr (char const *s, int c)
{
- register char *p = strrchr(s, c) ;
+ char *p = strrchr(s, c) ;
return p ? p - s : strlen(s) ;
}
diff --git a/src/libstddjb/str_start.c b/src/libstddjb/str_start.c
index 30396bd..a254a9a 100644
--- a/src/libstddjb/str_start.c
+++ b/src/libstddjb/str_start.c
@@ -1,16 +1,9 @@
/* ISC license. */
+#include <string.h>
#include <skalibs/bytestr.h>
-int str_start (register char const *s, register char const *t)
+int str_start (char const *s, char const *t)
{
- register char x ;
-
- for (;;)
- {
- x = *t++; if (!x) return 1; if (x != *s++) return 0;
- x = *t++; if (!x) return 1; if (x != *s++) return 0;
- x = *t++; if (!x) return 1; if (x != *s++) return 0;
- x = *t++; if (!x) return 1; if (x != *s++) return 0;
- }
+ return !strncmp(s, t, strlen(t)) ;
}
diff --git a/src/libstddjb/str_strn.c b/src/libstddjb/str_strn.c
index fef219b..b7c3090 100644
--- a/src/libstddjb/str_strn.c
+++ b/src/libstddjb/str_strn.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <string.h>
#include <skalibs/bytestr.h>
@@ -9,8 +8,8 @@ size_t str_strn (char const *haystack, size_t hlen, char const *needle, size_t n
char haystack2[hlen+1] ;
char needle2[nlen+1] ;
char *p ;
- byte_copy(haystack2, hlen, haystack) ; haystack2[hlen] = 0 ;
- byte_copy(needle2, nlen, needle) ; needle2[nlen] = 0 ;
+ memcpy(haystack2, haystack, hlen) ; haystack2[hlen] = 0 ;
+ memcpy(needle2, needle, nlen) ; needle2[nlen] = 0 ;
p = strstr(haystack2, needle2) ;
return p ? p - haystack2 : hlen ;
}
diff --git a/src/libstddjb/stralloc_catb.c b/src/libstddjb/stralloc_catb.c
index f1bdc0a..dac5075 100644
--- a/src/libstddjb/stralloc_catb.c
+++ b/src/libstddjb/stralloc_catb.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <string.h>
#include <skalibs/stralloc.h>
diff --git a/src/libstddjb/stralloc_catv.c b/src/libstddjb/stralloc_catv.c
index a0c50aa..df1432e 100644
--- a/src/libstddjb/stralloc_catv.c
+++ b/src/libstddjb/stralloc_catv.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <string.h>
#include <sys/uio.h>
#include <skalibs/siovec.h>
diff --git a/src/libstddjb/stralloc_copyb.c b/src/libstddjb/stralloc_copyb.c
index 31fc31e..26c3a4c 100644
--- a/src/libstddjb/stralloc_copyb.c
+++ b/src/libstddjb/stralloc_copyb.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <string.h>
#include <skalibs/stralloc.h>
diff --git a/src/libstddjb/stralloc_insertb.c b/src/libstddjb/stralloc_insertb.c
index f964ea5..1f0a99d 100644
--- a/src/libstddjb/stralloc_insertb.c
+++ b/src/libstddjb/stralloc_insertb.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <errno.h>
#include <skalibs/stralloc.h>
diff --git a/src/libstddjb/stralloc_ready_tuned.c b/src/libstddjb/stralloc_ready_tuned.c
index 53a47cd..d365d6e 100644
--- a/src/libstddjb/stralloc_ready_tuned.c
+++ b/src/libstddjb/stralloc_ready_tuned.c
@@ -1,13 +1,13 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <errno.h>
#include <skalibs/alloc.h>
#include <skalibs/stralloc.h>
int stralloc_ready_tuned (stralloc *sa, size_t n, size_t base, size_t a, size_t b)
{
- register size_t t ;
+ size_t t ;
if (!b) return (errno = EINVAL, 0) ;
t = n + base + a * n / b ;
if (t < n) return (errno = ERANGE, 0) ;
diff --git a/src/libstddjb/stralloc_reverse.c b/src/libstddjb/stralloc_reverse.c
index 46d22cb..38e22bb 100644
--- a/src/libstddjb/stralloc_reverse.c
+++ b/src/libstddjb/stralloc_reverse.c
@@ -1,11 +1,11 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <skalibs/stralloc.h>
void stralloc_reverse (stralloc *sa)
{
- register size_t i = 0 ;
+ size_t i = 0 ;
for (; i < sa->len >> 1 ; i++)
{
char tmp = sa->s[i] ;
diff --git a/src/libstddjb/stralloc_reverse_blocks.c b/src/libstddjb/stralloc_reverse_blocks.c
index 67a18de..86b7fc4 100644
--- a/src/libstddjb/stralloc_reverse_blocks.c
+++ b/src/libstddjb/stralloc_reverse_blocks.c
@@ -1,13 +1,12 @@
/* ISC license. */
-#include <sys/types.h>
#include <string.h>
#include <skalibs/stralloc.h>
void stralloc_reverse_blocks (stralloc *sa, size_t size)
{
- register size_t n = sa->len / (size << 1) ;
- register size_t i = 0 ;
+ size_t n = sa->len / (size << 1) ;
+ size_t i = 0 ;
char tmp[size] ;
for (; i < n ; i++)
{
diff --git a/src/libstddjb/strerr_sys.c b/src/libstddjb/strerr_sys.c
index 46789d8..e388f5a 100644
--- a/src/libstddjb/strerr_sys.c
+++ b/src/libstddjb/strerr_sys.c
@@ -3,13 +3,13 @@
/* MT-unsafe */
#include <unistd.h>
+#include <string.h>
#include <errno.h>
-#include <skalibs/error.h>
#include <skalibs/strerr.h>
void strerr_warnsys (char const *x1, char const *x2, char const *x3, char const *x4, char const *x5, char const *x6, char const *x7, char const *x8, char const *x9, char const *x10)
{
- strerr_warn(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, error_str(errno)) ;
+ strerr_warn(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, strerror(errno)) ;
}
void strerr_diesys (int e, char const *x1, char const *x2, char const *x3, char const *x4, char const *x5, char const *x6, char const *x7, char const *x8, char const *x9, char const *x10)
diff --git a/src/libstddjb/string_format.c b/src/libstddjb/string_format.c
index 73c2572..b4a1bfa 100644
--- a/src/libstddjb/string_format.c
+++ b/src/libstddjb/string_format.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <string.h>
#include <errno.h>
#include <skalibs/bytestr.h>
diff --git a/src/libstddjb/string_quote.c b/src/libstddjb/string_quote.c
index 37258c5..e648af4 100644
--- a/src/libstddjb/string_quote.c
+++ b/src/libstddjb/string_quote.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <skalibs/stralloc.h>
#include <skalibs/skamisc.h>
diff --git a/src/libstddjb/string_quote_nodelim.c b/src/libstddjb/string_quote_nodelim.c
index 26b612f..a25a4e6 100644
--- a/src/libstddjb/string_quote_nodelim.c
+++ b/src/libstddjb/string_quote_nodelim.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <skalibs/stralloc.h>
#include <skalibs/skamisc.h>
diff --git a/src/libstddjb/string_quote_nodelim_mustquote.c b/src/libstddjb/string_quote_nodelim_mustquote.c
index a978921..535628d 100644
--- a/src/libstddjb/string_quote_nodelim_mustquote.c
+++ b/src/libstddjb/string_quote_nodelim_mustquote.c
@@ -1,8 +1,7 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <errno.h>
-#include <skalibs/bytestr.h>
#include <skalibs/fmtscan.h>
#include <skalibs/stralloc.h>
#include <skalibs/skamisc.h>
diff --git a/src/libstddjb/string_unquote.c b/src/libstddjb/string_unquote.c
index 4245014..d22f46d 100644
--- a/src/libstddjb/string_unquote.c
+++ b/src/libstddjb/string_unquote.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <string.h>
#include <errno.h>
#include <skalibs/skamisc.h>
diff --git a/src/libstddjb/strn_fmt.c b/src/libstddjb/strn_fmt.c
index 0c6ffb7..d8cf58f 100644
--- a/src/libstddjb/strn_fmt.c
+++ b/src/libstddjb/strn_fmt.c
@@ -4,9 +4,9 @@
#include <skalibs/types.h>
#include <skalibs/fmtscan.h>
-size_t strn_fmt (char *blah, register char const *s, size_t len)
+size_t strn_fmt (char *blah, char const *s, size_t len)
{
- register char *d = blah ;
+ char *d = blah ;
size_t i ;
for (i = 0 ; i < len ; i++)
if ((s[i] >= 32) && ((unsigned char)s[i] < 127)) *d++ = s[i] ;
diff --git a/src/libstddjb/sysclock_from_localtm.c b/src/libstddjb/sysclock_from_localtm.c
index 6408fc8..3bce55a 100644
--- a/src/libstddjb/sysclock_from_localtm.c
+++ b/src/libstddjb/sysclock_from_localtm.c
@@ -1,13 +1,12 @@
/* ISC license. */
-#include <sys/types.h>
#include <time.h>
#include <skalibs/uint64.h>
#include <skalibs/djbtime.h>
-int sysclock_from_localtm (uint64 *uu, struct tm const *l)
+int sysclock_from_localtm (uint64_t *uu, struct tm const *l)
{
- uint64 u ;
+ uint64_t u ;
if (!ltm64_from_localtm(&u, l)) return 0 ;
if (!sysclock_from_ltm64(&u)) return 0 ;
*uu = u ;
diff --git a/src/libstddjb/sysclock_from_ltm64.c b/src/libstddjb/sysclock_from_ltm64.c
index a7e7a36..abdd31d 100644
--- a/src/libstddjb/sysclock_from_ltm64.c
+++ b/src/libstddjb/sysclock_from_ltm64.c
@@ -8,7 +8,7 @@
#include <skalibs/tai.h>
-int sysclock_from_ltm64 (uint64 *u)
+int sysclock_from_ltm64 (uint64_t *u)
{
tai_t t ;
if (!tai_from_ltm64(&t, *u)) return 0 ;
@@ -18,7 +18,7 @@ int sysclock_from_ltm64 (uint64 *u)
#else
-int sysclock_from_ltm64 (uint64 *u)
+int sysclock_from_ltm64 (uint64_t *u)
{
return utc_from_sysclock(u) ;
}
diff --git a/src/libstddjb/sysclock_from_tai.c b/src/libstddjb/sysclock_from_tai.c
index 3814bf2..02e5e2a 100644
--- a/src/libstddjb/sysclock_from_tai.c
+++ b/src/libstddjb/sysclock_from_tai.c
@@ -2,11 +2,12 @@
#include <errno.h>
#include <skalibs/config.h>
+#include <skalibs/uint64.h>
#include <skalibs/tai.h>
#ifdef SKALIBS_FLAG_CLOCKISTAI
-int sysclock_from_tai (uint64 *u, tai_t const *t)
+int sysclock_from_tai (uint64_t *u, tai_t const *t)
{
if (t->x < 10U) return (errno = EINVAL, 0) ;
*u = t->x - 10U ;
@@ -17,7 +18,7 @@ int sysclock_from_tai (uint64 *u, tai_t const *t)
#include <skalibs/djbtime.h>
-int sysclock_from_tai (uint64 *u, tai_t const *t)
+int sysclock_from_tai (uint64_t *u, tai_t const *t)
{
return utc_from_tai(u, t) ;
}
diff --git a/src/libstddjb/sysclock_from_utc.c b/src/libstddjb/sysclock_from_utc.c
index 49228a7..3f862aa 100644
--- a/src/libstddjb/sysclock_from_utc.c
+++ b/src/libstddjb/sysclock_from_utc.c
@@ -9,7 +9,7 @@
#include <skalibs/tai.h>
-int sysclock_from_utc (uint64 *u)
+int sysclock_from_utc (uint64_t *u)
{
tai_t t ;
if (!tai_from_utc(&t, *u)) return 0 ;
@@ -20,7 +20,7 @@ int sysclock_from_utc (uint64 *u)
#else
-int sysclock_from_utc (uint64 *u)
+int sysclock_from_utc (uint64_t *u)
{
(void)u ;
return 1 ;
diff --git a/src/libstddjb/tai_from_localtm.c b/src/libstddjb/tai_from_localtm.c
index 1f43070..b372bf5 100644
--- a/src/libstddjb/tai_from_localtm.c
+++ b/src/libstddjb/tai_from_localtm.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <time.h>
#include <skalibs/uint64.h>
#include <skalibs/tai.h>
@@ -8,7 +7,7 @@
int tai_from_localtm (tai_t *t, struct tm const *l)
{
- uint64 u ;
+ uint64_t u ;
if (!ltm64_from_localtm(&u, l)) return 0 ;
return tai_from_ltm64(t, u) ;
}
diff --git a/src/libstddjb/tai_from_ltm64.c b/src/libstddjb/tai_from_ltm64.c
index 0ecb49a..a2a4e4c 100644
--- a/src/libstddjb/tai_from_ltm64.c
+++ b/src/libstddjb/tai_from_ltm64.c
@@ -5,7 +5,7 @@
#include <skalibs/djbtime.h>
#include "djbtime-internal.h"
-int tai_from_ltm64 (tai_t *t, uint64 u)
+int tai_from_ltm64 (tai_t *t, uint64_t u)
{
switch (skalibs_tzisright())
{
diff --git a/src/libstddjb/tai_from_sysclock.c b/src/libstddjb/tai_from_sysclock.c
index 087f353..b813108 100644
--- a/src/libstddjb/tai_from_sysclock.c
+++ b/src/libstddjb/tai_from_sysclock.c
@@ -1,11 +1,12 @@
/* ISC license. */
#include <skalibs/config.h>
+#include <skalibs/uint64.h>
#include <skalibs/tai.h>
#ifdef SKALIBS_FLAG_CLOCKISTAI
-int tai_from_sysclock (tai_t *t, uint64 u)
+int tai_from_sysclock (tai_t *t, uint64_t u)
{
return tai_u64(t, u + 10U) ;
}
@@ -14,7 +15,7 @@ int tai_from_sysclock (tai_t *t, uint64 u)
#include <skalibs/djbtime.h>
-int tai_from_sysclock (tai_t *t, uint64 u)
+int tai_from_sysclock (tai_t *t, uint64_t u)
{
return tai_from_utc(t, u) ;
}
diff --git a/src/libstddjb/tai_from_utc.c b/src/libstddjb/tai_from_utc.c
index 3f4d5ec..1b9762b 100644
--- a/src/libstddjb/tai_from_utc.c
+++ b/src/libstddjb/tai_from_utc.c
@@ -5,7 +5,7 @@
#include <skalibs/djbtime.h>
#include "djbtime-internal.h"
-int tai_from_utc (tai_t *t, uint64 u)
+int tai_from_utc (tai_t *t, uint64_t u)
{
leapsecs_add(&u, 0) ;
return tai_u64(t, u + 10) ;
diff --git a/src/libstddjb/tai_now.c b/src/libstddjb/tai_now.c
index aaf388a..a9710d4 100644
--- a/src/libstddjb/tai_now.c
+++ b/src/libstddjb/tai_now.c
@@ -7,7 +7,7 @@
int tai_now (tai_t *t)
{
- register time_t u = time(0) ;
+ time_t u = time(0) ;
if (u == (time_t)-1) return 0 ;
return tai_from_time_sysclock(t, u) ;
}
diff --git a/src/libstddjb/tai_u64.c b/src/libstddjb/tai_u64.c
index 9132ff3..624f2cb 100644
--- a/src/libstddjb/tai_u64.c
+++ b/src/libstddjb/tai_u64.c
@@ -9,9 +9,9 @@
#include <skalibs/uint64.h>
#include <skalibs/tai.h>
-int tai_u64 (tai_t *t, uint64 u)
+int tai_u64 (tai_t *t, uint64_t u)
{
- if (u & ((uint64)1 << 63)) return (errno = EOVERFLOW, 0) ;
+ if (u & ((uint64_t)1 << 63)) return (errno = EOVERFLOW, 0) ;
t->x = u ;
return 1 ;
}
diff --git a/src/libstddjb/tain_addsec.c b/src/libstddjb/tain_addsec.c
index b0d19e2..cd22b18 100644
--- a/src/libstddjb/tain_addsec.c
+++ b/src/libstddjb/tain_addsec.c
@@ -7,12 +7,12 @@ int tain_addsec (tain_t *b, tain_t const *a, int c)
{
if (c >= 0)
{
- tai_t t = { .x = (uint64)c } ;
+ tai_t t = { .x = (uint64_t)c } ;
tai_add(&b->sec, &a->sec, &t) ;
}
else
{
- tai_t t = { .x = (uint64)-c } ;
+ tai_t t = { .x = (uint64_t)-c } ;
tai_sub(&b->sec, &a->sec, &t) ;
}
b->nano = a->nano ;
diff --git a/src/libstddjb/tain_fmt.c b/src/libstddjb/tain_fmt.c
index 1fa04e3..ce64832 100644
--- a/src/libstddjb/tain_fmt.c
+++ b/src/libstddjb/tain_fmt.c
@@ -1,9 +1,10 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/fmtscan.h>
#include <skalibs/tai.h>
-unsigned int tain_fmt (char *s, tain_t const *a)
+size_t tain_fmt (char *s, tain_t const *a)
{
char pack[TAIN_PACK] ;
tain_pack(pack, a) ;
diff --git a/src/libstddjb/tain_from_ntp.c b/src/libstddjb/tain_from_ntp.c
index 5314a38..68fa699 100644
--- a/src/libstddjb/tain_from_ntp.c
+++ b/src/libstddjb/tain_from_ntp.c
@@ -4,10 +4,10 @@
#include <skalibs/tai.h>
#include <skalibs/djbtime.h>
-int tain_from_ntp (tain_t *a, uint64 u)
+int tain_from_ntp (tain_t *a, uint64_t u)
{
tai_t secs = { .x = u >> 32 } ;
- if (secs.x <= 0x7FFFFFFFUL) secs.x |= ((uint64)1 << 32) ;
+ if (secs.x <= 0x7FFFFFFFUL) secs.x |= ((uint64_t)1 << 32) ;
secs.x += TAI_MAGIC ;
secs.x -= NTP_OFFSET ;
if (!tai_from_utc(&secs, secs.x)) return 0 ;
diff --git a/src/libstddjb/tain_scan.c b/src/libstddjb/tain_scan.c
index 84a0cab..6ab181d 100644
--- a/src/libstddjb/tain_scan.c
+++ b/src/libstddjb/tain_scan.c
@@ -1,12 +1,13 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/fmtscan.h>
#include <skalibs/tai.h>
-unsigned int tain_scan (char const *s, tain_t *a)
+size_t tain_scan (char const *s, tain_t *a)
{
char pack[TAIN_PACK] ;
- register unsigned int r = ucharn_scan(s, pack, TAIN_PACK) ;
+ size_t r = ucharn_scan(s, pack, TAIN_PACK) ;
if (r) tain_unpack(pack, a) ;
return r ;
}
diff --git a/src/libstddjb/tain_to_millisecs.c b/src/libstddjb/tain_to_millisecs.c
index 0fa9395..0854c49 100644
--- a/src/libstddjb/tain_to_millisecs.c
+++ b/src/libstddjb/tain_to_millisecs.c
@@ -5,7 +5,7 @@
int tain_to_millisecs (tain_t const *a)
{
- if (a->sec.x > (uint64)2147483) return -1 ;
- if ((a->sec.x == (uint64)2147483) && (a->nano > 646000000U)) return -1 ;
+ if (a->sec.x > (uint64_t)2147483) return -1 ;
+ if ((a->sec.x == (uint64_t)2147483) && (a->nano > 646000000U)) return -1 ;
return a->sec.x * 1000 + (a->nano + 999999) / 1000000U ;
}
diff --git a/src/libstddjb/time_from_tai.c b/src/libstddjb/time_from_tai.c
index cdf1357..406fcfb 100644
--- a/src/libstddjb/time_from_tai.c
+++ b/src/libstddjb/time_from_tai.c
@@ -5,14 +5,15 @@
#define _BSD_SOURCE
#endif
-#include <sys/types.h>
-#include <errno.h>
#include <skalibs/sysdeps.h>
+#include <time.h>
+#include <errno.h>
+#include <skalibs/uint64.h>
#include <skalibs/tai.h>
int time_from_tai (time_t *u, tai_t const *t)
{
- register uint64 uu = t->x - TAI_MAGIC ;
+ register uint64_t uu = t->x - TAI_MAGIC ;
#if SKALIBS_SIZEOFTIME < 8
if ((uu >> 32) && (uu >> 32) != 0xffffffffUL)
return (errno = EOVERFLOW, 0) ;
diff --git a/src/libstddjb/time_from_tai_relative.c b/src/libstddjb/time_from_tai_relative.c
index 52e8c2a..1d11e2e 100644
--- a/src/libstddjb/time_from_tai_relative.c
+++ b/src/libstddjb/time_from_tai_relative.c
@@ -5,9 +5,9 @@
#define _BSD_SOURCE
#endif
-#include <sys/types.h>
-#include <errno.h>
#include <skalibs/sysdeps.h>
+#include <time.h>
+#include <errno.h>
#include <skalibs/tai.h>
int time_from_tai_relative (time_t *u, tai_t const *t)
diff --git a/src/libstddjb/time_sysclock_from_tai.c b/src/libstddjb/time_sysclock_from_tai.c
index 4faa70a..3e8322b 100644
--- a/src/libstddjb/time_sysclock_from_tai.c
+++ b/src/libstddjb/time_sysclock_from_tai.c
@@ -5,15 +5,15 @@
#define _BSD_SOURCE
#endif
-#include <sys/types.h>
-#include <errno.h>
#include <skalibs/sysdeps.h>
+#include <time.h>
+#include <errno.h>
#include <skalibs/uint64.h>
#include <skalibs/tai.h>
int time_sysclock_from_tai (time_t *u, tai_t const *t)
{
- uint64 uu ;
+ uint64_t uu ;
if (!sysclock_from_tai(&uu, t)) return 0 ;
uu -= TAI_MAGIC ;
#if SKALIBS_SIZEOFTIME < 8
diff --git a/src/libstddjb/timestamp_fmt.c b/src/libstddjb/timestamp_fmt.c
index 1956723..816e523 100644
--- a/src/libstddjb/timestamp_fmt.c
+++ b/src/libstddjb/timestamp_fmt.c
@@ -1,8 +1,9 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/tai.h>
-unsigned int timestamp_fmt (char *s, tain_t const *a)
+size_t timestamp_fmt (char *s, tain_t const *a)
{
*s = '@' ;
return 1 + tain_fmt(s+1, a) ;
diff --git a/src/libstddjb/timestamp_scan.c b/src/libstddjb/timestamp_scan.c
index 1d48612..95671ee 100644
--- a/src/libstddjb/timestamp_scan.c
+++ b/src/libstddjb/timestamp_scan.c
@@ -1,10 +1,11 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/tai.h>
-unsigned int timestamp_scan (char const *s, tain_t *a)
+size_t timestamp_scan (char const *s, tain_t *a)
{
- register unsigned int r ;
+ size_t r ;
if (*s != '@') return 0 ;
r = tain_scan(s+1, a) ;
return r ? r+1 : 0 ;
diff --git a/src/libstddjb/ucharn_findlen.c b/src/libstddjb/ucharn_findlen.c
index 59b5577..b770035 100644
--- a/src/libstddjb/ucharn_findlen.c
+++ b/src/libstddjb/ucharn_findlen.c
@@ -5,7 +5,7 @@
size_t ucharn_findlen (char const *s)
{
- register size_t i = 0 ;
+ 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 5eec54f..cf2b2af 100644
--- a/src/libstddjb/ucharn_fmt.c
+++ b/src/libstddjb/ucharn_fmt.c
@@ -5,7 +5,7 @@
size_t ucharn_fmt (char *s, char const *key, size_t n)
{
- register size_t i = 0 ;
+ 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 d033096..3848082 100644
--- a/src/libstddjb/ucharn_fmt_little.c
+++ b/src/libstddjb/ucharn_fmt_little.c
@@ -5,7 +5,7 @@
size_t ucharn_fmt_little (char *s, char const *key, size_t n)
{
- register size_t i = 0 ;
+ 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 b544d0d..6a9b1fd 100644
--- a/src/libstddjb/ucharn_scan.c
+++ b/src/libstddjb/ucharn_scan.c
@@ -5,7 +5,7 @@
size_t ucharn_scan (char const *s, char *key, size_t n)
{
- register unsigned int i = 0 ;
+ size_t i = 0 ;
for (; i < n ; i++)
{
unsigned char c = fmtscan_num(s[2*i], 16) ;
diff --git a/src/libstddjb/ucharn_scan_little.c b/src/libstddjb/ucharn_scan_little.c
index b278dff..52fdd62 100644
--- a/src/libstddjb/ucharn_scan_little.c
+++ b/src/libstddjb/ucharn_scan_little.c
@@ -5,7 +5,7 @@
size_t ucharn_scan_little (char const *s, char *key, size_t n)
{
- register size_t i = 0 ;
+ size_t i = 0 ;
for (; i < n ; i++)
{
unsigned char c = fmtscan_num(s[(i<<1)+1], 16) ;
diff --git a/src/libstddjb/ucspi_get.c b/src/libstddjb/ucspi_get.c
index 916ae2a..b4572d1 100644
--- a/src/libstddjb/ucspi_get.c
+++ b/src/libstddjb/ucspi_get.c
@@ -1,7 +1,7 @@
/* ISC license. */
#include <errno.h>
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/env.h>
char const *ucspi_get (char const *s)
@@ -9,11 +9,11 @@ char const *ucspi_get (char const *s)
char const *x = env_get("PROTO") ;
if (x)
{
- unsigned int len = str_len(s) ;
- unsigned int xlen = str_len(x) ;
+ size_t len = strlen(s) ;
+ size_t xlen = strlen(x) ;
char tmp[len + xlen + 1] ;
- byte_copy(tmp, xlen, x) ;
- byte_copy(tmp + xlen, len + 1, s) ;
+ memcpy(tmp, x, xlen) ;
+ memcpy(tmp + xlen, s, len + 1) ;
x = env_get(tmp) ;
if (!x) errno = ENOENT ;
}
diff --git a/src/libstddjb/unsanitize_read.c b/src/libstddjb/unsanitize_read.c
index 4d9e99d..d21cacd 100644
--- a/src/libstddjb/unsanitize_read.c
+++ b/src/libstddjb/unsanitize_read.c
@@ -2,8 +2,8 @@
#include <sys/types.h>
#include <errno.h>
-#include <skalibs/allreadwrite.h>
#include <skalibs/error.h>
+#include <skalibs/allreadwrite.h>
ssize_t unsanitize_read (ssize_t r)
{
diff --git a/src/libstddjb/utc_from_localtm.c b/src/libstddjb/utc_from_localtm.c
index a5886f3..99b4470 100644
--- a/src/libstddjb/utc_from_localtm.c
+++ b/src/libstddjb/utc_from_localtm.c
@@ -1,11 +1,10 @@
/* ISC license. */
-#include <sys/types.h>
#include <time.h>
#include <skalibs/uint64.h>
#include <skalibs/djbtime.h>
-int utc_from_localtm (uint64 *uu, struct tm const *l)
+int utc_from_localtm (uint64_t *uu, struct tm const *l)
{
if (!ltm64_from_localtm(uu, l)) return 0 ;
utc_from_ltm64(uu) ;
diff --git a/src/libstddjb/utc_from_ltm64.c b/src/libstddjb/utc_from_ltm64.c
index 788a539..ab2d153 100644
--- a/src/libstddjb/utc_from_ltm64.c
+++ b/src/libstddjb/utc_from_ltm64.c
@@ -5,8 +5,7 @@
#include <skalibs/djbtime.h>
#include "djbtime-internal.h"
-
-int utc_from_ltm64 (uint64 *u)
+int utc_from_ltm64 (uint64_t *u)
{
#ifdef SKALIBS_FLAG_CLOCKISTAI
leapsecs_sub(u) ;
diff --git a/src/libstddjb/utc_from_sysclock.c b/src/libstddjb/utc_from_sysclock.c
index 979bb04..7310a10 100644
--- a/src/libstddjb/utc_from_sysclock.c
+++ b/src/libstddjb/utc_from_sysclock.c
@@ -8,7 +8,7 @@
#include <skalibs/tai.h>
-int utc_from_sysclock (uint64 *u)
+int utc_from_sysclock (uint64_t *u)
{
tai_t t = { .x = *u + 10U } ;
return utc_from_tai(u, &t) ;
@@ -16,7 +16,7 @@ int utc_from_sysclock (uint64 *u)
#else
-int utc_from_sysclock (uint64 *u)
+int utc_from_sysclock (uint64_t *u)
{
(void)u ;
return 1 ;
diff --git a/src/libstddjb/vbaprintf.c b/src/libstddjb/vbaprintf.c
index 1c23e8c..38bd331 100644
--- a/src/libstddjb/vbaprintf.c
+++ b/src/libstddjb/vbaprintf.c
@@ -1,8 +1,7 @@
/* ISC license. */
-#include <sys/types.h>
-#include <stdarg.h>
#include <stdio.h>
+#include <stdarg.h>
#include <skalibs/stralloc.h>
#include <skalibs/bufalloc.h>
#include <skalibs/lolstdio.h>
@@ -17,8 +16,8 @@ int vbaprintf (bufalloc *ba, char const *format, va_list args)
va_end(ugly) ;
}
if (r < 0) return r ;
- if (!stralloc_readyplus(&ba->x, (size_t)r + 1)) return -1 ;
- r = vsnprintf(ba->x.s + ba->x.len, (size_t)r + 1, format, args) ;
+ if (!stralloc_readyplus(&ba->x, r + 1)) return -1 ;
+ r = vsnprintf(ba->x.s + ba->x.len, r + 1, format, args) ;
if (r > 0) ba->x.len += r ;
return r ;
}
diff --git a/src/libstddjb/vbprintf.c b/src/libstddjb/vbprintf.c
index 2f8c13b..52dfb9b 100644
--- a/src/libstddjb/vbprintf.c
+++ b/src/libstddjb/vbprintf.c
@@ -1,8 +1,7 @@
/* ISC license. */
-#include <sys/types.h>
-#include <stdarg.h>
#include <stdio.h>
+#include <stdarg.h>
#include <skalibs/buffer.h>
#include <skalibs/lolstdio.h>
@@ -17,8 +16,8 @@ int vbprintf (buffer *b, char const *format, va_list args)
}
if (r < 0) return r ;
{
- char buf[(size_t)r + 1] ;
- r = vsnprintf(buf, (size_t)r + 1, format, args) ;
+ char buf[r+1] ;
+ r = vsnprintf(buf, r + 1, format, args) ;
if (r < 0) return r ;
if (buffer_put(b, buf, r) < r) return -1 ;
}
diff --git a/src/libstddjb/wait_nointr.c b/src/libstddjb/wait_nointr.c
index 90d6412..4e7a17a 100644
--- a/src/libstddjb/wait_nointr.c
+++ b/src/libstddjb/wait_nointr.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
#include <skalibs/djbunix.h>
diff --git a/src/libstddjb/wait_pid_nohang.c b/src/libstddjb/wait_pid_nohang.c
index 11beed6..7b27bbe 100644
--- a/src/libstddjb/wait_pid_nohang.c
+++ b/src/libstddjb/wait_pid_nohang.c
@@ -1,16 +1,16 @@
/* ISC license. */
-#include <sys/types.h>
+#include <sys/wait.h>
#include <skalibs/djbunix.h>
pid_t wait_pid_nohang (pid_t pid, int *wstat)
{
int w = 0 ;
- register pid_t r = 0 ;
+ pid_t r = 0 ;
while (r != pid)
{
r = wait_nohang(&w) ;
- if (!r || (r == (pid_t)-1)) return (int)r ;
+ if (!r || (r == (pid_t)-1)) return r ;
}
*wstat = w ;
return r ;
diff --git a/src/libstddjb/wait_pids_nohang.c b/src/libstddjb/wait_pids_nohang.c
index 3c52e6b..c13ddec 100644
--- a/src/libstddjb/wait_pids_nohang.c
+++ b/src/libstddjb/wait_pids_nohang.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <sys/types.h>
+#include <sys/wait.h>
#include <skalibs/djbunix.h>
int wait_pids_nohang (pid_t const *pids, unsigned int len, int *wstat)
@@ -8,10 +8,10 @@ int wait_pids_nohang (pid_t const *pids, unsigned int len, int *wstat)
for (;;)
{
int w ;
- register pid_t r = wait_nohang(&w) ;
+ pid_t r = wait_nohang(&w) ;
if (!r || (r == (pid_t)-1)) return (int)r ;
{
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
for (; i < len ; i++) if (r == pids[i]) break ;
if (i < len)
{
diff --git a/src/libstddjb/wait_reap.c b/src/libstddjb/wait_reap.c
index 7049b27..051b11e 100644
--- a/src/libstddjb/wait_reap.c
+++ b/src/libstddjb/wait_reap.c
@@ -4,7 +4,7 @@
unsigned int wait_reap ()
{
- register unsigned int n = 0 ;
+ unsigned int n = 0 ;
int wstat ;
while (wait_nohang(&wstat) > 0) n++ ;
return n ;
diff --git a/src/libstddjb/waitn.c b/src/libstddjb/waitn.c
index 0d01cd1..05d7f37 100644
--- a/src/libstddjb/waitn.c
+++ b/src/libstddjb/waitn.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <sys/types.h>
+#include <sys/wait.h>
#include <skalibs/djbunix.h>
int waitn (pid_t *pids, unsigned int n)
@@ -8,8 +8,8 @@ int waitn (pid_t *pids, unsigned int n)
while (n)
{
int wstat ;
- register unsigned int i = 0 ;
- register pid_t pid = wait_nointr(&wstat) ;
+ unsigned int i = 0 ;
+ pid_t pid = wait_nointr(&wstat) ;
if (pid < 0) return 0 ;
for (; i < n ; i++) if (pid == pids[i]) break ;
if (i < n) pids[i] = pids[--n] ;
diff --git a/src/libstddjb/waitn_reap.c b/src/libstddjb/waitn_reap.c
index 96a0c61..9f26b5d 100644
--- a/src/libstddjb/waitn_reap.c
+++ b/src/libstddjb/waitn_reap.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <sys/types.h>
+#include <sys/wait.h>
#include <skalibs/djbunix.h>
int waitn_reap (pid_t *pids, unsigned int len)
@@ -9,11 +9,11 @@ int waitn_reap (pid_t *pids, unsigned int len)
while (len)
{
int w ;
- register int r = wait_pids_nohang(pids, len, &w) ;
+ int r = wait_pids_nohang(pids, len, &w) ;
if (r < 0) return r ;
else if (!r) break ;
pids[r-1] = pids[--len] ;
n++ ;
}
- return (int)n ;
+ return n ;
}
diff --git a/src/libstddjb/waitpid_nointr.c b/src/libstddjb/waitpid_nointr.c
index 8c6a65e..838359f 100644
--- a/src/libstddjb/waitpid_nointr.c
+++ b/src/libstddjb/waitpid_nointr.c
@@ -1,15 +1,13 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
#include <skalibs/djbunix.h>
pid_t waitpid_nointr (pid_t pid, int *wstat, int flags)
{
- register pid_t r ;
- do
- r = waitpid(pid, wstat, flags) ;
+ pid_t r ;
+ do r = waitpid(pid, wstat, flags) ;
while ((r == (pid_t)-1) && (errno == EINTR)) ;
return r ;
}
diff --git a/src/libunixonacid/openwritevnclose_at.c b/src/libunixonacid/openwritevnclose_at.c
index 518187a..f5a9419 100644
--- a/src/libunixonacid/openwritevnclose_at.c
+++ b/src/libunixonacid/openwritevnclose_at.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
#include <errno.h>
diff --git a/src/sysdeps/tryipv6.c b/src/sysdeps/tryipv6.c
index 7a061cc..a384b0a 100644
--- a/src/sysdeps/tryipv6.c
+++ b/src/sysdeps/tryipv6.c
@@ -14,8 +14,7 @@
int main (void)
{
- int s ;
- register int r ;
+ int s, r ;
struct in6_addr foo ;
struct sockaddr_in6 bar ;
memset(&foo, 0, sizeof(struct sockaddr_in6)) ;
diff --git a/src/sysdeps/trynbwaitall.c b/src/sysdeps/trynbwaitall.c
index 90a02e6..a10fd0b 100644
--- a/src/sysdeps/trynbwaitall.c
+++ b/src/sysdeps/trynbwaitall.c
@@ -34,7 +34,7 @@
static int ndelay_on (int fd)
{
- register int got = fcntl(fd, F_GETFL) ;
+ int got = fcntl(fd, F_GETFL) ;
return (got == -1) ? -1 : fcntl(fd, F_SETFL, got | O_NONBLOCK) ;
}
diff --git a/src/sysdeps/tryppoll.c b/src/sysdeps/tryppoll.c
index 33380b8..1502f2c 100644
--- a/src/sysdeps/tryppoll.c
+++ b/src/sysdeps/tryppoll.c
@@ -1,6 +1,9 @@
/* ISC license. */
+#ifndef _GNU_SOURCE
#define _GNU_SOURCE
+#endif
+
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
diff --git a/src/sysdeps/trysplice.c b/src/sysdeps/trysplice.c
index a408f13..7428418 100644
--- a/src/sysdeps/trysplice.c
+++ b/src/sysdeps/trysplice.c
@@ -18,7 +18,7 @@ int main (void)
for (;;)
{
- register int r = splice(fd, 0, p[1], 0, N, 0) ;
+ ssize_t r = splice(fd, 0, p[1], 0, N, 0) ;
if (r < 0) return 1 ;
if (!r) break ;
if (splice(p[0], 0, 1, 0, r, 0) < r) return 2 ;