diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-07-12 16:53:59 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2023-07-12 16:53:59 +0000 |
commit | 207845f50a8fb54fe8e584928078dc3687399caf (patch) | |
tree | f58eac67edc2dbaba13a48442a2093f76e869991 /src/clients/s6-randomip.c | |
parent | 8cf671e973a4ea2ef7c9ca1321531a7ceeaa5073 (diff) | |
download | s6-dns-207845f50a8fb54fe8e584928078dc3687399caf.tar.xz |
Pass on all clients, add hosts support wherever applicable
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/clients/s6-randomip.c')
-rw-r--r-- | src/clients/s6-randomip.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/clients/s6-randomip.c b/src/clients/s6-randomip.c index 6a43794..158440a 100644 --- a/src/clients/s6-randomip.c +++ b/src/clients/s6-randomip.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include <sys/types.h> +#include <stddef.h> #include <errno.h> #include <skalibs/types.h> @@ -22,22 +22,23 @@ int main (int argc, char const *const *argv) size_t what = 0 ; int finite = 0 ; PROG = "s6-randomip" ; - for (;;) { - int opt = lgetopt(argc, argv, "46n:") ; - if (opt == -1) break ; - switch (opt) + subgetopt l = SUBGETOPT_ZERO ; + for (;;) { - case '4' : what |= 1 ; break ; - case '6' : what |= 2 ; break ; - case 'n' : - if (!uint0_scan(subgetopt_here.arg, &n)) dieusage() ; - finite = 1 ; - break ; - default : dieusage() ; + int opt = subgetopt_r(argc, argv, "46n:", &l) ; + if (opt == -1) break ; + switch (opt) + { + case '4' : what |= 1 ; break ; + case '6' : what |= 2 ; break ; + case 'n' : if (!uint0_scan(l.arg, &n)) dieusage() ; finite = 1 ; + break ; + default : dieusage() ; + } } + argc -= l.ind ; argv += l.ind ; } - argc -= subgetopt_here.ind ; argv += subgetopt_here.ind ; if (!what) what = 1 ; what = 1 << (1 << what) ; for (i = 0 ; !finite || (i < n) ; i++) @@ -52,7 +53,7 @@ int main (int argc, char const *const *argv) random_buf(ip, len) ; len = (len == 16) ? ip6_fmt(fmt, ip) : ip4_fmt(fmt, ip) ; fmt[len++] = '\n' ; - if (buffer_put(buffer_1, fmt, len) < (ssize_t)len) + if (buffer_put(buffer_1, fmt, len) < len) strerr_diefu1sys(111, "write to stdout") ; } if (!buffer_flush(buffer_1)) |