X-Git-Url: https://git.realraum.at/?p=svn42.git;a=blobdiff_plain;f=dart%2Feet.c;fp=dart%2Feet.c;h=0000000000000000000000000000000000000000;hp=aaab7dd15ae7ecb381cc1b6c3c767a1a92b253ba;hb=8e8f26d01ab21db191f62f2732808dcb75e8a74f;hpb=050398149d26f27a0b19971cbcea990574d73a57 diff --git a/dart/eet.c b/dart/eet.c deleted file mode 100644 index aaab7dd..0000000 --- a/dart/eet.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * eet - * - * - * Copyright (C) 2011 Christian Pointner - * - * This file is part of eet. - * - * eet is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * eet is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with eet. If not, see . - */ - -#include -#include -#include -#include -#include -#include - -int write_buf(char* buf, int len) -{ - int i; - for(i=0; i < len;) { - int w = write(1, &(buf[i]), len - i); - if(w < 0) - return w; - - i+=w; - } - return 0; -} - -int main(int argc, char* argv[]) -{ - if(argc < 2) { - fprintf(stderr, "Please specify a path to the fifo\n"); - return 1; - } - int fd = open(argv[1], O_RDONLY); - if(fd < 0) { - perror("open()"); - return 2; - } - - char buf[1024]; - fd_set rfds; - - for(;;) { - FD_ZERO(&rfds); - FD_SET(0, &rfds); - FD_SET(fd, &rfds); - int ret = select(fd+1, &rfds, NULL, NULL, NULL); - - if (ret == -1) { - perror("select()"); - return 3; - } - else { - int i; - for(i = 0; i < 2; i++) { - if(FD_ISSET((i ? fd : 0), &rfds)) { - int r = read((i ? fd : 0), buf, sizeof(buf)); - if(r <=0 ) { - return r; - } - - ret = write_buf(buf, r); - if(ret) return ret; - } - } - } - } - - return 0; -}