stew

a monorepo of some sort
Log | Files | Refs

commit 8aa2c5a89d869bca13c2b6f64132cc59fc0a6f64
parent 69bc11c0336c314b64477315db4cad848639f97b
Author: Renev Pavel <an2qzavok@gmail.com>
Date:   Sun,  2 Apr 2023 15:03:23 +0000

src sync

Diffstat:
Msrc/mkfile | 2+-
Asrc/poke.c | 37+++++++++++++++++++++++++++++++++++++
Asrc/wdb/print.c | 49+++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 87 insertions(+), 1 deletion(-)

diff --git a/src/mkfile b/src/mkfile @@ -1,5 +1,5 @@ </$objtype/mkfile -TARG=shuf +TARG=shuf poke HFILES= OFILES= </sys/src/cmd/mkmany diff --git a/src/poke.c b/src/poke.c @@ -0,0 +1,37 @@ +/* + simple port checking utility +*/ + +#include <u.h> +#include <libc.h> + +void +usage(void) +{ + fprint(2, "usage: %s addr1 [addr2 addr3 ...]\n", argv0); + exits("usage"); +}; + +void +main(int argc, char **argv) +{ + ARGBEGIN{ + default: + usage(); + }ARGEND + if (argc == 0) usage(); + + char **addr = malloc(sizeof(char *) * argc); + int i; + for (i = 0; i < argc; i++) { + addr[i] = netmkaddr(argv[i], "tcp", "echo"); + if (addr[i] == nil) sysfatal("failed at %s, %r", argv[i]); + } + for (i = 0; i < argc; i++) { + int d = dial(addr[i], nil, nil, nil); + if (d > 0) { + close(d); + print("%s open\n", addr[i]); + } else print("%s closed\n", addr[i]); + } +} diff --git a/src/wdb/print.c b/src/wdb/print.c @@ -0,0 +1,49 @@ +#include <u.h> +#include <libc.h> +#include <bio.h> + +/* + given uuids prints entries for human consumption +*/ + +char *wdb; +char *data; +Biobuf *bout; + +void +usage(void) +{ + fprint(2, "usage: %s uuid [uuid ...]\n", argv0); + exits("usage"); +} + +void +printuuid(char *uuid) +{ + char path[1024]; + sprint(path, "%s/%s", data, uuid); + + Bprint(bout, "%s/\n", path); + +} + +void +main(int argc, char **argv) +{ + ARGBEGIN{ + default: + usage(); + }ARGEND; + + if (argc == 0) usage(); + + bout = Bfdopen(1, OWRITE); + + wdb = smprint("/usr/rpa/lib/wdb"); + data = smprint("%s/data", wdb); + + int i; + for (i = 0; i < argc; i++) { + printuuid(argv[i]); + } +}