shithub: plumbreport

Download patch

ref: dc0e5b6d3069c412ed93f42d80e87680c133bff0
author: kvik <kvik@a-b.xyz>
date: Thu Nov 14 12:46:44 EST 2019

Let there be plumb reports

diff: cannot open b/bin//null: file does not exist: 'b/bin//null'
--- /dev/null
+++ b/bin/plumbreport
@@ -1,0 +1,8 @@
+#!/bin/rc -e
+rfork
+out=/n/chat/chat
+for(p in `{@{cd /mnt/plumb; ls}}){
+	if(! ~ $p (send rules)){
+		plumbeat $p >>$out &
+	}
+}
--- /dev/null
+++ b/eatplumb.c
@@ -1,0 +1,35 @@
+#include <u.h>
+#include <libc.h>
+#include <plumb.h>
+
+void
+usage(void)
+{
+	fprint(2, "usage: %s port\n", argv0);
+	exits("usage");
+}
+
+void
+main(int argc, char *argv[])
+{
+	int fd;
+	char *port;
+	Plumbmsg *m;
+
+	ARGBEGIN{
+	default: usage();
+	}ARGEND;
+	if(argc != 1)
+		usage();
+	port = argv[0];
+	
+	if((fd = plumbopen(port, OREAD)) < 0)
+		sysfatal("plumbopen: %r");
+	fprint(2, "listening on \"%s\"\n", port);
+	for(;;){
+		if((m = plumbrecv(fd)) == nil)
+			sysfatal("plumbrecv: %r");
+		print("* [%s] %s\n", port, m->data);
+		plumbfree(m);
+	}
+}
--- /dev/null
+++ b/mkfile
@@ -1,0 +1,27 @@
+</$objtype/mkfile
+
+BIN=/$objtype/bin
+
+TARGET=bin/eatplumb
+OFILES=obj/eatplumb.$O
+
+stub:VQ:
+	mkdir -p bin obj
+	mk all
+
+all:V: $TARGET
+
+install:V: all
+	cp $TARGET $BIN
+
+uninstall:V:
+	rm -f $BIN/$TARGET
+
+clean:V:
+	rm -f $TARGET obj/*
+
+$TARGET: $OFILES
+	$LD $LDFLAGS -o $target $prereq
+
+obj/%.$O: %.c
+	$CC $CFLAGS -o $target $stem.c