summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorepoch <epoch@hacking.allowed.org>2020-02-05 23:35:26 -0600
committerepoch <epoch@hacking.allowed.org>2020-02-05 23:35:26 -0600
commitfbcf2248e45c3369a963849aa4981cb283ebe755 (patch)
tree30fecf2dca71d5b78479abf48852e4b72011edd6
parentdd1015ea43e32dea0f2120210d69b0c4f2257992 (diff)
downloadhackvr-fbcf2248e45c3369a963849aa4981cb283ebe755.tar.gz
hackvr-fbcf2248e45c3369a963849aa4981cb283ebe755.zip
renamed GNUmakefile back to Makefile and added a tool to help with tailing multiple files in a way that won't block if any run out of data
-rw-r--r--src/Makefile (renamed from src/GNUmakefile)10
-rw-r--r--src/nonblocktail.c21
2 files changed, 28 insertions, 3 deletions
diff --git a/src/GNUmakefile b/src/Makefile
index 3a2c697..c02198f 100644
--- a/src/GNUmakefile
+++ b/src/Makefile
@@ -6,9 +6,12 @@ CFLAGS=-Wall -pedantic -std=c99 -DGRAPHICAL -ffast-math -I$(PREFIX)/include
LDFLAGS=-L$(PREFIX)/lib
#all: hackvr_headless hackvr_x11 hackvr_opengl slowcat ### when hackvr_opengl gets useful at all I'll start including it in default build.
-all: hackvr_headless hackvr_x11
+all: hackvr_headless hackvr_x11 slowcat nonblocktail
# hackvr_fb hackvr_freeglut slowcat
+nonblocktail: LDLIBS=-lidc
+nonblocktail: nonblocktail.c
+
hackvr_headless: LDLIBS=-lm -lidc
hackvr_headless: hackvr_headless.o math.o physics.o
@@ -64,9 +67,10 @@ install: all
install hackvr $(PREFIX)/bin/hackvr
install hackvr_headless $(PREFIX)/bin/hackvr_headless
install hackvr_x11 $(PREFIX)/bin/hackvr_x11
- install hackvr_fb $(PREFIX)/bin/hackvr_fb
- install hackvr_freeglut $(PREFIX)/bin/hackvr_freeglut
install slowcat $(PREFIX)/bin/slowcat
+ install nonblocktail $(PREFIX)/bin/nonblocktail
+# install hackvr_fb $(PREFIX)/bin/hackvr_fb
+# install hackvr_freeglut $(PREFIX)/bin/hackvr_freeglut
uninstall:
rm $(PREFIX)/bin/hackvr
diff --git a/src/nonblocktail.c b/src/nonblocktail.c
new file mode 100644
index 0000000..8b99e64
--- /dev/null
+++ b/src/nonblocktail.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <idc.h>
+#include <fcntl.h>
+
+extern struct idc_global idc;
+
+void handler(struct shit *me,char *line) {
+ if(!line) return;
+ if(line) printf("%s\n",line);
+}
+
+int main(int argc,char *argv[]) {
+ int i;
+ for(i=0;i<100;i++) {
+ idc.fds[i].fd=-1;
+ }
+ for(argv++,argc--;argc;argc--,argv++) {
+ idc.fds[add_fd(open(*argv,O_RDONLY),handler)].keep_open=1;
+ }
+ select_on_everything();
+}