diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-01-12 15:35:29 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-01-12 15:35:29 +0000 |
commit | 3f9536c5cc9ed6659ad2514859bd1716cbf7b26b (patch) | |
tree | 3f01ca46f59b9458c93ace3f07127d1e2bb460e8 /src/clients | |
parent | 3a289d1ca8dd2bce4a8bb6549709ea62262ec786 (diff) | |
download | s6-dns-3f9536c5cc9ed6659ad2514859bd1716cbf7b26b.tar.xz |
Types fix, first pass.
Some places marked XXX for the skalibs API change.
Diffstat (limited to 'src/clients')
-rw-r--r-- | src/clients/s6-dnsip4.c | 10 | ||||
-rw-r--r-- | src/clients/s6-dnsip6.c | 10 | ||||
-rw-r--r-- | src/clients/s6-dnsmx.c | 10 | ||||
-rw-r--r-- | src/clients/s6-dnsname-filter.c | 5 | ||||
-rw-r--r-- | src/clients/s6-dnsname.c | 9 | ||||
-rw-r--r-- | src/clients/s6-dnsns.c | 9 | ||||
-rw-r--r-- | src/clients/s6-dnsq.c | 7 | ||||
-rw-r--r-- | src/clients/s6-dnsqr.c | 3 | ||||
-rw-r--r-- | src/clients/s6-dnsqualify.c | 3 | ||||
-rw-r--r-- | src/clients/s6-dnssoa.c | 10 | ||||
-rw-r--r-- | src/clients/s6-dnssrv.c | 16 | ||||
-rw-r--r-- | src/clients/s6-dnstxt.c | 24 | ||||
-rw-r--r-- | src/clients/s6-randomip.c | 5 | ||||
-rw-r--r-- | src/clients/s6dns-generic-filter.h | 9 | ||||
-rw-r--r-- | src/clients/s6dns_generic_filter_main.c | 26 | ||||
-rw-r--r-- | src/clients/s6dns_namescanner.c | 8 |
16 files changed, 95 insertions, 69 deletions
diff --git a/src/clients/s6-dnsip4.c b/src/clients/s6-dnsip4.c index 03c52dd..1f1eb28 100644 --- a/src/clients/s6-dnsip4.c +++ b/src/clients/s6-dnsip4.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/uint.h> #include <skalibs/sgetopt.h> @@ -17,7 +18,8 @@ int main (int argc, char const *const *argv) { stralloc ips = STRALLOC_ZERO ; tain_t deadline ; - unsigned int i = 0 ; + size_t i = 0 ; + unsigned int t = 0 ; int flagqualify = 0 ; int flagunsort = 0 ; PROG = "s6-dnsip4" ; @@ -30,7 +32,7 @@ int main (int argc, char const *const *argv) { case 'q' : flagqualify = 1 ; break ; case 'r' : flagunsort = 1 ; break ; - case 't' : if (!uint0_scan(subgetopt_here.arg, &i)) dieusage() ; break ; + case 't' : if (!uint0_scan(subgetopt_here.arg, &t)) dieusage() ; break ; default : dieusage() ; } } @@ -38,7 +40,7 @@ int main (int argc, char const *const *argv) if (argc < 1) dieusage() ; tain_now_g() ; - if (i) tain_from_millisecs(&deadline, i) ; else deadline = tain_infinite_relative ; + if (t) tain_from_millisecs(&deadline, t) ; else deadline = tain_infinite_relative ; tain_add_g(&deadline, &deadline) ; if (!s6dns_init()) strerr_diefu1sys(111, "s6dns_init") ; { @@ -51,7 +53,7 @@ int main (int argc, char const *const *argv) for (i = 0 ; i < ips.len / 4 ; i++) { char fmt[IP4_FMT] ; - register unsigned int n = ip4_fmt(fmt, ips.s + 4 * i) ; + register size_t n = ip4_fmt(fmt, ips.s + 4 * i) ; fmt[n++] = '\n' ; if (buffer_put(buffer_1small, fmt, n) < (int)n) strerr_diefu1sys(111, "write to stdout") ; diff --git a/src/clients/s6-dnsip6.c b/src/clients/s6-dnsip6.c index e07ba53..a948b49 100644 --- a/src/clients/s6-dnsip6.c +++ b/src/clients/s6-dnsip6.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/uint.h> #include <skalibs/sgetopt.h> @@ -17,7 +18,8 @@ int main (int argc, char const *const *argv) { stralloc ips = STRALLOC_ZERO ; tain_t deadline ; - unsigned int i = 0 ; + size_t i = 0 ; + unsigned int t = 0 ; int flagqualify = 0 ; int flagunsort = 0 ; PROG = "s6-dnsip6" ; @@ -30,7 +32,7 @@ int main (int argc, char const *const *argv) { case 'q' : flagqualify = 1 ; break ; case 'r' : flagunsort = 1 ; break ; - case 't' : if (!uint0_scan(subgetopt_here.arg, &i)) dieusage() ; break ; + case 't' : if (!uint0_scan(subgetopt_here.arg, &t)) dieusage() ; break ; default : dieusage() ; } } @@ -38,7 +40,7 @@ int main (int argc, char const *const *argv) if (argc < 1) dieusage() ; tain_now_g() ; - if (i) tain_from_millisecs(&deadline, i) ; else deadline = tain_infinite_relative ; + if (t) tain_from_millisecs(&deadline, t) ; else deadline = tain_infinite_relative ; tain_add_g(&deadline, &deadline) ; if (!s6dns_init()) strerr_diefu1sys(111, "s6dns_init") ; { @@ -51,7 +53,7 @@ int main (int argc, char const *const *argv) for (i = 0 ; i < ips.len / 16 ; i++) { char fmt[IP6_FMT] ; - register unsigned int n = ip6_fmt(fmt, ips.s + 16 * i) ; + register size_t n = ip6_fmt(fmt, ips.s + 16 * i) ; fmt[n++] = '\n' ; if (buffer_put(buffer_1small, fmt, n) < (int)n) strerr_diefu1sys(111, "write to stdout") ; diff --git a/src/clients/s6-dnsmx.c b/src/clients/s6-dnsmx.c index a495cb2..5b8359c 100644 --- a/src/clients/s6-dnsmx.c +++ b/src/clients/s6-dnsmx.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/uint16.h> #include <skalibs/uint.h> @@ -19,7 +20,8 @@ int main (int argc, char const *const *argv) { genalloc mxs = GENALLOC_ZERO ; /* array of s6dns_message_rr_mx_t */ tain_t deadline ; - unsigned int i = 0 ; + size_t i = 0 ; + unsigned int t = 0 ; int flagqualify = 0 ; int flagunsort = 0 ; PROG = "s6-dnsmx" ; @@ -31,7 +33,7 @@ int main (int argc, char const *const *argv) { case 'q' : flagqualify = 1 ; break ; case 'r' : flagunsort = 1 ; break ; - case 't' : if (!uint0_scan(subgetopt_here.arg, &i)) dieusage() ; break ; + case 't' : if (!uint0_scan(subgetopt_here.arg, &t)) dieusage() ; break ; default : dieusage() ; } } @@ -39,7 +41,7 @@ int main (int argc, char const *const *argv) if (argc < 1) dieusage() ; tain_now_g() ; - if (i) tain_from_millisecs(&deadline, i) ; else deadline = tain_infinite_relative ; + if (t) tain_from_millisecs(&deadline, t) ; else deadline = tain_infinite_relative ; tain_add_g(&deadline, &deadline) ; if (!s6dns_init()) strerr_diefu1sys(111, "s6dns_init") ; { @@ -52,7 +54,7 @@ int main (int argc, char const *const *argv) for (i = 0 ; i < genalloc_len(s6dns_message_rr_mx_t, &mxs) ; i++) { char buf[S6DNS_FMT_MX] ; - register unsigned int len = s6dns_fmt_mx(buf, S6DNS_FMT_MX, genalloc_s(s6dns_message_rr_mx_t, &mxs) + i) ; + register size_t len = s6dns_fmt_mx(buf, S6DNS_FMT_MX, genalloc_s(s6dns_message_rr_mx_t, &mxs) + i) ; if (!len) strerr_diefu1sys(111, "format result") ; if (buffer_put(buffer_1, buf, len) < 0) goto err ; if (buffer_put(buffer_1, "\n", 1) < 0) goto err ; diff --git a/src/clients/s6-dnsname-filter.c b/src/clients/s6-dnsname-filter.c index 99dad32..0edbe7a 100644 --- a/src/clients/s6-dnsname-filter.c +++ b/src/clients/s6-dnsname-filter.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/error.h> #include <skalibs/strerr2.h> @@ -12,10 +13,10 @@ #define USAGE "s6-dnsname-filter [ -4 ] [ -6 ] [ -l lines ] [ -c concurrency ] [ -t timeout ] [ -f format ] [ -e errorformat ]" -static unsigned int ipscanner (s6dns_domain_t *d, char const *s) +static size_t ipscanner (s6dns_domain_t *d, char const *s) { char ip[16] ; - register unsigned int pos ; + register size_t pos ; if (flag6) { pos = ip6_scan(s, ip) ; diff --git a/src/clients/s6-dnsname.c b/src/clients/s6-dnsname.c index fe5ab9a..103edad 100644 --- a/src/clients/s6-dnsname.c +++ b/src/clients/s6-dnsname.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/uint.h> #include <skalibs/sgetopt.h> @@ -20,7 +21,7 @@ int main (int argc, char const *const *argv) genalloc ds = GENALLOC_ZERO ; /* array of s6dns_domain_t */ tain_t deadline ; ip46full_t ip = IP46FULL_ZERO ; - unsigned int i = 0 ; + unsigned int t = 0 ; int flagunsort = 0 ; int do4 = 0 ; int do6 = 0 ; @@ -34,7 +35,7 @@ int main (int argc, char const *const *argv) case '4' : do4 = 1 ; break ; case '6' : do6 = 1 ; break ; case 'r' : flagunsort = 1 ; break ; - case 't' : if (!uint0_scan(subgetopt_here.arg, &i)) dieusage() ; break ; + case 't' : if (!uint0_scan(subgetopt_here.arg, &t)) dieusage() ; break ; default : dieusage() ; } } @@ -53,7 +54,7 @@ int main (int argc, char const *const *argv) else if (!ip4_scan(argv[0], ip.ip)) dieusage() ; tain_now_g() ; - if (i) tain_from_millisecs(&deadline, i) ; else deadline = tain_infinite_relative ; + if (t) tain_from_millisecs(&deadline, t) ; else deadline = tain_infinite_relative ; tain_add_g(&deadline, &deadline) ; if (!s6dns_init()) strerr_diefu1sys(111, "s6dns_init") ; { @@ -65,7 +66,7 @@ int main (int argc, char const *const *argv) if (flagunsort) random_unsort(ds.s, genalloc_len(s6dns_domain_t, &ds), sizeof(s6dns_domain_t)) ; { char buf[S6DNS_FMT_DOMAINLIST(genalloc_len(s6dns_domain_t, &ds))] ; - unsigned int len = s6dns_fmt_domainlist(buf, S6DNS_FMT_DOMAINLIST(genalloc_len(s6dns_domain_t, &ds)), genalloc_s(s6dns_domain_t, &ds), genalloc_len(s6dns_domain_t, &ds), "\n", 1) ; + size_t len = s6dns_fmt_domainlist(buf, S6DNS_FMT_DOMAINLIST(genalloc_len(s6dns_domain_t, &ds)), genalloc_s(s6dns_domain_t, &ds), genalloc_len(s6dns_domain_t, &ds), "\n", 1) ; if (!len) strerr_diefu1sys(111, "format result") ; if (buffer_put(buffer_1, buf, len) < 0) goto err ; } diff --git a/src/clients/s6-dnsns.c b/src/clients/s6-dnsns.c index d1caba5..6e86b89 100644 --- a/src/clients/s6-dnsns.c +++ b/src/clients/s6-dnsns.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/uint.h> #include <skalibs/bytestr.h> @@ -18,7 +19,7 @@ int main (int argc, char const *const *argv) { genalloc ds = GENALLOC_ZERO ; /* array of s6dns_domain_t */ tain_t deadline ; - unsigned int i = 0 ; + unsigned int t = 0 ; int flagqualify = 0 ; int flagunsort = 0 ; PROG = "s6-dnsns" ; @@ -30,7 +31,7 @@ int main (int argc, char const *const *argv) { case 'q' : flagqualify = 1 ; break ; case 'r' : flagunsort = 1 ; break ; - case 't' : if (!uint0_scan(subgetopt_here.arg, &i)) dieusage() ; break ; + case 't' : if (!uint0_scan(subgetopt_here.arg, &t)) dieusage() ; break ; default : dieusage() ; } } @@ -38,7 +39,7 @@ int main (int argc, char const *const *argv) if (argc < 1) dieusage() ; tain_now_g() ; - if (i) tain_from_millisecs(&deadline, i) ; else deadline = tain_infinite_relative ; + if (t) tain_from_millisecs(&deadline, t) ; else deadline = tain_infinite_relative ; tain_add_g(&deadline, &deadline) ; if (!s6dns_init()) strerr_diefu1sys(111, "s6dns_init") ; { @@ -50,7 +51,7 @@ int main (int argc, char const *const *argv) if (flagunsort) random_unsort(ds.s, genalloc_len(s6dns_domain_t, &ds), sizeof(s6dns_domain_t)) ; { char buf[S6DNS_FMT_DOMAINLIST(genalloc_len(s6dns_domain_t, &ds))] ; - unsigned int len = s6dns_fmt_domainlist(buf, S6DNS_FMT_DOMAINLIST(genalloc_len(s6dns_domain_t, &ds)), genalloc_s(s6dns_domain_t, &ds), genalloc_len(s6dns_domain_t, &ds), "\n", 1) ; + size_t len = s6dns_fmt_domainlist(buf, S6DNS_FMT_DOMAINLIST(genalloc_len(s6dns_domain_t, &ds)), genalloc_s(s6dns_domain_t, &ds), genalloc_len(s6dns_domain_t, &ds), "\n", 1) ; if (!len) strerr_diefu1sys(111, "format result") ; if (buffer_put(buffer_1, buf, len) < 0) goto err ; } diff --git a/src/clients/s6-dnsq.c b/src/clients/s6-dnsq.c index 76ca4ea..538c925 100644 --- a/src/clients/s6-dnsq.c +++ b/src/clients/s6-dnsq.c @@ -1,8 +1,9 @@ /* ISC license. */ +#include <sys/types.h> +#include <stdint.h> #include <errno.h> #include <skalibs/uint16.h> -#include <skalibs/uint32.h> #include <skalibs/uint.h> #include <skalibs/bytestr.h> #include <skalibs/bitarray.h> @@ -23,7 +24,7 @@ int main (int argc, char const *const *argv) { tain_t deadline ; unsigned int debuglevel = 0 ; - uint16 qtype ; + uint16_t qtype ; genwrite_t *where = &genwrite_stderr ; PROG = "s6-dnsq" ; { @@ -60,7 +61,7 @@ int main (int argc, char const *const *argv) for (; (i < (unsigned int)(argc - 2)) && (j < S6DNS_MAX_SERVERS) ; i++) { ip46_t z[S6DNS_MAX_SERVERS] ; - unsigned int n ; + unsigned int n ; /* XXX: depends on ip46_scanlist API */ register unsigned int k = 0 ; if (!*argv[2+i]) continue ; if (!ip46_scanlist(z, S6DNS_MAX_SERVERS - j, argv[2 + i], &n)) diff --git a/src/clients/s6-dnsqr.c b/src/clients/s6-dnsqr.c index 1effe68..f1bb896 100644 --- a/src/clients/s6-dnsqr.c +++ b/src/clients/s6-dnsqr.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <stdint.h> #include <errno.h> #include <skalibs/uint16.h> #include <skalibs/uint.h> @@ -45,7 +46,7 @@ int main (int argc, char const *const *argv) { s6dns_debughook_t dbh = { .post_recv = 0, .pre_send = 0, .post_send = 0 } ; s6dns_domain_t d ; - uint16 qtype = s6dns_analyze_qtype_parse(argv[0]) ; + uint16_t qtype = s6dns_analyze_qtype_parse(argv[0]) ; if (!qtype) dieusage() ; if (!s6dns_domain_fromstring_noqualify_encode(&d, argv[1], str_len(argv[1]))) strerr_diefu2sys(100, "encode ", argv[1]) ; diff --git a/src/clients/s6-dnsqualify.c b/src/clients/s6-dnsqualify.c index 64767ae..94405db 100644 --- a/src/clients/s6-dnsqualify.c +++ b/src/clients/s6-dnsqualify.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <skalibs/bytestr.h> #include <skalibs/strerr2.h> #include <skalibs/buffer.h> @@ -22,7 +23,7 @@ int main (int argc, char const *const *argv) if (!n) strerr_diefu2sys(111, "qualify ", argv[1]) ; { char buf[S6DNS_FMT_DOMAINLIST(n)] ; - unsigned int len = s6dns_fmt_domainlist(buf, S6DNS_FMT_DOMAINLIST(n), list, n, "\n", 1) ; + size_t len = s6dns_fmt_domainlist(buf, S6DNS_FMT_DOMAINLIST(n), list, n, "\n", 1) ; if (!len) strerr_diefu1sys(111, "format result") ; if (buffer_put(buffer_1, buf, len) < 0) goto err ; } diff --git a/src/clients/s6-dnssoa.c b/src/clients/s6-dnssoa.c index 1b02ff6..e620c85 100644 --- a/src/clients/s6-dnssoa.c +++ b/src/clients/s6-dnssoa.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/uint.h> #include <skalibs/bytestr.h> @@ -18,7 +19,8 @@ int main (int argc, char const *const *argv) { genalloc soas = GENALLOC_ZERO ; /* array of s6dns_message_rr_soa_t */ tain_t deadline ; - unsigned int i = 0 ; + size_t i = 0 ; + unsigned int t = 0 ; int flagqualify = 0 ; int flagunsort = 0 ; PROG = "s6-dnssoa" ; @@ -30,7 +32,7 @@ int main (int argc, char const *const *argv) { case 'q' : flagqualify = 1 ; break ; case 'r' : flagunsort = 1 ; break ; - case 't' : if (!uint0_scan(subgetopt_here.arg, &i)) dieusage() ; break ; + case 't' : if (!uint0_scan(subgetopt_here.arg, &t)) dieusage() ; break ; default : dieusage() ; } } @@ -38,7 +40,7 @@ int main (int argc, char const *const *argv) if (argc < 1) dieusage() ; tain_now_g() ; - if (i) tain_from_millisecs(&deadline, i) ; else deadline = tain_infinite_relative ; + if (t) tain_from_millisecs(&deadline, t) ; else deadline = tain_infinite_relative ; tain_add_g(&deadline, &deadline) ; if (!s6dns_init()) strerr_diefu1sys(111, "s6dns_init") ; { @@ -51,7 +53,7 @@ int main (int argc, char const *const *argv) for (i = 0 ; i < genalloc_len(s6dns_message_rr_soa_t, &soas) ; i++) { char buf[S6DNS_FMT_SOA] ; - register unsigned int len = s6dns_fmt_soa(buf, S6DNS_FMT_SOA, genalloc_s(s6dns_message_rr_soa_t, &soas) + i) ; + register size_t len = s6dns_fmt_soa(buf, S6DNS_FMT_SOA, genalloc_s(s6dns_message_rr_soa_t, &soas) + i) ; if (!len) strerr_diefu1sys(111, "format result") ; if (buffer_put(buffer_1, buf, len) < 0) goto err ; if (buffer_put(buffer_1, "\n", 1) < 0) goto err ; diff --git a/src/clients/s6-dnssrv.c b/src/clients/s6-dnssrv.c index 283f1cd..47f5df0 100644 --- a/src/clients/s6-dnssrv.c +++ b/src/clients/s6-dnssrv.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/uint.h> #include <skalibs/bytestr.h> @@ -18,7 +19,8 @@ int main (int argc, char const *const *argv) { genalloc srvs = GENALLOC_ZERO ; /* array of s6dns_message_rr_srv_t */ tain_t deadline ; - unsigned int i = 0 ; + size_t i = 0 ; + unsigned int t = 0 ; int flagqualify = 0 ; int flagunsort = 0 ; PROG = "s6-dnssrv" ; @@ -30,7 +32,7 @@ int main (int argc, char const *const *argv) { case 'q' : flagqualify = 1 ; break ; case 'r' : flagunsort = 1 ; break ; - case 't' : if (!uint0_scan(subgetopt_here.arg, &i)) dieusage() ; break ; + case 't' : if (!uint0_scan(subgetopt_here.arg, &t)) dieusage() ; break ; default : dieusage() ; } } @@ -38,13 +40,13 @@ int main (int argc, char const *const *argv) if (argc < 3) dieusage() ; tain_now_g() ; - if (i) tain_from_millisecs(&deadline, i) ; else deadline = tain_infinite_relative ; + if (t) tain_from_millisecs(&deadline, t) ; else deadline = tain_infinite_relative ; tain_add_g(&deadline, &deadline) ; if (!s6dns_init()) strerr_diefu1sys(111, "s6dns_init") ; { - unsigned int n0 = str_len(argv[0]) ; - unsigned int n1 = str_len(argv[1]) ; - unsigned int n2 = str_len(argv[2]) ; + size_t n0 = str_len(argv[0]) ; + size_t n1 = str_len(argv[1]) ; + size_t n2 = str_len(argv[2]) ; char name[n0 + n1 + n2 + 5] ; name[0] = '_' ; byte_copy(name + 1, n0, argv[0]) ; @@ -63,7 +65,7 @@ int main (int argc, char const *const *argv) for (i = 0 ; i < genalloc_len(s6dns_message_rr_srv_t, &srvs) ; i++) { char buf[S6DNS_FMT_SRV] ; - register unsigned int len = s6dns_fmt_srv(buf, S6DNS_FMT_SRV, genalloc_s(s6dns_message_rr_srv_t, &srvs) + i) ; + register size_t len = s6dns_fmt_srv(buf, S6DNS_FMT_SRV, genalloc_s(s6dns_message_rr_srv_t, &srvs) + i) ; if (!len) strerr_diefu1sys(111, "format result") ; if (buffer_put(buffer_1, buf, len) < 0) goto err ; if (buffer_put(buffer_1, "\n", 1) < 0) goto err ; diff --git a/src/clients/s6-dnstxt.c b/src/clients/s6-dnstxt.c index fde69d2..5ee1427 100644 --- a/src/clients/s6-dnstxt.c +++ b/src/clients/s6-dnstxt.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/uint.h> #include <skalibs/bytestr.h> @@ -20,10 +21,11 @@ int main (int argc, char const *const *argv) { stralloc quoted = STRALLOC_ZERO ; stralloc sa = STRALLOC_ZERO ; - genalloc offsets = GENALLOC_ZERO ; /* array of unsigned int */ + genalloc offsets = GENALLOC_ZERO ; /* array of size_t */ tain_t deadline, stamp ; - unsigned int n ; - unsigned int i = 0 ; + size_t n ; + size_t i = 0 ; + unsigned int t = 0 ; int flagqualify = 0 ; int flagunsort = 0 ; PROG = "s6-dnstxt" ; @@ -35,7 +37,7 @@ int main (int argc, char const *const *argv) { case 'q' : flagqualify = 1 ; break ; case 'r' : flagunsort = 1 ; break ; - case 't' : if (!uint0_scan(subgetopt_here.arg, &i)) dieusage() ; break ; + case 't' : if (!uint0_scan(subgetopt_here.arg, &t)) dieusage() ; break ; default : dieusage() ; } } @@ -43,7 +45,7 @@ int main (int argc, char const *const *argv) if (argc < 1) dieusage() ; tain_now(&stamp) ; - if (i) tain_from_millisecs(&deadline, i) ; else deadline = tain_infinite_relative ; + if (t) tain_from_millisecs(&deadline, t) ; else deadline = tain_infinite_relative ; tain_add(&deadline, &deadline, &stamp) ; if (!s6dns_init()) strerr_diefu1sys(111, "s6dns_init") ; { @@ -51,21 +53,21 @@ int main (int argc, char const *const *argv) if (r < 0) strerr_diefu2sys((errno == ETIMEDOUT) ? 99 : 111, "resolve ", argv[0]) ; if (!r) strerr_diefu4x(2, "resolve ", argv[0], ": ", s6dns_constants_error_str(errno)) ; } - n = genalloc_len(unsigned int, &offsets) ; + n = genalloc_len(size_t, &offsets) ; if (!n) return 1 ; { - unsigned int printable_offsets[n] ; + size_t printable_offsets[n] ; for (i = 0 ; i < n ; i++) { - unsigned int beg = genalloc_s(unsigned int, &offsets)[i] ; - unsigned int end = (i < n-1 ? genalloc_s(unsigned int, &offsets)[i+1] : sa.len) - 1 ; + size_t beg = genalloc_s(size_t, &offsets)[i] ; + size_t end = (i < n-1 ? genalloc_s(size_t, &offsets)[i+1] : sa.len) - 1 ; printable_offsets[i] = quoted.len ; if (!string_quote("ed, sa.s + beg, end - beg) || !stralloc_0("ed)) strerr_diefu2sys(111, "quote ", sa.s + beg) ; } - genalloc_free(unsigned int, &offsets) ; + genalloc_free(size_t, &offsets) ; stralloc_free(&sa) ; - if (flagunsort) random_unsort((char *)printable_offsets, n, sizeof(unsigned int)) ; + if (flagunsort) random_unsort((char *)printable_offsets, n, sizeof(size_t)) ; for (i = 0 ; i < n ; i++) if ((buffer_puts(buffer_1small, quoted.s + printable_offsets[i]) < 0) || (buffer_put(buffer_1small, "\n", 1) < 1)) diff --git a/src/clients/s6-randomip.c b/src/clients/s6-randomip.c index 2c1581a..95ce042 100644 --- a/src/clients/s6-randomip.c +++ b/src/clients/s6-randomip.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include <sys/types.h> #include <errno.h> #include <skalibs/uint.h> #include <skalibs/sgetopt.h> @@ -17,7 +18,7 @@ int main (int argc, char const *const *argv) char ip[16] ; unsigned int n ; unsigned int i = 0 ; - unsigned int what = 0 ; + size_t what = 0 ; int finite = 0 ; PROG = "s6-randomip" ; for (;;) @@ -41,7 +42,7 @@ int main (int argc, char const *const *argv) if (!random_init()) strerr_diefu1sys(111, "init random generator") ; for (i = 0 ; !finite || (i < n) ; i++) { - unsigned int len = what ; + size_t len = what ; if (len > 16) { unsigned char c = random_char() ; diff --git a/src/clients/s6dns-generic-filter.h b/src/clients/s6dns-generic-filter.h index 53fa560..8b2c738 100644 --- a/src/clients/s6dns-generic-filter.h +++ b/src/clients/s6dns-generic-filter.h @@ -3,18 +3,19 @@ #ifndef SKADNS_GENERIC_FILTER_H #define SKADNS_GENERIC_FILTER_H -#include <skalibs/uint16.h> +#include <sys/types.h> +#include <stdint.h> #include <skalibs/stralloc.h> #include <s6-dns/s6dns-domain.h> -typedef unsigned int scan_func_t (s6dns_domain_t *, char const *) ; +typedef size_t scan_func_t (s6dns_domain_t *, char const *) ; typedef scan_func_t *scan_func_t_ref ; typedef int fmt_func_t (stralloc *, char const *, unsigned int) ; typedef fmt_func_t *fmt_func_t_ref ; -extern unsigned int s6dns_namescanner (s6dns_domain_t *, char const *) ; +extern size_t s6dns_namescanner (s6dns_domain_t *, char const *) ; extern int s6dns_domainformatter (stralloc *, char const *, unsigned int) ; -extern int s6dns_generic_filter_main (int, char const *const *, char const *const *, uint16, scan_func_t_ref, fmt_func_t_ref, char const *) ; +extern int s6dns_generic_filter_main (int, char const *const *, char const *const *, uint16_t, scan_func_t_ref, fmt_func_t_ref, char const *) ; extern int flag4 ; extern int flag6 ; diff --git a/src/clients/s6dns_generic_filter_main.c b/src/clients/s6dns_generic_filter_main.c index 664edef..6d51e67 100644 --- a/src/clients/s6dns_generic_filter_main.c +++ b/src/clients/s6dns_generic_filter_main.c @@ -1,5 +1,7 @@ /* ISC license. */ +#include <sys/types.h> +#include <stdint.h> #include <errno.h> #include <skalibs/error.h> #include <skalibs/uint16.h> @@ -25,8 +27,8 @@ typedef struct line_s line_t, *line_t_ref ; struct line_s { stralloc swrd ; - unsigned int wpos ; - int dpos ; + size_t wpos ; + ssize_t dpos ; char w[2] ; unsigned int pending : 1 ; } ; @@ -42,14 +44,14 @@ static void line_recycle (line_t *l) int flag4 = 0 ; int flag6 = 0 ; -int s6dns_generic_filter_main (int argc, char const *const *argv, char const *const *envp, uint16 qtype, scan_func_t_ref scanner, fmt_func_t_ref formatter, char const *USAGE) +int s6dns_generic_filter_main (int argc, char const *const *argv, char const *const *envp, uint16_t qtype, scan_func_t_ref scanner, fmt_func_t_ref formatter, char const *USAGE) { skadns_t a = SKADNS_ZERO ; tain_t deadline, tto ; char const *normalformat = "%s=%d%w%r" ; char const *errorformat = "%s=<%e>%w%r" ; - uint16 maxlines = 256 ; - uint16 maxconn = 128 ; + uint16_t maxlines = 256 ; + uint16_t maxconn = 128 ; { subgetopt_t l = SUBGETOPT_ZERO ; unsigned int t = 0 ; @@ -86,13 +88,13 @@ int s6dns_generic_filter_main (int argc, char const *const *argv, char const *co { iopause_fd x[3] = { { .fd = 0, .events = 0, .revents = 0 }, { .fd = 1, .events = 0, .revents = 0 }, { .fd = skadns_fd(&a), .events = 0, .revents = 0 } } ; - uint16 lhead = 0, ltail = 0, numlines = 0, pending = 0 ; + uint16_t lhead = 0, ltail = 0, numlines = 0, pending = 0 ; line_t storage[maxlines+1] ; - uint16 lineindex[maxconn] ; + uint16_t lineindex[maxconn] ; { line_t line_zero = LINE_ZERO ; char const *args[4] = { "", "", "", "" } ; - uint16 i = 0 ; + uint16_t i = 0 ; for (; i <= maxlines ; i++) storage[i] = line_zero ; if (!string_format(&storage[0].swrd, "sdwr", normalformat, args) || !string_format(&storage[0].swrd, "sewr", errorformat, args)) @@ -126,13 +128,13 @@ int s6dns_generic_filter_main (int argc, char const *const *argv, char const *co if (x[2].revents) { register int j = 0 ; - register uint16 const *list ; + register uint16_t const *list ; int n = skadns_update(&a) ; if (n < 0) strerr_diefu1sys(111, "skadns_update") ; list = skadns_list(&a) ; for (; j < n ; j++) { - register uint16 i = lineindex[list[j]] ; + register uint16_t i = lineindex[list[j]] ; register char const *packet = skadns_packet(&a, list[j]) ; if (packet) { @@ -185,7 +187,7 @@ int s6dns_generic_filter_main (int argc, char const *const *argv, char const *co else { tain_t sendlimit ; - uint16 id ; + uint16_t id ; line->w[0] = line->swrd.s[line->wpos] ; line->swrd.s[line->wpos] = 0 ; tain_addsec_g(&sendlimit, 2) ; @@ -209,7 +211,7 @@ int s6dns_generic_filter_main (int argc, char const *const *argv, char const *co for (; ltail != lhead ; ltail = (ltail+1) % (maxlines+1), numlines--) { char *args[4] ; - register line_t_ref line = storage + ltail ; + register line_t *line = storage + ltail ; if (line->pending) break ; args[0] = line->swrd.s ; args[1] = line->dpos < 0 ? (char *)s6dns_constants_error_str(-line->dpos) : line->swrd.s + line->dpos ; diff --git a/src/clients/s6dns_namescanner.c b/src/clients/s6dns_namescanner.c index 136b1e8..c2110d2 100644 --- a/src/clients/s6dns_namescanner.c +++ b/src/clients/s6dns_namescanner.c @@ -1,12 +1,16 @@ /* ISC license. */ +#include <sys/types.h> +#include <limits.h> +#include <errno.h> #include <s6-dns/s6dns-domain.h> #include "s6dns-generic-filter.h" -unsigned int s6dns_namescanner (s6dns_domain_t *d, char const *s) +size_t s6dns_namescanner (s6dns_domain_t *d, char const *s) { - register unsigned int pos = 0 ; + register size_t pos = 0 ; while (s[pos] && (s[pos] != ' ') && (s[pos] != '\t') && (s[pos] != '\r') && (s[pos] != '\n')) pos++ ; + if (pos > UINT_MAX) return (errno = ENAMETOOLONG, 0) ; if (!s6dns_domain_fromstring_noqualify_encode(d, s, pos)) return 0 ; return pos ; } |