From 42f56290e11c8d997968ddf0a93e940696b73381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Wed, 14 Jul 2021 14:22:50 +0200 Subject: Remove r1.c --- r1.c | 76 -------------------------------------------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 r1.c (limited to 'r1.c') diff --git a/r1.c b/r1.c deleted file mode 100644 index d2c0ec5..0000000 --- a/r1.c +++ /dev/null @@ -1,76 +0,0 @@ -#include -#include -#include -#include -#include - -#define MAXBUF 2048 - -fd_set rfds0, rfds1; -struct timeval timeout; - -int -main() -{ - char buf[MAXBUF]; - FILE *in, *out; - int c, i, n, ofd, state; - - if(!(in = fopen("/var/tmp/r.in", "w"))) - err(1, "fopen"); - if(!(out = fopen("/var/tmp/r.out", "r"))) - err(1, "fopen"); - ofd = fileno(out); - - FD_ZERO(&rfds0); - FD_SET(0, &rfds0); - - FD_ZERO(&rfds1); - FD_SET(ofd, &rfds1); - - timeout.tv_sec = 1; - timeout.tv_usec = 0; - - for(state = 0; printf("."); state = !state) - switch(state){ - case 0: - if(!select(0+1, &rfds0, NULL, NULL, &timeout)) - break; - printf("0 ready\n"); - break; - case 1: - if(!select(ofd+1, &rfds1, NULL, NULL, &timeout)) - break; - printf("1 ready\n"); - break; - } - -#if 0 - for(;;){ - printf("."); - FD_ZERO(&read_set); - FD_SET(0, &read_set); - FD_SET(ofd, &read_set); - switch(select(ofd+1, &read_set, NULL, NULL, &timeout)){ - case -1: - err(1, "select"); - break; - case 0: - break; - default: - if(FD_ISSET(0, &read_set)){ - fgets(buf, MAXBUF, stdin); - buf[strcspn(buf, "\n")] = 0; - printf("in: %s\n", buf); - }else if(FD_ISSET(ofd, &read_set)){ - fgets(buf, MAXBUF, stdin); - buf[strcspn(buf, "\n")] = 0; - printf("out: %s\n", buf); - }else{ - printf("?\n"); - } - } - } -#endif - -} -- cgit v1.2.3