diff options
author | Emanuele Giaquinta <exg@irssi.org> | 2008-04-25 08:42:47 +0000 |
---|---|---|
committer | exg <exg@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2008-04-25 08:42:47 +0000 |
commit | cad6fb2e19ef5abb78d880d9a09aa4ebf6a6db24 (patch) | |
tree | 7513d1d6fbac4dc72f441b070633dac1aa251733 /src | |
parent | e88bd3132328cbd80d39ad8f95b308e2d20d04d1 (diff) | |
download | irssi-cad6fb2e19ef5abb78d880d9a09aa4ebf6a6db24.zip |
Refactor code to create a watcher for an fd into a function.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4813 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r-- | src/core/misc.c | 10 | ||||
-rw-r--r-- | src/core/misc.h | 3 | ||||
-rw-r--r-- | src/fe-text/gui-readline.c | 6 |
3 files changed, 14 insertions, 5 deletions
diff --git a/src/core/misc.c b/src/core/misc.c index 186e91f4..dffcac6c 100644 --- a/src/core/misc.c +++ b/src/core/misc.c @@ -87,6 +87,16 @@ int g_input_add(GIOChannel *source, int condition, function, data); } +/* easy way to bypass glib polling of io channel internal buffer */ +int g_input_add_poll(int fd, int priority, int condition, + GInputFunction function, void *data) +{ + GIOChannel *source = g_io_channel_unix_new(fd); + int ret = g_input_add_full(source, priority, condition, function, data); + g_io_channel_unref(source); + return ret; +} + int g_timeval_cmp(const GTimeVal *tv1, const GTimeVal *tv2) { if (tv1->tv_sec < tv2->tv_sec) diff --git a/src/core/misc.h b/src/core/misc.h index 22914bdb..72a48e5f 100644 --- a/src/core/misc.h +++ b/src/core/misc.h @@ -1,6 +1,9 @@ #ifndef __MISC_H #define __MISC_H +int g_input_add_poll(int fd, int priority, int condition, + GInputFunction function, void *data); + /* `str' should be type char[MAX_INT_STRLEN] */ #define ltoa(str, num) \ g_snprintf(str, sizeof(str), "%d", num) diff --git a/src/fe-text/gui-readline.c b/src/fe-text/gui-readline.c index 1b37fde1..6cda7fbb 100644 --- a/src/fe-text/gui-readline.c +++ b/src/fe-text/gui-readline.c @@ -70,13 +70,9 @@ static void sig_input(void); void input_listen_init(int handle) { - GIOChannel *stdin_channel; - - stdin_channel = g_io_channel_unix_new(handle); - readtag = g_input_add_full(stdin_channel, + readtag = g_input_add_poll(handle, G_PRIORITY_HIGH, G_INPUT_READ, (GInputFunction) sig_input, NULL); - g_io_channel_unref(stdin_channel); } void input_listen_deinit(void) |