mirror of
https://github.com/irssi/irssi.git
synced 2024-11-03 04:27:19 -05:00
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
This commit is contained in:
parent
e88bd31323
commit
cad6fb2e19
@ -87,6 +87,16 @@ int g_input_add(GIOChannel *source, int condition,
|
|||||||
function, data);
|
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)
|
int g_timeval_cmp(const GTimeVal *tv1, const GTimeVal *tv2)
|
||||||
{
|
{
|
||||||
if (tv1->tv_sec < tv2->tv_sec)
|
if (tv1->tv_sec < tv2->tv_sec)
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#ifndef __MISC_H
|
#ifndef __MISC_H
|
||||||
#define __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] */
|
/* `str' should be type char[MAX_INT_STRLEN] */
|
||||||
#define ltoa(str, num) \
|
#define ltoa(str, num) \
|
||||||
g_snprintf(str, sizeof(str), "%d", num)
|
g_snprintf(str, sizeof(str), "%d", num)
|
||||||
|
@ -70,13 +70,9 @@ static void sig_input(void);
|
|||||||
|
|
||||||
void input_listen_init(int handle)
|
void input_listen_init(int handle)
|
||||||
{
|
{
|
||||||
GIOChannel *stdin_channel;
|
readtag = g_input_add_poll(handle,
|
||||||
|
|
||||||
stdin_channel = g_io_channel_unix_new(handle);
|
|
||||||
readtag = g_input_add_full(stdin_channel,
|
|
||||||
G_PRIORITY_HIGH, G_INPUT_READ,
|
G_PRIORITY_HIGH, G_INPUT_READ,
|
||||||
(GInputFunction) sig_input, NULL);
|
(GInputFunction) sig_input, NULL);
|
||||||
g_io_channel_unref(stdin_channel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void input_listen_deinit(void)
|
void input_listen_deinit(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user