FIFO's dev in branck 'linkdd'

This commit is contained in:
David Delassus 2011-09-01 16:39:53 +02:00
parent b2aff93c0c
commit bd263930fd
4 changed files with 1 additions and 92 deletions

View File

@ -1,56 +0,0 @@
/*
* wmfs2 by Martin Duquesnoy <xorg62@gmail.com> { 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);
}

View File

@ -1,18 +0,0 @@
/*
* wmfs2 by Martin Duquesnoy <xorg62@gmail.com> { for(i = 2011; i < 2111; ++i) ©(i); }
* File created by David Delassus.
* For license, see COPYING.
*/
#ifndef FIFO_H
#define FIFO_H
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
void fifo_init(void);
void fifo_read(void);
#endif /* FIFO_H */

View File

@ -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;
}

View File

@ -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);