From bd263930fd4bd178509e4659a0a65b8b48ebd3e3 Mon Sep 17 00:00:00 2001 From: David Delassus Date: Thu, 1 Sep 2011 16:39:53 +0200 Subject: [PATCH] FIFO's dev in branck 'linkdd' --- wmfs2/src/fifo.c | 56 ------------------------------------------------ wmfs2/src/fifo.h | 18 ---------------- wmfs2/src/wmfs.c | 11 +--------- wmfs2/src/wmfs.h | 8 ------- 4 files changed, 1 insertion(+), 92 deletions(-) delete mode 100644 wmfs2/src/fifo.c delete mode 100644 wmfs2/src/fifo.h diff --git a/wmfs2/src/fifo.c b/wmfs2/src/fifo.c deleted file mode 100644 index 30cfb8f..0000000 --- a/wmfs2/src/fifo.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * wmfs2 by Martin Duquesnoy { for(i = 2011; i < 2111; ++i) ©(i); } - * File created by David Delassus. - * For license, see COPYING. - */ - -#include "wmfs.h" -#include "fifo.h" -#include "config.h" - -#define FIFO_DEFAULT_PATH "/tmp/wmfs-fifo" - -void -fifo_init(void) -{ - W->fifo.path = FIFO_DEFAULT_PATH; - - if(mkfifo(W->fifo.path, 0644) < 0 - || !(W->fifo.fd = open(W->fifo.path, O_NONBLOCK, 0))) - { - warnx("Can't create FIFO: %s\n", strerror(errno)); - return; - } -} - -static void -fifo_parse(char *cmd) -{ - void (*func)(Uicb cmd); - char *uicb = strtok(cmd, " "); - char *arg = strtok(NULL, "\n"); - - printf("%s %s\n", uicb, arg); - - func = uicb_name_func(uicb); - if(func) - func(arg); - - XSync(W->dpy, false); -} - -void -fifo_read(void) -{ - char buf[256] = {0}; - - /* Don't read it if not open */ - if(!(W->fifo.fd)) - return; - - read(W->fifo.fd, buf, sizeof(buf) - 1); - - if(buf[0]) - fifo_parse(buf); -} - diff --git a/wmfs2/src/fifo.h b/wmfs2/src/fifo.h deleted file mode 100644 index 3c1395e..0000000 --- a/wmfs2/src/fifo.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * wmfs2 by Martin Duquesnoy { for(i = 2011; i < 2111; ++i) ©(i); } - * File created by David Delassus. - * For license, see COPYING. - */ - -#ifndef FIFO_H -#define FIFO_H - -#include -#include -#include -#include - -void fifo_init(void); -void fifo_read(void); - -#endif /* FIFO_H */ diff --git a/wmfs2/src/wmfs.c b/wmfs2/src/wmfs.c index 600f33e..6f745c3 100644 --- a/wmfs2/src/wmfs.c +++ b/wmfs2/src/wmfs.c @@ -15,7 +15,6 @@ #include "util.h" #include "config.h" #include "client.h" -#include "fifo.h" int wmfs_error_handler(Display *d, XErrorEvent *event) @@ -219,9 +218,8 @@ wmfs_loop(void) { FD_ZERO(&iset); FD_SET(fd, &iset); - FD_SET(W->fifo.fd, &iset); - if(select(fd + W->fifo.fd + 1, &iset, NULL, NULL, NULL) > 0) + if(select(fd + 1, &iset, NULL, NULL, NULL) > 0) { if(FD_ISSET(fd, &iset)) { @@ -231,8 +229,6 @@ wmfs_loop(void) HANDLE_EVENT(&ev); } } - else if(FD_ISSET(W->fifo.fd, &iset)) - fifo_read(); } } } @@ -245,7 +241,6 @@ wmfs_init(void) screen_init(); event_init(); config_init(); - fifo_init(); } void @@ -265,10 +260,6 @@ wmfs_quit(void) FREE_LIST(Keybind, W->h.keybind); FREE_LIST(Theme, W->h.theme); - /* FIFO stuffs */ - close(W->fifo.fd); - free(W->fifo.path); - W->running = false; } diff --git a/wmfs2/src/wmfs.h b/wmfs2/src/wmfs.h index 26a031e..cd066d7 100644 --- a/wmfs2/src/wmfs.h +++ b/wmfs2/src/wmfs.h @@ -212,14 +212,6 @@ struct Wmfs * and then selected client. */ Scr33n *screen; - - /* FIFO */ - struct - { - int fd; - char *path; - } fifo; - }; int wmfs_error_handler(Display *d, XErrorEvent *event);